From: "Douglas Evans" <dje@google.com>
To: "Paul Hilfinger" <Hilfinger@adacore.com>, gdb@sourceware.org
Subject: Re: print/x on references
Date: Thu, 18 Oct 2007 17:10:00 -0000 [thread overview]
Message-ID: <e394668d0710181010s2dd0618vf14a6d52ec0818c2@mail.gmail.com> (raw)
In-Reply-To: <e394668d0710181003j836bd06jc4cb50affb28e061@mail.gmail.com>
On 10/18/07, Douglas Evans <dje@google.com> wrote:
> To find the address of the pointer to the object I was thinking "p
> &(&x)". It works, at least in the simple example I used to experiment
> with.
>
> Am I misunderstanding your point? [quite likely - apologies]
Heh ... or used too simplistic an example. Here it is fwiw.
class c
{
int i;
};
void
foo (c& cref)
{
}
int
main ()
{
c cobj;
foo (cobj);
}
dje@ruffy:~/src$ gdb a.out
GNU gdb 6.7.50-20071017-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux"...
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
(gdb) b foo
Breakpoint 1 at 0x8048357: file ref-printing.cc, line 9.
(gdb) r
Starting program: /home/dje/src/a.out
Breakpoint 1, foo (cref=@0xffffd864) at ref-printing.cc:9
9 }
(gdb) info frame
Stack level 0, frame at 0xffffd840:
eip = 0x8048357 in foo(c&) (ref-printing.cc:9); saved eip 0x8048381
called by frame at 0xffffd870
source language c++.
Arglist at 0xffffd838, args: cref=@0xffffd864
Locals at 0xffffd838, Previous frame's sp is 0xffffd840
Saved registers:
ebp at 0xffffd838, eip at 0xffffd83c
(gdb) p cref
$1 = (c &) @0xffffd864: {i = 1334422496}
(gdb) p &cref
$2 = (c *) 0xffffd864
(gdb) p &(&cref)
$3 = (c **) 0xffffd840
(gdb) x/4x $ebp
0xffffd838: 0xffffd868 0x08048381 0xffffd864 0x416ed604
(gdb)
next prev parent reply other threads:[~2007-10-18 17:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-18 9:37 Paul Hilfinger
2007-10-18 11:16 ` Daniel Jacobowitz
2007-10-18 16:05 ` Douglas Evans
2007-10-18 16:30 ` Daniel Jacobowitz
2007-10-18 17:03 ` Douglas Evans
2007-10-18 17:10 ` Douglas Evans [this message]
2007-10-18 17:11 ` Daniel Jacobowitz
2007-10-18 17:45 ` Douglas Evans
2007-10-18 19:10 ` Paul Hilfinger
2007-10-18 19:21 ` Daniel Jacobowitz
2007-10-18 19:30 ` Paul Hilfinger
2007-10-18 19:39 ` Daniel Jacobowitz
2007-10-19 21:40 ` Jim Blandy
2007-10-19 22:00 ` Daniel Jacobowitz
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=e394668d0710181010s2dd0618vf14a6d52ec0818c2@mail.gmail.com \
--to=dje@google.com \
--cc=Hilfinger@adacore.com \
--cc=gdb@sourceware.org \
/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