From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ge0HNZfrmmptxCgAWB0awg (envelope-from ) for ; Fri, 04 Sep 2026 12:02:31 -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=D5IJSn/t; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C97FF1E033; Fri, 04 Sep 2026 12:02:31 -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 D13291E033 for ; Fri, 04 Sep 2026 12:02:29 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CBD54BB3BE4 for ; Fri, 4 Sep 2026 16:02:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0CBD54BB3BE4 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=D5IJSn/t Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 14B284BA23EF for ; Fri, 4 Sep 2026 16:01:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 14B284BA23EF 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 14B284BA23EF 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=1788537712; cv=none; b=CfPh8R01RR2dJVhbxnGDzgzB4Q+S9Mf+rkgvMcqQgUn5dxSvSKgc6RIB5fGEZYS3lpvgTZnH4R6rmUARU5a/+vMhy98r0vjU8XVlA+WmBie8udj/XqmPK3rcTruh84m9xpFRjyFgwS0sPwiuzFy8fy+DtTykqeYK/emhVRtCLSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788537712; c=relaxed/simple; bh=EG6gPjEU7nP5zAHyW7lnK4EoMfHFzvKBJS9Ug8l/VJI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=czdgKp9hcBGWvL1HJJLljjwpgfWgYbbgQsTlprfJye5MU7tElVIYBsBVTni84E/OleR7Vd6llJOdtStUraovoFk9W4FKOzUCbTq/PfXHgakP+9PmMySVfew4dpg2UXJtF4BMp3TggDSFFbtCD3fRoww27tJ9y8fIoJI7ow1LfxA= 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=D5IJSn/t reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14B284BA23EF Received: from eig-obgw-6001b.ext.cloudfilter.net ([10.0.30.143]) by cmsmtp with ESMTPS id 2TWXxfd29Lvgb2WMRx19pm; Fri, 04 Sep 2026 16:01:51 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 2WMQx0WMV9tXG2WMQx5K45; Fri, 04 Sep 2026 16:01:51 +0000 X-Authority-Analysis: v=2.4 cv=KK1aDEFo c=1 sm=1 tr=0 ts=6a9aeb6f a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=VdqzKS8jKosA:10 a=ItBw4LHWJt0A:10 a=CCpqsmhAAAAA:8 a=9srNWdky4c99E1fTnrgA:9 a=ul9cdbp4aOFLsgKbc677:22 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=cO2G+yDitVMcFVRSKORTfPv1NVq1bxbZ3ZAtySpciXQ=; b=D5IJSn/tN0EHfEAGwgoMwN+YxL HJLQZpDa0YRkbqs9MJANDPGzwZlPDLtv3rohEEolBpACrhOR4u8F5YsmCR6bchEuNcjuTr4Y9TF3m h7KSlHrl/+GnJS6tdxXrhxzu/; Received: from 97-122-117-2.hlrn.qwest.net ([97.122.117.2]:46800 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.5) (envelope-from ) id 1x2WMQ-000000022Wr-0tnG; Fri, 04 Sep 2026 10:01:50 -0600 From: Tom Tromey To: Matthieu Longo via Gdb Cc: Tom Tromey , Matthieu Longo , Andrew Burgess Subject: Re: RFC: prototype of C extensions using the Python limited API In-Reply-To: <143b06a7-117f-4500-a911-26f8f79eef2f@arm.com> (Matthieu Longo via Gdb's message of "Mon, 22 Jun 2026 11:24:52 +0100") References: <21479c1d-3a9a-4ae2-bc1a-5dc19871f275@arm.com> <143b06a7-117f-4500-a911-26f8f79eef2f@arm.com> X-Attribution: Tom Date: Fri, 04 Sep 2026 10:01:48 -0600 Message-ID: <87se3p0zv7.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain 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.117.2 X-Source-L: No X-Exim-ID: 1x2WMQ-000000022Wr-0tnG X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-117-2.hlrn.qwest.net (bapiya) [97.122.117.2]:46800 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: MS4xfII9q5Ruo3J2CuK/QgCbSZ8xo6IQzEdID6/UEXjOjXWrmaVmUm8bsOugWNi5fu7bb0zpHSk2uWfse5z0jnpkm0ZftGonW/HahLa/cHbW8hjGfwzAJRJZ wiX7+rnpxxUBfA+6ueVhczG7KqDK9qy/YvonPu8K2nT0cZoJRM3Ea2YVaoqS3pkK6doMs8XjRvlrCQ== X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-bounces~public-inbox=simark.ca@sourceware.org Sender: "Gdb" >>>>> Matthieu Longo via Gdb writes: >> Could you please review it so that we validate this new approach >> before I migrate all my previous patches to it ? Sorry about the delay on this. I finally found time today to read through this. I'm not sure I really understood it. There is a lot of stuff here, and I ended up trying to pick through the patch and figure out which parts are directly from gdb and which are modified. However this isn't really easy to do. It would probably help if you gave some kind of high-level overview of what your goal is and what the main classes are that implement the goal. Alternatively, a gdb patch series would probably be a lot simpler on the review end. I guess the goal is heap allocation of types and implementation of the 'traverse' stuff? To achieve this I think the main things I would look for in review are: * Any new APIs not be any worse for safety than what we currently are working toward. That is, automate to the extent possible, avoid error checks, don't pass raw PyObject* around. * Don't have excessive classes, templates, etc. * It's fine to put some new constraints on gdb-supplied code if it makes the wrappers simpler. Like, gdb probably won't interact with Python type objects in the most fully general way -- it's fine to say that gdb will create types and not ever destroy them, if that helps at all. > +### Issues > + > +1. Not sure why A_clear and B_clear are called twice. Is it due to the cycle ? > +2. The type name is `(null)` because `PyType_GetFullyQualifiedName()` returns `NULL` for an unknown reason. Please could you explain me why ? > +3. There is an unexpected error `AttributeError: __module__`. I don't understand where it comes from. I don't know the answer to any of these. > + template + std::is_same::value>> > + int visit (typename P::visitproc visit, void *arg) noexcept > + { > + return P::visit (m_obj, visit, arg); > + } I didn't understand why this is here. > + > + template + std::is_same::value>> > + void clear (P * = nullptr) noexcept > + { > + P::clear (&m_obj); > + } Earlier you said this was for storing a 'gdbpy_ref<> *' in a Python object. I somewhat feel that's to be avoided and we should just use PyObject*. Though thinking about it, I guess it's hard to articulate why. I suppose a pointer to a smart pointer feels strange. It's unfortunate we can't use the reference wrappers in the gdb classes for the time being; but since we can't I suppose it's perhaps best to follow Python conventions and just document that the fields are owned references. > + > +template > +struct gdbpy_object_type > +{ > +private: > + PyTypeObject *pytype_ () const noexcept If this is a wrapper I think "gdbpy_type_object" might be a nicer name. > +struct gdbpy_object_type_ref: > + public gdbpy_object_type , > + public gdbpy_ref <> > +struct gdbpy_object_type_bref: > + public gdbpy_object_type , > + public gdbpy_borrowed_ref <> > +struct gdbpy_py_obj_type_bref: > + public gdbpy_object_type , > + public gdbpy_borrowed_ref I didn't understand why these are all needed, or what their names mean. Tom