From: Michael Snyder Date: Mon, 30 Apr 2001 20:25:07 +0000 (+0000) Subject: 2001-04-30 Michael Snyder X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7ca673cdc5b96f7fbe66ac7253c0e56e9cb69697;p=binutils-gdb.git 2001-04-30 Michael Snyder * thread-db.c: Revert 2001-04-26 change for debugging output. * lin-lwp.c: Ditto. * lin-lwp.c: Add set/show debug lin-lwp command. Use this command to turn extra debugging output on / off. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e01b9c35f59..6ac66a90e2c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,7 +1,9 @@ 2001-04-30 Michael Snyder * thread-db.c: Revert 2001-04-26 change for debugging output. - * lin-lwp.c: Ditto. + * lin-lwp.c: Ditto. + * lin-lwp.c: Add set/show debug lin-lwp command. Use this + command to turn extra debugging output on / off. 2001-04-27 Andrew Cagney diff --git a/gdb/lin-lwp.c b/gdb/lin-lwp.c index 56e7bb23871..8e37a2ef87a 100644 --- a/gdb/lin-lwp.c +++ b/gdb/lin-lwp.c @@ -30,12 +30,10 @@ #include "inferior.h" #include "target.h" #include "regcache.h" +#include "gdbcmd.h" -#define DEBUG 1 - -#if DEBUG +static int debug_lin_lwp; 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 @@ -521,9 +519,9 @@ stop_wait_callback (struct lwp_info *lp, void *data) printf_unfiltered ("[%s exited]\n", target_pid_to_str (lp->pid)); } -#if DEBUG - printf ("%s exited.\n", target_pid_to_str (lp->pid)); -#endif + if (debug_lin_lwp) + printf ("%s exited.\n", target_pid_to_str (lp->pid)); + delete_lwp (lp->pid); return 0; } @@ -549,21 +547,22 @@ 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 - printf ("Tripped breakpoint at %lx in LWP %d" - " while waiting for SIGSTOP.\n", - (long) read_pc_pid (lp->pid), pid); -#endif + + if (debug_lin_lwp) + printf ("Tripped breakpoint at %lx in LWP %d" + " while waiting for SIGSTOP.\n", + (long) read_pc_pid (lp->pid), pid); + /* 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 - printf ("Received %s in LWP %d while waiting for SIGSTOP.\n", - strsignal (WSTOPSIG (status)), pid); -#endif + if (debug_lin_lwp) + printf ("Received %s in LWP %d while waiting for SIGSTOP.\n", + strsignal (WSTOPSIG (status)), pid); + /* The thread was stopped with a signal other than SIGSTOP, and didn't accidentiliy trip a breakpoint. Record the wait status. */ @@ -620,10 +619,10 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) lp = iterate_over_lwps (status_callback, NULL); if (lp) { -#if DEBUG - printf ("Using pending wait status for LWP %d.\n", - GET_LWP (lp->pid)); -#endif + if (debug_lin_lwp) + printf ("Using pending wait status for LWP %d.\n", + GET_LWP (lp->pid)); + status = lp->status; lp->status = 0; } @@ -635,19 +634,19 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) } else if (is_lwp (pid)) { -#if DEBUG - printf ("Waiting for specific LWP %d.\n", GET_LWP (pid)); -#endif + if (debug_lin_lwp) + printf ("Waiting for specific LWP %d.\n", GET_LWP (pid)); + /* 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 - if (status) + + if (debug_lin_lwp) + 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 @@ -725,9 +724,9 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) printf_unfiltered ("[%s exited]\n", target_pid_to_str (lp->pid)); } -#if DEBUG - printf ("%s exited.\n", target_pid_to_str (lp->pid)); -#endif + if (debug_lin_lwp) + printf ("%s exited.\n", target_pid_to_str (lp->pid)); + delete_lwp (lp->pid); /* Make sure there is at least one thread running. */ @@ -743,10 +742,10 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) if (lp->signalled && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP) { -#if DEBUG - printf ("Delayed SIGSTOP caught for %s.\n", - target_pid_to_str (lp->pid)); -#endif + if (debug_lin_lwp) + printf ("Delayed SIGSTOP caught for %s.\n", + target_pid_to_str (lp->pid)); + /* This is a delayed SIGSTOP. */ lp->signalled = 0; @@ -1040,6 +1039,13 @@ _initialize_lin_lwp (void) sigdelset (&suspend_mask, SIGCHLD); sigemptyset (&blocked_mask); + + add_show_from_set (add_set_cmd ("lin-lwp", no_class, var_zinteger, + (char *) &debug_lin_lwp, + "Set debugging of linux lwp module.\n\ +Enables printf debugging output.\n", + &setdebuglist), + &showdebuglist); }