From 187dd78d7bd1c03fcf16e54a30314512d38e1a4a Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 27 Feb 2003 18:13:05 +0000 Subject: Major update for pthreads, based in large part on improvements from glibc 2.3. This should make threads much more efficient. -Erik --- libpthread/linuxthreads_db/Banner | 1 + libpthread/linuxthreads_db/ChangeLog | 190 +++++++++++++++++++++- libpthread/linuxthreads_db/Makefile | 27 +-- libpthread/linuxthreads_db/Versions | 6 + libpthread/linuxthreads_db/proc_service.h | 16 +- libpthread/linuxthreads_db/td_init.c | 4 +- libpthread/linuxthreads_db/td_log.c | 6 +- libpthread/linuxthreads_db/td_symbol_list.c | 40 +++-- libpthread/linuxthreads_db/td_ta_clear_event.c | 4 +- libpthread/linuxthreads_db/td_ta_delete.c | 4 +- libpthread/linuxthreads_db/td_ta_enable_stats.c | 4 +- libpthread/linuxthreads_db/td_ta_event_addr.c | 2 +- libpthread/linuxthreads_db/td_ta_event_getmsg.c | 5 +- libpthread/linuxthreads_db/td_ta_get_nthreads.c | 2 +- libpthread/linuxthreads_db/td_ta_get_ph.c | 4 +- libpthread/linuxthreads_db/td_ta_get_stats.c | 4 +- libpthread/linuxthreads_db/td_ta_map_id2thr.c | 19 ++- libpthread/linuxthreads_db/td_ta_map_lwp2thr.c | 16 +- libpthread/linuxthreads_db/td_ta_new.c | 18 +- libpthread/linuxthreads_db/td_ta_reset_stats.c | 4 +- libpthread/linuxthreads_db/td_ta_set_event.c | 4 +- libpthread/linuxthreads_db/td_ta_setconcurrency.c | 4 +- libpthread/linuxthreads_db/td_ta_thr_iter.c | 36 +++- libpthread/linuxthreads_db/td_ta_tsd_iter.c | 5 +- libpthread/linuxthreads_db/td_thr_clear_event.c | 9 +- libpthread/linuxthreads_db/td_thr_dbresume.c | 4 +- libpthread/linuxthreads_db/td_thr_dbsuspend.c | 4 +- libpthread/linuxthreads_db/td_thr_event_enable.c | 22 ++- libpthread/linuxthreads_db/td_thr_event_getmsg.c | 9 +- libpthread/linuxthreads_db/td_thr_get_info.c | 21 ++- libpthread/linuxthreads_db/td_thr_getfpregs.c | 8 +- libpthread/linuxthreads_db/td_thr_getgregs.c | 9 +- libpthread/linuxthreads_db/td_thr_getxregs.c | 4 +- libpthread/linuxthreads_db/td_thr_getxregsize.c | 4 +- libpthread/linuxthreads_db/td_thr_set_event.c | 9 +- libpthread/linuxthreads_db/td_thr_setfpregs.c | 9 +- libpthread/linuxthreads_db/td_thr_setgregs.c | 9 +- libpthread/linuxthreads_db/td_thr_setprio.c | 4 +- libpthread/linuxthreads_db/td_thr_setsigpending.c | 4 +- libpthread/linuxthreads_db/td_thr_setxregs.c | 4 +- libpthread/linuxthreads_db/td_thr_sigsetmask.c | 4 +- libpthread/linuxthreads_db/td_thr_tls_get_addr.c | 70 ++++++++ libpthread/linuxthreads_db/td_thr_tsd.c | 12 +- libpthread/linuxthreads_db/td_thr_validate.c | 21 ++- libpthread/linuxthreads_db/thread_db.h | 37 +++-- libpthread/linuxthreads_db/thread_dbP.h | 5 + 46 files changed, 571 insertions(+), 136 deletions(-) create mode 100644 libpthread/linuxthreads_db/Banner create mode 100644 libpthread/linuxthreads_db/td_thr_tls_get_addr.c (limited to 'libpthread/linuxthreads_db') diff --git a/libpthread/linuxthreads_db/Banner b/libpthread/linuxthreads_db/Banner new file mode 100644 index 000000000..6f4f3f818 --- /dev/null +++ b/libpthread/linuxthreads_db/Banner @@ -0,0 +1 @@ +libthread_db work sponsored by Alpha Processor Inc diff --git a/libpthread/linuxthreads_db/ChangeLog b/libpthread/linuxthreads_db/ChangeLog index 4d29ae0bb..a366d657c 100644 --- a/libpthread/linuxthreads_db/ChangeLog +++ b/libpthread/linuxthreads_db/ChangeLog @@ -1,10 +1,198 @@ +2002-09-29 Ulrich Drepper + + * td_thr_tsd.c (td_thr_tsd): Read correct entry from pthread_keys + array. + +2002-09-28 Andreas Jaeger + + * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Fix reference to dtv. + +2002-09-24 Roland McGrath + + * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Fetch just the + individual members we need, not the whole structures. + +2002-09-24 Ulrich Drepper + + * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Change second + parameter to be the address of the link map in the inferior process. + * thread_db.h: Update prototype for td_thr_tls_get_addr. + +2002-08-23 Ulrich Drepper + + * thread_dbP.h: Define LINUXTHREADS_VERSION. + * td_symbol_list.c (symbol_list_arr): Add LINUXTHREADS_VERSION string. + * td_ta_new.c (td_ta_new): After verifying the thread library is + there check version. + * thread_db.h: Add new error TD_VERSION. + +2002-08-21 Roland McGrath + + * td_thr_tls_get_addr.c (td_thr_tls_get_addr): __attribute_used__ -> + __attribute__ ((unused)) for arguments. + +2002-08-07 Ulrich Drepper + + * thread_dbP.h: Define LINUXTHREADS_INITIAL_REPORT_EVENTS. + * td_thr_event_enable.c (td_thr_event_enable): If th->th_unique is + null write to __linuxthreads_initial_report_events. + * td_symbol_list.c (symbol_list_arr): Add + __linuxthreads_initial_report_events. + +2002-07-16 Ulrich Drepper + + * td_thr_clear_event.c: Yet more changes to help with TLS-enabled + libpthread. + * td_thr_event_enable.c: Likewise. + * td_thr_event_getmsg.c: Likewise. + * td_thr_set_event.c: Likewise. + * td_thr_setfpregs.c: Likewise. + * td_thr_setgregs.c: Likewise. + * td_thr_tsd.c: Likewise. + * td_thr_validate.c: Likewise. + +2002-07-15 Ulrich Drepper + + * td_ta_thr_iter.c: Some more changes to enable using TLS-enabled + libpthread. + * td_thr_event_enable.c: Likewise. + * td_thr_getfpregs.c: Likewise. + * td_thr_getgregs.c: Likewise. + +2002-07-14 Ulrich Drepper + + * td_ta_map_id2thr.c: Begin fixing implementation for libpthread with + TLS support. + * td_ta_map_lwp2thr.c: Likewise. + * td_ta_thr_iter.c: Likewise. + * td_thr_get_info.c: Likewise. + +2002-07-10 Ulrich Drepper + + * Versions [libthread_db] (GLIBC_2.3): Add td_thr_tls_get_addr. + +2002-06-14 H.J. Lu + + * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Don't include + "tls.h". Return TD_ERR if USE_TLS is not defined. + +2002-06-12 Ulrich Drepper + + * td_thr_tls_get_addr.c: New file. + * thread_db.h: Add prototype for td_thr_tls_get_addr. + * Makefile (libthread_db-routines): Add td_thr_tls_get_addr. + +2002-03-03 Andreas Jaeger + + * thread_dbP.h: Include for prototypes of __libc_write. + +2002-02-04 Ulrich Drepper + + * thread_dbP.h: Include descr.h instead of internals.h. + * td_ta_event_getmsg.c: Also include . + * td_ta_map_id2thr.c: Likewise. + * td_ta_map_lwp2thr.c: Likewise. + * td_ta_thr_iter.c: Likewise. + * td_ta_tsd_iter.c: Likewise. + * td_thr_tsd.c: Likewise. + * td_thr_validate.c: Likewise. + +2001-12-28 Andreas Jaeger + + * td_init.c (td_init): Don't use __FUNCTION__ as literal. + * td_log.c (td_log): Likewise. + * td_ta_delete.c (td_ta_delete): Likewise. + * td_ta_get_nthreads.c (td_ta_get_nthreads): Likewise. + * td_ta_get_ph.c (td_ta_get_ph): Likewise. + * td_ta_map_id2thr.c (td_ta_map_id2thr): Likewise. + * td_ta_map_lwp2thr.c (td_ta_map_lwp2thr): Likewise. + * td_ta_new.c (td_ta_new): Likewise. + * td_ta_clear_event.c (td_ta_clear_event): Likewise. + * td_ta_enable_stats.c (td_ta_enable_stats): Likewise. + * td_ta_event_addr.c (td_ta_event_addr): Likewise. + * td_ta_event_getmsg.c (td_ta_event_getmsg): Likewise. + * td_ta_get_stats.c (td_ta_get_stats): Likewise. + * td_ta_reset_stats.c (td_ta_reset_stats): Likewise. + * td_ta_set_event.c (td_ta_set_event): Likewise. + * td_ta_setconcurrency.c (td_ta_setconcurrency): Likewise. + * td_ta_thr_iter.c (td_ta_thr_iter): Likewise. + * td_ta_tsd_iter.c (td_ta_tsd_iter): Likewise. + * td_thr_clear_event.c (td_thr_clear_event): Likewise. + * td_thr_dbresume.c (td_thr_dbresume): Likewise. + * td_thr_dbsuspend.c (td_thr_dbsuspend): Likewise. + * td_thr_event_enable.c (td_thr_event_enable): Likewise. + * td_thr_event_getmsg.c (td_thr_event_getmsg): Likewise. + * td_thr_get_info.c (td_thr_get_info): Likewise. + * td_thr_getfpregs.c (td_thr_getfpregs): Likewise. + * td_thr_getgregs.c (td_thr_getgregs): Likewise. + * td_thr_getxregs.c (td_thr_getxregs): Likewise. + * td_thr_getxregsize.c (td_thr_getxregsize): Likewise. + * td_thr_set_event.c (td_thr_set_event): Likewise. + * td_thr_setfpregs.c (td_thr_setfpregs): Likewise. + * td_thr_setgregs.c (td_thr_setgregs): Likewise. + * td_thr_setprio.c (td_thr_setprio): Likewise. + * td_thr_setsigpending.c (td_thr_setsigpending): Likewise. + * td_thr_setxregs.c (td_thr_setxregs): Likewise. + * td_thr_sigsetmask.c (td_thr_sigsetmask): Likewise. + * td_thr_tsd.c (td_thr_tsd): Likewise. + * td_thr_validate.c (td_thr_validate): Likewise. + +2001-04-12 Ulrich Drepper + + * td_ta_map_id2thr.c: If thread terminated return TD_NOTHR. + * td_thr_validate.c: Likewise. + +2001-04-04 Ulrich Drepper + + * td_thr_getfpregs.c: If p_pid is zero use ps_getpid(). + * td_thr_getgregs.c: Likewise. + * td_thr_setfpregs.c: Likewise. + * td_thr_setgregs.c: Likewise. + +2001-03-20 Ulrich Drepper + + * 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 + + * Makefile: When generating DSO link with libc_nonshared.a. + +2000-08-01 Andreas Jaeger + + * Makefile (distribute): Add missing files. + +2000-04-24 Mark Kettenis + + * td_thr_get_info.c (td_thr_get_info): Set ti_state to + TD_THR_ACTIVE instead of TD_THR_RUN. If the thread is no longer + running but is still joinable, set it to TD_THR_ZOMBIE. Otherwise + set it to TD_THR_UNKNOWN. + +2000-02-25 Andreas Jaeger + + * td_ta_thr_iter.c: Include for prototype declaration. + * td_ta_tsd_iter.c: Likewise. + +2000-01-20 Andreas Jaeger + + * td_thr_getgregs.c (td_thr_getgregs): Fix typo. + 2000-01-19 Ulrich Drepper * td_thr_getgregs.c: Correct size parameter of memset call. 1999-12-02 Ulrich Drepper - * proc_service.h: Fix typoes in last added declaractions. + * proc_service.h: Fix typos in last added declaractions. 1999-12-01 Ulrich Drepper diff --git a/libpthread/linuxthreads_db/Makefile b/libpthread/linuxthreads_db/Makefile index ec3637bb4..d5d3ec5c9 100644 --- a/libpthread/linuxthreads_db/Makefile +++ b/libpthread/linuxthreads_db/Makefile @@ -39,18 +39,21 @@ SYSDEPINC = -I$(PTDIR)sysdeps/unix/sysv/linux \ -I$(TOPDIR)libc/sysdeps/linux/$(TARGET_ARCH) CFLAGS += $(SYSDEPINC) -DLIBPTHREAD_SO="\"libpthread.so.$(MAJOR_VERSION)\"" -CSRC=td_init.c td_log.c td_ta_clear_event.c td_ta_delete.c \ - td_ta_enable_stats.c td_ta_event_addr.c td_ta_event_getmsg.c \ - td_ta_get_nthreads.c td_ta_get_ph.c td_ta_get_stats.c \ - td_ta_map_id2thr.c td_ta_map_lwp2thr.c td_ta_new.c td_ta_reset_stats.c \ - td_ta_set_event.c td_ta_setconcurrency.c td_ta_thr_iter.c \ - td_ta_tsd_iter.c td_thr_clear_event.c td_thr_dbresume.c \ - td_thr_dbsuspend.c td_thr_event_enable.c td_thr_event_getmsg.c \ - td_thr_get_info.c td_thr_getfpregs.c td_thr_getgregs.c \ - td_thr_getxregs.c td_thr_getxregsize.c td_thr_set_event.c \ - td_thr_setfpregs.c td_thr_setgregs.c td_thr_setprio.c \ - td_thr_setsigpending.c td_thr_setxregs.c td_thr_sigsetmask.c \ - td_thr_tsd.c td_thr_validate.c td_symbol_list.c +CSRC= td_init.c td_log.c td_ta_delete.c td_ta_get_nthreads.c \ + td_ta_get_ph.c td_ta_map_id2thr.c td_ta_map_lwp2thr.c \ + td_ta_new.c td_ta_thr_iter.c td_ta_tsd_iter.c \ + td_thr_get_info.c td_thr_getfpregs.c td_thr_getgregs.c \ + td_thr_getxregs.c td_thr_getxregsize.c td_thr_setfpregs.c \ + td_thr_setgregs.c td_thr_setprio.c td_thr_setsigpending.c \ + td_thr_setxregs.c td_thr_sigsetmask.c td_thr_tsd.c \ + td_thr_validate.c td_thr_dbsuspend.c td_thr_dbresume.c \ + td_ta_setconcurrency.c td_ta_enable_stats.c \ + td_ta_reset_stats.c td_ta_get_stats.c td_ta_event_addr.c \ + td_thr_event_enable.c td_thr_set_event.c \ + td_thr_clear_event.c td_thr_event_getmsg.c \ + td_ta_set_event.c td_ta_event_getmsg.c \ + td_ta_clear_event.c td_symbol_list.c td_thr_tls_get_addr.c + COBJS=$(patsubst %.c,%.o, $(CSRC)) OBJS=$(COBJS) diff --git a/libpthread/linuxthreads_db/Versions b/libpthread/linuxthreads_db/Versions index 83b30ee6e..4ca8042c1 100644 --- a/libpthread/linuxthreads_db/Versions +++ b/libpthread/linuxthreads_db/Versions @@ -12,4 +12,10 @@ 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; + } + GLIBC_2.3 { + td_thr_tls_get_addr; + } } diff --git a/libpthread/linuxthreads_db/proc_service.h b/libpthread/linuxthreads_db/proc_service.h index 8f9a7d98f..74136c03e 100644 --- a/libpthread/linuxthreads_db/proc_service.h +++ b/libpthread/linuxthreads_db/proc_service.h @@ -2,19 +2,19 @@ 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 Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + 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 - Library General Public License for more details. + Lesser 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. */ + 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. */ /* The definitions in this file must correspond to those in the debugger. */ #include diff --git a/libpthread/linuxthreads_db/td_init.c b/libpthread/linuxthreads_db/td_init.c index 6c4dfc623..d714f1ba0 100644 --- a/libpthread/linuxthreads_db/td_init.c +++ b/libpthread/linuxthreads_db/td_init.c @@ -1,5 +1,5 @@ /* Initialization function of thread debugger support library. - 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 , 1999. @@ -27,6 +27,6 @@ td_err_e td_init (void) { /* XXX We have to figure out what has to be done. */ - LOG (__FUNCTION__); + LOG ("td_init"); return TD_OK; } diff --git a/libpthread/linuxthreads_db/td_log.c b/libpthread/linuxthreads_db/td_log.c index 2007eaacc..025273a63 100644 --- a/libpthread/linuxthreads_db/td_log.c +++ b/libpthread/linuxthreads_db/td_log.c @@ -1,5 +1,5 @@ /* Noop, left for historical reasons. - 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 , 1999. @@ -25,8 +25,8 @@ td_err_e td_log (void) { /* This interface is deprecated in the Sun interface. We provide it - for compatibility but don't do anyhting ourself. We might in + for compatibility but don't do anything ourself. We might in future do some logging if this seems reasonable. */ - LOG (__FUNCTION__); + LOG ("td_log"); return TD_OK; } diff --git a/libpthread/linuxthreads_db/td_symbol_list.c b/libpthread/linuxthreads_db/td_symbol_list.c index 61072dbf1..779332b9d 100644 --- a/libpthread/linuxthreads_db/td_symbol_list.c +++ b/libpthread/linuxthreads_db/td_symbol_list.c @@ -1,5 +1,5 @@ /* Return list of symbols the library can request. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2001. @@ -24,29 +24,33 @@ 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 + [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", + [LINUXTHREADS_INITIAL_REPORT_EVENTS] = "__linuxthreads_initial_report_events", + [LINUXTHREADS_VERSION] = "__linuxthreads_version", + [NUM_MESSAGES] = NULL }; -const char ** td_symbol_list (void) +const char ** +td_symbol_list (void) { - return symbol_list_arr; + return symbol_list_arr; } -int td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr) +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); + assert (idx >= 0 && idx < NUM_MESSAGES); + return ps_pglobal_lookup (ps, LIBPTHREAD_SO, symbol_list_arr[idx], sym_addr); } diff --git a/libpthread/linuxthreads_db/td_ta_clear_event.c b/libpthread/linuxthreads_db/td_ta_clear_event.c index fc7fde135..bdbcf47aa 100644 --- a/libpthread/linuxthreads_db/td_ta_clear_event.c +++ b/libpthread/linuxthreads_db/td_ta_clear_event.c @@ -1,5 +1,5 @@ /* Globally disable events. - 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 , 1999. @@ -29,7 +29,7 @@ td_ta_clear_event (ta, event) td_thr_events_t old_event; int i; - LOG (__FUNCTION__); + LOG ("td_ta_clear_event"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_delete.c b/libpthread/linuxthreads_db/td_ta_delete.c index 5d235630d..0e6ec17d0 100644 --- a/libpthread/linuxthreads_db/td_ta_delete.c +++ b/libpthread/linuxthreads_db/td_ta_delete.c @@ -1,5 +1,5 @@ /* Detach 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 , 1999. @@ -26,7 +26,7 @@ td_err_e td_ta_delete (td_thragent_t *ta) { - LOG (__FUNCTION__); + LOG ("td_ta_delete"); /* Safety check. */ if (ta == NULL || __td_agent_list == NULL) diff --git a/libpthread/linuxthreads_db/td_ta_enable_stats.c b/libpthread/linuxthreads_db/td_ta_enable_stats.c index 5a6fef7ee..1d4c34a8d 100644 --- a/libpthread/linuxthreads_db/td_ta_enable_stats.c +++ b/libpthread/linuxthreads_db/td_ta_enable_stats.c @@ -1,5 +1,5 @@ /* Enable collection of statistics for 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 , 1999. @@ -25,7 +25,7 @@ td_err_e td_ta_enable_stats (const td_thragent_t *ta, int enable) { /* XXX We have to figure out what has to be done. */ - LOG (__FUNCTION__); + LOG ("td_ta_enable_stats"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_event_addr.c b/libpthread/linuxthreads_db/td_ta_event_addr.c index 4f0f7bbf1..8bce35ae8 100644 --- a/libpthread/linuxthreads_db/td_ta_event_addr.c +++ b/libpthread/linuxthreads_db/td_ta_event_addr.c @@ -27,7 +27,7 @@ td_ta_event_addr (const td_thragent_t *ta, td_event_e event, td_notify_t *addr) td_err_e res = TD_NOEVENT; int idx = -1; - LOG (__FUNCTION__); + LOG ("td_ta_event_addr"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_event_getmsg.c b/libpthread/linuxthreads_db/td_ta_event_getmsg.c index a63a3d0a7..ec68ae0e2 100644 --- a/libpthread/linuxthreads_db/td_ta_event_getmsg.c +++ b/libpthread/linuxthreads_db/td_ta_event_getmsg.c @@ -1,5 +1,5 @@ /* Retrieve event. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -22,6 +22,7 @@ #include #include "thread_dbP.h" +#include "../linuxthreads/internals.h" td_err_e @@ -32,7 +33,7 @@ td_ta_event_getmsg (const td_thragent_t *ta, td_event_msg_t *msg) td_eventbuf_t event; psaddr_t addr; - LOG (__FUNCTION__); + LOG ("td_ta_event_getmsg"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_get_nthreads.c b/libpthread/linuxthreads_db/td_ta_get_nthreads.c index f275a25e7..839b56be5 100644 --- a/libpthread/linuxthreads_db/td_ta_get_nthreads.c +++ b/libpthread/linuxthreads_db/td_ta_get_nthreads.c @@ -25,7 +25,7 @@ td_ta_get_nthreads (const td_thragent_t *ta, int *np) { psaddr_t addr; - LOG (__FUNCTION__); + LOG ("td_ta_get_nthreads"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_get_ph.c b/libpthread/linuxthreads_db/td_ta_get_ph.c index e08d52137..23d328508 100644 --- a/libpthread/linuxthreads_db/td_ta_get_ph.c +++ b/libpthread/linuxthreads_db/td_ta_get_ph.c @@ -1,5 +1,5 @@ /* Get external process handle. - 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 , 1999. @@ -24,7 +24,7 @@ td_err_e td_ta_get_ph (const td_thragent_t *ta, struct ps_prochandle **ph) { - LOG (__FUNCTION__); + LOG ("td_ta_get_ph"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_get_stats.c b/libpthread/linuxthreads_db/td_ta_get_stats.c index 9aa049c3e..6bf2f5352 100644 --- a/libpthread/linuxthreads_db/td_ta_get_stats.c +++ b/libpthread/linuxthreads_db/td_ta_get_stats.c @@ -1,5 +1,5 @@ /* Retrieve statistics for 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 , 1999. @@ -25,7 +25,7 @@ td_err_e td_ta_get_stats (const td_thragent_t *ta, td_ta_stats_t *statsp) { /* XXX We have to figure out what has to be done. */ - LOG (__FUNCTION__); + LOG ("td_ta_get_stats"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_map_id2thr.c b/libpthread/linuxthreads_db/td_ta_map_id2thr.c index 5171a5bf1..ddb6492e2 100644 --- a/libpthread/linuxthreads_db/td_ta_map_id2thr.c +++ b/libpthread/linuxthreads_db/td_ta_map_id2thr.c @@ -1,5 +1,5 @@ /* Map thread ID to thread handle. - Copyright (C) 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -19,6 +19,7 @@ 02111-1307 USA. */ #include "thread_dbP.h" +#include "../linuxthreads/internals.h" td_err_e @@ -28,7 +29,7 @@ td_ta_map_id2thr (const td_thragent_t *ta, pthread_t pt, td_thrhandle_t *th) struct _pthread_descr_struct pds; int pthread_threads_max; - LOG (__FUNCTION__); + LOG ("td_ta_map_id2thr"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) @@ -44,7 +45,19 @@ td_ta_map_id2thr (const td_thragent_t *ta, pthread_t pt, td_thrhandle_t *th) /* Test whether this entry is in use. */ if (phc.h_descr == NULL) - return TD_BADTH; + { + if (pt % pthread_threads_max == 0) + { + /* The initial thread always exists but the thread library + might not yet be initialized. */ + th->th_ta_p = (td_thragent_t *) ta; + th->th_unique = NULL; + + return TD_OK; + } + + return TD_BADTH; + } /* Next test: get the descriptor to see whether this is not an old thread handle. */ diff --git a/libpthread/linuxthreads_db/td_ta_map_lwp2thr.c b/libpthread/linuxthreads_db/td_ta_map_lwp2thr.c index 8ae5aec78..1337a5c68 100644 --- a/libpthread/linuxthreads_db/td_ta_map_lwp2thr.c +++ b/libpthread/linuxthreads_db/td_ta_map_lwp2thr.c @@ -1,5 +1,5 @@ /* Which thread is running on an lwp? - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -19,6 +19,7 @@ 02111-1307 USA. */ #include "thread_dbP.h" +#include "../linuxthreads/internals.h" td_err_e @@ -34,7 +35,7 @@ td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th) # define num 1 #endif - LOG (__FUNCTION__); + LOG ("td_ta_map_lwp2thr"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) @@ -75,7 +76,16 @@ td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th) return TD_OK; } - } + } + else if (cnt == 0) + { + /* The initial thread always exists. But it might not yet be + initialized. Construct a value. */ + th->th_ta_p = (td_thragent_t *) ta; + th->th_unique = NULL; + + return TD_OK; + } return TD_NOLWP; } diff --git a/libpthread/linuxthreads_db/td_ta_new.c b/libpthread/linuxthreads_db/td_ta_new.c index 7bf687905..f19798b71 100644 --- a/libpthread/linuxthreads_db/td_ta_new.c +++ b/libpthread/linuxthreads_db/td_ta_new.c @@ -1,5 +1,5 @@ /* Attach to target process. - Copyright (C) 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -20,6 +20,7 @@ #include #include +#include #include "thread_dbP.h" @@ -33,9 +34,11 @@ td_err_e td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta) { psaddr_t addr; + psaddr_t versaddr; + char versbuf[sizeof (VERSION)]; struct agent_list *elemp; - LOG (__FUNCTION__); + LOG ("td_ta_new"); /* Get the global event mask. This is one of the variables which are new in the thread library to enable debugging. If it is @@ -43,6 +46,17 @@ td_ta_new (struct ps_prochandle *ps, td_thragent_t **ta) if (td_lookup (ps, PTHREAD_THREADS_EVENTS, &addr) != PS_OK) return TD_NOLIBTHREAD; + /* Check whether the versions match. */ + if (td_lookup (ps, LINUXTHREADS_VERSION, &versaddr) != PS_OK) + return TD_VERSION; + if (ps_pdread (ps, versaddr, versbuf, sizeof (versbuf)) != PS_OK) + return TD_ERR; + + versbuf[sizeof (versbuf) - 1] = '\0'; + if (strcmp (versbuf, VERSION) != 0) + /* Not the right version. */ + return TD_VERSION; + /* Fill in the appropriate information. */ *ta = (td_thragent_t *) malloc (sizeof (td_thragent_t)); if (*ta == NULL) diff --git a/libpthread/linuxthreads_db/td_ta_reset_stats.c b/libpthread/linuxthreads_db/td_ta_reset_stats.c index 9cc386cf8..b3ddbd07b 100644 --- a/libpthread/linuxthreads_db/td_ta_reset_stats.c +++ b/libpthread/linuxthreads_db/td_ta_reset_stats.c @@ -1,5 +1,5 @@ /* Reset statistics. - 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 , 1999. @@ -25,7 +25,7 @@ td_err_e td_ta_reset_stats (const td_thragent_t *ta) { /* XXX We have to figure out what has to be done. */ - LOG (__FUNCTION__); + LOG ("td_ta_reset_stats"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_set_event.c b/libpthread/linuxthreads_db/td_ta_set_event.c index 0ea8fc119..73cf9f405 100644 --- a/libpthread/linuxthreads_db/td_ta_set_event.c +++ b/libpthread/linuxthreads_db/td_ta_set_event.c @@ -1,5 +1,5 @@ /* Globally enable events. - 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 , 1999. @@ -29,7 +29,7 @@ td_ta_set_event (ta, event) td_thr_events_t old_event; int i; - LOG (__FUNCTION__); + LOG ("td_ta_set_event"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_setconcurrency.c b/libpthread/linuxthreads_db/td_ta_setconcurrency.c index 25c1c90c7..408e76309 100644 --- a/libpthread/linuxthreads_db/td_ta_setconcurrency.c +++ b/libpthread/linuxthreads_db/td_ta_setconcurrency.c @@ -1,5 +1,5 @@ /* Set suggested concurrency level for 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 , 1999. @@ -25,7 +25,7 @@ td_err_e td_ta_setconcurrency (const td_thragent_t *ta, int level) { /* This is something LinuxThreads does not support. */ - LOG (__FUNCTION__); + LOG ("td_ta_setconcurrency"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_thr_iter.c b/libpthread/linuxthreads_db/td_ta_thr_iter.c index 4c6f3f4cb..2dad149d5 100644 --- a/libpthread/linuxthreads_db/td_ta_thr_iter.c +++ b/libpthread/linuxthreads_db/td_ta_thr_iter.c @@ -1,5 +1,5 @@ /* Iterate over a process's threads. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -19,6 +19,7 @@ 02111-1307 USA. */ #include "thread_dbP.h" +#include "../linuxthreads/internals.h" #include static int @@ -30,6 +31,37 @@ handle_descr (const td_thragent_t *ta, td_thr_iter_f *callback, size_t sizeof_descr = ta->sizeof_descr; td_thrhandle_t th; + if (descr == NULL) + { + /* No descriptor (yet). */ + if (cnt == 0) + { + /* This is the main thread. Create a fake descriptor. */ + memset (&pds, '\0', sizeof (pds)); + + /* Empty thread descriptor the thread library would create. */ + pds.p_self = &pds; + pds.p_nextlive = pds.p_prevlive = &pds; + pds.p_tid = PTHREAD_THREADS_MAX; + /* The init code also sets up p_lock, p_errnop, p_herrnop, and + p_userstack but this should not be necessary here. */ + + th.th_ta_p = (td_thragent_t *) ta; + th.th_unique = NULL; + if (callback (&th, cbdata_p) != 0) + return TD_DBERR; + + /* All done successfully. */ + return TD_OK; + } + else if (cnt == 1) + /* The manager is not yet started. No big deal. */ + return TD_OK; + else + /* For every other thread this should not happen. */ + return TD_ERR; + } + if (ps_pdread (ta->ph, descr, &pds, sizeof_descr) != PS_OK) return TD_ERR; /* XXX Other error value? */ @@ -86,7 +118,7 @@ td_ta_thr_iter (const td_thragent_t *ta, td_thr_iter_f *callback, # define num 1 #endif - LOG (__FUNCTION__); + LOG ("td_ta_thr_iter"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_ta_tsd_iter.c b/libpthread/linuxthreads_db/td_ta_tsd_iter.c index f29938564..9e24250c6 100644 --- a/libpthread/linuxthreads_db/td_ta_tsd_iter.c +++ b/libpthread/linuxthreads_db/td_ta_tsd_iter.c @@ -1,5 +1,5 @@ /* Iterate over a process's thread-specific data. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -19,6 +19,7 @@ 02111-1307 USA. */ #include "thread_dbP.h" +#include "../linuxthreads/internals.h" #include td_err_e @@ -29,7 +30,7 @@ td_ta_tsd_iter (const td_thragent_t *ta, td_key_iter_f *callback, int pthread_keys_max; int cnt; - LOG (__FUNCTION__); + LOG ("td_ta_tsd_iter"); /* Test whether the TA parameter is ok. */ if (! ta_ok (ta)) diff --git a/libpthread/linuxthreads_db/td_thr_clear_event.c b/libpthread/linuxthreads_db/td_thr_clear_event.c index b75c0f0aa..c027fc09f 100644 --- a/libpthread/linuxthreads_db/td_thr_clear_event.c +++ b/libpthread/linuxthreads_db/td_thr_clear_event.c @@ -1,5 +1,5 @@ /* Disable specific event for thread. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -31,7 +31,12 @@ td_thr_clear_event (th, event) td_thr_events_t old_event; int i; - LOG (__FUNCTION__); + LOG ("td_thr_clear_event"); + + /* If the thread descriptor has not yet been constructed do not do + anything. */ + if (th->th_unique == NULL) + return TD_OK; /* Write the new value into the thread data structure. */ if (ps_pdread (th->th_ta_p->ph, diff --git a/libpthread/linuxthreads_db/td_thr_dbresume.c b/libpthread/linuxthreads_db/td_thr_dbresume.c index 68d62afd4..7b7f6eef9 100644 --- a/libpthread/linuxthreads_db/td_thr_dbresume.c +++ b/libpthread/linuxthreads_db/td_thr_dbresume.c @@ -1,5 +1,5 @@ /* Resume execution of given thread. - 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 , 1999. @@ -25,6 +25,6 @@ td_err_e td_thr_dbresume (const td_thrhandle_t *th) { /* XXX We have to figure out what has to be done. */ - LOG (__FUNCTION__); + LOG ("td_thr_dbresume"); return TD_NOCAPAB; } diff --git a/libpthread/linuxthreads_db/td_thr_dbsuspend.c b/libpthread/linuxthreads_db/td_thr_dbsuspend.c index 0655a1756..ef668023d 100644 --- a/libpthread/linuxthreads_db/td_thr_dbsuspend.c +++ b/libpthread/linuxthreads_db/td_thr_dbsuspend.c @@ -1,5 +1,5 @@ /* Suspend execution of given thread. - 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 , 1999. @@ -25,6 +25,6 @@ td_err_e td_thr_dbsuspend (const td_thrhandle_t *th) { /* XXX We have to figure out what has to be done. */ - LOG (__FUNCTION__); + LOG ("td_thr_dbsuspend"); return TD_NOCAPAB; } diff --git a/libpthread/linuxthreads_db/td_thr_event_enable.c b/libpthread/linuxthreads_db/td_thr_event_enable.c index 007f2a464..407f3fc44 100644 --- a/libpthread/linuxthreads_db/td_thr_event_enable.c +++ b/libpthread/linuxthreads_db/td_thr_event_enable.c @@ -1,5 +1,5 @@ /* Enable event process-wide. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -28,12 +28,28 @@ td_thr_event_enable (th, onoff) const td_thrhandle_t *th; int onoff; { - LOG (__FUNCTION__); + LOG ("td_thr_event_enable"); /* Write the new value into the thread data structure. */ + if (th->th_unique == NULL) + { + psaddr_t addr; + + if (td_lookup (th->th_ta_p->ph, LINUXTHREADS_INITIAL_REPORT_EVENTS, + &addr) != PS_OK) + /* Cannot read the symbol. This should not happen. */ + return TD_ERR; + + if (ps_pdwrite (th->th_ta_p->ph, addr, &onoff, sizeof (int)) != PS_OK) + return TD_ERR; + + return TD_OK; + } + if (ps_pdwrite (th->th_ta_p->ph, ((char *) th->th_unique - + offsetof (struct _pthread_descr_struct, p_report_events)), + + offsetof (struct _pthread_descr_struct, + p_report_events)), &onoff, sizeof (int)) != PS_OK) return TD_ERR; /* XXX Other error value? */ diff --git a/libpthread/linuxthreads_db/td_thr_event_getmsg.c b/libpthread/linuxthreads_db/td_thr_event_getmsg.c index 95b05ff07..bf4ddd4ad 100644 --- a/libpthread/linuxthreads_db/td_thr_event_getmsg.c +++ b/libpthread/linuxthreads_db/td_thr_event_getmsg.c @@ -1,5 +1,5 @@ /* Retrieve event. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -29,7 +29,12 @@ td_thr_event_getmsg (const td_thrhandle_t *th, td_event_msg_t *msg) { td_eventbuf_t event; - LOG (__FUNCTION__); + LOG ("td_thr_event_getmsg"); + + /* If the thread descriptor has not yet been created there cannot be + any event. */ + if (th->th_unique == NULL) + return TD_NOMSG; /* Read the even structure from the target. */ if (ps_pdread (th->th_ta_p->ph, diff --git a/libpthread/linuxthreads_db/td_thr_get_info.c b/libpthread/linuxthreads_db/td_thr_get_info.c index ed6b20f59..4666bda97 100644 --- a/libpthread/linuxthreads_db/td_thr_get_info.c +++ b/libpthread/linuxthreads_db/td_thr_get_info.c @@ -1,5 +1,5 @@ /* Get thread information. - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -29,12 +29,19 @@ td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop) { struct _pthread_descr_struct pds; - LOG (__FUNCTION__); + LOG ("td_thr_get_info"); - /* Get the thread descriptor. */ - if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds, - th->th_ta_p->sizeof_descr) != PS_OK) - return TD_ERR; /* XXX Other error value? */ + /* Handle the case when the thread library is not yet initialized. */ + if (th->th_unique == NULL) + { + memset (&pds, '\0', sizeof (pds)); + pds.p_tid = PTHREAD_THREADS_MAX; + } + else + /* Get the thread descriptor. */ + if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds, + th->th_ta_p->sizeof_descr) != PS_OK) + return TD_ERR; /* XXX Other error value? */ /* Fill in information. Clear first to provide reproducable results for the fields we do not fill in. */ @@ -54,7 +61,7 @@ td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop) infop->ti_tls = (char *) pds.p_specific; infop->ti_pri = pds.p_priority; infop->ti_type = TD_THR_USER; - + if (! pds.p_terminated) /* XXX For now there is no way to get more information. */ infop->ti_state = TD_THR_ACTIVE; diff --git a/libpthread/linuxthreads_db/td_thr_getfpregs.c b/libpthread/linuxthreads_db/td_thr_getfpregs.c index 67d5cd1e2..ea02760c9 100644 --- a/libpthread/linuxthreads_db/td_thr_getfpregs.c +++ b/libpthread/linuxthreads_db/td_thr_getfpregs.c @@ -26,7 +26,13 @@ td_thr_getfpregs (const td_thrhandle_t *th, prfpregset_t *regset) { struct _pthread_descr_struct pds; - LOG (__FUNCTION__); + LOG ("td_thr_getfpregs"); + + if (th->th_unique == NULL) + { + memset (regset, '\0', sizeof (*regset)); + return TD_OK; + } /* We have to get the state and the PID for this thread. */ if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds, diff --git a/libpthread/linuxthreads_db/td_thr_getgregs.c b/libpthread/linuxthreads_db/td_thr_getgregs.c index 5a42b6770..6f00677d6 100644 --- a/libpthread/linuxthreads_db/td_thr_getgregs.c +++ b/libpthread/linuxthreads_db/td_thr_getgregs.c @@ -26,7 +26,14 @@ td_thr_getgregs (const td_thrhandle_t *th, prgregset_t gregs) { struct _pthread_descr_struct pds; - LOG (__FUNCTION__); + LOG ("td_thr_getgregs"); + + if (th->th_unique == NULL) + { + /* No data yet. */ + memset (gregs, '\0', sizeof (prgregset_t)); + return TD_OK; + } /* We have to get the state and the PID for this thread. */ if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds, diff --git a/libpthread/linuxthreads_db/td_thr_getxregs.c b/libpthread/linuxthreads_db/td_thr_getxregs.c index 615d88296..39cd73cf1 100644 --- a/libpthread/linuxthreads_db/td_thr_getxregs.c +++ b/libpthread/linuxthreads_db/td_thr_getxregs.c @@ -1,5 +1,5 @@ /* Get a thread's extra state register set. - 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 , 1999. @@ -25,6 +25,6 @@ td_err_e td_thr_getxregs (const td_thrhandle_t *th, void *xregs) { /* XXX This might be platform specific. */ - LOG (__FUNCTION__); + LOG ("td_thr_getxregs"); return TD_NOXREGS; } diff --git a/libpthread/linuxthreads_db/td_thr_getxregsize.c b/libpthread/linuxthreads_db/td_thr_getxregsize.c index ed55bbab7..5d8ac288e 100644 --- a/libpthread/linuxthreads_db/td_thr_getxregsize.c +++ b/libpthread/linuxthreads_db/td_thr_getxregsize.c @@ -1,5 +1,5 @@ /* Get the size of the extra state register set for this architecture. - 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 , 1999. @@ -25,6 +25,6 @@ td_err_e td_thr_getxregsize (const td_thrhandle_t *th, int *sizep) { /* XXX This might be platform specific. */ - LOG (__FUNCTION__); + LOG ("td_thr_getxregsize"); return TD_NOXREGS; } diff --git a/libpthread/linuxthreads_db/td_thr_set_event.c b/libpthread/linuxthreads_db/td_thr_set_event.c index f537cce05..205b445c7 100644 --- a/libpthread/linuxthreads_db/td_thr_set_event.c +++ b/libpthread/linuxthreads_db/td_thr_set_event.c @@ -1,5 +1,5 @@ /* Enable specific event for thread. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -31,7 +31,12 @@ td_thr_set_event (th, event) td_thr_events_t old_event; int i; - LOG (__FUNCTION__); + LOG ("td_thr_set_event"); + + /* What shall we do if no thread descriptor exists but the user + wants to set an event? */ + if (th->th_unique == NULL) + return TD_NOTALLOC; /* Write the new value into the thread data structure. */ if (ps_pdread (th->th_ta_p->ph, diff --git a/libpthread/linuxthreads_db/td_thr_setfpregs.c b/libpthread/linuxthreads_db/td_thr_setfpregs.c index d5e1ce35a..e4d9ec65e 100644 --- a/libpthread/linuxthreads_db/td_thr_setfpregs.c +++ b/libpthread/linuxthreads_db/td_thr_setfpregs.c @@ -1,5 +1,5 @@ /* Set a thread's floating-point register set. - Copyright (C) 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -24,12 +24,13 @@ td_err_e td_thr_setfpregs (const td_thrhandle_t *th, const prfpregset_t *fpregs) { - struct _pthread_descr_struct pds; + struct _pthread_descr_struct pds = { .p_terminated = 0, .p_pid = 0 }; - LOG (__FUNCTION__); + LOG ("td_thr_setfpregs"); /* We have to get the state and the PID for this thread. */ - if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds, + if (th->th_unique != NULL + && ps_pdread (th->th_ta_p->ph, th->th_unique, &pds, sizeof (struct _pthread_descr_struct)) != PS_OK) return TD_ERR; diff --git a/libpthread/linuxthreads_db/td_thr_setgregs.c b/libpthread/linuxthreads_db/td_thr_setgregs.c index 8c7baa8e9..8c021a473 100644 --- a/libpthread/linuxthreads_db/td_thr_setgregs.c +++ b/libpthread/linuxthreads_db/td_thr_setgregs.c @@ -1,5 +1,5 @@ /* Set a thread's general register set. - Copyright (C) 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -24,12 +24,13 @@ td_err_e td_thr_setgregs (const td_thrhandle_t *th, prgregset_t gregs) { - struct _pthread_descr_struct pds; + struct _pthread_descr_struct pds = { .p_terminated = 0, .p_pid = 0 }; - LOG (__FUNCTION__); + LOG ("td_thr_setgregs"); /* We have to get the state and the PID for this thread. */ - if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds, + if (th->th_unique != NULL + && ps_pdread (th->th_ta_p->ph, th->th_unique, &pds, sizeof (struct _pthread_descr_struct)) != PS_OK) return TD_ERR; diff --git a/libpthread/linuxthreads_db/td_thr_setprio.c b/libpthread/linuxthreads_db/td_thr_setprio.c index c1e3ca5b1..98d202dfe 100644 --- a/libpthread/linuxthreads_db/td_thr_setprio.c +++ b/libpthread/linuxthreads_db/td_thr_setprio.c @@ -1,5 +1,5 @@ /* Set a thread's priority. - 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 , 1999. @@ -25,6 +25,6 @@ td_err_e td_thr_setprio (const td_thrhandle_t *th, int prio) { /* XXX We have to figure out what has to be done. */ - LOG (__FUNCTION__); + LOG ("td_thr_setprio"); return TD_OK; } diff --git a/libpthread/linuxthreads_db/td_thr_setsigpending.c b/libpthread/linuxthreads_db/td_thr_setsigpending.c index bec429ea1..98e30140e 100644 --- a/libpthread/linuxthreads_db/td_thr_setsigpending.c +++ b/libpthread/linuxthreads_db/td_thr_setsigpending.c @@ -1,5 +1,5 @@ /* Raise a signal for a thread. - 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 , 1999. @@ -26,6 +26,6 @@ td_thr_setsigpending (const td_thrhandle_t *th, unsigned char n, const sigset_t *ss) { /* XXX We have to figure out what has to be done. */ - LOG (__FUNCTION__); + LOG ("td_thr_setsigpending"); return TD_OK; } diff --git a/libpthread/linuxthreads_db/td_thr_setxregs.c b/libpthread/linuxthreads_db/td_thr_setxregs.c index c1915e5e9..da77ab3b4 100644 --- a/libpthread/linuxthreads_db/td_thr_setxregs.c +++ b/libpthread/linuxthreads_db/td_thr_setxregs.c @@ -1,5 +1,5 @@ /* Set a thread's extra state register set. - 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 , 1999. @@ -25,6 +25,6 @@ td_err_e td_thr_setxregs (const td_thrhandle_t *ta, const void *addr) { /* XXX This might have to be platform specific. */ - LOG (__FUNCTION__); + LOG ("td_thr_setxregs"); return TD_NOXREGS; } diff --git a/libpthread/linuxthreads_db/td_thr_sigsetmask.c b/libpthread/linuxthreads_db/td_thr_sigsetmask.c index ef3ebcbb8..8b0eb8185 100644 --- a/libpthread/linuxthreads_db/td_thr_sigsetmask.c +++ b/libpthread/linuxthreads_db/td_thr_sigsetmask.c @@ -1,5 +1,5 @@ /* Set a thread's signal mask. - 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 , 1999. @@ -25,6 +25,6 @@ td_err_e td_thr_sigsetmask (const td_thrhandle_t *th, const sigset_t *ss) { /* XXX We have to figure out what has to be done. */ - LOG (__FUNCTION__); + LOG ("td_thr_sigsetmask"); return TD_OK; } diff --git a/libpthread/linuxthreads_db/td_thr_tls_get_addr.c b/libpthread/linuxthreads_db/td_thr_tls_get_addr.c new file mode 100644 index 000000000..e140b77dc --- /dev/null +++ b/libpthread/linuxthreads_db/td_thr_tls_get_addr.c @@ -0,0 +1,70 @@ +/* Get address of thread local variable. + Copyright (C) 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 2002. + + 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 "link.h" +#include "thread_dbP.h" + +/* Value used for dtv entries for which the allocation is delayed. */ +# define TLS_DTV_UNALLOCATED ((void *) -1l) + + +td_err_e +td_thr_tls_get_addr (const td_thrhandle_t *th __attribute__ ((unused)), + void *map_address __attribute__ ((unused)), + size_t offset __attribute__ ((unused)), + void **address __attribute__ ((unused))) +{ +#if USE_TLS + size_t modid; + union dtv pdtv, *dtvp; + + LOG ("td_thr_tls_get_addr"); + + /* Get the DTV pointer from the thread descriptor. */ + if (ps_pdread (th->th_ta_p->ph, + &((struct _pthread_descr_struct *) th->th_unique)->p_header.data.dtvp, + &dtvp, sizeof dtvp) != PS_OK) + return TD_ERR; /* XXX Other error value? */ + + /* Read the module ID from the link_map. */ + if (ps_pdread (th->th_ta_p->ph, + &((struct link_map *) map_address)->l_tls_modid, + &modid, sizeof modid) != PS_OK) + return TD_ERR; /* XXX Other error value? */ + + /* Get the corresponding entry in the DTV. */ + if (ps_pdread (th->th_ta_p->ph, dtvp + modid, + &pdtv, sizeof (union dtv)) != PS_OK) + return TD_ERR; /* XXX Other error value? */ + + /* It could be that the memory for this module is not allocated for + the given thread. */ + if (pdtv.pointer == TLS_DTV_UNALLOCATED) + /* There is not much we can do. */ + return TD_NOTALLOC; + + *address = (char *) pdtv.pointer + offset; + + return TD_OK; +#else + return TD_ERR; +#endif +} diff --git a/libpthread/linuxthreads_db/td_thr_tsd.c b/libpthread/linuxthreads_db/td_thr_tsd.c index 302033681..f2cdefcfa 100644 --- a/libpthread/linuxthreads_db/td_thr_tsd.c +++ b/libpthread/linuxthreads_db/td_thr_tsd.c @@ -1,5 +1,5 @@ /* Get a thread-specific data pointer for a thread. - Copyright (C) 1999 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -19,6 +19,7 @@ 02111-1307 USA. */ #include "thread_dbP.h" +#include "../linuxthreads/internals.h" td_err_e @@ -33,7 +34,12 @@ td_thr_tsd (const td_thrhandle_t *th, const thread_key_t tk, void **data) unsigned int idx2nd; void *p; - LOG (__FUNCTION__); + LOG ("td_thr_tsd"); + + /* If there is no thread descriptor there cannot be any thread + specific data. */ + if (th->th_unique == NULL) + return TD_BADKEY; /* Get the thread descriptor. */ if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds, @@ -45,7 +51,7 @@ td_thr_tsd (const td_thrhandle_t *th, const thread_key_t tk, void **data) return TD_BADKEY; /* Get the key entry. */ - if (ps_pdread (th->th_ta_p->ph, keys, &key, + if (ps_pdread (th->th_ta_p->ph, &keys[tk], &key, sizeof (struct pthread_key_struct)) != PS_OK) return TD_ERR; /* XXX Other error value? */ diff --git a/libpthread/linuxthreads_db/td_thr_validate.c b/libpthread/linuxthreads_db/td_thr_validate.c index 354471071..e18b5728b 100644 --- a/libpthread/linuxthreads_db/td_thr_validate.c +++ b/libpthread/linuxthreads_db/td_thr_validate.c @@ -1,5 +1,5 @@ /* Validate a thread handle. - Copyright (C) 1999, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -19,6 +19,7 @@ 02111-1307 USA. */ #include "thread_dbP.h" +#include "../linuxthreads/internals.h" td_err_e @@ -27,14 +28,26 @@ td_thr_validate (const td_thrhandle_t *th) struct pthread_handle_struct *handles = th->th_ta_p->handles; int pthread_threads_max = th->th_ta_p->pthread_threads_max; int cnt; + struct pthread_handle_struct phc; - LOG (__FUNCTION__); + LOG ("td_thr_validate"); + + /* A special case: if the program just starts up the handle is + NULL. */ + if (th->th_unique == NULL) + { + /* Read the first handle. If the pointer to the thread + descriptor is not NULL this is an error. */ + if (ps_pdread (th->th_ta_p->ph, handles, &phc, + sizeof (struct pthread_handle_struct)) != PS_OK) + return TD_ERR; /* XXX Other error value? */ + + return phc.h_descr == NULL ? TD_OK : TD_NOTHR; + } /* Now get all descriptors, one after the other. */ for (cnt = 0; cnt < pthread_threads_max; ++cnt, ++handles) { - struct pthread_handle_struct phc; - if (ps_pdread (th->th_ta_p->ph, handles, &phc, sizeof (struct pthread_handle_struct)) != PS_OK) return TD_ERR; /* XXX Other error value? */ diff --git a/libpthread/linuxthreads_db/thread_db.h b/libpthread/linuxthreads_db/thread_db.h index 6301d7fa5..f0d9aa7c3 100644 --- a/libpthread/linuxthreads_db/thread_db.h +++ b/libpthread/linuxthreads_db/thread_db.h @@ -1,20 +1,20 @@ -/* Copyright (C) 1999 Free Software Foundation, Inc. +/* Copyright (C) 1999, 2001, 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 Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. + 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 - Library General Public License for more details. + Lesser 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. */ + 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. */ #ifndef _THREAD_DB_H #define _THREAD_DB_H 1 @@ -51,7 +51,9 @@ typedef enum TD_NOTSD, /* No thread-specific data available. */ TD_MALLOC, /* Out of memory. */ TD_PARTIALREG, /* Not entire register set was read or written. */ - TD_NOXREGS /* X register set not available for given thread. */ + TD_NOXREGS, /* X register set not available for given thread. */ + TD_NOTALLOC, /* TLS memory not yet allocated. */ + TD_VERSION /* Version if libpthread and libthread_db do not match. */ } td_err_e; @@ -92,6 +94,10 @@ typedef struct td_thrhandle } td_thrhandle_t; +/* Forward declaration of a type defined by and for the dynamic linker. */ +struct link_map; + + /* Flags for `td_ta_thr_iter'. */ #define TD_THR_ANY_USER_FLAGS 0xffffffff #define TD_THR_LOWEST_PRIORITY -20 @@ -289,6 +295,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); @@ -341,7 +350,7 @@ extern td_err_e td_ta_clear_event (const td_thragent_t *__ta, /* Return information about last event. */ extern td_err_e td_ta_event_getmsg (const td_thragent_t *__ta, - td_event_msg_t *msg); + td_event_msg_t *__msg); /* Set suggested concurrency level for process associated with TA. */ @@ -393,6 +402,12 @@ extern td_err_e td_thr_setxregs (const td_thrhandle_t *__th, const void *__addr); +/* Get address of thread local variable. */ +extern td_err_e td_thr_tls_get_addr (const td_thrhandle_t *__th, + void *__map_address, size_t __offset, + void **__address); + + /* Enable reporting for EVENT for thread TH. */ extern td_err_e td_thr_event_enable (const td_thrhandle_t *__th, int __event); diff --git a/libpthread/linuxthreads_db/thread_dbP.h b/libpthread/linuxthreads_db/thread_dbP.h index 8e87bae52..c45336ac9 100644 --- a/libpthread/linuxthreads_db/thread_dbP.h +++ b/libpthread/linuxthreads_db/thread_dbP.h @@ -2,7 +2,10 @@ #ifndef _THREAD_DBP_H #define _THREAD_DBP_H 1 +#define __FORCE_GLIBC +#include #include +#include #include "proc_service.h" #include "thread_db.h" #include "../linuxthreads/internals.h" @@ -22,6 +25,8 @@ enum LINUXTHREADS_CREATE_EVENT, LINUXTHREADS_DEATH_EVENT, LINUXTHREADS_REAP_EVENT, + LINUXTHREADS_INITIAL_REPORT_EVENTS, + LINUXTHREADS_VERSION, NUM_MESSAGES }; -- cgit v1.2.3