public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug nptl/14568] New: Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7
@ 2012-09-10 14:05 ilmalakhov at yandex dot ru
  2012-09-11  8:43 ` [Bug nptl/14568] " ilmalakhov at yandex dot ru
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ilmalakhov at yandex dot ru @ 2012-09-10 14:05 UTC (permalink / raw)
  To: glibc-bugs

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

             Bug #: 14568
           Summary: Sparc64: disagreement between gdb64 and libpthread.so
                    on where to look for %g7
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: nptl
        AssignedTo: unassigned@sourceware.org
        ReportedBy: ilmalakhov@yandex.ru
                CC: drepper.fsp@gmail.com
    Classification: Unclassified


Hi.

 There seems to be a disagreement between `gdb64' for Sparc64 and
`libpthread.so' on where to look for `%g7' when setting `th_unique' in
libthread_db. First of all, let's consider a situation when a 64-bit program is
being debugged.

 According to `nptl/sysdeps/sparc/tls.h'
. . .
# define DB_THREAD_SELF \
  REGISTER (32, 32, REG_G7 * 4, 0) REGISTER (64, 64, REG_G7 * 8, 0)
. . .

and `sysdeps/unix/sysv/linux/sparc/sys/ucontext.h'
. . .
define REG_G7  (10)
. . .

the value of `%g7' should be fetched from offset `8 * 10 == 0x50' of the `regs'
array filled in by `ps_lgetregs ()' (see the code of `__td_ta_lookup_th_unique
()' in `libthread_db').


 On the other hand, `ps_lgetregs ()' (it is implemented in gdb) ends up
invoking `sparc64_collect_gregset ()' which eventually fills in this array:
. . .
  if ((regnum >= SPARC_G1_REGNUM && regnum <= SPARC_O7_REGNUM) || regnum == -1)
    {
      int offset = gregset->r_g1_offset;

      if (sparc32)
        offset += 4;

      /* %g0 is always zero.  */
      for (i = SPARC_G1_REGNUM; i <= SPARC_O7_REGNUM; i++)
        {
          if (regnum == i || regnum == -1)
            regcache_raw_collect (regcache, i, regs + offset);
          offset += 8;
        }
    }
. . .


 Taking into account that `gregset' turns out to be a pointer to
`sparc64_linux_ptrace_gregset' and that the `r_g1_offset' field of the latter
equals to zero (see `sparc64-linux-nat.c'), `%g7' is actually placed at offset
`6 * 8 == 0x30' rather than 0x50.

 In practice this leads to "cannot get thread info" gdb failures when debugging
multithreaded apps. To fix this either `REGISTER (64, 64, 6 * 8, 0)' should\
 be specified in `libpthread' or `r_g1_offset' fixed appropriately in `gdb64'.


 As for the case of a 32-bit app being debugged with `gdb64', there is another
issue in addition to the described above. I believe that the "size" element of
`_thread_db_register64' should be set to 32 rather than to 64 in 32-bit
`libpthread.so' and that its "regofs" element should be increased by 4 (see the
corresponding code in `gdb64' above'):

# if __WORDSIZE == 64
#  define DB_THREAD_SELF \
  . . .  REGISTER (64, 64, 6 * 8, 0)
# else /* __WORDSIZE == 32  */
#  define DB_THREAD_SELF \
  . . .  REGISTER (64, 32, 6 * 8 + 4, 0)
# endif /* __WORDSIZE == 32  */

-- 
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] 7+ messages in thread

* [Bug nptl/14568] Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7
  2012-09-10 14:05 [Bug nptl/14568] New: Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7 ilmalakhov at yandex dot ru
@ 2012-09-11  8:43 ` ilmalakhov at yandex dot ru
  2012-09-28  7:36 ` davem at davemloft dot net
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ilmalakhov at yandex dot ru @ 2012-09-11  8:43 UTC (permalink / raw)
  To: glibc-bugs

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

Il'ya Malakhov <ilmalakhov at yandex dot ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |davem at davemloft dot net

-- 
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] 7+ messages in thread

