From patchwork Wed Jun 7 07:09:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schimpe, Christina" X-Patchwork-Id: 70704 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 DCE073858025 for ; Wed, 7 Jun 2023 07:10:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCE073858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1686121841; bh=3TkJpOxjwLFz87tIGbMYlN5Kkp1z9n2+1rGRk1QvjnM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=h7snzOMFiEOhXE8EOt2RgZq3cQX3wc1MgpuGOo1W3IIev7oh/N1DZX2e61+9cxzo5 IKWvDBEpkQZIUXt8TjEqmj5630HM9LUz7yQBucyOHnMFFeTg33ahQr3/GznFTwXcfT xfQ3desK2zv99tLOF7IuUFGTPZBXk4Lj3jH7Ammg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id A8B5D3858C54 for ; Wed, 7 Jun 2023 07:10:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A8B5D3858C54 X-IronPort-AV: E=McAfee;i="6600,9927,10733"; a="420459888" X-IronPort-AV: E=Sophos;i="6.00,223,1681196400"; d="scan'208";a="420459888" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2023 00:10:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10733"; a="1039483704" X-IronPort-AV: E=Sophos;i="6.00,223,1681196400"; d="scan'208";a="1039483704" Received: from labpc2315.iul.intel.com (HELO localhost) ([172.28.50.57]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2023 00:10:11 -0700 To: gdb-patches@sourceware.org Subject: [PATCH 1/1] gdb, infrun: refactor part of `proceed` into separate function Date: Wed, 7 Jun 2023 09:09:59 +0200 Message-Id: <20230607070959.3558904-2-christina.schimpe@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Christina Schimpe via Gdb-patches From: "Schimpe, Christina" Reply-To: Christina Schimpe Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From: Mihails Strasuns Split thread resuming block into separate function. Reviewed-By: Bruno Larsen --- gdb/infrun.c | 119 ++++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 59 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 58da1cef29e..571cf29ef32 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3268,6 +3268,63 @@ check_multi_target_resumption (process_stratum_target *resume_target) } } +/* Helper function for `proceed`, does bunch of checks to see + if a thread can be resumed right now, switches to that thread + and moves on to `keep_going_pass_signal`. */ + +static void +proceed_resume_thread_checked (thread_info *tp) +{ + if (!tp->inf->has_execution ()) + { + infrun_debug_printf ("[%s] target has no execution", + tp->ptid.to_string ().c_str ()); + return; + } + + if (tp->resumed ()) + { + infrun_debug_printf ("[%s] resumed", + tp->ptid.to_string ().c_str ()); + gdb_assert (tp->executing () || tp->has_pending_waitstatus ()); + return; + } + + if (thread_is_in_step_over_chain (tp)) + { + infrun_debug_printf ("[%s] needs step-over", + tp->ptid.to_string ().c_str ()); + return; + } + + /* If a thread of that inferior is waiting for a vfork-done + (for a detached vfork child to exec or exit), breakpoints are + removed. We must not resume any thread of that inferior, other + than the one waiting for the vfork-done. + In non-stop, forbid resuming a thread if some other thread of + that inferior is waiting for a vfork-done event (this means + breakpoints are out for this inferior). */ + + if (tp->inf->thread_waiting_for_vfork_done != nullptr + && (tp != tp->inf->thread_waiting_for_vfork_done + || non_stop)) + { + infrun_debug_printf ("[%s] another thread of this inferior is " + "waiting for vfork-done", + tp->ptid.to_string ().c_str ()); + return; + } + + infrun_debug_printf ("resuming %s", + tp->ptid.to_string ().c_str ()); + + execution_control_state ecs (tp); + switch_to_thread (tp); + keep_going_pass_signal (&ecs); + if (!ecs.wait_some_more) + error (_("Command aborted.")); +} + /* Basic routine for continuing the program in various fashions. ADDR is the address to resume at, or -1 for resume where stopped. @@ -3456,67 +3513,11 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal) resume_ptid)) { switch_to_thread_no_regs (tp); - - if (!tp->inf->has_execution ()) - { - infrun_debug_printf ("[%s] target has no execution", - tp->ptid.to_string ().c_str ()); - continue; - } - - if (tp->resumed ()) - { - infrun_debug_printf ("[%s] resumed", - tp->ptid.to_string ().c_str ()); - gdb_assert (tp->executing () || tp->has_pending_waitstatus ()); - continue; - } - - if (thread_is_in_step_over_chain (tp)) - { - infrun_debug_printf ("[%s] needs step-over", - tp->ptid.to_string ().c_str ()); - continue; - } - - /* If a thread of that inferior is waiting for a vfork-done - (for a detached vfork child to exec or exit), breakpoints are - removed. We must not resume any thread of that inferior, other - than the one waiting for the vfork-done. */ - if (tp->inf->thread_waiting_for_vfork_done != nullptr - && tp != tp->inf->thread_waiting_for_vfork_done) - { - infrun_debug_printf ("[%s] another thread of this inferior is " - "waiting for vfork-done", - tp->ptid.to_string ().c_str ()); - continue; - } - - infrun_debug_printf ("resuming %s", - tp->ptid.to_string ().c_str ()); - - execution_control_state ecs (tp); - switch_to_thread (tp); - keep_going_pass_signal (&ecs); - if (!ecs.wait_some_more) - error (_("Command aborted.")); + proceed_resume_thread_checked (tp); } } - else if (!cur_thr->resumed () - && !thread_is_in_step_over_chain (cur_thr) - /* In non-stop, forbid resuming a thread if some other thread of - that inferior is waiting for a vfork-done event (this means - breakpoints are out for this inferior). */ - && !(non_stop - && cur_thr->inf->thread_waiting_for_vfork_done != nullptr)) - { - /* The thread wasn't started, and isn't queued, run it now. */ - execution_control_state ecs (cur_thr); - switch_to_thread (cur_thr); - keep_going_pass_signal (&ecs); - if (!ecs.wait_some_more) - error (_("Command aborted.")); - } + else + proceed_resume_thread_checked (cur_thr); disable_commit_resumed.reset_and_commit (); }