diff options
author | Tom Tromey <tom@tromey.com> | 2018-11-24 11:54:26 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-01-09 18:28:15 -0700 |
commit | 3b9d3ac236dcc418619785e0660fc0063e6489b8 (patch) | |
tree | cf889e1bf17b40f716551bb173c9189a45a33a99 /gdb/printcmd.c | |
parent | 8b31193aa9752ba60d63cedaba943370d76ce543 (diff) | |
download | gdb-3b9d3ac236dcc418619785e0660fc0063e6489b8.zip gdb-3b9d3ac236dcc418619785e0660fc0063e6489b8.tar.gz gdb-3b9d3ac236dcc418619785e0660fc0063e6489b8.tar.bz2 |
Remove ALL_OBJSECTIONS
This removes the ALL_OBJSECTIONS macro, replacing its uses with ranged
for loops.
The special code in this macro for noticing a "break" from the inner
loop was only needed in a single place; so rather than try to
replicate this, I've simply replaced that use with a "goto".
gdb/ChangeLog
2019-01-09 Tom Tromey <tom@tromey.com>
* symfile.c (overlay_invalidate_all, find_pc_overlay)
(find_pc_mapped_section, list_overlays_command)
(map_overlay_command, unmap_overlay_command)
(simple_overlay_update): Use all_objfiles.
* spu-tdep.c (spu_overlay_update): Use all_objfiles.
* printcmd.c (info_symbol_command): Use all_objfiles.
* objfiles.h (ALL_OBJSECTIONS): Remove.
* maint.c (maintenance_translate_address): Use all_objfiles.
* gcore.c (gcore_create_callback): Use all_objfiles.
(objfile_find_memory_regions): Likewise.
Diffstat (limited to 'gdb/printcmd.c')
-rw-r--r-- | gdb/printcmd.c | 138 |
1 files changed, 70 insertions, 68 deletions
diff --git a/gdb/printcmd.c b/gdb/printcmd.c index a36f4ca..9c476e7 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1273,7 +1273,6 @@ static void info_symbol_command (const char *arg, int from_tty) { struct minimal_symbol *msymbol; - struct objfile *objfile; struct obj_section *osect; CORE_ADDR addr, sect_addr; int matches = 0; @@ -1283,78 +1282,81 @@ info_symbol_command (const char *arg, int from_tty) error_no_arg (_("address")); addr = parse_and_eval_address (arg); - ALL_OBJSECTIONS (objfile, osect) - { - /* Only process each object file once, even if there's a separate - debug file. */ - if (objfile->separate_debug_objfile_backlink) - continue; - - sect_addr = overlay_mapped_address (addr, osect); - - if (obj_section_addr (osect) <= sect_addr - && sect_addr < obj_section_endaddr (osect) - && (msymbol - = lookup_minimal_symbol_by_pc_section (sect_addr, osect).minsym)) + for (objfile *objfile : all_objfiles (current_program_space)) + ALL_OBJFILE_OSECTIONS (objfile, osect) { - const char *obj_name, *mapped, *sec_name, *msym_name; - const char *loc_string; - - matches = 1; - offset = sect_addr - MSYMBOL_VALUE_ADDRESS (objfile, msymbol); - mapped = section_is_mapped (osect) ? _("mapped") : _("unmapped"); - sec_name = osect->the_bfd_section->name; - msym_name = MSYMBOL_PRINT_NAME (msymbol); - - /* Don't print the offset if it is zero. - We assume there's no need to handle i18n of "sym + offset". */ - std::string string_holder; - if (offset) + /* Only process each object file once, even if there's a separate + debug file. */ + if (objfile->separate_debug_objfile_backlink) + continue; + + sect_addr = overlay_mapped_address (addr, osect); + + if (obj_section_addr (osect) <= sect_addr + && sect_addr < obj_section_endaddr (osect) + && (msymbol + = lookup_minimal_symbol_by_pc_section (sect_addr, + osect).minsym)) { - string_holder = string_printf ("%s + %u", msym_name, offset); - loc_string = string_holder.c_str (); - } - else - loc_string = msym_name; - - gdb_assert (osect->objfile && objfile_name (osect->objfile)); - obj_name = objfile_name (osect->objfile); - - if (MULTI_OBJFILE_P ()) - if (pc_in_unmapped_range (addr, osect)) - if (section_is_overlay (osect)) - printf_filtered (_("%s in load address range of " - "%s overlay section %s of %s\n"), - loc_string, mapped, sec_name, obj_name); - else - printf_filtered (_("%s in load address range of " - "section %s of %s\n"), - loc_string, sec_name, obj_name); - else - if (section_is_overlay (osect)) - printf_filtered (_("%s in %s overlay section %s of %s\n"), - loc_string, mapped, sec_name, obj_name); - else - printf_filtered (_("%s in section %s of %s\n"), - loc_string, sec_name, obj_name); - else - if (pc_in_unmapped_range (addr, osect)) - if (section_is_overlay (osect)) - printf_filtered (_("%s in load address range of %s overlay " - "section %s\n"), - loc_string, mapped, sec_name); + const char *obj_name, *mapped, *sec_name, *msym_name; + const char *loc_string; + + matches = 1; + offset = sect_addr - MSYMBOL_VALUE_ADDRESS (objfile, msymbol); + mapped = section_is_mapped (osect) ? _("mapped") : _("unmapped"); + sec_name = osect->the_bfd_section->name; + msym_name = MSYMBOL_PRINT_NAME (msymbol); + + /* Don't print the offset if it is zero. + We assume there's no need to handle i18n of "sym + offset". */ + std::string string_holder; + if (offset) + { + string_holder = string_printf ("%s + %u", msym_name, offset); + loc_string = string_holder.c_str (); + } else - printf_filtered (_("%s in load address range of section %s\n"), - loc_string, sec_name); - else - if (section_is_overlay (osect)) - printf_filtered (_("%s in %s overlay section %s\n"), - loc_string, mapped, sec_name); + loc_string = msym_name; + + gdb_assert (osect->objfile && objfile_name (osect->objfile)); + obj_name = objfile_name (osect->objfile); + + if (MULTI_OBJFILE_P ()) + if (pc_in_unmapped_range (addr, osect)) + if (section_is_overlay (osect)) + printf_filtered (_("%s in load address range of " + "%s overlay section %s of %s\n"), + loc_string, mapped, sec_name, obj_name); + else + printf_filtered (_("%s in load address range of " + "section %s of %s\n"), + loc_string, sec_name, obj_name); + else + if (section_is_overlay (osect)) + printf_filtered (_("%s in %s overlay section %s of %s\n"), + loc_string, mapped, sec_name, obj_name); + else + printf_filtered (_("%s in section %s of %s\n"), + loc_string, sec_name, obj_name); else - printf_filtered (_("%s in section %s\n"), - loc_string, sec_name); + if (pc_in_unmapped_range (addr, osect)) + if (section_is_overlay (osect)) + printf_filtered (_("%s in load address range of %s overlay " + "section %s\n"), + loc_string, mapped, sec_name); + else + printf_filtered + (_("%s in load address range of section %s\n"), + loc_string, sec_name); + else + if (section_is_overlay (osect)) + printf_filtered (_("%s in %s overlay section %s\n"), + loc_string, mapped, sec_name); + else + printf_filtered (_("%s in section %s\n"), + loc_string, sec_name); + } } - } if (matches == 0) printf_filtered (_("No symbol matches %s.\n"), arg); } |