From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from AUS01-ME3-obe.outbound.protection.outlook.com (mail-me3aus01olkn2157.outbound.protection.outlook.com [40.92.63.157]) by sourceware.org (Postfix) with ESMTPS id 955A43858C50 for ; Wed, 23 Mar 2022 14:25:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 955A43858C50 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3HjlHyDX+8zuNLnwElBM6RHFYvrPy+JWDz+Ro4PR5rh4OSEXK/6LndoNR7ctnQyybQiF/455Gu6QuxfvyRQ3a2lrgJhQokS5BbMpsH/IHRG9aJdaxQjVGBVaglwdDw5+y9I6x57rAVg2KYiTLv109pL+gqSJueMt5/oyE1C1hCs+J/2vecmUo57YCmLbJ7W3S5fL8CEnCaLBWTKz5ZELBt6N4iYN5rfjsBhowPGzen02iUNV/Y+5MSrU8ft8XvJI32fpYMmhaCn9dqsYUpTajapM8cqhCjx3KHv46NBihvz9PVDgiJYUb1D75qRF4VSq4GBZ4YogQ86EcOD8c/wqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ENoAEzEHlFAOkb8Lk59qaGHwzSwfP/vAk1gvpvyKzqQ=; b=KlWXM5Tqx3cfuSW0WLMIXxnYda76+hcMfDoN+FwpR3nHUavAvLZew28Jt/DD9vIeZJOIE2xf4iTG0zkHUHvfW6Y/C7zK/kQu7RLs4KB2yshgpeKTGrm0/F22Vq4NGbPyNCN4Z+w1yy6ppu+CiFW55072dP1MzJqN5opmeoXYiCBOZNe8BHNLDp6V7xIhr47bSVbQpi1v/t9ZhDPivuvT4+6onUSuDg0kBc2a3lKdbkSRWbxHoYM23KNkgi3FV4bPF/O8SF/dkGAbIFZ1pftCrakXe3reHuVdolqkuy2KmwU+BwCg2YbvTb1Y6UbdGAwu62vHHidVr8vo4l6o04HntA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:71::10) by MEYP282MB2104.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:c1::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.18; Wed, 23 Mar 2022 14:25:53 +0000 Received: from MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM ([fe80::5142:5d29:c331:4075]) by MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM ([fe80::5142:5d29:c331:4075%3]) with mapi id 15.20.5081.023; Wed, 23 Mar 2022 14:25:53 +0000 Message-ID: Subject: Re: [PATCH v2] gdb: fix using clear command to delete non-user breakpoints(PR cli/7161) From: Enze Li To: gdb-patches@sourceware.org Cc: pedro@palves.net, tom@tromey.com Date: Wed, 23 Mar 2022 22:25:48 +0800 In-Reply-To: References: <20220314122406.24889-1-lienze2010@hotmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 Content-Transfer-Encoding: 8bit X-TMN: [InDIn35cIOuVP0gMfo8TCrbL5B/UNwTa] X-ClientProxiedBy: HK2PR03CA0065.apcprd03.prod.outlook.com (2603:1096:202:17::35) To MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:71::10) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3108ec34-d409-4086-1a0f-08da0cd9094d X-MS-TrafficTypeDiagnostic: MEYP282MB2104:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pvBHfmqxE6V0FGkamYrpC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ZYTdQMlE4VWxyN3pYRDNFbWppZmZiMllxOEZ5UEo1bmdQ?= =?utf-8?B?Mml4MkpONEg2TGhpbVBsSVNOZytseDB0eXQ5OEVuOHhPTWZRamNoL0ZoZzBl?= =?utf-8?B?TWpIQTcveko2WTZqYWVzTkcxNGpKdFh0YUFkVW9lUmhRLzQ3bU16QTlBYm1z?= =?utf-8?B?anVqZ3FhemM2dXk3ZjRRYUU3enZ6NWNuWW5zdVhzVTkreWtZeFgyMEJBMjhF?= =?utf-8?B?VUtLOUIrVzlXQ3NtemNpQmNxcm5Zc2pvVTFJMFozTW5RKzRHdmRYZER3bVo2?= =?utf-8?B?TVhzazJoWWxmYWdQa2hyTzhqcmM0Q3dIUVBGZkUyMHVvaGRPR2xzb0w5dXBL?= =?utf-8?B?SnBDdz09?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-746f3.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 3108ec34-d409-4086-1a0f-08da0cd9094d X-MS-Exchange-CrossTenant-AuthSource: MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2022 14:25:53.3580 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MEYP282MB2104 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2022 14:26:00 -0000 Kindly Ping. The previous version is here, https://sourceware.org/pipermail/gdb-patches/2022-March/186607.html 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 > .  */ > + > +#include > + > +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 > . > + > +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" > +