about summary refs log tree commit diff
path: root/linuxthreads_db
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads_db')
-rw-r--r--linuxthreads_db/ChangeLog13
-rw-r--r--linuxthreads_db/Makefile2
-rw-r--r--linuxthreads_db/Versions3
-rw-r--r--linuxthreads_db/td_symbol_list.c55
-rw-r--r--linuxthreads_db/td_ta_event_addr.c16
-rw-r--r--linuxthreads_db/td_ta_get_nthreads.c6
-rw-r--r--linuxthreads_db/td_ta_new.c42
-rw-r--r--linuxthreads_db/thread_db.h5
-rw-r--r--linuxthreads_db/thread_dbP.h22
9 files changed, 117 insertions, 47 deletions
diff --git a/linuxthreads_db/ChangeLog b/linuxthreads_db/ChangeLog
index ebc6392028..3f19f7e2af 100644
--- a/linuxthreads_db/ChangeLog
+++ b/linuxthreads_db/ChangeLog
@@ -1,3 +1,16 @@
+2001-03-20  Ulrich Drepper  <drepper@redhat.com>
+
+	* Makefile (libthread_db-routines): Add td_symbol_list.
+	* Versions [libthread_db] (GLIBC_2.2.3): Add td_symbol_list.
+	* td_symbol_list.c: New file.
+	* thread_db.h: Add prototype for td_symbol_list.
+	* thread_dbP.h: Define symbol name indices.
+	Add prototype for td_lookup.
+	* td_ta_event_addr.c: Use td_lookup instead of directly using
+	ps_pglobal_lookup to find symbol address.
+	* td_ta_get_nthreads.c: Likewise.
+	* td_ta_new.c: Likewise.
+
 2001-03-18  Ulrich Drepper  <drepper@redhat.com>
 
 	* Makefile: When generating DSO link with libc_nonshared.a.
diff --git a/linuxthreads_db/Makefile b/linuxthreads_db/Makefile
index 489eb9e53d..1c3a2d4d84 100644
--- a/linuxthreads_db/Makefile
+++ b/linuxthreads_db/Makefile
@@ -39,7 +39,7 @@ libthread_db-routines = td_init td_log td_ta_delete td_ta_get_nthreads      \
 			td_thr_event_enable td_thr_set_event 		    \
 			td_thr_clear_event td_thr_event_getmsg		    \
 			td_ta_set_event td_ta_event_getmsg		    \
-			td_ta_clear_event
+			td_ta_clear_event td_symbol_list
 
 libthread_db-inhibit-o = $(filter-out .os,$(object-suffixes))
 
diff --git a/linuxthreads_db/Versions b/linuxthreads_db/Versions
index 83b30ee6e9..57619a3732 100644
--- a/linuxthreads_db/Versions
+++ b/linuxthreads_db/Versions
@@ -12,4 +12,7 @@ libthread_db {
     td_thr_setprio; td_thr_setsigpending; td_thr_setxregs; td_thr_sigsetmask;
     td_thr_tsd; td_thr_validate;
   }
+  GLIBC_2.2.3 {
+    td_symbol_list;
+  }
 }
