| Message ID | 20260515-python-safety-initial-v2-0-6129cadf258a@tromey.com |
|---|---|
| Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 789E64BA799B for <patchwork@sourceware.org>; Fri, 15 May 2026 20:00:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 789E64BA799B 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=x2WxLw6A X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id CA0B1409FCB8 for <gdb-patches@sourceware.org>; Fri, 15 May 2026 19:59:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA0B1409FCB8 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 CA0B1409FCB8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778875166; cv=none; b=Q8+y8cIM7iSvh9cFk+b8SvGfZnZ+9u95QkivFjH02pX4yfbBdagoXYG71XO4aow9VPV3oLX/g4/BDpPClf2G+5juwInkvSroGzcFFD6IRfJ4v5S8aKOpf6VsNL7+EtTxo+aRE3RdJGV7ueWpTepO8nKu7kfCrD8yIH60U//4oC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1778875166; c=relaxed/simple; bh=QNpYqO3U7ubqALnfLn0cRYh2dO5t8mfje6P8aEGxTUw=; h=DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version:To; b=fj2yZOObSV/JSPSzKy5zxEx+IVoV6R38ksKHrtVWc54G0R/hK37TXz44+r3LXUII4ZEJGmK6PqHKAoGzP6Q5WzUbkvv133BZXWXgmuFz4tnYT2cs7qPf2aME/AToSKYZw2aEZ5haZbLqjv/vRU+vrPEdUcLXAvb33tmGHax5580= 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=x2WxLw6A reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CA0B1409FCB8 Received: from eig-obgw-6002b.ext.cloudfilter.net ([10.0.30.203]) by cmsmtp with ESMTPS id Nx8swAu87jw8YNyguwanP3; Fri, 15 May 2026 19:59:24 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id NyguwvgZ9UxNwNyguwRbnV; Fri, 15 May 2026 19:59:24 +0000 X-Authority-Analysis: v=2.4 cv=WpMrMcfv c=1 sm=1 tr=0 ts=6a077b1c a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=zstS-IiYAAAA:8 a=D_ZWRSUw-nte3DH8E_EA:9 a=QEXdDO2ut3YA:10 a=ul9cdbp4aOFLsgKbc677:22 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=1RLUko2x0uDvzy9kFRsno/puHq/OIKscDduMzYUxxXM=; b=x2WxLw6AB8SxkXB4h0RtMm3HG2 DAISHLBhH0TGBECE8pp+cKDwDp+aSeH3WLoy6njdzMkA+Duec9aeVER7HpBWJhqersTZMskJF2RH5 WuPiWw2GM0Bqm0hbm9Xze54M0; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:60112 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 <tom@tromey.com>) id 1wNygt-0000000418T-3WbB; Fri, 15 May 2026 13:59:23 -0600 From: Tom Tromey <tom@tromey.com> Subject: [PATCH v2 0/4] Python safety initial work Date: Fri, 15 May 2026 13:59:20 -0600 Message-Id: <20260515-python-safety-initial-v2-0-6129cadf258a@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIABl7B2oC/4WOQQ6DIBREr2JYl1ZAWtNV79G4QPzoTyqYDzElx rsXvUCXL5l5MxuLQAiRPauNEawYMfgC8lIxOxk/AsehMJO1vNdaaL7kNAXPo3GQMkePCc2HN1L 2TjWmtaBY6S4EDr+n990V7k0E3pPxdjpsgXBEf5tNTEBHfsKYAuXzxiqO1r/FVfCat05orVQ7O P14JQoz5KsNM+v2ff8B//HT4dsAAAA= X-Change-ID: 20260515-python-safety-initial-422bf34a8ce3 To: gdb-patches@sourceware.org Cc: Tom Tromey <tom@tromey.com> 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: 1wNygt-0000000418T-3WbB 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]:60112 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: MS4xfCay8imfUYhx0CgfxOl/ZnHKbPHZi8ddZGPXupN3PzSYkWf6neZG4jh9JZgp0t7qjUV6S08CcDDjgJzoy7/mMgs1tQ67JF6Us84i7yzuYHKELSvD+xyk fVLdlQQVZN5fsFpYyHZ8zH+atNJ6+m6nk3Dw+vzuRWNYz2SWC4tdQcgPsfhobPPOzZk0p7x7fXa3A7SHosVU2p2T+G6o7040KAI= X-Spam-Status: No, score=-3006.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, TXREP, T_SPF_PERMERROR shortcircuit=no autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
| Series | Python safety initial work | |
Message
Tom Tromey
May 15, 2026, 7:59 p.m. UTC
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.com>
---
Changes in v2:
- Avoids Py_RETURN_* macros
- Link to v1: https://inbox.sourceware.org/gdb-patches/20260515-python-safety-initial-v1-0-8f155338df57@tromey.com
---
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 | 320 +++++++++++++++++++++++++++++++++++++++++
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, 829 insertions(+), 126 deletions(-)
---
base-commit: 5cb6772600a90b7a214b84277fc795c5d45e98fa
change-id: 20260515-python-safety-initial-422bf34a8ce3
Best regards,