aboutsummaryrefslogtreecommitdiff
path: root/gdb/minsyms.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2016-09-22 14:25:08 -0600
committerTom Tromey <tom@tromey.com>2016-10-21 14:17:33 -0600
commit8dddcb8f005e8470312bf33041bb6ddaa5084e32 (patch)
treed88f904c0193031ec5215f25f03201d321a558cc /gdb/minsyms.h
parentd25e87199327846e42b5a23f4365d75e75517ab3 (diff)
downloadgdb-8dddcb8f005e8470312bf33041bb6ddaa5084e32.zip
gdb-8dddcb8f005e8470312bf33041bb6ddaa5084e32.tar.gz
gdb-8dddcb8f005e8470312bf33041bb6ddaa5084e32.tar.bz2
Record minimal symbols directly in reader.
This patch changes minimal symbol creation in two ways. First, it removes global variables in favor of members of minimal_symbol_reader. Second, it changes functions like prim_record_minimal_symbol to be member functions of minimal_symbol_reader. 2016-10-21 Tom Tromey <tom@tromey.com> * xcoffread.c (record_minimal_symbol, scan_xcoff_symtab): Add "reader" argument. Update. (xcoff_initial_scan): Update. * symfile.h (mdebug_build_psymtabs): Add "reader" argument. * mipsread.c (mipscoff_symfile_read): Update. (read_alphacoff_dynamic_symtab): Add "reader" argument. Update. * minsyms.h (minimal_symbol_reader) <record, record_full>: Declare. <m_msym_bunch, m_msym_bunch_index, m_msym_count>: New members. <record_with_info>: New function, renamed from prim_record_minimal_symbol_and_info. * minsyms.c (msym_bunch, msym_bunch_index, msym_count): Remove globals. (minimal_symbol_reader): Initialize new members. (minimal_symbol_reader::record): Renamed from prim_record_minimal_symbol. (minimal_symbol_reader::record_full): Renamed from prim_record_minimal_symbol_full. (prim_record_minimal_symbol_and_info): Move to minsyms.h; rename. * mdebugread.c (mdebug_build_psymtabs, parse_partial_symbols) (record_minimal_symbol): Add "reader" argument. Update. (elfmdebug_build_psymtabs): Update. * machoread.c (macho_symtab_add_minsym, macho_symtab_read): Add "reader" argument. Update. (macho_symfile_read): Update. * elfread.c (record_minimal_symbol, elf_symtab_read) (elf_rel_plt_read): Add "reader" argument. Update. (elf_read_minimal_symbols): Update. * dbxread.c (record_minimal_symbol, read_dbx_dynamic_symtab) (read_dbx_symtab): Add "reader" argument. Update. (dbx_symfile_read): Update. * coffread.c (record_minimal_symbol, coff_symtab_read): Add "reader" argument. Update. (coff_symfile_read): Update. * coff-pe-read.h (read_pe_exported_syms): Add "reader" argument. * coff-pe-read.c (add_pe_exported_sym, add_pe_forwarded_sym) (read_pe_exported_syms): Add "reader" argument. Update.
Diffstat (limited to 'gdb/minsyms.h')
-rw-r--r--gdb/minsyms.h120
1 files changed, 66 insertions, 54 deletions
diff --git a/gdb/minsyms.h b/gdb/minsyms.h
index b83e2d0..b22920b 100644
--- a/gdb/minsyms.h
+++ b/gdb/minsyms.h
@@ -53,16 +53,17 @@ struct bound_minimal_symbol
as opaque and use functions provided by minsyms.c to inspect them.
*/
+struct msym_bunch;
+
/* An RAII-based object that is used to record minimal symbols while
they are being read. */
class minimal_symbol_reader
{
public:
- /* Prepare to start collecting minimal symbols. This should be called
- by a symbol reader to initialize the minimal symbol module.
- Currently, minimal symbol table creation is not reentrant; it
- relies on global (static) variables in minsyms.c. */
+ /* Prepare to start collecting minimal symbols. This should be
+ called by a symbol reader to initialize the minimal symbol
+ module. */
explicit minimal_symbol_reader (struct objfile *);
@@ -73,6 +74,56 @@ class minimal_symbol_reader
void install ();
+ /* Record a new minimal symbol. This is the "full" entry point;
+ simpler convenience entry points are also provided below.
+
+ This returns a new minimal symbol. It is ok to modify the returned
+ minimal symbol (though generally not necessary). It is not ok,
+ though, to stash the pointer anywhere; as minimal symbols may be
+ moved after creation. The memory for the returned minimal symbol
+ is still owned by the minsyms.c code, and should not be freed.
+
+ Arguments are:
+
+ NAME - the symbol's name
+ NAME_LEN - the length of the name
+ COPY_NAME - if true, the minsym code must make a copy of NAME. If
+ false, then NAME must be NUL-terminated, and must have a lifetime
+ that is at least as long as OBJFILE's lifetime.
+ ADDRESS - the address of the symbol
+ MS_TYPE - the type of the symbol
+ SECTION - the symbol's section
+ appropriate obj_section for the minimal symbol. This can be NULL.
+ OBJFILE - the objfile associated with the minimal symbol. */
+
+ struct minimal_symbol *record_full (const char *name,
+ int name_len,
+ int copy_name,
+ CORE_ADDR address,
+ enum minimal_symbol_type ms_type,
+ int section);
+
+ /* Like record_full, but:
+ - uses strlen to compute NAME_LEN,
+ - passes COPY_NAME = 1,
+ - and passes a default SECTION, depending on the type
+
+ This variant does not return the new symbol. */
+
+ void record (const char *, CORE_ADDR, enum minimal_symbol_type);
+
+ /* Like record_full, but:
+ - uses strlen to compute NAME_LEN,
+ - passes COPY_NAME = 1. */
+
+ struct minimal_symbol *record_with_info (const char *name,
+ CORE_ADDR address,
+ enum minimal_symbol_type ms_type,
+ int section)
+ {
+ return record_full (name, strlen (name), 1, address, ms_type, section);
+ }
+
private:
/* No need for these. They are intentionally not defined anywhere. */
@@ -81,60 +132,21 @@ class minimal_symbol_reader
minimal_symbol_reader (const minimal_symbol_reader &);
struct objfile *m_objfile;
-};
-/* Record a new minimal symbol. This is the "full" entry point;
- simpler convenience entry points are also provided below.
-
- This returns a new minimal symbol. It is ok to modify the returned
- minimal symbol (though generally not necessary). It is not ok,
- though, to stash the pointer anywhere; as minimal symbols may be
- moved after creation. The memory for the returned minimal symbol
- is still owned by the minsyms.c code, and should not be freed.
-
- Arguments are:
-
- NAME - the symbol's name
- NAME_LEN - the length of the name
- COPY_NAME - if true, the minsym code must make a copy of NAME. If
- false, then NAME must be NUL-terminated, and must have a lifetime
- that is at least as long as OBJFILE's lifetime.
- ADDRESS - the address of the symbol
- MS_TYPE - the type of the symbol
- SECTION - the symbol's section
- appropriate obj_section for the minimal symbol. This can be NULL.
- OBJFILE - the objfile associated with the minimal symbol. */
-
-struct minimal_symbol *prim_record_minimal_symbol_full
- (const char *name,
- int name_len,
- int copy_name,
- CORE_ADDR address,
- enum minimal_symbol_type ms_type,
- int section,
- struct objfile *objfile);
-
-/* Like prim_record_minimal_symbol_full, but:
- - uses strlen to compute NAME_LEN,
- - passes COPY_NAME = 1,
- - and passes a default SECTION, depending on the type
-
- This variant does not return the new symbol. */
+ /* Bunch currently being filled up.
+ The next field points to chain of filled bunches. */
-void prim_record_minimal_symbol (const char *, CORE_ADDR,
- enum minimal_symbol_type,
- struct objfile *);
+ struct msym_bunch *m_msym_bunch;
-/* Like prim_record_minimal_symbol_full, but:
- - uses strlen to compute NAME_LEN,
- - passes COPY_NAME = 1. */
+ /* Number of slots filled in current bunch. */
-struct minimal_symbol *prim_record_minimal_symbol_and_info
- (const char *,
- CORE_ADDR,
- enum minimal_symbol_type,
- int section,
- struct objfile *);
+ int m_msym_bunch_index;
+
+ /* Total number of minimal symbols recorded so far for the
+ objfile. */
+
+ int m_msym_count;
+};
/* Create the terminating entry of OBJFILE's minimal symbol table.
If OBJFILE->msymbols is zero, allocate a single entry from