http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46815
Summary: Invalid DW_AT_location for a retval instance of a
class that has a virtual function
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: debug
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 22649
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22649
Reproducer program to run under gdb
Problem Description:
When a local object is created from a class with a virtual function and that
object is also the retval for the function it is the local variable in, the
debuginfo generated for the object indicates that it is located in a register,
while in reality, its address is located in the register.
Steps to Reproduce:
$ cat > rep.cpp
class Sequence {
public:
virtual void foo(void);
};
Sequence getSequence()
{
Sequence data;
return data;
}
$ g++ -g -c rep.cpp
$ objdump -W rep.o | less
...
<3><c4>: Abbrev Number: 13 (DW_TAG_variable)
<c5> DW_AT_name : (indirect string, offset: 0x43): data
<c9> DW_AT_decl_file : 1
<ca> DW_AT_decl_line : 8
<cb> DW_AT_type : <0x31>
<cf> DW_AT_location : 1 byte block: 53 (DW_OP_reg3)
...
Additional Information:
Attached reproducer fullrep.cpp can be used to demonstrate this problem as seen
in gdb.
1) Build fullrep.cpp: gcc -g fullrep.cpp
2) Run under gdb:
[siddh...@spoyarek gcc-foo]$ gdb -q ./a.out
Reading symbols from /home/siddhesh/gcc-foo/a.out...done.
(gdb) break getSequence
Breakpoint 1 at 0x4007e0: file fullrep.cpp, line 14.
(gdb) r
Starting program: /home/siddhesh/gcc-foo/a.out
Breakpoint 1, getSequence () at fullrep.cpp:14
14 Sequence data;
(gdb) p data
$1 = {_vptr.Sequence = 0x7fffffffdfd0, i = 4}
(gdb) p &data
Address requested for identifier "data" which is in register $rbx
(gdb) p *((Sequence *)$rbx)
$2 = {_vptr.Sequence = 0x7fffffffe0c0, i = 0}
(gdb)