aboutsummaryrefslogtreecommitdiff
path: root/nptl_db
diff options
context:
space:
mode:
Diffstat (limited to 'nptl_db')
-rw-r--r--nptl_db/Makefile57
-rw-r--r--nptl_db/Versions21
-rw-r--r--nptl_db/proc_service.h73
-rw-r--r--nptl_db/shlib-versions2
-rw-r--r--nptl_db/td_init.c32
-rw-r--r--nptl_db/td_log.c32
-rw-r--r--nptl_db/td_symbol_list.c55
-rw-r--r--nptl_db/td_ta_clear_event.c52
-rw-r--r--nptl_db/td_ta_delete.c42
-rw-r--r--nptl_db/td_ta_enable_stats.c35
-rw-r--r--nptl_db/td_ta_event_addr.c69
-rw-r--r--nptl_db/td_ta_event_getmsg.c85
-rw-r--r--nptl_db/td_ta_get_nthreads.c41
-rw-r--r--nptl_db/td_ta_get_ph.c36
-rw-r--r--nptl_db/td_ta_get_stats.c35
-rw-r--r--nptl_db/td_ta_map_id2thr.c38
-rw-r--r--nptl_db/td_ta_map_lwp2thr.c43
-rw-r--r--nptl_db/td_ta_new.c115
-rw-r--r--nptl_db/td_ta_reset_stats.c35
-rw-r--r--nptl_db/td_ta_set_event.c52
-rw-r--r--nptl_db/td_ta_setconcurrency.c35
-rw-r--r--nptl_db/td_ta_thr_iter.c125
-rw-r--r--nptl_db/td_ta_tsd_iter.c53
-rw-r--r--nptl_db/td_thr_clear_event.c54
-rw-r--r--nptl_db/td_thr_dbresume.c30
-rw-r--r--nptl_db/td_thr_dbsuspend.c30
-rw-r--r--nptl_db/td_thr_event_enable.c41
-rw-r--r--nptl_db/td_thr_event_getmsg.c60
-rw-r--r--nptl_db/td_thr_get_info.c64
-rw-r--r--nptl_db/td_thr_getfpregs.c52
-rw-r--r--nptl_db/td_thr_getgregs.c52
-rw-r--r--nptl_db/td_thr_getxregs.c30
-rw-r--r--nptl_db/td_thr_getxregsize.c30
-rw-r--r--nptl_db/td_thr_set_event.c54
-rw-r--r--nptl_db/td_thr_setfpregs.c49
-rw-r--r--nptl_db/td_thr_setgregs.c49
-rw-r--r--nptl_db/td_thr_setprio.c30
-rw-r--r--nptl_db/td_thr_setsigpending.c31
-rw-r--r--nptl_db/td_thr_setxregs.c30
-rw-r--r--nptl_db/td_thr_sigsetmask.c30
-rw-r--r--nptl_db/td_thr_tls_get_addr.c70
-rw-r--r--nptl_db/td_thr_tsd.c71
-rw-r--r--nptl_db/td_thr_validate.c66
-rw-r--r--nptl_db/thread_db.h451
-rw-r--r--nptl_db/thread_dbP.h98
45 files changed, 2635 insertions, 0 deletions
diff --git a/nptl_db/Makefile b/nptl_db/Makefile
new file mode 100644
index 0000000000..4812cd2af9
--- /dev/null
+++ b/nptl_db/Makefile
@@ -0,0 +1,57 @@
+# Copyright (C) 2002 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# Makefile for NPTL debug library subdirectory of GNU C Library.
+
+subdir := nptl_db
+
+nptl_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_new td_ta_delete \
+ td_ta_get_nthreads td_ta_get_ph \
+ td_ta_map_id2thr td_ta_map_lwp2thr \
+ 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_tls_get_addr
+
+
+
+libthread_db-inhibit-o = $(filter-out .os,$(object-suffixes))
+
+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/nptl_db/Versions b/nptl_db/Versions
new file mode 100644
index 0000000000..4ca8042c12
--- /dev/null
+++ b/nptl_db/Versions
@@ -0,0 +1,21 @@
+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;
+ }
+}
diff --git a/nptl_db/proc_service.h b/nptl_db/proc_service.h
new file mode 100644
index 0000000000..9963c3aecd
--- /dev/null
+++ b/nptl_db/proc_service.h
@@ -0,0 +1,73 @@
+/* Copyright (C) 1999, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* 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);
+
+extern ps_err_e ps_get_thread_area (const struct ps_prochandle *, lwpid_t,
+ int, psaddr_t *);
diff --git a/nptl_db/shlib-versions b/nptl_db/shlib-versions
new file mode 100644
index 0000000000..592f7fa284
--- /dev/null
+++ b/nptl_db/shlib-versions
@@ -0,0 +1,2 @@
+# The thread debug library
+.*-.*-linux.* libthread_db=1
diff --git a/nptl_db/td_init.c b/nptl_db/td_init.c
new file mode 100644
index 0000000000..946ff7244e
--- /dev/null
+++ b/nptl_db/td_init.c
@@ -0,0 +1,32 @@
+/* Initialization function of thread debugger support library.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "thread_dbP.h"
+
+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/nptl_db/td_log.c b/nptl_db/td_log.c
new file mode 100644
index 0000000000..52212a0e9f
--- /dev/null
+++ b/nptl_db/td_log.c
@@ -0,0 +1,32 @@
+/* Noop, left for historical reasons.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "thread_dbP.h"
+
+
+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/nptl_db/td_symbol_list.c b/nptl_db/td_symbol_list.c
new file mode 100644
index 0000000000..1be7001d85
--- /dev/null
+++ b/nptl_db/td_symbol_list.c
@@ -0,0 +1,55 @@
+/* Return list of symbols the library can request.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.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"
+
+
+static const char *symbol_list_arr[] =
+{
+ [SYM_PTHREAD_THREADS_EVENTS] = "__nptl_threads_events",
+ [SYM_PTHREAD_LAST_EVENT] = "__nptl_last_event",
+ [SYM_PTHREAD_NTHREADS] = "nptl_nthreads",
+ [SYM_PTHREAD_STACK_USED] = "stack_used",
+ [SYM_PTHREAD_STACK_USER] = "__stack_user",
+ [SYM_PTHREAD_KEYS] = "pthread_keys",
+ [SYM_PTHREAD_KEYS_MAX] = "__pthread_pthread_keys_max",
+ [SYM_PTHREAD_SIZEOF_DESCR] = "__pthread_pthread_sizeof_descr",
+ [SYM_PTHREAD_CREATE_EVENT] = "__nptl_create_event",
+ [SYM_PTHREAD_DEATH_EVENT] = "__nptl_death_event",
+ [SYM_PTHREAD_VERSION] = "nptl_version",
+ [SYM_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 < SYM_NUM_MESSAGES);
+ return ps_pglobal_lookup (ps, LIBPTHREAD_SO, symbol_list_arr[idx], sym_addr);
+}
diff --git a/nptl_db/td_ta_clear_event.c b/nptl_db/td_ta_clear_event.c
new file mode 100644
index 0000000000..611281fbaa
--- /dev/null
+++ b/nptl_db/td_ta_clear_event.c
@@ -0,0 +1,52 @@
+/* Globally disable events.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_ta_clear_event (ta, event)
+ const td_thragent_t *ta;
+ td_thr_events_t *event;
+{
+ 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. */
+ td_thr_events_t old_event;
+ 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. */
+ int i;
+ 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/nptl_db/td_ta_delete.c b/nptl_db/td_ta_delete.c
new file mode 100644
index 0000000000..57b90e57f2
--- /dev/null
+++ b/nptl_db/td_ta_delete.c
@@ -0,0 +1,42 @@
+/* Detach to target process.
+ Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 1999.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdlib.h>
+
+#include "thread_dbP.h"
+
+
+td_err_e
+td_ta_delete (td_thragent_t *ta)
+{
+ LOG ("td_ta_delete");
+