c++/2039: gdb assumes 4 byte separation between 64 bit "long long" and "unsigned long long" stack allocated (not pointers) data member types within a C++ class

mstraub@gmail.com mstraub@gmail.com
Tue Nov 29 15:58:00 GMT 2005


>Number:         2039
>Category:       c++
>Synopsis:       gdb assumes 4 byte separation between 64 bit "long long" and "unsigned long long" stack allocated (not pointers) data member types within a C++ class
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 29 15:58:01 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     M.Straub
>Release:        GDB 6.2.1 (Bundled with SuSE 9.1)
>Organization:
>Environment:
SuSE 9.1, running under KDE, Intel 32bit architecture.
>Description:
When debugging a class with two or more 64 bit integers (signed or unsigned) as data members, the GDB parser assumes that the addresses of those two data members are 4 bytes apart and displays the values of those data members incorrectly in the debugger.
>How-To-Repeat:
Create a simple C++ class with two public "long long" data members.  Create a property set method, setting both values to a unique value that occupies 64 bits.  Use stdout print statements to print out the values of those variables immediately after setting them along with the address of those variables.  Use the gdb print or display command to print the values after the stdout print statements.  Doing this I consistently see the correct values printed to stdout, but incorrect values displayed in the debugger... Furthermore printing the address of those varaibles I see that the addresses are only 4 bytes apart... incorrect.
I believe gdb is incorrectly guessing the offsets of data members in or around 64 bit integers.
>Fix:
Fix GDB parser to correctly recognize that 64 bit variables take up 8 bytes and that pointers/addresses to data members after "long long" or "unsigned long long" should be 8 bytes apart, not 4.  The only case that they would be 4 apart would be if they were pointers to 64 bit integer.  Stack allocated 64 bit integers need to have addresses that are at a minimum 8 bytes apart.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gdb-prs mailing list