summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog24
-rw-r--r--nptl/pthread_create.c7
-rw-r--r--nptl/pthread_key_create.c6
-rw-r--r--nptl/sysdeps/alpha/td_ta_map_lwp2thr.c46
-rw-r--r--nptl/sysdeps/alpha/tls.h4
-rw-r--r--nptl/sysdeps/generic/td_ta_map_lwp2thr.c45
-rw-r--r--nptl/sysdeps/i386/td_ta_map_lwp2thr.c48
-rw-r--r--nptl/sysdeps/i386/tls.h5
-rw-r--r--nptl/sysdeps/ia64/td_ta_map_lwp2thr.c44
-rw-r--r--nptl/sysdeps/ia64/tls.h3
-rw-r--r--nptl/sysdeps/powerpc/td_ta_map_lwp2thr.c44
-rw-r--r--nptl/sysdeps/powerpc/tls.h7
-rw-r--r--nptl/sysdeps/s390/td_ta_map_lwp2thr.c45
-rw-r--r--nptl/sysdeps/s390/tls.h3
-rw-r--r--nptl/sysdeps/sh/td_ta_map_lwp2thr.c44
-rw-r--r--nptl/sysdeps/sh/tls.h3
-rw-r--r--nptl/sysdeps/sparc/td_ta_map_lwp2thr.c44
-rw-r--r--nptl/sysdeps/sparc/tls.h5
-rw-r--r--nptl/sysdeps/x86_64/td_ta_map_lwp2thr.c43
-rw-r--r--nptl/sysdeps/x86_64/tls.h3
20 files changed, 61 insertions, 412 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 0b16c02fa9..dba84a4e7f 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,27 @@
+2003-09-05  Roland McGrath  <roland@redhat.com>
+
+	* pthread_create.c (__pthread_pthread_sizeof_descr): Removed.
+	Instead, include ../nptl_db/db_info.c to do its magic.
+	* pthread_key_create.c (__pthread_pthread_keys_max): Removed.
+	(__pthread_pthread_key_2ndlevel_size): Likewise.
+	* sysdeps/alpha/tls.h (DB_THREAD_SELF): New macro.
+	* sysdeps/i386/tls.h (DB_THREAD_SELF): New macro.
+	* sysdeps/ia64/tls.h (DB_THREAD_SELF): New macro.
+	* sysdeps/powerpc/tls.h (DB_THREAD_SELF): New macro.
+	* sysdeps/s390/tls.h (DB_THREAD_SELF): New macro.
+	* sysdeps/sh/tls.h (DB_THREAD_SELF): New macro.
+	* sysdeps/sparc/tls.h (DB_THREAD_SELF): New macro.
+	* sysdeps/x86_64/tls.h (DB_THREAD_SELF): New macro.
+	* sysdeps/alpha/td_ta_map_lwp2thr.c: File removed.
+	* sysdeps/generic/td_ta_map_lwp2thr.c: File removed.
+	* sysdeps/i386/td_ta_map_lwp2thr.c: File removed.
+	* sysdeps/ia64/td_ta_map_lwp2thr.c: File removed.
+	* sysdeps/powerpc/td_ta_map_lwp2thr.c: File removed.
+	* sysdeps/s390/td_ta_map_lwp2thr.c: File removed.
+	* sysdeps/sh/td_ta_map_lwp2thr.c: File removed.
+	* sysdeps/sparc/td_ta_map_lwp2thr.c: File removed.
+	* sysdeps/x86_64/td_ta_map_lwp2thr.c: File removed.
+
 2003-09-08  Ulrich Drepper  <drepper@redhat.com>
 
 	* sysdeps/unix/sysv/linux/x86_64/bits/pthreadtypes.h: Change type
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 49825f093e..f8ab269bdd 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -60,9 +60,6 @@ struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX]
   __attribute__ ((nocommon));
 hidden_data_def (__pthread_keys)
 
-/* This is for libthread_db only.  */
-const int __pthread_pthread_sizeof_descr = sizeof (struct pthread);
-
 struct pthread *
 internal_function
 __find_in_stack_list (pd)
