From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fiyDBAd+uGPUJREAWB0awg (envelope-from ) for ; Fri, 06 Jan 2023 15:01:11 -0500 Received: by simark.ca (Postfix, from userid 112) id 076231E222; Fri, 6 Jan 2023 15:01:11 -0500 (EST) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=MchtwgKh; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 893D11E110 for ; Fri, 6 Jan 2023 15:01:10 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 626FE385841D for ; Fri, 6 Jan 2023 20:01:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 626FE385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673035267; bh=WK9DZMHJ8+nrXrKOsiyEMoAhibv3La3Pk3IODyUFi1o=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=MchtwgKhCxVwgOK7NTepkPDxr0/RiDXz03GblJpzQvEqjQX/PJbmi6LjCLwfaYb1R VMLiQDxvBg5972dm3BznDGIWb8hpR9D5NQxwuc3ePVMm1hN7DBJ/yBD0TfHeVVwR4X o1gRXZJOd14Q53soU0HVeU4jXArI9s1E03QqXWqw= Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id C2EAE3858D28 for ; Fri, 6 Jan 2023 20:00:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C2EAE3858D28 Received: from [172.16.0.64] (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 4663B1E110; Fri, 6 Jan 2023 15:00:47 -0500 (EST) Message-ID: <88e10ffd-8e87-b2bf-e6b3-f4567fb50e17@simark.ca> Date: Fri, 6 Jan 2023 15:00:46 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH 1/1] Add support for gdb.Type initialization from within the Python API Content-Language: fr To: dark.ryu.550@gmail.com, gdb-patches@sourceware.org References: <5c5201d92161$5908e600$0b1ab200$@gmail.com> In-Reply-To: <5c5201d92161$5908e600$0b1ab200$@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, Unfortunately, I am unable to apply this patch as well, please send it using git-send-email. On 1/5/23 18:56, dark.ryu.550--- via Gdb-patches wrote: > This patch adds support for creating types from within the Python API. It > does > > so by exposing the `init_*_type` family of functions, defined in > `gdbtypes.h` to > > Python and having them return `gdb.Type` objects connected to the newly > minted > > types. > > > > These functions are accessible in the root of the gdb module and all require > > a reference to a `gdb.Objfile`. Types created from this API are exclusively > > objfile-owned. It would maybe be nice to be able to create arch-owned types too. For instance, you could create types just after firing up GDB, without even having an objfile loaded. It's not necessary to implement it at the same time, but does your approach leave us the option to do that at a later time? > > > > This patch also adds an extra type - `gdb.FloatFormat` - to support creation > of > > floating point types by letting users control the format from within Python. > It > > is missing, however, a way to specify half formats and validation functions. > > > > It is important to note that types created using this interface are not > > automatically registered as a symbol, and so, types will become unreachable > > unless used to create a value that otherwise references it or saved in some > way. > > > > The main drawback of using the `init_*_type` family over implementing type > > initialization by hand is that any type that's created gets immediately > > allocated on its owner objfile's obstack, regardless of what its real > > lifetime requirements are. The main implication of this is that types that > > become unreachable will leak their memory for the lifetime of the objfile. > > Keeping track of the initialization of the type by hand would require a > > deeper change to the existing type object infrastructure. A bit too > ambitious > > for a first patch, I'd say. > > > > if it were to be done though, we would gain the ability to only keep in the > > obstack types that are known to be referenced in some other way - by > allocating > > and copying the data to the obstack as other objects are created that > reference > > it (eg. symbols). I think how you did it is ok, it's better to keep things simple. Simon