From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1673035247; bh=AZsuDOX8V781uBFRWUPrYELRkA543pxEPyY1VcpLMPw=; h=Date:Subject:To:References:From:In-Reply-To:From; b=F0k57WxQQJDB49usXWZO6P21LAYy1wQJUuyEkJ4YUQ1M9GI/Nl8nITb3CoGRI3Cc4 XTFZwYKH08EttrSB0QIbMIzK8Jeqa8XdjqAT4D74Z5GCUsjApYg6U4GRgX3mAiYTbS h1epe5MTsFllPW0K+eS+e+7kmTT0NFa8ust+Vnbg= 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> From: Simon Marchi In-Reply-To: <5c5201d92161$5908e600$0b1ab200$@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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