From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4708 invoked by alias); 25 Apr 2013 19:14:38 -0000 Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-prs-owner@sourceware.org Received: (qmail 4685 invoked by uid 48); 25 Apr 2013 19:14:37 -0000 From: "marcin.konarski at gmail dot com" To: gdb-prs@sourceware.org Subject: [Bug c++/15401] New: "set print object on" + printing variables of type: a reference to derived class. Date: Thu, 25 Apr 2013 19:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: marcin.konarski at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-SW-Source: 2013-q2/txt/msg00157.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=15401 Bug #: 15401 Summary: "set print object on" + printing variables of type: a reference to derived class. Product: gdb Version: 7.5 Status: NEW Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned@sourceware.org ReportedBy: marcin.konarski@gmail.com Classification: Unclassified gdb prints values of variables that are of reference type like they were a pointers if value in question is instance of some derived type that has a vtable. Notice difference in how f2 variable is printed in session script that is included below after I turn "set print object on". How to reproduce: [amok@vegeta](2/3)~/$ lsb_release -a LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch Distributor ID: Ubuntu Description: Ubuntu Raring Ringtail (development branch) Release: 13.04 Codename: raring [amok@vegeta](2/3)~/$ g++ --version g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [amok@vegeta](2/3)~/$ cat set-print-object-on.cxx struct Base { virtual ~Base() {} }; struct Foo : public Base { }; int main( int, char** ) { Foo f; Foo& f2( f ); return ( sizeof ( f2 ) ); } [amok@vegeta](2/3)~/$ g++ -g set-print-object-on.cxx [amok@vegeta](2/3)~/$ gdb ./a.out GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu Copyright (C) 2013 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 "x86_64-linux-gnu". For bug reporting instructions, please see: ... Reading symbols from /home/amok/a.out...done. (gdb) b main Breakpoint 1 at 0x4006ec: file set-print-object-on.cxx, line 8. (gdb) r Starting program: /home/amok/a.out Breakpoint 1, main () at set-print-object-on.cxx:8 8 Foo f; (gdb) n 9 Foo& f2( f ); (gdb) 10 return ( sizeof ( f2 ) ); (gdb) p f2 $1 = (Foo &) @0x7fffffffd550: { = {_vptr.Base = 0x4008f0 }, } (gdb) set print object on (gdb) p f2 $2 = (Foo *) 0x7fffffffd550 (gdb) quit A debugging session is active. Inferior 1 [process 2512] will be killed. Quit anyway? (y or n) y [amok@vegeta](2/3)~/$ -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.