public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/46815] New: Invalid DW_AT_location for a retval instance of a class that has a virtual function
@ 2010-12-06  8:10 siddhesh.poyarekar at gmail dot com
  2010-12-06 15:40 ` [Bug debug/46815] " jakub at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: siddhesh.poyarekar at gmail dot com @ 2010-12-06  8:10 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: siddhesh.poyarekar@gmail.com


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:

[siddhesh@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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-12-15 22:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-06  8:10 [Bug debug/46815] New: Invalid DW_AT_location for a retval instance of a class that has a virtual function siddhesh.poyarekar at gmail dot com
2010-12-06 15:40 ` [Bug debug/46815] " jakub at gcc dot gnu.org
2010-12-13 16:03 ` jason at gcc dot gnu.org
2010-12-15 17:51 ` jakub at gcc dot gnu.org
2010-12-15 22:01 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).