From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id FqVSJJXufWpyfSMAWB0awg (envelope-from ) for ; Thu, 13 Aug 2026 12:19:33 -0400 Received: by simark.ca (Postfix, from userid 112) id 7CB671E166; Thu, 13 Aug 2026 12:19:33 -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.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 CDDB71E09B for ; Thu, 13 Aug 2026 12:19:32 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 019CD4BA9005 for ; Thu, 13 Aug 2026 16:19:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 019CD4BA9005 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id A94A54B9DB68 for ; Thu, 13 Aug 2026 16:19:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A94A54B9DB68 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A94A54B9DB68 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=1786637948; cv=none; b=PaAhsqA0bnPkG4Yux73kVIE2OiE0mMUfMEHvN/tMaRXgmzUvSSSqctWOv/PnEGSxD1MrGxvCUjWWF8ul6VTHdR+jNPZYMM7mlt0/DSGUmB1Hl3Q5SDHzlQb+tbxuor7KunvFEF/Uwe5xZN7iRXpY5im1q/K8DcdighNptVZMlpk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786637948; c=relaxed/simple; bh=7M4BPBFY1YmeEu+ZegZREIApbQys4G67OhAq+SPf1LQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=wm8+Umd8PvleAV0knyRoscOWIW0lDbtinVzwOHStVLuuFLHDWAk0D4lYZ11bup8zkOIUa5RfogRD9NQoMP/6w2m53uor4ehhPNXYPrHVpKGSgejik3VwlZg3TVzt7FhLTzmU1NSj/1YqN5mAOFwatoiwvCn1R2q1zyGRldKZgrM= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A94A54B9DB68 Received: by simark.ca (Postfix) id 3BC6E1E09E; Thu, 13 Aug 2026 12:19:07 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/2] gdb: pass type name directly to arch_composite_type Date: Thu, 13 Aug 2026 12:18:59 -0400 Message-ID: <20260813161905.345483-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260813161905.345483-1-simon.marchi@efficios.com> References: <20260813161905.345483-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 There are a few spots that call arch_composite_type followed by set_name on the created type: sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); sigval_type->set_name (xstrdup ("sigval")); First, it's not necessary to duplicate the string, we can pass the literal string directly, and its lifetime will be appropriate. Second, we can pass the name directly to arch_composite_type, instead of doing a separate set_name call. So, replace the above with: sigval_type = arch_composite_type (gdbarch, "sigval", TYPE_CODE_UNION); Tested on Linux by running the gdb.*/*siginfo*.exp tests. Change-Id: I7779e2156ca42212623dea8de709887acc40d242 --- gdb/fbsd-tdep.c | 7 +++---- gdb/linux-tdep.c | 6 ++---- gdb/netbsd-tdep.c | 16 ++++++++-------- gdb/windows-tdep.c | 16 ++++++---------- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c index 419f935ea72f..0bb63b8c199d 100644 --- a/gdb/fbsd-tdep.c +++ b/gdb/fbsd-tdep.c @@ -1590,8 +1590,7 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch) void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); /* union sigval */ - sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); - sigval_type->set_name (xstrdup ("sigval")); + sigval_type = arch_composite_type (gdbarch, "sigval", TYPE_CODE_UNION); append_composite_type_field (sigval_type, "sival_int", int_type); append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); @@ -1641,8 +1640,8 @@ fbsd_get_siginfo_type (struct gdbarch *gdbarch) append_composite_type_field (reason_type, "__spare__", type); /* struct siginfo */ - siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - siginfo_type->set_name (xstrdup ("siginfo")); + siginfo_type = arch_composite_type (gdbarch, "siginfo", + TYPE_CODE_STRUCT); append_composite_type_field (siginfo_type, "si_signo", int_type); append_composite_type_field (siginfo_type, "si_errno", int_type); append_composite_type_field (siginfo_type, "si_code", int_type); diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index fa9e5cb6f4d9..de2e5aba313c 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -286,9 +286,8 @@ linux_get_siginfo_type (struct gdbarch *gdbarch) = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); /* sival_t */ - type *sigval_union_type = arch_composite_type (gdbarch, nullptr, + type *sigval_union_type = arch_composite_type (gdbarch, "sigval_t", TYPE_CODE_UNION); - sigval_union_type->set_name (xstrdup ("sigval_t")); append_composite_type_field (sigval_union_type, "sival_int", int_type); append_composite_type_field (sigval_union_type, "sival_ptr", void_ptr_type); @@ -394,9 +393,8 @@ linux_get_siginfo_type (struct gdbarch *gdbarch) sigsys_struct_type); /* struct siginfo */ - type *siginfo_struct_type = arch_composite_type (gdbarch, nullptr, + type *siginfo_struct_type = arch_composite_type (gdbarch, "siginfo", TYPE_CODE_STRUCT); - siginfo_struct_type->set_name (xstrdup ("siginfo")); append_composite_type_field (siginfo_struct_type, "si_signo", int_type); append_composite_type_field (siginfo_struct_type, "si_errno", int_type); append_composite_type_field (siginfo_struct_type, "si_code", int_type); diff --git a/gdb/netbsd-tdep.c b/gdb/netbsd-tdep.c index e369622ae7f7..1c0569873091 100644 --- a/gdb/netbsd-tdep.c +++ b/gdb/netbsd-tdep.c @@ -419,14 +419,14 @@ nbsd_get_siginfo_type (struct gdbarch *gdbarch) lwpid_type->set_target_type (int32_type); /* union sigval */ - type *sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); - sigval_type->set_name (gdbarch_obstack_strdup (gdbarch, "sigval")); + type *sigval_type = arch_composite_type (gdbarch, "sigval", + TYPE_CODE_UNION); append_composite_type_field (sigval_type, "sival_int", int_type); append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); /* union _option */ - type *option_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); - option_type->set_name (gdbarch_obstack_strdup (gdbarch, "_option")); + type *option_type = arch_composite_type (gdbarch, "_option", + TYPE_CODE_UNION); append_composite_type_field (option_type, "_pe_other_pid", pid_type); append_composite_type_field (option_type, "_pe_lwp", lwpid_type); @@ -480,8 +480,8 @@ nbsd_get_siginfo_type (struct gdbarch *gdbarch) append_composite_type_field (reason_type, "_ptrace_state", t); /* struct _ksiginfo */ - type *ksiginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - ksiginfo_type->set_name (gdbarch_obstack_strdup (gdbarch, "_ksiginfo")); + type *ksiginfo_type = arch_composite_type (gdbarch, "_ksiginfo", + TYPE_CODE_STRUCT); append_composite_type_field (ksiginfo_type, "_signo", int_type); append_composite_type_field (ksiginfo_type, "_code", int_type); append_composite_type_field (ksiginfo_type, "_errno", int_type); @@ -490,8 +490,8 @@ nbsd_get_siginfo_type (struct gdbarch *gdbarch) append_composite_type_field (ksiginfo_type, "_reason", reason_type); /* union siginfo */ - type *siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); - siginfo_type->set_name (gdbarch_obstack_strdup (gdbarch, "siginfo")); + type *siginfo_type = arch_composite_type (gdbarch, "siginfo", + TYPE_CODE_UNION); append_composite_type_field (siginfo_type, "si_pad", init_vector_type (char_type, 128)); append_composite_type_field (siginfo_type, "_info", ksiginfo_type); diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index c0a743914b1c..6e83c8773c2d 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -225,8 +225,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* list entry */ - list_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - list_type->set_name (xstrdup ("list")); + list_type = arch_composite_type (gdbarch, "list", TYPE_CODE_STRUCT); module_list_ptr_type = void_ptr_type; @@ -237,8 +236,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* Structured Exception Handler */ - seh_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - seh_type->set_name (xstrdup ("seh")); + seh_type = arch_composite_type (gdbarch, "seh", TYPE_CODE_STRUCT); seh_ptr_type = alloc.new_type (TYPE_CODE_PTR, void_ptr_type->length () * TARGET_CHAR_BIT, @@ -250,8 +248,8 @@ windows_get_tlb_type (struct gdbarch *gdbarch) builtin_type (gdbarch)->builtin_func_ptr); /* struct _PEB_LDR_DATA */ - peb_ldr_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - peb_ldr_type->set_name (xstrdup ("peb_ldr_data")); + peb_ldr_type = arch_composite_type (gdbarch, "peb_ldr_data", + TYPE_CODE_STRUCT); append_composite_type_field (peb_ldr_type, "length", dword32_type); append_composite_type_field (peb_ldr_type, "initialized", dword32_type); @@ -319,8 +317,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* struct process environment block */ - peb_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - peb_type->set_name (xstrdup ("peb")); + peb_type = arch_composite_type (gdbarch, "peb", TYPE_CODE_STRUCT); /* First bytes contain several flags. */ append_composite_type_field (peb_type, "flags", dword_ptr_type); @@ -338,8 +335,7 @@ windows_get_tlb_type (struct gdbarch *gdbarch) /* struct thread information block */ - tib_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - tib_type->set_name (xstrdup ("tib")); + tib_type = arch_composite_type (gdbarch, "tib", TYPE_CODE_STRUCT); /* uint32_t current_seh; %fs:0x0000 */ append_composite_type_field (tib_type, "current_seh", seh_ptr_type); -- 2.55.0