From patchwork Thu Apr 11 05:25:59 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: 88326 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 F35763849AC4 for ; Thu, 11 Apr 2024 05:26:45 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by sourceware.org (Postfix) with ESMTPS id 0E4E53858402 for ; Thu, 11 Apr 2024 05:26:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E4E53858402 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 0E4E53858402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712813173; cv=none; b=qclMYzSm9fwddGO+A3n6ZF/EzBjo3gC4ST8OCgA5nHbCmyhwPLKl+U7sA0Y2G0ZrZRqzU3mhzAxBXXdo09XM3VY4JWXAK9d+p6CWEeIrb1DRea+rxzYAa+h3x+d8sdJ3+2ieJQMVL3wZdNgmnsxjIm7f7U4vsm4t1is8dSpCXc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712813173; c=relaxed/simple; bh=6/+NCbt7RWqjWIG+VnDjuQlark55BekT+L3ptdfUhoU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=qjWhD9EBMz0F4hmRR87ZEi8BUs8DFicsPvpdk4aEMQ6Pd3nRIrqcNPr+iLBOm0R8y+pOhNi++PstJRmry7DU18JYSCJYMNBDEqPc8LSn9bFUT8BRRkkQN6U4297iPB5yM0SfB/xiutBDQgSEtBWOznV7Rhxjjx3MlP+7PgKokQ4= 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=1712813171; x=1744349171; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6/+NCbt7RWqjWIG+VnDjuQlark55BekT+L3ptdfUhoU=; b=kSAD+H5Ys3Acmq6cbcsQFO1Vc/3Q3RURPVVTn/acdFpXbDStDZDCTGnI p5W5xn2aqMUBupsQcAo+zEagTuNQPiqVtoktqCkr1ZYca1Lid6jrjZZUD jDkUmqeE0KK8mkOjMtU2unhxWdkv7fLgEw689DQRI5dXOq42OXDoLgSaH xlZaCR96yD6C90KOtiaA30RHuYOSQcJplNeTgTH0Pfi7vv1exTiBSEoKL 8047Ykzz6akGbQa8AS9UaNx8C5bbFcIe0dIbqKYxPXhBA4ctPhp4+mauy YlxGH3iOo0W+Nru/rGNYcTKWwnt+/TazL6JG8PdvFgTzTWT/7mVC5Q3BV g==; X-CSE-ConnectionGUID: YnSouguaS8CXgjDzxOrrsg== X-CSE-MsgGUID: QOp8QmyKSO6ATh4iGiPhag== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8367991" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="8367991" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 22:26:10 -0700 X-CSE-ConnectionGUID: C5u4CT8GQPuqUJPqS/69QA== X-CSE-MsgGUID: FVvE58jkRHibcVnbSTLe2A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="20764425" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Apr 2024 22:26:09 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Cc: pedro@palves.net Subject: [PATCH v2 1/6] gdb, btrace: fix pr19340 Date: Thu, 11 Apr 2024 05:25:59 +0000 Message-Id: <20240411052604.87893-2-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411052604.87893-1-markus.t.metzger@intel.com> References: <20240411052604.87893-1-markus.t.metzger@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP 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 0ef1dfbe652..1d946f9d3f2 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -414,11 +414,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.*" }