[RFC,v2,15/27] Add Infinity THREAD_SELF macros to sysdeps/sparc/nptl/tls.h

Message ID 1465814311-31470-16-git-send-email-gbenson@redhat.com
State New, archived
Headers

Commit Message

Gary Benson June 13, 2016, 10:38 a.m. UTC
  This commit adds Infinity THREAD_SELF macros for sparc.
---
 sysdeps/sparc/nptl/tls.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
  

Comments

Andreas Schwab June 13, 2016, 11:51 a.m. UTC | #1
Gary Benson <gbenson@redhat.com> writes:

> +/* Magic for Infinity to know how to do THREAD_SELF.  */
> +# define I8_THREAD_SELF I8_TS_REGISTER
> +# if __WORDSIZE == 32
> +#  define I8_TS_REG_OFFSET 10 * 4
> +# else
> +#  define I8_TS_REG_OFFSET (6 * 8) + (__WORDSIZE==64?0:4)

__WORDSIZE is always 64 here.

Andreas.
  
Gary Benson June 13, 2016, 2:05 p.m. UTC | #2
Hi Andreas,

Andreas Schwab wrote:
> Gary Benson <gbenson@redhat.com> writes:
> > +/* Magic for Infinity to know how to do THREAD_SELF.  */
> > +# define I8_THREAD_SELF I8_TS_REGISTER
> > +# if __WORDSIZE == 32
> > +#  define I8_TS_REG_OFFSET 10 * 4
> > +# else
> > +#  define I8_TS_REG_OFFSET (6 * 8) + (__WORDSIZE==64?0:4)
> 
> __WORDSIZE is always 64 here.

I was trying to make sense of what sparc is doing for libthread_db
too.  It has:

  # define DB_THREAD_SELF \
    REGISTER (32, 32, 10 * 4, 0) \
    REGISTER (64, __WORDSIZE, (6 * 8) + (__WORDSIZE==64?0:4), 0)

Similarly s390 has:

  # define DB_THREAD_SELF REGISTER (32, 32, 18 * 4, 0) \
                          REGISTER (64, __WORDSIZE, 18 * 8, 0)

Could the __WORDSIZE in both of those be replaced with 64?

Thanks,
Gary
  
Andreas Schwab June 13, 2016, 3:08 p.m. UTC | #3
Gary Benson <gbenson@redhat.com> writes:

> I was trying to make sense of what sparc is doing for libthread_db
> too.  It has:
>
>   # define DB_THREAD_SELF \
>     REGISTER (32, 32, 10 * 4, 0) \
>     REGISTER (64, __WORDSIZE, (6 * 8) + (__WORDSIZE==64?0:4), 0)
>
> Similarly s390 has:
>
>   # define DB_THREAD_SELF REGISTER (32, 32, 18 * 4, 0) \
>                           REGISTER (64, __WORDSIZE, 18 * 8, 0)
>
> Could the __WORDSIZE in both of those be replaced with 64?

No, of course not.  It is 32 in a 32-bit process.

Andreas.
  
Gary Benson June 15, 2016, 8:50 a.m. UTC | #4
Andreas Schwab wrote:
> Gary Benson <gbenson@redhat.com> writes:
> > I was trying to make sense of what sparc is doing for libthread_db
> > too.  It has:
> >
> >   # define DB_THREAD_SELF \
> >     REGISTER (32, 32, 10 * 4, 0) \
> >     REGISTER (64, __WORDSIZE, (6 * 8) + (__WORDSIZE==64?0:4), 0)
> >
> > Similarly s390 has:
> >
> >   # define DB_THREAD_SELF REGISTER (32, 32, 18 * 4, 0) \
> >                           REGISTER (64, __WORDSIZE, 18 * 8, 0)
> >
> > Could the __WORDSIZE in both of those be replaced with 64?
> 
> No, of course not.  It is 32 in a 32-bit process.

Ah, I see what's happening now.

What's being passed to libthread_db (and to Infinity in this series)
is a byte offset in bytes into prgregset_t.  That doesn't work for
Infinity if the offsets change depending on the wordsize of the
debugger.  I'll change these patches to pass a DWARF register number
and let the debugger figure out how to get the value.

Thanks for helping me work this out.

Cheers,
Gary
  

Patch

diff --git a/sysdeps/sparc/nptl/tls.h b/sysdeps/sparc/nptl/tls.h
index 08c0552..d8a24b6 100644
--- a/sysdeps/sparc/nptl/tls.h
+++ b/sysdeps/sparc/nptl/tls.h
@@ -125,6 +125,15 @@  register struct pthread *__thread_self __asm__("%g7");
   REGISTER (32, 32, 10 * 4, 0) \
   REGISTER (64, __WORDSIZE, (6 * 8) + (__WORDSIZE==64?0:4), 0)
 
+/* Magic for Infinity to know how to do THREAD_SELF.  */
+# define I8_THREAD_SELF I8_TS_REGISTER
+# if __WORDSIZE == 32
+#  define I8_TS_REG_OFFSET 10 * 4
+# else
+#  define I8_TS_REG_OFFSET (6 * 8) + (__WORDSIZE==64?0:4)
+# endif
+# define I8_TS_REG_BIAS 0
+
 /* Access to data in the thread descriptor is easy.  */
 #define THREAD_GETMEM(descr, member) \
   descr->member