/* libthread_db assisted debugging support, generic parts.
- Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006
+ Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
This file is part of GDB.
#include "gdbcore.h"
#include "linux-nat.h"
+#include <signal.h>
+
#ifdef HAVE_GNU_LIBC_VERSION_H
#include <gnu/libc-version.h>
#endif
return "only part of register set was written/read";
case TD_NOXREGS:
return "X register set not available for this thread";
+#ifdef THREAD_DB_HAS_TD_NOTALLOC
+ case TD_NOTALLOC:
+ return "thread has not yet allocated TLS for given module";
+#endif
+#ifdef THREAD_DB_HAS_TD_VERSION
+ case TD_VERSION:
+ return "versions of libpthread and libthread_db do not match";
+#endif
+#ifdef THREAD_DB_HAS_TD_NOTLS
+ case TD_NOTLS:
+ return "there is no TLS segment in the given module";
+#endif
default:
snprintf (buf, sizeof (buf), "unknown thread_db error '%d'", err);
return buf;
td_err_e err;
static int already_loaded;
+ /* Do nothing if we couldn't load libthread_db.so.1. */
+ if (td_ta_new_p == NULL)
+ return;
+
/* First time through, report that libthread_db was successfuly
loaded. Can't print this in in thread_db_load as, at that stage,
the interpreter and it's console haven't started. */
check_thread_signals ();
+ if (ti_p->ti_state == TD_THR_UNKNOWN || ti_p->ti_state == TD_THR_ZOMBIE)
+ return; /* A zombie thread -- do not attach. */
+
+ /* Under GNU/Linux, we have to attach to each and every thread. */
+ if (lin_lwp_attach_lwp (BUILD_LWP (ti_p->ti_lid, GET_PID (ptid)), 0) < 0)
+ return;
+
/* Add the thread to GDB's thread list. */
tp = add_thread (ptid);
tp->private = xmalloc (sizeof (struct private_thread_info));
if (verbose)
printf_unfiltered (_("[New %s]\n"), target_pid_to_str (ptid));
- if (ti_p->ti_state == TD_THR_UNKNOWN || ti_p->ti_state == TD_THR_ZOMBIE)
- return; /* A zombie thread -- do not attach. */
-
- /* Under GNU/Linux, we have to attach to each and every thread. */
-#ifdef ATTACH_LWP
- ATTACH_LWP (BUILD_LWP (ti_p->ti_lid, GET_PID (ptid)), 0);
-#endif
-
/* Enable thread event reporting for this thread. */
err = td_thr_event_enable_p (th_p, 1);
if (err != TD_OK)