From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95088 invoked by alias); 25 Apr 2016 08:45:12 -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 95016 invoked by uid 89); 25 Apr 2016 08:45:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=bp, xcnew, XCNEW, yours X-HELO: mail-pf0-f180.google.com Received: from mail-pf0-f180.google.com (HELO mail-pf0-f180.google.com) (209.85.192.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 25 Apr 2016 08:44:53 +0000 Received: by mail-pf0-f180.google.com with SMTP id y69so44138568pfb.1 for ; Mon, 25 Apr 2016 01:44:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=eUPvVMYtFmTzWJE6DBz53kP2Wc231RVbe6xFUWIMdaM=; b=X8FQDUx/sL5SXl+LKraNIDEB4fijfg+thlpeg9KAEDh4Gu+E9TFmm3bmmjWb2uWQL4 og5jq2eA+L9AVU8+svxJ/oXiK/T2aQnGeAIBQk2NTaNXx0MWJIvytM7JG/kbjI65EjNx lDTGXlTJmMl6/ls9oCrHFb66tipRU8smTqyC59Liw/qSEedYNKgNADuD6FV6tOUdGfLJ 6+cgogVssy5buLmsU1i/Z0HZaxx/IH3P3AJPNp0lEJ4zraK/UdU4HjnpgRIoIAkm/i44 PCJYJdvUM0EEOY/S9Wf4rSBHXD7cLADu0WCiAJT5AcMUPid9RhDcdPfS2l8RY9eTLsZH ooSw== X-Gm-Message-State: AOPr4FWQYPsAgwbMCXfqvM9d3MwF/q8csXpU1jq0ES737X5klyma400gEGcxkI3Amtmx/w== X-Received: by 10.98.76.216 with SMTP id e85mr47224901pfj.121.1461573891750; Mon, 25 Apr 2016 01:44:51 -0700 (PDT) Received: from E107787-LIN (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id p189sm26581206pfb.51.2016.04.25.01.44.49 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 25 Apr 2016 01:44:51 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: Yao Qi , gdb-patches@sourceware.org Subject: Re: [PATCH 4/7] Insert breakpoint even when the raw breakpoint is found References: <1458749384-19793-1-git-send-email-yao.qi@linaro.org> <1458749384-19793-5-git-send-email-yao.qi@linaro.org> <570BB7AF.1080703@redhat.com> <86y48jjj0v.fsf@gmail.com> <570CC2DA.6050504@redhat.com> Date: Mon, 25 Apr 2016 08:45:00 -0000 In-Reply-To: <570CC2DA.6050504@redhat.com> (Pedro Alves's message of "Tue, 12 Apr 2016 10:41:46 +0100") Message-ID: <864maqgjrn.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2016-04/txt/msg00543.txt.bz2 Pedro Alves writes: > Nothing else, that's all I meant. > > Actually, now that I look closer, I think we could merge the new > code with the code that handles inserting a new raw breakpoint just below. > > For example: Looks yours is good to me. I pushed it in. --=20 Yao (=E9=BD=90=E5=B0=A7) =46rom 20249ae4551ae7b2193caed73d9ce8d594f38754 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Mon, 25 Apr 2016 09:43:36 +0100 Subject: [PATCH] Insert breakpoint even when the raw breakpoint is found 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-04-25 Pedro Alves Yao Qi * mem-break.c (set_raw_breakpoint_at): Create a raw breakpoint object. Insert it if it is not inserted yet. Increase the refcount and link it into the proc's raw breakpoint list. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0b08605..5c94832 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2016-04-25 Pedro Alves + Yao Qi + + * mem-break.c (set_raw_breakpoint_at): Create a raw breakpoint + object. Insert it if it is not inserted yet. Increase the + refcount and link it into the proc's raw breakpoint list. + 2016-04-25 Yao Qi =20 * breakpoint.c (should_be_inserted): Return 0 if the location's diff --git a/gdb/gdbserver/mem-break.c b/gdb/gdbserver/mem-break.c index b06f8e9..419db9e 100644 --- a/gdb/gdbserver/mem-break.c +++ b/gdb/gdbserver/mem-break.c @@ -390,6 +390,7 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_AD= DR where, int kind, { struct process_info *proc =3D current_process (); struct raw_breakpoint *bp; + struct cleanup *old_chain =3D make_cleanup (null_cleanup, NULL); =20 if (type =3D=3D raw_bkpt_type_sw || type =3D=3D raw_bkpt_type_hw) { @@ -408,32 +409,39 @@ set_raw_breakpoint_at (enum raw_bkpt_type type, CORE_= ADDR where, int kind, else bp =3D find_raw_breakpoint_at (where, type, kind); =20 - if (bp !=3D NULL) + if (bp =3D=3D NULL) { - bp->refcount++; - return bp; + bp =3D XCNEW (struct raw_breakpoint); + bp->pc =3D where; + bp->kind =3D kind; + bp->raw_type =3D type; + make_cleanup (xfree, bp); } =20 - bp =3D XCNEW (struct raw_breakpoint); - bp->pc =3D where; - bp->kind =3D kind; - bp->refcount =3D 1; - bp->raw_type =3D type; - - *err =3D the_target->insert_point (bp->raw_type, bp->pc, bp->kind, bp); - if (*err !=3D 0) + if (!bp->inserted) { - if (debug_threads) - debug_printf ("Failed to insert breakpoint at 0x%s (%d).\n", - paddress (where), *err); - free (bp); - return NULL; + *err =3D the_target->insert_point (bp->raw_type, bp->pc, bp->kind, b= p); + if (*err !=3D 0) + { + if (debug_threads) + debug_printf ("Failed to insert breakpoint at 0x%s (%d).\n", + paddress (where), *err); + + do_cleanups (old_chain); + return NULL; + } + + bp->inserted =3D 1; } =20 - bp->inserted =3D 1; - /* Link the breakpoint in. */ - bp->next =3D proc->raw_breakpoints; - proc->raw_breakpoints =3D bp; + discard_cleanups (old_chain); + + /* Link the breakpoint in, if this is the first reference. */ + if (++bp->refcount =3D=3D 1) + { + bp->next =3D proc->raw_breakpoints; + proc->raw_breakpoints =3D bp; + } return bp; } =20