From 5325b9bf1ee283c40f076334eb3ea66e1f0a6ade Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 23 Nov 2018 17:32:08 -0700 Subject: Remove ALL_MSYMBOLS and ALL_OBJFILE_MSYMBOLS This removes the ALL_MSYMBOLS and ALL_OBJFILE_MSYMBOLS macros, replacing their uses with ranged for loops. In a couple of spots, a new declaration was needed in order to work around shadowing; these are just temporary and are removed in a subsequent patch. gdb/ChangeLog 2019-01-09 Tom Tromey * symtab.c (search_symbols) (default_collect_symbol_completion_matches_break_on): Use objfile_msymbols. * ada-lang.c (ada_lookup_simple_minsym) (ada_collect_symbol_completion_matches): Use objfile_msymbols. * minsyms.c (find_solib_trampoline_target): Use objfile_msymbols. * hppa-tdep.c (hppa_lookup_stub_minimal_symbol): Use objfile_msymbols. * coffread.c (coff_symfile_read): Use objfile_msymbols. * symmisc.c (dump_msymbols): Use objfile_msymbols. * objc-lang.c (find_methods): Use objfile_msymbols. (info_selectors_command, info_classes_command): Likewise. * stabsread.c (scan_file_globals): Use objfile_msymbols. * objfiles.h (class objfile_msymbols): New. (ALL_OBJFILE_MSYMBOLS): Remove. (ALL_MSYMBOLS): Remove. --- gdb/ada-lang.c | 89 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 43 deletions(-) (limited to 'gdb/ada-lang.c') diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index f462f68..e23a6fa 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -4913,8 +4913,6 @@ struct bound_minimal_symbol ada_lookup_simple_minsym (const char *name) { struct bound_minimal_symbol result; - struct objfile *objfile; - struct minimal_symbol *msymbol; memset (&result, 0, sizeof (result)); @@ -4924,16 +4922,19 @@ ada_lookup_simple_minsym (const char *name) symbol_name_matcher_ftype *match_name = ada_get_symbol_name_matcher (lookup_name); - ALL_MSYMBOLS (objfile, msymbol) - { - if (match_name (MSYMBOL_LINKAGE_NAME (msymbol), lookup_name, NULL) - && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline) - { - result.minsym = msymbol; - result.objfile = objfile; - break; - } - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + for (minimal_symbol *msymbol : objfile_msymbols (objfile)) + { + if (match_name (MSYMBOL_LINKAGE_NAME (msymbol), lookup_name, NULL) + && MSYMBOL_TYPE (msymbol) != mst_solib_trampoline) + { + result.minsym = msymbol; + result.objfile = objfile; + break; + } + } + } return result; } @@ -6391,8 +6392,6 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker, { struct symbol *sym; struct compunit_symtab *s; - struct minimal_symbol *msymbol; - struct objfile *objfile; const struct block *b, *surrounding_static_block = 0; struct block_iterator iter; @@ -6412,35 +6411,38 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker, anything that isn't a text symbol (everything else will be handled by the psymtab code above). */ - ALL_MSYMBOLS (objfile, msymbol) - { - QUIT; - - if (completion_skip_symbol (mode, msymbol)) - continue; - - language symbol_language = MSYMBOL_LANGUAGE (msymbol); - - /* Ada minimal symbols won't have their language set to Ada. If - we let completion_list_add_name compare using the - default/C-like matcher, then when completing e.g., symbols in a - package named "pck", we'd match internal Ada symbols like - "pckS", which are invalid in an Ada expression, unless you wrap - them in '<' '>' to request a verbatim match. - - Unfortunately, some Ada encoded names successfully demangle as - C++ symbols (using an old mangling scheme), such as "name__2Xn" - -> "Xn::name(void)" and thus some Ada minimal symbols end up - with the wrong language set. Paper over that issue here. */ - if (symbol_language == language_auto - || symbol_language == language_cplus) - symbol_language = language_ada; - - completion_list_add_name (tracker, - symbol_language, - MSYMBOL_LINKAGE_NAME (msymbol), - lookup_name, text, word); - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + for (minimal_symbol *msymbol : objfile_msymbols (objfile)) + { + QUIT; + + if (completion_skip_symbol (mode, msymbol)) + continue; + + language symbol_language = MSYMBOL_LANGUAGE (msymbol); + + /* Ada minimal symbols won't have their language set to Ada. If + we let completion_list_add_name compare using the + default/C-like matcher, then when completing e.g., symbols in a + package named "pck", we'd match internal Ada symbols like + "pckS", which are invalid in an Ada expression, unless you wrap + them in '<' '>' to request a verbatim match. + + Unfortunately, some Ada encoded names successfully demangle as + C++ symbols (using an old mangling scheme), such as "name__2Xn" + -> "Xn::name(void)" and thus some Ada minimal symbols end up + with the wrong language set. Paper over that issue here. */ + if (symbol_language == language_auto + || symbol_language == language_cplus) + symbol_language = language_ada; + + completion_list_add_name (tracker, + symbol_language, + MSYMBOL_LINKAGE_NAME (msymbol), + lookup_name, text, word); + } + } /* Search upwards from currently selected frame (so that we can complete on local vars. */ @@ -6465,6 +6467,7 @@ ada_collect_symbol_completion_matches (completion_tracker &tracker, /* Go through the symtabs and check the externs and statics for symbols which match. */ + struct objfile *objfile; ALL_COMPUNITS (objfile, s) { QUIT; -- cgit v1.1