From 540af400154502df8054af624998b03f659f1043 Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Mon, 30 Apr 2001 18:21:17 +0000 Subject: [PATCH] 2001-04-30 Michael Snyder * thread-db.c: Revert 2001-04-26 change for debugging output. * lin-lwp.c: Ditto. --- gdb/ChangeLog | 5 ++++ gdb/lin-lwp.c | 61 ++++++++++++++++++++++++++----------------------- gdb/thread-db.c | 26 ++++++++------------- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 43ac242ce6..e01b9c35f5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2001-04-30 Michael Snyder + + * thread-db.c: Revert 2001-04-26 change for debugging output. + * lin-lwp.c: Ditto. + 2001-04-27 Andrew Cagney * gdbtypes.c (check_stub_method): Always initialize ``p''. diff --git a/gdb/lin-lwp.c b/gdb/lin-lwp.c index 7f6f010317..56e7bb2387 100644 --- a/gdb/lin-lwp.c +++ b/gdb/lin-lwp.c @@ -31,8 +31,11 @@ #include "target.h" #include "regcache.h" -extern int debug_linux_threads; +#define DEBUG 1 + +#if DEBUG extern const char *strsignal (int sig); +#endif /* On Linux there are no real LWP's. The closest thing to LWP's are processes sharing the same VM space. A multi-threaded process is @@ -518,9 +521,9 @@ stop_wait_callback (struct lwp_info *lp, void *data) printf_unfiltered ("[%s exited]\n", target_pid_to_str (lp->pid)); } - if (debug_linux_threads) - printf ("%s exited.\n", target_pid_to_str (lp->pid)); - +#if DEBUG + printf ("%s exited.\n", target_pid_to_str (lp->pid)); +#endif delete_lwp (lp->pid); return 0; } @@ -546,21 +549,21 @@ stop_wait_callback (struct lwp_info *lp, void *data) If we do not do this, then we run the risk that the user will delete or disable the breakpoint, but the thread will have already tripped on it. */ - - if (debug_linux_threads) - printf ("Tripped breakpoint at %lx in LWP %d" - " while waiting for SIGSTOP.\n", - (long) read_pc_pid (lp->pid), pid); - +#if DEBUG + printf ("Tripped breakpoint at %lx in LWP %d" + " while waiting for SIGSTOP.\n", + (long) read_pc_pid (lp->pid), pid); +#endif /* Set the PC to before the trap. */ if (DECR_PC_AFTER_BREAK) write_pc_pid (read_pc_pid (pid) - DECR_PC_AFTER_BREAK, pid); } else { - if (debug_linux_threads) - printf ("Received %s in LWP %d while waiting for SIGSTOP.\n", - strsignal (WSTOPSIG (status)), pid); +#if DEBUG + printf ("Received %s in LWP %d while waiting for SIGSTOP.\n", + strsignal (WSTOPSIG (status)), pid); +#endif /* The thread was stopped with a signal other than SIGSTOP, and didn't accidentiliy trip a breakpoint. Record the wait status. */ @@ -617,9 +620,10 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) lp = iterate_over_lwps (status_callback, NULL); if (lp) { - if (debug_linux_threads) - printf ("Using pending wait status for LWP %d.\n", - GET_LWP (lp->pid)); +#if DEBUG + printf ("Using pending wait status for LWP %d.\n", + GET_LWP (lp->pid)); +#endif status = lp->status; lp->status = 0; } @@ -631,18 +635,19 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) } else if (is_lwp (pid)) { - if (debug_linux_threads) - printf ("Waiting for specific LWP %d.\n", GET_LWP (pid)); - +#if DEBUG + printf ("Waiting for specific LWP %d.\n", GET_LWP (pid)); +#endif /* We have a specific LWP to check. */ lp = find_lwp_pid (GET_LWP (pid)); gdb_assert (lp); status = lp->status; lp->status = 0; - if (debug_linux_threads) - if (status) +#if DEBUG + if (status) printf ("Using pending wait status for LWP %d.\n", GET_LWP (lp->pid)); +#endif /* If we have to wait, take into account whether PID is a cloned process or not. And we have to convert it to something that @@ -720,9 +725,9 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) printf_unfiltered ("[%s exited]\n", target_pid_to_str (lp->pid)); } - if (debug_linux_threads) - printf ("%s exited.\n", target_pid_to_str (lp->pid)); - +#if DEBUG + printf ("%s exited.\n", target_pid_to_str (lp->pid)); +#endif delete_lwp (lp->pid); /* Make sure there is at least one thread running. */ @@ -738,10 +743,10 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) if (lp->signalled && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP) { - if (debug_linux_threads) - printf ("Delayed SIGSTOP caught for %s.\n", - target_pid_to_str (lp->pid)); - +#if DEBUG + printf ("Delayed SIGSTOP caught for %s.\n", + target_pid_to_str (lp->pid)); +#endif /* This is a delayed SIGSTOP. */ lp->signalled = 0; diff --git a/gdb/thread-db.c b/gdb/thread-db.c index 3d5f7b4d06..e35775173e 100644 --- a/gdb/thread-db.c +++ b/gdb/thread-db.c @@ -31,16 +31,12 @@ #include "symfile.h" #include "objfiles.h" #include "target.h" -#include "command.h" -#include "gdbcmd.h" #include "regcache.h" #ifndef LIBTHREAD_DB_SO #define LIBTHREAD_DB_SO "libthread_db.so.1" #endif -int debug_linux_threads = 0; /* Set non-zero for debugging output. */ - /* If we're running on Linux, we must explicitly attach to any new threads. */ /* FIXME: There is certainly some room for improvements: @@ -55,7 +51,7 @@ static struct target_ops thread_db_ops; static struct target_ops *target_beneath; /* Pointer to the next function on the objfile event chain. */ -static void (*new_objfile_event_chain) (struct objfile *objfile); +static void (*target_new_objfile_chain) (struct objfile *objfile); /* Non-zero if we're using this module's target vector. */ static int using_thread_db; @@ -592,8 +588,8 @@ thread_db_new_objfile (struct objfile *objfile) } quit: - if (new_objfile_event_chain) - new_objfile_event_chain (objfile); + if (target_new_objfile_chain) + target_new_objfile_chain (objfile); } static void @@ -701,10 +697,11 @@ check_event (int pid) error ("Thread creation event doesn't match breakpoint."); #endif - if (in_thread_list (pid)) - error ("Spurious thread creation event."); - - attach_thread (pid, msg.th_p, &ti, 1); + /* We may already know about this thread, for instance when the + user has issued the `info threads' command before the SIGTRAP + for hitting the thread creation breakpoint was reported. */ + if (! in_thread_list (pid)) + attach_thread (pid, msg.th_p, &ti, 1); return; case TD_DEATH: @@ -1026,12 +1023,7 @@ _initialize_thread_db (void) add_target (&thread_db_ops); /* Add ourselves to objfile event chain. */ - new_objfile_event_chain = target_new_objfile_hook; + target_new_objfile_chain = target_new_objfile_hook; target_new_objfile_hook = thread_db_new_objfile; } - add_show_from_set (add_set_cmd ("debug-linux-threads", class_support, - var_boolean, (char *) &debug_linux_threads, - "Set debug output for linux-threads \ -on or off.\nUse \"on\" to enable, \"off\" to disable.", &setlist), - &showlist); }