* lin-lwp.c (status_to_str): New function.
authorMark Kettenis <kettenis@gnu.org>
Sat, 7 Jul 2001 10:58:37 +0000 (10:58 +0000)
committerMark Kettenis <kettenis@gnu.org>
Sat, 7 Jul 2001 10:58:37 +0000 (10:58 +0000)
(lin_lwp_wait): Use it to print debug messages where appropriate.

gdb/ChangeLog
gdb/lin-lwp.c

index c240072499e586eb47439b19b4812275496ec2f4..5cf3d87eaeb16e25a6b58486670b98f9e871b6c4 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-07  Mark Kettenis  <kettenis@gnu.org>
+
+       * lin-lwp.c (status_to_str): New function.
+       (lin_lwp_wait): Use it to print debug messages where appropriate.
+
 2001-07-06  Michael Chastain  <chastain@redhat.com>
 
        * i387-tdep.c (print_i387_value): Fix pointer glitch.
index 89752ddc15cbbdc57e2b1f94cce1b70613c314e4..66fedc579e98873be0e118cee93f787fc1de8978 100644 (file)
@@ -153,7 +153,27 @@ static sigset_t blocked_mask;
 /* Prototypes for local functions.  */
 static int stop_wait_callback (struct lwp_info *lp, void *data);
 \f
+/* 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;
+}
+\f
 /* 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);