diff --git a/linuxthreads_db/td_symbol_list.c b/linuxthreads_db/td_symbol_list.c
new file mode 100644
index 0000000000..06168d771c
--- /dev/null
+++ b/linuxthreads_db/td_symbol_list.c
@@ -0,0 +1,55 @@
+/* Return list of symbols the library can request.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <assert.h>
+#include <gnu/lib-names.h>
+#include "thread_dbP.h"
+
+
+static const char *symbol_list_arr[] =
+{
+  [PTHREAD_THREADS_EVENTS] = "__pthread_threads_events",
+  [PTHREAD_LAST_EVENT] = "__pthread_last_event",
+  [PTHREAD_HANDLES_NUM] = "__pthread_handles_num",
+  [PTHREAD_HANDLES] = "__pthread_handles",
+  [PTHREAD_KEYS] = "pthread_keys",
+  [LINUXTHREADS_PTHREAD_THREADS_MAX] = "__linuxthreads_pthread_threads_max",
+  [LINUXTHREADS_PTHREAD_KEYS_MAX] = "__linuxthreads_pthread_keys_max",
+  [LINUXTHREADS_PTHREAD_SIZEOF_DESCR] = "__linuxthreads_pthread_sizeof_descr",
+  [LINUXTHREADS_CREATE_EVENT] = "__linuxthreads_create_event",
+  [LINUXTHREADS_DEATH_EVENT] = "__linuxthreads_death_event",
+  [LINUXTHREADS_REAP_EVENT] = "__linuxthreads_reap_event",
+  [NUM_MESSAGES] = NULL
+};
+
+
+const char **
+td_symbol_list (void)
+{
+  return symbol_list_arr;
+}
+
+
+int
+td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr)
+{
+  assert (idx >= 0 && idx < NUM_MESSAGES);
+  return ps_pglobal_lookup (ps, LIBPTHREAD_SO, symbol_list_arr[idx], sym_addr);
+}
diff --git a/linuxthreads_db/td_ta_event_addr.c b/linuxthreads_db/td_ta_event_addr.c
index 7f217f1024..2a47b16d39 100644
--- a/linuxthreads_db/td_ta_event_addr.c
+++ b/linuxthreads_db/td_ta_event_addr.c
@@ -1,5 +1,5 @@
 /* Get event address.
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -18,8 +18,6 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <gnu/lib-names.h>
-
 #include "thread_dbP.h"
 
 
@@ -27,7 +25,7 @@ td_err_e
 td_ta_event_addr (const td_thragent_t *ta, td_event_e event, td_notify_t *addr)
 {
   td_err_e res = TD_NOEVENT;
-  const char *symbol = NULL;
+  int idx = -1;
 
   LOG (__FUNCTION__);
 
@@ -38,15 +36,15 @@ td_ta_event_addr (const td_thragent_t *ta, td_event_e event, td_notify_t *addr)
   switch (event)
     {
     case TD_CREATE:
-      symbol = "__linuxthreads_create_event";
+      idx = LINUXTHREADS_CREATE_EVENT;
       break;
 
     case TD_DEATH:
-      symbol = "__linuxthreads_death_event";
+      idx = LINUXTHREADS_DEATH_EVENT;
       break;
 
     case TD_REAP:
-      symbol = "__linuxthreads_reap_event";
+      idx = LINUXTHREADS_REAP_EVENT;
       break;
 
     default:
@@ -55,11 +53,11 @@ td_ta_event_addr (const td_thragent_t *ta, td_event_e event, td_notify_t *addr)
     }
 
   /* Now get the address.  */
