[commit] Add diagnostic messages to thread-db.c and lwp-pool.c

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[commit] Add diagnostic messages to thread-db.c and lwp-pool.c

Kevin Buettner
I've just committed the following patch.  It enables the GDB user to
turn on lwp-pool diagnostics from GDB.  In addition, in debugging a
recent RDA problem, I found it useful to see the PC value of stopped
LWPs.  (I was trying to determine whether or not a single-stepped thread
had actually been stepped or not.  It turns out that it had not, which
leads to a few more upcoming patches...)

This patch is somewhat on the large side.  That's due mostly to revising
interfaces so that debug_get_pc() could be called from within lwp-pool.c.
I considered discarding the changes that I made for printing out the PC
value, but in the end I decided that they were useful enough to warrant
this commit.

        * diagnostics.h: New file.
        * gdbserv-thread-db.h (debug_get_pc): Move declaration to new
        file diagnostics.h.
        * linux-target.c (diagnostics.h): Include.
        (linux_process_rcmd): Add new monitor commands "lwp-pool-noisy",
        "lwp-pool-quiet", "all-noisy", and "all-quiet".  Delete monitor
        commands "proc-service-noisy" and "proc-service-quiet".
        * lwp-pool.c (diagnostics.h): Include.
        (debug_lwp_pool): Remove `static' qualifier.
        (debug_report_state_change):  Add code for printing out the PC value
        at which program stopped.
        (debug_report_state_change, wait_and_handle, check_stop_pending)
        (lwp_pool_waitpid, lwp_pool_stop_all, lwp_pool_continue_all)
        (lwp_pool_continue_lwp, lwp_pool_attach): Add `serv' argument.  Fix
        all callers.
        * lwp-pool.h (lwp_pool_attach, lwp_pool_waitpid, lwp_pool_stop_all)
        (lwp_pool_continue_all, lwp_pool_continue_lwp): Add `serv' argument.
        (lwp_pool_singlestep_lwp): Revise comment regarding consistency of
        not passing `serv' parameter.
        * thread-db.c (diagnostics.h): Include.
        (proc_service_noisy): Delete this unused global.
        (attach_thread, continue_thread): Add `serv' parameter.  Fix all
        callers.
        (update_thread_list, thread_db_singlestep_program): Add diagnostic
        messages.

Index: diagnostics.h
===================================================================
RCS file: diagnostics.h
diff -N diagnostics.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ diagnostics.h 8 Nov 2005 21:56:22 -0000
@@ -0,0 +1,33 @@
+/* diagnostics.h - Functions and variables used in RDA diagnostics.
+
+   Copyright 2005 Red Hat, Inc.
+
+   This file is part of RDA, the Red Hat Debug Agent (and library).
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+  
+   Alternative licenses for RDA may be arranged by contacting Red Hat,
+   Inc.  */
+
+/* When non-zero, print thread-db related diagnostic messages.  */
+extern int thread_db_noisy;
+
+/* When non-zero, print lwp pool related diagnostic messages.  */
+extern int debug_lwp_pool;
+
+/* Fetch the PC value for a given pid.  */
+struct gdbserv;
+extern unsigned long debug_get_pc (struct gdbserv *serv, pid_t pid);
Index: gdbserv-thread-db.h
===================================================================
RCS file: /cvs/src/src/rda/unix/gdbserv-thread-db.h,v
retrieving revision 1.6
diff -u -p -r1.6 gdbserv-thread-db.h
--- gdbserv-thread-db.h 24 Aug 2005 01:14:35 -0000 1.6
+++ gdbserv-thread-db.h 8 Nov 2005 21:56:22 -0000
@@ -92,10 +92,6 @@ extern void mips_singlestep (struct gdbs
 extern void am33_singlestep (struct gdbserv *serv, pid_t pid, int sig);
 #endif
 
-
-/* Fetch the value of PC for debugging purposes.  */
-extern unsigned long debug_get_pc (struct gdbserv *serv, pid_t pid);
-
 /* Adjust PC value after trap has been hit.  */
 extern int decr_pc_after_break (struct gdbserv *serv, pid_t pid);
 
Index: linux-target.c
===================================================================
RCS file: /cvs/src/src/rda/unix/linux-target.c,v
retrieving revision 1.19
diff -u -p -r1.19 linux-target.c
--- linux-target.c 24 Aug 2005 01:14:35 -0000 1.19
+++ linux-target.c 8 Nov 2005 21:56:23 -0000
@@ -48,6 +48,7 @@
 #include "server.h"
 #include "arch.h"
 #include "ptrace-target.h"
+#include "diagnostics.h"
 
 #ifdef STOCK_BREAKPOINTS
 #include "stock-breakpoints.h"
@@ -3109,26 +3110,42 @@ linux_process_rcmd (struct gdbserv *serv
       thread_db_noisy = 0;
       gdbserv_output_string_as_bytes (serv, "RDA thread-db diagnostics disabled.\n");
     }
-  else if (strcmp (cmd, "proc-service-noisy") == 0)
+  else if (strcmp (cmd, "lwp-pool-noisy") == 0)
     {
-      proc_service_noisy = 1;
-      gdbserv_output_string_as_bytes (serv, "RDA proc-service diagnostics enabled.\n");
+      debug_lwp_pool = 1;
+      gdbserv_output_string_as_bytes (serv, "RDA lwp-pool diagnostics enabled.\n");
     }
-  else if (strcmp (cmd, "proc-service-quiet") == 0)
+  else if (strcmp (cmd, "lwp-pool-quiet") == 0)
     {
-      proc_service_noisy = 0;
-      gdbserv_output_string_as_bytes (serv, "RDA proc-service diagnostics disabled.\n");
+      debug_lwp_pool = 0;
+      gdbserv_output_string_as_bytes (serv, "RDA lwp-pool diagnostics disabled.\n");
+    }
+  else if (strcmp (cmd, "all-noisy") == 0)
+    {
+      process->debug_backend = 1;
+      thread_db_noisy = 1;
+      debug_lwp_pool = 1;
+      gdbserv_output_string_as_bytes (serv, "All RDA diagnostics enabled.\n");
+    }
+  else if (strcmp (cmd, "all-quiet") == 0)
+    {
+      process->debug_backend = 0;
+      thread_db_noisy = 0;
+      debug_lwp_pool = 0;
+      gdbserv_output_string_as_bytes (serv, "All RDA diagnostics disabled.\n");
     }
   else
     gdbserv_output_string_as_bytes (serv,
       "Unrecognized monitor command.\n"
       "Available commands are:\n"
+      "  monitor all-noisy\n"
+      "  monitor all-quiet\n"
       "  monitor rda-backend-noisy\n"
       "  monitor rda-backend-quiet\n"
       "  monitor thread-db-noisy\n"
       "  monitor thread-db-quiet\n"
-      "  monitor proc-service-noisy\n"
-      "  monitor proc-service-quiet\n");
+      "  monitor lwp-pool-noisy\n"
+      "  monitor lwp-pool-quiet\n");
 }
 
 /* This function is called from gdbloop_poll when a new incoming
Index: lwp-pool.c
===================================================================
RCS file: /cvs/src/src/rda/unix/lwp-pool.c,v
retrieving revision 1.2
diff -u -p -r1.2 lwp-pool.c
--- lwp-pool.c 30 Jun 2005 03:24:18 -0000 1.2
+++ lwp-pool.c 8 Nov 2005 21:56:23 -0000
@@ -37,7 +37,9 @@
 #include "lwp-pool.h"
 #include "lwp-ctrl.h"
 
-static int debug_lwp_pool = 0;
+#include "diagnostics.h"
+
+int debug_lwp_pool = 0;
 
 
 /* THE LIFETIME OF A TRACED LWP
@@ -772,14 +774,20 @@ lwp_state_str (enum lwp_state state)
 
 
 static void
-debug_report_state_change (pid_t lwp,
+debug_report_state_change (struct gdbserv *serv,
+                           pid_t lwp,
    enum lwp_state old,
    enum lwp_state new)
 {
   if (debug_lwp_pool && old != new)
-    fprintf (stderr,
-     "%32s -- %5d -> %-32s\n",
-     lwp_state_str (old), (int) lwp, lwp_state_str (new));
+    {
+      fprintf (stderr,
+       "%32s -- %5d -> %s",
+       lwp_state_str (old), (int) lwp, lwp_state_str (new));
+      if (new == lwp_state_stopped)
+ fprintf (stderr, "    (at %#lx)", debug_get_pc (serv, lwp));
+      fprintf (stderr, "\n");
+    }
 }
 
 
@@ -793,7 +801,7 @@ debug_report_state_change (pid_t lwp,
 
    If waitpid returns an error, print a message to stderr.  */
 static int
-wait_and_handle (struct lwp *l, int flags)
+wait_and_handle (struct gdbserv *serv, struct lwp *l, int flags)
 {
   int status;
   pid_t new_pid;
@@ -910,7 +918,7 @@ wait_and_handle (struct lwp *l, int flag
  }
     }
 
-  debug_report_state_change (l->pid, old_state, l->state);
+  debug_report_state_change (serv, l->pid, old_state, l->state);
 
   return 1;
 }
@@ -936,11 +944,11 @@ wait_and_handle (struct lwp *l, int flag
    some INTERESTING state.  It's really just wait_and_handle, with
    some error checking wrapped around it.  */
 static int
-check_stop_pending (struct lwp *l)
+check_stop_pending (struct gdbserv *serv, struct lwp *l)
 {
   assert (l->state == lwp_state_running_stop_pending);
 
-  wait_and_handle (l, __WALL);
+  wait_and_handle (serv, l, __WALL);
 
   switch (l->state)
     {
@@ -971,7 +979,7 @@ check_stop_pending (struct lwp *l)
 
 
 pid_t
-lwp_pool_waitpid (pid_t pid, int *stat_loc, int options)
+lwp_pool_waitpid (struct gdbserv *serv, pid_t pid, int *stat_loc, int options)
 {
   struct lwp *l;
   enum lwp_state old_state;
@@ -992,7 +1000,7 @@ lwp_pool_waitpid (pid_t pid, int *stat_l
  the interesting queue.  */
       while (! queue_non_empty (&interesting_queue))
  {
-  int result = wait_and_handle (NULL, options | __WALL);
+  int result = wait_and_handle (serv, NULL, options | __WALL);
 
   if (result <= 0)
     return result;
@@ -1013,7 +1021,7 @@ lwp_pool_waitpid (pid_t pid, int *stat_l
       while (l->state == lwp_state_running
      || l->state == lwp_state_running_stop_pending)
  {
-  int result = wait_and_handle (l, options | __WALL);
+  int result = wait_and_handle (serv, l, options | __WALL);
 
   if (result <= 0)
     return result;
@@ -1050,7 +1058,7 @@ lwp_pool_waitpid (pid_t pid, int *stat_l
  is not interesting any more.  */
       l->state = lwp_state_stopped;
       queue_delete (l);
-      debug_report_state_change (l->pid, old_state, l->state);
+      debug_report_state_change (serv, l->pid, old_state, l->state);
       break;
 
     case lwp_state_dead_interesting:
@@ -1069,7 +1077,7 @@ lwp_pool_waitpid (pid_t pid, int *stat_l
  uninteresting, but it's still got a stop pending.  */
       queue_delete (l);
       l->state = lwp_state_stopped_stop_pending;
-      debug_report_state_change (l->pid, old_state, l->state);
+      debug_report_state_change (serv, l->pid, old_state, l->state);
       break;
 
     default:
@@ -1088,7 +1096,7 @@ lwp_pool_waitpid (pid_t pid, int *stat_l
 
 
 void
-lwp_pool_stop_all (void)
+lwp_pool_stop_all (struct gdbserv *serv)
 {
   int i;
 
@@ -1149,13 +1157,13 @@ lwp_pool_stop_all (void)
       break;
     }
 
-  debug_report_state_change (l->pid, old_state, l->state);
+  debug_report_state_change (serv, l->pid, old_state, l->state);
  }
     }
 
   /* Gather wait results until the stopping queue is empty.  */
   while (queue_non_empty (&stopping_queue))
-    if (wait_and_handle (NULL, __WALL) < 0)
+    if (wait_and_handle (serv, NULL, __WALL) < 0)
       {
  fprintf (stderr, "ERROR: lwp_pool_stop_all wait failed: %s",
  strerror (errno));
@@ -1199,7 +1207,7 @@ lwp_pool_stop_all (void)
 
 
 void
-lwp_pool_continue_all (void)
+lwp_pool_continue_all (struct gdbserv *serv)
 {
   int i;
 
@@ -1255,7 +1263,7 @@ lwp_pool_continue_all (void)
               if (continue_lwp (l->pid, 0) == 0)
                 {
                   l->state = lwp_state_running_stop_pending;
-                  if (check_stop_pending (l) == 0)
+                  if (check_stop_pending (serv, l) == 0)
                     {
                       if (continue_lwp (l->pid, 0) == 0)
                         l->state = lwp_state_running;
@@ -1270,14 +1278,14 @@ lwp_pool_continue_all (void)
       break;
     }
 
-  debug_report_state_change (l->pid, old_state, l->state);
+  debug_report_state_change (serv, l->pid, old_state, l->state);
  }
     }
 }
 
 
 int
-lwp_pool_continue_lwp (pid_t pid, int signal)
+lwp_pool_continue_lwp (struct gdbserv *serv, pid_t pid, int signal)
 {
   struct lwp *l = hash_find_known (pid);
   enum lwp_state old_state = l->state;
@@ -1324,7 +1332,7 @@ lwp_pool_continue_lwp (pid_t pid, int si
       if (continue_lwp (l->pid, signal) == 0)
         {
           l->state = lwp_state_running_stop_pending;
-          if (check_stop_pending (l) == 0)
+          if (check_stop_pending (serv, l) == 0)
             {
               if (continue_lwp (l->pid, 0) == 0)
                 l->state = lwp_state_running;
@@ -1339,7 +1347,7 @@ lwp_pool_continue_lwp (pid_t pid, int si
       break;
     }
 
-  debug_report_state_change (l->pid, old_state, l->state);
+  debug_report_state_change (serv, l->pid, old_state, l->state);
 
   return result;
 }
@@ -1393,7 +1401,7 @@ lwp_pool_singlestep_lwp (struct gdbserv
       if (continue_lwp (l->pid, signal) == 0)
         {
           l->state = lwp_state_running_stop_pending;
-          if (check_stop_pending (l) == 0)
+          if (check_stop_pending (serv, l) == 0)
             {
               if (singlestep_lwp (serv, l->pid, 0) == 0)
                 l->state = lwp_state_running;
@@ -1408,7 +1416,7 @@ lwp_pool_singlestep_lwp (struct gdbserv
       break;
     }
 
-  debug_report_state_change (l->pid, old_state, l->state);
+  debug_report_state_change (serv, l->pid, old_state, l->state);
 
   return result;
 }
@@ -1434,7 +1442,7 @@ lwp_pool_new_stopped (pid_t pid)
 
 
 int
-lwp_pool_attach (pid_t pid)
+lwp_pool_attach (struct gdbserv *serv, pid_t pid)
 {
   /* Are we already managing this LWP?  */
   struct lwp *l = hash_find (pid);
@@ -1464,7 +1472,7 @@ lwp_pool_attach (pid_t pid)
  fprintf (stderr, "lwp_pool: %s: new LWP %d state %s\n",
  __func__, l->pid, lwp_state_str (l->state));
 
-      check_stop_pending (l);
+      check_stop_pending (serv, l);
 
       return 1;
     }
Index: lwp-pool.h
===================================================================
RCS file: /cvs/src/src/rda/unix/lwp-pool.h,v
retrieving revision 1.2
diff -u -p -r1.2 lwp-pool.h
--- lwp-pool.h 30 Jun 2005 03:24:18 -0000 1.2
+++ lwp-pool.h 8 Nov 2005 21:56:23 -0000
@@ -70,7 +70,7 @@ void lwp_pool_new_stopped (pid_t pid);
    lwp_pool_waitpid will report it, but the wait status caused by the
    attach is handled internally, and will not be reported via
    lwp_pool_waitpid.  */
-int lwp_pool_attach (pid_t pid);
+int lwp_pool_attach (struct gdbserv *serv, pid_t pid);
 
 
 /* Do we need a function for detaching from each LWP in the pool
@@ -86,7 +86,7 @@ int lwp_pool_attach (pid_t pid);
 
    The only bit that may be set in OPTIONS is WNOHANG.  We need to
    monitor the status of all LWP's, so we add __WALL as appropriate.  */
-pid_t lwp_pool_waitpid (pid_t pid, int *stat_loc, int options);
+pid_t lwp_pool_waitpid (struct gdbserv *serv, pid_t pid, int *stat_loc, int options);
 
 
 /* Stop all running LWP's in the pool.  This function does not return
@@ -94,26 +94,23 @@ pid_t lwp_pool_waitpid (pid_t pid, int *
 
    The wait status caused by the stop is handled internally, and will
    not be reported by lwp_pool_waitpid.  */
-void lwp_pool_stop_all (void);
+void lwp_pool_stop_all (struct gdbserv *serv);
 
 
 /* Continue all stopped, uninteresting LWP's in the pool.
    If some of the LWP's have been resumed with lwp_pool_singlestep or
    lwp_pool_continue, those will be left to continue to run.  */
-void lwp_pool_continue_all (void);
+void lwp_pool_continue_all (struct gdbserv *serv);
 
 
 /* Continue PID.  If SIGNAL is non-zero, continue it with signal
    SIGNAL.  Return zero on success, -1 on failure.  */
-int lwp_pool_continue_lwp (pid_t pid, int signal);
+int lwp_pool_continue_lwp (struct gdbserv *serv, pid_t pid, int signal);
 
 
 /* Continue PID in SERV for one instruction, delivering SIGNAL if it
    is non-zero, and stop with SIGSTOP if/when that instruction has
-   been completed.
-
-   The SERV argument is there because singlestep_lwp requires it.
-   Inconsistency, bleah.  */
+   been completed.  */
 int lwp_pool_singlestep_lwp (struct gdbserv *serv, pid_t pid, int signal);
 
 
Index: thread-db.c
===================================================================
RCS file: /cvs/src/src/rda/unix/thread-db.c,v
retrieving revision 1.15
diff -u -p -r1.15 thread-db.c
--- thread-db.c 4 Nov 2005 21:16:29 -0000 1.15
+++ thread-db.c 8 Nov 2005 21:56:23 -0000
@@ -43,10 +43,10 @@
 #include "gdbserv-thread-db.h"
 #include "lwp-ctrl.h"
 #include "lwp-pool.h"
+#include "diagnostics.h"
 
 /* Make lots of noise (debugging output). */
 int thread_db_noisy = 0;
-int proc_service_noisy = 0;
 
 #define ALWAYS_UPDATE_THREAD_LIST 0
 
@@ -1378,7 +1378,7 @@ thread_db_detach (struct gdbserv *serv,
 }
 
 static void
-attach_thread (struct gdbserv_thread *thread)
+attach_thread (struct gdbserv *serv, struct gdbserv_thread *thread)
 {
   if (thread->ti.ti_lid != 0)
     {
@@ -1392,7 +1392,7 @@ attach_thread (struct gdbserv_thread *th
  even when the LWP has exited --- in that case, it returns
  ps_getpid (&proc_handle).  The LWP pool code tolerates
  multiple requests to attach to the same PID.  */
-      int status = lwp_pool_attach (thread->ti.ti_lid);
+      int status = lwp_pool_attach (serv, thread->ti.ti_lid);
 
       /* If we're using signals to communicate with the thread
  library, send the newly attached thread the restart
@@ -1413,6 +1413,7 @@ static int
 find_new_threads_callback (const td_thrhandle_t *thandle, void *data)
 {
   struct gdbserv_thread *thread;
+  struct gdbserv *serv = data;
   td_thrinfo_t ti;
   td_err_e     ret;
 
@@ -1434,7 +1435,7 @@ find_new_threads_callback (const td_thrh
   if (thread_db_noisy)
     fprintf (stderr, "(new thread %s)\n", thread_debug_name (thread));
 
-  attach_thread (thread);
+  attach_thread (serv, thread);
 
   if (using_thread_db_events)
     {
@@ -1465,11 +1466,15 @@ static void
 update_thread_list (struct child_process *process)
 {
   struct gdbserv_thread *thread, *next;
+  struct gdbserv *serv = process->serv;
   td_thrhandle_t handle;
 
+  if (thread_db_noisy)
+    fprintf (stderr, "thread-db.c: update_thread_list\n");
+
   /* First make sure all libthread threads are in the list. */
   td_ta_thr_iter_p (thread_agent, find_new_threads_callback,
-    (void *) 0,
+    serv,
     TD_THR_ANY_STATE,
     TD_THR_LOWEST_PRIORITY,
     TD_SIGNO_MASK,
@@ -1840,7 +1845,7 @@ handle_thread_db_event (struct child_pro
   if (thread_db_noisy)
     fprintf (stderr, "(waiting after event bp step %s)\n",
      thread_debug_name (thread));
-  if (lwp_pool_waitpid (lwp, (int *) &w, 0) < 0)
+  if (lwp_pool_waitpid (serv, lwp, (int *) &w, 0) < 0)
     {
       fprintf (stderr, "error waiting for thread %d after "
        "stepping over event breakpoint:\n%s",
@@ -1869,12 +1874,13 @@ handle_thread_db_event (struct child_pro
    Send continue to a struct gdbserv_thread. */
 
 static void
-continue_thread (struct gdbserv_thread *thread, int signal)
+continue_thread (struct gdbserv *serv, struct gdbserv_thread *thread,
+                 int signal)
 {
   thread_db_flush_regset_caches();
 
   if (thread->ti.ti_lid != 0)
-    lwp_pool_continue_lwp (thread->ti.ti_lid, signal);
+    lwp_pool_continue_lwp (serv, thread->ti.ti_lid, signal);
 
   thread_db_invalidate_caches ();
 }
@@ -1892,15 +1898,15 @@ thread_db_continue_program (struct gdbse
 
   /* First resume the event thread. */
   if (process->event_thread)
-      continue_thread (process->event_thread, process->signal_to_send);
+      continue_thread (serv, process->event_thread, process->signal_to_send);
   else
-    lwp_pool_continue_lwp (process->pid, process->signal_to_send);
+    lwp_pool_continue_lwp (serv, process->pid, process->signal_to_send);
 
   process->stop_signal = process->stop_status =
     process->signal_to_send = 0;
 
   /* Then resume everyone else. */
-  lwp_pool_continue_all ();
+  lwp_pool_continue_all (serv);
   process->running = 1;
   thread_db_invalidate_caches ();
 
@@ -1932,15 +1938,27 @@ thread_db_singlestep_program (struct gdb
 
   /* First singlestep the event thread. */
   if (process->event_thread)
-    singlestep_thread (serv, process->event_thread, process->signal_to_send);
+    {
+      if (thread_db_noisy)
+ fprintf (stderr, "thread_db_singlestep_program: Single stepping event thread %d starting from %#lx\n",
+         process->event_thread->ti.ti_lid,
+ debug_get_pc (serv, process->event_thread->ti.ti_lid));
+      singlestep_thread (serv, process->event_thread, process->signal_to_send);
+    }
   else
-    lwp_pool_singlestep_lwp (serv, process->pid, process->signal_to_send);
+    {
+      if (thread_db_noisy)
+ fprintf (stderr, "thread_db_singlestep_program: Single stepping %d starting from %#lx\n",
+         process->pid,
+ debug_get_pc (serv, process->pid));
+      lwp_pool_singlestep_lwp (serv, process->pid, process->signal_to_send);
+    }
 
   process->stop_status = process->stop_signal =
     process->signal_to_send = 0;
 
   /* Then resume everyone else. */
-  lwp_pool_continue_all ();
+  lwp_pool_continue_all (serv);
   process->running = 1;
   thread_db_invalidate_caches ();
 
@@ -1974,7 +1992,7 @@ thread_db_continue_thread (struct gdbser
   else
     {
       process->pid = thread->ti.ti_lid; /* thread to be continued */
-      continue_thread (thread, process->signal_to_send);
+      continue_thread (serv, thread, process->signal_to_send);
       process->stop_status = process->stop_signal =
  process->signal_to_send = 0;
       process->running = 1;
@@ -2091,10 +2109,10 @@ thread_db_check_child_state (struct chil
  status results only from that thread, even though there may
  be others collected from before.  */
       if (process->focus_thread)
- eventpid = lwp_pool_waitpid (process->focus_thread->ti.ti_lid,
+ eventpid = lwp_pool_waitpid (serv, process->focus_thread->ti.ti_lid,
      (int *) &w, WNOHANG);
       else
- eventpid = lwp_pool_waitpid (-1, (int *) &w, WNOHANG);
+ eventpid = lwp_pool_waitpid (serv, -1, (int *) &w, WNOHANG);
 
       if (eventpid > 0) /* found an event */
  {
@@ -2118,7 +2136,7 @@ thread_db_check_child_state (struct chil
     }
 
   /* Stop all the threads we know about.  */
-  lwp_pool_stop_all ();
+  lwp_pool_stop_all (serv);
 
   if (thread_db_noisy)
     fprintf (stderr,
@@ -2185,6 +2203,8 @@ thread_db_check_child_state (struct chil
 #endif
 
  }
+
+      /* Continue the program.  */
       process->signal_to_send = process->stop_signal;
       currentvec->continue_program (serv);
       return 0;
@@ -2195,7 +2215,7 @@ thread_db_check_child_state (struct chil
   /* Pass this event back to GDB. */
   if (process->debug_backend)
     fprintf (stderr, "wait returned '%c' (%d) for %d.\n",
-     process->stop_status, process->stop_signal, eventpid);
+     process->stop_status, process->stop_signal, process->pid);
   return 1;
  }
     }