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

Hi Pedro, Tom

Thanks to both of you for the code review.  I have sent the v2 of the
patch to the list, adding a testcase dedicated to testing PR7161.

Thanks,
Enze

On Mon, 2022-03-14 at 13:53 +0000, Pedro Alves wrote:
> 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-17 14:30 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
2022-03-17 14:30   ` Enze Li [this message]
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=MEAP282MB0293CB238EBC785912DEA796DD129@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM \
    --to=lienze2010@hotmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    --cc=tom@tromey.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).