This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Show function address in 'info address func' instead of function descriptor

If we debug a program with debug information, we get the function
address of main shown below,

(gdb) p &main
$1 = (int (*)(void)) 0x10000554 <main>
(gdb) info address main
Symbol "main" is a function at address 0x10000554.

however, if we debug a program without debug information, "info address"
shows function descriptor address, while "p &main" shows function

(gdb) p &main
$1 = (<text variable, no debug info> *) 0x10000554 <.main>
(gdb) info address main
Symbol "main" is at 0x10020078 in a file compiled without debugging.

IMO, it is more reasonable to show function address instead of function
descriptor address.  Secondly, in GDB manual,

info address symbol
  Describe where the data for symbol is stored. For a register variable,
  this says which register it is kept in. For a non-register local
  variable, this prints the stack-frame offset at which the variable is
  always stored.
  Note the contrast with 'print &symbol', which does not work at all for
  a register variable, and for a stack local variable prints the exact
  address of the current instantiation of the variable.

we can tell that "info address symbol" and "print &symbol" should print
the same address but in different formats.  In case of no debug
information, "print &symbol" shows function address, so
"info address symbol" should show function address too.

with this patch applied, if we debug program without debug information,
it becomes:

(gdb) p &main
$1 = (<text variable, no debug info> *) 0x10000554 <.main>
(gdb) info address main
Symbol "main" is at 0x10000554 in a file compiled without debugging.

Regression tested on ppc64-linux (


2016-10-27  Yao Qi  <>

	* printcmd.c (address_info): Call
 gdb/printcmd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 7180fda..a256bed 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1489,7 +1489,10 @@ address_info (char *exp, int from_tty)
 	  gdbarch = get_objfile_arch (objfile);
 	  load_addr = BMSYMBOL_VALUE_ADDRESS (msymbol);
+	  /* The minimal symbol might point to a function descriptor;
+	     resolve it to the actual code address instead.  */
+	  load_addr = gdbarch_convert_from_func_ptr_addr (gdbarch, load_addr,
+							  &current_target);
 	  printf_filtered ("Symbol \"");
 	  fprintf_symbol_filtered (gdb_stdout, exp,
 				   current_language->la_language, DMGL_ANSI);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]