Bug 606660

Summary: print only shows the first member of a class if that member has any virt. method
Product: [Fedora] Fedora Reporter: David Tardon <dtardon>
Component: gdbAssignee: Jan Kratochvil <jan.kratochvil>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: jan.kratochvil, pmuldoon, swagiaal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gdb-7.1-27.fc13 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 609218 (view as bug list) Environment:
Last Closed: 2010-06-30 15:09:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 609218    
Attachments:
Description Flags
reproducer
none
gdb script to run the reproducer
none
correct reproducer none

Description David Tardon 2010-06-22 07:49:52 UTC
Description of problem:
If there is a C++ class whose first member is of a class type and the class of the member has at least one virt. function, and if "print objects is on, then any print of an object of that class prints only its first member. (Huh, well, not so much of a description... but the sample reproducer should be more comprehensive .-)

Version-Release number of selected component (if applicable):
gdb-7.1-26.fc13.x86_64

How reproducible:
always

Steps to Reproduce:
1. g++ -g3 -o print-class print-class.cc
2. gdb -nx -x print-class.gdb ./print-class
3. observe the result
  
Actual results:
$1 = (base) {_vptr.base = 0x400810}

Expected results:
$1 = {m_base = {_vptr.base = 0x400810}, m_i = 0}

Comment 1 David Tardon 2010-06-22 07:50:28 UTC
Created attachment 425847 [details]
reproducer

Comment 2 David Tardon 2010-06-22 07:50:53 UTC
Created attachment 425849 [details]
gdb script to run the reproducer

Comment 3 Jan Kratochvil 2010-06-25 11:21:35 UTC
I do not have the problem reproducible, it always prints:
$1 = {m_i = 0, m_base = {_vptr.base = 0x400830}}

It works the same even with `set print object on' removed as `obj' has both the declared type `wrapper' and the instance has also the rtti type `wrapper'.

Tested all the combinations of:
gdb-7.1-26.fc13.x86_64
GNU gdb (GDB) 7.1.50.20100625-cvs
gcc-c++-4.4.4-2.fc13.x86_64
gcc-c++-4.4.4-8.fc13.x86_64
g++ (GCC) 4.4.5 20100625 (prerelease)

These have a problem but this is outside of the Fedora BZ scope:
g++ (GCC) 4.5.1 20100625 (prerelease)
g++ (GCC) 4.6.0 20100625 (experimental)

Comment 4 David Tardon 2010-06-25 11:42:06 UTC
It fails here with

gdb-7.1-26.fc13.x86_64
gcc-4.4.4-8.fc14.x86_64

. As a matter of fact, I saw the same problem before ~4 months, but did nothing about it then.

Comment 6 Jan Kratochvil 2010-06-25 11:50:28 UTC
(In reply to comment #4)
> It fails here with
> 
> gdb-7.1-26.fc13.x86_64
> gcc-4.4.4-8.fc14.x86_64

Works even with these versions (forgot this is filed against Rawhide).

Please provide best the .s output and also the binary:
g++ -g3 -S -o print-class.s print-class.cc

BTW suggesting in this case s/-g3/-Wall -g/.

Comment 7 David Tardon 2010-06-25 11:50:54 UTC
Created attachment 426861 [details]
correct reproducer

I'm sorry for the confusion...

Comment 8 Jan Kratochvil 2010-06-27 13:18:27 UTC
Post for FSF GDB:
http://sourceware.org/ml/gdb-patches/2010-06/msg00615.html

Comment 9 Fedora Update System 2010-06-29 23:52:59 UTC
gdb-7.1-27.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/gdb-7.1-27.fc13

Comment 10 Fedora Update System 2010-06-30 15:09:12 UTC
gdb-7.1-27.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.