@@ -475,3 +472,7 @@ __pthread_create_2_0 (newthread, attr, start_routine, arg)
 compat_symbol (libpthread, __pthread_create_2_0, pthread_create,
 	       GLIBC_2_0);
 #endif
+
+/* Information for libthread_db.  */
+
+#include "../nptl_db/db_info.c"
diff --git a/nptl/pthread_key_create.c b/nptl/pthread_key_create.c
index 7827d9affc..cf35bc8776 100644
--- a/nptl/pthread_key_create.c
+++ b/nptl/pthread_key_create.c
@@ -24,12 +24,6 @@
 /* Internal mutex for __pthread_keys table handling.  */
 lll_lock_t __pthread_keys_lock = LLL_LOCK_INITIALIZER;
 
-
-/* For debugging purposes put the maximum number of keys in a variable.  */
-const int __pthread_pthread_keys_max = PTHREAD_KEYS_MAX;
-const int __pthread_pthread_key_2ndlevel_size = PTHREAD_KEY_2NDLEVEL_SIZE;
-
-
 int
 __pthread_key_create (key, destr)
      pthread_key_t *key;
diff --git a/nptl/sysdeps/alpha/td_ta_map_lwp2thr.c b/nptl/sysdeps/alpha/td_ta_map_lwp2thr.c
deleted file mode 100644
index b30b10b123..0000000000
--- a/nptl/sysdeps/alpha/td_ta_map_lwp2thr.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Which thread is running on an LWP?  PowerPC version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include "thread_dbP.h"
-#include <tls.h>
-
-
-td_err_e
-td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
-{
-  LOG ("td_ta_map_lwp2thr");
-
-  /* Test whether the TA parameter is ok.  */
-  if (! ta_ok (ta))
-    return TD_BADTA;
-
-  prgregset_t regs;
-  if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
-    return TD_ERR;
-
-  /* The uniq value is stored in slot 33 in recent gdb; it isn't stored
-     anywhere otherwise.  */
-  th->th_unique = ((void *) regs[32]
-		   - TLS_TCB_OFFSET - TLS_TCB_SIZE - TLS_PRE_TCB_SIZE);
-
-  /* Found it.  Now complete the `td_thrhandle_t' object.  */
-  th->th_ta_p = (td_thragent_t *) ta;
-
-  return TD_OK;
-}
diff --git a/nptl/sysdeps/alpha/tls.h b/nptl/sysdeps/alpha/tls.h
index 1718b3e466..8f61bb7409 100644
--- a/nptl/sysdeps/alpha/tls.h
+++ b/nptl/sysdeps/alpha/tls.h
@@ -118,6 +118,10 @@ typedef struct
     ((struct pthread *) (__builtin_thread_pointer () \
 			 - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
 
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF \
+  REGISTER (64, 32 * 8, - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+
 /* Identifier for the current thread.  THREAD_SELF is usable but
    sometimes more expensive than necessary as in this case.  */
 # define THREAD_ID (__builtin_thread_pointer ())
diff --git a/nptl/sysdeps/generic/td_ta_map_lwp2thr.c b/nptl/sysdeps/generic/td_ta_map_lwp2thr.c
deleted file mode 100644
index 126673e9af..0000000000
--- a/nptl/sysdeps/generic/td_ta_map_lwp2thr.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Which thread is running on an LWP?  Stub version.
-   Copyright (C) 2002 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include "thread_dbP.h"
-#include <tls.h>
-#include <sys/reg.h>
-
-
-td_err_e
-td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
-{
-  LOG ("td_ta_map_lwp2thr");
-
-  /* Test whether the TA parameter is ok.  */
-  if (! ta_ok (ta))
-    return TD_BADTA;
-
-  prgregset_t regs;
-  if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
-    return TD_ERR;
-
-# error port this file
-  // th->th_unique = thread register;
-
-  /* Found it.  Now complete the `td_thrhandle_t' object.  */
-  th->th_ta_p = (td_thragent_t *) ta;
-
-  return TD_OK;
-}
diff --git a/nptl/sysdeps/i386/td_ta_map_lwp2thr.c b/nptl/sysdeps/i386/td_ta_map_lwp2thr.c
deleted file mode 100644
index 94f6d34987..0000000000
--- a/nptl/sysdeps/i386/td_ta_map_lwp2thr.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Which thread is running on an LWP?  i386 version.
-   Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include "thread_dbP.h"
-#include <tls.h>
-#include <sys/reg.h>
-
-
-td_err_e
-td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
-{
-  LOG ("td_ta_map_lwp2thr");
-
-  /* Test whether the TA parameter is ok.  */
-  if (! ta_ok (ta))
-    return TD_BADTA;
-
-  prgregset_t regs;
-  if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
-    return TD_ERR;
-
-  /* Get the thread area for the addressed thread.  */
-  if (ps_get_thread_area (ta->ph, lwpid, regs[GS] >> 3, &th->th_unique)
-      != PS_OK)
-    return TD_ERR;	/* XXX Other error value?  */
-
-  /* Found it.  Now complete the `td_thrhandle_t' object.  */
-  th->th_ta_p = (td_thragent_t *) ta;
-
-  return TD_OK;
-}
diff --git a/nptl/sysdeps/i386/tls.h b/nptl/sysdeps/i386/tls.h
index 85d6473380..873467ca77 100644
--- a/nptl/sysdeps/i386/tls.h
+++ b/nptl/sysdeps/i386/tls.h
@@ -251,6 +251,11 @@ union user_desc_init
 	  : "i" (offsetof (struct pthread, header.self)));		      \
      __self;})
 
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF \
+  REGISTER_THREAD_AREA (32, offsetof (struct user_regs_struct, xgs), 3) \
+  REGISTER_THREAD_AREA (64, 26 * 8, 3) /* x86-64's user_regs_struct->gs */
+
 
 /* Read member of the thread descriptor directly.  */
 # define THREAD_GETMEM(descr, member) \
