From: "Mahmood Naderan via gdb" <gdb@sourceware.org>
To: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Viewing the address of an array in gdb
Date: Fri, 06 Jul 2018 03:33:00 -0000 [thread overview]
Message-ID: <1377359320.54438.1530847991768@mail.yahoo.com> (raw)
In-Reply-To: <1377359320.54438.1530847991768.ref@mail.yahoo.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 8402 bytes --]
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?
Regards,
Mahmood
From gdb-return-46502-listarch-gdb=sources.redhat.com@sourceware.org Fri Jul 06 11:15:40 2018
Return-Path: <gdb-return-46502-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 60353 invoked by alias); 6 Jul 2018 11:15:39 -0000
Mailing-List: contact gdb-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb.sourceware.org>
List-Subscribe: <mailto:gdb-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb/>
List-Post: <mailto:gdb@sourceware.org>
List-Help: <mailto:gdb-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-owner@sourceware.org
Delivered-To: mailing list gdb@sourceware.org
Received: (qmail 60117 invoked by uid 89); 6 Jul 2018 11:15:25 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:PHrt, H*RU:74.6.131.42, H*r:ip*74.6.131.42, Hx-spam-relays-external:74.6.131.42
X-HELO: sonic303-3.consmr.mail.bf2.yahoo.com
Received: from sonic303-3.consmr.mail.bf2.yahoo.com (HELO sonic303-3.consmr.mail.bf2.yahoo.com) (74.6.131.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Jul 2018 11:15:23 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t\x1530875707; bh=+ICGq2jEUtXmsvF9xyTfTeCjwc3DbBVA4zAWywkNJY4=; hÚte:From:Reply-To:To:Subject:References:From:Subject; b=CqCbClKpGFo7/sF4YYcnspeI91Yjnglaie6on8o590BgQ8/qAnEt81GejXTlsMg1RkkTQmJeHguSqBVTv+hXSjD962oTSbEmW+HjN1TdVRoqoXh8fy4Ge62CicKF0bNI5Ldm2YXrVPo8rBAqyZZ7Rj0MwEjZSiBL4siYAIaReh6xV9/lfJYCXIzy2x6qrDahvJhk/0C7vym3gjs8v77XESaxGS9iSxlsUIKI5qjIQVY0MO+u5Dj3t7U5OuR+OUwdvb8xCF2GSQXkafivgVpI3d7us/gyI/Blnqmpj4RQialQwjWWgn8b2Yq59H0Ee1MtQ0/rqUFmasE5+8awpmwxYQ=Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.bf2.yahoo.com with HTTP; Fri, 6 Jul 2018 11:15:07 +0000
Date: Fri, 06 Jul 2018 11:15:00 -0000
From: "Mahmood Naderan via gdb" <gdb@sourceware.org>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>
Message-ID: <1839186466.17059.1530875705518@mail.yahoo.com>
Subject: debugging a callq command
MIME-Version: 1.0
References: <1839186466.17059.1530875705518.ref@mail.yahoo.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-IsSubscribed: yes
X-SW-Source: 2018-07/txt/msg00014.txt.bz2
Content-length: 2712
Hi,
Trying to debug an assembly code with gdb, I see that a call function to a valid address exists but the control won't go to the target address.
As you can see, the first instruction is a jmp to 0x7fffffffde7d and there, it will call 0x7fffffffde70. However, the next instruction is something else while the program receives seg fault.
(gdb) nexti
0x00007fffffffde6e in ?? ()
1: x/20i $pc
=> 0x7fffffffde6e:   jmp   0x7fffffffde7d
  0x7fffffffde70:   pop   %rsi
  0x7fffffffde71:   xor   %ecx,%ecx
  0x7fffffffde73:   mov   $0x21,%cl
  0x7fffffffde75:   xorb  $0x35,(%rsi)
  0x7fffffffde78:   rex.RX loop 0x7fffffffde75
  0x7fffffffde7b:   jmp   0x7fffffffde82
  0x7fffffffde7d:   callq 0x7fffffffde70
  0x7fffffffde82:   pop   %rdi
  0x7fffffffde83:   jae   0x7fffffffdef2
(gdb) nexti
0x00007fffffffde6e in ?? ()
1: x/20i $pc
=> 0x7fffffffde6e:   jmp   0x7fffffffde7d
  0x7fffffffde70:   pop   %rsi
  0x7fffffffde71:   xor   %ecx,%ecx
  0x7fffffffde73:   mov   $0x21,%cl
  0x7fffffffde75:   xorb  $0x35,(%rsi)
  0x7fffffffde78:   rex.RX loop 0x7fffffffde75
  0x7fffffffde7b:   jmp   0x7fffffffde82
  0x7fffffffde7d:   callq 0x7fffffffde70
  0x7fffffffde82:   pop   %rdi
  0x7fffffffde83:   jae   0x7fffffffdef2
(gdb) nexti
Program received signal SIGSEGV, Segmentation fault.
0x00007fffffffde8c in ?? ()
1: x/20i $pc
=> 0x7fffffffde8c:   out   %eax,$0x5f
  0x7fffffffde8e:   ds insl (%dx),%es:(%rdi)
  0x7fffffffde90:   addr32 pop %rbp
  0x7fffffffde92:   sbb   0x46(%rdi),%cl
  0x7fffffffde95:   pop   %rbp
  0x7fffffffde96:   pop   %rbp
  0x7fffffffde97:   sbb   0x5c(%rdi),%dl
What is happening there? Any idea?
Regards,
Mahmood
From gdb-return-46503-listarch-gdb=sources.redhat.com@sourceware.org Fri Jul 06 11:31:08 2018
Return-Path: <gdb-return-46503-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 57426 invoked by alias); 6 Jul 2018 11:30:59 -0000
Mailing-List: contact gdb-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb.sourceware.org>
List-Subscribe: <mailto:gdb-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb/>
List-Post: <mailto:gdb@sourceware.org>
List-Help: <mailto:gdb-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-owner@sourceware.org
Delivered-To: mailing list gdb@sourceware.org
Received: (qmail 56158 invoked by uid 89); 6 Jul 2018 11:30:29 -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ºldwin, baldwin, sk:decr_af, sk:decr_pc
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:30:28 +0000
Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9AE16E9003; Fri, 6 Jul 2018 11:30:18 +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 6D9857C21; Fri, 6 Jul 2018 11:30:17 +0000 (UTC)
Subject: Re: RISC-V: decr_pc_after_break causing problems
To: John Baldwin <jhb@FreeBSD.org>, Palmer Dabbelt <palmer@sifive.com>, Jim Wilson <jimw@sifive.com>, andrew.burgess@embecosm.com
References: <mhng-c2172dd6-d7fb-4df6-87d4-a180afd408e3@palmer-si-x1c4> <95eb8848-182b-dab4-f9dc-298269885f53@FreeBSD.org>
Cc: gdb@sourceware.org
From: Pedro Alves <palves@redhat.com>
Message-ID: <d1125dae-66a2-d347-5017-64917114657c@redhat.com>
Date: Fri, 06 Jul 2018 11:30: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: <95eb8848-182b-dab4-f9dc-298269885f53@FreeBSD.org>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-SW-Source: 2018-07/txt/msg00015.txt.bz2
Content-length: 299
On 07/05/2018 11:54 PM, John Baldwin wrote:
> FWIW, my preference would be for the decr_after_pc_break match the hardware
> which from my understanding of the thread means it should always be zero.
Mine too, FWIW. PC adjustment is a source of trouble in ports that need it.
Thanks,
Pedro Alves
next parent reply other threads:[~2018-07-06 3:33 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 [this message]
2018-07-06 11:51 ` Pedro Alves
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=1377359320.54438.1530847991768@mail.yahoo.com \
--to=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