From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6842 invoked by alias); 18 Oct 2007 17:10:35 -0000 Received: (qmail 6834 invoked by uid 22791); 18 Oct 2007 17:10:34 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 18 Oct 2007 17:10:32 +0000 Received: from zps38.corp.google.com (zps38.corp.google.com [172.25.146.38]) by smtp-out.google.com with ESMTP id l9IHAQjT025380 for ; Thu, 18 Oct 2007 10:10:26 -0700 Received: from ug-out-1314.google.com (ugfh3.prod.google.com [10.66.184.3]) by zps38.corp.google.com with ESMTP id l9IHAPmw005663 for ; Thu, 18 Oct 2007 10:10:25 -0700 Received: by ug-out-1314.google.com with SMTP id h3so532089ugf for ; Thu, 18 Oct 2007 10:10:24 -0700 (PDT) Received: by 10.67.27.3 with SMTP id e3mr2063252ugj.1192727424795; Thu, 18 Oct 2007 10:10:24 -0700 (PDT) Received: by 10.66.242.13 with HTTP; Thu, 18 Oct 2007 10:10:24 -0700 (PDT) Message-ID: Date: Thu, 18 Oct 2007 17:10:00 -0000 From: "Douglas Evans" To: "Paul Hilfinger" , gdb@sourceware.org Subject: Re: print/x on references In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20071018093736.8076A48CB9C@nile.gnat.com> <20071018111644.GA32574@caradoc.them.org> <20071018163012.GA19490@caradoc.them.org> X-IsSubscribed: yes 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 X-SW-Source: 2007-10/txt/msg00149.txt.bz2 On 10/18/07, Douglas Evans 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 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)