This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 4/7] Insert breakpoint even when the raw breakpoint is found
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches at sourceware dot org
- Date: Mon, 11 Apr 2016 15:41:51 +0100
- Subject: Re: [PATCH 4/7] Insert breakpoint even when the raw breakpoint is found
- Authentication-results: sourceware.org; auth=none
- References: <1458749384-19793-1-git-send-email-yao dot qi at linaro dot org> <1458749384-19793-5-git-send-email-yao dot qi at linaro dot org>
On 03/23/2016 04:09 PM, Yao Qi wrote:
> ---
> 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..af01288 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);
> + bp->refcount--;
Can we only increase the refcount if inserting succeeds? gdbserver can
use gdb exceptions nowadays, and even though lots of current gdbserver
code isn't exception safe, it'd be nice to start considering that.
> + return NULL;
> + }
> + bp->inserted = 1;
> + }
> + return bp;
> }
>
> bp = XCNEW (struct raw_breakpoint);
>
Thanks,
Pedro Alves