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.*" } From patchwork Thu Apr 11 05:26:00 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: 88327 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 63893384AB78 for ; Thu, 11 Apr 2024 05:26:59 +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 68548385840B for ; Thu, 11 Apr 2024 05:26:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 68548385840B 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 68548385840B 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=1712813175; cv=none; b=HLfuYvyEvz1zVfcD6tFDBoCZxBfYWUCdsVdePjY47XFho4lyN9iOONC0lfd+o9tpeIhHm8caYRr+sm0qK9+KhuWAkb/OAycuCqtTcaITKgshrLn7cD9miesbRI7m3bfFh36aiGMns6orw/+SaFRLTuXk7lHdZWtz/sXGgtgYhIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712813175; c=relaxed/simple; bh=GyjHhpRcC4HGF6czK/JPt1upnjxDSin9KKGgQx/giyE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Mq+zuVRdgo5KM8lO6fgIiR/g5UDCsvrlYErbGk82DiEJWmoosMaZjjKlFtMvQyHtyyP/gnc8pjxsgEZRfKb6avVXqxJrcKUq/fWaxLGDkE53dfuo2ukB7Dn6ll9Phra9YOgqn64JWvJOgh3r/Q4u0esHkl9bzFzNtd1dMbdNl6M= 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=1712813173; x=1744349173; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GyjHhpRcC4HGF6czK/JPt1upnjxDSin9KKGgQx/giyE=; b=JS1/ctzcWmk+OScViaUPP+iqSt2CjmAZknrqC2hwG9U/JZoUbH4xUN/9 QmNY309G4VipfdHN57AxWpg3bT2qrIrvxtuf7KIf5bRo6JKdEipiNswYs +bEa6lbel52NBcnmMhRMmBCsrWc5wIh73/71OqodDz8SX5h467/2ZVNBm 0LhdScswAFcuwU09JJvT2gPtiKKy5zK8+y3U2h8cJvYYR7yLzzOT2L6eT W22ENRrBcDVyhm/cNi28yO5kojwJ720jxskf5pFqwUOHK3o4i64T+bO46 Pj1A+CKOMB9/IJ7sejkRnCFo6g5Dyp/RGIMrRg8haf33eiWRdqX1Kq+aX w==; X-CSE-ConnectionGUID: +2jS9CQMSoW6ok6iMqUZ0g== X-CSE-MsgGUID: fTF9jFFURt2+w/Xto2n41Q== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8367996" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="8367996" 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:13 -0700 X-CSE-ConnectionGUID: dqPJ/aTFTjepYnFuw2pgPw== X-CSE-MsgGUID: qRtz1IKFStSrMBKtD29Baw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="20764459" 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:12 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Cc: pedro@palves.net Subject: [PATCH v2 2/6] gdb, btrace: simplify gdb.btrace/multi-inferior.exp Date: Thu, 11 Apr 2024 05:26:00 +0000 Message-Id: <20240411052604.87893-3-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.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 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 Apr 11 05:26:01 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: 88328 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 2CEBA384AB6A for ; Thu, 11 Apr 2024 05:27:09 +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 F0091384AB69 for ; Thu, 11 Apr 2024 05:26:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F0091384AB69 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 F0091384AB69 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=1712813178; cv=none; b=K35HkNExe80IWoXHZWcsjFWpG3IVR0pQ5ua4Qjl5vrnbkRvUk5RFTl/CIjJrJ1mwU4IbdVZ4+FgTKJwhWXZJ4zga+rf2bqwwCTKbJhr6SUVciJua+bhGjA015wZ/Oag/t5Mchvb03b+BnUYABsrUoITOyCsSSu4UcnlOm6aLpPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712813178; c=relaxed/simple; bh=tTekNDHsNDySJdkN2yMnYAoyyxXOUvYQtZNwWCIq/2c=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=JW6vIeP8konG4ey5WS1nAEzN9/vXNGjRTKDatJRKbshf3mWSWZdlZuqU4ph2TCgoTSwSz3HoD6sDdCAIcBktyuLCFVzeUTGYFUlGzCFCnOLklmtL0PonofqzOR2f9avBsQiqA/3+6e33MJKBOXSatJ9MOsN4ceUGpOfWh2bILpE= 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=1712813177; x=1744349177; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tTekNDHsNDySJdkN2yMnYAoyyxXOUvYQtZNwWCIq/2c=; b=e1by86FCSK/NoTKJ+8pDFaGhQZcA/ZRNRxgn9dqjovfsKx0fprqP1/jp p7NIMvkLcfk0BAgf1nJvwRpYfdrZ1Ykd88ZhNJDoBNy5h1zFkmcybqM2A 40UcVB9jyv2Kq7/PjKWGOiQTpnmcTniBfwUtI+2EJyRtN+ULeQ6CSPt1j OcsoQYYVTPtcA5JF7pWc+4Wn+93WkEMg1Kxlt0PylLD++xI+EcRBqshil gGze5I4Tjlnbv6IuMS2jSGHw4HLWM9PeBR32dfSgks43fxL51O9Kv8n8y ztjZjrNT0m8g/2ZJcuI7MKGm7gEdSLBvICDb6mpQJ3msgxR16nzspL5Rx g==; X-CSE-ConnectionGUID: ZzXXUmjcRnaqq+DXYE7x7A== X-CSE-MsgGUID: hUMerXEmRYKu3bG+sJER0g== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8368004" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="8368004" 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:16 -0700 X-CSE-ConnectionGUID: 0UJuZHNCSEa3m2HwHqrbLw== X-CSE-MsgGUID: kRciNfgFQO2yy8Nr36mOpA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="20764478" 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:15 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Cc: pedro@palves.net Subject: [PATCH v2 3/6] gdb, btrace: remove record_btrace_target::supports_*() Date: Thu, 11 Apr 2024 05:26:01 +0000 Message-Id: <20240411052604.87893-4-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.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 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 1d946f9d3f2..66f283b8680 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -130,10 +130,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; @@ -2706,18 +2703,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 @@ -2733,18 +2718,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 Apr 11 05:26:02 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: 88331 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 7A8FC384AB51 for ; Thu, 11 Apr 2024 05:27:42 +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 5D9AB384AB73 for ; Thu, 11 Apr 2024 05:26:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D9AB384AB73 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 5D9AB384AB73 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=1712813181; cv=none; b=hJIsETaLn2DF14Cb56xsS9ncNlXzfEIQsHAGJejgEzFVvmVKi1JZa45cukfWIvKyig/ngOFnVK0EahtRS1TZ/alyBiGXCJXOytupXQYPh5IVlU3HFHEYNhrWhD27L7lvVV9c3N6cSbwDbIKlH7L/8D8YzP1iNPAO+Rj9UdrF1o8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712813181; c=relaxed/simple; bh=kr35Jfn1gb/qX52gptfMtUB0qB1KdZ9kvWMq1HOJD9c=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=jxuNcqKtHNsPEfQ4NKL352aTN/7IVlgjOzlqNnv7Fl97DEyUM1lAG14XlXWczaRzTFdDp1xI2BeKrT78vCTzHHWTVY/HvQPWDPgElb/vcsaR/wtoEfHanig1jn+RflKGxRzjGpE8cnPb5/bZY0REs8iKt++K71wl8oBSvLmrcss= 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=1712813179; x=1744349179; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kr35Jfn1gb/qX52gptfMtUB0qB1KdZ9kvWMq1HOJD9c=; b=Yt3rquD+f2TFF9t8MUp9WrzPUhUMFR3mXaT5aLyOfrY95rQlm5p3LC1c Xy8i0BHd87TShHbY7cepe/Ay0ggIv5h4DkZ/ovThPnz7/xCCIUqlvRPkl UDgneY+fakmoP5JjiZ7lBshOKrHSl5rg9nntQinuQlDNmv3DhdWrKF597 OoJ9FAHwcIgiHHgkNXICsd4mbP5IoZbGS67A7eswB7n2/xtWVOP44phV8 jM3iIitCZpkEB47gJVOCdKvhyuy7JP/TnYJk4k94lg5mj4v4er12zoKEx kkkpaROJD39LK1FznPVCwtqeC0/zkfHoi9ZpWfGHCgppVYK511zqRw8TF Q==; X-CSE-ConnectionGUID: s376uxNsTQW00aOcSwo9QA== X-CSE-MsgGUID: rZTgFWWiQuizpVifz/UMOw== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8368008" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="8368008" 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:19 -0700 X-CSE-ConnectionGUID: HEa/8S18R1uowAQoVpuKAA== X-CSE-MsgGUID: MzPNx932SoCAu6T4+j7xsw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="20764533" 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:18 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Cc: pedro@palves.net Subject: [PATCH v2 4/6] gdb, btrace: set wait status to ignore if nothing is moving Date: Thu, 11 Apr 2024 05:26:02 +0000 Message-Id: <20240411052604.87893-5-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.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 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 66f283b8680..53ed481eb4d 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -2279,14 +2279,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; } @@ -2555,7 +2555,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 Apr 11 05:26:03 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: 88330 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 0056D3849AC2 for ; Thu, 11 Apr 2024 05:27:33 +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 644FE384AB42 for ; Thu, 11 Apr 2024 05:26:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 644FE384AB42 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 644FE384AB42 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=1712813185; cv=none; b=DP6xUVGPLhajhSQteDr45WKaAeruwc1Wl7YTw7Qpwv/IBoivQWpu6ag+HTQeXIs5N85GqRRIGXfdJJ9qKctvlqs/rt95VC11lYDcmHwpu78P/IedSPiWkU5xvfsgWBhzG3QlwncTka3kH5HsMrTNMLGimMekwAd1BVMOCvjShEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712813185; c=relaxed/simple; bh=BS4QG/VeP4C7CDcKg7hdyxddL6s+MvaV+wkOQ7axffQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ibQnfvqUkGxofowaNwWY+cmQiePWe9LuCLrLeT22oujzTXMneTm5UYhfQLcetXMN8p2paIisspBPrKgaSGF1VvZsA2eTC41r6zkWcbJVUOiNvoFQdmhM+dtDd1Edgk6MYq/mFoxIJ9sfYRyj+F9ciOeuqd+qqibt7PV1APvOqYo= 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=1712813182; x=1744349182; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BS4QG/VeP4C7CDcKg7hdyxddL6s+MvaV+wkOQ7axffQ=; b=TrfV2WIS0GRkKQafmbq0QNGeO7xvqqFLWzvFzr3JCcwD5AoMx9QFIp0o XsdzrwTJwfYm43sw0qA1hQ2FlspX3TuaX77jqhnIG6wlwhg6TbPp8pPht qRJwKZ0jDtOUwet4eGs93QFApYnWzVhlNxo0WWziVZN7KLamEc/1VW4N3 FYx5Xfa54aMGK6Frj3gSuvMbxsYCYjl4zmF3J1byTDG4DcP0Mfe7YGqcj Hk32GvpUrQvAf1w/O8WBNv2nZsXIUHS7P5rFNHjYDrE0bcv+02Lhm17FA dNCvnSoGJPOvnc9a6JSESQdjfq4fO75o6byqWi2E828xCwoy0WUa7hC7z A==; X-CSE-ConnectionGUID: ZmHB7mM8THCnxwXFm5iDpA== X-CSE-MsgGUID: 1pz+36q7TBiX6gs3tJokNQ== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8368012" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="8368012" 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:22 -0700 X-CSE-ConnectionGUID: HEIrFpzRQAWkdFYr1Ark0g== X-CSE-MsgGUID: Q51EXFSQSuqlp0nFe8om2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="20764558" 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:21 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Cc: pedro@palves.net Subject: [PATCH v2 5/6] gdb, infrun: fix silent inferior switch in do_target_wait() Date: Thu, 11 Apr 2024 05:26:03 +0000 Message-Id: <20240411052604.87893-6-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.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 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. In some cases, e.g. gdb.threads/detach-step-over.exp, we ask to wait for one inferior, and get an event from a different inferior back without noticing the inferior switch. Wait for a single inferior, instead. Since we iterate over all inferiors, we still cover everything. This exposes another bug with STOP_QUIETLY_NO_SIGSTOP handling. After attaching, we interrupt all threads in the new inferior, then call do_target_wait() to receive the stopped events. This randomly selects an inferior to start waiting for and iterates over all inferiors starting from there. The initial stop event for the main thread is already queued up, so we wouldn't actually wait() if we had started with the new inferior. Or if we had waited for minus_one_ptid, which would then have silently switched inferiors. Since we no longer allow that, we may actually wait() for the new inferior and find other events to report, out of which we randomly select one. If we selected an event for another thread, e.g. one that had been interrupted as part of non-stop attach, STOP_QUIETLY_NO_SIGSTOP would be applied to that thread (unnecessarily), leaving the main thread with a SIGSTOP event but last_resume_kind = 0 (resume_continue). When the main thread is later selected, SIGSTOP is reported to the user. Normally, linux-nat's wait() turns the SIGSTOP it uses for interrupting threads into GDB_SIGNAL_0. This is based on last_resume_kind, which is set to 2 (resume_stop) when sending SIGSTOP to interrupt a thread. We do this for all threads of the new inferior when interrupting them as part of non-stop attach. Except for the main thread, which we expect to be reported before the first wait(). Set last_resume_kind to resume_stop for the main thread after attaching. --- gdb/infrun.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- gdb/linux-nat.c | 17 ++++++++++++----- gdb/remote.c | 22 +++++++++++++++++----- 3 files changed, 72 insertions(+), 13 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index a5030b16376..9ca0571065c 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4198,7 +4198,23 @@ do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, auto do_wait = [&] (inferior *inf) { - ecs->ptid = do_target_wait_1 (inf, wait_ptid, &ecs->ws, options); + ptid_t ptid { inf->pid }; + + /* Make sure we're not widening WAIT_PTID. */ + if (!ptid.matches (wait_ptid) + /* 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. Fall back to waiting for + WAIT_PTID in that case. */ + || !target_can_async_p () || ((options & TARGET_WNOHANG) == 0) + /* FIXME: I don't see why we should have inferiors with zero pid, + which indicates that the respective ptid is not a process. + They do exist, though, and we cannot wait for them. */ + || !ptid.is_pid ()) + ptid = wait_ptid; + + ecs->ptid = do_target_wait_1 (inf, ptid, &ecs->ws, options); ecs->target = inf->process_target (); return (ecs->ws.kind () != TARGET_WAITKIND_IGNORE); }; @@ -4208,6 +4224,12 @@ do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, reported the stop to the user, polling for events. */ scoped_restore_current_thread restore_thread; + /* The first TARGET_WAITKIND_NO_RESUMED execution state. + + If we do not find a more interesting event, we will report that. */ + execution_control_state no_resumed {}; + no_resumed.ptid = null_ptid; + intrusive_list_iterator start = inferior_list.iterator_to (*selected); @@ -4218,7 +4240,13 @@ do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, inferior *inf = &*it; if (inferior_matches (inf) && do_wait (inf)) - return true; + { + if (ecs->ws.kind () != TARGET_WAITKIND_NO_RESUMED) + return true; + + if (no_resumed.ptid == null_ptid) + no_resumed = *ecs; + } } for (intrusive_list_iterator it = inferior_list.begin (); @@ -4228,7 +4256,19 @@ do_target_wait (ptid_t wait_ptid, execution_control_state *ecs, inferior *inf = &*it; if (inferior_matches (inf) && do_wait (inf)) - return true; + { + if (ecs->ws.kind () != TARGET_WAITKIND_NO_RESUMED) + return true; + + if (no_resumed.ptid == null_ptid) + no_resumed = *ecs; + } + } + + if (no_resumed.ptid != null_ptid) + { + *ecs = no_resumed; + return true; } ecs->ws.set_ignore (); diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 2602e1f240d..06b39d67a72 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -1154,6 +1154,7 @@ linux_nat_target::attach (const char *args, int from_tty) /* Add the initial process as the first LWP to the list. */ lp = add_initial_lwp (ptid); + lp->last_resume_kind = resume_stop; status = linux_nat_post_attach_wait (lp->ptid, &lp->signalled); if (!WIFSTOPPED (status)) @@ -3329,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. */ diff --git a/gdb/remote.c b/gdb/remote.c index a09ba4d715d..49abd4e4376 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7825,12 +7825,24 @@ remote_target::remote_notif_remove_queued_reply (ptid_t ptid) { remote_state *rs = get_remote_state (); + auto pred = [=] (const stop_reply_up &event) + { + /* A null ptid should only happen if we have a single process. It + wouldn't match the process ptid, though, so let's check this case + separately. */ + if ((event->ptid == null_ptid) && ptid.is_pid ()) + return true; + + /* A minus one ptid should only happen for events that match + everything. It wouldn't match a process or thread ptid, though, so + let's check this case separately. */ + if (event->ptid == minus_one_ptid) + return true; + + return event->ptid.matches (ptid); + }; auto iter = std::find_if (rs->stop_reply_queue.begin (), - rs->stop_reply_queue.end (), - [=] (const stop_reply_up &event) - { - return event->ptid.matches (ptid); - }); + rs->stop_reply_queue.end (), pred); stop_reply_up result; if (iter != rs->stop_reply_queue.end ()) { From patchwork Thu Apr 11 05:26:04 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: 88329 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 2A5F0385841E for ; Thu, 11 Apr 2024 05:27:31 +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 07CD6384AB65 for ; Thu, 11 Apr 2024 05:26:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 07CD6384AB65 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 07CD6384AB65 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=1712813189; cv=none; b=luVR0B2AEmQ1c1X9iWOzyUqtsGpurL/Dp5EbTTDMUWHDYIm+JEbqcYKsQTK4SMhUs5xsBOoQtYYqQL2hrlKy9HCR5InhmODfEZgthS3gBIyYlYgbfhA4B+rpO9enirKWc5701guuKjCWg4ygKtLwkmAQJI7NS2HcXWOUZLdQPRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712813189; c=relaxed/simple; bh=hRcHYMj1KdX25AfxHff++YpXQxB354BgrHZahnQWzpQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=fvKcxtmea+n3w2JSTC3mJxbScCK8KS8TOc1ixDN0obP7eOTSB8ysZE9oYPWyIXujjSib2hXQls44xPyoRXVxGc0WUopstZWGLu61bifx+b3s54kJ+KX7RgY1pV7S3sipMtvdvjemSWcrLuaGispn5w0ZDjjv3vdMGKU8WRBuKwg= 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=1712813187; x=1744349187; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=hRcHYMj1KdX25AfxHff++YpXQxB354BgrHZahnQWzpQ=; b=PdVTRFka3vJMAXSNHAiuE2dfmMQm6pJlEthREEvuBW422meMnJF8NBGU pWERSpTKszSzDnEUgKCjiElN1tDdh8dwJI+GiY0qM3UDkZX73QABt/mpI 6xIVXgwa/b5SzAnb6dMJRrn/U/uzsTrcEyoSg4qUu721kggQb/OoDiBYG 8JvmtNo17tbxSNXZ5bl6quzMn82SlZJDCiZEY+HpOIEj00pW1Y6XmegNB N9u/2n+lgW8F+gqzInIVftx5BYgFAJLg4hwvFV7GJROR0b+C+Ti/jat3r ArJPJq7sQtsH4Cz54qt95iH/znNGCrm17deQlxXZ+z6viMYPrKpXzRpAH w==; X-CSE-ConnectionGUID: gg7BRDnOThyWpWOcUB91dQ== X-CSE-MsgGUID: ReTy6a3MTtaRG/MIiQC64w== X-IronPort-AV: E=McAfee;i="6600,9927,11039"; a="8368022" X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="8368022" 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:25 -0700 X-CSE-ConnectionGUID: Zv6OfZytQoKnKtJfG7vuqg== X-CSE-MsgGUID: ji/kpRYtTva5m9ynYC4VWA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,192,1708416000"; d="scan'208";a="20764573" 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:24 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Cc: pedro@palves.net Subject: [PATCH v2 6/6] gdb, btrace, infrun: per-inferior run-control Date: Thu, 11 Apr 2024 05:26:04 +0000 Message-Id: <20240411052604.87893-7-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.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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 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 9ca0571065c..a237d970030 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2399,7 +2399,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. */ @@ -3117,15 +3118,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); @@ -3204,7 +3207,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 53ed481eb4d..3f9e19b1a02 100644 --- a/gdb/record-btrace.c +++ b/gdb/record-btrace.c @@ -121,7 +121,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; @@ -2159,7 +2158,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; @@ -2542,7 +2541,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); } @@ -2663,7 +2662,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); } @@ -2693,7 +2692,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 (); @@ -2708,7 +2707,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 (); @@ -2718,26 +2717,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" }