From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 78633 invoked by alias); 11 Mar 2016 12:04:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 78615 invoked by uid 89); 11 Mar 2016 12:04:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 spammy= 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; Fri, 11 Mar 2016 12:04:27 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 80F5985543; Fri, 11 Mar 2016 12:04:26 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2BC4P6x029947; Fri, 11 Mar 2016 07:04:25 -0500 Subject: Re: [PATCH 7/8] Resume the inferior with signal rather than stepping over To: Yao Qi , gdb-patches@sourceware.org References: <1457088276-1170-1-git-send-email-yao.qi@linaro.org> <1457088276-1170-8-git-send-email-yao.qi@linaro.org> From: Pedro Alves Message-ID: <56E2B449.7010905@redhat.com> Date: Fri, 11 Mar 2016 12:04:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1457088276-1170-8-git-send-email-yao.qi@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-03/txt/msg00185.txt.bz2 On 03/04/2016 10:44 AM, Yao Qi wrote: > When GDBserver steps over a breakpoint using software single step, it > enqueues the signal, single step and deliver the signal in the next > resume if step over is not needed. In this way, the program won't > receive the signal if the conditional breakpoint is set a branch to > self instruction, because the step over is always needed. > > This patch removes the restriction that don't deliver the signal to > the inferior if we are trying to reinsert a breakpoint for software > single step and change the decision on resume vs. step-over when the > LWP has pending signals to deliver. Once the handler returns, it'll retrap the same breakpoint we already stopped for, and thus I think we'll count a spurious tracepoint/breakpoint hit. Sounds like we'll need to do like GDB does and remember that we are advancing past a signal handler, and need to get back to stepping over the breakpoint if/when the handler returns successfully? > > gdb/gdbserver: > > 2016-03-04 Yao Qi > > * linux-low.c (LWP_SIGNAL_CAN_BE_DELIVERED): Adjust. > (need_step_over_p): Return zero if the LWP has pending signals > can be delivered on software single step target. > --- > gdb/gdbserver/linux-low.c | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c > index 2330e67..9bae787 100644 > --- a/gdb/gdbserver/linux-low.c > +++ b/gdb/gdbserver/linux-low.c > @@ -4119,12 +4119,10 @@ single_step (struct lwp_info* lwp) > } > > /* The signal can not be delivered to the inferior if we are trying to > - reinsert a breakpoint for software single step or we're trying to > finish a fast tracepoint collect. */ > > #define LWP_SIGNAL_CAN_BE_DELIVERED(LWP) \ > - !(((LWP)->bp_reinsert != 0 && can_software_single_step ()) \ > - || (LWP)->collecting_fast_tracepoint) > + !((LWP)->collecting_fast_tracepoint) > > /* Resume execution of LWP. If STEP is nonzero, single-step it. If > SIGNAL is nonzero, give it that signal. */ > @@ -4572,6 +4570,20 @@ need_step_over_p (struct inferior_list_entry *entry, void *dummy) > return 0; > } > > + /* On software single step target, resume the inferior with signal > + rather than stepping over. */ > + if (can_software_single_step () > + && lwp->pending_signals != NULL > + && LWP_SIGNAL_CAN_BE_DELIVERED (lwp)) > + { > + if (debug_threads) > + debug_printf ("Need step over [LWP %ld]? Ignoring, has pending" > + " signals.\n", > + lwpid_of (thread)); > + > + return 0; I notice this missed restoring the current thread (below). > + } > + > saved_thread = current_thread; > current_thread = thread; > > -- Thanks, Pedro Alves