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]

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

On 10/27/2016 10:25 AM, Yao Qi wrote:
> 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>

I thought we were going to fix that?  That's showing the
result as a function pointer type, however a function pointer's
value should be a descriptor, not the function address?

E.g., on ppc64 (gcc110 on the compile farm):

$cat  ~/func.c
#include <stdio.h>

void some_function () {}
void (*func) (void) = some_function;

int main ()
  printf ("func => %p\n", (void *) func);
  printf ("some_function => %p\n", (void *) some_function);
  printf ("&some_function => %p\n", (void *) &some_function);

  printf ("(func == some_function) => %d\n", func == some_function);
  printf ("(func == &some_function) => %d\n", func == &some_function);

  return 0;

Here's what the inferior sees:

$ ./func 
func => 0x10020080
some_function => 0x10020080
&some_function => 0x10020080
(func == some_function) => 1
(func == &some_function) => 1

But then what gdb shows:

(gdb) start
(gdb) p func
$1 = (void (*)(void)) @0x10020080: 0x100005d4 <some_function>
(gdb) p some_function
$2 = {void ()} 0x100005d4 <some_function>
(gdb) p &some_function
$3 = (void (*)()) 0x100005d4 <some_function>
(gdb) p func == some_function
$4 = 0
(gdb) p func == &some_function
$5 = 0

> (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
> address.

Pedro Alves

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