From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3899 invoked by alias); 19 Nov 2007 00:35:41 -0000 Received: (qmail 3891 invoked by uid 22791); 19 Nov 2007 00:35:40 -0000 X-Spam-Check-By: sourceware.org Received: from wa-out-1112.google.com (HELO wa-out-1112.google.com) (209.85.146.179) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 19 Nov 2007 00:35:37 +0000 Received: by wa-out-1112.google.com with SMTP id l35so2110027waf for ; Sun, 18 Nov 2007 16:35:34 -0800 (PST) Received: by 10.115.60.1 with SMTP id n1mr551503wak.1195432534039; Sun, 18 Nov 2007 16:35:34 -0800 (PST) Received: by 10.115.74.3 with HTTP; Sun, 18 Nov 2007 16:35:34 -0800 (PST) Message-ID: <366c6f340711181635x47116762nf7ec620eb5801dd2@mail.gmail.com> Date: Mon, 19 Nov 2007 00:35:00 -0000 From: "Peng Yu" To: gdb@sourceware.org Subject: gdb does not print the reference to the base class members MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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-11/txt/msg00174.txt.bz2 Hi, I try to print reference x for the following problem. But gdb does not print the one in class B refered to class A? Do you know how to print its value? Thanks, Peng (gdb) b 22 Breakpoint 1 at 0x8048694: file main.cc, line 22. (gdb) b 14 Breakpoint 2 at 0x8048706: file main.cc, line 14. (gdb) r Failed to read a valid object file image from memory. Breakpoint 1, main () at main.cc:22 22 B b(10); (gdb) p x $1 = (int &) @0xbffd86cc: 5 (gdb) c Breakpoint 2, B (this=0xbffd86c8, a=10) at main.cc:14 14 std::cout << x << std::endl; (gdb) p x No symbol "x" in current context. #include class A { public: A(int a) : _a(a) { } protected: int _a; }; class B : public A { public: B(int a) : A(a) { int &x = A::_a;//can not print from gdb, Line 12 std::cout << x << std::endl; } }; int main(){ int a = 5; int &x = a;//this one can be printed in gdb, Line 22 B b(10); std::cout << x << std::endl; }