From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6115 invoked by alias); 8 Nov 2005 22:15:57 -0000 Mailing-List: contact rda-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: rda-owner@sourceware.org Received: (qmail 6039 invoked by uid 22791); 8 Nov 2005 22:15:48 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 08 Nov 2005 22:15:48 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id jA8MFkw5020974 for ; Tue, 8 Nov 2005 17:15:46 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id jA8MFaV13769 for ; Tue, 8 Nov 2005 17:15:36 -0500 Received: from localhost.localdomain (vpn50-70.rdu.redhat.com [172.16.50.70]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id jA8MFZU4016972 for ; Tue, 8 Nov 2005 17:15:36 -0500 Received: from ironwood.lan (ironwood.lan [192.168.64.8]) by localhost.localdomain (8.12.11/8.12.10) with ESMTP id jA8MFUqZ008959 for ; Tue, 8 Nov 2005 15:15:30 -0700 Date: Tue, 08 Nov 2005 22:15:00 -0000 From: Kevin Buettner To: rda@sources.redhat.com Subject: [commit] Add diagnostic messages to thread-db.c and lwp-pool.c Message-ID: <20051108151530.4e8dd0b4@ironwood.lan> Organization: Red Hat X-Mailer: Sylpheed-Claws 0.9.12cvs173.1 (GTK+ 2.4.14; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2005-q4/txt/msg00002.txt.bz2 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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. +=20=20=20 + 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 =20 - -/* 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); =20 Index: linux-target.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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" =20 #ifdef STOCK_BREAKPOINTS #include "stock-breakpoints.h" @@ -3109,26 +3110,42 @@ linux_process_rcmd (struct gdbserv *serv thread_db_noisy =3D 0; gdbserv_output_string_as_bytes (serv, "RDA thread-db diagnostics dis= abled.\n"); } - else if (strcmp (cmd, "proc-service-noisy") =3D=3D 0) + else if (strcmp (cmd, "lwp-pool-noisy") =3D=3D 0) { - proc_service_noisy =3D 1; - gdbserv_output_string_as_bytes (serv, "RDA proc-service diagnostics = enabled.\n"); + debug_lwp_pool =3D 1; + gdbserv_output_string_as_bytes (serv, "RDA lwp-pool diagnostics enab= led.\n"); } - else if (strcmp (cmd, "proc-service-quiet") =3D=3D 0) + else if (strcmp (cmd, "lwp-pool-quiet") =3D=3D 0) { - proc_service_noisy =3D 0; - gdbserv_output_string_as_bytes (serv, "RDA proc-service diagnostics = disabled.\n"); + debug_lwp_pool =3D 0; + gdbserv_output_string_as_bytes (serv, "RDA lwp-pool diagnostics disa= bled.\n"); + } + else if (strcmp (cmd, "all-noisy") =3D=3D 0) + { + process->debug_backend =3D 1; + thread_db_noisy =3D 1; + debug_lwp_pool =3D 1; + gdbserv_output_string_as_bytes (serv, "All RDA diagnostics enabled.\= n"); + } + else if (strcmp (cmd, "all-quiet") =3D=3D 0) + { + process->debug_backend =3D 0; + thread_db_noisy =3D 0; + debug_lwp_pool =3D 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"); } =20 /* This function is called from gdbloop_poll when a new incoming Index: lwp-pool.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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" =20 -static int debug_lwp_pool =3D 0; +#include "diagnostics.h" + +int debug_lwp_pool =3D 0; =20 =0C /* THE LIFETIME OF A TRACED LWP @@ -772,14 +774,20 @@ lwp_state_str (enum lwp_state state) =20 =20 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 !=3D 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 =3D=3D lwp_state_stopped) + fprintf (stderr, " (at %#lx)", debug_get_pc (serv, lwp)); + fprintf (stderr, "\n"); + } } =20 =20 @@ -793,7 +801,7 @@ debug_report_state_change (pid_t lwp, =20 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;=20 @@ -910,7 +918,7 @@ wait_and_handle (struct lwp *l, int flag } } =20 - debug_report_state_change (l->pid, old_state, l->state); + debug_report_state_change (serv, l->pid, old_state, l->state); =20 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 =3D=3D lwp_state_running_stop_pending); =20 - wait_and_handle (l, __WALL); + wait_and_handle (serv, l, __WALL); =20 switch (l->state) { @@ -971,7 +979,7 @@ check_stop_pending (struct lwp *l) =20 =20 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 opti= ons) { 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 =3D wait_and_handle (NULL, options | __WALL); + int result =3D wait_and_handle (serv, NULL, options | __WALL); =20 if (result <=3D 0) return result; @@ -1013,7 +1021,7 @@ lwp_pool_waitpid (pid_t pid, int *stat_l while (l->state =3D=3D lwp_state_running || l->state =3D=3D lwp_state_running_stop_pending) { - int result =3D wait_and_handle (l, options | __WALL); + int result =3D wait_and_handle (serv, l, options | __WALL); =20 if (result <=3D 0) return result; @@ -1050,7 +1058,7 @@ lwp_pool_waitpid (pid_t pid, int *stat_l is not interesting any more. */ l->state =3D 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; =20 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 =3D 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; =20 default: @@ -1088,7 +1096,7 @@ lwp_pool_waitpid (pid_t pid, int *stat_l =20 =20 void -lwp_pool_stop_all (void) +lwp_pool_stop_all (struct gdbserv *serv) { int i; =20 @@ -1149,13 +1157,13 @@ lwp_pool_stop_all (void) break; } =20 - debug_report_state_change (l->pid, old_state, l->state); + debug_report_state_change (serv, l->pid, old_state, l->state); } } =20 /* 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) =20 =20 void -lwp_pool_continue_all (void) +lwp_pool_continue_all (struct gdbserv *serv) { int i; =20 @@ -1255,7 +1263,7 @@ lwp_pool_continue_all (void) if (continue_lwp (l->pid, 0) =3D=3D 0) { l->state =3D lwp_state_running_stop_pending; - if (check_stop_pending (l) =3D=3D 0) + if (check_stop_pending (serv, l) =3D=3D 0) { if (continue_lwp (l->pid, 0) =3D=3D 0) l->state =3D lwp_state_running; @@ -1270,14 +1278,14 @@ lwp_pool_continue_all (void) break; } =20 - debug_report_state_change (l->pid, old_state, l->state); + debug_report_state_change (serv, l->pid, old_state, l->state); } } } =20 =20 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 =3D hash_find_known (pid); enum lwp_state old_state =3D l->state; @@ -1324,7 +1332,7 @@ lwp_pool_continue_lwp (pid_t pid, int si if (continue_lwp (l->pid, signal) =3D=3D 0) { l->state =3D lwp_state_running_stop_pending; - if (check_stop_pending (l) =3D=3D 0) + if (check_stop_pending (serv, l) =3D=3D 0) { if (continue_lwp (l->pid, 0) =3D=3D 0) l->state =3D lwp_state_running; @@ -1339,7 +1347,7 @@ lwp_pool_continue_lwp (pid_t pid, int si break; } =20 - debug_report_state_change (l->pid, old_state, l->state); + debug_report_state_change (serv, l->pid, old_state, l->state); =20 return result; } @@ -1393,7 +1401,7 @@ lwp_pool_singlestep_lwp (struct gdbserv=20 if (continue_lwp (l->pid, signal) =3D=3D 0) { l->state =3D lwp_state_running_stop_pending; - if (check_stop_pending (l) =3D=3D 0) + if (check_stop_pending (serv, l) =3D=3D 0) { if (singlestep_lwp (serv, l->pid, 0) =3D=3D 0) l->state =3D lwp_state_running; @@ -1408,7 +1416,7 @@ lwp_pool_singlestep_lwp (struct gdbserv=20 break; } =20 - debug_report_state_change (l->pid, old_state, l->state); + debug_report_state_change (serv, l->pid, old_state, l->state); =20 return result; } @@ -1434,7 +1442,7 @@ lwp_pool_new_stopped (pid_t pid) =20 =20 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 =3D 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)); =20 - check_stop_pending (l); + check_stop_pending (serv, l); =20 return 1; } Index: lwp-pool.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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); =20 =20 /* Do we need a function for detaching from each LWP in the pool @@ -86,7 +86,7 @@ int lwp_pool_attach (pid_t pid); =20 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, in= t options); =20 =20 /* 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 * =20 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); =20 =20 /* 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); =20 =20 /* 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); =20 =20 /* 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); =20 =20 Index: thread-db.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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" =20 /* Make lots of noise (debugging output). */ int thread_db_noisy =3D 0; -int proc_service_noisy =3D 0; =20 #define ALWAYS_UPDATE_THREAD_LIST 0 =20 @@ -1378,7 +1378,7 @@ thread_db_detach (struct gdbserv *serv,=20 } =20 static void -attach_thread (struct gdbserv_thread *thread) +attach_thread (struct gdbserv *serv, struct gdbserv_thread *thread) { if (thread->ti.ti_lid !=3D 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 =3D lwp_pool_attach (thread->ti.ti_lid); + int status =3D lwp_pool_attach (serv, thread->ti.ti_lid); =20 /* 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 =3D data; td_thrinfo_t ti; td_err_e ret; =20 @@ -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)); =20 - attach_thread (thread); + attach_thread (serv, thread); =20 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 =3D process->serv; td_thrhandle_t handle; =20 + 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,=20 - (void *) 0,=20 + serv,=20 TD_THR_ANY_STATE,=20 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. */ =20 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(); =20 if (thread->ti.ti_lid !=3D 0) - lwp_pool_continue_lwp (thread->ti.ti_lid, signal); + lwp_pool_continue_lwp (serv, thread->ti.ti_lid, signal); =20 thread_db_invalidate_caches (); } @@ -1892,15 +1898,15 @@ thread_db_continue_program (struct gdbse =20 /* 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_sen= d); else - lwp_pool_continue_lwp (process->pid, process->signal_to_send); + lwp_pool_continue_lwp (serv, process->pid, process->signal_to_send); =20 process->stop_signal =3D process->stop_status =3D=20 process->signal_to_send =3D 0; =20 /* Then resume everyone else. */ - lwp_pool_continue_all (); + lwp_pool_continue_all (serv); process->running =3D 1; thread_db_invalidate_caches (); =20 @@ -1932,15 +1938,27 @@ thread_db_singlestep_program (struct gdb =20 /* First singlestep the event thread. */ if (process->event_thread) - singlestep_thread (serv, process->event_thread, process->signal_to_sen= d); + { + if (thread_db_noisy) + fprintf (stderr, "thread_db_singlestep_program: Single stepping event thr= ead %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_s= end); + } 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 starti= ng from %#lx\n", + process->pid, + debug_get_pc (serv, process->pid)); + lwp_pool_singlestep_lwp (serv, process->pid, process->signal_to_send= ); + } =20 process->stop_status =3D process->stop_signal =3D process->signal_to_send =3D 0; =20 /* Then resume everyone else. */ - lwp_pool_continue_all (); + lwp_pool_continue_all (serv); process->running =3D 1; thread_db_invalidate_caches (); =20 @@ -1974,7 +1992,7 @@ thread_db_continue_thread (struct gdbser else { process->pid =3D 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 =3D process->stop_signal =3D process->signal_to_send =3D 0; process->running =3D 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 =3D lwp_pool_waitpid (process->focus_thread->ti.ti_lid, + eventpid =3D lwp_pool_waitpid (serv, process->focus_thread->ti.ti_lid, (int *) &w, WNOHANG); else - eventpid =3D lwp_pool_waitpid (-1, (int *) &w, WNOHANG); + eventpid =3D lwp_pool_waitpid (serv, -1, (int *) &w, WNOHANG); =20 if (eventpid > 0) /* found an event */ { @@ -2118,7 +2136,7 @@ thread_db_check_child_state (struct chil } =20 /* Stop all the threads we know about. */ - lwp_pool_stop_all (); + lwp_pool_stop_all (serv); =20 if (thread_db_noisy) fprintf (stderr, @@ -2185,6 +2203,8 @@ thread_db_check_child_state (struct chil #endif =20 } + + /* Continue the program. */ process->signal_to_send =3D 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",=20 - process->stop_status, process->stop_signal, eventpid); + process->stop_status, process->stop_signal, process->pid); return 1; } }