From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) by sourceware.org (Postfix) with ESMTPS id 344553858D1E for ; Mon, 18 Apr 2022 16:04:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 344553858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id x18so11216037wrc.0 for ; Mon, 18 Apr 2022 09:04:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=k4eL4HzH2gH60FCiSVguzDBOjYuKw3e+hDHAFzvi8e4=; b=SRaPWQ1eZGppBzMhT4ZfZV5aMzb6TrKGV2Y/WMaTKXUi1TC6Vofq1xer5Bs17ma4hI iSykvC9PjIw2MvhMUoEFHJSYNeva2+qUEbtX9u2dkeb8b3ytzzLsd4W8ZJjTvpCtoGMN vQ1vd7b2WjGhGk7xXJrl15EZsOGyehs6KXDDE8LzbCoawybKnMXvsBDfXLhoUraudJ9Y s5k6VvsAE/G2WK5Ml1hLSpmSD1aijorq3pCAFehtWcmpQqFJFurWhPXYKy+/LIQzKlfK I8YoknLAS+KiVCUF+vdM7C/3ulBbWDclDAJQfN/BG2oTx4V4yeLEDSwJFGhAx+wVRY28 w88g== X-Gm-Message-State: AOAM531XT+5SF1NPB7kjOMUuUgET7sG1fUeuyn+dA2Q++wstHgBf7jNu r1hpNtPFgH2xZu2bhXhZ4fgGKuZhL5U= X-Google-Smtp-Source: ABdhPJxnDpBD/5LjqSjMQba5nDp1Qw+j05eUjQTjdry64mUyI1uV0uN3jgDX9KllgOLnBoranu2dAQ== X-Received: by 2002:a05:6000:136e:b0:207:a5e9:f816 with SMTP id q14-20020a056000136e00b00207a5e9f816mr8869047wrz.307.1650297880128; Mon, 18 Apr 2022 09:04:40 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id v5-20020a5d6785000000b0020a792848eesm8945793wru.82.2022.04.18.09.04.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Apr 2022 09:04:39 -0700 (PDT) Message-ID: <2350d4f9-0f69-48a2-4291-dee5743e6614@palves.net> Date: Mon, 18 Apr 2022 17:04:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v3] gdb: fix using clear command to delete non-user breakpoints(PR cli/7161) Content-Language: en-US To: Enze Li , tom@tromey.com Cc: gdb-patches@sourceware.org References: <87sfqez4de.fsf@tromey.com> From: Pedro Alves In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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: Mon, 18 Apr 2022 16:04:43 -0000 On 2022-04-16 04:42, Enze Li via Gdb-patches wrote: > diff --git a/gdb/testsuite/gdb.base/clear_non_user_bp.exp b/gdb/testsuite/gdb.base/clear_non_user_bp.exp > new file mode 100644 > index 00000000000..4f0731e06f6 > --- /dev/null > +++ b/gdb/testsuite/gdb.base/clear_non_user_bp.exp > @@ -0,0 +1,64 @@ > +# 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 . > + > +# Regression test for PR gdb/7161. Test that GDB cannot delete non-user > +# breakpoints with clear command. > + > +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 "" > + } You shouldn't need a timeout match, gdb_test_multiple already has one internally. > + } > + return "" > +} > + > +standard_testfile .c > + > +# this testcase just needs a "Hello world" source file, reuse Uppercase "this" -> "This". > +# gdb.server/sysroot.c instead of adding a new one. > +if { [gdb_compile "${srcdir}/gdb.server/sysroot.c" "${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 sysroot.c:23" \ > + ".*Breakpoint.* at .*" \ > + "set breakpoint" > + > +set bp_addr [get_maint_info_bp "-1"] > + It's not portable to assume that breakpoint -1 is the shlib_events breakpoint. Some targets don't even use such a breakpoint. E.g., Windows. It would be better to instead make get_maint_info_bp look for the first internal breakpoint and return its number. > +gdb_test "maint info break -1" \ > + "-1.*shlib events.*keep y.*$bp_addr.*" \ > + "maint info breakpoint -1 error" Why is this test called "... error" ? > + > +gdb_test "clear *$bp_addr" \ > + "No breakpoint at \\*$bp_addr." \ > + "clear internal breakpoint error" > + It would be good to issue the "maint info break" command again after the clear, to make sure that GDB really didn't delete the breakpoint, even if the clear command errored out. Not a strong requirement, but it would be great if we also had a test trying to clear an internal python breakpoint. Did you look into adding that? If it's too complicated to add it here or to a new file, maybe add a "clear" test to gdb.python/py-breakpoint.exp ?