summaryrefslogtreecommitdiff
path: root/linuxthreads_db
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
committerUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
commita334319f6530564d22e775935d9c91663623a1b4 (patch)
treeb5877475619e4c938e98757d518bb1e9cbead751 /linuxthreads_db
parent0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff)
downloadglibc-a334319f6530564d22e775935d9c91663623a1b4.tar.gz
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'linuxthreads_db')
-rw-r--r--linuxthreads_db/Banner1
-rw-r--r--linuxthreads_db/ChangeLog447
-rw-r--r--linuxthreads_db/Makefile57
-rw-r--r--linuxthreads_db/Versions24
-rw-r--r--linuxthreads_db/proc_service.h70
-rw-r--r--linuxthreads_db/shlib-versions2
-rw-r--r--linuxthreads_db/td_init.c32
-rw-r--r--linuxthreads_db/td_log.c32
-rw-r--r--linuxthreads_db/td_symbol_list.c62
-rw-r--r--linuxthreads_db/td_ta_clear_event.c53
-rw-r--r--linuxthreads_db/td_ta_delete.c58
-rw-r--r--linuxthreads_db/td_ta_enable_stats.c35
-rw-r--r--linuxthreads_db/td_ta_event_addr.c73
-rw-r--r--linuxthreads_db/td_ta_event_getmsg.c129
-rw-r--r--linuxthreads_db/td_ta_get_nthreads.c42
-rw-r--r--linuxthreads_db/td_ta_get_ph.c36
-rw-r--r--linuxthreads_db/td_ta_get_stats.c35
-rw-r--r--linuxthreads_db/td_ta_map_id2thr.c79
-rw-r--r--linuxthreads_db/td_ta_map_lwp2thr.c91
-rw-r--r--linuxthreads_db/td_ta_new.c150
-rw-r--r--linuxthreads_db/td_ta_reset_stats.c35
-rw-r--r--linuxthreads_db/td_ta_set_event.c53
-rw-r--r--linuxthreads_db/td_ta_setconcurrency.c35
-rw-r--r--linuxthreads_db/td_ta_thr_iter.c176
-rw-r--r--linuxthreads_db/td_ta_tsd_iter.c56
-rw-r--r--linuxthreads_db/td_thr_clear_event.c62
-rw-r--r--linuxthreads_db/td_thr_dbresume.c30
-rw-r--r--linuxthreads_db/td_thr_dbsuspend.c30
-rw-r--r--linuxthreads_db/td_thr_event_enable.c57
-rw-r--r--linuxthreads_db/td_thr_event_getmsg.c65
-rw-r--r--linuxthreads_db/td_thr_get_info.c83
-rw-r--r--linuxthreads_db/td_thr_getfpregs.c58
-rw-r--r--linuxthreads_db/td_thr_getgregs.c58
-rw-r--r--linuxthreads_db/td_thr_getxregs.c30
-rw-r--r--linuxthreads_db/td_thr_getxregsize.c30
-rw-r--r--linuxthreads_db/td_thr_set_event.c62
-rw-r--r--linuxthreads_db/td_thr_setfpregs.c47
-rw-r--r--linuxthreads_db/td_thr_setgregs.c47
-rw-r--r--linuxthreads_db/td_thr_setprio.c30
-rw-r--r--linuxthreads_db/td_thr_setsigpending.c31
-rw-r--r--linuxthreads_db/td_thr_setxregs.c30
-rw-r--r--linuxthreads_db/td_thr_sigsetmask.c30
-rw-r--r--linuxthreads_db/td_thr_tls_get_addr.c45
-rw-r--r--linuxthreads_db/td_thr_tlsbase.c71
-rw-r--r--linuxthreads_db/td_thr_tsd.c82
-rw-r--r--linuxthreads_db/td_thr_validate.c70
-rw-r--r--linuxthreads_db/thread_db.h459
-rw-r--r--linuxthreads_db/thread_dbP.h108
48 files changed, 3478 insertions, 0 deletions
diff --git a/linuxthreads_db/Banner b/linuxthreads_db/Banner
new file mode 100644
index 0000000000..6f4f3f8189
--- /dev/null
+++ b/linuxthreads_db/Banner
@@ -0,0 +1 @@
+libthread_db work sponsored by Alpha Processor Inc
diff --git a/linuxthreads_db/ChangeLog b/linuxthreads_db/ChangeLog
new file mode 100644
index 0000000000..338bf8207f
--- /dev/null
+++ b/linuxthreads_db/ChangeLog
@@ -0,0 +1,447 @@
+2004-05-01 Jakub Jelinek <jakub@redhat.com>
+
+ * thread_dbP.h (LOG): Use write instead of __libc_write.
+
+2004-03-13 Jakub Jelinek <jakub@redhat.com>
+
+ * td_thr_tlsbase.c: Remove dl-tls.h include. Don't use
+ TLS_TP_OFFSET in the #if, but TLS_TCB_SIZE == 0 ?:.
+
+2004-03-12 Roland McGrath <roland@redhat.com>
+
+ * td_thr_tlsbase.c [TLS_DTV_AT_TP && TLS_TP_OFFSET > 0]: Handle this
+ case (PowerPC) differently.
+
+2003-11-25 Roland McGrath <roland@redhat.com>
+
+ * td_symbol_list.c (symbol_list_arr) [HAVE_ASM_GLOBAL_DOT_NAME]:
+ Prepend "." to symbol names for functions.
+
+2003-08-18 Daniel Jacobowitz <drow@mvista.com>
+
+ * td_thr_getfpregs.c (td_thr_getfpregs): Use the main thread if
+ the descriptor is uninitialized.
+ * td_thr_getgregs.c (td_thr_getgregs): Likewise.
+
+2003-03-15 Roland McGrath <roland@redhat.com>
+
+ * thread_db.h (td_err_e): Add TD_NOTLS and TD_TLSDEFER.
+ (td_thr_tlsbase): Declare it.
+ * td_thr_tlsbase.c: New file.
+ * Makefile (libthread_db-routines): Add it.
+ * Versions (libthread_db: GLIBC_2.3.3): New set, add td_thr_tlsbase.
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Use td_thr_tlsbase.
+
+2003-02-27 Roland McGrath <roland@redhat.com>
+
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Handle TLS_DTV_AT_TP.
+
+ * td_ta_thr_iter.c (handle_descr) [!defined USE_TLS || !TLS_DTV_AT_TP]:
+ Conditionalize p_header use on this.
+
+2003-01-29 Roland McGrath <roland@redhat.com>
+
+ * td_ta_new.c (td_ta_new): Cap the `sizeof_descr' value read from the
+ inferior at `sizeof (struct _pthread_descr_struct)', since we use it
+ as a length in copies to our own structures.
+
+2003-01-05 Ulrich Drepper <drepper@redhat.com>
+
+ * Makefile (libthread_db.so-no-z-defs): Define.
+
+2002-09-29 Ulrich Drepper <drepper@redhat.com>
+
+ * td_thr_tsd.c (td_thr_tsd): Read correct entry from pthread_keys
+ array.
+
+2002-09-28 Andreas Jaeger <aj@suse.de>
+
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): Fix reference to dtv.
+
+2002-09-24 Roland McGrath <roland@redhat.com>
+
+ * 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 <drepper@redhat.com>
+
+ * 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 <drepper@redhat.com>
+
+ * 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 <roland@redhat.com>
+
+ * td_thr_tls_get_addr.c (td_thr_tls_get_addr): __attribute_used__ ->
+ __attribute__ ((unused)) for arguments.
+
+2002-08-07 Ulrich Drepper <drepper@redhat.com>
+
+ * 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 <drepper@redhat.com>
+
+ * 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 <drepper@redhat.com>
+
+ * 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 <drepper@redhat.com>
+
+ * 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 <drepper@redhat.com>
+
+ * Versions [libthread_db] (GLIBC_2.3): Add td_thr_tls_get_addr.
+
+2002-06-14 H.J. Lu <hjl@gnu.org>
+
+ * 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 <drepper@redhat.com>
+
+ * 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 <aj@suse.de>
+
+ * thread_dbP.h: Include <unistd.h> for prototypes of __libc_write.
+
+2002-02-04 Ulrich Drepper <drepper@redhat.com>
+
+ * thread_dbP.h: Include descr.h instead of internals.h.
+ * td_ta_event_getmsg.c: Also include <linuxthreads/internals.h>.
+ * 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 <aj@suse.de>
+
+ * 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 <drepper@redhat.com>
+
+ * td_ta_map_id2thr.c: If thread terminated return TD_NOTHR.
+ * td_thr_validate.c: Likewise.
+
+2001-04-04 Ulrich Drepper <drepper@redhat.com>
+
+ * 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 <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.
+
+2000-08-01 Andreas Jaeger <aj@suse.de>
+
+ * Makefile (distribute): Add missing files.
+
+2000-04-24 Mark Kettenis <kettenis@gnu.org>
+
+ * 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 <aj@suse.de>
+
+ * td_ta_thr_iter.c: Include <alloca.h> for prototype declaration.
+ * td_ta_tsd_iter.c: Likewise.
+
+2000-01-20 Andreas Jaeger <aj@suse.de>
+
+ * td_thr_getgregs.c (td_thr_getgregs): Fix typo.
+
+2000-01-19 Ulrich Drepper <drepper@cygnus.com>
+
+ * td_thr_getgregs.c: Correct size parameter of memset call.
+
+1999-12-02 Ulrich Drepper <drepper@cygnus.com>
+
+ * proc_service.h: Fix typos in last added declaractions.
+
+1999-12-01 Ulrich Drepper <drepper@cygnus.com>
+
+ * proc_service.h: Add ps_pstop, ps_pcontinue, ps_lstop, and
+ ps_lcontinue prototypes.
+
+1999-11-23 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile: Correct dependency for shared object.
+
+1999-11-22 Ulrich Drepper <drepper@cygnus.com>
+
+ * td_ta_map_lwp2thr.c: Add missing brace in comparison.
+
+ * thread_dbP.h (LOG): Only print message if __td_debug is nonzero.
+ * td_init.c: Add __td_debug.
+
+1999-11-12 Ulrich Drepper <drepper@cygnus.com>
+
+ * td_ta_thr_iter.c: Start copying list of descriptors from right
+ position in target process.
+
+ * td_ta_thr_iter.c: Fix loop starting point over all but main and
+ manager thread.
+
+ * td_ta_thr_iter.c: Read descriptors for main and manager thread
+ special since after this we can assume that no new threads will be
+ created anymore (at least in the gdb implementation).
+
+ * Makefile: Define version correctly.
+
+1999-11-10 Ulrich Drepper <drepper@cygnus.com>
+
+ * td_ta_map_lwp2thr.c: If p_pid field is zero, this is before the
+ thread library is initialized and we get the PID from the
+ debugger.
+
+1999-11-08 Ulrich Drepper <drepper@cygnus.com>
+
+ * td_thr_get_info.c: Make sure ti_lid is never zero.
+
+ * proc_service.h: Add ps_getpid prototype.
+
+1999-11-03 Ulrich Drepper <drepper@cygnus.com>
+
+ * thread_dbP.h (ta_ok): New function.
+ * td_ta_new.c: Add new handle to list.
+ * td_ta_delete.c: Remove handle from list.
+ * td_ta_clear_event.c: Use ta_ok to check for correct ta parameter.
+ * td_ta_enable_stats.c: Likewise.
+ * td_ta_event_addr.c: Likewise.
+ * td_ta_event_getmsg.c: Likewise.
+ * td_ta_get_nthreads.c: Likewise.
+ * td_ta_get_ph.c: Likewise.
+ * td_ta_get_stats.c: Likewise.
+ * td_ta_map_id2thr.c: Likewise.
+ * td_ta_map_lwp2thr.c: Likewise.
+ * td_ta_reset_stats.c: Likewise.
+ * td_ta_set_event.c: Likewise.
+ * td_ta_setconcurrency.c: Likewise.
+ * td_ta_thr_iter.c: Likewise.
+
+ * td_ta_tsd_iter.c: Optimize memory retrieving.
+
+ * Versions: New file.
+
+ * td_thr_get_info.c (td_thr_get_info): Initialize ti_traceme.
+
+1999-11-02 Ulrich Drepper <drepper@cygnus.com>
+
+ * td_ta_thr_iter.c (td_ta_thr_iter): Optimize a bit. Read all
+ handles at once.
+
+ * thread_dbP.h (struct th_thragent): Add pthread_handle_num.
+ * td_ta_new.c: Initialize pthread_handle_num.
+ * td_ta_event_getmsg.c: If last event was already reported search
+ for another unreported event.
+
+ * td_thr_get_info.c (td_thr_get_info): Initialize ti_events.
+
+ * Makefile (libthread_db-routines): Add td_ta_set_event,
+ td_ta_event_getmsg, and td_ta_clear_event.
+ * td_ta_clear_event.c: New file.
+ * td_ta_event_getmsg.c: New file.
+ * td_ta_new.c: Get address of __pthread_last_event in target.
+ * td_ta_set_event.c: Don't overwrite old mask, set additional bits.
+ * td_thr_set_event.c: Likewise.
+ * td_thr_clear_event.c: Implement.
+ * thread_db.h: Declare td_ta_clear_event and td_ta_event_getmsg.
+ * thread_dbP.h (struct td_thragent): Add pthread_last_event.
+
+ * td_ta_new.c: Don't test for __pthread_threads_debug. Get address
+ of __pthread_threads_events and fail if this is not possible.
+ * td_ta_event_addr.c: Implement.
+ * td_thr_event_enable.c: Implement.
+ * td_thr_event_getmsg.c: Implement.
+ * td_thr_set_event.c: Implement.
+ * td_ta_set_event.c: New file.
+ * thread_db.h (td_eventbuf_t): Define.
+ Declare td_ta_set_event.
+ * thread_dbP.h (struct td_thragent): Add pthread_threads_eventsp.
+
+ * td_thr_getfpregs.c: For terminated threads return empty structure.
+ * td_thr_getgregs.c: Likewise.
+ * td_thr_setfpregs.c: Likewise.
+ * td_thr_setgregs.c: Likewise.
+
+1999-11-01 Ulrich Drepper <drepper@cygnus.com>
+
+ * thread_db.h: Shuffle types around to make things work for gdb.
+ * thread_dbP.h: Include proc_service.h before thread_db.h.
+
+ * thread_db.h: It's TD_NOLIBTHREAD, not TD_LIBTHREAD.
+ * td_ta_new.c: Likewise.
+
+1999-10-14 Ulrich Drepper <drepper@cygnus.com>
+
+ * td_ta_new.c: p_startfct does not exist anymore.
+
+ * td_thr_get_info.c: Always initialize start function.
+
+ * td_ta_thr_iter.c: Don't return threads which exited (but are not
+ joined).
+
+ * td_thr_validate.c: Don't skip manager thread.
+
+1999-10-13 Ulrich Drepper <drepper@cygnus.com>
+
+ * td_ta_thr_iter.c: Use size of descriptor from *TA.
+ Don't return manager thread before it's actually running.
+ Actually use state parameter to distingusih at least a few states.
+
+ * td_thr_get_info.c: Handle manager thread special. Fill in ti_lid,
+ ti_state, and ti_startfunc fields.
+
+1999-10-12 Andreas Jaeger <aj@suse.de>
+
+ * thread_dbP.h: Include <string.h> for strlen declaration. Remove
+ __libc_write prototype since this is already declared in
+ linuxthreads/internals.h.
+
+1999-10-11 Ulrich Drepper <drepper@cygnus.com>
+
+ * thread_db.h: Fix comment for ti_type.
+
+ * td_thr_get_info.c: Initialize ti_type field.
+
+ * td_ta_thr_iter.c: Also report the manager thread.
+
+1999-10-08 Andreas Jaeger <aj@suse.de>
+
+ * thread_db.h: Fix typos in comments.
+
+ * td_ta_get_nthreads.c (td_ta_get_nthreads): Don't hardcode
+ libpthread library name, get it from <gnu/lib-names.h> instead.
+ * td_ta_new.c (td_ta_new): Likewise.
+
+1999-10-08 Ulrich Drepper <drepper@cygnus.com>
+
+ * shlib-versions: New file.
+
+1999-10-07 Ulrich Drepper <drepper@cygnus.com>
+
+ * Makefile: New file.
+ * proc_service.h: New file.
+ * td_init.c: New file.
+ * td_log.c: New file.
+ * td_ta_delete.c: New file.
+ * td_ta_enable_stats.c: New file.
+ * td_ta_event_addr.c: New file.
+ * td_ta_get_nthreads.c: New file.
+ * td_ta_get_ph.c: New file.
+ * td_ta_get_stats.c: New file.
+ * td_ta_map_id2thr.c: New file.
+ * td_ta_map_lwp2thr.c: New file.
+ * td_ta_new.c: New file.
+ * td_ta_reset_stats.c: New file.
+ * td_ta_setconcurrency.c: New file.
+ * td_ta_thr_iter.c: New file.
+ * td_ta_tsd_iter.c: New file.
+ * td_thr_clear_event.c: New file.
+ * td_thr_dbresume.c: New file.
+ * td_thr_dbsuspend.c: New file.
+ * td_thr_event_enable.c: New file.
+ * td_thr_event_getmsg.c: New file.
+ * td_thr_get_info.c: New file.
+ * td_thr_getfpregs.c: New file.
+ * td_thr_getgregs.c: New file.
+ * td_thr_getxregs.c: New file.
+ * td_thr_getxregsize.c: New file.
+ * td_thr_set_event.c: New file.
+ * td_thr_setfpregs.c: New file.
+ * td_thr_setgregs.c: New file.
+ * td_thr_setprio.c: New file.
+ * td_thr_setsigpending.c: New file.
+ * td_thr_setxregs.c: New file.
+ * td_thr_sigsetmask.c: New file.
+ * td_thr_tsd.c: New file.
+ * td_thr_validate.c: New file.
+ * thread_db.h: New file.
+ * thread_dbP.h: New file.
diff --git a/linuxthreads_db/Makefile b/linuxthreads_db/Makefile
new file mode 100644
index 0000000000..53e46f7758
--- /dev/null
+++ b/linuxthreads_db/Makefile
@@ -0,0 +1,57 @@
+# Copyright (C) 1999, 2000, 2001, 2002, 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.
+
+# Makefile for linuxthreads debug library subdirectory of GNU C Library.
+
+subdir := linuxthreads_db
+
+linuxthreads_db-version = 1.0
+
+extra-libs = libthread_db
+extra-libs-others := $(extra-libs)
+
+headers = thread_db.h
+libthread_db-routines = td_init td_log td_ta_delete td_ta_get_nthreads \
+ td_ta_get_ph td_ta_map_id2thr td_ta_map_lwp2thr \
+ td_ta_new td_ta_thr_iter td_ta_tsd_iter \
+ td_thr_get_info td_thr_getfpregs td_thr_getgregs \
+ td_thr_getxregs td_thr_getxregsize td_thr_setfpregs \
+ td_thr_setgregs td_thr_setprio td_thr_setsigpending \
+ td_thr_setxregs td_thr_sigsetmask td_thr_tsd \
+ td_thr_validate td_thr_dbsuspend td_thr_dbresume \
+ td_ta_setconcurrency td_ta_enable_stats \
+ td_ta_reset_stats td_ta_get_stats td_ta_event_addr \
+ 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_symbol_list \
+ td_thr_tlsbase td_thr_tls_get_addr
+
+libthread_db-inhibit-o = $(filter-out .os,$(object-suffixes))
+
+# The ps_* callback functions are not defined.
+libthread_db.so-no-z-defs = yes
+
+distribute = thread_dbP.h shlib-versions proc_service.h
+include ../Rules
+
+# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
+# This ensures they will load libc.so for needed symbols if loaded by
+# a statically-linked program that hasn't already loaded it.
+$(objpfx)libthread_db.so: $(common-objpfx)libc.so \
+ $(common-objpfx)libc_nonshared.a
diff --git a/linuxthreads_db/Versions b/linuxthreads_db/Versions
new file mode 100644
index 0000000000..063493c676
--- /dev/null
+++ b/linuxthreads_db/Versions
@@ -0,0 +1,24 @@
+libthread_db {
+ GLIBC_2.1.3 {
+ # t*
+ td_init; td_log; td_ta_clear_event; td_ta_delete; td_ta_enable_stats;
+ td_ta_event_addr; td_ta_event_getmsg; td_ta_get_nthreads; td_ta_get_ph;
+ td_ta_get_stats; td_ta_map_id2thr; td_ta_map_lwp2thr; td_ta_new;
+ td_ta_reset_stats; td_ta_set_event; td_ta_setconcurrency;
+ td_ta_thr_iter; td_ta_tsd_iter; td_thr_clear_event; td_thr_dbresume;
+ td_thr_dbsuspend; td_thr_event_enable; td_thr_event_getmsg;
+ td_thr_get_info; td_thr_getfpregs; td_thr_getgregs; td_thr_getxregs;
+ td_thr_getxregsize; td_thr_set_event; td_thr_setfpregs; td_thr_setgregs;
+ 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;
+ }
+ GLIBC_2.3.3 {
+ td_thr_tlsbase;
+ }
+}
diff --git a/linuxthreads_db/proc_service.h b/linuxthreads_db/proc_service.h
new file mode 100644
index 0000000000..74136c03e1
--- /dev/null
+++ b/linuxthreads_db/proc_service.h
@@ -0,0 +1,70 @@
+/* Copyright (C) 1999 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. */
+
+/* The definitions in this file must correspond to those in the debugger. */
+#include <sys/procfs.h>
+
+typedef enum
+{
+ PS_OK, /* generic "call succeeded" */
+ PS_ERR, /* generic. */
+ PS_BADPID, /* bad process handle */
+ PS_BADLID, /* bad lwp identifier */
+ PS_BADADDR, /* bad address */
+ PS_NOSYM, /* p_lookup() could not find given symbol */
+ PS_NOFREGS
+ /*
+ * FPU register set not available for given
+ * lwp
+ */
+} ps_err_e;
+
+
+struct ps_prochandle; /* user defined. */
+
+
+extern ps_err_e ps_pdread(struct ps_prochandle *,
+ psaddr_t, void *, size_t);
+extern ps_err_e ps_pdwrite(struct ps_prochandle *,
+ psaddr_t, const void *, size_t);
+extern ps_err_e ps_ptread(struct ps_prochandle *,
+ psaddr_t, void *, size_t);
+extern ps_err_e ps_ptwrite(struct ps_prochandle *,
+ psaddr_t, const void *, size_t);
+
+extern ps_err_e ps_pglobal_lookup(struct ps_prochandle *,
+ const char *object_name, const char *sym_name, psaddr_t *sym_addr);
+
+
+extern ps_err_e ps_lgetregs(struct ps_prochandle *,
+ lwpid_t, prgregset_t);
+extern ps_err_e ps_lsetregs(struct ps_prochandle *,
+ lwpid_t, const prgregset_t);
+extern ps_err_e ps_lgetfpregs(struct ps_prochandle *,
+ lwpid_t, prfpregset_t *);
+extern ps_err_e ps_lsetfpregs(struct ps_prochandle *,
+ lwpid_t, const prfpregset_t *);
+
+extern pid_t ps_getpid (struct ps_prochandle *);
+
+
+extern ps_err_e ps_pstop (const struct ps_prochandle *);
+extern ps_err_e ps_pcontinue (const struct ps_prochandle *);
+
+extern ps_err_e ps_lstop (const struct ps_prochandle *, lwpid_t);
+extern ps_err_e ps_lcontinue (const struct ps_prochandle *, lwpid_t);
diff --git a/linuxthreads_db/shlib-versions b/linuxthreads_db/shlib-versions
new file mode 100644
index 0000000000..592f7fa284
--- /dev/null
+++ b/linuxthreads_db/shlib-versions
@@ -0,0 +1,2 @@
+# The thread debug library
+.*-.*-linux.* libthread_db=1
diff --git a/linuxthreads_db/td_init.c b/linuxthreads_db/td_init.c
new file mode 100644
index 0000000000..d714f1ba03
--- /dev/null
+++ b/linuxthreads_db/td_init.c
@@ -0,0 +1,32 @@
+/* Initialization function of thread debugger support library.
+ 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.
+
+ 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"
+
+int __td_debug;
+
+
+td_err_e
+td_init (void)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_init");
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_log.c b/linuxthreads_db/td_log.c
new file mode 100644
index 0000000000..025273a634
--- /dev/null
+++ b/linuxthreads_db/td_log.c
@@ -0,0 +1,32 @@
+/* Noop, left for historical reasons.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_log (void)
+{
+ /* This interface is deprecated in the Sun interface. We provide it
+ for compatibility but don't do anything ourself. We might in
+ future do some logging if this seems reasonable. */
+ LOG ("td_log");
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_symbol_list.c b/linuxthreads_db/td_symbol_list.c
new file mode 100644
index 0000000000..2f7b2bd4d0
--- /dev/null
+++ b/linuxthreads_db/td_symbol_list.c
@@ -0,0 +1,62 @@
+/* Return list of symbols the library can request.
+ Copyright (C) 2001, 2002, 2003 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 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 <assert.h>
+#include <gnu/lib-names.h>
+#include "thread_dbP.h"
+
+#ifdef HAVE_ASM_GLOBAL_DOT_NAME
+# define DOT "." /* PPC64 requires . prefix on code symbols. */
+#else
+# define DOT /* No prefix. */
+#endif
+
+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] = DOT "__linuxthreads_create_event",
+ [LINUXTHREADS_DEATH_EVENT] = DOT "__linuxthreads_death_event",
+ [LINUXTHREADS_REAP_EVENT] = DOT "__linuxthreads_reap_event",
+ [LINUXTHREADS_INITIAL_REPORT_EVENTS] = "__linuxthreads_initial_report_events",
+ [LINUXTHREADS_VERSION] = "__linuxthreads_version",
+ [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_clear_event.c b/linuxthreads_db/td_ta_clear_event.c
new file mode 100644
index 0000000000..bdbcf47aac
--- /dev/null
+++ b/linuxthreads_db/td_ta_clear_event.c
@@ -0,0 +1,53 @@
+/* Globally disable events.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_ta_clear_event (ta, event)
+ const td_thragent_t *ta;
+ td_thr_events_t *event;
+{
+ td_thr_events_t old_event;
+ int i;
+
+ LOG ("td_ta_clear_event");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Write the new value into the thread data structure. */
+ if (ps_pdread (ta->ph, ta->pthread_threads_eventsp,
+ &old_event, sizeof (td_thrhandle_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Remove the set bits in. */
+ for (i = 0; i < TD_EVENTSIZE; ++i)
+ old_event.event_bits[i] &= ~event->event_bits[i];
+
+ /* Write the new value into the thread data structure. */
+ if (ps_pdwrite (ta->ph, ta->pthread_threads_eventsp,
+ &old_event, sizeof (td_thrhandle_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_delete.c b/linuxthreads_db/td_ta_delete.c
new file mode 100644
index 0000000000..0e6ec17d01
--- /dev/null
+++ b/linuxthreads_db/td_ta_delete.c
@@ -0,0 +1,58 @@
+/* Detach to target process.
+ 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.
+
+ 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 <stdlib.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_ta_delete (td_thragent_t *ta)
+{
+ LOG ("td_ta_delete");
+
+ /* Safety check. */
+ if (ta == NULL || __td_agent_list == NULL)
+ return TD_BADTA;
+
+ /* Remove the handle from the list. */
+ if (ta == __td_agent_list->ta)
+ /* It's the first element of the list. */
+ __td_agent_list = __td_agent_list->next;
+ else
+ {
+ /* We have to search for it. */
+ struct agent_list *runp = __td_agent_list;
+
+ while (runp->next != NULL && runp->next->ta != ta)
+ runp = runp->next;
+
+ if (runp->next == NULL)
+ /* It's not a valid decriptor since it is not in the list. */
+ return TD_BADTA;
+
+ runp->next = runp->next->next;
+ }
+
+ /* The handle was allocated in `td_ta_new'. */
+ free (ta);
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_enable_stats.c b/linuxthreads_db/td_ta_enable_stats.c
new file mode 100644
index 0000000000..1d4c34a8d7
--- /dev/null
+++ b/linuxthreads_db/td_ta_enable_stats.c
@@ -0,0 +1,35 @@
+/* Enable collection of statistics for process.
+ 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.
+
+ 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"
+
+
+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 ("td_ta_enable_stats");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_event_addr.c b/linuxthreads_db/td_ta_event_addr.c
new file mode 100644
index 0000000000..8bce35ae86
--- /dev/null
+++ b/linuxthreads_db/td_ta_event_addr.c
@@ -0,0 +1,73 @@
+/* Get event address.
+ 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.
+
+ 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"
+
+
+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;
+ int idx = -1;
+
+ LOG ("td_ta_event_addr");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ switch (event)
+ {
+ case TD_CREATE:
+ idx = LINUXTHREADS_CREATE_EVENT;
+ break;
+
+ case TD_DEATH:
+ idx = LINUXTHREADS_DEATH_EVENT;
+ break;
+
+ case TD_REAP:
+ idx = LINUXTHREADS_REAP_EVENT;
+ break;
+
+ default:
+ /* Event cannot be handled. */
+ break;
+ }
+
+ /* Now get the address. */
+ if (idx != -1)
+ {
+ psaddr_t taddr;
+
+ if (td_lookup (ta->ph, idx, &taddr) == PS_OK)
+ {
+ /* Success, we got the address. */
+ addr->type = NOTIFY_BPT;
+ addr->u.bptaddr = taddr;
+
+ res = TD_OK;
+ }
+ else
+ res = TD_ERR;
+ }
+
+ return res;
+}
diff --git a/linuxthreads_db/td_ta_event_getmsg.c b/linuxthreads_db/td_ta_event_getmsg.c
new file mode 100644
index 0000000000..c3a4492a12
--- /dev/null
+++ b/linuxthreads_db/td_ta_event_getmsg.c
@@ -0,0 +1,129 @@
+/* Retrieve event.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <stddef.h>
+#include <string.h>
+
+#include "thread_dbP.h"
+#include <linuxthreads/internals.h>
+
+
+td_err_e
+td_ta_event_getmsg (const td_thragent_t *ta, td_event_msg_t *msg)
+{
+ /* XXX I cannot think of another way but using a static variable. */
+ static td_thrhandle_t th;
+ td_eventbuf_t event;
+ psaddr_t addr;
+
+ LOG ("td_ta_event_getmsg");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Get the pointer to the thread descriptor with the last event. */
+ if (ps_pdread (ta->ph, ta->pthread_last_event,
+ &addr, sizeof (void *)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* If the pointer is NULL no event occurred. */
+ if (addr == 0)
+ return TD_NOMSG;
+
+ /* Read the even structure from the target. */
+ if (ps_pdread (ta->ph,
+ ((char *) addr
+ + offsetof (struct _pthread_descr_struct, p_eventbuf)),
+ &event, sizeof (td_eventbuf_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Check whether an event occurred. */
+ if (event.eventnum == TD_EVENT_NONE)
+ {
+ /* Oh well, this means the last event was already read. So
+ we have to look for any other event. */
+ struct pthread_handle_struct handles[ta->pthread_threads_max];
+ int num;
+ int i;
+
+ /* Read the number of currently active threads. */
+ if (ps_pdread (ta->ph, ta->pthread_handles_num, &num, sizeof (int))
+ != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Now read the handles. */
+ if (ps_pdread (ta->ph, ta->handles, handles,
+ ta->pthread_threads_max * sizeof (handles[0])) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ for (i = 0; i < ta->pthread_threads_max && num > 0; ++i)
+ {
+ if (handles[i].h_descr == NULL)
+ /* No entry here. */
+ continue;
+
+ /* First count this active thread. */
+ --num;
+
+ if (handles[i].h_descr == addr)
+ /* We already handled this. */
+ continue;
+
+ /* Read the event data for this thread. */
+ if (ps_pdread (ta->ph,
+ ((char *) handles[i].h_descr
+ + offsetof (struct _pthread_descr_struct,
+ p_eventbuf)),
+ &event, sizeof (td_eventbuf_t)) != PS_OK)
+ return TD_ERR;
+
+ if (event.eventnum != TD_EVENT_NONE)
+ {
+ /* We found a thread with an unreported event. */
+ addr = handles[i].h_descr;
+ break;
+ }
+ }
+
+ /* If we haven't found any other event signal this to the user. */
+ if (event.eventnum == TD_EVENT_NONE)
+ return TD_NOMSG;
+ }
+
+ /* Generate the thread descriptor. */
+ th.th_ta_p = (td_thragent_t *) ta;
+ th.th_unique = addr;
+
+ /* Fill the user's data structure. */
+ msg->event = event.eventnum;
+ msg->th_p = &th;
+ msg->msg.data = (uintptr_t) event.eventdata;
+
+ /* And clear the event message in the target. */
+ memset (&event, '\0', sizeof (td_eventbuf_t));
+ if (ps_pdwrite (ta->ph,
+ ((char *) addr
+ + offsetof (struct _pthread_descr_struct, p_eventbuf)),
+ &event, sizeof (td_eventbuf_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_get_nthreads.c b/linuxthreads_db/td_ta_get_nthreads.c
new file mode 100644
index 0000000000..839b56be59
--- /dev/null
+++ b/linuxthreads_db/td_ta_get_nthreads.c
@@ -0,0 +1,42 @@
+/* Get the number of threads in the process.
+ 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.
+
+ 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"
+
+td_err_e
+td_ta_get_nthreads (const td_thragent_t *ta, int *np)
+{
+ psaddr_t addr;
+
+ LOG ("td_ta_get_nthreads");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Access the variable `__pthread_handles_num'. */
+ 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)
+ return TD_ERR; /* XXX Other error value? */
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_get_ph.c b/linuxthreads_db/td_ta_get_ph.c
new file mode 100644
index 0000000000..23d3285084
--- /dev/null
+++ b/linuxthreads_db/td_ta_get_ph.c
@@ -0,0 +1,36 @@
+/* Get external process handle.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_ta_get_ph (const td_thragent_t *ta, struct ps_prochandle **ph)
+{
+ LOG ("td_ta_get_ph");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ *ph = ta->ph;
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_get_stats.c b/linuxthreads_db/td_ta_get_stats.c
new file mode 100644
index 0000000000..6bf2f53527
--- /dev/null
+++ b/linuxthreads_db/td_ta_get_stats.c
@@ -0,0 +1,35 @@
+/* Retrieve statistics for process.
+ 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.
+
+ 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"
+
+
+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 ("td_ta_get_stats");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_map_id2thr.c b/linuxthreads_db/td_ta_map_id2thr.c
new file mode 100644
index 0000000000..ddeb2d3c4a
--- /dev/null
+++ b/linuxthreads_db/td_ta_map_id2thr.c
@@ -0,0 +1,79 @@
+/* Map thread ID to thread handle.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <linuxthreads/internals.h>
+
+
+td_err_e
+td_ta_map_id2thr (const td_thragent_t *ta, pthread_t pt, td_thrhandle_t *th)
+{
+ struct pthread_handle_struct phc;
+ struct _pthread_descr_struct pds;
+ int pthread_threads_max;
+
+ LOG ("td_ta_map_id2thr");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Make the following expression a bit smaller. */
+ pthread_threads_max = ta->pthread_threads_max;
+
+ /* We can compute the entry in the handle array we want. */
+ if (ps_pdread (ta->ph, ta->handles + pt % pthread_threads_max, &phc,
+ sizeof (struct pthread_handle_struct)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Test whether this entry is in use. */
+ if (phc.h_descr == NULL)
+ {
+ 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. */
+ if (ps_pdread (ta->ph, phc.h_descr, &pds,
+ sizeof (struct _pthread_descr_struct)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ if (pds.p_tid != pt)
+ return TD_BADTH;
+
+ if (pds.p_terminated != 0)
+ return TD_NOTHR;
+
+ /* Create the `td_thrhandle_t' object. */
+ th->th_ta_p = (td_thragent_t *) ta;
+ th->th_unique = phc.h_descr;
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_map_lwp2thr.c b/linuxthreads_db/td_ta_map_lwp2thr.c
new file mode 100644
index 0000000000..dd2fcbfe4e
--- /dev/null
+++ b/linuxthreads_db/td_ta_map_lwp2thr.c
@@ -0,0 +1,91 @@
+/* Which thread is running on an lwp?
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <linuxthreads/internals.h>
+
+
+td_err_e
+td_ta_map_lwp2thr (const td_thragent_t *ta, lwpid_t lwpid, td_thrhandle_t *th)
+{
+ int pthread_threads_max = ta->pthread_threads_max;
+ size_t sizeof_descr = ta->sizeof_descr;
+ struct pthread_handle_struct phc[pthread_threads_max];
+ size_t cnt;
+#ifdef ALL_THREADS_STOPPED
+ int num;
+#else
+# define num 1
+#endif
+
+ LOG ("td_ta_map_lwp2thr");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Read all the descriptors. */
+ if (ps_pdread (ta->ph, ta->handles, phc,
+ sizeof (struct pthread_handle_struct) * pthread_threads_max)
+ != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+#ifdef ALL_THREADS_STOPPED
+ /* Read the number of currently active threads. */
+ if (ps_pdread (ta->ph, ta->pthread_handles_num, &num, sizeof (int)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+#endif
+
+ /* Get the entries one after the other and find out whether the ID
+ matches. */
+ for (cnt = 0; cnt < pthread_threads_max && num > 0; ++cnt)
+ if (phc[cnt].h_descr != NULL)
+ {
+ struct _pthread_descr_struct pds;
+
+#ifdef ALL_THREADS_STOPPED
+ /* First count this active thread. */
+ --num;
+#endif
+
+ if (ps_pdread (ta->ph, phc[cnt].h_descr, &pds, sizeof_descr) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ if ((pds.p_pid ?: ps_getpid (ta->ph)) == lwpid)
+ {
+ /* Found it. Now fill in the `td_thrhandle_t' object. */
+ th->th_ta_p = (td_thragent_t *) ta;
+ th->th_unique = phc[cnt].h_descr;
+
+ 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/linuxthreads_db/td_ta_new.c b/linuxthreads_db/td_ta_new.c
new file mode 100644
index 0000000000..e93d8b4c50
--- /dev/null
+++ b/linuxthreads_db/td_ta_new.c
@@ -0,0 +1,150 @@
+/* Attach to target process.
+ Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <version.h>
+
+#include "thread_dbP.h"
+
+
+/* Datatype for the list of known thread agents. Normally there will
+ be exactly one so we don't spend much though on making it fast. */
+struct agent_list *__td_agent_list;
+
+
+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 ("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
+ not available we cannot debug. */
+ 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)
+ return TD_MALLOC;
+
+ /* Store the proc handle which we will pass to the callback functions
+ back into the debugger. */
+ (*ta)->ph = ps;
+
+ /* Remember the address. */
+ (*ta)->pthread_threads_eventsp = (td_thr_events_t *) addr;
+
+ /* Get the pointer to the variable pointing to the thread descriptor
+ with the last event. */
+ if (td_lookup (ps, PTHREAD_LAST_EVENT, &(*ta)->pthread_last_event) != PS_OK)
+ {
+ free_return:
+ free (*ta);
+ return TD_ERR;
+ }
+
+ /* Get the pointer to the variable containing the number of active
+ threads. */
+ 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 (td_lookup (ps, PTHREAD_HANDLES, &addr) != PS_OK)
+ goto free_return;
+
+ (*ta)->handles = (struct pthread_handle_struct *) addr;
+
+
+ if (td_lookup (ps, PTHREAD_KEYS, &addr) != PS_OK)
+ goto free_return;
+
+ /* Cast to the right type. */
+ (*ta)->keys = (struct pthread_key_struct *) addr;
+
+ /* 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 (td_lookup (ps, LINUXTHREADS_PTHREAD_THREADS_MAX, &addr) != PS_OK)
+ (*ta)->pthread_threads_max = PTHREAD_THREADS_MAX;
+ else
+ {
+ if (ps_pdread (ps, addr, &(*ta)->pthread_threads_max, sizeof (int))
+ != PS_OK)
+ goto free_return;
+ }
+
+ /* Similar for the maximum number of thread local data keys. */
+ if (td_lookup (ps, 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;
+ }
+
+ /* And for the size of the second level arrays for the keys. */
+ if (td_lookup (ps, LINUXTHREADS_PTHREAD_SIZEOF_DESCR, &addr) != PS_OK)
+ (*ta)->sizeof_descr = sizeof (struct _pthread_descr_struct);
+ else
+ {
+ if (ps_pdread (ps, addr, &(*ta)->sizeof_descr, sizeof (int)) != PS_OK)
+ goto free_return;
+ /* Don't let bogons in the inferior make us mess ourselves. */
+ if ((*ta)->sizeof_descr > sizeof (struct _pthread_descr_struct))
+ (*ta)->sizeof_descr = sizeof (struct _pthread_descr_struct);
+ }
+
+ /* Now add the new agent descriptor to the list. */
+ elemp = (struct agent_list *) malloc (sizeof (struct agent_list));
+ if (elemp == NULL)
+ {
+ /* Argh, now that everything else worked... */
+ free (*ta);
+ return TD_MALLOC;
+ }
+
+ /* We don't care for thread-safety here. */
+ elemp->ta = *ta;
+ elemp->next = __td_agent_list;
+ __td_agent_list = elemp;
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_reset_stats.c b/linuxthreads_db/td_ta_reset_stats.c
new file mode 100644
index 0000000000..b3ddbd07b3
--- /dev/null
+++ b/linuxthreads_db/td_ta_reset_stats.c
@@ -0,0 +1,35 @@
+/* Reset statistics.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_ta_reset_stats (const td_thragent_t *ta)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_ta_reset_stats");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_set_event.c b/linuxthreads_db/td_ta_set_event.c
new file mode 100644
index 0000000000..73cf9f4051
--- /dev/null
+++ b/linuxthreads_db/td_ta_set_event.c
@@ -0,0 +1,53 @@
+/* Globally enable events.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_ta_set_event (ta, event)
+ const td_thragent_t *ta;
+ td_thr_events_t *event;
+{
+ td_thr_events_t old_event;
+ int i;
+
+ LOG ("td_ta_set_event");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ /* Write the new value into the thread data structure. */
+ if (ps_pdread (ta->ph, ta->pthread_threads_eventsp,
+ &old_event, sizeof (td_thrhandle_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Or the new bits in. */
+ for (i = 0; i < TD_EVENTSIZE; ++i)
+ old_event.event_bits[i] |= event->event_bits[i];
+
+ /* Write the new value into the thread data structure. */
+ if (ps_pdwrite (ta->ph, ta->pthread_threads_eventsp,
+ &old_event, sizeof (td_thrhandle_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_ta_setconcurrency.c b/linuxthreads_db/td_ta_setconcurrency.c
new file mode 100644
index 0000000000..408e763094
--- /dev/null
+++ b/linuxthreads_db/td_ta_setconcurrency.c
@@ -0,0 +1,35 @@
+/* Set suggested concurrency level for process.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_ta_setconcurrency (const td_thragent_t *ta, int level)
+{
+ /* This is something LinuxThreads does not support. */
+ LOG ("td_ta_setconcurrency");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ return TD_NOCAPAB;
+}
diff --git a/linuxthreads_db/td_ta_thr_iter.c b/linuxthreads_db/td_ta_thr_iter.c
new file mode 100644
index 0000000000..9ab04e14e3
--- /dev/null
+++ b/linuxthreads_db/td_ta_thr_iter.c
@@ -0,0 +1,176 @@
+/* Iterate over a process's threads.
+ Copyright (C) 1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <linuxthreads/internals.h>
+#include <alloca.h>
+
+static int
+handle_descr (const td_thragent_t *ta, td_thr_iter_f *callback,
+ void *cbdata_p, td_thr_state_e state, int ti_pri,
+ size_t cnt, pthread_descr descr)
+{
+ struct _pthread_descr_struct pds;
+ 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. */
+#if !defined USE_TLS || !TLS_DTV_AT_TP
+ pds.p_header.data.self = &pds;
+#endif
+ 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? */
+
+ /* The manager thread must be handled special. The descriptor
+ exists but the thread only gets created when the first
+ `pthread_create' call is issued. A clear indication that this
+ happened is when the p_pid field is non-zero. */
+ if (cnt == 1 && pds.p_pid == 0)
+ return TD_OK;
+
+ /* Now test whether this thread matches the specified
+ conditions. */
+
+ /* Only if the priority level is as high or higher. */
+ if (pds.p_priority < ti_pri)
+ return TD_OK;
+
+ /* Test the state.
+ XXX This is incomplete. */
+ if (state != TD_THR_ANY_STATE)
+ return TD_OK;
+
+ /* XXX For now we ignore threads which are not running anymore.
+ The reason is that gdb tries to get the registers and fails.
+ In future we should have a special mode of the thread library
+ in which we keep the process around until the actual join
+ operation happened. */
+ if (pds.p_exited != 0)
+ return TD_OK;
+
+ /* Yep, it matches. Call the callback function. */
+ th.th_ta_p = (td_thragent_t *) ta;
+ th.th_unique = descr;
+ if (callback (&th, cbdata_p) != 0)
+ return TD_DBERR;
+
+ /* All done successfully. */
+ return TD_OK;
+}
+
+
+td_err_e
+td_ta_thr_iter (const td_thragent_t *ta, td_thr_iter_f *callback,
+ void *cbdata_p, td_thr_state_e state, int ti_pri,
+ sigset_t *ti_sigmask_p, unsigned int ti_user_flags)
+{
+ int pthread_threads_max;
+ struct pthread_handle_struct *phc;
+ td_err_e result = TD_OK;
+ int cnt;
+#ifdef ALL_THREADS_STOPPED
+ int num;
+#else
+# define num 1
+#endif
+
+ LOG ("td_ta_thr_iter");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ pthread_threads_max = ta->pthread_threads_max;
+ phc = (struct pthread_handle_struct *) alloca (sizeof (phc[0])
+ * pthread_threads_max);
+
+ /* First read only the main thread and manager thread information. */
+ if (ps_pdread (ta->ph, ta->handles, phc,
+ sizeof (struct pthread_handle_struct) * 2) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Now handle these descriptors. */
+ result = handle_descr (ta, callback, cbdata_p, state, ti_pri, 0,
+ phc[0].h_descr);
+ if (result != TD_OK)
+ return result;
+ result = handle_descr (ta, callback, cbdata_p, state, ti_pri, 1,
+ phc[1].h_descr);
+ if (result != TD_OK)
+ return result;
+
+ /* Read all the descriptors. */
+ if (ps_pdread (ta->ph, ta->handles + 2, &phc[2],
+ (sizeof (struct pthread_handle_struct)
+ * (pthread_threads_max - 2))) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+#ifdef ALL_THREADS_STOPPED
+ /* Read the number of currently active threads. */
+ if (ps_pdread (ta->ph, ta->pthread_handles_num, &num, sizeof (int)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+#endif
+
+ /* Now get all descriptors, one after the other. */
+ for (cnt = 2; cnt < pthread_threads_max && num > 0; ++cnt)
+ if (phc[cnt].h_descr != NULL)
+ {
+#ifdef ALL_THREADS_STOPPED
+ /* First count this active thread. */
+ --num;
+#endif
+
+ result = handle_descr (ta, callback, cbdata_p, state, ti_pri, cnt,
+ phc[cnt].h_descr);
+ if (result != TD_OK)
+ break;
+ }
+
+ return result;
+}
diff --git a/linuxthreads_db/td_ta_tsd_iter.c b/linuxthreads_db/td_ta_tsd_iter.c
new file mode 100644
index 0000000000..2eb41f6a15
--- /dev/null
+++ b/linuxthreads_db/td_ta_tsd_iter.c
@@ -0,0 +1,56 @@
+/* Iterate over a process's thread-specific data.
+ Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <linuxthreads/internals.h>
+#include <alloca.h>
+
+td_err_e
+td_ta_tsd_iter (const td_thragent_t *ta, td_key_iter_f *callback,
+ void *cbdata_p)
+{
+ struct pthread_key_struct *keys;
+ int pthread_keys_max;
+ int cnt;
+
+ LOG ("td_ta_tsd_iter");
+
+ /* Test whether the TA parameter is ok. */
+ if (! ta_ok (ta))
+ return TD_BADTA;
+
+ pthread_keys_max = ta->pthread_keys_max;
+ keys = (struct pthread_key_struct *) alloca (sizeof (keys[0])
+ * pthread_keys_max);
+
+ /* Read all the information about the keys. */
+ if (ps_pdread (ta->ph, ta->keys, keys,
+ sizeof (keys[0]) * pthread_keys_max) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Now get all descriptors, one after the other. */
+ for (cnt = 0; cnt < pthread_keys_max; ++cnt)
+ if (keys[cnt].in_use
+ /* Return with an error if the callback returns a nonzero value. */
+ && callback (cnt, keys[cnt].destr, cbdata_p) != 0)
+ return TD_DBERR;
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_clear_event.c b/linuxthreads_db/td_thr_clear_event.c
new file mode 100644
index 0000000000..c027fc09fd
--- /dev/null
+++ b/linuxthreads_db/td_thr_clear_event.c
@@ -0,0 +1,62 @@
+/* Disable specific event for thread.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <stddef.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_thr_clear_event (th, event)
+ const td_thrhandle_t *th;
+ td_thr_events_t *event;
+{
+ td_thr_events_t old_event;
+ int i;
+
+ 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,
+ ((char *) th->th_unique
+ + offsetof (struct _pthread_descr_struct,
+ p_eventbuf.eventmask)),
+ &old_event, sizeof (td_thrhandle_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Remove the set bits in. */
+ for (i = 0; i < TD_EVENTSIZE; ++i)
+ old_event.event_bits[i] &= ~event->event_bits[i];
+
+ /* Write the new value into the thread data structure. */
+ if (ps_pdwrite (th->th_ta_p->ph,
+ ((char *) th->th_unique
+ + offsetof (struct _pthread_descr_struct,
+ p_eventbuf.eventmask)),
+ &old_event, sizeof (td_thrhandle_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_dbresume.c b/linuxthreads_db/td_thr_dbresume.c
new file mode 100644
index 0000000000..7b7f6eef9f
--- /dev/null
+++ b/linuxthreads_db/td_thr_dbresume.c
@@ -0,0 +1,30 @@
+/* Resume execution of given thread.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_thr_dbresume (const td_thrhandle_t *th)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_thr_dbresume");
+ return TD_NOCAPAB;
+}
diff --git a/linuxthreads_db/td_thr_dbsuspend.c b/linuxthreads_db/td_thr_dbsuspend.c
new file mode 100644
index 0000000000..ef668023de
--- /dev/null
+++ b/linuxthreads_db/td_thr_dbsuspend.c
@@ -0,0 +1,30 @@
+/* Suspend execution of given thread.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_thr_dbsuspend (const td_thrhandle_t *th)
+{
+ /* XXX We have to figure out what has to be done. */
+ LOG ("td_thr_dbsuspend");
+ return TD_NOCAPAB;
+}
diff --git a/linuxthreads_db/td_thr_event_enable.c b/linuxthreads_db/td_thr_event_enable.c
new file mode 100644
index 0000000000..407f3fc44a
--- /dev/null
+++ b/linuxthreads_db/td_thr_event_enable.c
@@ -0,0 +1,57 @@
+/* Enable event process-wide.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <stddef.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_thr_event_enable (th, onoff)
+ const td_thrhandle_t *th;
+ int onoff;
+{
+ 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)),
+ &onoff, sizeof (int)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_event_getmsg.c b/linuxthreads_db/td_thr_event_getmsg.c
new file mode 100644
index 0000000000..bf4ddd4ade
--- /dev/null
+++ b/linuxthreads_db/td_thr_event_getmsg.c
@@ -0,0 +1,65 @@
+/* Retrieve event.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <stddef.h>
+#include <string.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_thr_event_getmsg (const td_thrhandle_t *th, td_event_msg_t *msg)
+{
+ td_eventbuf_t event;
+
+ 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,
+ ((char *) th->th_unique
+ + offsetof (struct _pthread_descr_struct, p_eventbuf)),
+ &event, sizeof (td_eventbuf_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Check whether an event occurred. */
+ if (event.eventnum == TD_EVENT_NONE)
+ /* Nothing. */
+ return TD_NOMSG;
+
+ /* Fill the user's data structure. */
+ msg->event = event.eventnum;
+ msg->th_p = th;
+ msg->msg.data = (uintptr_t) event.eventdata;
+
+ /* And clear the event message in the target. */
+ memset (&event, '\0', sizeof (td_eventbuf_t));
+ if (ps_pdwrite (th->th_ta_p->ph,
+ ((char *) th->th_unique
+ + offsetof (struct _pthread_descr_struct, p_eventbuf)),
+ &event, sizeof (td_eventbuf_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_get_info.c b/linuxthreads_db/td_thr_get_info.c
new file mode 100644
index 0000000000..4666bda976
--- /dev/null
+++ b/linuxthreads_db/td_thr_get_info.c
@@ -0,0 +1,83 @@
+/* Get thread information.
+ Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <stddef.h>
+#include <string.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_thr_get_info (const td_thrhandle_t *th, td_thrinfo_t *infop)
+{
+ struct _pthread_descr_struct pds;
+
+ LOG ("td_thr_get_info");
+
+ /* 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. */
+ memset (infop, '\0', sizeof (td_thrinfo_t));
+
+ /* We have to handle the manager thread special since the thread
+ descriptor in older versions is not fully initialized. */
+ if (pds.p_nr == 1)
+ {
+ infop->ti_tid = th->th_ta_p->pthread_threads_max * 2 + 1;
+ infop->ti_type = TD_THR_SYSTEM;
+ infop->ti_state = TD_THR_ACTIVE;
+ }
+ else
+ {
+ infop->ti_tid = pds.p_tid;
+ 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;
+ else if (! pds.p_detached)
+ infop->ti_state = TD_THR_ZOMBIE;
+ else
+ infop->ti_state = TD_THR_UNKNOWN;
+ }
+
+ /* Initialization which are the same in both cases. */
+ infop->ti_lid = pds.p_pid ?: ps_getpid (th->th_ta_p->ph);
+ infop->ti_ta_p = th->th_ta_p;
+ infop->ti_startfunc = pds.p_start_args.start_routine;
+ memcpy (&infop->ti_events, &pds.p_eventbuf.eventmask,
+ sizeof (td_thr_events_t));
+ infop->ti_traceme = pds.p_report_events != 0;
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_getfpregs.c b/linuxthreads_db/td_thr_getfpregs.c
new file mode 100644
index 0000000000..31c55c8765
--- /dev/null
+++ b/linuxthreads_db/td_thr_getfpregs.c
@@ -0,0 +1,58 @@
+/* Get a thread's floating-point register set.
+ Copyright (C) 1999, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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"
+
+
+td_err_e
+td_thr_getfpregs (const td_thrhandle_t *th, prfpregset_t *regset)
+{
+ struct _pthread_descr_struct pds;
+
+ LOG ("td_thr_getfpregs");
+
+ if (th->th_unique == NULL)
+ {
+ /* No data yet. Use the main thread. */
+ pid_t pid = ps_getpid (th->th_ta_p->ph);
+ if (ps_lgetfpregs (th->th_ta_p->ph, pid, regset) != PS_OK)
+ return TD_ERR;
+ 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,
+ sizeof (struct _pthread_descr_struct)) != PS_OK)
+ return TD_ERR;
+
+ /* If the thread already terminated we return all zeroes. */
+ if (pds.p_terminated)
+ memset (regset, '\0', sizeof (*regset));
+ /* Otherwise get the register content through the callback. */
+ else
+ {
+ pid_t pid = pds.p_pid ?: ps_getpid (th->th_ta_p->ph);
+
+ if (ps_lgetfpregs (th->th_ta_p->ph, pid, regset) != PS_OK)
+ return TD_ERR;
+ }
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_getgregs.c b/linuxthreads_db/td_thr_getgregs.c
new file mode 100644
index 0000000000..a9ec6a37da
--- /dev/null
+++ b/linuxthreads_db/td_thr_getgregs.c
@@ -0,0 +1,58 @@
+/* Get a thread's general register set.
+ Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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"
+
+
+td_err_e
+td_thr_getgregs (const td_thrhandle_t *th, prgregset_t gregs)
+{
+ struct _pthread_descr_struct pds;
+
+ LOG ("td_thr_getgregs");
+
+ if (th->th_unique == NULL)
+ {
+ /* No data yet. Use the main thread. */
+ pid_t pid = ps_getpid (th->th_ta_p->ph);
+ if (ps_lgetregs (th->th_ta_p->ph, pid, gregs) != PS_OK)
+ return TD_ERR;
+ 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,
+ sizeof (struct _pthread_descr_struct)) != PS_OK)
+ return TD_ERR;
+
+ /* If the thread already terminated we return all zeroes. */
+ if (pds.p_terminated)
+ memset (gregs, '\0', sizeof (prgregset_t));
+ /* Otherwise get the register content through the callback. */
+ else
+ {
+ pid_t pid = pds.p_pid ?: ps_getpid (th->th_ta_p->ph);
+
+ if (ps_lgetregs (th->th_ta_p->ph, pid, gregs) != PS_OK)
+ return TD_ERR;
+ }
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_getxregs.c b/linuxthreads_db/td_thr_getxregs.c
new file mode 100644
index 0000000000..39cd73cf1d
--- /dev/null
+++ b/linuxthreads_db/td_thr_getxregs.c
@@ -0,0 +1,30 @@
+/* Get a thread's extra state register set.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_thr_getxregs (const td_thrhandle_t *th, void *xregs)
+{
+ /* XXX This might be platform specific. */
+ LOG ("td_thr_getxregs");
+ return TD_NOXREGS;
+}
diff --git a/linuxthreads_db/td_thr_getxregsize.c b/linuxthreads_db/td_thr_getxregsize.c
new file mode 100644
index 0000000000..5d8ac288e4
--- /dev/null
+++ b/linuxthreads_db/td_thr_getxregsize.c
@@ -0,0 +1,30 @@
+/* Get the size of the extra state register set for this architecture.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_thr_getxregsize (const td_thrhandle_t *th, int *sizep)
+{
+ /* XXX This might be platform specific. */
+ LOG ("td_thr_getxregsize");
+ return TD_NOXREGS;
+}
diff --git a/linuxthreads_db/td_thr_set_event.c b/linuxthreads_db/td_thr_set_event.c
new file mode 100644
index 0000000000..205b445c79
--- /dev/null
+++ b/linuxthreads_db/td_thr_set_event.c
@@ -0,0 +1,62 @@
+/* Enable specific event for thread.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <stddef.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_thr_set_event (th, event)
+ const td_thrhandle_t *th;
+ td_thr_events_t *event;
+{
+ td_thr_events_t old_event;
+ int i;
+
+ 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,
+ ((char *) th->th_unique
+ + offsetof (struct _pthread_descr_struct,
+ p_eventbuf.eventmask)),
+ &old_event, sizeof (td_thrhandle_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Or the new bits in. */
+ for (i = 0; i < TD_EVENTSIZE; ++i)
+ old_event.event_bits[i] |= event->event_bits[i];
+
+ /* Write the new value into the thread data structure. */
+ if (ps_pdwrite (th->th_ta_p->ph,
+ ((char *) th->th_unique
+ + offsetof (struct _pthread_descr_struct,
+ p_eventbuf.eventmask)),
+ &old_event, sizeof (td_thrhandle_t)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_setfpregs.c b/linuxthreads_db/td_thr_setfpregs.c
new file mode 100644
index 0000000000..e4d9ec65e7
--- /dev/null
+++ b/linuxthreads_db/td_thr_setfpregs.c
@@ -0,0 +1,47 @@
+/* Set a thread's floating-point register set.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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"
+
+
+td_err_e
+td_thr_setfpregs (const td_thrhandle_t *th, const prfpregset_t *fpregs)
+{
+ struct _pthread_descr_struct pds = { .p_terminated = 0, .p_pid = 0 };
+
+ LOG ("td_thr_setfpregs");
+
+ /* We have to get the state and the PID for this thread. */
+ 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;
+
+ /* Only set the registers if the thread hasn't yet terminated. */
+ if (pds.p_terminated == 0)
+ {
+ pid_t pid = pds.p_pid ?: ps_getpid (th->th_ta_p->ph);
+
+ if (ps_lsetfpregs (th->th_ta_p->ph, pid, fpregs) != PS_OK)
+ return TD_ERR;
+ }
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_setgregs.c b/linuxthreads_db/td_thr_setgregs.c
new file mode 100644
index 0000000000..8c021a4738
--- /dev/null
+++ b/linuxthreads_db/td_thr_setgregs.c
@@ -0,0 +1,47 @@
+/* Set a thread's general register set.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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"
+
+
+td_err_e
+td_thr_setgregs (const td_thrhandle_t *th, prgregset_t gregs)
+{
+ struct _pthread_descr_struct pds = { .p_terminated = 0, .p_pid = 0 };
+
+ LOG ("td_thr_setgregs");
+
+ /* We have to get the state and the PID for this thread. */
+ 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;
+
+ /* Only set the registers if the thread hasn't yet terminated. */
+ if (pds.p_terminated == 0)
+ {
+ pid_t pid = pds.p_pid ?: ps_getpid (th->th_ta_p->ph);
+
+ if (ps_lsetregs (th->th_ta_p->ph, pid, gregs) != PS_OK)
+ return TD_ERR;
+ }
+
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_setprio.c b/linuxthreads_db/td_thr_setprio.c
new file mode 100644
index 0000000000..98d202dfe0
--- /dev/null
+++ b/linuxthreads_db/td_thr_setprio.c
@@ -0,0 +1,30 @@
+/* Set a thread's priority.
+ 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.
+
+ 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"
+
+
+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 ("td_thr_setprio");
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_setsigpending.c b/linuxthreads_db/td_thr_setsigpending.c
new file mode 100644
index 0000000000..98e30140eb
--- /dev/null
+++ b/linuxthreads_db/td_thr_setsigpending.c
@@ -0,0 +1,31 @@
+/* Raise a signal for a thread.
+ 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.
+
+ 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"
+
+
+td_err_e
+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 ("td_thr_setsigpending");
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_setxregs.c b/linuxthreads_db/td_thr_setxregs.c
new file mode 100644
index 0000000000..da77ab3b43
--- /dev/null
+++ b/linuxthreads_db/td_thr_setxregs.c
@@ -0,0 +1,30 @@
+/* Set a thread's extra state register set.
+ 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.
+
+ 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"
+
+
+td_err_e
+td_thr_setxregs (const td_thrhandle_t *ta, const void *addr)
+{
+ /* XXX This might have to be platform specific. */
+ LOG ("td_thr_setxregs");
+ return TD_NOXREGS;
+}
diff --git a/linuxthreads_db/td_thr_sigsetmask.c b/linuxthreads_db/td_thr_sigsetmask.c
new file mode 100644
index 0000000000..8b0eb81859
--- /dev/null
+++ b/linuxthreads_db/td_thr_sigsetmask.c
@@ -0,0 +1,30 @@
+/* Set a thread's signal mask.
+ 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.
+
+ 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"
+
+
+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 ("td_thr_sigsetmask");
+ return TD_OK;
+}
diff --git a/linuxthreads_db/td_thr_tls_get_addr.c b/linuxthreads_db/td_thr_tls_get_addr.c
new file mode 100644
index 0000000000..c900cac8e0
--- /dev/null
+++ b/linuxthreads_db/td_thr_tls_get_addr.c
@@ -0,0 +1,45 @@
+/* Get address of thread local variable.
+ Copyright (C) 2002,2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 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"
+
+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
+ /* Read the module ID from the link_map. */
+ size_t modid;
+ 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? */
+
+ td_err_e result = td_thr_tlsbase (th, modid, address);
+ if (result == TD_OK)
+ *address += offset;
+ return result;
+#else
+ return TD_ERR;
+#endif
+}
diff --git a/linuxthreads_db/td_thr_tlsbase.c b/linuxthreads_db/td_thr_tlsbase.c
new file mode 100644
index 0000000000..081e8d0e70
--- /dev/null
+++ b/linuxthreads_db/td_thr_tlsbase.c
@@ -0,0 +1,71 @@
+/* Locate TLS data for a thread.
+ Copyright (C) 2003, 2004 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"
+
+/* Value used for dtv entries for which the allocation is delayed. */
+# define TLS_DTV_UNALLOCATED ((void *) -1l)
+
+td_err_e
+td_thr_tlsbase (const td_thrhandle_t *th,
+ unsigned long int modid,
+ psaddr_t *base)
+{
+ if (modid < 1)
+ return TD_NOTLS;
+
+#if USE_TLS
+ union dtv pdtv, *dtvp;
+
+ LOG ("td_thr_tlsbase");
+
+ psaddr_t dtvpp = th->th_unique;
+#if TLS_TCB_AT_TP
+ dtvpp += offsetof (struct _pthread_descr_struct, p_header.data.dtvp);
+#elif TLS_DTV_AT_TP
+/* Special case hack. If TLS_TCB_SIZE == 0 (on PowerPC), there is no TCB
+ containing the DTV at the TP, but actually the TCB lies behind the TP,
+ i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE. */
+ dtvpp += TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
+ - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0);
+#else
+# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined."
+#endif
+
+ /* Get the DTV pointer from the thread descriptor. */
+ if (ps_pdread (th->th_ta_p->ph, dtvpp, &dtvp, sizeof dtvp) != 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)
+ return TD_TLSDEFER;
+
+ *base = (char *) pdtv.pointer;
+
+ return TD_OK;
+#else
+ return TD_ERR;
+#endif
+}
diff --git a/linuxthreads_db/td_thr_tsd.c b/linuxthreads_db/td_thr_tsd.c
new file mode 100644
index 0000000000..978dc5e524
--- /dev/null
+++ b/linuxthreads_db/td_thr_tsd.c
@@ -0,0 +1,82 @@
+/* Get a thread-specific data pointer for a thread.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <linuxthreads/internals.h>
+
+
+td_err_e
+td_thr_tsd (const td_thrhandle_t *th, const thread_key_t tk, void **data)
+{
+ struct _pthread_descr_struct pds;
+ struct pthread_key_struct *keys = th->th_ta_p->keys;
+ struct pthread_key_struct key;
+ int pthread_keys_max = th->th_ta_p->pthread_keys_max;
+ int pthread_key_2ndlevel_size = th->th_ta_p->pthread_key_2ndlevel_size;
+ unsigned int idx1st;
+ unsigned int idx2nd;
+ void *p;
+
+ 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,
+ sizeof (struct _pthread_descr_struct)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* Check correct value of key. */
+ if (tk >= pthread_keys_max)
+ return TD_BADKEY;
+
+ /* Get the key entry. */
+ 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? */
+
+ /* Fail if this key is not at all used. */
+ if (! key.in_use)
+ return TD_BADKEY;
+
+ /* Compute the indeces. */
+ idx1st = tk / pthread_key_2ndlevel_size;
+ idx2nd = tk % pthread_key_2ndlevel_size;
+
+ /* Check the pointer to the second level array. */
+ if (pds.p_specific[idx1st] == NULL)
+ return TD_NOTSD;
+
+ /* Now get the real key.
+ XXX I don't know whether it's correct but there is currently no
+ easy way to determine whether a key was never set or the value
+ is NULL. We return an error whenever the value is NULL. */
+ if (ps_pdread (th->th_ta_p->ph, &pds.p_specific[idx1st][idx2nd], &p,
+ sizeof (void *)) != PS_OK)
+ return TD_ERR;
+
+ if (p != NULL)
+ *data = p;
+
+ return p != NULL ? TD_OK : TD_NOTSD;
+}
diff --git a/linuxthreads_db/td_thr_validate.c b/linuxthreads_db/td_thr_validate.c
new file mode 100644
index 0000000000..6f893d3f7f
--- /dev/null
+++ b/linuxthreads_db/td_thr_validate.c
@@ -0,0 +1,70 @@
+/* Validate a thread handle.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@cygnus.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 <linuxthreads/internals.h>
+
+
+td_err_e
+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 ("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)
+ {
+ if (ps_pdread (th->th_ta_p->ph, handles, &phc,
+ sizeof (struct pthread_handle_struct)) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ if (phc.h_descr != NULL && phc.h_descr == th->th_unique)
+ {
+ struct _pthread_descr_struct pds;
+
+ if (ps_pdread (th->th_ta_p->ph, phc.h_descr, &pds,
+ th->th_ta_p->sizeof_descr) != PS_OK)
+ return TD_ERR; /* XXX Other error value? */
+
+ /* XXX There should be another test using the TID but this is
+ currently not available. */
+ return pds.p_terminated != 0 ? TD_NOTHR : TD_OK;
+ }
+ }
+
+ return TD_ERR;
+}
diff --git a/linuxthreads_db/thread_db.h b/linuxthreads_db/thread_db.h
new file mode 100644
index 0000000000..c115399a32
--- /dev/null
+++ b/linuxthreads_db/thread_db.h
@@ -0,0 +1,459 @@
+/* thread_db.h -- interface to libthread_db.so library for debugging -lpthread
+ Copyright (C) 1999,2001,2002,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. */
+
+#ifndef _THREAD_DB_H
+#define _THREAD_DB_H 1
+
+/* This is the debugger interface for the LinuxThreads library. It is
+ modelled closely after the interface with same names in Solaris with
+ the goal to share the same code in the debugger. */
+#include <pthread.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/procfs.h>
+
+
+/* Error codes of the library. */
+typedef enum
+{
+ TD_OK, /* No error. */
+ TD_ERR, /* No further specified error. */
+ TD_NOTHR, /* No matching thread found. */
+ TD_NOSV, /* No matching synchronization handle found. */
+ TD_NOLWP, /* No matching light-weighted process found. */
+ TD_BADPH, /* Invalid process handle. */
+ TD_BADTH, /* Invalid thread handle. */
+ TD_BADSH, /* Invalid synchronization handle. */
+ TD_BADTA, /* Invalid thread agent. */
+ TD_BADKEY, /* Invalid key. */
+ TD_NOMSG, /* No event available. */
+ TD_NOFPREGS, /* No floating-point register content available. */
+ TD_NOLIBTHREAD, /* Application not linked with thread library. */
+ TD_NOEVENT, /* Requested event is not supported. */
+ TD_NOCAPAB, /* Capability not available. */
+ TD_DBERR, /* Internal debug library error. */
+ TD_NOAPLIC, /* Operation is not applicable. */
+ 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_TLSDEFER, /* Thread has not yet allocated TLS for given module. */
+ TD_NOTALLOC = TD_TLSDEFER,
+ TD_VERSION, /* Version if libpthread and libthread_db do not match. */
+ TD_NOTLS /* There is TLS segment in the given module. */
+} td_err_e;
+
+
+/* Possible thread states. TD_THR_ANY_STATE is a pseudo-state used to
+ select threads regardless of state in td_ta_thr_iter(). */
+typedef enum
+{
+ TD_THR_ANY_STATE,
+ TD_THR_UNKNOWN,
+ TD_THR_STOPPED,
+ TD_THR_RUN,
+ TD_THR_ACTIVE,
+ TD_THR_ZOMBIE,
+ TD_THR_SLEEP,
+ TD_THR_STOPPED_ASLEEP
+} td_thr_state_e;
+
+/* Thread type: user or system. TD_THR_ANY_TYPE is a pseudo-type used
+ to select threads regardless of type in td_ta_thr_iter(). */
+typedef enum
+{
+ TD_THR_ANY_TYPE,
+ TD_THR_USER,
+ TD_THR_SYSTEM
+} td_thr_type_e;
+
+
+/* Types of the debugging library. */
+
+/* Handle for a process. This type is opaque. */
+typedef struct td_thragent td_thragent_t;
+
+/* The actual thread handle type. This is also opaque. */
+typedef struct td_thrhandle
+{
+ td_thragent_t *th_ta_p;
+ psaddr_t th_unique;
+} 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
+#define TD_SIGNO_MASK NULL
+
+
+#define TD_EVENTSIZE 2
+#define BT_UISHIFT 5 /* log base 2 of BT_NBIPUI, to extract word index */
+#define BT_NBIPUI (1 << BT_UISHIFT) /* n bits per uint */
+#define BT_UIMASK (BT_NBIPUI - 1) /* to extract bit index */
+
+/* Bitmask of enabled events. */
+typedef struct td_thr_events
+{
+ uint32_t event_bits[TD_EVENTSIZE];
+} td_thr_events_t;
+
+/* Event set manipulation macros. */
+#define __td_eventmask(n) \
+ (UINT32_C (1) << (((n) - 1) & BT_UIMASK))
+#define __td_eventword(n) \
+ ((UINT32_C ((n) - 1)) >> BT_UISHIFT)
+
+#define td_event_emptyset(setp) \
+ do { \
+ int __i; \
+ for (__i = TD_EVENTSIZE; __i > 0; --__i) \
+ (setp)->event_bits[__i - 1] = 0; \
+ } while (0)
+
+#define td_event_fillset(setp) \
+ do { \
+ int __i; \
+ for (__i = TD_EVENTSIZE; __i > 0; --__i) \
+ (setp)->event_bits[__i - 1] = UINT32_C (0xffffffff); \
+ } while (0)
+
+#define td_event_addset(setp, n) \
+ (((setp)->event_bits[__td_eventword (n)]) |= __td_eventmask (n))
+#define td_event_delset(setp, n) \
+ (((setp)->event_bits[__td_eventword (n)]) &= ~__td_eventmask (n))
+#define td_eventismember(setp, n) \
+ (__td_eventmask (n) & ((setp)->event_bits[__td_eventword (n)]))
+#if TD_EVENTSIZE == 2
+# define td_eventisempty(setp) \
+ (!((setp)->event_bits[0]) && !((setp)->event_bits[1]))
+#else
+# error "td_eventisempty must be changed to match TD_EVENTSIZE"
+#endif
+
+/* Events reportable by the thread implementation. */
+typedef enum
+{
+ TD_ALL_EVENTS, /* Pseudo-event number. */
+ TD_EVENT_NONE = TD_ALL_EVENTS, /* Depends on context. */
+ TD_READY, /* Is executable now. */
+ TD_SLEEP, /* Blocked in a synchronization obj. */
+ TD_SWITCHTO, /* Now assigned to a process. */
+ TD_SWITCHFROM, /* Not anymore assigned to a process. */
+ TD_LOCK_TRY, /* Trying to get an unavailable lock. */
+ TD_CATCHSIG, /* Signal posted to the thread. */
+ TD_IDLE, /* Process getting idle. */
+ TD_CREATE, /* New thread created. */
+ TD_DEATH, /* Thread terminated. */
+ TD_PREEMPT, /* Preempted. */
+ TD_PRI_INHERIT, /* Inherited elevated priority. */
+ TD_REAP, /* Reaped. */
+ TD_CONCURRENCY, /* Number of processes changing. */
+ TD_TIMEOUT, /* Conditional variable wait timed out. */
+ TD_MIN_EVENT_NUM = TD_READY,
+ TD_MAX_EVENT_NUM = TD_TIMEOUT,
+ TD_EVENTS_ENABLE = 31 /* Event reporting enabled. */
+} td_event_e;
+
+/* Values representing the different ways events are reported. */
+typedef enum
+{
+ NOTIFY_BPT, /* User must insert breakpoint at u.bptaddr. */
+ NOTIFY_AUTOBPT, /* Breakpoint at u.bptaddr is automatically
+ inserted. */
+ NOTIFY_SYSCALL /* System call u.syscallno will be invoked. */
+} td_notify_e;
+
+/* Description how event type is reported. */
+typedef struct td_notify
+{
+ td_notify_e type; /* Way the event is reported. */
+ union
+ {
+ psaddr_t bptaddr; /* Address of breakpoint. */
+ int syscallno; /* Number of system call used. */
+ } u;
+} td_notify_t;
+
+/* Structure used to report event. */
+typedef struct td_event_msg
+{
+ td_event_e event; /* Event type being reported. */
+ const td_thrhandle_t *th_p; /* Thread reporting the event. */
+ union
+ {
+# if 0
+ td_synchandle_t *sh; /* Handle of synchronization object. */
+#endif
+ uintptr_t data; /* Event specific data. */
+ } msg;
+} td_event_msg_t;
+
+/* Structure containing event data available in each thread structure. */
+typedef struct
+{
+ td_thr_events_t eventmask; /* Mask of enabled events. */
+ td_event_e eventnum; /* Number of last event. */
+ void *eventdata; /* Data associated with event. */
+} td_eventbuf_t;
+
+
+/* Gathered statistics about the process. */
+typedef struct td_ta_stats
+{
+ int nthreads; /* Total number of threads in use. */
+ int r_concurrency; /* Concurrency level requested by user. */
+ int nrunnable_num; /* Average runnable threads, numerator. */
+ int nrunnable_den; /* Average runnable threads, denominator. */
+ int a_concurrency_num; /* Achieved concurrency level, numerator. */
+ int a_concurrency_den; /* Achieved concurrency level, denominator. */
+ int nlwps_num; /* Average number of processes in use,
+ numerator. */
+ int nlwps_den; /* Average number of processes in use,
+ denominator. */
+ int nidle_num; /* Average number of idling processes,
+ numerator. */
+ int nidle_den; /* Average number of idling processes,
+ denominator. */
+} td_ta_stats_t;
+
+
+/* Since Sun's library is based on Solaris threads we have to define a few
+ types to map them to POSIX threads. */
+typedef pthread_t thread_t;
+typedef pthread_key_t thread_key_t;
+
+
+/* Callback for iteration over threads. */
+typedef int td_thr_iter_f (const td_thrhandle_t *, void *);
+
+/* Callback for iteration over thread local data. */
+typedef int td_key_iter_f (thread_key_t, void (*) (void *), void *);
+
+
+
+/* Forward declaration. This has to be defined by the user. */
+struct ps_prochandle;
+
+
+/* Information about the thread. */
+typedef struct td_thrinfo
+{
+ td_thragent_t *ti_ta_p; /* Process handle. */
+ unsigned int ti_user_flags; /* Unused. */
+ thread_t ti_tid; /* Thread ID returned by
+ pthread_create(). */
+ char *ti_tls; /* Pointer to thread-local data. */
+ psaddr_t ti_startfunc; /* Start function passed to
+ pthread_create(). */
+ psaddr_t ti_stkbase; /* Base of thread's stack. */
+ long int ti_stksize; /* Size of thread's stack. */
+ psaddr_t ti_ro_area; /* Unused. */
+ int ti_ro_size; /* Unused. */
+ td_thr_state_e ti_state; /* Thread state. */
+ unsigned char ti_db_suspended; /* Nonzero if suspended by debugger. */
+ td_thr_type_e ti_type; /* Type of the thread (system vs
+ user thread). */
+ intptr_t ti_pc; /* Unused. */
+ intptr_t ti_sp; /* Unused. */
+ short int ti_flags; /* Unused. */
+ int ti_pri; /* Thread priority. */
+ lwpid_t ti_lid; /* Unused. */
+ sigset_t ti_sigmask; /* Signal mask. */
+ unsigned char ti_traceme; /* Nonzero if event reporting
+ enabled. */
+ unsigned char ti_preemptflag; /* Unused. */
+ unsigned char ti_pirecflag; /* Unused. */
+ sigset_t ti_pending; /* Set of pending signals. */
+ td_thr_events_t ti_events; /* Set of enabled events. */
+} td_thrinfo_t;
+
+
+
+/* Prototypes for exported library functions. */
+
+/* Initialize the thread debug support library. */
+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);
+
+/* Free resources allocated for TA. */
+extern td_err_e td_ta_delete (td_thragent_t *__ta);
+
+/* Get number of currently running threads in process associated with TA. */
+extern td_err_e td_ta_get_nthreads (const td_thragent_t *__ta, int *__np);
+
+/* Return process handle passed in `td_ta_new' for process associated with
+ TA. */
+extern td_err_e td_ta_get_ph (const td_thragent_t *__ta,
+ struct ps_prochandle **__ph);
+
+/* Map thread library handle PT to thread debug library handle for process
+ associated with TA and store result in *TH. */
+extern td_err_e td_ta_map_id2thr (const td_thragent_t *__ta, pthread_t __pt,
+ td_thrhandle_t *__th);
+
+/* Map process ID LWPID to thread debug library handle for process
+ associated with TA and store result in *TH. */
+extern td_err_e td_ta_map_lwp2thr (const td_thragent_t *__ta, lwpid_t __lwpid,
+ td_thrhandle_t *__th);
+
+
+/* Call for each thread in a process associated with TA the callback function
+ CALLBACK. */
+extern td_err_e td_ta_thr_iter (const td_thragent_t *__ta,
+ td_thr_iter_f *__callback, void *__cbdata_p,
+ td_thr_state_e __state, int __ti_pri,
+ sigset_t *__ti_sigmask_p,
+ unsigned int __ti_user_flags);
+
+/* Call for each defined thread local data entry the callback function KI. */
+extern td_err_e td_ta_tsd_iter (const td_thragent_t *__ta, td_key_iter_f *__ki,
+ void *__p);
+
+
+/* Get event address for EVENT. */
+extern td_err_e td_ta_event_addr (const td_thragent_t *__ta,
+ td_event_e __event, td_notify_t *__ptr);
+
+/* Enable EVENT in global mask. */
+extern td_err_e td_ta_set_event (const td_thragent_t *__ta,
+ td_thr_events_t *__event);
+
+/* Disable EVENT in global mask. */
+extern td_err_e td_ta_clear_event (const td_thragent_t *__ta,
+ td_thr_events_t *__event);
+
+/* Return information about last event. */
+extern td_err_e td_ta_event_getmsg (const td_thragent_t *__ta,
+ td_event_msg_t *__msg);
+
+
+/* Set suggested concurrency level for process associated with TA. */
+extern td_err_e td_ta_setconcurrency (const td_thragent_t *__ta, int __level);
+
+
+/* Enable collecting statistics for process associated with TA. */
+extern td_err_e td_ta_enable_stats (const td_thragent_t *__ta, int __enable);
+
+/* Reset statistics. */
+extern td_err_e td_ta_reset_stats (const td_thragent_t *__ta);
+
+/* Retrieve statistics from process associated with TA. */
+extern td_err_e td_ta_get_stats (const td_thragent_t *__ta,
+ td_ta_stats_t *__statsp);
+
+
+/* Validate that TH is a thread handle. */
+extern td_err_e td_thr_validate (const td_thrhandle_t *__th);
+
+/* Return information about thread TH. */
+extern td_err_e td_thr_get_info (const td_thrhandle_t *__th,
+ td_thrinfo_t *__infop);
+
+/* Retrieve floating-point register contents of process running thread TH. */
+extern td_err_e td_thr_getfpregs (const td_thrhandle_t *__th,
+ prfpregset_t *__regset);
+
+/* Retrieve general register contents of process running thread TH. */
+extern td_err_e td_thr_getgregs (const td_thrhandle_t *__th,
+ prgregset_t __gregs);
+
+/* Retrieve extended register contents of process running thread TH. */
+extern td_err_e td_thr_getxregs (const td_thrhandle_t *__th, void *__xregs);
+
+/* Get size of extended register set of process running thread TH. */
+extern td_err_e td_thr_getxregsize (const td_thrhandle_t *__th, int *__sizep);
+
+/* Set floating-point register contents of process running thread TH. */
+extern td_err_e td_thr_setfpregs (const td_thrhandle_t *__th,
+ const prfpregset_t *__fpregs);
+
+/* Set general register contents of process running thread TH. */
+extern td_err_e td_thr_setgregs (const td_thrhandle_t *__th,
+ prgregset_t __gregs);
+
+/* Set extended register contents of process running thread TH. */
+extern td_err_e td_thr_setxregs (const td_thrhandle_t *__th,
+ const void *__addr);
+
+
+/* Get address of the given module's TLS storage area for the given thread. */
+extern td_err_e td_thr_tlsbase (const td_thrhandle_t *__th,
+ unsigned long int __modid,
+ psaddr_t *__base);
+
+/* 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);
+
+/* Enable EVENT for thread TH. */
+extern td_err_e td_thr_set_event (const td_thrhandle_t *__th,
+ td_thr_events_t *__event);
+
+/* Disable EVENT for thread TH. */
+extern td_err_e td_thr_clear_event (const td_thrhandle_t *__th,
+ td_thr_events_t *__event);
+
+/* Get event message for thread TH. */
+extern td_err_e td_thr_event_getmsg (const td_thrhandle_t *__th,
+ td_event_msg_t *__msg);
+
+
+/* Set priority of thread TH. */
+extern td_err_e td_thr_setprio (const td_thrhandle_t *__th, int __prio);
+
+
+/* Set pending signals for thread TH. */
+extern td_err_e td_thr_setsigpending (const td_thrhandle_t *__th,
+ unsigned char __n, const sigset_t *__ss);
+
+/* Set signal mask for thread TH. */
+extern td_err_e td_thr_sigsetmask (const td_thrhandle_t *__th,
+ const sigset_t *__ss);
+
+
+/* Return thread local data associated with key TK in thread TH. */
+extern td_err_e td_thr_tsd (const td_thrhandle_t *__th,
+ const thread_key_t __tk, void **__data);
+
+
+/* Suspend execution of thread TH. */
+extern td_err_e td_thr_dbsuspend (const td_thrhandle_t *__th);
+
+/* Resume execution of thread TH. */
+extern td_err_e td_thr_dbresume (const td_thrhandle_t *__th);
+
+#endif /* thread_db.h */
diff --git a/linuxthreads_db/thread_dbP.h b/linuxthreads_db/thread_dbP.h
new file mode 100644
index 0000000000..63b408afc1
--- /dev/null
+++ b/linuxthreads_db/thread_dbP.h
@@ -0,0 +1,108 @@
+/* Private header for thread debug library. */
+#ifndef _THREAD_DBP_H
+#define _THREAD_DBP_H 1
+
+#include <string.h>
+#include <unistd.h>
+#include "proc_service.h"
+#include "thread_db.h"
+#include "../linuxthreads/descr.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,
+ LINUXTHREADS_INITIAL_REPORT_EVENTS,
+ LINUXTHREADS_VERSION,
+ NUM_MESSAGES
+ };
+
+
+/* Comment out the following for less verbose output. */
+#ifndef NDEBUG
+# define LOG(c) if (__td_debug) write (2, c "\n", strlen (c "\n"))
+extern int __td_debug;
+#else
+# define LOG(c)
+#endif
+
+
+/* Handle for a process. This type is opaque. */
+struct td_thragent
+{
+ /* Delivered by the debugger and we have to pass it back in the
+ proc callbacks. */
+ struct ps_prochandle *ph;
+
+ /* Some cached information. */
+
+ /* Address of the `__pthread_handles' array. */
+ struct pthread_handle_struct *handles;
+
+ /* Address of the `pthread_kyes' array. */
+ struct pthread_key_struct *keys;
+
+ /* Maximum number of threads. */
+ int pthread_threads_max;
+
+ /* Maximum number of thread-local data keys. */
+ int pthread_keys_max;
+
+ /* Size of 2nd level array for thread-local data keys. */
+ int pthread_key_2ndlevel_size;
+
+ /* Sizeof struct _pthread_descr_struct. */
+ int sizeof_descr;
+
+ /* Pointer to the `__pthread_threads_events' variable in the target. */
+ psaddr_t pthread_threads_eventsp;
+
+ /* Pointer to the `__pthread_last_event' variable in the target. */
+ psaddr_t pthread_last_event;
+
+ /* Pointer to the `__pthread_handles_num' variable. */
+ psaddr_t pthread_handles_num;
+};
+
+
+/* Type used internally to keep track of thread agent descriptors. */
+struct agent_list
+{
+ td_thragent_t *ta;
+ struct agent_list *next;
+};
+
+/* List of all known descriptors. */
+extern struct agent_list *__td_agent_list;
+
+/* Function used to test for correct thread agent pointer. */
+static inline int
+ta_ok (const td_thragent_t *ta)
+{
+ struct agent_list *runp = __td_agent_list;
+
+ if (ta == NULL)
+ return 0;
+
+ while (runp != NULL && runp->ta != ta)
+ runp = runp->next;
+
+ 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 */