public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Enze Li <lienze2010@hotmail.com>
To: gdb-patches@sourceware.org
Subject: [PING^2][PATCH v2] gdb: fix using clear command to delete non-user breakpoints(PR cli/7161)
Date: Thu, 14 Apr 2022 13:58:26 +0800	[thread overview]
Message-ID: <MEAP282MB02930B7581FB94F068D520DEDDEF9@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <MEAP282MB029318332185354DA7DF4F15DD129@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM>

Ping^2.  :-)

Thanks,
Enze

On Thu, 2022-03-17 at 22:24 +0800, Enze Li via Gdb-patches wrote:
> The clear command shouldn't delete momentary and internal
> breakpoints,
> nor internal breakpoints created via Python's gdb.Breakpoint.
> 
> This patch fixes this issue and adds a testcase.
> 
> Regression tested on x86_64 openSUSE Tumbleweed.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=7161
> ---
>  gdb/breakpoint.c                  |  3 +-
>  gdb/testsuite/gdb.base/pr7161.c   | 25 +++++++++++++
>  gdb/testsuite/gdb.base/pr7161.exp | 59
> +++++++++++++++++++++++++++++++
>  3 files changed, 86 insertions(+), 1 deletion(-)
>  create mode 100644 gdb/testsuite/gdb.base/pr7161.c
>  create mode 100644 gdb/testsuite/gdb.base/pr7161.exp
> 
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index a3cfeea6989..ee1ce793593 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -10979,7 +10979,8 @@ clear_command (const char *arg, int from_tty)
>  	{
>  	  int match = 0;
>  	  /* Are we going to delete b?  */
> -	  if (b->type != bp_none && !is_watchpoint (b))
> +	  if (b->type != bp_none && !is_watchpoint (b)
> +	      && user_breakpoint_p (b))
>  	    {
>  	      for (bp_location *loc : b->locations ())
>  		{
> diff --git a/gdb/testsuite/gdb.base/pr7161.c
> b/gdb/testsuite/gdb.base/pr7161.c
> new file mode 100644
> index 00000000000..b5a3a8ccb30
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/pr7161.c
> @@ -0,0 +1,25 @@
> +/* This test is part of GDB, the GNU debugger.
> +
> +   Copyright 2022 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or
> modify
> +   it under the terms of the GNU General Public License as published
> by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <
> http://www.gnu.org/licenses/>;.  */
> +
> +#include <stdio.h>
> +
> +int
> +main ()
> +{
> +  printf("Hello,world!\n"); /* break here */
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.base/pr7161.exp
> b/gdb/testsuite/gdb.base/pr7161.exp
> new file mode 100644
> index 00000000000..533e61d1795
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/pr7161.exp
> @@ -0,0 +1,59 @@
> +# Copyright 2022 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or
> modify
> +# it under the terms of the GNU General Public License as published
> by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <
> http://www.gnu.org/licenses/>;.
> +
> +proc get_maint_info_bp { var } {
> +    global expect_out
> +    global gdb_prompt
> +
> +    gdb_test_multiple "maint info break -1" "find address of
> internal bp $var" {
> +	-re ".*(0x\[0-9a-f\]+).*$gdb_prompt $" {
> +            return $expect_out(1,string)
> +	}
> +        timeout { 
> +	    perror "couldn't find address of $var"
> +	    return ""
> +        }
> +    }
> +    return ""
> +}
> +
> +standard_testfile .c
> +
> +if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}"
> executable {debug}] != "" } {
> +     untested "failed to compile"
> +     return -1
> +}
> +
> +# Start with a fresh gdb.
> +clean_restart ${binfile}
> +
> +if ![runto_main] then {
> +    return 0
> +}
> +
> +gdb_test "break [gdb_get_line_number "break here"]" \
> +	".*Breakpoint.* at .*" \
> +	"set breakpoint"
> +
> +set bp_addr [get_maint_info_bp "-1"]
> +
> +gdb_test "maint info break -1" \
> +    "-1.*shlib events.*keep y.*$bp_addr.*" \
> +    "maint info breakpoint -1 error"
> +
> +gdb_test "clear *$bp_addr" \
> +    "No breakpoint at \\*$bp_addr." \
> +    "clear internal breakpoint error"
> +


  parent reply	other threads:[~2022-04-14  5:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220314122406.24889-1-lienze2010@hotmail.com>
2022-03-17 14:24 ` [PATCH " Enze Li
2022-03-23 14:25   ` Enze Li
2022-04-14  5:58   ` Enze Li [this message]
2022-04-15 16:41   ` Tom Tromey
2022-04-16  3:42     ` [PATCH v3] " Enze Li
2022-04-17 21:26       ` Tom Tromey
2022-04-18 16:04       ` Pedro Alves
2022-04-19 14:07         ` Enze Li
2022-04-22 15:01           ` Pedro Alves
2022-04-18 16:12       ` Tom Tromey
2022-04-19  2:10         ` Enze Li
2022-04-19  3:26           ` Tom Tromey
2022-04-18 23:49       ` Simon Marchi
2022-04-19  3:37         ` Simon Marchi
2022-04-19 13:32           ` Enze Li
2022-04-17  7:18     ` [PATCH RESEND " Enze Li
2022-04-17 22:29       ` Lancelot SIX
2022-04-21 14:29       ` Enze Li

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=MEAP282MB02930B7581FB94F068D520DEDDEF9@MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM \
    --to=lienze2010@hotmail.com \
    --cc=gdb-patches@sourceware.org \
    /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).