From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id v02bJR/AYWL0vAEAWB0awg (envelope-from ) for ; Thu, 21 Apr 2022 16:35:43 -0400 Received: by simark.ca (Postfix, from userid 112) id 835261E058; Thu, 21 Apr 2022 16:35:43 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=L3r6Rviz; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AE3891E00D for ; Thu, 21 Apr 2022 16:35:42 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3234F3857343 for ; Thu, 21 Apr 2022 20:35:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3234F3857343 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1650573342; bh=21Y5IDt9gr3KZnRu543pv5g5tuFNzB492L1WYeDv5XE=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=L3r6Rviz2FrF8uEElECy/+/3zlVlMwiDNJ+iIsMJSFXEOQw0cQ5UUgNwRGbF5m/70 uCKUROIWhnq71ikvwlOxFNzyQDTH5dJ2tuZTZYXQfI9utmzB1A0Nk3hd6dsvK0KSzl VFEJ3Vt+576uP8vy61bBRRKqwGujsCgPxQ/Zxj5g= Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id 774A7385842B for ; Thu, 21 Apr 2022 20:35:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 774A7385842B Received: from ubuntu.lan (unknown [IPv6:2a02:390:9086::635]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id B8BD281D8F; Thu, 21 Apr 2022 20:35:19 +0000 (UTC) Date: Thu, 21 Apr 2022 20:35:11 +0000 To: Andrew Burgess Subject: Re: [PATCHv4 1/2] gdb: add some additional thread status debug output Message-ID: <20220421203458.cupeseh6bkpfbmpq@ubuntu.lan> References: <20220113183406.3577620-1-aburgess@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Thu, 21 Apr 2022 20:35:19 +0000 (UTC) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi I just have some minor remarks on this patch. See below. On Thu, Apr 21, 2022 at 05:45:55PM +0100, Andrew Burgess via Gdb-patches wrote: > While working on this patch: > > https://sourceware.org/pipermail/gdb-patches/2022-January/185109.html > > I found it really useful to print the executing/resumed status of all > threads (or all threads in a particular inferior) at various > places (e.g. when a new inferior is started, when GDB attaches, etc). > > This debug was original part of the above patch, but I wanted to original -> originally ? > rewrite this as a separate patch and move the code into a new function > in infrun.h, which is what this patch does. > > Unless 'set debug infrun on' is in effect, then there should be no > user visible changes after this commit. > --- > gdb/infcmd.c | 19 ++++++++----------- > gdb/infrun.c | 3 +++ > gdb/infrun.h | 26 ++++++++++++++++++++++++++ > 3 files changed, 37 insertions(+), 11 deletions(-) > > diff --git a/gdb/infcmd.c b/gdb/infcmd.c > index 84eb6e5d79b..1beade2acec 100644 > --- a/gdb/infcmd.c > +++ b/gdb/infcmd.c > @@ -238,6 +238,9 @@ post_create_inferior (int from_tty) > /* Be sure we own the terminal in case write operations are performed. */ > target_terminal::ours_for_output (); > > + infrun_debug_show_threads ("threads in the newly created inferior", > + current_inferior ()->non_exited_threads ()); > + > /* If the target hasn't taken care of this already, do it now. > Targets which need to access registers during to_open, > to_create_inferior, or to_attach should do it earlier; but many > @@ -454,6 +457,9 @@ run_command_1 (const char *args, int from_tty, enum run_how run_how) > shouldn't refer to run_target again. */ > run_target = NULL; > > + infrun_debug_show_threads ("immediately after create_process", > + current_inferior ()->non_exited_threads ()); > + > /* We're starting off a new process. When we get out of here, in > non-stop mode, finish the state of all threads of that process, > but leave other threads alone, as they may be stopped in internal > @@ -2589,17 +2595,8 @@ attach_command (const char *args, int from_tty) > shouldn't refer to attach_target again. */ > attach_target = NULL; > > - if (debug_infrun) > - { > - infrun_debug_printf ("immediately after attach:"); > - for (thread_info *thread : inferior->non_exited_threads ()) > - infrun_debug_printf (" thread %s, executing = %d, resumed = %d, " > - "state = %s", > - thread->ptid.to_string ().c_str (), > - thread->executing (), > - thread->resumed (), > - thread_state_string (thread->state)); > - } > + infrun_debug_show_threads ("immediately after attach", > + current_inferior ()->non_exited_threads ()); > > /* Enable async mode if it is supported by the target. */ > if (target_can_async_p ()) > diff --git a/gdb/infrun.c b/gdb/infrun.c > index c311240b78c..a814f5cbc2b 100644 > --- a/gdb/infrun.c > +++ b/gdb/infrun.c > @@ -5043,6 +5043,9 @@ stop_all_threads (const char *reason, inferior *inf) > INFRUN_SCOPED_DEBUG_START_END ("reason=%s, inf=%d", reason, > inf != nullptr ? inf->num : -1); > > + infrun_debug_show_threads ("non-exited threads", > + all_non_exited_threads ()); > + > scoped_restore_current_thread restore_thread; > > /* Enable thread events on relevant targets. */ > diff --git a/gdb/infrun.h b/gdb/infrun.h > index 9685f3a9775..1421fa4050a 100644 > --- a/gdb/infrun.h > +++ b/gdb/infrun.h > @@ -48,6 +48,32 @@ extern bool debug_infrun; > #define INFRUN_SCOPED_DEBUG_ENTER_EXIT \ > scoped_debug_enter_exit (debug_infrun, "infrun") > > +/* A infrun debug helper routine to print out all the threads in the set > + THREADS (which should be a range type that returns thread_info* > + objects). > + > + The TITLE is a string that is printed before the list of threads. > + > + Output is only produced when 'set debug infrun on'. */ > + > +template > +static inline void > +infrun_debug_show_threads (const char *title, ThreadRange threads) > +{ > + if (debug_infrun) > + { > + infrun_debug_printf ("%s:", (title)); I do not think the extra parens around title are necessary. Best, Lancelot > + for (thread_info *thread : threads) > + infrun_debug_printf (" thread %s, executing = %d, resumed = %d, " > + "state = %s", > + thread->ptid.to_string ().c_str (), > + thread->executing (), > + thread->resumed (), > + thread_state_string (thread->state)); > + } > +} > + > + > /* Nonzero if we want to give control to the user when we're notified > of shared library events by the dynamic linker. */ > extern int stop_on_solib_events; > -- > 2.25.4 >