summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-10-26 16:47:10 +0100
committerPedro Alves <palves@redhat.com>2016-10-26 16:47:10 +0100
commitb15cc25cbe7c13e450f77b4a309223b9b3da3936 (patch)
treea2f0d2c4f5bb63d6915fbd2516d49a2f61c5620e
parent85ad3aaf403d2104c82010494d3d4a93a36e2e6f (diff)
downloadbinutils-gdb-b15cc25cbe7c13e450f77b4a309223b9b3da3936.tar.gz
Make symfile_add_flags and objfile->flags strongly typed
This makes these flag types be "enum flag" types. The benefit is making use of C++'s stronger typing -- mixing the flags types by mistake errors at compile time. This caught one old bug in symbol_file_add_main_1 already, fixed by this patch as well: @@ -1318,7 +1326,7 @@ symbol_file_add_main_1 (const char *args, int from_tty, int flags) what is frameless. */ reinit_frame_cache (); - if ((flags & SYMFILE_NO_READ) == 0) + if ((add_flags & SYMFILE_NO_READ) == 0) set_initial_language (); } Above, "flags" are objfile flags, not symfile_add_flags. So that was actually checking for "flag & OBJF_PSYMTABS_READ", which has the same value as SYMFILE_NO_READ... I moved the flags definitions to separate files to break circular dependencies. Built with --enable-targets=all and tested on x86-64 Fedora 23. gdb/ChangeLog: 2016-10-26 Pedro Alves <palves@redhat.com> * coffread.c (coff_symfile_read): Use symfile_add_flags. * dbxread.c (dbx_symfile_read): Ditto. * elfread.c (elf_symfile_read): Ditto. * inferior.h: Include symfile-add-flags.h. (struct inferior) <symfile_flags>: Now symfile_add_flags. * machoread.c (macho_add_oso_symfile, macho_symfile_read_all_oso) (macho_symfile_read, mipscoff_symfile_read): Use symfile_add_flags. * objfile-flags.h: New file. * objfiles.c (allocate_objfile): Use objfile_flags. * objfiles.h: Include objfile-flags.h. (struct objfile) <flags>: Now an objfile_flags. (OBJF_REORDERED, OBJF_SHARED, OBJF_READNOW, OBJF_USERLOADED) (OBJF_PSYMTABS_READ, OBJF_MAINLINE, OBJF_NOT_FILENAME): Delete. Converted to an enum-flags in objfile-flags.h. (allocate_objfile): Use objfile_flags. * python/py-objfile.c (objfpy_add_separate_debug_file): Remove unnecessary local. * solib.c (solib_read_symbols, solib_add) (reload_shared_libraries_1): Use symfile_add_flags. * solib.h: Include "symfile-add-flags.h". (solib_read_symbols): Use symfile_add_flags. * symfile-add-flags.h: New file. * symfile-debug.c (debug_sym_read): Use symfile_add_flags. * symfile-mem.c (symbol_file_add_from_memory): Use symfile_add_flags. * symfile.c (read_symbols, syms_from_objfile_1) (syms_from_objfile, finish_new_objfile): Use symfile_add_flags. (symbol_file_add_with_addrs): Use symfile_add_flags and objfile_flags. (symbol_file_add_separate): Use symfile_add_flags. (symbol_file_add_from_bfd, symbol_file_add): Use symfile_add_flags and objfile_flags. (symbol_file_add_main_1): : Use objfile_flags. Fix add_flags vs flags confusion. (symbol_file_command): Use objfile_flags. (add_symbol_file_command): Use symfile_add_flags and objfile_flags. (clear_symtab_users): Use symfile_add_flags. * symfile.h: Include "symfile-add-flags.h" and "objfile-flags.h". (struct sym_fns) <sym_read>: Use symfile_add_flags. (clear_symtab_users): Use symfile_add_flags. (enum symfile_add_flags): Delete, moved to symfile-add-flags.h and converted to enum-flags. (symbol_file_add, symbol_file_add_from_bfd) (symbol_file_add_separate): Use symfile_add_flags. * xcoffread.c (xcoff_initial_scan): Use symfile_add_flags.
-rw-r--r--gdb/ChangeLog50
-rw-r--r--gdb/coffread.c2
-rw-r--r--gdb/dbxread.c4
-rw-r--r--gdb/elfread.c2
-rw-r--r--gdb/inferior.h7
-rw-r--r--gdb/machoread.c7
-rw-r--r--gdb/mipsread.c2
-rw-r--r--gdb/objfile-flags.h71
-rw-r--r--gdb/objfiles.c2
-rw-r--r--gdb/objfiles.h54
-rw-r--r--gdb/python/py-objfile.c3
-rw-r--r--gdb/solib.c18
-rw-r--r--gdb/solib.h4
-rw-r--r--gdb/symfile-add-flags.h48
-rw-r--r--gdb/symfile-debug.c4
-rw-r--r--gdb/symfile-mem.c7
-rw-r--r--gdb/symfile.c61
-rw-r--r--gdb/symfile.h36
-rw-r--r--gdb/xcoffread.c4
19 files changed, 257 insertions, 129 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6e24938991e..45e29cc3011 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,55 @@
2016-10-26 Pedro Alves <palves@redhat.com>
+ * coffread.c (coff_symfile_read): Use symfile_add_flags.
+ * dbxread.c (dbx_symfile_read): Ditto.
+ * elfread.c (elf_symfile_read): Ditto.
+ * inferior.h: Include symfile-add-flags.h.
+ (struct inferior) <symfile_flags>: Now symfile_add_flags.
+ * machoread.c (macho_add_oso_symfile, macho_symfile_read_all_oso)
+ (macho_symfile_read, mipscoff_symfile_read): Use
+ symfile_add_flags.
+ * objfile-flags.h: New file.
+ * objfiles.c (allocate_objfile): Use objfile_flags.
+ * objfiles.h: Include objfile-flags.h.
+ (struct objfile) <flags>: Now an objfile_flags.
+ (OBJF_REORDERED, OBJF_SHARED, OBJF_READNOW, OBJF_USERLOADED)
+ (OBJF_PSYMTABS_READ, OBJF_MAINLINE, OBJF_NOT_FILENAME): Delete.
+ Converted to an enum-flags in objfile-flags.h.
+ (allocate_objfile): Use objfile_flags.
+ * python/py-objfile.c (objfpy_add_separate_debug_file): Remove
+ unnecessary local.
+ * solib.c (solib_read_symbols, solib_add)
+ (reload_shared_libraries_1): Use symfile_add_flags.
+ * solib.h: Include "symfile-add-flags.h".
+ (solib_read_symbols): Use symfile_add_flags.
+ * symfile-add-flags.h: New file.
+ * symfile-debug.c (debug_sym_read): Use symfile_add_flags.
+ * symfile-mem.c (symbol_file_add_from_memory): Use
+ symfile_add_flags.
+ * symfile.c (read_symbols, syms_from_objfile_1)
+ (syms_from_objfile, finish_new_objfile): Use symfile_add_flags.
+ (symbol_file_add_with_addrs): Use symfile_add_flags and
+ objfile_flags.
+ (symbol_file_add_separate): Use symfile_add_flags.
+ (symbol_file_add_from_bfd, symbol_file_add): Use symfile_add_flags
+ and objfile_flags.
+ (symbol_file_add_main_1): : Use objfile_flags. Fix add_flags vs
+ flags confusion.
+ (symbol_file_command): Use objfile_flags.
+ (add_symbol_file_command): Use symfile_add_flags and
+ objfile_flags.
+ (clear_symtab_users): Use symfile_add_flags.
+ * symfile.h: Include "symfile-add-flags.h" and "objfile-flags.h".
+ (struct sym_fns) <sym_read>: Use symfile_add_flags.
+ (clear_symtab_users): Use symfile_add_flags.
+ (enum symfile_add_flags): Delete, moved to symfile-add-flags.h and
+ converted to enum-flags.
+ (symbol_file_add, symbol_file_add_from_bfd)
+ (symbol_file_add_separate): Use symfile_add_flags.
+ * xcoffread.c (xcoff_initial_scan): Use symfile_add_flags.
+
+2016-10-26 Pedro Alves <palves@redhat.com>
+
* inferior.h (ALL_NON_EXITED_INFERIORS): New macro.
* infrun.c (do_target_resume): Call target_commit_resume.
(proceed): Defer target_commit_resume while looping over threads,
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 3125fb1d557..501e9011222 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -559,7 +559,7 @@ static bfd *symfile_bfd;
/* Read a symbol file, after initialization by coff_symfile_init. */
static void
-coff_symfile_read (struct objfile *objfile, int symfile_flags)
+coff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
struct coff_symfile_info *info;
bfd *abfd = objfile->obfd;
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index 9e6df696ed1..2230de84944 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -283,7 +283,7 @@ static void dbx_symfile_init (struct objfile *);
static void dbx_new_init (struct objfile *);
-static void dbx_symfile_read (struct objfile *, int);
+static void dbx_symfile_read (struct objfile *, symfile_add_flags);
static void dbx_symfile_finish (struct objfile *);
@@ -520,7 +520,7 @@ record_minimal_symbol (minimal_symbol_reader &reader,
hung off the objfile structure. */
static void
-dbx_symfile_read (struct objfile *objfile, int symfile_flags)
+dbx_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
bfd *sym_bfd;
int val;
diff --git a/gdb/elfread.c b/gdb/elfread.c
index f5aa55e5e82..7349c83dcf6 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1181,7 +1181,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags,
capability even for files compiled without -g. */
static void
-elf_symfile_read (struct objfile *objfile, int symfile_flags)
+elf_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
bfd *abfd = objfile->obfd;
struct elfinfo ei;
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 300cc10cd90..403c0967e69 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -43,6 +43,8 @@ struct target_desc_info;
#include "progspace.h"
#include "registry.h"
+#include "symfile-add-flags.h"
+
struct infcall_suspend_state;
struct infcall_control_state;
@@ -388,9 +390,8 @@ struct inferior
LONGEST exit_code;
/* Default flags to pass to the symbol reading functions. These are
- used whenever a new objfile is created. The valid values come
- from enum symfile_add_flags. */
- int symfile_flags;
+ used whenever a new objfile is created. */
+ symfile_add_flags symfile_flags;
/* Info about an inferior's target description (if it's fetched; the
user supplied description's filename, if any; etc.). */
diff --git a/gdb/machoread.c b/gdb/machoread.c
index 7889b00df31..00f25a48117 100644
--- a/gdb/machoread.c
+++ b/gdb/machoread.c
@@ -430,7 +430,8 @@ macho_resolve_oso_sym_with_minsym (struct objfile *main_objfile, asymbol *sym)
static void
macho_add_oso_symfile (oso_el *oso, bfd *abfd, const char *name,
- struct objfile *main_objfile, int symfile_flags)
+ struct objfile *main_objfile,
+ symfile_add_flags symfile_flags)
{
int storage;
int i;
@@ -632,7 +633,7 @@ macho_add_oso_symfile (oso_el *oso, bfd *abfd, const char *name,
static void
macho_symfile_read_all_oso (VEC (oso_el) **oso_vector_ptr,
struct objfile *main_objfile,
- int symfile_flags)
+ symfile_add_flags symfile_flags)
{
int ix;
VEC (oso_el) *vec = *oso_vector_ptr;
@@ -826,7 +827,7 @@ macho_check_dsym (struct objfile *objfile, char **filenamep)
}
static void
-macho_symfile_read (struct objfile *objfile, int symfile_flags)
+macho_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
bfd *abfd = objfile->obfd;
long storage_needed;
diff --git a/gdb/mipsread.c b/gdb/mipsread.c
index 39af0d335c1..d9cf3bd8a88 100644
--- a/gdb/mipsread.c
+++ b/gdb/mipsread.c
@@ -67,7 +67,7 @@ mipscoff_symfile_init (struct objfile *objfile)
/* Read a symbol file from a file. */
static void
-mipscoff_symfile_read (struct objfile *objfile, int symfile_flags)
+mipscoff_symfile_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
bfd *abfd = objfile->obfd;
diff --git a/gdb/objfile-flags.h b/gdb/objfile-flags.h
new file mode 100644
index 00000000000..da03918bb4b
--- /dev/null
+++ b/gdb/objfile-flags.h
@@ -0,0 +1,71 @@
+/* Definition of objfile flags.
+
+ Copyright (C) 1992-2016 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#if !defined (OBJFILE_FLAGS_H)
+#define OBJFILE_FLAGS_H
+
+#include "common/enum-flags.h"
+
+/* Defines for the objfile flags field. Defined in a separate file to
+ break circular header dependencies. */
+
+enum objfile_flag
+ {
+ /* When an object file has its functions reordered (currently
+ Irix-5.2 shared libraries exhibit this behaviour), we will need
+ an expensive algorithm to locate a partial symtab or symtab via
+ an address. To avoid this penalty for normal object files, we
+ use this flag, whose setting is determined upon symbol table
+ read in. */
+ OBJF_REORDERED = 1 << 0, /* Functions are reordered */
+
+ /* Distinguish between an objfile for a shared library and a
+ "vanilla" objfile. This may come from a target's
+ implementation of the solib interface, from add-symbol-file, or
+ any other mechanism that loads dynamic objects. */
+ OBJF_SHARED = 1 << 1, /* From a shared library */
+
+ /* User requested that this objfile be read in it's entirety. */
+ OBJF_READNOW = 1 << 2, /* Immediate full read */
+
+ /* This objfile was created because the user explicitly caused it
+ (e.g., used the add-symbol-file command). This bit offers a
+ way for run_command to remove old objfile entries which are no
+ longer valid (i.e., are associated with an old inferior), but
+ to preserve ones that the user explicitly loaded via the
+ add-symbol-file command. */
+ OBJF_USERLOADED = 1 << 3, /* User loaded */
+
+ /* Set if we have tried to read partial symtabs for this objfile.
+ This is used to allow lazy reading of partial symtabs. */
+ OBJF_PSYMTABS_READ = 1 << 4,
+
+ /* Set if this is the main symbol file (as opposed to symbol file
+ for dynamically loaded code). */
+ OBJF_MAINLINE = 1 << 5,
+
+ /* ORIGINAL_NAME and OBFD->FILENAME correspond to text description
+ unrelated to filesystem names. It can be for example
+ "<image in memory>". */
+ OBJF_NOT_FILENAME = 1 << 6,
+ };
+
+DEF_ENUM_FLAGS_TYPE (enum objfile_flag, objfile_flags);
+
+#endif /* !defined (OBJFILE_FLAGS_H) */
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 6e66a8e51fe..4dc6a0ae36b 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -366,7 +366,7 @@ build_objfile_section_table (struct objfile *objfile)
simply copied through to the new objfile flags member. */
struct objfile *
-allocate_objfile (bfd *abfd, const char *name, int flags)
+allocate_objfile (bfd *abfd, const char *name, objfile_flags flags)
{
struct objfile *objfile;
char *expanded_name;
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 87a974c7909..dbf38e3f3bd 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -22,6 +22,7 @@
#include "hashtab.h"
#include "gdb_obstack.h" /* For obstack internals. */
+#include "objfile-flags.h"
#include "symfile.h" /* For struct psymbol_allocation_list. */
#include "progspace.h"
#include "registry.h"
@@ -288,10 +289,9 @@ struct objfile
CORE_ADDR addr_low;
- /* Some flag bits for this objfile.
- The values are defined by OBJF_*. */
+ /* Some flag bits for this objfile. */
- unsigned short flags;
+ objfile_flags flags;
/* The program space associated with this objfile. */
@@ -444,54 +444,10 @@ struct objfile
htab_t static_links;
};
-/* Defines for the objfile flag word. */
-
-/* When an object file has its functions reordered (currently Irix-5.2
- shared libraries exhibit this behaviour), we will need an expensive
- algorithm to locate a partial symtab or symtab via an address.
- To avoid this penalty for normal object files, we use this flag,
- whose setting is determined upon symbol table read in. */
-
-#define OBJF_REORDERED (1 << 0) /* Functions are reordered */
-
-/* Distinguish between an objfile for a shared library and a "vanilla"
- objfile. This may come from a target's implementation of the solib
- interface, from add-symbol-file, or any other mechanism that loads
- dynamic objects. */
-
-#define OBJF_SHARED (1 << 1) /* From a shared library */
-
-/* User requested that this objfile be read in it's entirety. */
-
-#define OBJF_READNOW (1 << 2) /* Immediate full read */
-
-/* This objfile was created because the user explicitly caused it
- (e.g., used the add-symbol-file command). This bit offers a way
- for run_command to remove old objfile entries which are no longer
- valid (i.e., are associated with an old inferior), but to preserve
- ones that the user explicitly loaded via the add-symbol-file
- command. */
-
-#define OBJF_USERLOADED (1 << 3) /* User loaded */
-
-/* Set if we have tried to read partial symtabs for this objfile.
- This is used to allow lazy reading of partial symtabs. */
-
-#define OBJF_PSYMTABS_READ (1 << 4)
-
-/* Set if this is the main symbol file
- (as opposed to symbol file for dynamically loaded code). */
-
-#define OBJF_MAINLINE (1 << 5)
-
-/* ORIGINAL_NAME and OBFD->FILENAME correspond to text description unrelated to
- filesystem names. It can be for example "<image in memory>". */
-
-#define OBJF_NOT_FILENAME (1 << 6)
-
/* Declarations for functions defined in objfiles.c */
-extern struct objfile *allocate_objfile (bfd *, const char *name, int);
+extern struct objfile *allocate_objfile (bfd *, const char *name,
+ objfile_flags);
extern struct gdbarch *get_objfile_arch (const struct objfile *);
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index 82df4b20199..1972fb5375e 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -437,7 +437,6 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
static char *keywords[] = { "file_name", NULL };
objfile_object *obj = (objfile_object *) self;
const char *file_name;
- int symfile_flags = 0;
OBJFPY_REQUIRE_VALID (obj);
@@ -448,7 +447,7 @@ objfpy_add_separate_debug_file (PyObject *self, PyObject *args, PyObject *kw)
{
bfd *abfd = symfile_bfd_open (file_name);
- symbol_file_add_separate (abfd, file_name, symfile_flags, obj->objfile);
+ symbol_file_add_separate (abfd, file_name, 0, obj->objfile);
}
CATCH (except, RETURN_MASK_ALL)
{
diff --git a/gdb/solib.c b/gdb/solib.c
index b8c2b4243ae..5067191c577 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -669,7 +669,7 @@ master_so_list (void)
loaded. */
int
-solib_read_symbols (struct so_list *so, int flags)
+solib_read_symbols (struct so_list *so, symfile_add_flags flags)
{
if (so->symbols_loaded)
{
@@ -999,8 +999,10 @@ solib_add (const char *pattern, int from_tty,
{
int any_matches = 0;
int loaded_any_symbols = 0;
- const int flags =
- SYMFILE_DEFER_BP_RESET | (from_tty ? SYMFILE_VERBOSE : 0);
+ symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET;
+
+ if (from_tty)
+ add_flags |= SYMFILE_VERBOSE;
for (gdb = so_list_head; gdb; gdb = gdb->next)
if (! pattern || re_exec (gdb->so_name))
@@ -1024,7 +1026,7 @@ solib_add (const char *pattern, int from_tty,
printf_unfiltered (_("Symbols already loaded for %s\n"),
gdb->so_name);
}
- else if (solib_read_symbols (gdb, flags))
+ else if (solib_read_symbols (gdb, add_flags))
loaded_any_symbols = 1;
}
}
@@ -1357,8 +1359,10 @@ reload_shared_libraries_1 (int from_tty)
char *filename, *found_pathname = NULL;
bfd *abfd;
int was_loaded = so->symbols_loaded;
- const int flags =
- SYMFILE_DEFER_BP_RESET | (from_tty ? SYMFILE_VERBOSE : 0);
+ symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET;
+
+ if (from_tty)
+ add_flags |= SYMFILE_VERBOSE;
filename = tilde_expand (so->so_original_name);
make_cleanup (xfree, filename);
@@ -1407,7 +1411,7 @@ reload_shared_libraries_1 (int from_tty)
if (!got_error
&& (auto_solib_add || was_loaded || libpthread_solib_p (so)))
- solib_read_symbols (so, flags);
+ solib_read_symbols (so, add_flags);
}
}
diff --git a/gdb/solib.h b/gdb/solib.h
index 00fd6cb4bfb..8116b1d24d3 100644
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -26,6 +26,8 @@ struct target_ops;
struct target_so_ops;
struct program_space;
+#include "symfile-add-flags.h"
+
/* Called when we free all symtabs, to free the shared library information
as well. */
@@ -34,7 +36,7 @@ extern void clear_solib (void);
/* Called to add symbols from a shared library to gdb's symbol table. */
extern void solib_add (const char *, int, struct target_ops *, int);
-extern int solib_read_symbols (struct so_list *, int);
+extern int solib_read_symbols (struct so_list *, symfile_add_flags);
/* Function to be called when the inferior starts up, to discover the
names of shared libraries that are dynamically linked, the base
diff --git a/gdb/symfile-add-flags.h b/gdb/symfile-add-flags.h
new file mode 100644
index 00000000000..c7f5d795d75
--- /dev/null
+++ b/gdb/symfile-add-flags.h
@@ -0,0 +1,48 @@
+/* Definition of symfile add flags.
+
+ Copyright (C) 1990-2016 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#if !defined (SYMFILE_ADD_FLAGS_H)
+#define SYMFILE_ADD_FLAGS_H
+
+#include "common/enum-flags.h"
+
+/* This enum encodes bit-flags passed as ADD_FLAGS parameter to
+ symbol_file_add, etc. Defined in a separate file to break circular
+ header dependencies. */
+
+enum symfile_add_flag
+ {
+ /* Be chatty about what you are doing. */
+ SYMFILE_VERBOSE = 1 << 1,
+
+ /* This is the main symbol file (as opposed to symbol file for
+ dynamically loaded code). */
+ SYMFILE_MAINLINE = 1 << 2,
+
+ /* Do not call breakpoint_re_set when adding this symbol file. */
+ SYMFILE_DEFER_BP_RESET = 1 << 3,
+
+ /* Do not immediately read symbols for this file. By default,
+ symbols are read when the objfile is created. */
+ SYMFILE_NO_READ = 1 << 4
+ };
+
+DEF_ENUM_FLAGS_TYPE (enum symfile_add_flag, symfile_add_flags);
+
+#endif /* !defined(SYMFILE_ADD_FLAGS_H) */
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 0792b7113b4..a361dab29aa 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -442,14 +442,14 @@ debug_sym_init (struct objfile *objfile)
}
static void
-debug_sym_read (struct objfile *objfile, int symfile_flags)
+debug_sym_read (struct objfile *objfile, symfile_add_flags symfile_flags)
{
const struct debug_sym_fns_data *debug_data
= ((const struct debug_sym_fns_data *)
objfile_data (objfile, symfile_debug_objfile_data_key));
fprintf_filtered (gdb_stdlog, "sf->sym_read (%s, 0x%x)\n",
- objfile_debug_name (objfile), symfile_flags);
+ objfile_debug_name (objfile), (unsigned) symfile_flags);
debug_data->real_sf->sym_read (objfile, symfile_flags);
}
diff --git a/gdb/symfile-mem.c b/gdb/symfile-mem.c
index 79739a601fe..58257b91e4a 100644
--- a/gdb/symfile-mem.c
+++ b/gdb/symfile-mem.c
@@ -91,6 +91,7 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
struct section_addr_info *sai;
unsigned int i;
struct cleanup *cleanup;
+ symfile_add_flags add_flags = 0;
if (bfd_get_flavour (templ) != bfd_target_elf_flavour)
error (_("add-symbol-file-from-memory not supported for this target"));
@@ -126,9 +127,11 @@ symbol_file_add_from_memory (struct bfd *templ, CORE_ADDR addr,
}
sai->num_sections = i;
+ if (from_tty)
+ add_flags |= SYMFILE_VERBOSE;
+
objf = symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd),
- from_tty ? SYMFILE_VERBOSE : 0,
- sai, OBJF_SHARED, NULL);
+ add_flags, sai, OBJF_SHARED, NULL);
add_target_sections_of_objfile (objf);
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 7eb6cdc0c44..616fef0f8c2 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -85,7 +85,8 @@ int readnow_symbol_files; /* Read full symbols immediately. */
static void load_command (char *, int);
-static void symbol_file_add_main_1 (const char *args, int from_tty, int flags);
+static void symbol_file_add_main_1 (const char *args, int from_tty,
+ objfile_flags flags);
static void add_symbol_file_command (char *, int);
@@ -865,7 +866,7 @@ default_symfile_segments (bfd *abfd)
possibly force the partial symbols to be read. */
static void
-read_symbols (struct objfile *objfile, int add_flags)
+read_symbols (struct objfile *objfile, symfile_add_flags add_flags)
{
(*objfile->sf->sym_read) (objfile, add_flags);
objfile->per_bfd->minsyms_read = 1;
@@ -994,7 +995,7 @@ init_entry_point_info (struct objfile *objfile)
static void
syms_from_objfile_1 (struct objfile *objfile,
struct section_addr_info *addrs,
- int add_flags)
+ symfile_add_flags add_flags)
{
struct section_addr_info *local_addr = NULL;
struct cleanup *old_chain;
@@ -1085,7 +1086,7 @@ syms_from_objfile_1 (struct objfile *objfile,
static void
syms_from_objfile (struct objfile *objfile,
struct section_addr_info *addrs,
- int add_flags)
+ symfile_add_flags add_flags)
{
syms_from_objfile_1 (objfile, addrs, add_flags);
init_entry_point_info (objfile);
@@ -1096,7 +1097,7 @@ syms_from_objfile (struct objfile *objfile,
objfile. ADD_FLAGS is a bitmask of enum symfile_add_flags. */
static void
-finish_new_objfile (struct objfile *objfile, int add_flags)
+finish_new_objfile (struct objfile *objfile, symfile_add_flags add_flags)
{
/* If this is the main symbol file we have to clean up all users of the
old main symbol file. Otherwise it is sufficient to fixup all the
@@ -1138,9 +1139,10 @@ finish_new_objfile (struct objfile *objfile, int add_flags)
Upon failure, jumps back to command level (never returns). */
static struct objfile *
-symbol_file_add_with_addrs (bfd *abfd, const char *name, int add_flags,
+symbol_file_add_with_addrs (bfd *abfd, const char *name,
+ symfile_add_flags add_flags,
struct section_addr_info *addrs,
- int flags, struct objfile *parent)
+ objfile_flags flags, struct objfile *parent)
{
struct objfile *objfile;
const int from_tty = add_flags & SYMFILE_VERBOSE;
@@ -1164,8 +1166,9 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, int add_flags,
&& !query (_("Load new symbol table from \"%s\"? "), name))
error (_("Not confirmed."));
- objfile = allocate_objfile (abfd, name,
- flags | (mainline ? OBJF_MAINLINE : 0));
+ if (mainline)
+ flags |= OBJF_MAINLINE;
+ objfile = allocate_objfile (abfd, name, flags);
if (parent)
add_separate_debug_objfile (objfile, parent);
@@ -1242,7 +1245,8 @@ symbol_file_add_with_addrs (bfd *abfd, const char *name, int add_flags,
see allocate_objfile's definition. */
void
-symbol_file_add_separate (bfd *bfd, const char *name, int symfile_flags,
+symbol_file_add_separate (bfd *bfd, const char *name,
+ symfile_add_flags symfile_flags,
struct objfile *objfile)
{
struct section_addr_info *sap;
@@ -1268,9 +1272,10 @@ symbol_file_add_separate (bfd *bfd, const char *name, int symfile_flags,
See symbol_file_add_with_addrs's comments for details. */
struct objfile *
-symbol_file_add_from_bfd (bfd *abfd, const char *name, int add_flags,
+symbol_file_add_from_bfd (bfd *abfd, const char *name,
+ symfile_add_flags add_flags,
struct section_addr_info *addrs,
- int flags, struct objfile *parent)
+ objfile_flags flags, struct objfile *parent)
{
return symbol_file_add_with_addrs (abfd, name, add_flags, addrs, flags,
parent);
@@ -1280,8 +1285,8 @@ symbol_file_add_from_bfd (bfd *abfd, const char *name, int add_flags,
loaded file. See symbol_file_add_with_addrs's comments for details. */
struct objfile *
-symbol_file_add (const char *name, int add_flags,
- struct section_addr_info *addrs, int flags)
+symbol_file_add (const char *name, symfile_add_flags add_flags,
+ struct section_addr_info *addrs, objfile_flags flags)
{
bfd *bfd = symfile_bfd_open (name);
struct cleanup *cleanup = make_cleanup_bfd_unref (bfd);
@@ -1307,10 +1312,13 @@ symbol_file_add_main (const char *args, int from_tty)
}
static void
-symbol_file_add_main_1 (const char *args, int from_tty, int flags)
+symbol_file_add_main_1 (const char *args, int from_tty, objfile_flags flags)
{
- const int add_flags = (current_inferior ()->symfile_flags
- | SYMFILE_MAINLINE | (from_tty ? SYMFILE_VERBOSE : 0));
+ symfile_add_flags add_flags = (current_inferior ()->symfile_flags
+ | SYMFILE_MAINLINE);
+
+ if (from_tty)
+ add_flags |= SYMFILE_VERBOSE;
symbol_file_add (args, add_flags, NULL, flags);
@@ -1318,7 +1326,7 @@ symbol_file_add_main_1 (const char *args, int from_tty, int flags)
what is frameless. */
reinit_frame_cache ();
- if ((flags & SYMFILE_NO_READ) == 0)
+ if ((add_flags & SYMFILE_NO_READ) == 0)
set_initial_language ();
}
@@ -1646,7 +1654,7 @@ symbol_file_command (char *args, int from_tty)
else
{
char **argv = gdb_buildargv (args);
- int flags = OBJF_USERLOADED;
+ objfile_flags flags = OBJF_USERLOADED;
struct cleanup *cleanups;
char *name = NULL;
@@ -2222,7 +2230,6 @@ add_symbol_file_command (char *args, int from_tty)
{
struct gdbarch *gdbarch = get_current_arch ();
char *filename = NULL;
- int flags = OBJF_USERLOADED | OBJF_SHARED;
char *arg;
int section_index = 0;
int argcnt = 0;
@@ -2232,6 +2239,11 @@ add_symbol_file_command (char *args, int from_tty)
int expecting_sec_addr = 0;
char **argv;
struct objfile *objf;
+ objfile_flags flags = OBJF_USERLOADED | OBJF_SHARED;
+ symfile_add_flags add_flags = 0;
+
+ if (from_tty)
+ add_flags |= SYMFILE_VERBOSE;
struct sect_opt
{
@@ -2357,8 +2369,7 @@ add_symbol_file_command (char *args, int from_tty)
if (from_tty && (!query ("%s", "")))
error (_("Not confirmed."));
- objf = symbol_file_add (filename, from_tty ? SYMFILE_VERBOSE : 0,
- section_addrs, flags);
+ objf = symbol_file_add (filename, add_flags, section_addrs, flags);
add_target_sections_of_objfile (objf);
@@ -2937,11 +2948,11 @@ add_compunit_symtab_to_objfile (struct compunit_symtab *cu)
}
-/* Reset all data structures in gdb which may contain references to symbol
- table data. ADD_FLAGS is a bitmask of enum symfile_add_flags. */
+/* Reset all data structures in gdb which may contain references to
+ symbol table data. */
void
-clear_symtab_users (int add_flags)
+clear_symtab_users (symfile_add_flags add_flags)
{
/* Someday, we should do better than this, by only blowing away
the things that really need to be blown. */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 32902cb26b0..cd94d855850 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -23,6 +23,8 @@
/* This file requires that you first include "bfd.h". */
#include "symtab.h"
#include "probe.h"
+#include "symfile-add-flags.h"
+#include "objfile-flags.h"
/* Opaque declarations. */
struct target_section;
@@ -347,7 +349,7 @@ struct sym_fns
file we are reading. SYMFILE_FLAGS are the flags passed to
symbol_file_add & co. */
- void (*sym_read) (struct objfile *, int);
+ void (*sym_read) (struct objfile *, symfile_add_flags);
/* Read the partial symbols for an objfile. This may be NULL, in which case
gdb has to check other ways if this objfile has any symbols. This may
@@ -436,7 +438,7 @@ extern void add_compunit_symtab_to_objfile (struct compunit_symtab *cu);
extern void add_symtab_fns (enum bfd_flavour flavour, const struct sym_fns *);
-extern void clear_symtab_users (int add_flags);
+extern void clear_symtab_users (symfile_add_flags add_flags);
extern enum language deduce_language_from_filename (const char *);
@@ -445,34 +447,14 @@ extern enum language deduce_language_from_filename (const char *);
function. */
extern void add_filename_language (const char *ext, enum language lang);
-/* This enum encodes bit-flags passed as ADD_FLAGS parameter to
- symbol_file_add, etc. */
+extern struct objfile *symbol_file_add (const char *, symfile_add_flags,
+ struct section_addr_info *, objfile_flags);
-enum symfile_add_flags
- {
- /* Be chatty about what you are doing. */
- SYMFILE_VERBOSE = 1 << 1,
-
- /* This is the main symbol file (as opposed to symbol file for dynamically
- loaded code). */
- SYMFILE_MAINLINE = 1 << 2,
-
- /* Do not call breakpoint_re_set when adding this symbol file. */
- SYMFILE_DEFER_BP_RESET = 1 << 3,
-
- /* Do not immediately read symbols for this file. By default,
- symbols are read when the objfile is created. */
- SYMFILE_NO_READ = 1 << 4
- };
-
-extern struct objfile *symbol_file_add (const char *, int,
- struct section_addr_info *, int);
-
-extern struct objfile *symbol_file_add_from_bfd (bfd *, const char *, int,
+extern struct objfile *symbol_file_add_from_bfd (bfd *, const char *, symfile_add_flags,
struct section_addr_info *,
- int, struct objfile *parent);
+ objfile_flags, struct objfile *parent);
-extern void symbol_file_add_separate (bfd *, const char *, int,
+extern void symbol_file_add_separate (bfd *, const char *, symfile_add_flags,
struct objfile *);
extern char *find_separate_debug_file_by_debuglink (struct objfile *);
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 974152f8091..90d07531dfd 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -195,7 +195,7 @@ eb_complaint (int arg1)
_("Mismatched .eb symbol ignored starting at symnum %d"), arg1);
}
-static void xcoff_initial_scan (struct objfile *, int);
+static void xcoff_initial_scan (struct objfile *, symfile_add_flags);
static void scan_xcoff_symtab (minimal_symbol_reader &,
struct objfile *);
@@ -2925,7 +2925,7 @@ xcoff_get_toc_offset (struct objfile *objfile)
loaded). */
static void
-xcoff_initial_scan (struct objfile *objfile, int symfile_flags)
+xcoff_initial_scan (struct objfile *objfile, symfile_add_flags symfile_flags)
{
bfd *abfd;
int val;