From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by sourceware.org (Postfix) with ESMTPS id 8BC6B3857C46 for ; Fri, 9 Oct 2020 11:28:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8BC6B3857C46 IronPort-SDR: 5PBIBz/cpIAgy+ZZakC9ix/eMiwxBdA1SOEKBRq040fUMc8jUCS+CQm8aPoIQgIjGOo365NrpO KhgxR+EeVqAg== X-IronPort-AV: E=McAfee;i="6000,8403,9768"; a="152391744" X-IronPort-AV: E=Sophos;i="5.77,354,1596524400"; d="scan'208";a="152391744" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2020 04:28:29 -0700 IronPort-SDR: OqaZNAhyK6mUbXF4gub0kYB+O33oQBy5AjqIPz4FwtNz9o4846mBZZx/nRdBrUj4mi73ftBoND DfpVdCkG+GyA== X-IronPort-AV: E=Sophos;i="5.77,354,1596524400"; d="scan'208";a="462156468" 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:28 -0700 From: Natalia Saiapova To: gdb-patches@sourceware.org Subject: [PATCH v2 2/6] gdb/infrun: in condition evaluation resume only current thread. Date: Fri, 9 Oct 2020 13:27:14 +0200 Message-Id: <20201009112719.629-3-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=-8.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, 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:28:33 -0000 When stopped at a conditional BP, GDB evaluates the condition for the event thread in order to decide whether the thread should be stopped or resumed. Thus, if the condition includes an inferior call, during the call not all threads have finalized state, some of them might still be shown as running. While executing the proceed for the inferior call, GDB tries to resume all non-exited threads. This leads to the following assertion, when GDB tries to resume a running thread: (gdb) b 43 if foo() Breakpoint 1 at 0x119b: file main.c, line 43. (gdb) run Starting program: main [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff77c4700 (LWP 21421)] [New Thread 0x7ffff6fc3700 (LWP 21422)] gdb/nat/x86-linux-dregs.c:146: internal-error: void x86_linux_update_debug_registers(lwp_info*): Assertion `lwp_is_stopped (lwp)' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. This is a bug, please report it. For instructions, see: . This patch changes the behavior, so if the current thread is in the middle of a condition evaluation, only the current thread is resumed. gdb/ChangeLog: 2020-08-26 Natalia Saiapova Tankut Baris Aktemur * infrun.c (user_visible_resume_ptid): In BP condition evaluation, resume only the current thread Co-authored-by: Natalia Saiapova Co-authored-by: Tankut Baris Aktemur Signed-off-by: Natalia Saiapova --- gdb/infrun.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gdb/infrun.c b/gdb/infrun.c index d552fb3adb2..91271c2ddbe 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2156,6 +2156,14 @@ user_visible_resume_ptid (int step) mode. */ resume_ptid = inferior_ptid; } + else if (inferior_ptid != null_ptid + && inferior_thread ()->control.in_cond_eval) + { + /* The inferior thread is evaluating a BP condition. Other threads + might be stopped or running and we do not want to change their + state, thus, resume only the current thread. */ + resume_ptid = inferior_ptid; + } else if (!sched_multi && target_supports_multi_process ()) { /* Resume all threads of the current process (and none of other -- 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