public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug symtab/11717] common/.bss variables from shared libraries not  displayed correctly
       [not found] <bug-11717-4717@http.sourceware.org/bugzilla/>
@ 2012-01-31 18:05 ` eager at eagercon dot com
  2012-04-03  8:30 ` jakub at redhat dot com
  1 sibling, 0 replies; 6+ messages in thread
From: eager at eagercon dot com @ 2012-01-31 18:05 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=11717

eager at eagercon dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eager at eagercon dot com

--- Comment #3 from eager at eagercon dot com 2012-01-31 18:04:56 UTC ---
As the test case shows, this problem is not limited to unintialized variables
in .bss -- it also occurs with initialized variables in .data.  

The basic problem is that the DW_AT_location for the variable in the shared
library is incorrect, since it does not match how the variable is accessed.  It
says that var is addressed directly, while in fact it is accessed indirectly
through the GOT.

GCC generates
    DW_OP_addr  var
which points to the unused copy of var in the shared library.  The correct
DWARF should be
    DW_OP_addr  var@GOT
    DW_OP_deref

I'm unclear what the patch is doing exactly, but to the extent it is having gdb
ignore the generated debug info, as suggested by this comment
+          /* Never use DW_AT_location, rely on the minimal symbols.  */
then this seems to be headed in the wrong direction.  The best fix for
incorrect debug data is to generate the correct info.  Or this fix should be
clearly identified as a workaround for incorrect data, with some way of
defeating the workaround when correct data is present.

Unfortunately, gdb does not currently support "complex" DWARF expressions which
include an indirect reference.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug symtab/11717] common/.bss variables from shared libraries not  displayed correctly
       [not found] <bug-11717-4717@http.sourceware.org/bugzilla/>
  2012-01-31 18:05 ` [Bug symtab/11717] common/.bss variables from shared libraries not displayed correctly eager at eagercon dot com
@ 2012-04-03  8:30 ` jakub at redhat dot com
  1 sibling, 0 replies; 6+ messages in thread
From: jakub at redhat dot com @ 2012-04-03  8:30 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=11717

Jakub Jelinek <jakub at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at redhat dot com

--- Comment #4 from Jakub Jelinek <jakub at redhat dot com> 2012-04-03 08:30:08 UTC ---
(In reply to comment #3)
> As the test case shows, this problem is not limited to unintialized variables
> in .bss -- it also occurs with initialized variables in .data.  
> 
> The basic problem is that the DW_AT_location for the variable in the shared
> library is incorrect, since it does not match how the variable is accessed.  It
> says that var is addressed directly, while in fact it is accessed indirectly
> through the GOT.
> 
> GCC generates
>     DW_OP_addr  var
> which points to the unused copy of var in the shared library.  The correct
> DWARF should be
>     DW_OP_addr  var@GOT
>     DW_OP_deref

Unfortunately, that has a couple of problems:
1) we don't want to generate runtime overhead just for debugging, so the above
   would "work" only if we have some other GOT reference to that symbol in the
   code
2) on most targets we don't have suitable relocations that would give us the 
   address of the GOT slot
Even
DW_OP_addr var@GOT
DW_OP_addr _GLOBAL_OFFSET_TABLE_
DW_OP_plus
DW_OP_deref
doesn't work on x86_64, while var@GOT in that case gives the relative offset
from _GLOBAL_OFFSET_TABLE_ to the GOT entry for var, unfortunately
_GLOBAL_OFFSET_TABLE_ symbol is handled specially and thus becomes a wrong kind
of relocation.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug symtab/11717] common/.bss variables from shared libraries not  displayed correctly
  2010-06-18 13:25 [Bug symtab/11717] New: " lance604 at gmail dot com
                   ` (2 preceding siblings ...)
  2010-07-21  8:55 ` jan dot kratochvil at redhat dot com
