From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 5rBRHPWWfmqefiQAWB0awg (envelope-from ) for ; Fri, 14 Aug 2026 00:17:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1786681077; bh=pkkovku2zCNDiFFEkBj66uwhv+HP4UN0j12AMU0V/Jc=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=IgSe8zY1cDTfxzUDrcyCni/5MQqPnVeWW/X67jWlzd6ItvLozM403cNtpl/jA33W2 lmgil+tMzz8DlyRqMJjpKh6ULROmv909+BX2jRJq58oPmm5vtzWwlQ+5nxsFD8gO3V Rm9QUnSJ/ZYp9hxtmm6JmeiEYoQUhzkztJvcqzKU= Received: by simark.ca (Postfix, from userid 112) id 60A941E033; Fri, 14 Aug 2026 00:17:57 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=WyJzUt5o; dkim-atps=neutral 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 55CA71E033 for ; Fri, 14 Aug 2026 00:17:53 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DF3364BA79A1 for ; Fri, 14 Aug 2026 04:17:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF3364BA79A1 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=WyJzUt5o Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 38B8C4BA23F4 for ; Fri, 14 Aug 2026 04:17:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38B8C4BA23F4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 38B8C4BA23F4 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786681049; cv=none; b=MRw2azl86hkyKOPh64ShSMmiYxt3YEPwqFYVpayD8N/0KQOCVY9pB4yWMfpRJ+zSQ0ZMLQH04CX/eZoOiqoulzsQhAZ9+GGep4UlnTf/nW3u/q25MYt8WC1yUrRbXRjeVVK/RO/lFfQG3f3fSgC7Iwj26n5XnQWOnc0px7YAwBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786681049; c=relaxed/simple; bh=pkkovku2zCNDiFFEkBj66uwhv+HP4UN0j12AMU0V/Jc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=HFxyLdwMgHzaRuFCxyzh+auNYz9f5uo+zP544/CXe3YjTnri7fFInaY6aeqZjh/9UVNV8jaFXQRWeXi49AFbxzpNf1mdk7lWWCGQsMN+iwd1t+TV/feuPqsaZxC6LIvhwVVECQQV3tHCu/iH7AtCEmZ0FsHm28OOvCXLbzGCmt4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=WyJzUt5o DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38B8C4BA23F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1786681047; bh=pkkovku2zCNDiFFEkBj66uwhv+HP4UN0j12AMU0V/Jc=; h=Date:Subject:To:References:From:In-Reply-To:From; b=WyJzUt5oUF0jilM3MmIfBzGrG3VT7BgoJSyiPyKlBqCJ638csSE3N36XTJPdw30ts VmL6rSOiEicaE7LP7pNHlYVB4+nCy+9eW/uDcm++ZrW5Kiulm3Ax8umdBeUJGkSslX wz6uK3asXqECKJItW3vogvNUTeVnnMQqf4Df8H1w= Received: by simark.ca (Postfix) id 7A35F1E033; Fri, 14 Aug 2026 00:17:25 -0400 (EDT) Message-ID: <501a7d7b-df70-4d66-88c6-ad6fbe4e7e49@simark.ca> Date: Fri, 14 Aug 2026 00:17:24 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] gdbtypes: improve documentation of composite type helpers To: Matthieu Longo , gdb-patches@sourceware.org References: <20260813172736.500755-1-matthieu.longo@arm.com> Content-Language: fr From: Simon Marchi In-Reply-To: <20260813172736.500755-1-matthieu.longo@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 On 8/13/26 1:27 PM, Matthieu Longo wrote: > Document how arch_composite_type handles a null NAME, and clarify the > semantics of a null or empty field name for the append_composite_type* > helpers. > > Suggested-By: Simon Marchi Thanks for the patch! It would be a good time to clean things up a bit, to bring them up to the current standard. The comments in the .c file should just be: /* See gdbtypes.h. */ And the proper comments should be moved to the .h file. > @@ -5428,9 +5429,11 @@ arch_composite_type (struct gdbarch *gdbarch, const char *name, > return t; > } > > -/* Add new field with name NAME and type FIELD to composite type T. > - Do not set the field's position or adjust the type's length; > - the caller should do so. Return the new field. */ > +/* Add a new field named NAME with type FIELD to composite type T. > + This function does not set the field's position or adjust the length of T; > + the caller is responsible for doing so. If NAME is nullptr or an empty > + string, the field represents an anonymous struct or union whose fields > + are visible directly in the parent scope. Return the newly added field. */ > > struct field * > append_composite_type_field_raw (struct type *t, const char *name, I don't think that a field NAME can be nullptr. For the "search through anonymous structs/unions" code to work, the name specifically needs to be a non-nullptr empty string: https://gitlab.com/gnutools/binutils-gdb/-/blob/a760a797aeb6e9143d60f0b8b2b8f71da88cabcf/gdb/valops.c#L2014-2015 And I don't think it's actually safe to pass nullptr. When I try to change one of the siginfo fields to have a nullptr type, GDB crashes here: #2 0x00007efd9800ded2 in __ubsan_handle_nonnull_arg_abort () from /usr/lib/libubsan.so.1 #3 0x000055fa5ad2f2a5 in ui_file::puts (this=0x7b1d93e02310, str=0x0) at /home/smarchi/src/binutils-gdb/gdb/ui-file.h:77 #4 0x000055fa5e47b89d in gdb_puts (linebuffer=0x0, stream=0x7b1d93e02310) at /home/smarchi/src/binutils-gdb/gdb/utils.c:1912 #5 0x000055fa5e47bb9d in fputs_styled (linebuffer=0x0, style=..., stream=0x7b1d93e02310) at /home/smarchi/src/binutils-gdb/gdb/utils.c:1928 I think it would be safer to just say "empty string" here. For types, I think that the name can be nullptr: it's possible to create a type and never call set_name on it. Simon