From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id mBIQNnqKYWI4agEAWB0awg (envelope-from ) for ; Thu, 21 Apr 2022 12:46:50 -0400 Received: by simark.ca (Postfix, from userid 112) id DA1991E15F; Thu, 21 Apr 2022 12:46:50 -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=r+nti2Kc; 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 50F391E01D for ; Thu, 21 Apr 2022 12:46:50 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F12343839406 for ; Thu, 21 Apr 2022 16:46:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F12343839406 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1650559610; bh=L/ENul07fmO7ip4tfa1RXJ6A3hixEGPkGN8udMya/vc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=r+nti2KcnEDydv8hMHRgAEUDA02ieaRQrVhwCGq4k/OHjNGI8reSx+U0AtZQ7fOP7 2++Jd9FW38hMHMvP6qAvgPKKV0NOyjWtagye4NaKOtlIn8zLNPUVXerC+QPZBAy+67 +mUO+1fMXze5diMB7CR6KCguJTanlfK4DHLxUQj0= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CAC883858430 for ; Thu, 21 Apr 2022 16:46:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CAC883858430 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-113-G-FTuEWPPL-cRwjvTyQe5w-1; Thu, 21 Apr 2022 12:46:03 -0400 X-MC-Unique: G-FTuEWPPL-cRwjvTyQe5w-1 Received: by mail-wm1-f69.google.com with SMTP id d13-20020a05600c3acd00b0038ff865c043so4721746wms.3 for ; Thu, 21 Apr 2022 09:46:03 -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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L/ENul07fmO7ip4tfa1RXJ6A3hixEGPkGN8udMya/vc=; b=4sSDy3b2mcSCW9XkfRp4QNS6vKwm7OraNwuChWWRny2vT5XMDlt7JcSQ2Q9iiB78IR UjvdLP4D9nRfkM3BUs5DyoLZC9vczFL8WDzqaA3MXKU0uxxsjA0fvmpxCjcJPXm8UMvz yDmUbS4kzHykkOrPibZGPv97wDYy/IaAF3KeUd8jTGWr2WRgt9QIn1bJ7pbI0uYsj0gx qJBR5AXurjz2RJuWfzRaruOdaJNhyvj8sSp8k7LBH19KEvvyF3uVN82gLeELjl8rT354 FbxPCB2pERnnjLYY9jMZfi30Kv2yQ8AY+BSum5bOM+F/aiB8KobyknhtdunzCcJ9lVH7 7dAQ== X-Gm-Message-State: AOAM530xf5G8AzWug79baUDdlCVbu053hhCOymPjxKlSGoz1IIvui3dH C0/RQdGSvrdBuD/NftmXmCdHSlEIyuh5MKfznbf0aavRQh+m4iZxc+ztTJMUDrqJE4WqrR0lyUu gL9pbu9Mz2tEgQ5x/MCFxslL4scFKsZLZ+fUiAboytdOFwXzVpuQe2ZFJFQ+ffwAC8nIDx9p0PQ == X-Received: by 2002:a05:6000:1688:b0:20a:7ef8:d201 with SMTP id y8-20020a056000168800b0020a7ef8d201mr427774wrd.515.1650559561799; Thu, 21 Apr 2022 09:46:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuvlntUNjufNzDHTvJoabTNKsC2oB1St2ynMyxHVUtphpwOJ9Aj4mByw6e0PG5BZ9FGVR6rA== X-Received: by 2002:a05:6000:1688:b0:20a:7ef8:d201 with SMTP id y8-20020a056000168800b0020a7ef8d201mr427752wrd.515.1650559561416; Thu, 21 Apr 2022 09:46:01 -0700 (PDT) Received: from localhost (host81-136-113-48.range81-136.btcentralplus.com. [81.136.113.48]) by smtp.gmail.com with ESMTPSA id r9-20020a05600c320900b0038f0894d80csm2348583wmp.7.2022.04.21.09.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Apr 2022 09:46:00 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCHv4 1/2] gdb: add some additional thread status debug output Date: Thu, 21 Apr 2022 17:45:55 +0100 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: <20220113183406.3577620-1-aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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: Andrew Burgess Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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 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)); + 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