From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id YVWBAMKy22p10xAAWB0awg (envelope-from ) for ; Fri, 23 Oct 2026 15:17:22 -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=JDdkwjVb; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F2013378002; Fri, 23 Oct 2026 15:17:21 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 64D5A1E007 for ; Fri, 23 Oct 2026 15:17:21 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D26F4BA2E1C for ; Fri, 23 Oct 2026 19:17:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D26F4BA2E1C 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=JDdkwjVb Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 3EBB54BA2E0C for ; Fri, 23 Oct 2026 19:15:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3EBB54BA2E0C 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 3EBB54BA2E0C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792782952; cv=none; b=YRY9fS+2yjtL7CPBygw7tsCLoMa5HofEeO+nZE4SCF0c2SX4QQifflott7x9oF8zqYXDR0Pnx+eR761z8Yq3+CecSsTOhDo5205O0stzM2DbxZIyBp6nxJyhQgtDUzKZFJT2L9D2wTNX+MIRq8Yf5NwWwY2L6iE9g7EzFT5nv74= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792782952; c=relaxed/simple; bh=Ke/csyyEfDoHCVLInWvjnTAA7ao/yfikTfUUvW+F3bE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=vQYKUSkArRWhyP2nulHdff5z4ub/81Ty/qrsPc5VE5fB4qt8wqYSMBQNZgsgf7dj/Z/c/ceu+woS3fiwA9+vYx8zGRVXXqESxw5DBf5rYfxf56ev/V5OcqSH+vnqgQizVNYa1DRT14e8weeuLKYSF89y89y07o09U4c8ZI1+HRM= 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=JDdkwjVb reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3EBB54BA2E0C Received: from eig-obgw-6004b.ext.cloudfilter.net ([10.0.30.210]) by cmsmtp with ESMTPS id K49ExqlfULvgbKKk3xSHkF; Fri, 23 Oct 2026 19:15:52 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id KKk2xCqdlbKT1KKk2xKQeE; Fri, 23 Oct 2026 19:15:50 +0000 X-Authority-Analysis: v=2.4 cv=YfK95xRf c=1 sm=1 tr=0 ts=6adbb267 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=ItBw4LHWJt0A:10 a=shrr99JAOEBKaZmjSe8A: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=IZFzNBPpLLcyVNEVh2mF40MTXfetkjNMCjlztj6XBZ0=; b=JDdkwjVbSzqltl0GQ1KvXAEOs6 hiQgLl81BM/PJZIYveqVo5AI/q9b2ARvbrEOi9F4s1sypuwReFERr88ogSPqLDnetPLXLTD6yxgS9 r0vR3vpQyDOvIaejiDdXcLmip; Received: from 97-122-110-129.hlrn.qwest.net ([97.122.110.129]:59452 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 1xKKk2-00000000DHL-19bv; Fri, 23 Oct 2026 13:15:50 -0600 From: Tom Tromey Date: Fri, 23 Oct 2026 13:15:48 -0600 Subject: [PATCH 3/6] Add gdbpy_safe_invalid_object_repr MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261023-python-safety-fixmes-v1-3-055b9e1d237b@tromey.com> References: <20261023-python-safety-fixmes-v1-0-055b9e1d237b@tromey.com> In-Reply-To: <20261023-python-safety-fixmes-v1-0-055b9e1d237b@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: 1xKKk2-00000000DHL-19bv 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]:59452 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfGspVCMR4TOLVyZhgWG+lPGQPp0u+qxGczOaD7BhdMn/PznROskgT48sCeROLlyZxzLlVmlrwc6GzXLuGEyGawgX8BWBAg30wadnUZGtKxmmgqrlZz2/ E50fq9Fzucla+YkmPSsvnCwY5bmBovUJhHcpUpUOetp+5+Ahd+KruobG3kJlN8mCMs1F9LUfjKCazW+S6OUci23LuepOr30kU2k= 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 gdbpy_safe_invalid_object_repr, a simple wrapper that lets us remove some Python FIXMEs. --- gdb/python/py-arch.c | 4 +--- gdb/python/py-connection.c | 5 +---- gdb/python/py-frame.c | 4 +--- gdb/python/py-symbol.c | 5 +---- gdb/python/py-wrappers.h | 11 +++++++++++ 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index 3de1b3c4533..d9639797bb8 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -286,9 +286,7 @@ gdbpy_ref<> arch_object::repr () { if (gdbarch == nullptr) - /* FIXME: Python safety. Eventually gdb_py_invalid_object_repr - should throw. */ - return gdbpy_ref<> (gdb_py_invalid_object_repr (this)); + return gdbpy_safe_invalid_object_repr (this); auto arch_info = gdbarch_bfd_arch_info (gdbarch); return gdbpy_unicode_from_format ("<%s arch_name=%s printable_name=%s>", diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c index 809c60f9ce3..313a5202ee3 100644 --- a/gdb/python/py-connection.c +++ b/gdb/python/py-connection.c @@ -248,10 +248,7 @@ gdbpy_ref<> connection_object::repr () { if (target == nullptr) - /* FIXME: Python safety. gdb_py_invalid_object_repr ought to - throw on error, and return gdbpy_ref<>, but currently does - not. */ - return gdbpy_ref<> (gdb_py_invalid_object_repr (this)); + return gdbpy_safe_invalid_object_repr (this); return (gdbpy_unicode_from_format ("<%s num=%d, what=\"%s\">", diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 4aedd7db563..58b08c3d454 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -173,9 +173,7 @@ frame_object::repr () { frame_info_ptr f_info = frame_find_by_id (frame_id); if (f_info == nullptr) - /* FIXME: Python safety. gdb_py_invalid_object_repr should - throw on error. */ - return gdbpy_ref<> (gdb_py_invalid_object_repr (this)); + return gdbpy_safe_invalid_object_repr (this); return gdbpy_unicode_from_format ("<%s level=%d frame-id=%s>", gdbpy_py_obj_tp_name (this).c_str (), diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c index 3be1d933493..b5dcca5658d 100644 --- a/gdb/python/py-symbol.c +++ b/gdb/python/py-symbol.c @@ -320,10 +320,7 @@ gdbpy_ref<> symbol_object::repr () { if (symbol == nullptr) - /* FIXME: Python safety. gdb_py_invalid_object_repr ought to - throw on error, and return gdbpy_ref<>, but currently does - not. */ - return gdbpy_ref<> (gdb_py_invalid_object_repr (this)); + return gdbpy_safe_invalid_object_repr (this); return gdbpy_unicode_from_format ("<%s print_name=%s>", gdbpy_py_obj_tp_name (this).c_str (), diff --git a/gdb/python/py-wrappers.h b/gdb/python/py-wrappers.h index 69295fa6af3..1f7d4bfc467 100644 --- a/gdb/python/py-wrappers.h +++ b/gdb/python/py-wrappers.h @@ -403,4 +403,15 @@ gdbpy_safe_from_ulongest (ULONGEST l) throw gdb_python_exception (); return result; } + +/* A wrapper for gdb_py_invalid_object_repr that throws on error. */ +static inline gdbpy_ref<> +gdbpy_safe_invalid_object_repr (gdbpy_borrowed_ref<> self) +{ + gdbpy_ref<> result (gdb_py_invalid_object_repr (self)); + if (result == nullptr) + throw gdb_python_exception (); + return result; +} + #endif /* GDB_PYTHON_PY_WRAPPERS_H */ -- 2.49.0