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/coffread.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'gdb/coffread.c') diff --git a/gdb/coffread.c b/gdb/coffread.c index 830deb58408..67b9cb7eb77 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -568,7 +568,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags) unsigned int num_symbols; int symtab_offset; int stringtab_offset; - struct cleanup *back_to, *cleanup_minimal_symbols; + struct cleanup *back_to; int stabstrsize; info = (struct coff_symfile_info *) objfile_data (objfile, @@ -645,8 +645,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags) if (val < 0) error (_("\"%s\": can't get string table"), name); - init_minimal_symbol_collection (); - cleanup_minimal_symbols = make_cleanup_discard_minimal_symbols (); + minimal_symbol_reader reader; /* Now that the executable file is positioned at symbol table, process it and define symbols accordingly. */ @@ -656,7 +655,7 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags) /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. */ - install_minimal_symbols (objfile); + reader.install (objfile); if (pe_file) { @@ -699,9 +698,6 @@ coff_symfile_read (struct objfile *objfile, int symfile_flags) } } - /* Free the installed minimal symbol data. */ - do_cleanups (cleanup_minimal_symbols); - bfd_map_over_sections (abfd, coff_locate_sections, (void *) info); if (info->stabsects) -- cgit v1.2.1