From patchwork Sat May 23 15:28:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 6902 Received: (qmail 62703 invoked by alias); 23 May 2015 15:29:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 62690 invoked by uid 89); 23 May 2015 15:29:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 23 May 2015 15:29:01 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4NFSw6O021236 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 23 May 2015 11:28:59 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4NFSuLW031754; Sat, 23 May 2015 11:28:57 -0400 Message-ID: <55609CB8.3050104@redhat.com> Date: Sat, 23 May 2015 16:28:56 +0100 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Doug Evans CC: gdb-patches@sourceware.org Subject: Re: [PATCH 11/18] Implement all-stop on top of a target running non-stop mode References: <047d7b2e4e86aaa0ff0516afeb5c@google.com> In-Reply-To: <047d7b2e4e86aaa0ff0516afeb5c@google.com> On 05/22/2015 07:35 PM, Doug Evans wrote: > I found another instance in keep_going_stepped_thread: > > if (target_is_non_stop_p ()) > resume_ptid = inferior_ptid; > else > resume_ptid = user_visible_resume_ptid > (tp->control.stepping_command); > > Can you add a comment here too? > Thanks. > [An alternative would be to add a utility function that > contained this code and then put the comment there, > but I'll leave it to you to decide if you want > such a function.] That's a good idea. How about this? I'll fold it in if it looks good. --- gdb/infrun.c | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index d9fc4e5..fe48c91 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2173,6 +2173,25 @@ user_visible_resume_ptid (int step) return resume_ptid; } +/* Return a ptid representing the set of threads that we will resume, + in the perspective of the target, assuming run control handling + does not require leaving some threads stopped (e.g., stepping past + breakpoint). USER_STEP indicates whether we're about to start the + target for a stepping command. */ + +static ptid_t +internal_resume_ptid (int user_step) +{ + /* In non-stop, we always control threads individually. Note that + the target may always work in non-stop mode even with "set + non-stop off", in which case user_visible_resume_ptid could + return a wildcard ptid. */ + if (target_is_non_stop_p ()) + return inferior_ptid; + else + return user_visible_resume_ptid (user_step); +} + /* Wrapper for target_resume, that handles infrun-specific bookkeeping. */ @@ -2384,15 +2403,7 @@ resume (enum gdb_signal sig) insert_single_step_breakpoint (gdbarch, aspace, pc); insert_breakpoints (); - /* In non-stop, we always control threads individually. - Note that the target may always work in non-stop mode - even with "set non-stop off", in which case - user_visible_resume_ptid could return a wildcard - ptid. */ - if (target_is_non_stop_p ()) - resume_ptid = inferior_ptid; - else - resume_ptid = user_visible_resume_ptid (user_step); + resume_ptid = internal_resume_ptid (user_step); do_target_resume (resume_ptid, 0, GDB_SIGNAL_0); discard_cleanups (old_cleanups); tp->resumed = 1; @@ -2501,20 +2512,9 @@ resume (enum gdb_signal sig) use singlestep breakpoint. */ gdb_assert (!(thread_has_single_step_breakpoints_set (tp) && step)); - /* Decide the set of threads to ask the target to resume. Start - by assuming everything will be resumed, than narrow the set - by applying increasingly restricting conditions. */ - resume_ptid = user_visible_resume_ptid (user_step); - - /* Maybe resume a single thread after all. */ - if (target_is_non_stop_p ()) - { - /* If non-stop mode, threads are always controlled - individually. */ - resume_ptid = inferior_ptid; - } - else if ((step || thread_has_single_step_breakpoints_set (tp)) - && tp->control.trap_expected) + /* Decide the set of threads to ask the target to resume. */ + if ((step || thread_has_single_step_breakpoints_set (tp)) + && tp->control.trap_expected) { /* We're allowing a thread to run past a breakpoint it has hit, by single-stepping the thread with the breakpoint @@ -2523,6 +2523,8 @@ resume (enum gdb_signal sig) breakpoint if allowed to run. */ resume_ptid = inferior_ptid; } + else + resume_ptid = internal_resume_ptid (user_step); if (execution_direction != EXEC_REVERSE && step && breakpoint_inserted_here_p (aspace, pc)) @@ -6833,10 +6835,7 @@ keep_going_stepped_thread (struct thread_info *tp) stop_pc); tp->resumed = 1; - if (target_is_non_stop_p ()) - resume_ptid = inferior_ptid; - else - resume_ptid = user_visible_resume_ptid (tp->control.stepping_command); + resume_ptid = internal_resume_ptid (tp->control.stepping_command); do_target_resume (resume_ptid, 0, GDB_SIGNAL_0); } else