aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2008-11-18 21:31:27 +0000
committerPaul Pluzhnikov <ppluzhnikov@google.com>2008-11-18 21:31:27 +0000
commitc14c28ba117dee9fd0bf17fc3437e808221a7829 (patch)
treef325e191374bc352f84e4194fe2dbfc521e7133d /gdb
parent00a0b122cf3b524243c3cea05101bacd5a1595ba (diff)
downloadgdb-c14c28ba117dee9fd0bf17fc3437e808221a7829.zip
gdb-c14c28ba117dee9fd0bf17fc3437e808221a7829.tar.gz
gdb-c14c28ba117dee9fd0bf17fc3437e808221a7829.tar.bz2
2008-11-18 Paul Pluzhnikov <ppluzhnikov@google.com>
* objfiles.h: New MULTI_OBJFILE_P macro. * printcmd.c (sym_info): Print object name. * maint.c (maintenance_translate_address): Likewise.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog6
-rw-r--r--gdb/doc/ChangeLog6
-rw-r--r--gdb/doc/gdb.texinfo14
-rw-r--r--gdb/maint.c30
-rw-r--r--gdb/objfiles.h4
-rw-r--r--gdb/printcmd.c54
-rw-r--r--gdb/testsuite/ChangeLog4
-rw-r--r--gdb/testsuite/gdb.base/sepsymtab.exp2
8 files changed, 104 insertions, 16 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fae3dea..92dfcc5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-18 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * objfiles.h: New MULTI_OBJFILE_P macro.
+ * printcmd.c (sym_info): Print object name.
+ * maint.c (maintenance_translate_address): Likewise.
+
2008-11-18 Joel Brobecker <brobecker@adacore.com>
* NEWS: Document the removal of "catch load" and "catch unload".
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index 14f36d9..4cfc683 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,3 +1,9 @@
+2008-11-18 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * gdb.texinfo (Symbols): Mention printing containing
+ image name in "info symbol".
+ (Maint translate-address): Likewise.
+
2008-11-18 Joel Brobecker <brobecker@adacore.com>
* gdb.texinfo (Set Catchpoints): Remove the documentation of
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index b11d61c..aef5308 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -11856,6 +11856,16 @@ _initialize_vx + 396 in section .text
This is the opposite of the @code{info address} command. You can use
it to find out the name of a variable or a function given its address.
+For dynamically linked executables, the name of executable or shared
+library containing the symbol is also printed:
+
+@smallexample
+(@value{GDBP}) info symbol 0x400225
+_start + 5 in section .text of /tmp/a.out
+(@value{GDBP}) info symbol 0x2aaaac2811cf
+__read_nocancel + 6 in section .text of /usr/lib64/libc.so.6
+@end smallexample
+
@kindex whatis
@item whatis [@var{arg}]
Print the data type of @var{arg}, which can be either an expression or
@@ -24611,6 +24621,10 @@ the symbol's location to the specified address. This is similar to
the @code{info address} command (@pxref{Symbols}), except that this
command also allows to find symbols in other sections.
+If section was not specified, the section in which the symbol was found
+is also printed. For dynamically linked executables, the name of
+executable or shared library containing the symbol is printed as well.
+
@end table
The following command is useful for non-interactive invocations of
diff --git a/gdb/maint.c b/gdb/maint.c
index 365e374..c3a70c1 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -35,6 +35,7 @@
#include "symfile.h"
#include "objfiles.h"
#include "value.h"
+#include "gdb_assert.h"
#include "cli/cli-decode.h"
@@ -484,9 +485,32 @@ maintenance_translate_address (char *arg, int from_tty)
sym = lookup_minimal_symbol_by_pc (address);
if (sym)
- printf_filtered ("%s+%s\n",
- SYMBOL_PRINT_NAME (sym),
- pulongest (address - SYMBOL_VALUE_ADDRESS (sym)));
+ {
+ const char *symbol_name = SYMBOL_PRINT_NAME (sym);
+ const char *symbol_offset = pulongest (address - SYMBOL_VALUE_ADDRESS (sym));
+
+ sect = SYMBOL_OBJ_SECTION(sym);
+ if (sect != NULL)
+ {
+ const char *section_name;
+ const char *obj_name;
+
+ gdb_assert (sect->the_bfd_section && sect->the_bfd_section->name);
+ section_name = sect->the_bfd_section->name;
+
+ gdb_assert (sect->objfile && sect->objfile->name);
+ obj_name = sect->objfile->name;
+
+ if (MULTI_OBJFILE_P ())
+ printf_filtered (_("%s + %s in section %s of %s\n"),
+ symbol_name, symbol_offset, section_name, obj_name);
+ else
+ printf_filtered (_("%s + %s in section %s\n"),
+ symbol_name, symbol_offset, section_name);
+ }
+ else
+ printf_filtered (_("%s + %s\n"), symbol_name, symbol_offset);
+ }
else if (sect)
printf_filtered (_("no symbol at %s:0x%s\n"),
sect->the_bfd_section->name, paddr (address));
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index c8b5af3..fe42f54 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -583,4 +583,8 @@ extern void *objfile_data (struct objfile *objfile,
uninitialized section index. */
#define SECT_OFF_BSS(objfile) (objfile)->sect_index_bss
+/* Answer whether there is more than one object file loaded. */
+
+#define MULTI_OBJFILE_P() (object_files && object_files->next)
+
#endif /* !defined (OBJFILES_H) */
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index fe20626..fec81d9 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1012,21 +1012,51 @@ sym_info (char *arg, int from_tty)
&& sect_addr < obj_section_endaddr (osect)
&& (msymbol = lookup_minimal_symbol_by_pc_section (sect_addr, osect)))
{
+ const char *obj_name, *mapped, *sec_name, *msym_name;
+
matches = 1;
offset = sect_addr - SYMBOL_VALUE_ADDRESS (msymbol);
- if (offset)
- printf_filtered ("%s + %u in ",
- SYMBOL_PRINT_NAME (msymbol), offset);
+ mapped = section_is_mapped (osect) ? _("mapped") : _("unmapped");
+ sec_name = osect->the_bfd_section->name;
+ msym_name = SYMBOL_PRINT_NAME (msymbol);
+
+ 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 "
+ "%s overlay section %s of %s\n"),
+ msym_name, offset,
+ mapped, sec_name, obj_name);
+ else
+ printf_filtered (_("%s + %u in load address range of "
+ "section %s of %s\n"),
+ msym_name, offset, 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);
+ else
+ printf_filtered (_("%s + %u in section %s of %s\n"),
+ msym_name, offset, sec_name, obj_name);
else
- printf_filtered ("%s in ",
- SYMBOL_PRINT_NAME (msymbol));
- if (pc_in_unmapped_range (addr, osect))
- printf_filtered (_("load address range of "));
- if (section_is_overlay (osect))
- printf_filtered (_("%s overlay "),
- section_is_mapped (osect) ? "mapped" : "unmapped");
- printf_filtered (_("section %s"), osect->the_bfd_section->name);
- printf_filtered ("\n");
+ if (pc_in_unmapped_range (addr, osect))
+ if (section_is_overlay (osect))
+ printf_filtered (_("%s + %u in load address range of %s overlay "
+ "section %s\n"),
+ msym_name, offset, mapped, sec_name);
+ else
+ printf_filtered (_("%s + %u in load address range of section %s\n"),
+ msym_name, offset, sec_name);
+ else
+ if (section_is_overlay (osect))
+ printf_filtered (_("%s + %u in %s overlay section %s\n"),
+ msym_name, offset, mapped, sec_name);
+ else
+ printf_filtered (_("%s + %u in section %s\n"),
+ msym_name, offset, sec_name);
}
}
if (matches == 0)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ba31a1d..f06c5ac 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2008-11-18 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ * gdb.base/sepsymtab.exp: Update for new 'info sym' format.
+
2008-11-17 Doug Evans <dje@google.com>
* gdb.mi/mi-syn-frame.exp: Update expected output.
diff --git a/gdb/testsuite/gdb.base/sepsymtab.exp b/gdb/testsuite/gdb.base/sepsymtab.exp
index ce0ea7d..3192701 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 in section \[^\r\n\]+\[\r\n\]+$gdb_prompt \$" {
+ -re "^${command_regex}\[\r\n\]+main \\+ 0 in section \[^\r\n\]+\[\r\n\]+$gdb_prompt \$" {
pass "$command"
}
}