diff options
author | Tom Tromey <tom@tromey.com> | 2016-09-22 13:47:48 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2016-10-21 14:17:33 -0600 |
commit | 873a915e0ad44cb303b071638536f27569491030 (patch) | |
tree | 6209436a7e32b15b891764df1e5e2738e33a4ec5 /gdb/minsyms.c | |
parent | 4b6749b9a4680e79affdb9c02ea2f5ba39a54587 (diff) | |
download | gdb-873a915e0ad44cb303b071638536f27569491030.zip gdb-873a915e0ad44cb303b071638536f27569491030.tar.gz gdb-873a915e0ad44cb303b071638536f27569491030.tar.bz2 |
Introduce minimal_symbol_reader
This patch introduced minimal_symbol_reader, a RAII-based class which
replaces the current make_cleanup_discard_minimal_symbols.
2016-10-21 Tom Tromey <tom@tromey.com>
* xcoffread.c (xcoff_initial_scan): Use
minimal_symbol_reader.
* mipsread.c (mipscoff_symfile_read): Use
minimal_symbol_reader.
* minsyms.h (minimal_symbol_reader): New class.
(init_minimal_symbol_collection)
(make_cleanup_discard_minimal_symbols, install_minimal_symbols):
Don't declare.
* minsyms.c (minimal_symbol_reader): Renamed from
init_minimal_symbol_collection, turned into constructor.
(~minimal_symbol_reader): Renamed from
do_discard_minimal_symbols_cleanup, turned into destructor.
(make_cleanup_discard_minimal_symbols): Remove.
(minimal_symbol_reader::install): Rename form
install_minimal_symbols.
* mdebugread.c (elfmdebug_build_psymtabs): Use
minimal_symbol_reader.
* machoread.c (macho_symfile_read): Use
minimal_symbol_reader.
* elfread.c (elf_read_minimal_symbols): Use
minimal_symbol_reader.
* dbxread.c (dbx_symfile_read): Use minimal_symbol_reader.
* coffread.c (coff_symfile_read): Use
minimal_symbol_reader.
Diffstat (limited to 'gdb/minsyms.c')
-rw-r--r-- | gdb/minsyms.c | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/gdb/minsyms.c b/gdb/minsyms.c index b478402..a100d4c 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -921,8 +921,7 @@ get_symbol_leading_char (bfd *abfd) /* See minsyms.h. */ -void -init_minimal_symbol_collection (void) +minimal_symbol_reader::minimal_symbol_reader () { msym_count = 0; msym_bunch = NULL; @@ -932,6 +931,26 @@ init_minimal_symbol_collection (void) msym_bunch_index = BUNCH_SIZE; } +/* Discard the currently collected minimal symbols, if any. If we wish + to save them for later use, we must have already copied them somewhere + else before calling this function. + + FIXME: We could allocate the minimal symbol bunches on their own + obstack and then simply blow the obstack away when we are done with + it. Is it worth the extra trouble though? */ + +minimal_symbol_reader::~minimal_symbol_reader () +{ + struct msym_bunch *next; + + while (msym_bunch != NULL) + { + next = msym_bunch->next; + xfree (msym_bunch); + msym_bunch = next; + } +} + /* See minsyms.h. */ void @@ -1087,37 +1106,6 @@ compare_minimal_symbols (const void *fn1p, const void *fn2p) } } -/* Discard the currently collected minimal symbols, if any. If we wish - to save them for later use, we must have already copied them somewhere - else before calling this function. - - FIXME: We could allocate the minimal symbol bunches on their own - obstack and then simply blow the obstack away when we are done with - it. Is it worth the extra trouble though? */ - -static void -do_discard_minimal_symbols_cleanup (void *arg) -{ - struct msym_bunch *next; - - while (msym_bunch != NULL) - { - next = msym_bunch->next; - xfree (msym_bunch); - msym_bunch = next; - } -} - -/* See minsyms.h. */ - -struct cleanup * -make_cleanup_discard_minimal_symbols (void) -{ - return make_cleanup (do_discard_minimal_symbols_cleanup, 0); -} - - - /* Compact duplicate entries out of a minimal symbol table by walking through the table and compacting out entries with duplicate addresses and matching names. Return the number of entries remaining. @@ -1244,7 +1232,7 @@ build_minimal_symbol_hash_tables (struct objfile *objfile) attempts to demangle them if we later add more minimal symbols. */ void -install_minimal_symbols (struct objfile *objfile) +minimal_symbol_reader::install (struct objfile *objfile) { int bindex; int mcount; |