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