diff options
author | Tom Tromey <tom@tromey.com> | 2018-11-23 12:20:05 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-01-09 18:28:14 -0700 |
commit | aed57c537116ae91f553ac835b3f96d1f87b3bb0 (patch) | |
tree | c2699609b04041be0ab313616b8a20e771a7a47e /gdb/symtab.c | |
parent | 99d89cdea6c296bdd94ce532350d139d3900ff78 (diff) | |
download | binutils-gdb-aed57c537116ae91f553ac835b3f96d1f87b3bb0.tar.gz |
Remove most uses of ALL_OBJFILES
This removes most uses of ALL_OBJFILES, replacing them with ranged for
loops. The remaining uses are all in macros, and will be removed in
subsequent patches.
gdb/ChangeLog
2019-01-09 Tom Tromey <tom@tromey.com>
* symtab.c (iterate_over_symtabs, matching_obj_sections)
(expand_symtab_containing_pc, lookup_static_symbol)
(basic_lookup_transparent_type, find_pc_sect_compunit_symtab)
(find_symbol_at_address, find_line_symtab, find_main_name): Use
all_objfiles.
* probe.c (find_probe_by_pc, collect_probes): Use all_objfiles.
* breakpoint.c (create_overlay_event_breakpoint)
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint): Use all_objfiles.
* linux-thread-db.c (try_thread_db_load_from_pdir)
(has_libpthread): Use all_objfiles.
* ada-lang.c (add_nonlocal_symbols): Use all_objfiles.
* linespec.c (iterate_over_all_matching_symtabs)
(search_minsyms_for_name): Use all_objfiles.
* maint.c (maintenance_info_sections): Use all_objfiles.
* main.c (captured_main_1): Use all_objfiles.
* spu-tdep.c (spu_objfile_from_frame): Use all_objfiles.
* guile/scm-objfile.c (gdbscm_objfiles): Use all_objfiles.
* guile/scm-pretty-print.c
(ppscm_find_pretty_printer_from_objfiles): Use all_objfiles.
* solib-spu.c (append_ocl_sos): Use all_objfiles.
* symmisc.c (maintenance_print_symbols): Use all_objfiles.
(maintenance_print_msymbols): Use all_objfiles.
* source.c (select_source_symtab): Use all_objfiles.
* jit.c (jit_find_objf_with_entry_addr): Use all_objfiles.
* symfile.c (remove_symbol_file_command)
(expand_symtabs_matching, map_symbol_filenames): Use
all_objfiles.
* ppc-linux-tdep.c (ppc_linux_spe_context_inferior_created): Use
all_objfiles.
* dwarf2-frame.c (dwarf2_frame_find_fde): Use all_objfiles.
* objc-lang.c (find_methods): Use all_objfiles.
* objfiles.c (have_partial_symbols, have_full_symbols)
(have_minimal_symbols, qsort_cmp)
(default_iterate_over_objfiles_in_search_order): Use
all_objfiles.
* hppa-tdep.c (find_unwind_entry): Use all_objfiles.
* psymtab.c (maintenance_print_psymbols): Use all_objfiles.
(maintenance_check_psymtabs): Use all_objfiles.
(ALL_PSYMTABS): Remove.
* compile/compile-object-run.c (do_module_cleanup): Use
all_objfiles.
* blockframe.c (find_pc_partial_function): Use all_objfiles.
* cp-support.c (add_symbol_overload_list_qualified): Use
all_objfiles.
* windows-tdep.c (windows_iterate_over_objfiles_in_search_order):
Use all_objfiles.
* dwarf-index-write.c (save_gdb_index_command): Use all_objfiles.
* python/py-xmethods.c (gdbpy_get_matching_xmethod_workers): Use
all_objfiles.
* python/py-objfile.c (objfpy_lookup_objfile_by_name)
(objfpy_lookup_objfile_by_build_id): Use all_objfiles.
* python/py-prettyprint.c (find_pretty_printer_from_objfiles):
Uses all_objfiles.
* solib.c (solib_read_symbols): Use all_objfiles
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r-- | gdb/symtab.c | 210 |
1 files changed, 103 insertions, 107 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c index aad60931b58..17ee94607e2 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -464,7 +464,6 @@ void iterate_over_symtabs (const char *name, gdb::function_view<bool (symtab *)> callback) { - struct objfile *objfile; gdb::unique_xmalloc_ptr<char> real_path; /* Here we are interested in canonicalizing an absolute path, not @@ -475,7 +474,7 @@ iterate_over_symtabs (const char *name, gdb_assert (IS_ABSOLUTE_PATH (real_path.get ())); } - ALL_OBJFILES (objfile) + for (objfile *objfile : all_objfiles (current_program_space)) { if (iterate_over_some_symtabs (name, real_path.get (), objfile->compunit_symtabs, NULL, @@ -486,7 +485,7 @@ iterate_over_symtabs (const char *name, /* Same search rules as above apply here, but now we look thru the psymtabs. */ - ALL_OBJFILES (objfile) + for (objfile *objfile : all_objfiles (current_program_space)) { if (objfile->sf && objfile->sf->qf->map_symtabs_matching_filename (objfile, @@ -1013,9 +1012,12 @@ matching_obj_sections (struct obj_section *obj_first, /* Otherwise check that they are in corresponding objfiles. */ - ALL_OBJFILES (obj) - if (obj->obfd == first->owner) - break; + for (objfile *objfile : all_objfiles (current_program_space)) + if (objfile->obfd == first->owner) + { + obj = objfile; + break; + } gdb_assert (obj != NULL); if (obj->separate_debug_objfile != NULL @@ -1033,7 +1035,6 @@ matching_obj_sections (struct obj_section *obj_first, void expand_symtab_containing_pc (CORE_ADDR pc, struct obj_section *section) { - struct objfile *objfile; struct bound_minimal_symbol msymbol; /* If we know that this is not a text address, return failure. This is @@ -1048,16 +1049,16 @@ expand_symtab_containing_pc (CORE_ADDR pc, struct obj_section *section) || MSYMBOL_TYPE (msymbol.minsym) == mst_file_bss)) return; - ALL_OBJFILES (objfile) - { - struct compunit_symtab *cust = NULL; + for (objfile *objfile : all_objfiles (current_program_space)) + { + struct compunit_symtab *cust = NULL; - if (objfile->sf) - cust = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol, - pc, section, 0); - if (cust) - return; - } + if (objfile->sf) + cust = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol, + pc, section, 0); + if (cust) + return; + } } /* Hash function for the symbol cache. */ @@ -2576,7 +2577,6 @@ struct block_symbol lookup_static_symbol (const char *name, const domain_enum domain) { struct symbol_cache *cache = get_symbol_cache (current_program_space); - struct objfile *objfile; struct block_symbol result; struct block_symbol_cache *bsc; struct symbol_cache_slot *slot; @@ -2592,7 +2592,7 @@ lookup_static_symbol (const char *name, const domain_enum domain) return result; } - ALL_OBJFILES (objfile) + for (objfile *objfile : all_objfiles (current_program_space)) { result = lookup_symbol_in_objfile (objfile, STATIC_BLOCK, name, domain); if (result.symbol != NULL) @@ -2793,7 +2793,6 @@ basic_lookup_transparent_type_1 (struct objfile *objfile, int block_index, struct type * basic_lookup_transparent_type (const char *name) { - struct objfile *objfile; struct type *t; /* Now search all the global symbols. Do the symtab's first, then @@ -2801,19 +2800,19 @@ basic_lookup_transparent_type (const char *name) of the desired name as a global, then do psymtab-to-symtab conversion on the fly and return the found symbol. */ - ALL_OBJFILES (objfile) - { - t = basic_lookup_transparent_type_1 (objfile, GLOBAL_BLOCK, name); - if (t) - return t; - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + t = basic_lookup_transparent_type_1 (objfile, GLOBAL_BLOCK, name); + if (t) + return t; + } - ALL_OBJFILES (objfile) - { - t = basic_lookup_transparent_type_quick (objfile, GLOBAL_BLOCK, name); - if (t) - return t; - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + t = basic_lookup_transparent_type_quick (objfile, GLOBAL_BLOCK, name); + if (t) + return t; + } /* Now search the static file-level symbols. Not strictly correct, but more useful than an error. @@ -2822,19 +2821,19 @@ basic_lookup_transparent_type (const char *name) of the desired name as a file-level static, then do psymtab-to-symtab conversion on the fly and return the found symbol. */ - ALL_OBJFILES (objfile) - { - t = basic_lookup_transparent_type_1 (objfile, STATIC_BLOCK, name); - if (t) - return t; - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + t = basic_lookup_transparent_type_1 (objfile, STATIC_BLOCK, name); + if (t) + return t; + } - ALL_OBJFILES (objfile) - { - t = basic_lookup_transparent_type_quick (objfile, STATIC_BLOCK, name); - if (t) - return t; - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + t = basic_lookup_transparent_type_quick (objfile, STATIC_BLOCK, name); + if (t) + return t; + } return (struct type *) 0; } @@ -2877,7 +2876,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) { struct compunit_symtab *cust; struct compunit_symtab *best_cust = NULL; - struct objfile *objfile; + struct objfile *obj_file; CORE_ADDR distance = 0; struct bound_minimal_symbol msymbol; @@ -2910,7 +2909,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) It also happens for objfiles that have their functions reordered. For these, the symtab we are looking for is not necessarily read in. */ - ALL_COMPUNITS (objfile, cust) + ALL_COMPUNITS (obj_file, cust) { struct block *b; const struct blockvector *bv; @@ -2929,15 +2928,15 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) /* In order to better support objfiles that contain both stabs and coff debugging info, we continue on if a psymtab can't be found. */ - if ((objfile->flags & OBJF_REORDERED) && objfile->sf) + if ((obj_file->flags & OBJF_REORDERED) && obj_file->sf) { struct compunit_symtab *result; result - = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, - msymbol, - pc, section, - 0); + = obj_file->sf->qf->find_pc_sect_compunit_symtab (obj_file, + msymbol, + pc, section, + 0); if (result != NULL) return result; } @@ -2948,8 +2947,8 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) ALL_BLOCK_SYMBOLS (b, iter, sym) { - fixup_symbol_section (sym, objfile); - if (matching_obj_sections (SYMBOL_OBJ_SECTION (objfile, sym), + fixup_symbol_section (sym, obj_file); + if (matching_obj_sections (SYMBOL_OBJ_SECTION (obj_file, sym), section)) break; } @@ -2967,19 +2966,19 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) /* Not found in symtabs, search the "quick" symtabs (e.g. psymtabs). */ - ALL_OBJFILES (objfile) - { - struct compunit_symtab *result; - - if (!objfile->sf) - continue; - result = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, - msymbol, - pc, section, - 1); - if (result != NULL) - return result; - } + for (objfile *objf : all_objfiles (current_program_space)) + { + struct compunit_symtab *result; + + if (!objf->sf) + continue; + result = objf->sf->qf->find_pc_sect_compunit_symtab (objf, + msymbol, + pc, section, + 1); + if (result != NULL) + return result; + } return NULL; } @@ -2999,35 +2998,33 @@ find_pc_compunit_symtab (CORE_ADDR pc) struct symbol * find_symbol_at_address (CORE_ADDR address) { - struct objfile *objfile; - - ALL_OBJFILES (objfile) - { - if (objfile->sf == NULL - || objfile->sf->qf->find_compunit_symtab_by_address == NULL) - continue; - - struct compunit_symtab *symtab - = objfile->sf->qf->find_compunit_symtab_by_address (objfile, address); - if (symtab != NULL) - { - const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (symtab); + for (objfile *objfile : all_objfiles (current_program_space)) + { + if (objfile->sf == NULL + || objfile->sf->qf->find_compunit_symtab_by_address == NULL) + continue; - for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i) - { - struct block *b = BLOCKVECTOR_BLOCK (bv, i); - struct block_iterator iter; - struct symbol *sym; + struct compunit_symtab *symtab + = objfile->sf->qf->find_compunit_symtab_by_address (objfile, address); + if (symtab != NULL) + { + const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (symtab); - ALL_BLOCK_SYMBOLS (b, iter, sym) + for (int i = GLOBAL_BLOCK; i <= STATIC_BLOCK; ++i) { - if (SYMBOL_CLASS (sym) == LOC_STATIC - && SYMBOL_VALUE_ADDRESS (sym) == address) - return sym; + struct block *b = BLOCKVECTOR_BLOCK (bv, i); + struct block_iterator iter; + struct symbol *sym; + + ALL_BLOCK_SYMBOLS (b, iter, sym) + { + if (SYMBOL_CLASS (sym) == LOC_STATIC + && SYMBOL_VALUE_ADDRESS (sym) == address) + return sym; + } } - } - } - } + } + } return NULL; } @@ -3352,7 +3349,6 @@ find_line_symtab (struct symtab *symtab, int line, BEST_INDEX and BEST_LINETABLE identify the item for it. */ int best; - struct objfile *objfile; struct compunit_symtab *cu; struct symtab *s; @@ -3361,13 +3357,14 @@ find_line_symtab (struct symtab *symtab, int line, else best = 0; - ALL_OBJFILES (objfile) - { - if (objfile->sf) - objfile->sf->qf->expand_symtabs_with_fullname (objfile, - symtab_to_fullname (symtab)); - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + if (objfile->sf) + objfile->sf->qf->expand_symtabs_with_fullname + (objfile, symtab_to_fullname (symtab)); + } + struct objfile *objfile; ALL_FILETABS (objfile, cu, s) { struct linetable *l; @@ -5691,7 +5688,6 @@ static void find_main_name (void) { const char *new_main_name; - struct objfile *objfile; /* First check the objfiles to see whether a debuginfo reader has picked up the appropriate main name. Historically the main name @@ -5699,15 +5695,15 @@ find_main_name (void) relies on the order of objfile creation -- which still isn't guaranteed to get the correct answer, but is just probably more accurate. */ - ALL_OBJFILES (objfile) - { - if (objfile->per_bfd->name_of_main != NULL) - { - set_main_name (objfile->per_bfd->name_of_main, - objfile->per_bfd->language_of_main); - return; - } - } + for (objfile *objfile : all_objfiles (current_program_space)) + { + if (objfile->per_bfd->name_of_main != NULL) + { + set_main_name (objfile->per_bfd->name_of_main, + objfile->per_bfd->language_of_main); + return; + } + } /* Try to see if the main procedure is in Ada. */ /* FIXME: brobecker/2005-03-07: Another way of doing this would |