diff --git a/nptl/sysdeps/ia64/td_ta_map_lwp2thr.c b/nptl/sysdeps/ia64/td_ta_map_lwp2thr.c
deleted file mode 100644
index b9f32eb8a1..0000000000
--- a/nptl/sysdeps/ia64/td_ta_map_lwp2thr.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Which thread is running on an LWP?  IA-64 version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include "thread_dbP.h"
-#include <tls.h>
-
-
-td_err_e
-td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
-{
-  LOG ("td_ta_map_lwp2thr");
-
-  /* Test whether the TA parameter is ok.  */
-  if (! ta_ok (ta))
-    return TD_BADTA;
-
-  prgregset_t regs;
-  if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
-    return TD_ERR;
-
-  /* IA-64 thread register is r13.  */
-  th->th_unique = (void *) (((struct pthread *) regs[13]) - 1);
-
-  /* Found it.  Now complete the `td_thrhandle_t' object.  */
-  th->th_ta_p = (td_thragent_t *) ta;
-
-  return TD_OK;
-}
diff --git a/nptl/sysdeps/ia64/tls.h b/nptl/sysdeps/ia64/tls.h
index 8a13a59d30..b6b20c0f50 100644
--- a/nptl/sysdeps/ia64/tls.h
+++ b/nptl/sysdeps/ia64/tls.h
@@ -113,6 +113,9 @@ register struct pthread *__thread_self __asm__("r13");
 /* Return the thread descriptor for the current thread.  */
 # define THREAD_SELF (__thread_self - 1)
 
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF REGISTER (64, 13 * 8, -sizeof (struct pthread))
+
 /* Access to data in the thread descriptor is easy.  */
 #define THREAD_GETMEM(descr, member) \
   descr->member
