* printcmd.c (sym_info): Don't print the offset if it's zero.

* gdb.base/sepsymtab.exp: Update, old "info sym" format restored.
This commit is contained in:
Doug Evans 2008-11-20 16:13:11 +00:00
parent 607cecd2d4
commit e2fd701eb4
4 changed files with 40 additions and 18 deletions

View File

@ -1,3 +1,7 @@
2008-11-20 Doug Evans <dje@google.com>
* printcmd.c (sym_info): Don't print the offset if it's zero.
2008-11-20 Pedro Alves <pedro@codesourcery.com>
* infrun.c (resume): If following a fork, reread the current

View File

@ -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)

View File

@ -1,3 +1,7 @@
2008-11-20 Doug Evans <dje@google.com>
* gdb.base/sepsymtab.exp: Update, old "info sym" format restored.
2008-11-18 Thiago Jung Bauermann <bauerman@br.ibm.com>
* gdb.arch/ppc-dfp.exp: New file.

View File

@ -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"
}
}