From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by sourceware.org (Postfix) with ESMTPS id 8CE293857C63 for ; Fri, 9 Oct 2020 11:28:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8CE293857C63 IronPort-SDR: JWCX3ezCnKcmmDdRRvVbwKZPbV00tlc9u8OTwxKYBYTYYSFgaGXZxXcv1ZHlGdDLZKL3eYw3Bf O1Hq84+8J/rQ== X-IronPort-AV: E=McAfee;i="6000,8403,9768"; a="165586490" X-IronPort-AV: E=Sophos;i="5.77,354,1596524400"; d="scan'208";a="165586490" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2020 04:28:57 -0700 IronPort-SDR: nZzzlLTh9knYBnjx/6Pk/+fFoVoFwBxPDfGFWPC8vHEtsaPuMSHDzbcSKnTUHXMG/Ujz6r85eL E6pFnqlXc45w== X-IronPort-AV: E=Sophos;i="5.77,354,1596524400"; d="scan'208";a="462156542" Received: from ulll2701.iul.intel.com (HELO localhost) ([172.28.50.171]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2020 04:28:56 -0700 From: Natalia Saiapova To: gdb-patches@sourceware.org Subject: [PATCH v2 4/6] gdb/infrun: in condition evaluation wait only for the current inferior. Date: Fri, 9 Oct 2020 13:27:16 +0200 Message-Id: <20201009112719.629-5-natalia.saiapova@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201009112719.629-1-natalia.saiapova@intel.com> References: <20200831123519.16232-1-natalia.saiapova () intel ! com> <20201009112719.629-1-natalia.saiapova@intel.com> X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: Fri, 09 Oct 2020 11:29:01 -0000 In the middle of a condition evaluation, to successfully finish the inferior call we need to wait for events from the current thread. Otherwise, a pending event from another thread might be taken and the inferior call is abandoned. gdb/ChangeLog: 2020-08-26 Natalia Saiapova Tankut Baris Aktemur * infrun.c (do_target_wait): Match an inferior PID with the expected PID. (fetch_inferior_event): In condition evaluation, wait for the event from the current inferior. Co-authored-by: Natalia Saiapova Co-authored-by: Tankut Baris Aktemur Signed-off-by: Natalia Saiapova --- gdb/infrun.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 91271c2ddbe..d260eb6e3a7 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3565,10 +3565,11 @@ do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, polling the rest of the inferior list starting from that one in a circular fashion until the whole list is polled once. */ - auto inferior_matches = [&wait_ptid] (inferior *inf) + ptid_t wait_pid_ptid {wait_ptid.pid ()}; + auto inferior_matches = [&wait_pid_ptid] (inferior *inf) { - return (inf->process_target () != NULL - && ptid_t (inf->pid).matches (wait_ptid)); + return (inf->process_target () != nullptr + && ptid_t (inf->pid).matches (wait_pid_ptid)); }; /* First see how many matching inferiors we have. */ @@ -3906,7 +3907,15 @@ fetch_inferior_event () = make_scoped_restore (&execution_direction, target_execution_direction ()); - if (!do_target_wait (minus_one_ptid, ecs, TARGET_WNOHANG)) + ptid_t waiton_ptid = minus_one_ptid; + + /* If the thread is in the middle of the condition evaluation, + wait for the event from the current inferior. */ + if (inferior_ptid != null_ptid + && inferior_thread ()->control.in_cond_eval) + waiton_ptid = inferior_ptid; + + if (!do_target_wait (waiton_ptid, ecs, TARGET_WNOHANG)) return; gdb_assert (ecs->ws.kind != TARGET_WAITKIND_IGNORE); -- 2.17.1 Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Gary Kershaw Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928