This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/15401] New: "set print object on" + printing variables of type: a reference to derived class.
- From: "marcin.konarski at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Thu, 25 Apr 2013 19:14:37 +0000
- Subject: [Bug c++/15401] New: "set print object on" + printing variables of type: a reference to derived class.
- Auto-submitted: auto-generated
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 <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 "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
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: {<Base> = {_vptr.Base = 0x4008f0 <vtable for
Foo+16>}, <No data fields>}
(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.