summaryrefslogtreecommitdiff
path: root/gdb/lin-lwp.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2001-07-07 10:58:37 +0000
committerMark Kettenis <kettenis@gnu.org>2001-07-07 10:58:37 +0000
commit22d7870321167d3a52162a2ae5d4dbb60789c10d (patch)
tree54dfa9dfecb35a6f516596e935e6f3c08cf92c8b /gdb/lin-lwp.c
parent512eb262dd52ce49d8491827f592f535c685e882 (diff)
downloadgdb-22d7870321167d3a52162a2ae5d4dbb60789c10d.tar.gz
* lin-lwp.c (status_to_str): New function.
(lin_lwp_wait): Use it to print debug messages where appropriate.
Diffstat (limited to 'gdb/lin-lwp.c')
-rw-r--r--gdb/lin-lwp.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/gdb/lin-lwp.c b/gdb/lin-lwp.c
index 89752ddc15c..66fedc579e9 100644
--- a/gdb/lin-lwp.c
+++ b/gdb/lin-lwp.c
@@ -153,7 +153,27 @@ static sigset_t blocked_mask;
/* Prototypes for local functions. */
static int stop_wait_callback (struct lwp_info *lp, void *data);
+/* Convert wait status STATUS to a string. Used for printing debug
+ messages only. */
+static char *
+status_to_str (int status)
+{
+ static char buf[64];
+
+ if (WIFSTOPPED (status))
+ snprintf (buf, sizeof (buf), "%s (stopped)",
+ strsignal (WSTOPSIG (status)));
+ else if (WIFSIGNALED (status))
+ snprintf (buf, sizeof (buf), "%s (terminated)",
+ strsignal (WSTOPSIG (status)));
+ else
+ snprintf (buf, sizeof (buf), "%d (exited)",
+ WEXITSTATUS (status));
+
+ return buf;
+}
+
/* Initialize the list of LWPs. Note that this module, contrary to
what GDB's generic threads layer does for its thread list,
re-initializes the LWP lists whenever we mourn or detach (which
@@ -901,11 +921,9 @@ lin_lwp_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
lp->status = 0;
if (debug_lin_lwp && status)
- fprintf_unfiltered (gdb_stdlog,
- "Using pending wait status %d for LWP %ld.\n",
- WIFSTOPPED (status) ? WSTOPSIG (status) :
- WIFSIGNALED (status) ? WTERMSIG (status) :
- WEXITSTATUS (status), GET_LWP (lp->ptid));
+ fprintf_unfiltered (gdb_stdlog,
+ "Using pending wait status %s for LWP %ld.\n",
+ status_to_str (status), GET_LWP (lp->ptid));
}
/* But if we don't fine one, we'll have to wait, and check both
@@ -927,11 +945,9 @@ lin_lwp_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
lp->status = 0;
if (debug_lin_lwp && status)
- fprintf_unfiltered (gdb_stdlog,
- "Using pending wait status %d for LWP %ld.\n",
- WIFSTOPPED (status) ? WSTOPSIG (status) :
- WIFSIGNALED (status) ? WTERMSIG (status) :
- WEXITSTATUS (status), GET_LWP (lp->ptid));
+ fprintf_unfiltered (gdb_stdlog,
+ "Using pending wait status %s for LWP %ld.\n",
+ status_to_str (status), GET_LWP (lp->ptid));
/* 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
@@ -1103,9 +1119,8 @@ lin_lwp_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
lp->stopped = 1;
if (debug_lin_lwp)
- fprintf_unfiltered (gdb_stdlog,
- "LLW: Candidate event %d in %ld\n",
- WSTOPSIG (status), GET_LWP (lp->ptid));
+ fprintf_unfiltered (gdb_stdlog, "Candidate event %s in LWP %ld.\n",
+ status_to_str (status), GET_LWP (lp->ptid));
/* Now stop all other LWP's ... */
iterate_over_lwps (stop_callback, NULL);