From patchwork Thu Mar 7 13:28:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Metzger, Markus T" X-Patchwork-Id: 86927 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CF5953857702 for ; Thu, 7 Mar 2024 13:29:26 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by sourceware.org (Postfix) with ESMTPS id DBA153857BB8 for ; Thu, 7 Mar 2024 13:28:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBA153857BB8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DBA153857BB8 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818134; cv=none; b=KkFsfR4bGM/h2tMXKl0bUeTzbWpzwfv6Yvz6274vmT2hMVh+otenRXwXHxM2FOBd4u98rrEPIWNy4n14wkT2qgiZ3I3pxhdSNWRMCUNo6NOcgxXiNtWc3W02TWx6g164Sl4UnIjwy/MeaLDuft6QFRFJUzCYECcoNt2RjRX40yE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818134; c=relaxed/simple; bh=XGWyZD7T3+xEsWsOWlnArph9PGuPLNbiLdGiAbvO4DQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=WOs+yramxTzw0f17jrIBjQFqma4x3t9Fwsiub95jYW3j4klSeaOMnS6P2daALRS/NwxSk0HUFrIQZzLcd/T22ZCUPj4M0S/yD7mryYM/F7eTxxnUwiP98YGmtBd3F+goqSh7kA+qL7/WCSQiRmgGqSnotEMFWNbeVZjvxecgWhA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709818133; x=1741354133; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=XGWyZD7T3+xEsWsOWlnArph9PGuPLNbiLdGiAbvO4DQ=; b=WInLc7lIuFntmh+gKUTlHP2IPnAdgBoFdVShmucQQJhgpwx9m598Em5X Jh2tDPT67xeThDUNlkuxAc7n2o2GrJBvuudWDe3R4bciOIU22FCSZG/4G HOXc08L5wiiR4v6m0phXOwkcls+otL9zOyt5QuRRqefttOZ09wdtgqJLB p95okTdJnNFR2nRoG2ScW7Vs1qguYxsUVjJgeW+7Ei+IairXXBc9xSBaR 9QVp6aF7R+SCo5MX2/OsMwEAqFf7aLgt/R1nUAIojcQii0ee24W9KZjfD FQFTJeAeXaSLOU0UqMZTlnXtfWouywQANcKQwVz2r/yvFMjrW2vLmvuzW A==; X-IronPort-AV: E=McAfee;i="6600,9927,11005"; a="4654405" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="4654405" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:28:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="10010142" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:28:51 -0800 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 1/6] gdb, btrace: fix pr19340 Date: Thu, 7 Mar 2024 13:28:40 +0000 Message-Id: <20240307132845.2909415-2-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307132845.2909415-1-markus.t.metzger@intel.com> References: <20240307132845.2909415-1-markus.t.metzger@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org GDB fails with an assertion when stopping recording on a replaying thread and then resuming that thread. Stopping recording left the thread replaying but the record target is gone. Stop replaying all threads in the selected inferior before stopping recording. If the selected thread had been replaying, print the (potentially updated) location. I had to change the stepping test slightly to account for different compilers generating slightly different debug information, so when stepping the 'return 0' after 'record stop' I would end up in a different location depending on which compiler I used. The test still covers all stepping commands. Fixes PR gdb/19340. --- gdb/record-btrace.c | 17 +++++++++++++++++ gdb/testsuite/gdb.btrace/step.exp | 22 +++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 6350400c318..dd6ef8db3a3 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -415,11 +415,28 @@ record_btrace_target::stop_recording () { DEBUG ("stop recording"); + /* Remember the selected thread if it exists and is replaying. */ + thread_info *curr = nullptr; + if (inferior_ptid.lwp_p ()) + { + curr = inferior_thread (); + if (!btrace_is_replaying (curr)) + curr = nullptr; + } + + record_stop_replaying (); record_btrace_auto_disable (); for (thread_info *tp : current_inferior ()->non_exited_threads ()) if (tp->btrace.target != NULL) btrace_disable (tp); + + /* Print the updated location in case we had stopped a replaying thread. */ + if (curr != nullptr) + { + curr->set_stop_pc (regcache_read_pc (get_thread_regcache (curr))); + print_stack_frame (get_selected_frame (), 1, SRC_AND_LOC, 1); + } } /* The disconnect method of target record-btrace. */ diff --git a/gdb/testsuite/gdb.btrace/step.exp b/gdb/testsuite/gdb.btrace/step.exp index 0adc18bd924..ed6d2140bdd 100644 --- a/gdb/testsuite/gdb.btrace/step.exp +++ b/gdb/testsuite/gdb.btrace/step.exp @@ -31,18 +31,26 @@ if ![runto_main] { # trace the call to the test function with_test_prefix "record" { gdb_test_no_output "record btrace" - gdb_test "next" + gdb_test "step" + gdb_test "next 2" } # let's step around a bit with_test_prefix "replay" { - gdb_test "reverse-next" ".*main\.2.*" "reverse-next.1" + gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.1" gdb_test "step" ".*fun4\.2.*" "step.1" gdb_test "next" ".*fun4\.3.*" "next.1" gdb_test "step" ".*fun2\.2.*" "step.2" - gdb_test "finish" ".*fun4\.4.*" "finish.1" - gdb_test "reverse-step" ".*fun2\.3.*" "reverse-step.1" - gdb_test "reverse-finish" ".*fun4\.3.*" "reverse-finish.1" - gdb_test "reverse-next" ".*fun4\.2.*" "reverse-next.2" - gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.2" + gdb_test "reverse-finish" ".*fun4\.3.*" "reverse-finish.2" + gdb_test "reverse-step" ".*fun1\.2.*" "reverse-step.1" + gdb_test "finish" ".*fun4\.3.*" "finish.1" + gdb_test "reverse-next" ".*fun4\.2.*" "reverse-next.1" + gdb_test "reverse-finish" ".*main\.2.*" "reverse-finish.3" +} + +# stop recording and try to step live (pr19340) +with_test_prefix "live" { + gdb_test "record stop" "fun4\.4.*Process record is stopped.*" + gdb_test "reverse-next" "Target .* does not support this command.*" + gdb_test "step" ".*fun3\.2.*" } From patchwork Thu Mar 7 13:28:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Metzger, Markus T" X-Patchwork-Id: 86928 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11EAA385771A for ; Thu, 7 Mar 2024 13:29:58 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by sourceware.org (Postfix) with ESMTPS id 208133857833 for ; Thu, 7 Mar 2024 13:28:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 208133857833 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 208133857833 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818137; cv=none; b=PxEWRA9th6ObuGv/MyYTGnwrL41RbB/oSkuveNXxkLa4ZkJTL6lC2yx8t1emQcI9RutHcGXBbtOp1XK9DqPa91vpigEb+Q0agW9UIHy7DPV+4NiObS/bhMuyD/UIqBKJ7PIWxYI4LZjovAUj9gp+Jx+gfuSoIVQAmeLiUZeIu0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818137; c=relaxed/simple; bh=GyjHhpRcC4HGF6czK/JPt1upnjxDSin9KKGgQx/giyE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Mi3x787urYTTwtj2bNCEnLWU9sQT6XFxOr4LEYP7kfOCrDnz17AS66um5qzvYmbHZr+w74V8TQjDw8NDkYepUiuzLbnGZQ22fB3Ie6Y8QsFanPoFyXiici12Q8WlDbA8YEuXPF1yiCSVE+hQbcSpT0/+UU5JbpjunzuRaIz4wVo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709818135; x=1741354135; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=GyjHhpRcC4HGF6czK/JPt1upnjxDSin9KKGgQx/giyE=; b=XARGFRISL0PP4kcdg6TT8HC3xo8gltOso+pmE2eR5JVLFH/z8YrV2sfg dXnAyKCRHlwpbP3+1xH/345d1ChK1Ut+d7+mdPX0CMnGkcnGM5Zi/Gv1H sEExhWrTS7OS2iXDg89m7AT2rylsIfaMX57AyveD7ksEvc8J+FcYsQHft JLr8505ctRjiI18qD6xUNsE649xcRXKRe2AZseFhGuSLyAGx72ZtLEVSw dL3D8u44wfUx3WhDyYX+IpVcIR7Chjp8xXvkbsy/y5Da02aooWoAsRk0C 8URyJUSFfvIrwXqN0gEJGyMXSSfv2bCCUEK91pdypJpOjAqI/XNKkYcW9 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11005"; a="4654414" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="4654414" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:28:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="10010146" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:28:54 -0800 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 2/6] gdb, btrace: simplify gdb.btrace/multi-inferior.exp Date: Thu, 7 Mar 2024 13:28:41 +0000 Message-Id: <20240307132845.2909415-3-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307132845.2909415-1-markus.t.metzger@intel.com> References: <20240307132845.2909415-1-markus.t.metzger@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org We don't really need three inferiors to test multi-inferior recording. We don't really need to start recording on the second inferior first. We don't really need to check info record before starting recording. If we were recording, there would be output, causing a fail. This just complicates the test when there is something to debug. --- gdb/testsuite/gdb.btrace/multi-inferior.exp | 24 +++------------------ 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/gdb/testsuite/gdb.btrace/multi-inferior.exp b/gdb/testsuite/gdb.btrace/multi-inferior.exp index 6996b182e65..174d38364a4 100644 --- a/gdb/testsuite/gdb.btrace/multi-inferior.exp +++ b/gdb/testsuite/gdb.btrace/multi-inferior.exp @@ -37,6 +37,8 @@ with_test_prefix "inferior 1" { if ![runto_main] { return -1 } + + gdb_test_no_output "record btrace" } with_test_prefix "inferior 2" { @@ -48,25 +50,5 @@ with_test_prefix "inferior 2" { return -1 } - gdb_test_no_output "record btrace" "record btrace" -} - -with_test_prefix "inferior 1" { - gdb_test "inferior 1" "Switching to inferior 1.*" - - gdb_test "info record" "No recording is currently active\\." - gdb_test_no_output "record btrace" "record btrace" -} - -with_test_prefix "inferior 3" { - gdb_test "add-inferior -exec ${host_binfile}" "Added inferior 3.*" \ - "add third inferior" - gdb_test "inferior 3" "Switching to inferior 3.*" - - if ![runto_main] { - return -1 - } - - gdb_test "info record" "No recording is currently active\\." - gdb_test_no_output "record btrace" "record btrace" + gdb_test_no_output "record btrace" } From patchwork Thu Mar 7 13:28:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Metzger, Markus T" X-Patchwork-Id: 86930 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 684253857715 for ; Thu, 7 Mar 2024 13:30:26 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by sourceware.org (Postfix) with ESMTPS id 97E2B3857BBC for ; Thu, 7 Mar 2024 13:28:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 97E2B3857BBC Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 97E2B3857BBC Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818142; cv=none; b=Lw6ekD300cDuph9CQOoJqe9jf4iBzQEGsAaCnn4f/DCf9h895iQkgNBakszMWCdqhKpPFARs6kD8n7g4t61CQEYLOXgtKZV6+pDSUtxS/bC3AiE4HWMAh8IQNo1W/oAQz7+2KQO3PCp3eWMNrm4Il4kXj/TSoaLI5Ggh1kvMp3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818142; c=relaxed/simple; bh=yvlxor1VbGhwkCCQxFwTdFMXaZ2KxhtckwEzAOJ7cTg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=a+xT5pDcn6ify/ebpeg7j7B5yqZ9aZDkf7XXcAHkN3sDnvwL/Uh0IdW94oOf/e93jo8II02vmTKYTBiuFg+xLcrxcBY+jjBENDKY1/VSOe7h42OH3PVWfynQc9s15brvTqZxppp5d37TN6b8j4wWdIlXQkZexM9Nh1nM/6TpwLg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709818139; x=1741354139; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=yvlxor1VbGhwkCCQxFwTdFMXaZ2KxhtckwEzAOJ7cTg=; b=KXQMWZYq2NK05G4XrCIWtKEr3yvF4D8K9RwP/70viT4HeQtgMJ/eJPAx f5orCo8EnKj6l1EXQbRWxMMdPlZ5gXcDbWCswtM5Hm5zhE6054vfP1law 62yaEHIY1Tm5MQhjIlJFghM6zdqpIO7KShIBM+Mp6uVLCfWA10gYWlRKJ Z4jZdPK86muP65b516rVIEsgOffjkW2E5Avcr0mm3FlMwqNyGjprGKOLj yc7HjA6j5bgEnmAEVJP27BQkr8KHw2Hm1i1zLl7bf+wqC6l0qz7+E/hjw LPyCkenOcaCwD1bJm8HFgL0EQ8gmHzr4qek+jxcilnorkcC90bc9Eh8dh g==; X-IronPort-AV: E=McAfee;i="6600,9927,11005"; a="4654421" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="4654421" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:28:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="10010151" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:28:57 -0800 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 3/6] gdb, btrace: remove record_btrace_target::supports_*() Date: Thu, 7 Mar 2024 13:28:42 +0000 Message-Id: <20240307132845.2909415-4-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307132845.2909415-1-markus.t.metzger@intel.com> References: <20240307132845.2909415-1-markus.t.metzger@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Let's not introduce support for breakpoint types the target beneath does not support, even though we could while replaying. Otherwise, users may set breakpoints during replay that then couldn't be inserted into the target when switching back to recording. --- gdb/record-btrace.c | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index dd6ef8db3a3..9f2999268d8 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -131,10 +131,7 @@ class record_btrace_target final : public target_ops bool can_execute_reverse () override; bool stopped_by_sw_breakpoint () override; - bool supports_stopped_by_sw_breakpoint () override; - bool stopped_by_hw_breakpoint () override; - bool supports_stopped_by_hw_breakpoint () override; enum exec_direction_kind execution_direction () override; void prepare_to_generate_core () override; @@ -2707,18 +2704,6 @@ record_btrace_target::stopped_by_sw_breakpoint () return this->beneath ()->stopped_by_sw_breakpoint (); } -/* The supports_stopped_by_sw_breakpoint method of target - record-btrace. */ - -bool -record_btrace_target::supports_stopped_by_sw_breakpoint () -{ - if (record_is_replaying (minus_one_ptid)) - return true; - - return this->beneath ()->supports_stopped_by_sw_breakpoint (); -} - /* The stopped_by_sw_breakpoint method of target record-btrace. */ bool @@ -2734,18 +2719,6 @@ record_btrace_target::stopped_by_hw_breakpoint () return this->beneath ()->stopped_by_hw_breakpoint (); } -/* The supports_stopped_by_hw_breakpoint method of target - record-btrace. */ - -bool -record_btrace_target::supports_stopped_by_hw_breakpoint () -{ - if (record_is_replaying (minus_one_ptid)) - return true; - - return this->beneath ()->supports_stopped_by_hw_breakpoint (); -} - /* The update_thread_list method of target record-btrace. */ void From patchwork Thu Mar 7 13:28:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Metzger, Markus T" X-Patchwork-Id: 86929 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 56A25385770C for ; Thu, 7 Mar 2024 13:30:01 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by sourceware.org (Postfix) with ESMTPS id 7A7853857815 for ; Thu, 7 Mar 2024 13:29:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A7853857815 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A7853857815 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818143; cv=none; b=uJ8rszr2vVc33uYzwJPwdgE2+jyJ9OVs8sJvarBJcVTBcBTFaadyK/E2kRP5jq2QGPtLjaU0pD0IpFrgh+q2pMM5pSgDtmCs78m5ONc8swnC8XtC0rqe2GltlFelnFIm0eKHc8u+/toB/JRg1JSYuFjjeiKMHqsY5wM7fA+dkvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818143; c=relaxed/simple; bh=w8oDNgOuZqRB/KjUXfMbg9xU83fqTu6sEv2AhS05IQs=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=HMVWpave6REzIJpc+UyQBovh1RN/6CALnEfhQO5Y9hV2TdTo8Wk+lR1DysF5cjb9hRvNsqzNBZ4wR4m5//9btQVt/TgZiclkmU5Ffy8v9Zc+hUO1313q1jBF1EqAFWGJge7sSDQ/85GPPJcJPtiBJ8ws/cXY+UVERzhPPK3Qm1g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709818142; x=1741354142; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=w8oDNgOuZqRB/KjUXfMbg9xU83fqTu6sEv2AhS05IQs=; b=PTfVta01B4M+8LeqIE7U6PW41yTidfyWlqNv4a6CluNX7tF+I5iNShIY 9lzzgwPyE01C0lbZMqcWgCLvQF8IxXkTNKdhpYod2v0pg0oicImTtoj9c xh/eF5BwEX9OwBOyiC1iMWqeZQVkzfkhTNlWKtgOG+salxxPU0DdXy3bx K+Vuux2LO5hiMO9cpYFYWhU0F6ZQH0vAXd+rWizmtt66WRq1cXRXL7hax 6tATHEmLm5YrRvgK9c3XUNdVUYMurqJaYau84PC76MXKWzvzHTjmX+Pgz asrEdkdRe0a7UrVLyj1ktUkEfrN46eZEG3KUo/wmy4BiDTCrqJ0xurp0x A==; X-IronPort-AV: E=McAfee;i="6600,9927,11005"; a="4654427" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="4654427" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:29:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="10010156" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:29:00 -0800 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 4/6] gdb, btrace: set wait status to ignore if nothing is moving Date: Thu, 7 Mar 2024 13:28:43 +0000 Message-Id: <20240307132845.2909415-5-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307132845.2909415-1-markus.t.metzger@intel.com> References: <20240307132845.2909415-1-markus.t.metzger@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org When record_btrace::wait() is called and no threads are moving, we set the wait status to no_resumed. Change that to ignore. This helps with enabling per-inferior run-control for the record btrace target as it avoids breaking out of do_target_wait() too early with no_resumed when there would have been an event on another thread. --- gdb/record-btrace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 9f2999268d8..8b20ab53ca7 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -2280,14 +2280,14 @@ btrace_step_spurious (void) return status; } -/* Return a target_waitstatus indicating that the thread was not resumed. */ +/* Return a target_waitstatus indicating that nothing is moving. */ static struct target_waitstatus -btrace_step_no_resumed (void) +btrace_step_no_moving_threads (void) { struct target_waitstatus status; - status.set_no_resumed (); + status.set_ignore (); return status; } @@ -2556,7 +2556,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status, if (moving.empty ()) { - *status = btrace_step_no_resumed (); + *status = btrace_step_no_moving_threads (); DEBUG ("wait ended by %s: %s", null_ptid.to_string ().c_str (), status->to_string ().c_str ()); From patchwork Thu Mar 7 13:28:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Metzger, Markus T" X-Patchwork-Id: 86931 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3A6BD3857715 for ; Thu, 7 Mar 2024 13:30:31 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by sourceware.org (Postfix) with ESMTPS id 6EB033857C4A for ; Thu, 7 Mar 2024 13:29:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6EB033857C4A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6EB033857C4A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818147; cv=none; b=dL9eJPrDDtj2FVtKwQs3F5keQ+UR9Id5E9XdthnLE8R2Hh0dLAMpUwTqZVPPMzA8XeJMplyj2yuv7Q8EyQ/ozxEXLRJXTE3aC6tnH79+rd7JIc7SelJZFDVfWUPM9IrPw2/wb4YE4cBK47om56e+LuZHD0d2a0OZzttrLtP+1Zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818147; c=relaxed/simple; bh=UWGuqVbY/MaAFfezJOJTNps1LstNmHJCLdhZc28BrUc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=hIvrYa7UcSi6jxsDB+VC4nFm9KChsCCmYOEYPyUW5edO9l13aIfMfjgY4X4vPEQ0kTk0HfuCnrZNz9WL40CezEqaJf1wLHxHKwm/uAzb/gAQr6/3qLQ4xxPUuMIg9FELmW7wBOmGNpA3MW79QlImPQM0eAjWOnZ8DlTRtSbNUa0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709818145; x=1741354145; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=UWGuqVbY/MaAFfezJOJTNps1LstNmHJCLdhZc28BrUc=; b=hVeCS455HW5S/NmdT0WcA2B3wTRnyr8eDrEXywLztAIOzFGoKkUkMvBA IBbJCueO4zlsJmdWiOfEDr+GJYAuBxrjp1yfrqyuUxaaewLVawq3tn+BD Zb6HNCVcT96o4eFD35pdko5ESpaibC70nIj7teEtWgwO/H5fQsavW3M1b OAmYJXa9ZpPj+GRlGH9v4Nk78aMzfjf9uwtVtO4sU4As6epXr7exPZiwT Sv09uMqE7zS7w5i7tMdGFjpaVXdSQnBivuJCw/YE0LGdS3HIyMtdbCKv1 jscxmR/hz3q5Jwd2PSOT+mFzybWBUYzus5nJ4fJshwyN1MegEbS8sbFIv g==; X-IronPort-AV: E=McAfee;i="6600,9927,11005"; a="4654437" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="4654437" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:29:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="10010165" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:29:02 -0800 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 5/6] gdb, infrun: wait for single inferior Date: Thu, 7 Mar 2024 13:28:44 +0000 Message-Id: <20240307132845.2909415-6-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307132845.2909415-1-markus.t.metzger@intel.com> References: <20240307132845.2909415-1-markus.t.metzger@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org In do_target_wait(), we iterate over inferiors and call do_target_wait_1(), which eventually calls target_wait() per inferior. Each time, we wait for minus_one_ptid. For the record btrace target, with one inferior replaying and the other recording, calling wait(minus_one_ptid) prevents forwarding the request to the target beneath for the recording inferior. We could try to handle this in record_btrace::wait(), e.g. by forwarding and also checking replaying threads, but it seems better to more clearly specify the intent of the wait() request. Wait for a single inferior, instead. Since we iterate over all inferiors, we still cover everything. --- gdb/infrun.c | 22 +++++++++++++++++++++- gdb/linux-nat.c | 16 +++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index bbb98f6dcdb..d9ab69723b8 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4176,7 +4176,27 @@ do_target_wait (execution_control_state *ecs, target_wait_flags options) auto do_wait = [&] (inferior *inf) { - ecs->ptid = do_target_wait_1 (inf, minus_one_ptid, &ecs->ws, options); + /* FIXME: I don't see why we should have inferiors with zero pid, + which is also indicating that the respective ptid is not a process. + + We do have them, though, and we could either skip them or do a + generic wait-for-anything. + + Targets that cannot async will be asked for a blocking wait. + + Blocking wait does not work inferior-by-inferior if the target + provides more than one inferior. + + Blocking wait does not work target-by-target, either, if we have + more than one target. We cannot do much about that, here, other + than to preserve the existing behavior of passing + minus_one_ptid. */ + ptid_t ptid { inf->pid }; + if (!ptid.is_pid () || !target_can_async_p () + || ((options & TARGET_WNOHANG) != 0)) + ptid = minus_one_ptid; + + ecs->ptid = do_target_wait_1 (inf, ptid, &ecs->ws, options); ecs->target = inf->process_target (); return (ecs->ws.kind () != TARGET_WAITKIND_IGNORE); }; diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 3ba072bc8d7..908623c9af7 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -3330,12 +3330,18 @@ linux_nat_wait_1 (ptid_t ptid, struct target_waitstatus *ourstatus, moment at which we know its PID. */ if (ptid.is_pid () && find_lwp_pid (ptid) == nullptr) { - ptid_t lwp_ptid (ptid.pid (), ptid.pid ()); + /* Unless we already did and this is simply a request to wait for a + particular inferior. */ + inferior *inf = find_inferior_ptid (linux_target, ptid); + if (inf && inf->find_thread (ptid)) + { + ptid_t lwp_ptid (ptid.pid (), ptid.pid ()); - /* Upgrade the main thread's ptid. */ - thread_change_ptid (linux_target, ptid, lwp_ptid); - lp = add_initial_lwp (lwp_ptid); - lp->resumed = 1; + /* Upgrade the main thread's ptid. */ + thread_change_ptid (linux_target, ptid, lwp_ptid); + lp = add_initial_lwp (lwp_ptid); + lp->resumed = 1; + } } /* Make sure SIGCHLD is blocked until the sigsuspend below. */ From patchwork Thu Mar 7 13:28:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Metzger, Markus T" X-Patchwork-Id: 86932 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1866385783E for ; Thu, 7 Mar 2024 13:30:59 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) by sourceware.org (Postfix) with ESMTPS id 20B6F3857837 for ; Thu, 7 Mar 2024 13:29:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20B6F3857837 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 20B6F3857837 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818152; cv=none; b=xn5A+zpCAybZ1xjoYrQTXilEuiV9SaO8AzVVz6ZgrOgO/2wkoLi60acWPj6NZ8gBRid94j0VL2t16lfmA23ST/E1/a5Y87MzJTNeFvNUclaHE2MFMGzYQmPBH14An3c6WIPG0vJ7Sr2RWUzN0+NwsulZVVvwCFX5shV6dgqyqG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709818152; c=relaxed/simple; bh=95xM3Xqn4JU0Dlo/r7vmhOoh2Wqn9M1IGoA0qj23nl4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=SFFszrx0i2biAzMu/vE2NQaMoxruuVCkY5tX4P4djUYm/3KAW0Ftblj2hqm759b6xyawpDV2isbQmcCg6A62dPzddu7dvQbJgJJWBPXrUr5d1XTKfbtW9dZBH8D3QlciPxE108FjJIrsVg3CLhERbh+sGox4wUhbMoKO2WhllDs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709818147; x=1741354147; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=95xM3Xqn4JU0Dlo/r7vmhOoh2Wqn9M1IGoA0qj23nl4=; b=h/+DV2iGNnK8oDisA1v2bEopxNdpZAULLjw3Oi8QQRRpE2tcjYzCbOyI TvgmCTNXxxCMoJOAdKMj7oHvzO3pgPTa6MMo9epentNhCJBUMxZUO9RXi N8Tc3V5yrNN7IwHjrnVHWXfBRkFgm+q9QegAYsYw6dQKUgsrptKKCsZOT Cdigc9kPf5znwx50ElBWp8lVS0Vm/VaHqerXwzPoIDxavIFwM0eWOvvtt 2n05YSvGl04icShHd02wRauALXxkcO2yyaGZSIgZ2reLHMt7unvLoT1we 6V5dN2eIsy91EjP6RrsEc33hI/o718o5hlQSPDAYbjWLbovy1UApH8+Mv Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11005"; a="4654444" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="4654444" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:29:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="10010168" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 05:29:05 -0800 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH 6/6] gdb, btrace, infrun: per-inferior run-control Date: Thu, 7 Mar 2024 13:28:45 +0000 Message-Id: <20240307132845.2909415-7-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307132845.2909415-1-markus.t.metzger@intel.com> References: <20240307132845.2909415-1-markus.t.metzger@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org While recording is already per inferior, run-control isn't. As soon as any thread in any inferior is replaying, no other inferior can be resumed. This is controlled by many calls to record_is_replaying(minus_one_ptid). Instead of minus_one_ptid, pass the ptid of the inferior to be checked. --- gdb/infrun.c | 17 ++++++++------ gdb/record-btrace.c | 26 +++++---------------- gdb/testsuite/gdb.btrace/multi-inferior.c | 10 +++++++- gdb/testsuite/gdb.btrace/multi-inferior.exp | 19 +++++++++++++++ 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index d9ab69723b8..b3f7f7aa19d 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2400,7 +2400,8 @@ user_visible_resume_ptid (int step) resume_ptid = inferior_ptid; } else if ((scheduler_mode == schedlock_replay) - && target_record_will_replay (minus_one_ptid, execution_direction)) + && target_record_will_replay (ptid_t (inferior_ptid.pid ()), + execution_direction)) { /* User-settable 'scheduler' mode requires solo thread resume in replay mode. */ @@ -3110,15 +3111,17 @@ clear_proceed_status (int step) This is a convenience feature to not require the user to explicitly stop replaying the other threads. We're assuming that the user's intent is to resume tracing the recorded process. */ + ptid_t resume_ptid = user_visible_resume_ptid (step); if (!non_stop && scheduler_mode == schedlock_replay - && target_record_is_replaying (minus_one_ptid) - && !target_record_will_replay (user_visible_resume_ptid (step), - execution_direction)) - target_record_stop_replaying (); + && target_record_is_replaying (ptid_t (resume_ptid.pid ())) + && !target_record_will_replay (resume_ptid, execution_direction)) + { + target_record_stop_replaying (); + resume_ptid = user_visible_resume_ptid (step); + } if (!non_stop && inferior_ptid != null_ptid) { - ptid_t resume_ptid = user_visible_resume_ptid (step); process_stratum_target *resume_target = user_visible_resume_target (resume_ptid); @@ -3197,7 +3200,7 @@ schedlock_applies (struct thread_info *tp) || (scheduler_mode == schedlock_step && tp->control.stepping_command) || (scheduler_mode == schedlock_replay - && target_record_will_replay (minus_one_ptid, + && target_record_will_replay (ptid_t (tp->inf->pid), execution_direction))); } diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c index 8b20ab53ca7..cf0b894e344 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -122,7 +122,6 @@ class record_btrace_target final : public target_ops ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override; void stop (ptid_t) override; - void update_thread_list () override; bool thread_alive (ptid_t ptid) override; void goto_record_begin () override; void goto_record_end () override; @@ -2160,7 +2159,7 @@ record_btrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal) make progress, we may need to explicitly move replaying threads to the end of their execution history. */ if ((::execution_direction != EXEC_REVERSE) - && !record_is_replaying (minus_one_ptid)) + && !record_is_replaying (ptid_t (ptid.pid ()))) { this->beneath ()->resume (ptid, step, signal); return; @@ -2543,7 +2542,7 @@ record_btrace_target::wait (ptid_t ptid, struct target_waitstatus *status, /* As long as we're not replaying, just forward the request. */ if ((::execution_direction != EXEC_REVERSE) - && !record_is_replaying (minus_one_ptid)) + && !record_is_replaying (ptid_t (ptid.pid ()))) { return this->beneath ()->wait (ptid, status, options); } @@ -2664,7 +2663,7 @@ record_btrace_target::stop (ptid_t ptid) /* As long as we're not replaying, just forward the request. */ if ((::execution_direction != EXEC_REVERSE) - && !record_is_replaying (minus_one_ptid)) + && !record_is_replaying (ptid_t (ptid.pid ()))) { this->beneath ()->stop (ptid); } @@ -2694,7 +2693,7 @@ record_btrace_target::can_execute_reverse () bool record_btrace_target::stopped_by_sw_breakpoint () { - if (record_is_replaying (minus_one_ptid)) + if (record_is_replaying (ptid_t (inferior_ptid.pid ()))) { struct thread_info *tp = inferior_thread (); @@ -2709,7 +2708,7 @@ record_btrace_target::stopped_by_sw_breakpoint () bool record_btrace_target::stopped_by_hw_breakpoint () { - if (record_is_replaying (minus_one_ptid)) + if (record_is_replaying (ptid_t (inferior_ptid.pid ()))) { struct thread_info *tp = inferior_thread (); @@ -2719,26 +2718,13 @@ record_btrace_target::stopped_by_hw_breakpoint () return this->beneath ()->stopped_by_hw_breakpoint (); } -/* The update_thread_list method of target record-btrace. */ - -void -record_btrace_target::update_thread_list () -{ - /* We don't add or remove threads during replay. */ - if (record_is_replaying (minus_one_ptid)) - return; - - /* Forward the request. */ - this->beneath ()->update_thread_list (); -} - /* The thread_alive method of target record-btrace. */ bool record_btrace_target::thread_alive (ptid_t ptid) { /* We don't add or remove threads during replay. */ - if (record_is_replaying (minus_one_ptid)) + if (record_is_replaying (ptid_t (ptid.pid ()))) return true; /* Forward the request. */ diff --git a/gdb/testsuite/gdb.btrace/multi-inferior.c b/gdb/testsuite/gdb.btrace/multi-inferior.c index fb4ffc22a17..6f1052a7f25 100644 --- a/gdb/testsuite/gdb.btrace/multi-inferior.c +++ b/gdb/testsuite/gdb.btrace/multi-inferior.c @@ -15,8 +15,16 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +static int +fun (void) +{ + int x = fun (); /* fun.1 */ + return x; /* fun.2 */ +} + int main (void) { - return 0; + int x = fun (); /* main.1 */ + return x; /* main.2 */ } diff --git a/gdb/testsuite/gdb.btrace/multi-inferior.exp b/gdb/testsuite/gdb.btrace/multi-inferior.exp index 174d38364a4..df7f423a088 100644 --- a/gdb/testsuite/gdb.btrace/multi-inferior.exp +++ b/gdb/testsuite/gdb.btrace/multi-inferior.exp @@ -39,6 +39,8 @@ with_test_prefix "inferior 1" { } gdb_test_no_output "record btrace" + gdb_test "step 4" "fun\.1.*" + gdb_test "reverse-step" "fun\.1.*" } with_test_prefix "inferior 2" { @@ -51,4 +53,21 @@ with_test_prefix "inferior 2" { } gdb_test_no_output "record btrace" + gdb_test "step 4" "fun\.1.*" + gdb_test "reverse-step" "fun\.1.*" + + gdb_test "info record" "Replay in progress.*" + gdb_test "record stop" "Process record is stopped.*" + + gdb_test "step" "fun\.1.*" +} + +with_test_prefix "inferior 1" { + gdb_test "inferior 1" "Switching to inferior 1.*" + + gdb_test "info record" "Replay in progress.*" + gdb_test "reverse-finish" "fun\.1.*" + gdb_test "record goto end" "fun\.1.*" + gdb_test "step 2" "fun\.1.*" + gdb_test "reverse-step 3" }