summaryrefslogtreecommitdiff
path: root/gdb/lin-lwp.c
diff options
context:
space:
mode:
authorMichael Snyder <msnyder@specifix.com>2001-04-26 23:14:20 +0000
committerMichael Snyder <msnyder@specifix.com>2001-04-26 23:14:20 +0000
commit1eb93c8be3f2118012ee08b80f9160bb8d13b917 (patch)
treee6a851255c7229fc5b046bdf49e82f90705d3834 /gdb/lin-lwp.c
parent44ff0f6c48bd950e857dbf4f59aff26a0c2c24a9 (diff)
downloadgdb-1eb93c8be3f2118012ee08b80f9160bb8d13b917.tar.gz
2001-04-26 Michael Snyder <msnyder@redhat.com>
* thread-db.c (_initialize_thread_db): Add set/show command "debug-linux-threads" for debugging output. * lin-lwp.c (various): Use global "debug_linux_threads to turn on extra debugging output.
Diffstat (limited to 'gdb/lin-lwp.c')
-rw-r--r--gdb/lin-lwp.c61
1 files changed, 28 insertions, 33 deletions
diff --git a/gdb/lin-lwp.c b/gdb/lin-lwp.c
index 56e7bb23871..7f6f0103173 100644
--- a/gdb/lin-lwp.c
+++ b/gdb/lin-lwp.c
@@ -31,11 +31,8 @@
#include "target.h"
#include "regcache.h"
-#define DEBUG 1
-
-#if DEBUG
+extern int debug_linux_threads;
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 +518,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_linux_threads)
+ printf ("%s exited.\n", target_pid_to_str (lp->pid));
+
delete_lwp (lp->pid);
return 0;
}
@@ -549,21 +546,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
- printf ("Tripped breakpoint at %lx in LWP %d"
- " while waiting for SIGSTOP.\n",
- (long) read_pc_pid (lp->pid), pid);
-#endif
+
+ if (debug_linux_threads)
+ 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_linux_threads)
+ 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 +617,9 @@ 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_linux_threads)
+ printf ("Using pending wait status for LWP %d.\n",
+ GET_LWP (lp->pid));
status = lp->status;
lp->status = 0;
}
@@ -635,19 +631,18 @@ 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_linux_threads)
+ 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_linux_threads)
+ 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 +720,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_linux_threads)
+ 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 +738,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_linux_threads)
+ printf ("Delayed SIGSTOP caught for %s.\n",
+ target_pid_to_str (lp->pid));
+
/* This is a delayed SIGSTOP. */
lp->signalled = 0;