public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Enze Li <lienze2010@hotmail.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: prevent the use of the clear command to remove the internal breakpoint (PR cli/7161)
Date: Mon, 14 Mar 2022 13:53:44 +0000	[thread overview]
Message-ID: <afcccbd6-5162-c9ee-4741-2394ba94618a@palves.net> (raw)
In-Reply-To: <MEAP282MB02934158E060B08C8A69930EDD0F9@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM>

Hi!

On 2022-03-14 12:24, Enze Li via Gdb-patches wrote:
> This patch fixes the PR cli/7161 - "clear command removes internal
> breakpoints".
> 
> In this patch, a new function "internal_breakpoint" is added to
> determine whether the breakpoint is internal or not.  If the
> breakpoint is internal when using the clear command, no action will
> be taken, thus preventing the use of the clear command to remove
> the interal breakpoint.
> 
> Tested on x86_64-linux.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7161
> ---
>  gdb/breakpoint.c | 10 +++++++++-
>  gdb/breakpoint.h |  3 +++
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index a3cfeea6989..08628d885e7 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -6477,6 +6477,13 @@ pending_breakpoint_p (struct breakpoint *b)
>    return b->loc == NULL;
>  }
>  
> +/* See breakpoint.h.  */
> +bool
> +internal_breakpoint (struct breakpoint *b)
> +{
> +  return b->ops == &internal_breakpoint_ops;
> +}
> +

The clear command shouldn't delete momentary breakpoints either (those have bp num == 0),
nor internal breakpoints created via Python's gdb.Breakpoint, I think.  Neither of these
use internal_breakpoint_ops. 

I think we should check the existing user_breakpoint_p instead.

This should really have a testcase in the gdb testsuite.

Pedro Alves

  reply	other threads:[~2022-03-14 13:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-14 12:24 Enze Li
2022-03-14 13:53 ` Pedro Alves [this message]
2022-03-17 14:30   ` Enze Li
2022-03-14 13:55 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afcccbd6-5162-c9ee-4741-2394ba94618a@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    --cc=lienze2010@hotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).