From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 46WPAh44cWKGCQQAWB0awg (envelope-from ) for ; Tue, 03 May 2022 10:11:42 -0400 Received: by simark.ca (Postfix, from userid 112) id F21421E087; Tue, 3 May 2022 10:11:41 -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=cYF8+qDE; 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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.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 54FBE1E058 for ; Tue, 3 May 2022 10:11:41 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BE4238346B7 for ; Tue, 3 May 2022 14:11:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BE4238346B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1651587100; bh=RLG6MwxxdDRHf7AwOeJXi025Ql9awDtx9LVRIi3q+Dw=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=cYF8+qDEqFXznxQt9C3MbhzgGj9NBLFKm1wqtAebOhlF+3H1dDOEsMv5JSriSSefY 7wCUjd1RCWRt9eSmtKGquCT+NWLi4JNPZJDD3E3391+Bm8nR4P2rt5C3HOzOKbtYMA vkdUcKN0Nx2YcDSG+LJ90C4odH22bCFmrGgXn1dw= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 709013856DC6 for ; Tue, 3 May 2022 14:11:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 709013856DC6 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556-ZZVO_RKtONWT74uFnm2_gQ-1; Tue, 03 May 2022 10:06:09 -0400 X-MC-Unique: ZZVO_RKtONWT74uFnm2_gQ-1 Received: by mail-wm1-f72.google.com with SMTP id v191-20020a1cacc8000000b0038ce818d2efso5946802wme.1 for ; Tue, 03 May 2022 07:06:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=RLG6MwxxdDRHf7AwOeJXi025Ql9awDtx9LVRIi3q+Dw=; b=2zIaq/D4IlIk/jKWnO4kQOj5F3q19JDLinayMmMhqLI+QDc99TZtBsCSA0/Armiyvr z+t36JiWMziACegdJ0Az8irXKqaG8qmVaZhrSMyrbrk+v3de4ROIrjjb+3bHdgSP+YAy h7elIGBmU037HmvbI4kx/AGOQDrlhDoXMlVlkL8ObaOq6u6qAhHpg44ri8CrJXXInT2N V4kgrsch0N8KBc//pm9BZU/5ldvY7wrr8M9vAete59x+zCK7m/9TeLuKGQjqqDiTvUVo hrL7R1hVlniQYuPjReOe04OsjnQKkpJ6Ohhh4rw3oPay7o9ylK44r5iiQiqHNwMWxOhs glHg== X-Gm-Message-State: AOAM533ZcpP76noh0E/2D6fpTc5q5jjzY0a9t2FChr3dZRtHPi8hJf+5 xvlD9osJln84go79PEZTl8ITzrRE8tbB+v9g3ZvHzakpaRMdrQfY5hxJlMuQQxB0q9V+AUkL31S +iBjPXuH1KINHBsAzZwdzAw== X-Received: by 2002:a05:6000:188d:b0:20c:71e5:86d7 with SMTP id a13-20020a056000188d00b0020c71e586d7mr3663520wri.185.1651586698285; Tue, 03 May 2022 07:04:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGDgC0mHMyJklaguBZ6zUSTZIRYZ6UQ89h7UfCfbDs8pvm9ZX5GEw+9Lt88A9nYxU9ew8hIg== X-Received: by 2002:a05:6000:188d:b0:20c:71e5:86d7 with SMTP id a13-20020a056000188d00b0020c71e586d7mr3663503wri.185.1651586697977; Tue, 03 May 2022 07:04:57 -0700 (PDT) Received: from localhost (host81-136-113-48.range81-136.btcentralplus.com. [81.136.113.48]) by smtp.gmail.com with ESMTPSA id n124-20020a1c2782000000b0039447beb28asm2177209wmn.23.2022.05.03.07.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 07:04:57 -0700 (PDT) To: Lancelot SIX Subject: Re: [PATCHv4 1/2] gdb: add some additional thread status debug output In-Reply-To: <877d7hqa6n.fsf@redhat.com> References: <20220113183406.3577620-1-aburgess@redhat.com> <20220421203458.cupeseh6bkpfbmpq@ubuntu.lan> <877d7hqa6n.fsf@redhat.com> Date: Tue, 03 May 2022 15:04:56 +0100 Message-ID: <87r15an247.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Andrew Burgess writes: > Lancelot SIX via Gdb-patches writes: > >> 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. > > Thanks, I made these fixes locally. I've gone ahead and pushed just this patch for now. Thanks, Andrew