From patchwork Thu Feb 26 19:01:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 5320 Received: (qmail 98342 invoked by alias); 26 Feb 2015 19:01:42 -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 98330 invoked by uid 89); 26 Feb 2015 19:01:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham 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; Thu, 26 Feb 2015 19:01:40 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1QJ1aPC031519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 26 Feb 2015 14:01:37 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1QJ1Ylu019987; Thu, 26 Feb 2015 14:01:35 -0500 Message-ID: <54EF6D8E.7060405@redhat.com> Date: Thu, 26 Feb 2015 19:01:34 +0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Yao Qi CC: gdb-patches@sourceware.org Subject: Re: [pushed] gdbserver: redo stepping over breakpoint that was on top of a permanent breakpoint References: <1424723261-15719-1-git-send-email-palves@redhat.com> <86lhjnxzrs.fsf@gmail.com> In-Reply-To: <86lhjnxzrs.fsf@gmail.com> On 02/24/2015 12:25 PM, Yao Qi wrote: > Pedro Alves writes: > >> + unsigned int increment_pc; >> + >> + if (the_low_target.breakpoint_len > the_low_target.decr_pc_after_break) >> + increment_pc = the_low_target.breakpoint_len; >> + else >> + increment_pc = the_low_target.decr_pc_after_break; > > AFAICS, the_low_target.breakpoint_len is greater or equal to > the_low_target.decr_pc_after_break. Why don't we use .breakpoint_len > instead? The code is correct, however, the comparison here leads me to > think under what situation .breakpoint_len is less than .decr_pc_after_break. Good point. The history is that I started out by always incrementing by decr_pc_after_break. Later, I recalled that that's not always the same as breakpoint length, and thinking that maybe archs that set decr_pc_after_break may not set breakpoint_len, wrote "increment = max (decr_pc_after_break, breakpoint_len);". That didn't work (we don't define max anywhere), so I expanded that into the "if", and never thought about it again. :-) It's hard to tell whether there are such ports, but likely not. If there are, bp-permanent.exp should catch them failing, I think. :-) So I went ahead and pushed the patch below. Thanks. --- [PATCH] gdbserver/Linux: Simplify stepping past program breakpoint a little .decr_pc_after_break is never higher than .breakpoint_len, so use .breakpoint_len directly. Based on idea from Yao here: https://sourceware.org/ml/gdb-patches/2015-02/msg00689.html gdb/gdbserver/ChangeLog: 2015-02-26 Pedro Alves * linux-low.c (linux_wait_1): When incrementing the PC past a program breakpoint always use the_low_target.breakpoint_len as increment, rather than the maximum between that and the_low_target.decr_pc_after_break. --- gdb/gdbserver/ChangeLog | 7 +++++++ gdb/gdbserver/linux-low.c | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index a130aab..6bb8950 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2015-02-26 Pedro Alves + + * linux-low.c (linux_wait_1): When incrementing the PC past a + program breakpoint always use the_low_target.breakpoint_len as + increment, rather than the maximum between that and + the_low_target.decr_pc_after_break. + 2015-02-23 Pedro Alves * linux-low.c (check_stopped_by_breakpoint): Don't check if the diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 1c66985..c0d3b0d 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -2555,12 +2555,7 @@ linux_wait_1 (ptid_t ptid, if (!ptid_equal (step_over_bkpt, null_ptid) && event_child->stop_reason == LWP_STOPPED_BY_SW_BREAKPOINT) { - unsigned int increment_pc; - - if (the_low_target.breakpoint_len > the_low_target.decr_pc_after_break) - increment_pc = the_low_target.breakpoint_len; - else - increment_pc = the_low_target.decr_pc_after_break; + unsigned int increment_pc = the_low_target.breakpoint_len; if (debug_threads) {