From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mBbnGTvrYmJh6wEAWB0awg (envelope-from ) for ; Fri, 22 Apr 2022 13:51:55 -0400 Received: by simark.ca (Postfix, from userid 112) id 64CAD1E058; Fri, 22 Apr 2022 13:51:55 -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=du6vXXNN; 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 B3B411E00E for ; Fri, 22 Apr 2022 13:51:54 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 441D73857374 for ; Fri, 22 Apr 2022 17:51:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 441D73857374 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1650649914; bh=TDO4/xEPKYWquNUiesSETKU9nqZ/KKrixV0Si9JbWXM=; 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=du6vXXNNTsDD0qK0qXU7PF/qRva9ZlmIN2N8Lw69+KK29YFb3pRinBiVbf0tjDScj K8lccIrDbap5VqbsR/RlR+vJlKb/oIDhbeANpJ9EMPd2d54JI/26pe09wwS7h3XVf8 +ai+ZYoYQKx+QmHUW9AavCciJlUtnHc1E9mBUZD4= 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 7C8733858C2C for ; Fri, 22 Apr 2022 17:50:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7C8733858C2C Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-126-z8XIeP9HOByLfZEUHhZlhQ-1; Fri, 22 Apr 2022 13:50:44 -0400 X-MC-Unique: z8XIeP9HOByLfZEUHhZlhQ-1 Received: by mail-wr1-f71.google.com with SMTP id x4-20020adfbb44000000b0020ac8fd27b6so806280wrg.10 for ; Fri, 22 Apr 2022 10:50:43 -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=TDO4/xEPKYWquNUiesSETKU9nqZ/KKrixV0Si9JbWXM=; b=vuND4O0LeGo8QuDu4rkcV+vmOhHWGvwWtr1cvptA/l6kGLYkHcsvpSLg51QAdd4Td1 Y6d+9g2/OUOpLH2m6bChGVwBwmSf+j3uP5PLejnrVfXC8Ao0ZA5X57a5FDEe2du7BHAO EYdrYeW9dJTpPmQax6g5q1eFHUahhUWlKyddCMoeFFEgaUQU5LkbgH/qBrVjxD2UGnzK 0USIV2wHCMjM5Yaieah7ShzxC/5hhctd39rta1ZTlxp7HLquhAmoHMirbYmSiCmPFXV4 y9QCJTCaLjAa7TxEy1XJ/C1UJlVI6LKby6kHTTmQx41YW5/blnlS4d9N9IQsYmnPFHOH nBNw== X-Gm-Message-State: AOAM530tVBNUSK/37ShJw67QG+ix1JdbwB8yDo5uc7/Duk0l/pfFb2BU x+N8wYqU2DpBxyvmEPR/L79E68hkHhxwGxtdoUEi2xBF+32TseThCt62XNJkViIxpL9AmLEKfQE /aVkzbwMGizMQXvHoQ09gWw== X-Received: by 2002:a05:600c:4ec6:b0:392:8b89:fce9 with SMTP id g6-20020a05600c4ec600b003928b89fce9mr5201050wmq.25.1650649842585; Fri, 22 Apr 2022 10:50:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrP2wcR8jybm00qUJhRzAWgMe1frJZ816IG6/2fGsMCVDzSVzPMdMROPOVf/ZMdlIn0mE+6w== X-Received: by 2002:a05:600c:4ec6:b0:392:8b89:fce9 with SMTP id g6-20020a05600c4ec600b003928b89fce9mr5201039wmq.25.1650649842306; Fri, 22 Apr 2022 10:50:42 -0700 (PDT) Received: from localhost (host81-136-113-48.range81-136.btcentralplus.com. [81.136.113.48]) by smtp.gmail.com with ESMTPSA id d18-20020a05600c34d200b0038ed14b7ac3sm2084030wmq.40.2022.04.22.10.50.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 10:50:41 -0700 (PDT) To: Lancelot SIX Subject: Re: [PATCHv4 1/2] gdb: add some additional thread status debug output In-Reply-To: <20220421203458.cupeseh6bkpfbmpq@ubuntu.lan> References: <20220113183406.3577620-1-aburgess@redhat.com> <20220421203458.cupeseh6bkpfbmpq@ubuntu.lan> Date: Fri, 22 Apr 2022 18:50:40 +0100 Message-ID: <877d7hqa6n.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" 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. Andrew > > 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 >>