From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CfHQDSpmB2qUzT0AWB0awg (envelope-from ) for ; Fri, 15 May 2026 14:30:02 -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=PrBH7yb/; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 299DF1E0B1; Fri, 15 May 2026 14:30:02 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham 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 AAB361E067 for ; Fri, 15 May 2026 14:30:00 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 502AD4C31856 for ; Fri, 15 May 2026 18:29:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 502AD4C31856 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=PrBH7yb/ Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id 59376409FC98 for ; Fri, 15 May 2026 18:23:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59376409FC98 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 59376409FC98 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778869407; cv=none; b=sN5bigk5P2b5wpuXCh2vY4VmHJAbvPKBywUN9vPF+oXL59X0bfKk0Cr9rU6iqQD0TVbfhPB5VgNQMyqSWKvZRqKgxvj77MQcQcBhemtuNGquE11s2lZTAhhj4Ln6esse+BltXu7fuO3TFXHE690Kk4/tPY6LpE/6wYCjix6Fxyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778869407; c=relaxed/simple; bh=fW42W5RE3PnUuqaz9nGI5JHJjTNl/Iu2TPAKBNllO3k=; h=DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version:To; b=NtuShW5Q8a50k1rqPU/cOlqOEwj7U7V8+30mWCq4APB9A4f5ck2RakyPJcql3ZikxWpUfjO89n+TIavX6OBCbd0D/bzFBfZNB81XyruZd1frz6p9NZvOK1nMJwKM2Tjzi+da4gkZEiap6d6K/gO9QtZRC20kpBkSYVtt2zvx3hY= 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=PrBH7yb/ reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59376409FC98 Received: from eig-obgw-5005b.ext.cloudfilter.net ([10.0.29.189]) by cmsmtp with ESMTPS id Ne68wFl3w4RkpNxC3wqmkD; Fri, 15 May 2026 18:23:27 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id NxBxwKhVHkWUFNxBxwU6cb; Fri, 15 May 2026 18:23:21 +0000 X-Authority-Analysis: v=2.4 cv=frTcZE4f c=1 sm=1 tr=0 ts=6a07649e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=ItBw4LHWJt0A:10 a=zstS-IiYAAAA:8 a=W4V1jmvNGvZgYn-WTacA:9 a=QEXdDO2ut3YA:10 a=4G6NA9xxw8l3yy4pmD5M:22 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:Content-Transfer-Encoding:Content-Type:MIME-Version: Message-Id:Date:Subject:From:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XJweN5Ce9vrq0LCuOc9dVVLQcn0j5kgj7paTqc/YoHQ=; b=PrBH7yb/TfaZpWFhXiiEGTVYmD LUh185Ji5cYi8lcHAXLWmZfyardGpu3hxH4LLdpXzxTMRhhSDeI6Eh1G2mIwm/e5RsW1MlXRnep1O DeN4tofn8v98+qgt57oClXxEm; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:46584 helo=[192.168.0.17]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.2) (envelope-from ) id 1wNxBx-00000002ZaG-0T6C; Fri, 15 May 2026 12:23:21 -0600 From: Tom Tromey Subject: [PATCH 0/4] Python safety initial work Date: Fri, 15 May 2026 12:23:18 -0600 Message-Id: <20260515-python-safety-initial-v1-0-8f155338df57@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAJZkB2oC/x3MwQ6CMAyA4VchPbsIA4zxVQyHbnasiRbSLkZCe Henx+/w/zsYKZPBrdlB6c3Gi1R0pwZiRpnJ8aMafOsv7diNbt1KXsQZJiqbY+HC+HSD9yH1A14 j9VDbVSnx5/+9T9UBjVxQlJh/t0V5Zjm/0AopHMcX2qxRvYcAAAA= X-Change-ID: 20260515-python-safety-initial-422bf34a8ce3 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: 75.166.225.82 X-Source-L: No X-Exim-ID: 1wNxBx-00000002ZaG-0T6C X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-225-82.hlrn.qwest.net ([192.168.0.17]) [75.166.225.82]:46584 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBg99BLwQzrDODVYCFMITVcE3hQQo1WGXHB0r3au07rxb0wjf2tPZwhwTVHI347hWz2fenFrFJFqQpQ4YjMHwSPbvKNt5VcH8FrVtETj7Dc0wZEpFwQf CYI77knXVnYi3pGLk8fiSojpi0kyUvw4sBC8T+PoOx4wYghThb2T7Xe9bCEAkNcLCc1pg8md40uhPYjMaGxcv/aXmpPWW8ZNnA8= 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 I rewrote my earlier Python safety series to use methods a while back. And while I like the result, I got bogged down converting things, so I thought I'd send some initial work, with the idea that if this looks good, other code can be transformed in pieces. Since this is extracted from a larger series, there is some code in here that isn't currently used in-tree. This is mainly true for the gdb functions that wrap Python APIs, see patch 2. Patch 4 shows what the end effect is, but the patch is somewhat hard to read IMO. So for instance now the 'title' getter for a TUI window is just an ordinary method: const std::string & gdbpy_tui_window::title () { require_valid (); return window->title (); } Since it wants to only operate on a valid window, require_valid will throw if that isn't the case. Note there's no explicit error checking, no casts, no messing with reference counts, and the return type is just a string. All these boilerplate details are handled by a template wrapper function. Signed-off-by: Tom Tromey --- Tom Tromey (4): Add gdbpy_borrowed_ref Add wrappers for some Python APIs Add wrappers for Python implementation functions and methods Convert py-tui.c to the "python safety" approach gdb/python/py-ref.h | 80 +++++++++++ gdb/python/py-safety.h | 321 +++++++++++++++++++++++++++++++++++++++++ gdb/python/py-tui.c | 208 +++++++++++---------------- gdb/python/py-wrappers.h | 334 +++++++++++++++++++++++++++++++++++++++++++ gdb/python/python-internal.h | 8 +- gdb/python/python.c | 5 +- 6 files changed, 830 insertions(+), 126 deletions(-) --- base-commit: 776715ea683b93c0415fc4eb31b4fcec5f2153fc change-id: 20260515-python-safety-initial-422bf34a8ce3 Best regards, -- Tom Tromey