From 873a915e0ad44cb303b071638536f27569491030 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 22 Sep 2016 13:47:48 -0600 Subject: 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 * 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. --- gdb/minsyms.h | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'gdb/minsyms.h') diff --git a/gdb/minsyms.h b/gdb/minsyms.h index 8857f1a..d75bd41 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -53,21 +53,33 @@ struct bound_minimal_symbol as opaque and use functions provided by minsyms.c to inspect them. */ -/* 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. */ +/* 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. */ + + explicit minimal_symbol_reader (); + + ~minimal_symbol_reader (); -void init_minimal_symbol_collection (void); + /* Install the minimal symbols that have been collected into the + given objfile. */ -/* Return a cleanup which is used to clean up the global state left - over by minimal symbol creation. After calling - init_minimal_symbol_collection, a symbol reader should call this - function. Then, after all minimal symbols have been read, - regardless of whether they are installed or not, the cleanup - returned by this function should be run. */ + void install (struct objfile *); -struct cleanup *make_cleanup_discard_minimal_symbols (void); + private: + + /* No need for these. They are intentionally not defined anywhere. */ + minimal_symbol_reader &operator= + (const minimal_symbol_reader &); + minimal_symbol_reader (const minimal_symbol_reader &); +}; /* Record a new minimal symbol. This is the "full" entry point; simpler convenience entry points are also provided below. @@ -122,13 +134,6 @@ struct minimal_symbol *prim_record_minimal_symbol_and_info int section, struct objfile *); -/* Install the minimal symbols that have been collected into the given - objfile. After this is called, the cleanup returned by - make_cleanup_discard_minimal_symbols should be run in order to - clean up global state. */ - -void install_minimal_symbols (struct objfile *); - /* Create the terminating entry of OBJFILE's minimal symbol table. If OBJFILE->msymbols is zero, allocate a single entry from OBJFILE->objfile_obstack; otherwise, just initialize -- cgit v1.1