aboutsummaryrefslogtreecommitdiff
path: root/gdb/printcmd.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2008-11-20 16:13:11 +0000
committerDoug Evans <dje@google.com>2008-11-20 16:13:11 +0000
commite2fd701eb4e8c8e59741a6a5ae97d759e70e239a (patch)
tree75e12f826b8052dea0ff2ecd1c8cb90d580fc459 /gdb/printcmd.c
parent607cecd2d4e6f0533f7e28f18d088ff4ec1109dd (diff)
downloadgdb-e2fd701eb4e8c8e59741a6a5ae97d759e70e239a.zip
gdb-e2fd701eb4e8c8e59741a6a5ae97d759e70e239a.tar.gz
gdb-e2fd701eb4e8c8e59741a6a5ae97d759e70e239a.tar.bz2
* printcmd.c (sym_info): Don't print the offset if it's zero.
* gdb.base/sepsymtab.exp: Update, old "info sym" format restored.
Diffstat (limited to 'gdb/printcmd.c')
-rw-r--r--gdb/printcmd.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index fec81d9..81638fb 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)