From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SUOQDFGNz2oLJgkAWB0awg (envelope-from ) for ; Wed, 14 Oct 2026 10:10:25 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=j1PM3T7m; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 272471E050; Wed, 14 Oct 2026 10:10:25 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 703B51E04E for ; Wed, 14 Oct 2026 10:10:24 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 09DD24BA23DB for ; Wed, 14 Oct 2026 14:10:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09DD24BA23DB Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=j1PM3T7m Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id B653F4BA23C8 for ; Wed, 14 Oct 2026 14:08:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B653F4BA23C8 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B653F4BA23C8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791986933; cv=none; b=CuwKnjMWzgPfgkcvpxEYEzZHWkkOiaLpdVnNcSgmS5uFJpUt6FbW6+Ie3ViYSJipuTj6pHS7SlCJh5q2DlWU89ZCGnI6DuGjcVHoQuWu5T6Ovfwka64kjP9xQTZEzCphwAcbTyoqHIt9D0iFLmMLYVvmewSryuN7LEFekZD6BzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791986933; c=relaxed/simple; bh=5DkaTWk+UoxeuICw9LCjaul22SEdsYhok88vE+KyIwk=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=NMURflfbZiOPcSqRldFf8/Y7UyqNC7jZGlEzIw9Et9YhrM7aNuXtCVnFAEPlnKy7zCqZym16tovsYG6OgJjpSTGhSZgCDKxUNIkVRgKLKNNci3c2AesuuSeMXuOJ+iWHkzFhTDTfAJ8H/ub4ms7QMPJTfr4YNxd2tMx/HQIGXBc= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=j1PM3T7m reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B653F4BA23C8 Received: from eig-obgw-6006b.ext.cloudfilter.net ([10.0.30.211]) by cmsmtp with ESMTPS id GwgJxLw6lc3XsGzf2xy92a; Wed, 14 Oct 2026 14:08:52 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id Gzf2xknk2bhSyGzf2xbGp8; Wed, 14 Oct 2026 14:08:52 +0000 X-Authority-Analysis: v=2.4 cv=IJECChvG c=1 sm=1 tr=0 ts=6acf8cf4 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=ItBw4LHWJt0A:10 a=C0Wkuj2hxmGuBKgoQnQA:9 a=QEXdDO2ut3YA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Kdy0KVaDNHcPwpPsQMvl9XRKnsYlxCR7ZYh/n9cXq4g=; b=j1PM3T7mTmCPQeCi4n+Kuk+jUE S4ZZn9zr19EgSSPPZ7HW64Lvo0D23vp3rJeTTihptus307kI9/yYN6EecyvlZ/EiNIVDgScA0RVyD P5itkQ940iAZ6rPw8B9V8zQ01; Received: from 97-122-110-129.hlrn.qwest.net ([97.122.110.129]:45562 helo=[192.168.0.17]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xGzf1-000000002J7-3f4H; Wed, 14 Oct 2026 08:08:51 -0600 From: Tom Tromey Date: Wed, 14 Oct 2026 08:08:51 -0600 Subject: [PATCH 3/5] Add require_valid to Python breakpoint and breakpoint location MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261014-python-safety-breakpoint-v1-3-c8e72d58f3cd@tromey.com> References: <20261014-python-safety-breakpoint-v1-0-c8e72d58f3cd@tromey.com> In-Reply-To: <20261014-python-safety-breakpoint-v1-0-c8e72d58f3cd@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.110.129 X-Source-L: No X-Exim-ID: 1xGzf1-000000002J7-3f4H X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-129.hlrn.qwest.net ([192.168.0.17]) [97.122.110.129]:45562 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfG4E2BIikvfdSvxjFz5afe2bg3iOMdttKk7Yq05uIt6S9DiR3AI8oPyC7mlU2dLMdh9HY8PKvfjwJlf4h7Oe3vb9i+wLbDP35sz2FVNP8/Ej7CVyPcPg buWnf1SCMEM6ZLNw3ssZULmSByglidDDUvSVJymv/l7r5ADRSVr2HJcYX1f7uBJF8075Ou2Nl1YD2+fjyJ45RRnFcPkTkRdqjjc= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This adds a require_valid method to the Python breakpoint and breakpoint location objects. These will be used in subsequent patches. Note that the breakpoint location implementation checks that the breakpoint is valid. This was done by all users of the macro, so it seemed more convenient to do this here. --- gdb/python/py-breakpoint.c | 17 +++++++++++++++++ gdb/python/python-internal.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 8781c17838b..40d1244abcf 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -69,6 +69,15 @@ struct gdbpy_breakpoint_location_object : public PyObject /* Implementation of 'repr'. */ gdbpy_ref<> repr (); + + /* If this breakpoint location is not valid, throw an exception. */ + void require_valid () const + { + owner->require_valid (); + if (owner->bp != bp_loc->owner) + return gdbpy_err_format (PyExc_RuntimeError, + _("Breakpoint location is invalid.")); + } }; static_assert (gdb::is_python_allocatable_v); @@ -159,6 +168,14 @@ static struct pybp_code pybp_watch_types[] = {NULL} /* Sentinel. */ }; +void +gdbpy_breakpoint_object::require_valid () const +{ + if (bp == nullptr) + gdbpy_err_format (PyExc_RuntimeError, _("Breakpoint %d is invalid."), + number); +} + /* Python function which checks the validity of a breakpoint object. */ static PyObject * bppy_is_valid (PyObject *self, PyObject *args) diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 55e5e8eaabe..2d990ee6ac1 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -427,6 +427,9 @@ struct gdbpy_breakpoint_object : public PyObject /* 1 is this is a FinishBreakpoint object, 0 otherwise. */ int is_finish_bp; + + /* If this breakpoint is not valid, throw an exception. */ + void require_valid () const; }; static_assert (gdb::is_python_allocatable_v); -- 2.49.0