diff --git a/nptl/sysdeps/powerpc/td_ta_map_lwp2thr.c b/nptl/sysdeps/powerpc/td_ta_map_lwp2thr.c
deleted file mode 100644
index d1a93681a3..0000000000
--- a/nptl/sysdeps/powerpc/td_ta_map_lwp2thr.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Which thread is running on an LWP?  PowerPC version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include "thread_dbP.h"
-#include <tls.h>
-
-
-td_err_e
-td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
-{
-  LOG ("td_ta_map_lwp2thr");
-
-  /* Test whether the TA parameter is ok.  */
-  if (! ta_ok (ta))
-    return TD_BADTA;
-
-  prgregset_t regs;
-  if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
-    return TD_ERR;
-
-  th->th_unique = ((void *) regs[PT_THREAD_POINTER]
-		   - TLS_TCB_OFFSET - TLS_TCB_SIZE - TLS_PRE_TCB_SIZE);
-
-  /* Found it.  Now complete the `td_thrhandle_t' object.  */
-  th->th_ta_p = (td_thragent_t *) ta;
-
-  return TD_OK;
-}
diff --git a/nptl/sysdeps/powerpc/tls.h b/nptl/sysdeps/powerpc/tls.h
index 6573bb6b04..02595637c7 100644
--- a/nptl/sysdeps/powerpc/tls.h
+++ b/nptl/sysdeps/powerpc/tls.h
@@ -129,6 +129,13 @@ register void *__thread_register __asm__ ("r13");
     ((struct pthread *) (__thread_register \
 			 - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE))
 
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF							      \
+  REGISTER (32, PT_THREAD_POINTER * 4,					      \
+	    - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)			      \
+  REGISTER (64, PT_THREAD_POINTER * 8,					      \
+	    - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
+
 /* Read member of the thread descriptor directly.  */
 # define THREAD_GETMEM(descr, member) ((void)(descr), (THREAD_SELF)->member)
 
diff --git a/nptl/sysdeps/s390/td_ta_map_lwp2thr.c b/nptl/sysdeps/s390/td_ta_map_lwp2thr.c
deleted file mode 100644
index 5b0bf840d8..0000000000
--- a/nptl/sysdeps/s390/td_ta_map_lwp2thr.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Which thread is running on an LWP?  i386 version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Martin Schwidefsky <schwidefsky@de.ibm.com>, 2003.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include "thread_dbP.h"
-#include <tls.h>
-
-
-td_err_e
-td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
-{
-  LOG ("td_ta_map_lwp2thr");
-
-  /* Test whether the TA parameter is ok.  */
-  if (! ta_ok (ta))
-    return TD_BADTA;
-
-  prgregset_t regs;
-  if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
-    return TD_ERR;
-
-  /* S390 thread register is ACR0, aka register 18.  */
-  th->th_unique = (void *) regs[18];
-
-  /* Found it.  Now complete the `td_thrhandle_t' object.  */
-  th->th_ta_p = (td_thragent_t *) ta;
-
-  return TD_OK;
-}
diff --git a/nptl/sysdeps/s390/tls.h b/nptl/sysdeps/s390/tls.h
index 06237ae15b..7b38e3389d 100644
--- a/nptl/sysdeps/s390/tls.h
+++ b/nptl/sysdeps/s390/tls.h
@@ -137,6 +137,9 @@ typedef struct
 /* Return the thread descriptor for the current thread.  */
 # define THREAD_SELF ((struct pthread *) __builtin_thread_pointer ())
 
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF REGISTER (32, 18 * 4, 0) REGISTER (64, 18 * 8, 0)
+
 /* Access to data in the thread descriptor is easy.  */
 #define THREAD_GETMEM(descr, member) \
   descr->member
diff --git a/nptl/sysdeps/sh/td_ta_map_lwp2thr.c b/nptl/sysdeps/sh/td_ta_map_lwp2thr.c
deleted file mode 100644
index 75853009da..0000000000
--- a/nptl/sysdeps/sh/td_ta_map_lwp2thr.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Which thread is running on an LWP?  Stub version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include "thread_dbP.h"
-#include <tls.h>
-#include <sys/reg.h>
-
-
-td_err_e
-td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
-{
-  LOG ("td_ta_map_lwp2thr");
-
-  /* Test whether the TA parameter is ok.  */
-  if (! ta_ok (ta))
-    return TD_BADTA;
-
-  prgregset_t regs;
-  if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
-    return TD_ERR;
-
-  th->th_unique = regs[REG_GBR];
-
-  /* Found it.  Now complete the `td_thrhandle_t' object.  */
-  th->th_ta_p = (td_thragent_t *) ta;
-
-  return TD_OK;
-}
diff --git a/nptl/sysdeps/sh/tls.h b/nptl/sysdeps/sh/tls.h
index 1e27b987e0..b6d8428bf6 100644
--- a/nptl/sysdeps/sh/tls.h
+++ b/nptl/sysdeps/sh/tls.h
@@ -117,6 +117,9 @@ typedef struct
      __asm ("stc gbr,%0" : "=r" (__self));				      \
      __self - 1;})
 
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF REGISTER (32, REG_GBR * 4, 0)
+
 /* Read member of the thread descriptor directly.  */
 # define THREAD_GETMEM(descr, member) (descr->member)
 
