From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26308 invoked by alias); 11 Mar 2016 11:54:06 -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 26140 invoked by uid 89); 11 Mar 2016 11:54:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2068, existed, defer, bp 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 11:53:53 +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 (Postfix) with ESMTPS id B5416BF9F8; Fri, 11 Mar 2016 11:53:52 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2BBrpgB004348; Fri, 11 Mar 2016 06:53:52 -0500 Subject: Re: [PATCH 5/8] Insert breakpoint even when the raw breakpoint is found To: Yao Qi , gdb-patches@sourceware.org References: <1457088276-1170-1-git-send-email-yao.qi@linaro.org> <1457088276-1170-6-git-send-email-yao.qi@linaro.org> From: Pedro Alves Message-ID: <56E2B1CF.7080101@redhat.com> Date: Fri, 11 Mar 2016 11:54: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-6-git-send-email-yao.qi@linaro.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2016-03/txt/msg00184.txt.bz2 On 03/04/2016 10:44 AM, Yao Qi wrote: > When GDBserver inserts a breakpoint, it looks for raw breakpoint, if > the raw breakpoint is found, increase its refcount, and return. This > doesn't work when it steps over a breakpoint using software single > step and the underneath instruction of breakpoint is branch to self. > > When stepping over a breakpoint on ADDR using software single step, > GDBserver uninsert the breakpoint, so the corresponding raw breakpoint > RAW's 'inserted' flag is zero. Then, GDBserver insert single step > breakpoint at the same address ADDR because the instruction is branch > to self, the same raw brekapoint RAW is found, and increase the > refcount. However, the raw breakpoint is not inserted, and the > program won't stop. > > gdb/gdbserver: > > 2016-03-04 Yao Qi > > * mem-break.c (set_raw_breakpoint_at): Insert raw breakpoint > when its refcount is increased. > --- > gdb/gdbserver/mem-break.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c > index b06f8e9..73c5e8a 100644 > --- a/gdb/gdbserver/mem-break.c > +++ b/gdb/gdbserver/mem-break.c > @@ -411,7 +411,22 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_ADDR where, int kind, > if (bp != NULL) > { > bp->refcount++; > - return bp; > + > + if (!bp->inserted) > + { > + *err = the_target->insert_point (bp->raw_type, bp->pc, bp->kind, > + bp); > + if (*err != 0) > + { > + if (debug_threads) > + debug_printf ("Failed to insert breakpoint at 0x%s (%d).\n", > + paddress (where), *err); > + free (bp); If this raw breapoint already existed, and we just bumped the refcount, then this free leaves those other breakpoints with a stale pointer. But I'd like to defer this patch until we reach a conclusion on the previous one on the gdb side. > + return NULL; > + } > + bp->inserted = 1; > + } > + return bp; > } > > bp = XCNEW (struct raw_breakpoint); > -- Thanks, Pedro Alves