This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/14568] New: Sparc64: disagreement between gdb64 and libpthread.so on where to look for %g7


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]