@ 2010-08-22  7:41 ` jan dot kratochvil at redhat dot com
  3 siblings, 0 replies; 6+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-08-22  7:41 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From jan dot kratochvil at redhat dot com  2010-08-22 07:41 -------
#include <iostream>
int main()
{
  return std::cin.eof();
}

(gdb) p std::cin
$1 = {<error reading variable>
(gdb) p &std::cin
$2 = (std::istream *) 0x7ffff7dc7b60
Symbol table '.dynsym' contains 9 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     7: 0000000000600b60   280 OBJECT  GLOBAL DEFAULT   25 _ZSt3cin@GLIBCXX_3.4 (2)

because of:
Relocation section '.rela.dyn' at offset 0x4a8 contains 2 entries:
    Offset             Info             Type               Symbol's Value 
Symbol's Name + Addend
0000000000600b60  0000000700000005 R_X86_64_COPY          0000000000600b60
_ZSt3cin + 0

Unaware if it is the only problem of:
(gdb) p std::cin.eof()
Cannot access memory at address 0xffffffffffffffe8


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11717

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug symtab/11717] common/.bss variables from shared libraries not  displayed correctly
  2010-06-18 13:25 [Bug symtab/11717] New: " lance604 at gmail dot com
  2010-07-12 20:01 ` [Bug symtab/11717] " nbowler at draconx dot ca
  2010-07-21  8:43 ` jan dot kratochvil at redhat dot com
@ 2010-07-21  8:55 ` jan dot kratochvil at redhat dot com
  2010-08-22  7:41 ` jan dot kratochvil at redhat dot com
  3 siblings, 0 replies; 6+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-07-21  8:55 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From jan dot kratochvil at redhat dot com  2010-07-21 08:55 -------
Created an attachment (id=4880)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=4880&action=view)
GDB fix for the copy-relocations.

This patch has been posted first at:
gfortran invalid DW_AT_location for overridable variables
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40040#c7

But it has heavy regressions now, still the symbols reading logic should be
reworked.


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=11717

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug symtab/11717] common/.bss variables from shared libraries not  displayed correctly
  2010-06-18 13:25 [Bug symtab/11717] New: " lance604 at gmail dot com
  2010-07-12 20:01 ` [Bug symtab/11717] " nbowler at draconx dot ca
@ 2010-07-21  8:43 ` jan dot kratochvil at redhat dot com
  2010-07-21  8:55 ` jan dot kratochvil at redhat dot com
  2010-08-22  7:41 ` jan dot kratochvil at redhat dot com
  3 siblings, 0 replies; 6+ messages in thread
From: jan dot kratochvil at redhat dot com @ 2010-07-21  8:43 UTC (permalink / raw)
  To: gdb-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jan dot kratochvil at redhat
                   |                            |dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1


http://sourceware.org/bugzilla/show_bug.cgi?id=11717

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug symtab/11717] common/.bss variables from shared libraries not  displayed correctly
  2010-06-18 13:25 [Bug symtab/11717] New: " lance604 at gmail dot com
@ 2010-07-12 20:01 ` nbowler at draconx dot ca
  2010-07-21  8:43 ` jan dot kratochvil at redhat dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: nbowler at draconx dot ca @ 2010-07-12 20:01 UTC (permalink / raw)
  To: gdb-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nbowler at draconx dot ca


http://sourceware.org/bugzilla/show_bug.cgi?id=11717

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2012-04-03  8:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-11717-4717@http.sourceware.org/bugzilla/>
2012-01-31 18:05 ` [Bug symtab/11717] common/.bss variables from shared libraries not displayed correctly eager at eagercon dot com
2012-04-03  8:30 ` jakub at redhat dot com
2010-06-18 13:25 [Bug symtab/11717] New: " lance604 at gmail dot com
2010-07-12 20:01 ` [Bug symtab/11717] " nbowler at draconx dot ca
2010-07-21  8:43 ` jan dot kratochvil at redhat dot com
2010-07-21  8:55 ` jan dot kratochvil at redhat dot com
2010-08-22  7:41 ` jan dot kratochvil at redhat dot com

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).