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.*" }