aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.h
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 /gdb/symfile.h
parent85ad3aaf403d2104c82010494d3d4a93a36e2e6f (diff)
downloadgdb-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/symfile.h')
-rw-r--r--gdb/symfile.h36
1 files changed, 9 insertions, 27 deletions
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 32902cb..cd94d85 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 *);