From patchwork Fri Dec 29 10:41:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Natalia Saiapova X-Patchwork-Id: 82997 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 74A653858C36 for ; Fri, 29 Dec 2023 10:43:39 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by sourceware.org (Postfix) with ESMTPS id 77EDE3858D39 for ; Fri, 29 Dec 2023 10:42:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 77EDE3858D39 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 77EDE3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.126 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846555; cv=none; b=Q8aOPFCW7aNnHPcj8W55IG/jUjeBNO6rDM/qLsg4Qf2VzC9A59OaezFvENP2b+kYYhmzfsTN4ukKy6qvo74M3vQLmUP8PMvZlcnihf2djenMdMiqHb8xbt/8fGut9OYxc5la6REbd613af/U4J6gViJgBR/eNNbpekbj/Mg4UTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846555; c=relaxed/simple; bh=Pq7AKFZEU+3E0KI0BmwhTDNc9QO3aXOJrXAgmgmDlaM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=tKQ7Xavvh62+kh6zv1qpaGmCZiuNUWKB2UzNC7vXqepA/G9x+J7nrnb0J3Rbi5stwGbe56kglQ9+HqMlU7hUd/lq9atIzlrxn7Yv7kkIcgv7ZSuK6HFABNu8zEes0pChFF1F8HKDwtJGNeBc8tk0yA+KjCn5/lOcX+Snef5zsNY= 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=1703846553; x=1735382553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Pq7AKFZEU+3E0KI0BmwhTDNc9QO3aXOJrXAgmgmDlaM=; b=DYAiYQ3TY/DBCwLCaohzaLVQhQg6cPAcVJC1ii0OH4iW6LLcyCbjb2Gp h2jsHdsbmSKkXIdP1qr8+1QLu+XLET1OHn9SjazauMvuuIg4r+wd6ryBL GUEhBhy2tbInHAfosx+Ah59G0DRWbgnrZB2NLEtwDUQsJgHWXVi8g4wk2 68b/voyc+c1GolFnr6rF/T/PJ39Fhb15q8PA6kP9fV4JO1MDAs56pTnX3 dgEw2YDUhu66NzyCmfJH0ssid+oE+4yFuBOOjnlB3483hS01YDAJrWC7F KOIQZ5RJTnt5QL0F1kBngbb37EQvgJawzFU0KRjRM4IUGkaGU+xGCfg83 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="381613088" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="381613088" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:42:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="755000241" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="755000241" Received: from unknown (HELO localhost) ([10.211.177.238]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:42:30 -0800 From: Natalia Saiapova To: gdb-patches@sourceware.org Cc: tankut.baris.aktemur@intel.com Subject: [PATCH 1/6] gdb: use schedlock_applies in user_visible_resume_ptid. Date: Fri, 29 Dec 2023 10:41:57 +0000 Message-Id: <20231229104202.7878-2-natalia.saiapova@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231229104202.7878-1-natalia.saiapova@intel.com> References: <20231229104202.7878-1-natalia.saiapova@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 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 This is a refactoring. The logic in user_visible_resume_ptid is very similar to schedlock_applies, but uses `step` parameter instead of `tp->control.stepping_command`. Refactor schedlock_applies logic into the following two methods: bool schedlock_applies_to_thread (thread_info *tp) and bool schedlock_applies (bool step) such that they share the logic. Update the call-sites accordingly, where we have only the thread, use the former, and where we have the bool step, use the latter. --- gdb/infrun.c | 49 +++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 1d863896c40..e10bde94744 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -107,7 +107,9 @@ static bool start_step_over (void); static bool step_over_info_valid_p (void); -static bool schedlock_applies (struct thread_info *tp); +static bool schedlock_applies_to_thread (thread_info *tp); + +static bool schedlock_applies (bool step); /* Asynchronous signal handler registered as event loop source for when we have pending events ready to be passed to the core. */ @@ -1970,7 +1972,7 @@ any_thread_needs_target_thread_events (process_stratum_target *target, { for (thread_info *tp : all_non_exited_threads (target, resume_ptid)) if (displaced_step_in_progress_thread (tp) - || schedlock_applies (tp) + || schedlock_applies_to_thread (tp) || tp->thread_fsm () != nullptr) return true; return false; @@ -1983,7 +1985,7 @@ static void update_thread_events_after_step_over (thread_info *event_thread, const target_waitstatus &event_status) { - if (schedlock_applies (event_thread)) + if (schedlock_applies_to_thread (event_thread)) { /* If scheduler-locking applies, continue reporting thread-created/thread-cloned events. */ @@ -2383,6 +2385,9 @@ ptid_t user_visible_resume_ptid (int step) { ptid_t resume_ptid; + thread_info *tp = nullptr; + if (inferior_ptid != null_ptid) + tp = inferior_thread (); if (non_stop) { @@ -2390,20 +2395,12 @@ user_visible_resume_ptid (int step) individually. */ resume_ptid = inferior_ptid; } - else if ((scheduler_mode == schedlock_on) - || (scheduler_mode == schedlock_step && step)) + else if (schedlock_applies (step)) { /* User-settable 'scheduler' mode requires solo thread resume. */ resume_ptid = inferior_ptid; } - else if ((scheduler_mode == schedlock_replay) - && target_record_will_replay (minus_one_ptid, execution_direction)) - { - /* User-settable 'scheduler' mode requires solo thread resume in replay - mode. */ - resume_ptid = inferior_ptid; - } else if (!sched_multi && target_supports_multi_process ()) { /* Resume all threads of the current process (and none of other @@ -2574,7 +2571,7 @@ do_target_resume (ptid_t resume_ptid, bool step, enum gdb_signal sig) */ if (step_over_info_valid_p () || displaced_step_in_progress_thread (tp) - || schedlock_applies (tp)) + || schedlock_applies_to_thread (tp)) { gdb_thread_options options = GDB_THREAD_OPTION_CLONE | GDB_THREAD_OPTION_EXIT; @@ -3185,15 +3182,23 @@ thread_still_needs_step_over (struct thread_info *tp) return what; } +/* Returns true if scheduler locking applies to TP. */ + +static bool +schedlock_applies_to_thread (thread_info *tp) +{ + bool step = (tp != nullptr) && tp->control.stepping_command; + return schedlock_applies (step); +} + /* Returns true if scheduler locking applies. STEP indicates whether - we're about to do a step/next-like command to a thread. */ + we're about to do a step/next-like command. */ static bool -schedlock_applies (struct thread_info *tp) +schedlock_applies (bool step) { return (scheduler_mode == schedlock_on - || (scheduler_mode == schedlock_step - && tp->control.stepping_command) + || (scheduler_mode == schedlock_step && step) || (scheduler_mode == schedlock_replay && target_record_will_replay (minus_one_ptid, execution_direction))); @@ -3690,7 +3695,7 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) /* If scheduler locking applies, we can avoid iterating over all threads. */ - if (!non_stop && !schedlock_applies (cur_thr)) + if (!non_stop && !schedlock_applies_to_thread (cur_thr)) { for (thread_info *tp : all_non_exited_threads (resume_target, resume_ptid)) @@ -5938,7 +5943,7 @@ handle_thread_exited (execution_control_state *ecs) } inferior *inf = ecs->event_thread->inf; - bool slock_applies = schedlock_applies (ecs->event_thread); + bool slock_applies = schedlock_applies_to_thread (ecs->event_thread); delete_thread (ecs->event_thread); ecs->event_thread = nullptr; @@ -6377,7 +6382,7 @@ handle_inferior_event (struct execution_control_state *ecs) /* If resuming the child, mark it running. */ if ((ecs->ws.kind () == TARGET_WAITKIND_THREAD_CLONED - && !schedlock_applies (ecs->event_thread)) + && !schedlock_applies_to_thread (ecs->event_thread)) || (ecs->ws.kind () != TARGET_WAITKIND_THREAD_CLONED && (follow_child || (!detach_fork && (non_stop || sched_multi))))) @@ -6386,7 +6391,7 @@ handle_inferior_event (struct execution_control_state *ecs) /* In non-stop mode, also resume the other branch. */ if ((ecs->ws.kind () == TARGET_WAITKIND_THREAD_CLONED && target_is_non_stop_p () - && !schedlock_applies (ecs->event_thread)) + && !schedlock_applies_to_thread (ecs->event_thread)) || (ecs->ws.kind () != TARGET_WAITKIND_THREAD_CLONED && (!detach_fork && (non_stop || (sched_multi @@ -8249,7 +8254,7 @@ switch_back_to_stepped_thread (struct execution_control_state *ecs) current thread is stepping. If some other thread not the event thread is stepping, then it must be that scheduler locking is not in effect. */ - if (schedlock_applies (ecs->event_thread)) + if (schedlock_applies_to_thread (ecs->event_thread)) return false; /* Otherwise, we no longer expect a trap in the current thread. From patchwork Fri Dec 29 10:41:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Natalia Saiapova X-Patchwork-Id: 82998 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 09180385841F for ; Fri, 29 Dec 2023 10:44:03 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by sourceware.org (Postfix) with ESMTPS id 7768F3858403 for ; Fri, 29 Dec 2023 10:42:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7768F3858403 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 7768F3858403 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.126 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846570; cv=none; b=pPOz48JfLVVfojP0pRMQkndaFvCfsagnl4EVVDr5WzIbiDc4cUJsCgFDSplE+Yn9GsKWQuwyIS42ML8j3dGq8Tyj56RMfmQdSYpqSOUY8U0a5AocUYEM93Z3kVq85yegWQ4PJSXkel66MMHQ/D7ZMvYmFZIN9Od4jctWEkhLw0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846570; c=relaxed/simple; bh=W1uarJYGjqAAPCn1vZ3ni2pWeizVTYpvLYVrUSDisCo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=sXOQVKbVHFxmG5L73g/mEg7HMiiazSTz858jjcub7tLdh1/421YopGgJ9XH+CAZ73xGdNHZxz7tCeuJP/Xa2tzSuoxjOGr6Nlvp3i9gqXkMO1ujG2jHNHzPdrhYEtNzVQYDYDtEsASayr/7s4aSCeRAPdcrMsSpkFSbYUcAxUMk= 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=1703846564; x=1735382564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W1uarJYGjqAAPCn1vZ3ni2pWeizVTYpvLYVrUSDisCo=; b=jW3SA7LtFF+EEL4hvmzO/zeSaoPaEkYlLHQfRQWhhehqmnZYiH7AVv2H mZSvuP4FeUCnHCGfv33BL5tfceqG7SK1l0d0mAJCRxLaQzqCQVXJEV4rq cokIT0fLv73QHavHhGdUsD4ShHhwItPt3Cya1jpy36U1HOvYfV8uW8pUp e7Jw/Hnl0Q08dUwfKWid0Rxi4Sgaky1rzrYWh0zveaZvpSDrSdOiTQYwA /NEkTZVM0JJZi0AjFkQyJesj+Xd/1Nx6QcKLYwOw+dLivGWIH+y9VuyOO EwmL4SSObfWu6wmlVhN/0P5En2k0C/MPAN6ptec3eIBTKaQe4tyH+yger A==; X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="381613094" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="381613094" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:42:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="27111955" Received: from unknown (HELO localhost) ([10.211.177.238]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:42:43 -0800 From: Natalia Saiapova To: gdb-patches@sourceware.org Cc: tankut.baris.aktemur@intel.com Subject: [PATCH 2/6] gdb, cli: remove left-over code from "set_logging_on". Date: Fri, 29 Dec 2023 10:41:58 +0000 Message-Id: <20231229104202.7878-3-natalia.saiapova@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231229104202.7878-1-natalia.saiapova@intel.com> References: <20231229104202.7878-1-natalia.saiapova@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 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 This is a refactoring. Remove the left-over code, which rewrites the logging filename in "set logging on" command. The code became unused after the deprecation of "set logging (on|off)" command. Before the deprecation, the command could also take a file name and rewrite the logging file, e.g.: (gdb) set logging on lalala Copying output to lalala. Copying debug output to lalala. After the command was deprecated and reimplemented as an alias to "set logging enable on", additional input after "on" became invalid: (gdb) set logging on lalala Warning: 'set logging on', an alias for the command 'set logging enabled', is deprecated. Use 'set logging enabled on'. "on" or "off" expected. (gdb) set logging on lalala "on" or "off" expected. (gdb) set logging enable on lalala "on" or "off" expected. (gdb) set logging enable on Copying output to gdb.txt. Copying debug output to gdb.txt. --- gdb/cli/cli-logging.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c index a74e43034e8..e2ce0262538 100644 --- a/gdb/cli/cli-logging.c +++ b/gdb/cli/cli-logging.c @@ -160,11 +160,6 @@ handle_redirections (int from_tty) static void set_logging_on (const char *args, int from_tty) { - const char *rest = args; - - if (rest && *rest) - logging_filename = rest; - handle_redirections (from_tty); } From patchwork Fri Dec 29 10:41:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Natalia Saiapova X-Patchwork-Id: 82999 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 CF8CD3858421 for ; Fri, 29 Dec 2023 10:44:32 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by sourceware.org (Postfix) with ESMTPS id CE5433858D33 for ; Fri, 29 Dec 2023 10:42:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE5433858D33 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 CE5433858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.126 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846576; cv=none; b=An5YiQMErUnixEdCIRoJzhgLTC6HxxBMYrVnwasLP3hTQW6VXYhSk36g4cIAz2pbYmIfbFzSbI/jsKazoCJ3KoG5jJO53CIw+tL+vD/6WbHZb2U6i1g6cNC6jBzO6G3Mb3k4lflVNm4rSpP6VxbGUyGTKdBGFHEQ3MlPQAxjbi4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846576; c=relaxed/simple; bh=FUNLfRXHyK4Thi3ut3u9HuoFXn+mXjzdgx04Fu95hM8=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=RKzGQFLbQFWEQIgD+BneqXuDgf4FxSGepY3mwVpQaJLPcvNEhhjgNqocUdI3xAZ6ieZefwGfeYE78XrxJ289XdKEoeNqoeAq0CebXruKvf4eQdEdBv9ZYD/unNjS0E+LeqVNNIdyLDN2SDGxKYGZShOjgnsko9T3WgctOEQplwg= 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=1703846573; x=1735382573; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FUNLfRXHyK4Thi3ut3u9HuoFXn+mXjzdgx04Fu95hM8=; b=EJwI3mHHViGbWZb+KooiUjsA+xRW1SK1On6XRptZNC37HFJA/GWbqMXg 46+xlqjnuprYd9YpKnxwtI6asIhpALYpotDHuXn9hNCK0f6J71gwbDh4C QaP4446RtQJc/YDus1huJI6gubFKVFg73NAU81wCxNt4wXGdYg9v5YmeA u8SkJe2wtP3ceDvDQ6nIdv/aIOKd4xfxkiCDwU7i6VpMrYb0Lk+OrqlOG wxVIjMJgNn8XF46Stb5u+h15ZwgXGNJap7ZrlhS6+7ET7G82PW1bUQ7uc 7yq1hZ6NEAUYv1fUiDnM6zPYwX4hZYfnMN1nq8fb88zKaLhXjbMZi+u8A w==; X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="381613099" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="381613099" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:42:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="27111991" Received: from unknown (HELO localhost) ([10.211.177.238]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:42:53 -0800 From: Natalia Saiapova To: gdb-patches@sourceware.org Cc: tankut.baris.aktemur@intel.com Subject: [PATCH 3/6] gdb, cli: pass the argument of a set command to its callback. Date: Fri, 29 Dec 2023 10:41:59 +0000 Message-Id: <20231229104202.7878-4-natalia.saiapova@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231229104202.7878-1-natalia.saiapova@intel.com> References: <20231229104202.7878-1-natalia.saiapova@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.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 This might be useful, if some commands need to have a special case if run w/o arguments. --- gdb/cli/cli-setshow.c | 2 +- gdb/infrun.c | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 11f93068b68..158425a9df1 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -448,7 +448,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) error (_("gdb internal error: bad var_type in do_setshow_command")); } - c->func (NULL, from_tty, c); + c->func (arg, from_tty, c); if (notify_command_param_changed_p (option_changed, c)) { diff --git a/gdb/infrun.c b/gdb/infrun.c index e10bde94744..b8feef6bc2d 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2385,9 +2385,6 @@ ptid_t user_visible_resume_ptid (int step) { ptid_t resume_ptid; - thread_info *tp = nullptr; - if (inferior_ptid != null_ptid) - tp = inferior_thread (); if (non_stop) { From patchwork Fri Dec 29 10:42:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Natalia Saiapova X-Patchwork-Id: 83000 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 120E93858402 for ; Fri, 29 Dec 2023 10:44:57 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id C525B3858C35 for ; Fri, 29 Dec 2023 10:43:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C525B3858C35 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 C525B3858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.100 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846590; cv=none; b=tQpSS331/S8x9G1fsJ17+vduoSCqRjfd92YHfDgQSmEBS32df5RtPOAH/RLlqWh3zALCHF7vGjDRwjjvKyxb3CBXwTbSfLXTw444acawCn2zAZvk/LZPI0viamvFPEEsga0e7WACxSdxJ9ccx43tm023cbkBK5PLzdBTB8SFX84= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846590; c=relaxed/simple; bh=z8I2iRYLWQA4Pipevh290/DhrgEfLBz07CrwB8cRutE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=SIze6wa1KjOHVx9IEotC8+Vl9N1cMMbvKs8nU8LAG3jiXXjUQtJDT7UhY7i86iIc2rM8kuDNqvU7FWdadE7gaX3+BJmhHWZq3E726shyIS6n4mWnmd8vgw9P9cm1Xd7QWRMFx4yEQHr2PADzPXPF8CoF9PDJQJAs2vKFr1IMPV8= 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=1703846586; x=1735382586; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z8I2iRYLWQA4Pipevh290/DhrgEfLBz07CrwB8cRutE=; b=h895esNy4ovTjXdVnC6aar+pp2fP9l6YiRyVF1sqPEzRteIeVKYSm3eN FzGXZTkV62/QG10SpJmyG8Sqh3Df2PRs+Ig0AHoZ/r/Mw73+BSu37L9VJ LrY1ZRWgP4iUgJBYWWFMnOsgBoIl0K71tAUkauhYFtphwST7DsuggtbSR 6RYv6SOrrmUR1HJ2AHLAmnWxMkCIm4z+3zP0uKTbF8OBpLmym0VuFvkuh QpLWCrUHS2xsuMZjytq8Iq75e5CEuefynXs0I/R/6Iexxq0ErqpdbBcNV F5L8n1raGjQkZH+E50vhvKGou4Z8ZBcOU1epIomvcshVa30/Jx2vn5njF w==; X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="463052609" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="463052609" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:43:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="782281308" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="782281308" Received: from unknown (HELO localhost) ([10.211.177.238]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:43:04 -0800 From: Natalia Saiapova To: gdb-patches@sourceware.org Cc: tankut.baris.aktemur@intel.com Subject: [PATCH 4/6] gdb: change the internal representation of scheduler locking. Date: Fri, 29 Dec 2023 10:42:00 +0000 Message-Id: <20231229104202.7878-5-natalia.saiapova@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231229104202.7878-1-natalia.saiapova@intel.com> References: <20231229104202.7878-1-natalia.saiapova@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.3 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 Introduce a new structure to manage different options of the scheduler locking. The options can coexist together and be set individually. In the next patch gdb: add commands to control scheduler locking. we introduce the commands to control these options. In this patch we do not introduce new commands and keep the previous API. New scheduler locking options are: replay run -- control non-stepping commands during replay mode. replay step -- control stepping commands during replay mode. run -- control non-stepping commands during normal exection. step -- control stepping commands during normal exection. Internally they hold a bool value, when true the locking is enabled. Mapping to the old settings Old Settings | New settings ----------------------------------- off | all are false | replay | run = false, step = false, | replay run = true, replay step = true | step | run = false, step = true, | replay run = false, replay step = true | on | all are true --- gdb/infrun.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 115 insertions(+), 7 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index b8feef6bc2d..f70f615abf8 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -111,6 +111,11 @@ static bool schedlock_applies_to_thread (thread_info *tp); static bool schedlock_applies (bool step); +struct schedlock_options; + +static bool schedlock_applies_to_opts (const schedlock_options &opts, + bool step); + /* Asynchronous signal handler registered as event loop source for when we have pending events ready to be passed to the core. */ static struct async_event_handler *infrun_async_inferior_event_token; @@ -2322,7 +2327,69 @@ infrun_thread_ptid_changed (process_stratum_target *target, inferior_ptid = new_ptid; } - +/* A structure to hold scheduler locking settings for + a mode, replay or normal. */ +struct schedlock_options +{ + struct option { + const std::string name; + bool value; + + option () = delete; + option (std::string name, bool value) + : name (std::move (name)), value (value) + {} + + /* Forbid accidential copying. */ + option (const option &) = delete; + option operator= (const option &) = delete; + option (option &&) = default; + option &operator= (option &&) = default; + + operator bool () const { return value; } + const char *c_str () const { return value ? "on" : "off"; } + /* Set new value. Return true, if the value has changed. */ + bool set (bool new_value); + }; + + schedlock_options () = delete; + schedlock_options (option run, option step) + : run (std::move (run)), step (std::move (step)) + {} + + /* Forbid accidential copying. */ + schedlock_options (const schedlock_options &) = delete; + schedlock_options operator= (const schedlock_options &) = delete; + schedlock_options (schedlock_options &&) = default; + schedlock_options &operator= (schedlock_options &&) = default; + + /* If true, the scheduler is locked during non-stepping. */ + option run; + /* If true, the scheduler is locked during stepping. */ + option step; +}; + +bool +schedlock_options::option::set (bool new_value) +{ + if (value != new_value) + { + value = new_value; + return true; + } + + return false; +} + +struct schedlock +{ + schedlock (schedlock_options opt, schedlock_options replay_opt) + : normal (std::move (opt)), replay (std::move (replay_opt)) + {} + + schedlock_options normal; + schedlock_options replay; +}; static const char schedlock_off[] = "off"; static const char schedlock_on[] = "on"; @@ -2335,7 +2402,34 @@ static const char *const scheduler_enums[] = { schedlock_replay, nullptr }; + static const char *scheduler_mode = schedlock_replay; + +schedlock schedlock {{{"run", false}, {"step", false}}, + {{"replay run", true}, {"replay step", true}}}; + +/* A helper function to set scheduler locking shortcuts: + set scheduler-locking on: all options are on. + set scheduler-locking off: all options are off. + set scheduler-locking replay: only replay options are on. + set scheduler-locking step: only "step" and "replay step" are on. */ + +static void +set_schedlock_shortcut_option (const char *shortcut) +{ + bool is_on = (shortcut == schedlock_on); + bool is_step = (shortcut == schedlock_step); + bool is_replay = (shortcut == schedlock_replay); + bool is_off = (shortcut == schedlock_off); + /* Check that we got a valid shortcut option. */ + gdb_assert (is_on || is_step || is_replay || is_off); + + schedlock.normal.run.set (is_on); + schedlock.normal.step.set (is_on || is_step); + schedlock.replay.run.set (is_on || is_replay); + schedlock.replay.step.set (is_on || is_replay || is_step); +} + static void show_scheduler_mode (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) @@ -2352,9 +2446,13 @@ set_schedlock_func (const char *args, int from_tty, struct cmd_list_element *c) if (!target_can_lock_scheduler ()) { scheduler_mode = schedlock_off; + /* Set scheduler locking off. */ + set_schedlock_shortcut_option (schedlock_off); error (_("Target '%s' cannot support this command."), target_shortname ()); } + + set_schedlock_shortcut_option (scheduler_mode); } /* True if execution commands resume all threads of all processes by @@ -3102,7 +3200,7 @@ 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. */ - if (!non_stop && scheduler_mode == schedlock_replay + if (!non_stop && schedlock_applies_to_opts (schedlock.replay, step) && target_record_is_replaying (minus_one_ptid) && !target_record_will_replay (user_visible_resume_ptid (step), execution_direction)) @@ -3179,6 +3277,17 @@ thread_still_needs_step_over (struct thread_info *tp) return what; } +/* Return true if OPTS lock the scheduler. + STEP indicates whether a thread is about to step. + Note, this does not take into the account the mode (replay or + normal execution). */ + +static bool +schedlock_applies_to_opts (const schedlock_options &opts, bool step) +{ + return ((opts.run && !step) || (opts.step && step)); +} + /* Returns true if scheduler locking applies to TP. */ static bool @@ -3194,11 +3303,10 @@ schedlock_applies_to_thread (thread_info *tp) static bool schedlock_applies (bool step) { - return (scheduler_mode == schedlock_on - || (scheduler_mode == schedlock_step && step) - || (scheduler_mode == schedlock_replay - && target_record_will_replay (minus_one_ptid, - execution_direction))); + bool is_replay = target_record_will_replay (minus_one_ptid, + execution_direction); + schedlock_options &opts = is_replay ? schedlock.replay : schedlock.normal; + return schedlock_applies_to_opts (opts, step); } /* Set process_stratum_target::COMMIT_RESUMED_STATE in all target From patchwork Fri Dec 29 10:42:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Natalia Saiapova X-Patchwork-Id: 83001 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 E4A303858408 for ; Fri, 29 Dec 2023 10:45:01 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id D136D3858C41 for ; Fri, 29 Dec 2023 10:43:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D136D3858C41 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 D136D3858C41 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.100 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846602; cv=none; b=WEX92E8MMKdn9LzZd+A1LPEzcPr0rpxl2hfAXk45JMZ8WxDziVBHOfQWGiMiLBKzuB+2R6QBsehlULGdRiYbr+ms6AhxRF2R0XhXA7+xXQPHhty7BDNRUKO+rFrQCA3atdIKZxEnKzy5mA2Vxtn2c2v2f50+TZ1JmtAOJ3Fbj2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846602; c=relaxed/simple; bh=rlAmW/FJZ+Mx8ZqCBrbRQcrQmzokFBxSeTfbNv5OJNE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=iggM6P4Nqkbl+E4vvhPOrCOuOwYVpsGoaJMJQVkREN9zJDiIpqRq3d5CzX3yddVIJUIXqmAZHnaGIRydIcfqskSHZ4e7MtttKtQdEWVYUKML/LQnHYbR/qVVh0NLX79zTfQQO9RvQ9nQvqpnumMYfOsSdp78oUdumMdm6sUer3o= 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=1703846596; x=1735382596; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rlAmW/FJZ+Mx8ZqCBrbRQcrQmzokFBxSeTfbNv5OJNE=; b=EJ6xKru0bz5qeVn9pJix+qwxYebUTAD0EaK/oxqqfoDmk9Ya/xuDU35Z EizT7yprO9XLNf0zlAj+OnEnCVQvx4tPmJm8XEzCm/2W7Is0Sq8BnAV59 AJQh9fJKppy55oR4VuDWudbTbAQ+OuZEWKS06xvhNWUiqn4bQDr7CDTPn RfMDfHTHWfKygUKR1Ugv53sEMJ7FTAgWxwJAB+OZXJYULkxV/O7AoE4+S mjVjaTlifMRJUupdJWPZlNNjRQP3kqARE8N3K8nlQDk6DaDYHTBSU6YV5 cPa+YBRpKmxZs5qKHRJr1Pl42WxTfs5X13yTu7ZiTG+QXjl4Mtn4uyKbc w==; X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="463052616" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="463052616" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:43:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="782281328" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="782281328" Received: from unknown (HELO localhost) ([10.211.177.238]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:43:14 -0800 From: Natalia Saiapova To: gdb-patches@sourceware.org Cc: tankut.baris.aktemur@intel.com Subject: [PATCH 5/6] gdb: add commands to control scheduler locking. Date: Fri, 29 Dec 2023 10:42:01 +0000 Message-Id: <20231229104202.7878-6-natalia.saiapova@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231229104202.7878-1-natalia.saiapova@intel.com> References: <20231229104202.7878-1-natalia.saiapova@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 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 this patch, we introduce new command options for set/show scheduler locking. New options give the user finer control over the scheduler. Introduce set scheduler-locking show scheduler-locking For example, with these commands a user can get a combined scheduler locking for stepping commands during the normal execution and for all commands in replay mode. The existing scheduler-locking settings still exist and work as shortcuts. set scheduler-locking step is equivalent to set scheduler-locking replay run off set scheduler-locking replay step on set scheduler-locking run off set scheduler-locking step on set scheduler-locking on is equivalent to set scheduler-locking replay run on set scheduler-locking replay step on set scheduler-locking run on set scheduler-locking step on set scheduler-locking replay is equivalent to set scheduler-locking replay run on set scheduler-locking replay step on set scheduler-locking run off set scheduler-locking step off set scheduler-locking off is equivalent to set scheduler-locking replay run off set scheduler-locking replay step off set scheduler-locking run off set scheduler-locking step off This is bound to the structure we introduced in the previous commit: gdb: change the internal representation of scheduler locking. To introduce it under scheduler-locking I had to change the way the show command works. (gdb) show scheduler-locking scheduler-locking replay run: "on" Scheduler locking for non-stepping commands is "on" during replay mode. scheduler-locking replay step: "on" Scheduler locking for stepping commands is "on" during replay mode. scheduler-locking run: "off" Scheduler locking for non-stepping commands is "off" during normal execution. scheduler-locking step: "off" Scheduler locking for stepping commands is "off" during normal execution. (gdb) show scheduler-locking replay scheduler-locking replay run: "on" Scheduler locking for non-stepping commands is "on" during replay mode. scheduler-locking replay step: "on" Scheduler locking for stepping commands is "on" during replay mode. (gdb) show scheduler-locking replay step "on" Scheduler locking for stepping commands is "on" during replay mode. (gdb) show scheduler-locking run "off" Scheduler locking for non-stepping commands is "off" during normal execution. Note, there is a small inconsistency with the "set scheduler-locking step". If we did not keep the older way of setting the scheduler locking, command set scheduler-locking step would be the same as set scheduler-locking step on while to be backward compatible, we have it as set scheduler-locking step on set scheduler-locking replay step on Reviewed-By: Eli Zaretskii --- gdb/NEWS | 17 ++ gdb/doc/gdb.texinfo | 61 ++++- gdb/infrun.c | 220 ++++++++++++++---- .../gdb.mi/user-selected-context-sync.exp | 20 +- .../gdb.threads/hand-call-in-threads.exp | 8 +- .../multiple-successive-infcall.exp | 5 +- gdb/testsuite/gdb.threads/schedlock.exp | 79 ++++++- gdb/testsuite/lib/gdb.exp | 53 ++++- 8 files changed, 367 insertions(+), 96 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 4358494a6b6..bdbbadacb89 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -18,6 +18,23 @@ disassemble * New commands +set scheduler-locking replay run | replay step | run | step (on|off) +show scheduler-locking (replay run | replay step | run | step) + Extend the scheduler locking settings with a set of set/show + commands, which can be used individually to control the scheduler during + various commands. + 'replay run' -- when on, the scheduler is locked during non-stepping + commands in replay mode. + 'replay step' -- when on, the scheduler is locked during stepping + commands in replay mode. + 'run' -- when on, the scheduler is locked during non-stepping commands + in normal mode. + 'step' -- when on, the scheduler is locked during stepping commands + in normal mode. + The older scheduler locking settings can be used as shortcuts, their behavior + is not changed. + The output of "show scheduler-locking" has changed to support the new settings. + info missing-debug-handler List all the registered missing debug handlers. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 42a91235661..0560b9a5ea7 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -7110,22 +7110,56 @@ On some OSes, you can modify @value{GDBN}'s default behavior by locking the OS scheduler to allow only a single thread to run. @table @code -@item set scheduler-locking @var{mode} -@cindex scheduler-locking + +@item set scheduler-locking @var{type} [@code{on}|@code{off}] +@cindex scheduler locking type +@cindex lock scheduler +Set the scheduler locking settings. It applies to normal execution, +record mode, and replay mode. The scheduler locking can be set separately +for stepping and non-stepping commands. + +@table @code +@item replay run +When @code{on} the scheduler is locked for non-stepping commands during +replay mode. For commands like @samp{continue}, @samp{until}, @samp{finish}, +or expression evaluation only the current thread may run. + +@item replay step +When @code{on} the scheduler is locked for stepping commands during replay +mode. This mode optimizes for single-stepping; only the current thread is +resumed while you are stepping, so that the focus of debugging does not change +unexpectedly. + +@item run +When @code{on} the scheduler is locked for non-stepping commands during +normal execution and record modes. For commands like @samp{continue}, +@samp{until}, @samp{finish}, or expression evaluation only the current +thread may run. + +@item step +When @code{on} the scheduler is locked for stepping commands during +normal execution and record modes. This mode optimizes for single-stepping; +only the current thread is resumed while you are stepping, so that the focus +of debugging does not change unexpectedly. + +@end table + +@item set scheduler-locking @var{shortcut-mode} @cindex scheduler locking mode @cindex lock scheduler -Set the scheduler locking mode. It applies to normal execution, -record mode, and replay mode. @var{mode} can be one of -the following: +One can choose to not set the scheduler locking settings individually but use +the following predefined shortcut modes. @table @code @item off -There is no locking and any thread may run at any time. +There is no locking and any thread may run at any time. This is equivalent to +setting all options to @code{off}. @item on -Only the current thread may run when the inferior is resumed. New +Only the current thread may run when the inferior is resumed. New threads created by the resumed thread are held stopped at their entry -point, before they execute any instruction. +point, before they execute any instruction. This is +equivalent to setting all options to @code{on}. @item step Behaves like @code{on} when stepping, and @code{off} otherwise. @@ -7140,9 +7174,18 @@ another thread hits a breakpoint during its timeslice, @value{GDBN} does not change the current thread away from the thread that you are debugging. +This is equivalent to set @samp{scheduler-locking step} and +@samp{scheduler-locking replay step} to @code{on}, while other settings +are @code{off}. + @item replay Behaves like @code{on} in replay mode, and @code{off} in either record mode or during normal execution. This is the default mode. + +This is equivalent to set @samp{scheduler-locking replay run} and +@samp{scheduler-locking replay step} to @code{on}, while other settings +are @code{off}. + @end table @item show scheduler-locking @@ -33949,7 +33992,7 @@ the end or beginning of a replay log if one is being used. @end itemize In all-stop mode (@pxref{All-Stop Mode}), may resume only one thread, or all threads, depending on the -value of the @samp{scheduler-locking} variable. If @samp{--all} is +value of the @samp{scheduler-locking} variables. If @samp{--all} is specified, all threads (in all inferiors) will be resumed. The @samp{--all} option is ignored in all-stop mode. If the @samp{--thread-group} options is specified, then all threads in that thread group are resumed. diff --git a/gdb/infrun.c b/gdb/infrun.c index f70f615abf8..daf8cecd601 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -77,6 +77,7 @@ #include "extension.h" #include "disasm.h" #include "interps.h" +#include "cli/cli-decode.h" /* Prototypes for local functions */ @@ -116,6 +117,12 @@ struct schedlock_options; static bool schedlock_applies_to_opts (const schedlock_options &opts, bool step); +/* Command lists for the scheduler locking. */ +static cmd_list_element *schedlock_set_cmdlist; +static cmd_list_element *schedlock_show_cmdlist; +static cmd_list_element *schedlock_set_replay_cmdlist; +static cmd_list_element *schedlock_show_replay_cmdlist; + /* Asynchronous signal handler registered as event loop source for when we have pending events ready to be passed to the core. */ static struct async_event_handler *infrun_async_inferior_event_token; @@ -2348,7 +2355,8 @@ struct schedlock_options operator bool () const { return value; } const char *c_str () const { return value ? "on" : "off"; } - /* Set new value. Return true, if the value has changed. */ + /* Set new value. Return true, if the value has changed. + Also notifies the observer, if the value has changed. */ bool set (bool new_value); }; @@ -2375,6 +2383,8 @@ schedlock_options::option::set (bool new_value) if (value != new_value) { value = new_value; + std::string param_name = "scheduler-locking " + name; + interps_notify_param_changed (param_name.c_str (), c_str ()); return true; } @@ -2395,15 +2405,6 @@ static const char schedlock_off[] = "off"; static const char schedlock_on[] = "on"; static const char schedlock_step[] = "step"; static const char schedlock_replay[] = "replay"; -static const char *const scheduler_enums[] = { - schedlock_off, - schedlock_on, - schedlock_step, - schedlock_replay, - nullptr -}; - -static const char *scheduler_mode = schedlock_replay; schedlock schedlock {{{"run", false}, {"step", false}}, {{"replay run", true}, {"replay step", true}}}; @@ -2424,35 +2425,89 @@ set_schedlock_shortcut_option (const char *shortcut) /* Check that we got a valid shortcut option. */ gdb_assert (is_on || is_step || is_replay || is_off); - schedlock.normal.run.set (is_on); - schedlock.normal.step.set (is_on || is_step); - schedlock.replay.run.set (is_on || is_replay); - schedlock.replay.step.set (is_on || is_replay || is_step); + bool any_changed = schedlock.normal.run.set (is_on); + any_changed = schedlock.normal.step.set (is_on || is_step) || any_changed; + any_changed = schedlock.replay.run.set (is_on || is_replay) || any_changed; + any_changed = schedlock.replay.step.set (is_on || is_replay || is_step) + || any_changed; + + /* If at least one parameter has changed, notify the observer + in the old-fashioned way. */ + if (any_changed) + interps_notify_param_changed ("scheduler-locking", shortcut); } +/* Default callback for set methods of scheduler locking options. + Checks that the scheduler locking is supported. + If no, it reverts all options to "off" and throws an error. */ + static void -show_scheduler_mode (struct ui_file *file, int from_tty, - struct cmd_list_element *c, const char *value) +set_schedlock_callback (const char *args, int from_tty, cmd_list_element *c) { - gdb_printf (file, - _("Mode for locking scheduler " - "during execution is \"%s\".\n"), - value); + if (target_can_lock_scheduler ()) + return; + + /* Set scheduler locking off and error out. */ + set_schedlock_shortcut_option (schedlock_off); + error (_("Target '%s' cannot support this command."), target_shortname ()); } +/* Support for shortcut schedlock options: "on", "off", "step", "replay". */ + static void -set_schedlock_func (const char *args, int from_tty, struct cmd_list_element *c) +set_schedlock_step (const char *args, int from_tty, cmd_list_element *c) { - if (!target_can_lock_scheduler ()) - { - scheduler_mode = schedlock_off; - /* Set scheduler locking off. */ - set_schedlock_shortcut_option (schedlock_off); - error (_("Target '%s' cannot support this command."), - target_shortname ()); - } + if (!args || !*args) + set_schedlock_shortcut_option (schedlock_step); + set_schedlock_callback (args, from_tty, nullptr); +} + +static void +set_schedlock_replay (const char *args, int from_tty) +{ + set_schedlock_shortcut_option (schedlock_replay); + set_schedlock_callback (args, from_tty, nullptr); +} - set_schedlock_shortcut_option (scheduler_mode); +static void +set_schedlock_on (const char *args, int from_tty) +{ + set_schedlock_shortcut_option (schedlock_on); + set_schedlock_callback (args, from_tty, nullptr); +} + +static void +set_schedlock_off (const char *args, int from_tty) +{ + set_schedlock_shortcut_option (schedlock_off); + set_schedlock_callback (args, from_tty, nullptr); +} + +/* Default method to show a single option of scheduler locking. */ + +static void +show_schedlock_option (ui_file *file, int from_tty, + cmd_list_element *c, const char *value) +{ + gdb_assert (c->prefix != nullptr); + const char *mode; + if (strcmp (c->prefix->name, "replay") == 0) + mode = "replay mode"; + else if (strcmp (c->prefix->name, "scheduler-locking") == 0) + mode = "normal execution"; + else + gdb_assert_not_reached ("Unexpected command prefix."); + + const char *type; + if (strcmp (c->name, "step") == 0) + type = "stepping commands"; + else if (strcmp (c->name, "run") == 0) + type = "non-stepping commands"; + else + gdb_assert_not_reached ("Unexpected command name."); + + gdb_printf (file, _("\"%s\"\tScheduler locking for %s is " + "\"%s\" during the %s.\n"), value, type, value, mode); } /* True if execution commands resume all threads of all processes by @@ -8354,14 +8409,6 @@ switch_back_to_stepped_thread (struct execution_control_state *ecs) return true; } - /* If scheduler locking applies even if not stepping, there's no - need to walk over threads. Above we've checked whether the - current thread is stepping. If some other thread not the - event thread is stepping, then it must be that scheduler - locking is not in effect. */ - if (schedlock_applies_to_thread (ecs->event_thread)) - return false; - /* Otherwise, we no longer expect a trap in the current thread. Clear the trap_expected flag before switching back -- this is what keep_going does as well, if we call it. */ @@ -10652,21 +10699,92 @@ By default, the debugger will use the same inferior."), show_follow_exec_mode_string, &setlist, &showlist); - add_setshow_enum_cmd ("scheduler-locking", class_run, - scheduler_enums, &scheduler_mode, _("\ -Set mode for locking scheduler during execution."), _("\ -Show mode for locking scheduler during execution."), _("\ -off == no locking (threads may preempt at any time)\n\ -on == full locking (no thread except the current thread may run)\n\ - This applies to both normal execution and replay mode.\n\ -step == scheduler locked during stepping commands (step, next, stepi, nexti).\n\ - In this mode, other threads may run during other commands.\n\ - This applies to both normal execution and replay mode.\n\ -replay == scheduler locked in replay mode and unlocked during normal execution."), - set_schedlock_func, /* traps on target vector */ - show_scheduler_mode, + /* Commands for set/show scheduler-locking. */ + + add_setshow_prefix_cmd ("scheduler-locking", class_run, _("\ +Scheduler locking settings.\n\ +Configure scheduler locking settings in various conditions."), _("\ +Show scheduler locking settings in various conditions."), + &schedlock_set_cmdlist, + &schedlock_show_cmdlist, &setlist, &showlist); + add_setshow_boolean_cmd ("run", class_run, &schedlock.normal.run.value, _("\ +Scheduler locking for non-stepping commands during normal execution."), _("\ +Show scheduler locking for non-stepping commands during normal execution."), + _("\ +Controls scheduler locking for non-stepping commands during normal execution.\n\ +Commands include continue, until, finish. The setting does not affect \ +stepping."), + set_schedlock_callback, + show_schedlock_option, + &schedlock_set_cmdlist, + &schedlock_show_cmdlist); + + add_setshow_boolean_cmd ("step", class_run, &schedlock.normal.step.value, _("\ +Scheduler locking for stepping commands. W/o arguments locks the scheduler \ +for stepping."), _("\ +Show scheduler locking for stepping commands during normal execution."), _("\ +If argument \"on\" or \"off\", sets scheduler locking behavior for stepping\n\ +commands only during normal execution.\n\ +Commands include step, next, stepi, nexti."), + set_schedlock_step, + show_schedlock_option, + &schedlock_set_cmdlist, + &schedlock_show_cmdlist); + + /* Commands for set/show scheduler-locking in replay mode. + The base command adds support for the shortcut + set scheduler-locking replay + command. */ + + add_setshow_prefix_cmd ("replay", class_run, _("\ +Scheduler locking settings for replay mode.\n\ +Configure scheduler locking in various conditions such as during continuing\n\ +or stepping."), +("Show scheduler locking in replay mode."), + &schedlock_set_replay_cmdlist, + &schedlock_show_replay_cmdlist, + &schedlock_set_cmdlist, + &schedlock_show_cmdlist); + add_prefix_cmd ("replay", class_run, set_schedlock_replay, _("\ +Scheduler locking settings for replay mode. \ +W/o arguments completely locks the scheduler in replay mode."), + &schedlock_set_replay_cmdlist, + 0, &schedlock_set_cmdlist); + + add_setshow_boolean_cmd ("run", class_run, &schedlock.replay.run.value, _("\ +Set scheduler locking for non-stepping commands in replay mode."), _("\ +Show scheduler locking for non-stepping commands in replay mode."), _("\ +Controls scheduler locking for non-stepping commands in replay mode.\n\ +Commands include continue, until, finish. The setting does not affect \ +stepping."), + set_schedlock_callback, + show_schedlock_option, + &schedlock_set_replay_cmdlist, + &schedlock_show_replay_cmdlist); + + add_setshow_boolean_cmd ("step", class_run, &schedlock.replay.step.value, _("\ +Set scheduler locking for stepping commands in replay mode."), _("\ +Show scheduler locking for stepping commands in replay mode."), _("\ +Controls scheduler locking for stepping commands in replay mode.\n\ +Commands include step, next, stepi, nexti."), + set_schedlock_callback, + show_schedlock_option, + &schedlock_set_replay_cmdlist, + &schedlock_show_replay_cmdlist); + +/* Commands "set scheduler-locking on" and "set scheduler-locking off" + are provided for backward compatibility. */ + c = add_cmd ("on", class_run, set_schedlock_on, _("\ +[Shortcut] Full locking (no thread except the current thread may run).\n\ +This applies to both normal execution and replay mode."), + &schedlock_set_cmdlist); + + c = add_cmd ("off", class_run, set_schedlock_off, _("\ +[Shortcut] No locking (threads may preempt at any time)."), + &schedlock_set_cmdlist); + add_setshow_boolean_cmd ("schedule-multiple", class_run, &sched_multi, _("\ Set mode for resuming threads of all processes."), _("\ Show mode for resuming threads of all processes."), _("\ diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp index 4889c31aff3..625a47fb745 100644 --- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp +++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp @@ -255,17 +255,12 @@ proc make_cli_in_mi_re { command cli_in_mi_mode mode event inf cli_thread # Return the current value of the "scheduler-locking" parameter. proc show_scheduler_locking { } { - global gdb_prompt - global expect_out - - set any "\[^\r\n\]*" - set test "show scheduler-locking" - gdb_test_multiple $test $test { - -re ".*Mode for locking scheduler during execution is \"(${any})\".\r\n$gdb_prompt " { - pass $test - return $expect_out(1,string) - } + set schedlock [get_scheduler_locking $test] + + if {$schedlock ne "unknown"} { + pass $test + return $schedlock } error "Couldn't get current scheduler-locking value." @@ -342,7 +337,10 @@ proc test_continue_to_start { mode inf } { } # Restore scheduler-locking to its original value. - gdb_test_no_output "set scheduler-locking $previous_schedlock_val" + gdb_test_no_output "set scheduler-locking replay run [lindex $previous_schedlock_val 0]" + gdb_test_no_output "set scheduler-locking replay step [lindex $previous_schedlock_val 1]" + gdb_test_no_output "set scheduler-locking run [lindex $previous_schedlock_val 2]" + gdb_test_no_output "set scheduler-locking step [lindex $previous_schedlock_val 3]" } else { # $mode == "non-stop" # Put a thread-specific breakpoint for thread 2 of the current # inferior. We don't put a breakpoint for thread 3, since we diff --git a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp index 58039ddd30e..d18254910db 100644 --- a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp +++ b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp @@ -68,7 +68,9 @@ gdb_test "continue" \ # Before we start making hand function calls, turn on scheduler locking. gdb_test_no_output "set scheduler-locking on" "enable scheduler locking" -gdb_test "show scheduler-locking" ".* locking scheduler .* is \"on\"." "show scheduler locking on" +set test "show scheduler-locking on" +gdb_assert {[get_scheduler_locking $test {"on" "on" "on" "on"}] ne "unknown"} \ + $test # Now hand-call a function in each thread, having the function # stop without returning. @@ -139,7 +141,9 @@ gdb_test_multiple "maint print dummy-frames" "all dummies popped" { # Before we resume the full program, turn off scheduler locking. gdb_test_no_output "set scheduler-locking off" "disable scheduler locking" -gdb_test "show scheduler-locking" ".* locking scheduler .* is \"off\"." "show scheduler locking off" +set test "show scheduler-locking off" +gdb_assert {[get_scheduler_locking $test {"off" "off" "off" "off"}] ne "unknown"} \ + $test # Continue one last time, the program should exit normally. # diff --git a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp index bd037a02674..69e750fea44 100644 --- a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp +++ b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp @@ -49,8 +49,9 @@ foreach_with_prefix thread {5 4 3} { gdb_breakpoint [gdb_get_line_number "testmarker01"] gdb_continue_to_breakpoint "testmarker01" gdb_test_no_output "set scheduler-locking on" -gdb_test "show scheduler-locking" \ - "Mode for locking scheduler during execution is \"on\"." +set test "show scheduler-locking" +gdb_assert {[get_scheduler_locking $test {"on" "on" "on" "on"}] ne "unknown"} \ + $test foreach_with_prefix thread {5 4 3 2 1} { gdb_test "thread ${thread}" "Switching to .*" diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp index 3c60f6b3478..cf11fd3a0a0 100644 --- a/gdb/testsuite/gdb.threads/schedlock.exp +++ b/gdb/testsuite/gdb.threads/schedlock.exp @@ -94,7 +94,8 @@ proc get_current_thread { description } { # Make sure we're stopped in the loop, in one of the non-main threads. proc goto_loop { msg } { - gdb_breakpoint [concat [gdb_get_line_number "schedlock.exp: main loop"] " if arg != 0"] + global srcfile + gdb_breakpoint [concat "$srcfile:" [gdb_get_line_number "schedlock.exp: main loop"] " if arg != 0"] set test "return to loop" if {$msg != ""} { @@ -264,16 +265,21 @@ with_test_prefix "schedlock=on: cmd=continue" { } # Test stepping/nexting with different modes of scheduler locking. -proc test_step { schedlock cmd call_function } { +# Do scheduler-locking off setting before the test if PRESET_SCHEDLOCK_OFF is 1. +# LOCKED defines whether we expect the thread to be locked. If -1, then +# determine it first. +proc test_step { schedlock cmd call_function { preset_schedlock_off 1 } { locked -1 } } { global NUM - gdb_test_no_output "set scheduler-locking off" + if {$preset_schedlock_off} { + gdb_test_no_output "set scheduler-locking off" + } goto_loop "" set curthread [get_current_thread "before"] # No need to set to off again. This avoids a duplicate message. - if {$schedlock != "off"} { + if {$preset_schedlock_off && $schedlock != "off"} { gdb_test_no_output "set scheduler-locking $schedlock" } @@ -284,16 +290,17 @@ proc test_step { schedlock cmd call_function } { step_ten_loops $cmd - if { $schedlock == "on" || $schedlock == "step" } { - set locked 1 - } else { - set locked 0 + if { $locked == -1 } { + if { $schedlock == "on" || $schedlock == "step"} { + set locked 1 + } else { + set locked 0 + } } - check_result $cmd $curthread $before_args $locked } -# Test stepping/nexting with different modes of scheduler locking. +# Test stepping/nexting with different shortcut modes of scheduler locking. foreach schedlock {"off" "step" "on"} { with_test_prefix "schedlock=$schedlock" { with_test_prefix "cmd=step" { @@ -312,3 +319,55 @@ foreach schedlock {"off" "step" "on"} { } } } + +proc test_schedlock_opts {run step} { + set test "show scheduler-locking" + if {[get_scheduler_locking $test [list "off" "off" $run $step]] eq "unknown"} { + fail $test + } else { + pass $test + } + + set locked 0 + if {$step eq "on"} { + set locked 1 + } + + # Stepping tests. + with_test_prefix "cmd=step" { + test_step "" "step" 0 0 $locked + } + with_test_prefix "cmd=next" { + foreach call_function {0 1} { + with_test_prefix "call_function=$call_function" { + test_step "" "next" $call_function 0 $locked + } + } + } + + # Continuing tests. + set locked 0 + if {$run eq "on"} { + set locked 1 + } + with_test_prefix "cmd=continue" { + # Use whichever we stopped in. + set curthread [get_current_thread "before"] + set cont_args [get_args "before"] + my_continue "continue" + check_result "continue" $curthread $cont_args $locked + } +} + +gdb_test_no_output "set scheduler-locking off" + +# Test different options of scheduler locking. +foreach run {"off" "on"} { + foreach step {"off" "on"} { + with_test_prefix "run=$run step=$step" { + gdb_test_no_output "set scheduler-locking run $run" + gdb_test_no_output "set scheduler-locking step $step" + test_schedlock_opts $run $step + } + } +} diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index eb8f6998b1e..a7c85c2b20a 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -8565,6 +8565,42 @@ gdb_caching_proc gdb_target_symbol_prefix {} { return $prefix } +proc get_scheduler_locking {{test ""} {expected ""}} { + global gdb_prompt + if {$test eq ""} { + set test "reading current scheduler-locking mode" + } + + set any "\[^\r\n\]+" + set on_off "\(?:on|off\)" + + set i [expr 4 - [llength $expected]] + while {$i > 0} { + incr i -1 + lappend expected $on_off + } + set schedlock_regex \ + [multi_line \ + "${any}replay run: +\"\([lindex $expected 0]\)\"${any}non-stepping${any}replay${any}" \ + "${any}replay step: +\"\([lindex $expected 1]\)\"${any}stepping${any}replay${any}" \ + "${any}run: +\"\([lindex $expected 2]\)\"${any}non-stepping${any}normal execution${any}" \ + "${any}step: +\"\([lindex $expected 3]\)\"${any}stepping${any}normal execution${any}"] + + set current_schedule_locking_mode "unknown" + gdb_test_multiple "show scheduler-locking" $test { + -re -wrap $schedlock_regex { + set current_schedule_locking_mode \ + [list $expect_out(1,string) \ + $expect_out(2,string) \ + $expect_out(3,string) \ + $expect_out(4,string)] + } + -re -wrap "" {} + timeout {} + } + return $current_schedule_locking_mode +} + # Return 1 if target supports scheduler locking, otherwise return 0. gdb_caching_proc target_supports_scheduler_locking {} { @@ -8586,21 +8622,16 @@ gdb_caching_proc target_supports_scheduler_locking {} { set current_schedule_locking_mode "" set test "reading current scheduler-locking mode" - gdb_test_multiple "show scheduler-locking" $test { - -re "Mode for locking scheduler during execution is \"(\[\^\"\]*)\".*$gdb_prompt" { - set current_schedule_locking_mode $expect_out(1,string) - } - -re "$gdb_prompt $" { - set supports_schedule_locking 0 - } - timeout { - set supports_schedule_locking 0 - } + set current_schedule_locking_mode [get_scheduler_locking $test] + if { $current_scheduler_locking eq "unknown" } { + set supports_schedule_locking 0 } if { $supports_schedule_locking == -1 } { set test "checking for scheduler-locking support" - gdb_test_multiple "set scheduler-locking $current_schedule_locking_mode" $test { + + # Try to set scheduler-locking run. + gdb_test_multiple "set scheduler-locking run [lindex $current_schedule_locking_mode 0]" $test { -re "Target '\[^'\]+' cannot support this command\..*$gdb_prompt $" { set supports_schedule_locking 0 } From patchwork Fri Dec 29 10:42:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Natalia Saiapova X-Patchwork-Id: 83002 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 AB5CE3858404 for ; Fri, 29 Dec 2023 10:45:20 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by sourceware.org (Postfix) with ESMTPS id 27D95385840B for ; Fri, 29 Dec 2023 10:43:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27D95385840B 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 27D95385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=134.134.136.100 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846614; cv=none; b=kMnS5fDSQkk2ci3eUSlKViQinbxgTGijgTVzZ2ro7c1UDyZ2cD2jrzsD3hLE8B2iyD3ycRDs9sQtvA5KAdhrRc8vDm2NvXpLkUssOYe9eIGyrRW6vO2WOtj14/Cj7oro1hC5VDknmLJ2ez2OVmqLm3SEcChGbD8wws1dKaPmL6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703846614; c=relaxed/simple; bh=kVtK+/Al+rArX5oaU6wFV2eySFd9X5JQD4Xrloghfpk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=TMVwXBJPczCkeD62CBlHkO7czKC9DEYNLqfVt2A2yBzdYgE2ykqXwc7hq/Ny2VcwzVrOAGNjR5WysA5XhuCxM9exf6QGfJXZjSCAypRhD6NUJGSpcXpG3Kck3RkKa5bz+ACAwrj5UgXjk3HTevQC6MTJZApoE5tIC/Apb3EsJ7A= 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=1703846607; x=1735382607; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kVtK+/Al+rArX5oaU6wFV2eySFd9X5JQD4Xrloghfpk=; b=DPpiEidLiPPLb+y6vRZ36p8kqcBF1Pf+elgdxHFeoGJUs9hYRT1C6e9u Q4F77iuuyIoPIGeZaFDbBv07n9Y1bNbuVDWeCn1xOwqwhE77oOM3oSxRQ 3YGEh+eX0DrQ4PFY1rgcU6bmBF1qp9erfsUz7fvwvbf8AXibw940+LVGW 9j66otr4hb6TYY4YXzkHmPCL9HGvnvUl5C5rWt2ZSfO53o0NXxZWbTXim +zqJdeOBemT1QEH2V1iSypvsZJ77/yPG3U0C22dxF1XjbGtujV4XXEqXf 2ophBqS+U56DQcXDRw+isSUWyqwu4uektZa2U/ymWohqywODQr1ezpCBg A==; X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="463052620" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="463052620" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:43:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10937"; a="782281374" X-IronPort-AV: E=Sophos;i="6.04,314,1695711600"; d="scan'208";a="782281374" Received: from unknown (HELO localhost) ([10.211.177.238]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Dec 2023 02:43:25 -0800 From: Natalia Saiapova To: gdb-patches@sourceware.org Cc: tankut.baris.aktemur@intel.com Subject: [PATCH 6/6] gdb: add eval option to lock the scheduler during infcalls. Date: Fri, 29 Dec 2023 10:42:02 +0000 Message-Id: <20231229104202.7878-7-natalia.saiapova@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231229104202.7878-1-natalia.saiapova@intel.com> References: <20231229104202.7878-1-natalia.saiapova@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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 This adds the following commands to control scheduler-locking for inferior calls during normal execution: set scheduler-locking eval (on|off} show scheduler-locking eval and during replay mode: set scheduler-locking replay eval (on|off) show scheduler-locking replay eval Note, previously, infcalls were handled with the "run" option. Now, the "run" option affects only continuing commands, but not the expression evaluation. Show scheduler locking: (gdb) show scheduler-locking scheduler-locking eval: "off" Scheduler locking for expression evaluation is "off" during normal execution. scheduler-locking replay eval: "on" Scheduler locking for expression evaluation is "on" during replay mode. scheduler-locking replay run: "on" Scheduler locking for continuing commands is "on" during replay mode. scheduler-locking replay step: "on" Scheduler locking for stepping commands is "on" during replay mode. scheduler-locking run: "off" Scheduler locking for continuing commands is "off" during normal execution. scheduler-locking step: "off" Scheduler locking for stepping commands is "off" during normal execution. Reviewed-By: Eli Zaretskii --- gdb/NEWS | 14 ++- gdb/doc/gdb.texinfo | 19 ++-- gdb/infrun.c | 98 ++++++++++++++----- .../gdb.mi/user-selected-context-sync.exp | 10 +- .../gdb.threads/hand-call-in-threads.exp | 4 +- .../multiple-successive-infcall.exp | 2 +- gdb/testsuite/gdb.threads/schedlock.exp | 36 +++++-- gdb/testsuite/lib/gdb.exp | 22 +++-- 8 files changed, 144 insertions(+), 61 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index bdbbadacb89..532179cdca1 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -18,16 +18,20 @@ disassemble * New commands -set scheduler-locking replay run | replay step | run | step (on|off) -show scheduler-locking (replay run | replay step | run | step) - Extend the scheduler locking settings with a set of set/show +set scheduler-locking eval | replay eval | replay run | replay step | run | step (on|off) +show scheduler-locking (eval | replay eval | replay run | replay step | run | step) + Extend the scheduler-locking settings with a set of set/show commands, which can be used individually to control the scheduler during various commands. - 'replay run' -- when on, the scheduler is locked during non-stepping + 'eval' -- when on, the scheduler is locked during expression evaluation + in normal mode. + 'replay eval' -- when on, the scheduler is locked during expression + evaluation in replay mode. + 'replay run' -- when on, the scheduler is locked during continuing commands in replay mode. 'replay step' -- when on, the scheduler is locked during stepping commands in replay mode. - 'run' -- when on, the scheduler is locked during non-stepping commands + 'run' -- when on, the scheduler is locked during continuing commands in normal mode. 'step' -- when on, the scheduler is locked during stepping commands in normal mode. diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 0560b9a5ea7..3eddcc569df 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -7119,10 +7119,18 @@ record mode, and replay mode. The scheduler locking can be set separately for stepping and non-stepping commands. @table @code +@item eval +When @code{on} the scheduler is locked for expression evaluation during +normal execution and record modes, such that only the current thread may run. + +@item replay eval +When @code{on} the scheduler is locked for expression evaluation during +replay mode, such that only the current thread may run. + @item replay run -When @code{on} the scheduler is locked for non-stepping commands during -replay mode. For commands like @samp{continue}, @samp{until}, @samp{finish}, -or expression evaluation only the current thread may run. +When @code{on} the scheduler is locked for continuing commands during +replay mode. For commands like @samp{continue}, @samp{until} or @samp{finish} +only the current thread may run. @item replay step When @code{on} the scheduler is locked for stepping commands during replay @@ -7131,10 +7139,9 @@ resumed while you are stepping, so that the focus of debugging does not change unexpectedly. @item run -When @code{on} the scheduler is locked for non-stepping commands during +When @code{on} the scheduler is locked for continuing commands during normal execution and record modes. For commands like @samp{continue}, -@samp{until}, @samp{finish}, or expression evaluation only the current -thread may run. +@samp{until}, or @samp{finish} only the current thread may run. @item step When @code{on} the scheduler is locked for stepping commands during diff --git a/gdb/infrun.c b/gdb/infrun.c index daf8cecd601..67412c7148b 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -110,12 +110,12 @@ static bool step_over_info_valid_p (void); static bool schedlock_applies_to_thread (thread_info *tp); -static bool schedlock_applies (bool step); +static bool schedlock_applies (bool step, thread_info *tp = nullptr); struct schedlock_options; static bool schedlock_applies_to_opts (const schedlock_options &opts, - bool step); + bool step, thread_info *tp = nullptr); /* Command lists for the scheduler locking. */ static cmd_list_element *schedlock_set_cmdlist; @@ -2361,8 +2361,8 @@ struct schedlock_options }; schedlock_options () = delete; - schedlock_options (option run, option step) - : run (std::move (run)), step (std::move (step)) + schedlock_options (option eval, option run, option step) + : eval (std::move (eval)), run (std::move (run)), step (std::move (step)) {} /* Forbid accidential copying. */ @@ -2371,7 +2371,9 @@ struct schedlock_options schedlock_options (schedlock_options &&) = default; schedlock_options &operator= (schedlock_options &&) = default; - /* If true, the scheduler is locked during non-stepping. */ + /* If true, the scheduler is locked during inferior calls. */ + option eval; + /* If true, the scheduler is locked during continuing. */ option run; /* If true, the scheduler is locked during stepping. */ option step; @@ -2406,8 +2408,18 @@ static const char schedlock_on[] = "on"; static const char schedlock_step[] = "step"; static const char schedlock_replay[] = "replay"; -schedlock schedlock {{{"run", false}, {"step", false}}, - {{"replay run", true}, {"replay step", true}}}; +schedlock schedlock { + { + {"eval", false}, + {"run", false}, + {"step", false} + }, + { + {"replay eval", true}, + {"replay run", true}, + {"replay step", true} + } +}; /* A helper function to set scheduler locking shortcuts: set scheduler-locking on: all options are on. @@ -2427,9 +2439,11 @@ set_schedlock_shortcut_option (const char *shortcut) bool any_changed = schedlock.normal.run.set (is_on); any_changed = schedlock.normal.step.set (is_on || is_step) || any_changed; + any_changed = schedlock.normal.eval.set (is_on) || any_changed; any_changed = schedlock.replay.run.set (is_on || is_replay) || any_changed; any_changed = schedlock.replay.step.set (is_on || is_replay || is_step) || any_changed; + any_changed = schedlock.replay.eval.set (is_on || is_replay) || any_changed; /* If at least one parameter has changed, notify the observer in the old-fashioned way. */ @@ -2502,7 +2516,9 @@ show_schedlock_option (ui_file *file, int from_tty, if (strcmp (c->name, "step") == 0) type = "stepping commands"; else if (strcmp (c->name, "run") == 0) - type = "non-stepping commands"; + type = "continuing commands"; + else if (strcmp (c->name, "eval") == 0) + type = "expression evaluation"; else gdb_assert_not_reached ("Unexpected command name."); @@ -2538,6 +2554,9 @@ ptid_t user_visible_resume_ptid (int step) { ptid_t resume_ptid; + thread_info *tp = nullptr; + if (inferior_ptid != null_ptid) + tp = inferior_thread (); if (non_stop) { @@ -2545,7 +2564,7 @@ user_visible_resume_ptid (int step) individually. */ resume_ptid = inferior_ptid; } - else if (schedlock_applies (step)) + else if (schedlock_applies (step, tp)) { /* User-settable 'scheduler' mode requires solo thread resume. */ @@ -3334,13 +3353,20 @@ thread_still_needs_step_over (struct thread_info *tp) /* Return true if OPTS lock the scheduler. STEP indicates whether a thread is about to step. + While the stepping info we take from STEP argument, the inferior call + state we get from the thread TP. Note, this does not take into the account the mode (replay or normal execution). */ static bool -schedlock_applies_to_opts (const schedlock_options &opts, bool step) +schedlock_applies_to_opts (const schedlock_options &opts, bool step, + thread_info *tp) { - return ((opts.run && !step) || (opts.step && step)); + bool in_infcall = (tp != nullptr) && tp->control.in_infcall; + + return ((opts.run && !step && !in_infcall) + || (opts.step && step) + || (opts.eval && in_infcall)); } /* Returns true if scheduler locking applies to TP. */ @@ -3349,19 +3375,19 @@ static bool schedlock_applies_to_thread (thread_info *tp) { bool step = (tp != nullptr) && tp->control.stepping_command; - return schedlock_applies (step); + return schedlock_applies (step, tp); } -/* Returns true if scheduler locking applies. STEP indicates whether - we're about to do a step/next-like command. */ +/* Returns true if scheduler locking applies to thread TP. + STEP indicates whether we're about to do a step/next-like command. */ static bool -schedlock_applies (bool step) +schedlock_applies (bool step, thread_info *tp) { bool is_replay = target_record_will_replay (minus_one_ptid, execution_direction); schedlock_options &opts = is_replay ? schedlock.replay : schedlock.normal; - return schedlock_applies_to_opts (opts, step); + return schedlock_applies_to_opts (opts, step, tp); } /* Set process_stratum_target::COMMIT_RESUMED_STATE in all target @@ -10710,12 +10736,11 @@ Show scheduler locking settings in various conditions."), &setlist, &showlist); add_setshow_boolean_cmd ("run", class_run, &schedlock.normal.run.value, _("\ -Scheduler locking for non-stepping commands during normal execution."), _("\ -Show scheduler locking for non-stepping commands during normal execution."), - _("\ -Controls scheduler locking for non-stepping commands during normal execution.\n\ -Commands include continue, until, finish. The setting does not affect \ -stepping."), +Scheduler locking for continuing commands during normal execution."), _("\ +Show scheduler locking for continuing commands during normal execution."), _("\ +Controls scheduler locking for continuing commands during normal execution.\n\ +Commands include continue, until, finish. The setting does not affect\n\ +stepping and expression evaluation."), set_schedlock_callback, show_schedlock_option, &schedlock_set_cmdlist, @@ -10733,6 +10758,16 @@ Commands include step, next, stepi, nexti."), &schedlock_set_cmdlist, &schedlock_show_cmdlist); + add_setshow_boolean_cmd ("eval", class_run, &schedlock.normal.eval.value, _("\ +Scheduler locking for expression evaluation during normal execution."), _("\ +Show scheduler locking for expression evaluation during normal execution."), + _("\ +Controls scheduler locking for expression evaluation during normal execution."), + set_schedlock_callback, + show_schedlock_option, + &schedlock_set_cmdlist, + &schedlock_show_cmdlist); + /* Commands for set/show scheduler-locking in replay mode. The base command adds support for the shortcut set scheduler-locking replay @@ -10754,11 +10789,11 @@ W/o arguments completely locks the scheduler in replay mode."), 0, &schedlock_set_cmdlist); add_setshow_boolean_cmd ("run", class_run, &schedlock.replay.run.value, _("\ -Set scheduler locking for non-stepping commands in replay mode."), _("\ -Show scheduler locking for non-stepping commands in replay mode."), _("\ -Controls scheduler locking for non-stepping commands in replay mode.\n\ -Commands include continue, until, finish. The setting does not affect \ -stepping."), +Set scheduler locking for continuing commands in replay mode."), _("\ +Show scheduler locking for continuing commands in replay mode."), _("\ +Controls scheduler locking for continuing commands in replay mode.\n\ +Commands include continue, until, finish. The setting does not affect\n\ +stepping and expression evaluation."), set_schedlock_callback, show_schedlock_option, &schedlock_set_replay_cmdlist, @@ -10774,6 +10809,15 @@ Commands include step, next, stepi, nexti."), &schedlock_set_replay_cmdlist, &schedlock_show_replay_cmdlist); + add_setshow_boolean_cmd ("eval", class_run, &schedlock.replay.eval.value, _("\ +Set scheduler locking for expression evaluation in replay mode."), _("\ +Show scheduler locking for expression evaluation in replay mode."), _("\ +Controls scheduler locking for expression evaluation in replay mode."), + set_schedlock_callback, + show_schedlock_option, + &schedlock_set_replay_cmdlist, + &schedlock_show_replay_cmdlist); + /* Commands "set scheduler-locking on" and "set scheduler-locking off" are provided for backward compatibility. */ c = add_cmd ("on", class_run, set_schedlock_on, _("\ diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp index 625a47fb745..01ab4c016ec 100644 --- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp +++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp @@ -337,10 +337,12 @@ proc test_continue_to_start { mode inf } { } # Restore scheduler-locking to its original value. - gdb_test_no_output "set scheduler-locking replay run [lindex $previous_schedlock_val 0]" - gdb_test_no_output "set scheduler-locking replay step [lindex $previous_schedlock_val 1]" - gdb_test_no_output "set scheduler-locking run [lindex $previous_schedlock_val 2]" - gdb_test_no_output "set scheduler-locking step [lindex $previous_schedlock_val 3]" + gdb_test_no_output "set scheduler-locking eval [lindex $previous_schedlock_val 0]" + gdb_test_no_output "set scheduler-locking replay eval [lindex $previous_schedlock_val 1]" + gdb_test_no_output "set scheduler-locking replay run [lindex $previous_schedlock_val 2]" + gdb_test_no_output "set scheduler-locking replay step [lindex $previous_schedlock_val 3]" + gdb_test_no_output "set scheduler-locking run [lindex $previous_schedlock_val 4]" + gdb_test_no_output "set scheduler-locking step [lindex $previous_schedlock_val 5]" } else { # $mode == "non-stop" # Put a thread-specific breakpoint for thread 2 of the current # inferior. We don't put a breakpoint for thread 3, since we diff --git a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp index d18254910db..e0083a6369c 100644 --- a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp +++ b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp @@ -69,7 +69,7 @@ gdb_test "continue" \ gdb_test_no_output "set scheduler-locking on" "enable scheduler locking" set test "show scheduler-locking on" -gdb_assert {[get_scheduler_locking $test {"on" "on" "on" "on"}] ne "unknown"} \ +gdb_assert {[get_scheduler_locking $test {"on" "on" "on" "on" "on" "on"}] ne "unknown"} \ $test # Now hand-call a function in each thread, having the function @@ -142,7 +142,7 @@ gdb_test_multiple "maint print dummy-frames" "all dummies popped" { # Before we resume the full program, turn off scheduler locking. gdb_test_no_output "set scheduler-locking off" "disable scheduler locking" set test "show scheduler-locking off" -gdb_assert {[get_scheduler_locking $test {"off" "off" "off" "off"}] ne "unknown"} \ +gdb_assert {[get_scheduler_locking $test {"off" "off" "off" "off" "off" "off"}] ne "unknown"} \ $test # Continue one last time, the program should exit normally. diff --git a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp index 69e750fea44..75387883301 100644 --- a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp +++ b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp @@ -50,7 +50,7 @@ gdb_breakpoint [gdb_get_line_number "testmarker01"] gdb_continue_to_breakpoint "testmarker01" gdb_test_no_output "set scheduler-locking on" set test "show scheduler-locking" -gdb_assert {[get_scheduler_locking $test {"on" "on" "on" "on"}] ne "unknown"} \ +gdb_assert {[get_scheduler_locking $test {"on" "on" "on" "on" "on" "on"}] ne "unknown"} \ $test foreach_with_prefix thread {5 4 3 2 1} { diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp index cf11fd3a0a0..c77aae98864 100644 --- a/gdb/testsuite/gdb.threads/schedlock.exp +++ b/gdb/testsuite/gdb.threads/schedlock.exp @@ -228,7 +228,7 @@ proc check_result { cmd before_thread before_args locked } { set num_other_threads 0 for {set i 0} {$i < $NUM} {incr i} { if {[lindex $before_args $i] == [lindex $after_args $i]} { - if {$i == $before_thread} { + if {$i == $before_thread && $cmd ne "infcall"} { fail "$test (didn't run)" } } else { @@ -320,9 +320,9 @@ foreach schedlock {"off" "step" "on"} { } } -proc test_schedlock_opts {run step} { +proc test_schedlock_opts {eval run step} { set test "show scheduler-locking" - if {[get_scheduler_locking $test [list "off" "off" $run $step]] eq "unknown"} { + if {[get_scheduler_locking $test [list $eval "off" "off" "off" $run $step]] eq "unknown"} { fail $test } else { pass $test @@ -357,6 +357,25 @@ proc test_schedlock_opts {run step} { my_continue "continue" check_result "continue" $curthread $cont_args $locked } + + # Infcall tests. + set locked 0 + if {$eval eq "on"} { + set locked 1 + } + with_test_prefix "cmd=infcall" { + # Use whichever we stopped in. + set curthread [get_current_thread "before-infcall"] + set cont_args [get_args "before-infcall"] + + for {set i 0} {[expr $i < 10]} {set i [expr $i + 1]} { + with_test_prefix "infcall #$i" { + gdb_test "print some_function()" ".*" + } + } + + check_result "infcall" $curthread $cont_args $locked + } } gdb_test_no_output "set scheduler-locking off" @@ -364,10 +383,13 @@ gdb_test_no_output "set scheduler-locking off" # Test different options of scheduler locking. foreach run {"off" "on"} { foreach step {"off" "on"} { - with_test_prefix "run=$run step=$step" { - gdb_test_no_output "set scheduler-locking run $run" - gdb_test_no_output "set scheduler-locking step $step" - test_schedlock_opts $run $step + foreach eval {"off" "on"} { + with_test_prefix "run=$run step=$step eval=$eval" { + gdb_test_no_output "set scheduler-locking eval $eval" + gdb_test_no_output "set scheduler-locking run $run" + gdb_test_no_output "set scheduler-locking step $step" + test_schedlock_opts $eval $run $step + } } } } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index a7c85c2b20a..4120e2125f4 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -8574,17 +8574,19 @@ proc get_scheduler_locking {{test ""} {expected ""}} { set any "\[^\r\n\]+" set on_off "\(?:on|off\)" - set i [expr 4 - [llength $expected]] + set i [expr 6 - [llength $expected]] while {$i > 0} { incr i -1 lappend expected $on_off } set schedlock_regex \ [multi_line \ - "${any}replay run: +\"\([lindex $expected 0]\)\"${any}non-stepping${any}replay${any}" \ - "${any}replay step: +\"\([lindex $expected 1]\)\"${any}stepping${any}replay${any}" \ - "${any}run: +\"\([lindex $expected 2]\)\"${any}non-stepping${any}normal execution${any}" \ - "${any}step: +\"\([lindex $expected 3]\)\"${any}stepping${any}normal execution${any}"] + "${any}eval: +\"\([lindex $expected 0]\)\"${any}expression evaluation${any}normal execution${any}" \ + "${any}replay eval: +\"\([lindex $expected 1]\)\"${any}expression evaluation${any}replay${any}" \ + "${any}replay run: +\"\([lindex $expected 2]\)\"${any}continuing${any}replay${any}" \ + "${any}replay step: +\"\([lindex $expected 3]\)\"${any}stepping${any}replay${any}" \ + "${any}run: +\"\([lindex $expected 4]\)\"${any}continuing${any}normal execution${any}" \ + "${any}step: +\"\([lindex $expected 5]\)\"${any}stepping${any}normal execution${any}"] set current_schedule_locking_mode "unknown" gdb_test_multiple "show scheduler-locking" $test { @@ -8593,7 +8595,9 @@ proc get_scheduler_locking {{test ""} {expected ""}} { [list $expect_out(1,string) \ $expect_out(2,string) \ $expect_out(3,string) \ - $expect_out(4,string)] + $expect_out(4,string) \ + $expect_out(5,string) \ + $expect_out(6,string)] } -re -wrap "" {} timeout {} @@ -8623,15 +8627,15 @@ gdb_caching_proc target_supports_scheduler_locking {} { set test "reading current scheduler-locking mode" set current_schedule_locking_mode [get_scheduler_locking $test] - if { $current_scheduler_locking eq "unknown" } { + if { $current_schedule_locking_mode eq "unknown" } { set supports_schedule_locking 0 } if { $supports_schedule_locking == -1 } { set test "checking for scheduler-locking support" - # Try to set scheduler-locking run. - gdb_test_multiple "set scheduler-locking run [lindex $current_schedule_locking_mode 0]" $test { + # Try to set scheduler-locking eval. + gdb_test_multiple "set scheduler-locking eval [lindex $current_schedule_locking_mode 0]" $test { -re "Target '\[^'\]+' cannot support this command\..*$gdb_prompt $" { set supports_schedule_locking 0 }