diff --git a/nptl/sysdeps/sparc/td_ta_map_lwp2thr.c b/nptl/sysdeps/sparc/td_ta_map_lwp2thr.c
deleted file mode 100644
index f120b96e73..0000000000
--- a/nptl/sysdeps/sparc/td_ta_map_lwp2thr.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Which thread is running on an LWP?  SPARC version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include "thread_dbP.h"
-#include <tls.h>
-
-
-td_err_e
-td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
-{
-  LOG ("td_ta_map_lwp2thr");
-
-  /* Test whether the TA parameter is ok.  */
-  if (! ta_ok (ta))
-    return TD_BADTA;
-
-  prgregset_t regs;
-  if (ps_lgetregs (ta->ph, lwpid, regs) != PS_OK)
-    return TD_ERR;
-
-  /* SPARC thread register is %g7.  */
-  th->th_unique = (void *) regs[7];
-
-  /* Found it.  Now complete the `td_thrhandle_t' object.  */
-  th->th_ta_p = (td_thragent_t *) ta;
-
-  return TD_OK;
-}
diff --git a/nptl/sysdeps/sparc/tls.h b/nptl/sysdeps/sparc/tls.h
index 87255941c1..8c4264f24f 100644
--- a/nptl/sysdeps/sparc/tls.h
+++ b/nptl/sysdeps/sparc/tls.h
@@ -104,6 +104,11 @@ register struct pthread *__thread_self __asm__("%g7");
 /* Return the thread descriptor for the current thread.  */
 #define THREAD_SELF  __thread_self
 
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF_INCLUDE <sys/ucontext.h>
+# define DB_THREAD_SELF \
+  REGISTER (32, REG_G7 * 4, 0) REGISTER (64, REG_G7 * 8, 0)
+
 /* Access to data in the thread descriptor is easy.  */
 #define THREAD_GETMEM(descr, member) \
   descr->member
diff --git a/nptl/sysdeps/x86_64/td_ta_map_lwp2thr.c b/nptl/sysdeps/x86_64/td_ta_map_lwp2thr.c
deleted file mode 100644
index d49d00c277..0000000000
--- a/nptl/sysdeps/x86_64/td_ta_map_lwp2thr.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Which thread is running on an LWP?  x86-64 version.
-   Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#include "thread_dbP.h"
-#include <tls.h>
-#include <sys/reg.h>
-
-
-td_err_e
-td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
-{
-  LOG ("td_ta_map_lwp2thr");
-
-  /* Test whether the TA parameter is ok.  */
-  if (! ta_ok (ta))
-    return TD_BADTA;
-
-  /* Get the %fs segment register base address for the addressed thread.  */
-  if (ps_get_thread_area (ta->ph, lwpid, FS, &th->th_unique) != PS_OK)
-    return TD_ERR;	/* XXX Other error value?  */
-
-  /* Found it.  Now complete the `td_thrhandle_t' object.  */
-  th->th_ta_p = (td_thragent_t *) ta;
-
-  return TD_OK;
-}
diff --git a/nptl/sysdeps/x86_64/tls.h b/nptl/sysdeps/x86_64/tls.h
index 999c3aa55a..3d6111f4e3 100644
--- a/nptl/sysdeps/x86_64/tls.h
+++ b/nptl/sysdeps/x86_64/tls.h
@@ -161,6 +161,9 @@ typedef struct
 	  : "i" (offsetof (struct pthread, header.self)));	 	      \
      __self;})
 
+/* Magic for libthread_db to know how to do THREAD_SELF.  */
+# define DB_THREAD_SELF_INCLUDE  <sys/reg.h> /* For the FS constant.  */
+# define DB_THREAD_SELF CONST_THREAD_AREA (64, FS)
 
 /* Read member of the thread descriptor directly.  */
 # define THREAD_GETMEM(descr, member) \