From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 59303 invoked by alias); 6 Jul 2018 11:51:08 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 59268 invoked by uid 89); 6 Jul 2018 11:51:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=relation, Hx-languages-length:1933, HContent-Transfer-Encoding:8bit X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Jul 2018 11:51:06 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 36C6272651; Fri, 6 Jul 2018 11:51:05 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id B606921565E1; Fri, 6 Jul 2018 11:51:04 +0000 (UTC) Subject: Re: Viewing the address of an array in gdb To: Mahmood Naderan , "gdb@sourceware.org" References: <1377359320.54438.1530847991768.ref@mail.yahoo.com> <1377359320.54438.1530847991768@mail.yahoo.com> From: Pedro Alves Message-ID: Date: Fri, 06 Jul 2018 11:51:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1377359320.54438.1530847991768@mail.yahoo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-07/txt/msg00018.txt.bz2 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 "" > (gdb) x/30x 0x7ffff7dd43e0 > 0x7ffff7dd43e0 :    0x00000000    0x00000000    0x00000000    0x00000000 > 0x7ffff7dd43f0 :    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 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 . 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