From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by sourceware.org (Postfix) with ESMTPS id 5E6253898C77 for ; Mon, 14 Mar 2022 13:53:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5E6253898C77 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-wm1-f42.google.com with SMTP id r65so9373655wma.2 for ; Mon, 14 Mar 2022 06:53:49 -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:references:from:in-reply-to :content-transfer-encoding; bh=oUog3mcEi+DU0rIVT7o0FRpP8eJZbqUe4SVr6He5L7M=; b=U21hWskt1SaekVS8FS+8y0YPWdU10LV84pZHBYWi/csBPAC2676kyOODU4TCkPZNNI X5KXH66sftqbURgdRPCT2AoZE8lOgC1EKDtdsgp9VAgqTgoDxH0NWqQahHzBvBtI7CWv n/qucNPDfdM4o6UnBhzIAc6eDwdE05x1un1AYNUd+MninpYO9o7vH348CTguE/0rZ1p+ zfGUlWF0OzrWSQyuUNxfDbLEifwXToIzDEpi/oCic4naS01cHfYNxCcTz39EYqeSfnlX 2+MekYPSi+soyU3XGOREyhvy5xqMLVkYHO2vcnhRC+CKGxFSzf0EpGgbZiPi3jsLxPYc KmEA== X-Gm-Message-State: AOAM531blc4djmX0SgfcQ85S6BzJhYcYYmkWOgGA2pt6PbCjUniHXG8k MFKhVXhRYjkJYwJZUR51a0IGykNNkI0= X-Google-Smtp-Source: ABdhPJzsG8FlHtKrpunH1MmlyZJynqJBtPE79AhuB86AgWxPXBCQddksMeIZQwjBXaw3IUjocCSdUw== X-Received: by 2002:a7b:c5d0:0:b0:355:482a:6f44 with SMTP id n16-20020a7bc5d0000000b00355482a6f44mr17633546wmk.58.1647266028126; Mon, 14 Mar 2022 06:53:48 -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 j34-20020a05600c1c2200b0038995cb915fsm30921809wms.9.2022.03.14.06.53.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Mar 2022 06:53:46 -0700 (PDT) Message-ID: Date: Mon, 14 Mar 2022 13:53:44 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] gdb: prevent the use of the clear command to remove the internal breakpoint (PR cli/7161) Content-Language: en-US To: Enze Li , gdb-patches@sourceware.org References: From: Pedro Alves In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, 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, 14 Mar 2022 13:53:50 -0000 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