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: Viewing the address of an array in gdb

On 07/06/2018 04:33 AM, Mahmood Naderan via gdb wrote:
> Hi,
> I have define "char buffer[100]" in a C code. Trying to view the location of buffer in GDB, I see this
> (gdb) p &buffer[0]
> $1 = 0x7ffff7dd43e0 <buffer> ""
> (gdb) x/30x 0x7ffff7dd43e0
> 0x7ffff7dd43e0 <buffer>:    0x00000000    0x00000000    0x00000000    0x00000000
> 0x7ffff7dd43f0 <buffer+16>:    0x00000000    0x00000000    0x00000000    0x00000000
> 0x7ffff7dd4400 <_dl_open_hook>:    0x00000000    0x00000000    0xffb51dd2    0xa7d1a586
> 0x7ffff7dd4410 <__vdso_getcpu>:    0xf5b51dd2    0xa7d1a586    0xffffdf28    0x00007fff
> 0x7ffff7dd4420 <__libc_argc>:    0x00000002    0x00000000    0x00000000    0x00000000
> 0x7ffff7dd4430 <__gconv_alias_db>:    0x00000000    0x00000000    0x00000000    0x00000000
> 0x7ffff7dd4440 <__gconv_modules_db>:    0x00000000    0x00000000    0x00000000    0x00000000
> 0x7ffff7dd4450 <__gconv_path_envvar>:    0x00000000    0x00000000
> (gdb) p &buffer[99]
> $2 = 0x7ffff7dd4443 <__gconv_modules_db+3> ""
> (gdb) 
> Why I don't see <buffer+32> and similar things?

Because buffer + 32 is the address of the _dl_open_hook

What goes inside the <....> is the name of the symbol at the address
presented to its left, it has no direct relation the the expression you
passed to the command.

When there's no symbol at the exact address, <....> shows the name
of closest symbol, plus an offset into the symbol, which is why
you see <buffer+16>.  

Try these:

(gdb) info symbol 0x7ffff7dd4410
__vdso_getcpu in section .bss of /lib64/
(gdb) info symbol 0x7ffff7dd4400
_dl_open_hook in section .bss of /lib64/
(gdb) info symbol 0x7ffff7dd43f0
buffer + 16 in section .bss of /lib64/
(gdb) info symbol 0x7ffff7dd43e0
buffer in section .bss of /lib64/

Pedro Alves

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