Bug 9607 - print displays wrong value of char-pointer in a class, delivered as function parameter
Summary: print displays wrong value of char-pointer in a class, delivered as function ...
Status: RESOLVED DUPLICATE of bug 11836
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.8
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-18 19:38 UTC by cmayer
Modified: 2010-10-11 22:13 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
gdb_bug.tar.gz (697 bytes, application/octet-stream)
, cmayer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cmayer 2008-08-18 19:38:01 UTC
[Converted from Gnats 2502]

"print" displays wrong value of a char-pointer in a class, delivered as function-parameter. Output by cerr displays the correct value.

Release:
gdb 6.8

Environment:
Arch Linux, kernel 2.6.26, gcc 4.3.1, gdb 6.8,make 3.81

How-To-Repeat:
Download the attachet file. Unpack it and compile it with make. Debug the created prog with gdb and set a breakpoint at test.cpp:10 (output by cerr). type print param in the gdb-console.
Comment 1 Tom Tromey 2009-05-20 22:58:55 UTC
I can use a trick to see the string:

(gdb) p ((char **) &param)[1]
$2 = 0x8048936 "TestValue"

gdb appears to be printing the "zeroth slot" of the object rather than the first.
This in turns appears to be a debug info problem, afaict:

 <1><33f4>: Abbrev Number: 79 (DW_TAG_class_type)
    <33f5>   DW_AT_name        : (indirect string, offset: 0x19b8): myclass     
    <33f9>   DW_AT_byte_size   : 4      
    <33fa>   DW_AT_decl_file   : 29     
    <33fb>   DW_AT_decl_line   : 9      
    <33fc>   DW_AT_sibling     : <0x343e>       
 <2><3400>: Abbrev Number: 80 (DW_TAG_member)
    <3401>   DW_AT_name        : str    
    <3405>   DW_AT_decl_file   : 29     
    <3406>   DW_AT_decl_line   : 11     
    <3407>   DW_AT_type        : <0xaef>        
    <340b>   DW_AT_data_member_location: 2 byte block: 23 0    
(DW_OP_plus_uconst: 0)


It seems to me that the data member location should not be 0.
However, I am not certain; I'll have to do more reading.
Comment 2 Tom Tromey 2009-05-21 19:03:13 UTC
This diagnosis is wrong -- I'm not sure what I was thinking here,
since this class doesn't have a vtable.  So, the string should appear
at offset 0.
This could be bad debug info elsewhere.  Or an undiagnosed bug in gdb.
Comment 3 Tom Tromey 2010-10-11 22:13:52 UTC
I think this is a bug in g++.
Closing as a dup of the gdb tracker.

*** This bug has been marked as a duplicate of bug 11836 ***