* [Bug nptl/14568] Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7
  2012-09-10 14:05 [Bug nptl/14568] New: Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7 ilmalakhov at yandex dot ru
  2012-09-11  8:43 ` [Bug nptl/14568] " ilmalakhov at yandex dot ru
@ 2012-09-28  7:36 ` davem at davemloft dot net
  2012-09-28  7:38 ` davem at davemloft dot net
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: davem at davemloft dot net @ 2012-09-28  7:36 UTC (permalink / raw)
  To: glibc-bugs


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

--- Comment #1 from David S. Miller <davem at davemloft dot net> 2012-09-28 07:35:40 UTC ---
Thanks for this report, your analysis is excellent.

I'll think about whether this is better to fix in GDB or glibc.

-- 
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] 7+ messages in thread

* [Bug nptl/14568] Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7
  2012-09-10 14:05 [Bug nptl/14568] New: Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7 ilmalakhov at yandex dot ru
  2012-09-11  8:43 ` [Bug nptl/14568] " ilmalakhov at yandex dot ru
  2012-09-28  7:36 ` davem at davemloft dot net
@ 2012-09-28  7:38 ` davem at davemloft dot net
  2012-09-28  7:39 ` davem at davemloft dot net
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: davem at davemloft dot net @ 2012-09-28  7:38 UTC (permalink / raw)
  To: glibc-bugs


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

--- Comment #2 from David S. Miller <davem at davemloft dot net> 2012-09-28 07:38:15 UTC ---
Thanks for this report, your analysis is excellent.

I'll think about whether this is better to fix in GDB or glibc.

-- 
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] 7+ messages in thread

* [Bug nptl/14568] Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7
  2012-09-10 14:05 [Bug nptl/14568] New: Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7 ilmalakhov at yandex dot ru
                   ` (2 preceding siblings ...)
  2012-09-28  7:38 ` davem at davemloft dot net
@ 2012-09-28  7:39 ` davem at davemloft dot net
  2012-10-06  5:10 ` davem at davemloft dot net
  2014-06-17  4:35 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: davem at davemloft dot net @ 2012-09-28  7:39 UTC (permalink / raw)
  To: glibc-bugs


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

David S. Miller <davem at davemloft dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at sourceware    |davem at davemloft dot net
                   |dot org                     |

-- 
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] 7+ messages in thread

* [Bug nptl/14568] Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7
  2012-09-10 14:05 [Bug nptl/14568] New: Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7 ilmalakhov at yandex dot ru
                   ` (3 preceding siblings ...)
  2012-09-28  7:39 ` davem at davemloft dot net
@ 2012-10-06  5:10 ` davem at davemloft dot net
  2014-06-17  4:35 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: davem at davemloft dot net @ 2012-10-06  5:10 UTC (permalink / raw)
  To: glibc-bugs


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

David S. Miller <davem at davemloft dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from David S. Miller <davem at davemloft dot net> 2012-10-06 05:09:43 UTC ---
        [BZ #14568]
        * sysdeps/sparc/tls.h (DB_THREAD_SELF_INCLUDE): Delete.
        (DB_THREAD_SELF): Use constants for the register offsets.  Correct
        the case of a 64-bit debugger with a 32-bit inferior.

-- 
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] 7+ messages in thread

* [Bug nptl/14568] Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7
  2012-09-10 14:05 [Bug nptl/14568] New: Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7 ilmalakhov at yandex dot ru
                   ` (4 preceding siblings ...)
  2012-10-06  5:10 ` davem at davemloft dot net
@ 2014-06-17  4:35 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-17  4:35 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=14568

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

end of thread, other threads:[~2014-06-17  4:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-10 14:05 [Bug nptl/14568] New: Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7 ilmalakhov at yandex dot ru
2012-09-11  8:43 ` [Bug nptl/14568] " ilmalakhov at yandex dot ru
2012-09-28  7:36 ` davem at davemloft dot net
2012-09-28  7:38 ` davem at davemloft dot net
2012-09-28  7:39 ` davem at davemloft dot net
2012-10-06  5:10 ` davem at davemloft dot net
2014-06-17  4:35 ` fweimer 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).