From: Doug Evans Date: Thu, 20 Nov 2008 16:13:11 +0000 (+0000) Subject: * printcmd.c (sym_info): Don't print the offset if it's zero. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e2fd701eb4e8c8e59741a6a5ae97d759e70e239a;p=binutils-gdb.git * printcmd.c (sym_info): Don't print the offset if it's zero. * gdb.base/sepsymtab.exp: Update, old "info sym" format restored. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 62b98fe5f99..89f352dea29 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2008-11-20 Doug Evans + + * printcmd.c (sym_info): Don't print the offset if it's zero. + 2008-11-20 Pedro Alves * infrun.c (resume): If following a fork, reread the current diff --git a/gdb/printcmd.c b/gdb/printcmd.c index fec81d9fcfd..81638fbd2d5 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1013,6 +1013,8 @@ sym_info (char *arg, int from_tty) && (msymbol = lookup_minimal_symbol_by_pc_section (sect_addr, osect))) { const char *obj_name, *mapped, *sec_name, *msym_name; + char *loc_string; + struct cleanup *old_chain; matches = 1; offset = sect_addr - SYMBOL_VALUE_ADDRESS (msymbol); @@ -1020,43 +1022,55 @@ sym_info (char *arg, int from_tty) sec_name = osect->the_bfd_section->name; msym_name = SYMBOL_PRINT_NAME (msymbol); + /* Don't print the offset if it is zero. + We assume there's no need to handle i18n of "sym + offset". */ + if (offset) + xasprintf (&loc_string, "%s + %u", msym_name, offset); + else + xasprintf (&loc_string, "%s", msym_name); + + /* Use a cleanup to free loc_string in case the user quits + a pagination request inside printf_filtered. */ + old_chain = make_cleanup (xfree, loc_string); + gdb_assert (osect->objfile && osect->objfile->name); obj_name = osect->objfile->name; if (MULTI_OBJFILE_P ()) if (pc_in_unmapped_range (addr, osect)) if (section_is_overlay (osect)) - printf_filtered (_("%s + %u in load address range of " + printf_filtered (_("%s in load address range of " "%s overlay section %s of %s\n"), - msym_name, offset, - mapped, sec_name, obj_name); + loc_string, mapped, sec_name, obj_name); else - printf_filtered (_("%s + %u in load address range of " + printf_filtered (_("%s in load address range of " "section %s of %s\n"), - msym_name, offset, sec_name, obj_name); + loc_string, sec_name, obj_name); else if (section_is_overlay (osect)) - printf_filtered (_("%s + %u in %s overlay section %s of %s\n"), - msym_name, offset, mapped, sec_name, obj_name); + printf_filtered (_("%s in %s overlay section %s of %s\n"), + loc_string, mapped, sec_name, obj_name); else - printf_filtered (_("%s + %u in section %s of %s\n"), - msym_name, offset, sec_name, obj_name); + 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 + %u in load address range of %s overlay " + printf_filtered (_("%s in load address range of %s overlay " "section %s\n"), - msym_name, offset, mapped, sec_name); + loc_string, mapped, sec_name); else - printf_filtered (_("%s + %u in load address range of section %s\n"), - msym_name, offset, sec_name); + printf_filtered (_("%s in load address range of section %s\n"), + loc_string, sec_name); else if (section_is_overlay (osect)) - printf_filtered (_("%s + %u in %s overlay section %s\n"), - msym_name, offset, mapped, sec_name); + printf_filtered (_("%s in %s overlay section %s\n"), + loc_string, mapped, sec_name); else - printf_filtered (_("%s + %u in section %s\n"), - msym_name, offset, sec_name); + printf_filtered (_("%s in section %s\n"), + loc_string, sec_name); + + do_cleanups (old_chain); } } if (matches == 0) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index a7378724e4e..b08bcd13751 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-11-20 Doug Evans + + * gdb.base/sepsymtab.exp: Update, old "info sym" format restored. + 2008-11-18 Thiago Jung Bauermann * gdb.arch/ppc-dfp.exp: New file. diff --git a/gdb/testsuite/gdb.base/sepsymtab.exp b/gdb/testsuite/gdb.base/sepsymtab.exp index 31927017603..ce0ea7d2b37 100644 --- a/gdb/testsuite/gdb.base/sepsymtab.exp +++ b/gdb/testsuite/gdb.base/sepsymtab.exp @@ -45,7 +45,7 @@ gdb_load ${binfile} set command "info sym main" set command_regex [string_to_regexp $command] gdb_test_multiple "$command" "$command" { - -re "^${command_regex}\[\r\n\]+main \\+ 0 in section \[^\r\n\]+\[\r\n\]+$gdb_prompt \$" { + -re "^${command_regex}\[\r\n\]+main in section \[^\r\n\]+\[\r\n\]+$gdb_prompt \$" { pass "$command" } }