From: Pedro Alves <palves@redhat.com>
To: Mahmood Naderan <nt_mahmood@yahoo.com>,
"gdb@sourceware.org" <gdb@sourceware.org>
Subject: Re: Viewing the address of an array in gdb
Date: Fri, 06 Jul 2018 11:51:00 -0000 [thread overview]
Message-ID: <bf878de6-339b-c1ab-be8b-b57981fccce9@redhat.com> (raw)
In-Reply-To: <1377359320.54438.1530847991768@mail.yahoo.com>
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
symbol.
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/libc.so.6
(gdb) info symbol 0x7ffff7dd4400
_dl_open_hook in section .bss of /lib64/libc.so.6
(gdb) info symbol 0x7ffff7dd43f0
buffer + 16 in section .bss of /lib64/libc.so.6
(gdb) info symbol 0x7ffff7dd43e0
buffer in section .bss of /lib64/libc.so.6
(gdb)
Thanks,
Pedro Alves
next prev parent reply other threads:[~2018-07-06 11:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1377359320.54438.1530847991768.ref@mail.yahoo.com>
2018-07-06 3:33 ` Mahmood Naderan via gdb
2018-07-06 11:51 ` Pedro Alves [this message]
2018-07-06 12:00 ` Pedro Alves
2018-07-06 12:06 ` Pedro Alves
2018-07-06 13:08 ` Mahmood Naderan via gdb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf878de6-339b-c1ab-be8b-b57981fccce9@redhat.com \
--to=palves@redhat.com \
--cc=gdb@sourceware.org \
--cc=nt_mahmood@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox