From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from AUS01-ME3-obe.outbound.protection.outlook.com (mail-me3aus01olkn2176.outbound.protection.outlook.com [40.92.63.176]) by sourceware.org (Postfix) with ESMTPS id 714CC385840F for ; Thu, 17 Mar 2022 14:24:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 714CC385840F ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XAHeOvnc6KFEvdqB/Yd6blWSMWKqJq2fMhRXmpvwHxlxzhcf6n+Qd5tsS9EwY3y8DDagGNd24PC3EMTIF2uATMvnzIQ3fPWf2f1p490o0wkxoMQqHVhKMABfwSe8yXNuZZ4gT5cNq6b5SLIHo1aYJwi3NpNmjWrPaJOQ1lnb4KhBvZPYGrcAP6OrNxapqTydWrvWpCbkmdtYIMIgYYhmD97LB2s1653+ughVyUGPIrizFRxjiS1C8zq1k/+U6p/xepGMi46+2FnaZWRohBOAjgKFrQEmcktw2F0E6KbwaD4zJya5zGVZVMEzwhm4m1xiYq1aN9BO1jA6JzI083bnew== 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=VwuA8MJv/FnjQiBCbkl4GsmnHIXaKXyAAe8nVGlRxHQ=; b=a71RYNhb6F6ai5cdJVlgGr+8bclcMrgXGZWphV0lRjl+0ZrZDFRD+YLYMY7RhlqlE4M4lK9jCWUBVyAfFh3vTvWmMxq5vQr3czUF5FDpaTHd1lG+VuTmCDwhQs0ZnSUThWDumQlQE6vYPR5czNBwMLpuOQcrB/ISjeE4YapQu7GbzAoZ8tC0trG+mgNVz9htUj6piNMZ7O+T7r23DxpFt/Z5z9VehO00ap20ZTJ9Ooslmmqb/gczsfGwbnn3ys6yPi0DDYqrI0ohooX2zxKSD/KmGWxH7L4MNq8o70GRMT8rv5xi301Y41tp9+Am0a5PGqSj4FYmNwrhsf3QORyuXQ== 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 MEAP282MB1414.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:64::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.25; Thu, 17 Mar 2022 14:24:28 +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.017; Thu, 17 Mar 2022 14:24:28 +0000 From: Enze Li To: gdb-patches@sourceware.org Subject: [PATCH v2] gdb: fix using clear command to delete non-user breakpoints(PR cli/7161) Date: Thu, 17 Mar 2022 22:24:15 +0800 Message-ID: X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314122406.24889-1-lienze2010@hotmail.com> References: <20220314122406.24889-1-lienze2010@hotmail.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [omuDD4lYJ3BeeOnyR4K+lC0b4GAb1WjW] X-ClientProxiedBy: HK2PR0302CA0001.apcprd03.prod.outlook.com (2603:1096:202::11) To MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:71::10) X-Microsoft-Original-Message-ID: <20220317142415.14424-1-lienze2010@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3cb67fee-8243-4f2a-4183-08da0821d883 X-MS-TrafficTypeDiagnostic: MEAP282MB1414:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jt9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AEObwuE+IjKiCg4+DIxl6WjaAaQ08syuz6A4yBP+hUwlDpBlPeP/8Xxm9T?= =?us-ascii?Q?O3CowqGvbDoQwjMzFppkbK62E+iCU7jBbLhv2rB4xszNAJouLHTFWAZF76fC?= =?us-ascii?Q?sYhZAZ75g3zCV/rQEw531y1MX57Fkb3C0NXMlGWXBS49k6gvA8Hx1LFhkIp3?= =?us-ascii?Q?Wp2R7dnICewAJaPocH35ap+CXY9yESqSo7n1jMpYlpRefl6TZjjdr/l/JLLc?= =?us-ascii?Q?qEihtiIkveiUlgztUrfr5vksqBOEhJwT7SUf+cYD0l0DrWfpgEQ0X/WePoa0?= =?us-ascii?Q?i4DMbwWhelkAPROY10Qw6ybzRRQVNj59fUhT8gdQqr58KF1okgdAJY3s6oRb?= =?us-ascii?Q?iY4uVO1j+qEHSTj+yELFYVoSg4FMJHu517FUMuUVaiG0Rq08XSudJ8cNMvln?= =?us-ascii?Q?5BDyS/zzy6+DwwN7mMPlMzGtNloIMW/LhDoLzZHydTyvDE37lrQIuqaG66v6?= =?us-ascii?Q?+C/5JMrfhRbtHrmSWAoJYYrZCut6/KrOYor5PQTVI054sqZ3CwX64OtyTEyB?= =?us-ascii?Q?IHVSbqU+hwMD47s8ucEACAPHCYE+3rmPnTKpZxWa7walZIyyURPocMBVafgn?= =?us-ascii?Q?fgJ/O8bTR7M0zxgK/PoRAFJcZTP7wB/v4hRy31qVp0uzSIOUby/WayduHdSI?= =?us-ascii?Q?UR1no5ozHjepn60KLBV10682dVkS/xX9sUwA8HZG/FPxy0SMCZgcMY/kxdF4?= =?us-ascii?Q?Ku9cKYlWMlHdCJM5TsOlZCTP1ce0xU72X6JhVf5vJgqACzyuXA5Knnd/wEVm?= =?us-ascii?Q?12rNRmsONYIdPS0ZTiXEV1Cn6dbyA1O5X++YoA6wYGRPBNKn4tNFQdcNKeAT?= =?us-ascii?Q?XO/BHz8Mgehb4W85nNQE0CqWY9hpK7ctUQ=3D=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-746f3.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 3cb67fee-8243-4f2a-4183-08da0821d883 X-MS-Exchange-CrossTenant-AuthSource: MEAP282MB0293.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Mar 2022 14:24:28.8269 (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: MEAP282MB1414 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, 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: Thu, 17 Mar 2022 14:24:35 -0000 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" + -- 2.35.1