-  if (symbol != NULL)
+  if (idx != -1)
     {
       psaddr_t taddr;
 
-      if (ps_pglobal_lookup (ta->ph, LIBPTHREAD_SO, symbol, &taddr) == PS_OK)
+      if (td_lookup (ta->ph, idx, &taddr) == PS_OK)
 	{
 	  /* Success, we got the address.  */
 	  addr->type = NOTIFY_BPT;
diff --git a/linuxthreads_db/td_ta_get_nthreads.c b/linuxthreads_db/td_ta_get_nthreads.c
index 9396250534..c2c5b10eba 100644
--- a/linuxthreads_db/td_ta_get_nthreads.c
+++ b/linuxthreads_db/td_ta_get_nthreads.c
@@ -1,5 +1,5 @@
 /* Get the number of threads in the process.
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -19,7 +19,6 @@
    Boston, MA 02111-1307, USA.  */
 
 #include "thread_dbP.h"
-#include <gnu/lib-names.h>
 
 td_err_e
 td_ta_get_nthreads (const td_thragent_t *ta, int *np)
@@ -33,8 +32,7 @@ td_ta_get_nthreads (const td_thragent_t *ta, int *np)
     return TD_BADTA;
 
   /* Access the variable `__pthread_handles_num'.  */
-  if (ps_pglobal_lookup (ta->ph, LIBPTHREAD_SO, "__pthread_handles_num",
-		         &addr) != PS_OK)
+  if (td_lookup (ta->ph, PTHREAD_HANDLES_NUM, &addr) != PS_OK)
      return TD_ERR;	/* XXX Other error value?  */
 
   if (ps_pdread (ta->ph, addr, np, sizeof (int)) != PS_OK)
diff --git a/linuxthreads_db/td_ta_new.c b/linuxthreads_db/td_ta_new.c
index 8d6ee9a7c5..08c1822ae3 100644
--- a/linuxthreads_db/td_ta_new.c
+++ b/linuxthreads_db/td_ta_new.c
@@ -1,5 +1,5 @@
 /* Attach to target process.
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
 
@@ -20,7 +20,6 @@
 
 #include <stddef.h>
 #include <stdlib.h>
-#include <gnu/lib-names.h>
 
 #include "thread_dbP.h"
 
@@ -41,8 +40,7 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
   /* Get the global event mask.  This is one of the variables which
      are new in the thread library to enable debugging.  If it is
      not available we cannot debug.  */
-  if (ps_pglobal_lookup (ps, LIBPTHREAD_SO,
-			 "__pthread_threads_events", &addr) != PS_OK)
+  if (td_lookup (ps, PTHREAD_THREADS_EVENTS, &addr) != PS_OK)
     return TD_NOLIBTHREAD;
 
   /* Fill in the appropriate information.  */
@@ -59,9 +57,7 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
 
   /* Get the pointer to the variable pointing to the thread descriptor
      with the last event.  */
-  if (ps_pglobal_lookup (ps, LIBPTHREAD_SO,
-			 "__pthread_last_event",
-			 &(*ta)->pthread_last_event) != PS_OK)
+  if (td_lookup (ps, PTHREAD_LAST_EVENT, &(*ta)->pthread_last_event) != PS_OK)
     {
     free_return:
       free (*ta);
@@ -70,21 +66,18 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
 
   /* Get the pointer to the variable containing the number of active
      threads.  */
-  if (ps_pglobal_lookup (ps, LIBPTHREAD_SO,
-			 "__pthread_handles_num",
-			 &(*ta)->pthread_handles_num) != PS_OK)
+  if (td_lookup (ps, PTHREAD_HANDLES_NUM, &(*ta)->pthread_handles_num)
+      != PS_OK)
     goto free_return;
 
   /* See whether the library contains the necessary symbols.  */
-  if (ps_pglobal_lookup (ps, LIBPTHREAD_SO, "__pthread_handles",
-		         &addr) != PS_OK)
+  if (td_lookup (ps, PTHREAD_HANDLES, &addr) != PS_OK)
     goto free_return;
 
   (*ta)->handles = (struct pthread_handle_struct *) addr;
 
 
-  if (ps_pglobal_lookup (ps, LIBPTHREAD_SO, "pthread_keys",
-		         &addr) != PS_OK)
+  if (td_lookup (ps, PTHREAD_KEYS, &addr) != PS_OK)
     goto free_return;
 
   /* Cast to the right type.  */
@@ -93,8 +86,7 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
   /* Find out about the maximum number of threads.  Old implementations
      don't provide this information.  In this case we assume that the
      debug  library is compiled with the same values.  */
-  if (ps_pglobal_lookup (ps, LIBPTHREAD_SO,
-			 "__linuxthreads_pthread_threads_max", &addr) != PS_OK)
+  if (td_lookup (ps, LINUXTHREADS_PTHREAD_THREADS_MAX, &addr) != PS_OK)
     (*ta)->pthread_threads_max = PTHREAD_THREADS_MAX;
   else
     {
@@ -104,8 +96,7 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
     }
 
   /* Similar for the maximum number of thread local data keys.  */
-  if (ps_pglobal_lookup (ps, LIBPTHREAD_SO,
-			 "__linuxthreads_pthread_keys_max", &addr) != PS_OK)
+  if (td_lookup (ps, LINUXTHREADS_PTHREAD_KEYS_MAX, &addr) != PS_OK)
     (*ta)->pthread_keys_max = PTHREAD_KEYS_MAX;
   else
     {
@@ -115,9 +106,7 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
     }
 
   /* And for the size of the second level arrays for the keys.  */
-  if (ps_pglobal_lookup (ps, LIBPTHREAD_SO,
-			 "__linuxthreads_pthread_sizeof_descr", &addr)
-      != PS_OK)
+  if (td_lookup (ps, LINUXTHREADS_PTHREAD_SIZEOF_DESCR, &addr) != PS_OK)
     (*ta)->sizeof_descr = sizeof (struct _pthread_descr_struct);
   else
     {
@@ -125,17 +114,6 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta)
 	goto free_return;
     }
 
-  /* Similar for the maximum number of thread local data keys.  */
-  if (ps_pglobal_lookup (ps, LIBPTHREAD_SO,
-			 "__linuxthreads_pthread_keys_max", &addr) != PS_OK)
-    (*ta)->pthread_keys_max = PTHREAD_KEYS_MAX;
-  else
-    {
-      if (ps_pdread (ps, addr, &(*ta)->pthread_keys_max, sizeof (int))
-	  != PS_OK)
-	goto free_return;
-    }
-
   /* Now add the new agent descriptor to the list.  */
   elemp = (struct agent_list *) malloc (sizeof (struct agent_list));
   if (elemp == NULL)
diff --git a/linuxthreads_db/thread_db.h b/linuxthreads_db/thread_db.h
index 6301d7fa5f..3c67146191 100644
--- a/linuxthreads_db/thread_db.h
+++ b/linuxthreads_db/thread_db.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2001 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
@@ -289,6 +289,9 @@ extern td_err_e td_init (void);
 /* Historical relict.  Should not be used anymore.  */
 extern td_err_e td_log (void);
 
+/* Return list of symbols the library can request.  */
+extern const char **td_symbol_list (void);
+
 /* Generate new thread debug library handle for process PS.  */
 extern td_err_e td_ta_new (struct ps_prochandle *__ps, td_thragent_t **__ta);
 
diff --git a/linuxthreads_db/thread_dbP.h b/linuxthreads_db/thread_dbP.h
index 13e534afe6..8e87bae52d 100644
--- a/linuxthreads_db/thread_dbP.h
+++ b/linuxthreads_db/thread_dbP.h
@@ -8,6 +8,24 @@
 #include "../linuxthreads/internals.h"
 
 
+/* Indeces for the symbol names.  */
+enum
+  {
+    PTHREAD_THREADS_EVENTS = 0,
+    PTHREAD_LAST_EVENT,
+    PTHREAD_HANDLES_NUM,
+    PTHREAD_HANDLES,
+    PTHREAD_KEYS,
+    LINUXTHREADS_PTHREAD_THREADS_MAX,
+    LINUXTHREADS_PTHREAD_KEYS_MAX,
+    LINUXTHREADS_PTHREAD_SIZEOF_DESCR,
+    LINUXTHREADS_CREATE_EVENT,
+    LINUXTHREADS_DEATH_EVENT,
+    LINUXTHREADS_REAP_EVENT,
+    NUM_MESSAGES
+  };
+
+
 /* Comment out the following for less verbose output.  */
 #ifndef NDEBUG
 # define LOG(c) if (__td_debug) __libc_write (2, c "\n", strlen (c "\n"))
@@ -80,4 +98,8 @@ ta_ok (const td_thragent_t *ta)
   return runp != NULL;
 }
 
+
+/* Internal wrapper around ps_pglobal_lookup.  */
+extern int td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr);
+
 #endif /* thread_dbP.h */