From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2RIfI5bufWpyfSMAWB0awg (envelope-from ) for ; Thu, 13 Aug 2026 12:19:34 -0400 Received: by simark.ca (Postfix, from userid 112) id 8CF4A1E166; Thu, 13 Aug 2026 12:19:34 -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 [IPv6:2620:52:6:3111::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 C6FEE1E09B for ; Thu, 13 Aug 2026 12:19:33 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 805AE4BB1C38 for ; Thu, 13 Aug 2026 16:19:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 805AE4BB1C38 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 9870E4BAE7CF for ; Thu, 13 Aug 2026 16:19:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9870E4BAE7CF 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 9870E4BAE7CF 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=wF7RLJyvv0Bk7yxl5pHCIHo+uwF5sx8DLCLpMHm8DOOYxoxkSg2S9IC1T9EYchoMBJo4wj+EQf8iMncF0kDBcTUvbmyTbqSjywUzjwhCRlBSGBBQ0s9eCD77BDyjPPXwgu6EVw0RQDyE4wf8+iAmnfd36Jl9ZUayRDDojwioMHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786637948; c=relaxed/simple; bh=rpUKBZ6ALTlF7ScFTSYgxSsFFPnBV7qnw6JLLY4z6xU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=wOwIDkV7eXg6dApaK6M/ZcMvpvdhDZd1kE66x0IW0YgI3G8QmDFiMqd59Srk5z5k54NyE55TUg+fJBCcQboKxL7E4eKx8XUC1Aa9zeLtik9X0PypUTOG986txlJv9srmveJBl0Wl2yCMqRPiz2SyXromVUwEunlpdbCpussqGOI= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9870E4BAE7CF Received: by simark.ca (Postfix) id 5346C1E09B; Thu, 13 Aug 2026 12:19:07 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] gdb/linux-tdep: clearer variable names in linux_get_siginfo_type Date: Thu, 13 Aug 2026 12:18:58 -0400 Message-ID: <20260813161905.345483-1-simon.marchi@efficios.com> X-Mailer: git-send-email 2.55.0 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 Instead of reusing the single variable `type`, use distinct variables for the various types created. I find it more readable this way, it's easier to track what's being added to what. Do other cleanups at the same time, like NULL -> nullptr, removing some `struct` keywords, and moving variable declarations to the point of first use. Change-Id: I846df0d4ad2208b768465c14abdc5422cc16bd07 --- gdb/linux-tdep.c | 154 +++++++++++++++++++++++++---------------------- 1 file changed, 83 insertions(+), 71 deletions(-) diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 23e43ba5c5f9..fa9e5cb6f4d9 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -268,58 +268,54 @@ get_linux_inferior_data (inferior *inf) /* Implementation of gdbarch_get_siginfo_type. */ -static struct type * +static type * linux_get_siginfo_type (struct gdbarch *gdbarch) { - struct linux_gdbarch_data *linux_gdbarch_data; - struct type *void_ptr_type; - struct type *uid_type, *pid_type; - struct type *sigval_type, *clock_type; - struct type *siginfo_type, *sifields_type; - struct type *type; + linux_gdbarch_data *linux_gdbarch_data = get_linux_gdbarch_data (gdbarch); - linux_gdbarch_data = get_linux_gdbarch_data (gdbarch); - if (linux_gdbarch_data->siginfo_type != NULL) + if (linux_gdbarch_data->siginfo_type != nullptr) return linux_gdbarch_data->siginfo_type; type_allocator alloc (gdbarch); const struct builtin_type *builtin_types = builtin_type (gdbarch); - struct type *int_type = builtin_types->builtin_int; - struct type *uint_type = builtin_types->builtin_unsigned_int; - struct type *long_type = builtin_types->builtin_long; - - void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); + type *int_type = builtin_types->builtin_int; + type *uint_type = builtin_types->builtin_unsigned_int; + type *long_type = builtin_types->builtin_long; + type *void_ptr_type + = lookup_pointer_type (builtin_type (gdbarch)->builtin_void); /* sival_t */ - sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); - sigval_type->set_name (xstrdup ("sigval_t")); - append_composite_type_field (sigval_type, "sival_int", int_type); - append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type); + type *sigval_union_type = arch_composite_type (gdbarch, nullptr, + 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); /* __pid_t */ - pid_type = alloc.new_type (TYPE_CODE_TYPEDEF, - int_type->length () * TARGET_CHAR_BIT, - "__pid_t"); + type *pid_type = alloc.new_type (TYPE_CODE_TYPEDEF, + int_type->length () * TARGET_CHAR_BIT, + "__pid_t"); pid_type->set_target_type (int_type); pid_type->set_target_is_stub (true); /* __uid_t */ - uid_type = alloc.new_type (TYPE_CODE_TYPEDEF, - uint_type->length () * TARGET_CHAR_BIT, - "__uid_t"); + type *uid_type = alloc.new_type (TYPE_CODE_TYPEDEF, + uint_type->length () * TARGET_CHAR_BIT, + "__uid_t"); uid_type->set_target_type (uint_type); uid_type->set_target_is_stub (true); /* __clock_t */ - clock_type = alloc.new_type (TYPE_CODE_TYPEDEF, - long_type->length () * TARGET_CHAR_BIT, - "__clock_t"); + type *clock_type = alloc.new_type (TYPE_CODE_TYPEDEF, + long_type->length () * TARGET_CHAR_BIT, + "__clock_t"); clock_type->set_target_type (long_type); clock_type->set_target_is_stub (true); /* _sifields */ - sifields_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION); + type *sifields_union_type = arch_composite_type (gdbarch, nullptr, + TYPE_CODE_UNION); { const int si_max_size = 128; @@ -331,70 +327,86 @@ linux_get_siginfo_type (struct gdbarch *gdbarch) si_pad_size = (si_max_size / size_of_int) - 4; else si_pad_size = (si_max_size / size_of_int) - 3; - append_composite_type_field (sifields_type, "_pad", + + append_composite_type_field (sifields_union_type, "_pad", init_vector_type (int_type, si_pad_size)); } /* _kill */ - type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - append_composite_type_field (type, "si_pid", pid_type); - append_composite_type_field (type, "si_uid", uid_type); - append_composite_type_field (sifields_type, "_kill", type); + type *kill_struct_type = arch_composite_type (gdbarch, nullptr, + TYPE_CODE_STRUCT); + append_composite_type_field (kill_struct_type, "si_pid", pid_type); + append_composite_type_field (kill_struct_type, "si_uid", uid_type); + append_composite_type_field (sifields_union_type, "_kill", kill_struct_type); /* _timer */ - type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - append_composite_type_field (type, "si_tid", int_type); - append_composite_type_field (type, "si_overrun", int_type); - append_composite_type_field (type, "si_sigval", sigval_type); - append_composite_type_field (sifields_type, "_timer", type); + type *timer_struct_type = arch_composite_type (gdbarch, nullptr, + TYPE_CODE_STRUCT); + append_composite_type_field (timer_struct_type, "si_tid", int_type); + append_composite_type_field (timer_struct_type, "si_overrun", int_type); + append_composite_type_field (timer_struct_type, "si_sigval", + sigval_union_type); + append_composite_type_field (sifields_union_type, "_timer", + timer_struct_type); /* _rt */ - type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - append_composite_type_field (type, "si_pid", pid_type); - append_composite_type_field (type, "si_uid", uid_type); - append_composite_type_field (type, "si_sigval", sigval_type); - append_composite_type_field (sifields_type, "_rt", type); + type *rt_struct_type = arch_composite_type (gdbarch, nullptr, + TYPE_CODE_STRUCT); + append_composite_type_field (rt_struct_type, "si_pid", pid_type); + append_composite_type_field (rt_struct_type, "si_uid", uid_type); + append_composite_type_field (rt_struct_type, "si_sigval", sigval_union_type); + append_composite_type_field (sifields_union_type, "_rt", rt_struct_type); /* _sigchld */ - type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - append_composite_type_field (type, "si_pid", pid_type); - append_composite_type_field (type, "si_uid", uid_type); - append_composite_type_field (type, "si_status", int_type); - append_composite_type_field (type, "si_utime", clock_type); - append_composite_type_field (type, "si_stime", clock_type); - append_composite_type_field (sifields_type, "_sigchld", type); + type *sigchld_struct_type = arch_composite_type (gdbarch, nullptr, + TYPE_CODE_STRUCT); + append_composite_type_field (sigchld_struct_type, "si_pid", pid_type); + append_composite_type_field (sigchld_struct_type, "si_uid", uid_type); + append_composite_type_field (sigchld_struct_type, "si_status", int_type); + append_composite_type_field (sigchld_struct_type, "si_utime", clock_type); + append_composite_type_field (sigchld_struct_type, "si_stime", clock_type); + append_composite_type_field (sifields_union_type, "_sigchld", + sigchld_struct_type); /* _sigfault */ - type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - append_composite_type_field (type, "si_addr", void_ptr_type); - append_composite_type_field (sifields_type, "_sigfault", type); + type *sigfault_struct_type = arch_composite_type (gdbarch, nullptr, + TYPE_CODE_STRUCT); + append_composite_type_field (sigfault_struct_type, "si_addr", void_ptr_type); + append_composite_type_field (sifields_union_type, "_sigfault", + sigfault_struct_type); /* _sigpoll */ - type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - append_composite_type_field (type, "si_band", long_type); - append_composite_type_field (type, "si_fd", int_type); - append_composite_type_field (sifields_type, "_sigpoll", type); + type *sigpoll_struct_type = arch_composite_type (gdbarch, NULL, + TYPE_CODE_STRUCT); + append_composite_type_field (sigpoll_struct_type, "si_band", long_type); + append_composite_type_field (sigpoll_struct_type, "si_fd", int_type); + append_composite_type_field (sifields_union_type, "_sigpoll", + sigpoll_struct_type); /* _sigsys */ - type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - append_composite_type_field (type, "_call_addr", void_ptr_type); - append_composite_type_field (type, "_syscall", int_type); - append_composite_type_field (type, "_arch", uint_type); - append_composite_type_field (sifields_type, "_sigsys", type); + type *sigsys_struct_type = arch_composite_type (gdbarch, nullptr, + TYPE_CODE_STRUCT); + append_composite_type_field (sigsys_struct_type, "_call_addr", + void_ptr_type); + append_composite_type_field (sigsys_struct_type, "_syscall", int_type); + append_composite_type_field (sigsys_struct_type, "_arch", uint_type); + append_composite_type_field (sifields_union_type, "_sigsys", + sigsys_struct_type); /* struct siginfo */ - siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT); - siginfo_type->set_name (xstrdup ("siginfo")); - 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); - append_composite_type_field_aligned (siginfo_type, - "_sifields", sifields_type, + type *siginfo_struct_type = arch_composite_type (gdbarch, nullptr, + 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); + append_composite_type_field_aligned (siginfo_struct_type, "_sifields", + sifields_union_type, long_type->length ()); - linux_gdbarch_data->siginfo_type = siginfo_type; + linux_gdbarch_data->siginfo_type = siginfo_struct_type; - return siginfo_type; + return siginfo_struct_type; } /* Return true if the target is running on uClinux instead of normal base-commit: 1686e21559a7812ebbc05f57372cc30880768bf7 -- 2.55.0