diff options
author | Pedro Alves <palves@redhat.com> | 2016-10-26 16:47:10 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-10-26 16:47:10 +0100 |
commit | b15cc25cbe7c13e450f77b4a309223b9b3da3936 (patch) | |
tree | a2f0d2c4f5bb63d6915fbd2516d49a2f61c5620e /gdb/objfiles.h | |
parent | 85ad3aaf403d2104c82010494d3d4a93a36e2e6f (diff) | |
download | gdb-b15cc25cbe7c13e450f77b4a309223b9b3da3936.zip gdb-b15cc25cbe7c13e450f77b4a309223b9b3da3936.tar.gz gdb-b15cc25cbe7c13e450f77b4a309223b9b3da3936.tar.bz2 |
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.
Diffstat (limited to 'gdb/objfiles.h')
-rw-r--r-- | gdb/objfiles.h | 54 |
1 files changed, 5 insertions, 49 deletions
diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 87a974c..dbf38e3 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 *); |