From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by sourceware.org (Postfix) with ESMTPS id EB8BA3861896 for ; Mon, 6 Jul 2020 19:03:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EB8BA3861896 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=alves.ped@gmail.com Received: by mail-wm1-f67.google.com with SMTP id o2so43191793wmh.2 for ; Mon, 06 Jul 2020 12:03:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=nS6rZTrk/sFzCtrmI341Cpd38HljhFe8HHMSRHTzZ+Q=; b=kHVRg7/MQLbXPFqpL4TE5h+fPtJTdKeJC2tFEynUZPGVtm4Wf57QgMb8LfZAv5Og/V j9papemgUoeMjd+CfkkdiqJcqsa1DHxBBqQyscS8VPCVpdl6nBCQ/TkSdxzxqre/3D8x ApAUefleDFWTfUbnvbF2p3OLFScgJrDvonH72XIe6EboDTuuvijem+wCUb0aV6j8a45u cSzDOz9tHOquOgo0NdJ8mW5DepT9IK8RrXkAl1+fz47L6f3j6aDsnsPaCrm9xSFQpIoJ /ozH7R+bBQFc+ul9AfJe1K14G1aImcEMga/JW9lJ4L7PdK/NbKbRJjzDJg2z71ytLuWI gfIA== X-Gm-Message-State: AOAM532iJrROTBPM2BzPGwIElwwMJYycNzoRoLt0X0Nd1XUiEzMszrj7 GMdVD6oGC8i9D4Qh/G2+NJ8ph4dvFabGiw== X-Google-Smtp-Source: ABdhPJziyCiNzk9707B1tURZwP6mk4TMYn68CM54K36qrjNdG4p1JqLXp/Qybgn3Ihbra1FkBYEZxw== X-Received: by 2002:a7b:cc8b:: with SMTP id p11mr619065wma.180.1594062187641; Mon, 06 Jul 2020 12:03:07 -0700 (PDT) Received: from localhost ([2001:8a0:f91a:c400:8728:8fef:5b85:5934]) by smtp.gmail.com with ESMTPSA id r8sm24861521wrp.40.2020.07.06.12.03.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Jul 2020 12:03:06 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 4/7] Fix handle_no_resumed w/ multiple targets Date: Mon, 6 Jul 2020 20:02:49 +0100 Message-Id: <20200706190252.22552-5-pedro@palves.net> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20200706190252.22552-1-pedro@palves.net> References: <20200706190252.22552-1-pedro@palves.net> X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: , X-List-Received-Date: Mon, 06 Jul 2020 19:03:10 -0000 handle_no_resumed is currently not considering multiple targets. Say you have two inferiors 1 and 2, each connected to a different target, A and B. Now say you set inferior 2 running, with "continue &". Now you select a thread of inferior 1, say thread 1.2, and continue in the foreground. All other threads of inferior 1 are left stopped. Thread 1.2 exits, and thus target A has no other resumed thread, so it reports TARGET_WAITKIND_NO_RESUMED. At this point, if both inferiors were running in the same target, handle_no_resumed would realize that threads of inferior 2 are still executing, so the TARGET_WAITKIND_NO_RESUMED event should be ignored. But because handle_no_resumed only walks the threads of the current target, it misses noticing that threads of inferior 2 are still executing. The fix is just to walk over all threads of all targets. A testcase covering the use case above will be added in a following patch. It can't be added yet because it depends on yet another fix to handle_no_resumed not included here. gdb/ChangeLog: PR gdb/26199 * infrun.c (handle_no_resumed): Handle multiple targets. --- gdb/infrun.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index a01e0969cb..0f2f45a4d2 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -5068,16 +5068,28 @@ handle_no_resumed (struct execution_control_state *ecs) have resumed threads _now_. In the example above, this removes thread 3 from the thread list. If thread 2 was re-resumed, we ignore this event. If we find no thread resumed, then we cancel - the synchronous command show "no unwaited-for " to the user. */ - update_thread_list (); + the synchronous command and show "no unwaited-for " to the + user. */ + + { + scoped_restore_current_thread restore_thread; + + for (auto *target : all_non_exited_process_targets ()) + { + switch_to_target_no_thread (target); + update_thread_list (); + } + } - for (thread_info *thread : all_non_exited_threads (ecs->target)) + for (thread_info *thread : all_non_exited_threads ()) { if (thread->executing || thread->suspend.waitstatus_pending_p) { - /* There were no unwaited-for children left in the target at - some point, but there are now. Just ignore. */ + /* Either there were no unwaited-for children left in the + target at some point, but there are now, or some target + other than the eventing one has unwaited-for children + left. Just ignore. */ if (debug_infrun) fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_NO_RESUMED " -- 2.14.5