From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id 0B86B3858422 for ; Mon, 12 Jun 2023 07:50:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B86B3858422 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686556206; x=1718092206; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HgsRR65BAlz+eAZS0RHaeqQEPM8VtpdaMGYe6x1g0F0=; b=QGSbpVY1ZbPKFn1Nl1vb9Ib1UJo0WupFov6lwi2TA3X+xDPj+7kO8Aug px31Xb9hPjyc2JOsC0nYIEeYt/wn8+fzQGy3TxLxWyEtoitMq+im3ywxn ios49tFZOfb0FzioIDEUDwTmN9BImdTIhiARim21Ux1gZxfjxuviY0JPs Fb/Ohw+AvL3foEFpT0C/2FsOlcuq4q2UJFrQgyhIzlrywq4HiQ6hDtHrJ jr/kCmyixlSdkjZwBla+4K0QQGOWRnDK2C46hS7j3PMDzF1MSEvBJAzyj yhW3acXw92S//HrrzF1Ae2if+azTFq61kY9wuBhEYV4ZGQFucDYvm7loW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10738"; a="338335556" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="338335556" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 00:50:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10738"; a="957909846" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="957909846" Received: from labpc2315.iul.intel.com (HELO localhost) ([172.28.50.57]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 00:50:03 -0700 From: Christina Schimpe To: gdb-patches@sourceware.org Cc: blarsen@redhat.com, aburgess@redhat.com Subject: [PATCH v2 1/1] gdb, infrun: refactor part of `proceed` into separate function Date: Mon, 12 Jun 2023 09:49:27 +0200 Message-Id: <20230612074927.424961-2-christina.schimpe@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230612074927.424961-1-christina.schimpe@intel.com> References: <20230612074927.424961-1-christina.schimpe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 List-Id: From: Mihails Strasuns Split thread resuming block into separate function. Co-Authored-By: Christina Schimpe --- gdb/infrun.c | 120 ++++++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index 58da1cef29e..ec41b658864 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -3268,6 +3268,64 @@ check_multi_target_resumption (process_stratum_target *resume_target) } } + /* Helper function for `proceed`. Check if thread TP is suitable for + resuming, and, if it is, switch to the thread and call + `keep_going_pass_signal`. If TP is not suitable for resuming then + this function will just return without switching threads. */ + +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; + } + + /* There are further two scenarios for which we must not resume the thread: + - 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 +3514,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 (); } -- 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928