From patchwork Wed Dec 17 15:54:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 126707 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 7DCC54BA23DC for ; Wed, 17 Dec 2025 15:56:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DCC54BA23DC X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 289D94BA2E29 for ; Wed, 17 Dec 2025 15:55:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 289D94BA2E29 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 289D94BA2E29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986954; cv=none; b=EHsHJnqyS8zudiFOQiiffgoTvYzyB76Ff3Id3tr+LlQlq7gRoI3+PQdOJ5SnLoYKEaw8PWcHK9p5Tu9278nuSDdqnRUp6B5rwT4yj3ytU1hQMMez8xPF1S3WsF7ENzcn2mMaaYWKnMlRLSxJPL8snwXkckLdcyI7/AjF2Rhf46w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986954; c=relaxed/simple; bh=oiF5ImtQgG6y84Qd68NJqU45tkvCEDzg3WT69pKdK/Q=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=DZyt1vmkzdt1kOUljovOY6NQq8SUOGTsMdoeSoiI4RS6AV4jQ9pin1E+o6NzUzIsSYJ9jRQ1qesOCN4xvy8p4sF/fwvLhzx0yRxItD59mGE/ZATU9K7LtMQ/DTeC9e2p858KHbaYJsqX9FwwCQvtZt7OazZRsbPJn5SNB3pR85s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 289D94BA2E29 Received: by simark.ca (Postfix) id A6E221E093; Wed, 17 Dec 2025 10:55:53 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/7] gdb: make create_function_type static Date: Wed, 17 Dec 2025 10:54:55 -0500 Message-ID: <20251217155550.37654-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217155550.37654-1-simon.marchi@efficios.com> References: <20251217155550.37654-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1165.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, LOCAL_AUTHENTICATION_FAIL_DMARC, LOCAL_AUTHENTICATION_FAIL_SPF, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org From: Simon Marchi It is only used within gdbtypes.c. Change-Id: I3976ca1ec3253c0ade6e7ac71d967d09108d2454 --- gdb/gdbtypes.c | 6 ++++-- gdb/gdbtypes.h | 22 ++++++++++------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 975e1246a0df..96d5e0c425a6 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -560,9 +560,11 @@ make_function_type (struct type *type, struct type **typeptr) return ntype; } -/* See gdbtypes.h. */ +/* Given a return type and argument types, create new function type. + If the final type in PARAM_TYPES is NULL, create a varargs function. + New type is allocated using ALLOC. */ -struct type * +static struct type * create_function_type (type_allocator &alloc, struct type *return_type, int nparams, diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 3ae5a1ef4841..ebacb30b847e 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2517,21 +2517,19 @@ extern struct type *lookup_pointer_type (struct type *); extern struct type *make_function_type (struct type *, struct type **); -/* Given a return type and argument types, create new function type. - If the final type in PARAM_TYPES is NULL, create a varargs function. - New type is allocated using ALLOC. */ -extern struct type *create_function_type (type_allocator &alloc, - struct type *return_type, - int nparams, - struct type **param_types); +/* Create a new function type with return type RETURN_TYPE and unspecified + number and types of parameters. + + The new function type has the same owner as RETURN_TYPE. */ -/* Like create_function_type, but allocate the new function type at - the same obstack as RETURN_TYPE and with unspecified number of - parameters and their types. */ extern struct type *lookup_function_type (struct type *return_type); -/* Like create_function_type, but allocate the new function type at - the same obstack as RETURN_TYPE. */ +/* Create a new function type with return type RETURN_TYPE and NPARAMS parameter + of types PARAM_TYPES. If the final type in PARAM_TYPES is nullptr, create a + varargs function. + + The new function type has the same owner as RETURN_TYPE. */ + extern struct type *lookup_function_type_with_arguments (struct type *return_type, int nparams, From patchwork Wed Dec 17 15:54:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 126710 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 9C7524BA23D8 for ; Wed, 17 Dec 2025 15:56:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C7524BA23D8 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id ECB844BA2E04 for ; Wed, 17 Dec 2025 15:55:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ECB844BA2E04 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 ECB844BA2E04 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986955; cv=none; b=qv51hkhkCwTM2TR4BK9i5eeQAxR3wjx1dQ7RN2lCKNqcuY1LHCE0tU5W3n/7r18IkCqyuuhtxxZckfKWaUhE9ffCvP3M9A85+a1uesflR3PYewG4HxX1zI9wgyj0Fhm5CWKtnMKmlEd3otDFMpU3BqjlDqkMwyMDhhkr7Yfb86I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986955; c=relaxed/simple; bh=bbsJVGBsolhuBAy4GH4u58MTGtEKGEb9+DbbOtH1NcU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=GJ1POf3GwV+bq8vFlfZJhmPQHi2GtjX1z4EzpFC+OJjf1fTCsSHb4KKZfWb0sLehvP3mVp5sMkpgrLaR9mvYDgjt9SpJiYNnu9AHKveVALgxc5y3Wok98ltj1YTEFWISRp1XPQVyXeS/FHsLT4m2FMI+jN4o0Lq5i/DXhSYKM3g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECB844BA2E04 Received: by simark.ca (Postfix) id 8480A1E08D; Wed, 17 Dec 2025 10:55:54 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/7] gdb: remove make_pointer_type typeptr parameter Date: Wed, 17 Dec 2025 10:54:56 -0500 Message-ID: <20251217155550.37654-3-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217155550.37654-1-simon.marchi@efficios.com> References: <20251217155550.37654-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1166.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, LOCAL_AUTHENTICATION_FAIL_DMARC, LOCAL_AUTHENTICATION_FAIL_SPF, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org From: Simon Marchi It is always nullptr. Change-Id: I88e81427c781bd6356203ccc969eae1ab84ac0ef --- gdb/break-catch-throw.c | 2 +- gdb/gdbtypes.c | 37 ++++++------------------------------- gdb/gdbtypes.h | 4 +++- gdb/gnu-v3-abi.c | 4 ++-- gdb/mdebugread.c | 2 +- 5 files changed, 13 insertions(+), 36 deletions(-) diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 3ad3beb41e8b..552d7124bbd9 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -481,7 +481,7 @@ compute_exception (struct gdbarch *argc, struct internalvar *var, void *ignore) the std::type_info for the exception. Now we find the type from the type_info and cast the result. */ obj_type = cplus_type_from_type_info (arg1); - return value_ind (value_cast (make_pointer_type (obj_type, NULL), arg0)); + return value_ind (value_cast (make_pointer_type (obj_type), arg0)); } /* Implementation of the '$_exception' variable. */ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 96d5e0c425a6..2b0025c05c42 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -360,13 +360,10 @@ smash_type (struct type *type) /* For now, leave the pointer/reference types alone. */ } -/* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points - to a pointer to memory where the pointer type should be stored. - If *TYPEPTR is zero, update it to point to the pointer type we return. - We allocate new memory if needed. */ +/* See gdbtypes.h. */ -struct type * -make_pointer_type (struct type *type, struct type **typeptr) +type * +make_pointer_type (type *type) { struct type *ntype; /* New type */ struct type *chain; @@ -374,31 +371,9 @@ make_pointer_type (struct type *type, struct type **typeptr) ntype = TYPE_POINTER_TYPE (type); if (ntype) - { - if (typeptr == 0) - return ntype; /* Don't care about alloc, - and have new type. */ - else if (*typeptr == 0) - { - *typeptr = ntype; /* Tracking alloc, and have new type. */ - return ntype; - } - } - - if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ - { - ntype = type_allocator (type).new_type (); - if (typeptr) - *typeptr = ntype; - } - else /* We have storage, but need to reset it. */ - { - ntype = *typeptr; - chain = TYPE_CHAIN (ntype); - smash_type (ntype); - TYPE_CHAIN (ntype) = chain; - } + return ntype; + ntype = type_allocator (type).new_type (); ntype->set_target_type (type); TYPE_POINTER_TYPE (type) = ntype; @@ -429,7 +404,7 @@ make_pointer_type (struct type *type, struct type **typeptr) struct type * lookup_pointer_type (struct type *type) { - return make_pointer_type (type, (struct type **) 0); + return make_pointer_type (type); } /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index ebacb30b847e..f27ff36498c0 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2511,7 +2511,9 @@ extern struct_elt lookup_struct_elt (struct type *, const char *, int); extern struct type *lookup_struct_elt_type (struct type *, const char *, int); -extern struct type *make_pointer_type (struct type *, struct type **); +/* Lookup a pointer to a type TYPE. */ + +extern type *make_pointer_type (type *type); extern struct type *lookup_pointer_type (struct type *); diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 700e271903e2..483ae2d98909 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1003,7 +1003,7 @@ build_std_type_info_type (struct gdbarch *arch) struct type *char_type = builtin_type (arch)->builtin_char; struct type *char_ptr_type - = make_pointer_type (make_cv_type (1, 0, char_type, NULL), NULL); + = make_pointer_type (make_cv_type (1, 0, char_type, NULL)); t = type_allocator (arch).new_type (TYPE_CODE_STRUCT, 0, nullptr); @@ -1120,7 +1120,7 @@ gnuv3_get_typeid (struct value *value) error (_("cannot find typeinfo for object of type '%s'"), name); typeinfo_value = value_field (vtable, vtable_field_type_info); - result = value_ind (value_cast (make_pointer_type (typeinfo_type, NULL), + result = value_ind (value_cast (make_pointer_type (typeinfo_type), typeinfo_value)); } else diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index f5949e614f4b..6f6fddc42831 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -838,7 +838,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, "program has no memory available". To avoid this, we patch up the type and make it void* instead. (davidm@azstarnet.com). */ - t = make_pointer_type (t, NULL); + t = make_pointer_type (t); } } b = top_stack->cur_block; From patchwork Wed Dec 17 15:54:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 126711 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id B7A354BA2E3E for ; Wed, 17 Dec 2025 15:56:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7A354BA2E3E X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 755544BA2E2C for ; Wed, 17 Dec 2025 15:55:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 755544BA2E2C 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 755544BA2E2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986955; cv=none; b=l0qINiVnyQ+G2JpW3XD78RmRPXXDQK8sO0oeaKjQ8sRxYOGkJbLOjJdmJbXIkdpJ/KHorf10lmwz95Jzgrjp3ojnsl15qfoiqkt1PDHOVmz58sf52T+VWw/0VtmDkCHeeXv1AWDvMPBd0l5WTlKRoDZ2B9vjjOD+QKvgGTn52XA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986955; c=relaxed/simple; bh=fYHpbpdE+9rpMjaDML0J6fYCpP8CMDz8ql0Bq/IIW+U=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=HmZTGVGMzfcw3ExR0TXu5bytiFj1Htp07R/bgUZBe7DpINDh4Mp0p/qqFMlbdeJMOCMJXYTiKYkcXrzFOC/9Y01iNmDZ6rrPNSoTq92MQfnAuyBN2SwBtz/fV8LOMMWlgwVK1F8lU9bJJrCs9ZV3AY34vVG/Ak2XcLtbG3hXr5M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 755544BA2E2C Received: by simark.ca (Postfix) id 0F4A51E0B6; Wed, 17 Dec 2025 10:55:55 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 3/7] gdb: remove make_reference_type typeptr parameter Date: Wed, 17 Dec 2025 10:54:57 -0500 Message-ID: <20251217155550.37654-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217155550.37654-1-simon.marchi@efficios.com> References: <20251217155550.37654-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1166.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, LOCAL_AUTHENTICATION_FAIL_DMARC, LOCAL_AUTHENTICATION_FAIL_SPF, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org From: Simon Marchi It is always passed nullptr. Change-Id: I1ec2afacb694c6d708df28ea6d47f08ceaf973db --- gdb/gdbtypes.c | 39 ++++++--------------------------------- gdb/gdbtypes.h | 5 +++-- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 2b0025c05c42..aa0cb2c515a3 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -407,15 +407,10 @@ lookup_pointer_type (struct type *type) return make_pointer_type (type); } -/* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, - points to a pointer to memory where the reference type should be - stored. If *TYPEPTR is zero, update it to point to the reference - type we return. We allocate new memory if needed. REFCODE denotes - the kind of reference type to lookup (lvalue or rvalue reference). */ +/* See gdbtypes.h. */ -struct type * -make_reference_type (struct type *type, struct type **typeptr, - enum type_code refcode) +type * +make_reference_type (type *type, type_code refcode) { struct type *ntype; /* New type */ struct type **reftype; @@ -427,31 +422,9 @@ make_reference_type (struct type *type, struct type **typeptr, : TYPE_RVALUE_REFERENCE_TYPE (type)); if (ntype) - { - if (typeptr == 0) - return ntype; /* Don't care about alloc, - and have new type. */ - else if (*typeptr == 0) - { - *typeptr = ntype; /* Tracking alloc, and have new type. */ - return ntype; - } - } - - if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ - { - ntype = type_allocator (type).new_type (); - if (typeptr) - *typeptr = ntype; - } - else /* We have storage, but need to reset it. */ - { - ntype = *typeptr; - chain = TYPE_CHAIN (ntype); - smash_type (ntype); - TYPE_CHAIN (ntype) = chain; - } + return ntype; + ntype = type_allocator (type).new_type (); ntype->set_target_type (type); reftype = (refcode == TYPE_CODE_REF ? &TYPE_REFERENCE_TYPE (type) : &TYPE_RVALUE_REFERENCE_TYPE (type)); @@ -484,7 +457,7 @@ make_reference_type (struct type *type, struct type **typeptr, struct type * lookup_reference_type (struct type *type, enum type_code refcode) { - return make_reference_type (type, (struct type **) 0, refcode); + return make_reference_type (type, refcode); } /* Lookup the lvalue reference type for the type TYPE. */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index f27ff36498c0..afb8319cca6b 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2432,9 +2432,10 @@ extern struct type *lookup_reference_type (struct type *, enum type_code); extern struct type *lookup_lvalue_reference_type (struct type *); extern struct type *lookup_rvalue_reference_type (struct type *); +/* Lookup a C++ `reference' to a type TYPE. REFCODE denotes the kind of + reference type to lookup (lvalue or rvalue reference). */ -extern struct type *make_reference_type (struct type *, struct type **, - enum type_code); +extern type *make_reference_type (type *type, type_code refcode); extern struct type *make_cv_type (int, int, struct type *, struct type **); From patchwork Wed Dec 17 15:54:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 126709 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 75E2B4B9DB75 for ; Wed, 17 Dec 2025 15:56:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75E2B4B9DB75 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id F36BC4BA2E32 for ; Wed, 17 Dec 2025 15:55:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F36BC4BA2E32 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 F36BC4BA2E32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986956; cv=none; b=UgT6rpZkr4ONCc9Nz2yAJOSjNBOjoWquW3LfKLvW0HocqlF0kykcrLhjWJYOqF2I+LqMNVe5XEcapj+Fg7fytdl1wfYMg1FNL1uRIhrgrB/h1hG0VcbNLXvfinzeOAQmv4K6kgtwzKBLYGHO9AQXdHeAePbNasTszatchWnkCBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986956; c=relaxed/simple; bh=ueVZr51EqQ/cU8qmHLJ6uk1dJu+FHNVlqBwaMPs0uhU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=jnQ8f8oaRyaQGBsbGDVYSN+d/mVtstSQbffIXMNEwnjEBcsfqIf+eRCg3W9q/7QFg/aNKssN1XyCBbsu7EhT7JQ5BKoLKcvXic5qE+R05rwa0QObFvfQmT7Sw/ogowgrZs/eyhccQnJmNe5IBck/nHsl6FWJVztJ8HLOG2tGCJw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F36BC4BA2E32 Received: by simark.ca (Postfix) id 71FDC1E0BC; Wed, 17 Dec 2025 10:55:55 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/7] gdb: remove make_function_type typeptr parameter Date: Wed, 17 Dec 2025 10:54:58 -0500 Message-ID: <20251217155550.37654-5-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217155550.37654-1-simon.marchi@efficios.com> References: <20251217155550.37654-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1166.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, LOCAL_AUTHENTICATION_FAIL_DMARC, LOCAL_AUTHENTICATION_FAIL_SPF, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org From: Simon Marchi In a few places, it is passed nullptr, meaning that we allocate a type using a type allocator derived from the return type. In the -> lookup_function_type_with_arguments -> create_function_type -> make_function_type and -> lookup_function_type -> create_function_type -> make_function_type paths, we create an allocator based on the return type, pass it down, and create a type using that, which then gets passed to make_function_type. Instead, we can let make_function_type allocate the type based on the return type. Change-Id: I3f38e2f4744ab664bd91b006b00501332df617b5 --- gdb/avr-tdep.c | 2 +- gdb/ft32-tdep.c | 2 +- gdb/gdbtypes.c | 46 +++++++++++----------------------------------- gdb/gdbtypes.h | 4 +++- gdb/z80-tdep.c | 2 +- 5 files changed, 17 insertions(+), 39 deletions(-) diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 4f6d1fc9d00e..1a80e0b4ef8b 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1475,7 +1475,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) be defined. */ type_allocator alloc (gdbarch); tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - tdep->func_void_type = make_function_type (tdep->void_type, NULL); + tdep->func_void_type = make_function_type (tdep->void_type); tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL, tdep->func_void_type); diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index b1ebd7209eea..1f2c2d970afa 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -576,7 +576,7 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) be defined. */ type_allocator alloc (gdbarch); void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - func_void_type = make_function_type (void_type, NULL); + func_void_type = make_function_type (void_type); tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL, func_void_type); tdep->pc_type->set_instance_flags (tdep->pc_type->instance_flags () diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index aa0cb2c515a3..f42fee408fdb 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -476,30 +476,14 @@ lookup_rvalue_reference_type (struct type *type) return lookup_reference_type (type, TYPE_CODE_RVALUE_REF); } -/* Lookup a function type that returns type TYPE. TYPEPTR, if - nonzero, points to a pointer to memory where the function type - should be stored. If *TYPEPTR is zero, update it to point to the - function type we return. We allocate new memory if needed. */ +/* See gdbtypes.h. */ -struct type * -make_function_type (struct type *type, struct type **typeptr) +type * +make_function_type (type *return_type) { - struct type *ntype; /* New type */ - - if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ - { - ntype = type_allocator (type).new_type (); - if (typeptr) - *typeptr = ntype; - } - else /* We have storage, but need to reset it. */ - { - ntype = *typeptr; - smash_type (ntype); - } - - ntype->set_target_type (type); + type *ntype = type_allocator (return_type).new_type (); + ntype->set_target_type (return_type); ntype->set_length (1); ntype->set_code (TYPE_CODE_FUNC); @@ -512,16 +496,10 @@ make_function_type (struct type *type, struct type **typeptr) If the final type in PARAM_TYPES is NULL, create a varargs function. New type is allocated using ALLOC. */ -static struct type * -create_function_type (type_allocator &alloc, - struct type *return_type, - int nparams, - struct type **param_types) +static type * +create_function_type (type *return_type, int nparams, type **param_types) { - struct type *fn = alloc.new_type (); - int i; - - make_function_type (return_type, &fn); + type *fn = make_function_type (return_type); if (nparams > 0) { @@ -543,7 +521,7 @@ create_function_type (type_allocator &alloc, } fn->alloc_fields (nparams); - for (i = 0; i < nparams; ++i) + for (int i = 0; i < nparams; ++i) fn->field (i).set_type (param_types[i]); return fn; @@ -554,8 +532,7 @@ create_function_type (type_allocator &alloc, struct type * lookup_function_type (struct type *return_type) { - type_allocator alloc (return_type); - return create_function_type (alloc, return_type, 0, nullptr); + return create_function_type (return_type, 0, nullptr); } /* See gdbtypes.h. */ @@ -565,8 +542,7 @@ lookup_function_type_with_arguments (struct type *return_type, int nparams, struct type **param_types) { - type_allocator alloc (return_type); - return create_function_type (alloc, return_type, nparams, param_types); + return create_function_type (return_type, nparams, param_types); } /* Identify address space identifier by name -- return a diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index afb8319cca6b..b467190ffb7f 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2518,7 +2518,9 @@ extern type *make_pointer_type (type *type); extern struct type *lookup_pointer_type (struct type *); -extern struct type *make_function_type (struct type *, struct type **); +/* Lookup a function type that returns type RETURN_TYPE. */ + +extern struct type *make_function_type (type *return_type); /* Create a new function type with return type RETURN_TYPE and unspecified number and types of parameters. diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index b07d6b15385b..fd4171abac76 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -1142,7 +1142,7 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) type_allocator alloc (gdbarch); tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - tdep->func_void_type = make_function_type (tdep->void_type, NULL); + tdep->func_void_type = make_function_type (tdep->void_type); tdep->pc_type = init_pointer_type (alloc, tdep->addr_length * TARGET_CHAR_BIT, NULL, tdep->func_void_type); From patchwork Wed Dec 17 15:54:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 126708 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id C74024BA2E1F for ; Wed, 17 Dec 2025 15:56:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C74024BA2E1F X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 443DB4BA2E34 for ; Wed, 17 Dec 2025 15:55:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 443DB4BA2E34 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 443DB4BA2E34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986956; cv=none; b=aEsnh0E2E4EP35S7aInfqORJGYyE2BcX4dGHFKYmjtunFKbKkhU8qLrgMzIUKt4vozjiMlcoaovEqvqycojyS8gqgh6F8+k1M4j3ZwXa40ESbfYtvmL+p4rT7zd9WZiQxhMeLOTWGUP/gDFnbhhUWnINsGevzKpquoSqqy08g5Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986956; c=relaxed/simple; bh=LQzjjz7BO6LRclkNcJyWa41BK/oLTJhexOneS07oKVo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=hs+0O4KzsmTvQd9yRAl6lhXCeSQYuMv+i3uBjLmUfsLsC/WC0ang/3zPmryO/ttfTnjh2q4NDQ+M2cad3jEBdKtAH35swwnETDaHsByFOPnGqYbiA75E9vh89xS5UasrOFBd/H+R+uf7xD4hc2IxdVfcffRP7THvofgM1jr3lxc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 443DB4BA2E34 Received: by simark.ca (Postfix) id CE3D71E0C2; Wed, 17 Dec 2025 10:55:55 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 5/7] gdb: remove make_function_type Date: Wed, 17 Dec 2025 10:54:59 -0500 Message-ID: <20251217155550.37654-6-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217155550.37654-1-simon.marchi@efficios.com> References: <20251217155550.37654-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1166.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, LOCAL_AUTHENTICATION_FAIL_DMARC, LOCAL_AUTHENTICATION_FAIL_SPF, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org From: Simon Marchi We now have make_function_type and lookup_function_type exposed by gdbtypes.h, which do essentially the same thing. Remove make_function_type, inlining its code inside create_function_type. Change all other callers of make_function_type to use lookup_function_type instead. Change-Id: Id7c25f02059efe5c0f15e8ab8a35ac1fa97d9d6a --- gdb/avr-tdep.c | 2 +- gdb/ft32-tdep.c | 2 +- gdb/gdbtypes.c | 24 +++++++----------------- gdb/gdbtypes.h | 4 ---- gdb/z80-tdep.c | 2 +- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c index 1a80e0b4ef8b..a88fdb2f9202 100644 --- a/gdb/avr-tdep.c +++ b/gdb/avr-tdep.c @@ -1475,7 +1475,7 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) be defined. */ type_allocator alloc (gdbarch); tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - tdep->func_void_type = make_function_type (tdep->void_type); + tdep->func_void_type = lookup_function_type (tdep->void_type); tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL, tdep->func_void_type); diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 1f2c2d970afa..ecfbdfd0fc57 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -576,7 +576,7 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) be defined. */ type_allocator alloc (gdbarch); void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - func_void_type = make_function_type (void_type); + func_void_type = lookup_function_type (void_type); tdep->pc_type = init_pointer_type (alloc, 4 * TARGET_CHAR_BIT, NULL, func_void_type); tdep->pc_type->set_instance_flags (tdep->pc_type->instance_flags () diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f42fee408fdb..d3e9bbbdcd52 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -476,22 +476,6 @@ lookup_rvalue_reference_type (struct type *type) return lookup_reference_type (type, TYPE_CODE_RVALUE_REF); } -/* See gdbtypes.h. */ - -type * -make_function_type (type *return_type) -{ - type *ntype = type_allocator (return_type).new_type (); - - ntype->set_target_type (return_type); - ntype->set_length (1); - ntype->set_code (TYPE_CODE_FUNC); - - INIT_FUNC_SPECIFIC (ntype); - - return ntype; -} - /* Given a return type and argument types, create new function type. If the final type in PARAM_TYPES is NULL, create a varargs function. New type is allocated using ALLOC. */ @@ -499,7 +483,13 @@ make_function_type (type *return_type) static type * create_function_type (type *return_type, int nparams, type **param_types) { - type *fn = make_function_type (return_type); + type *fn = type_allocator (return_type).new_type (); + + fn->set_target_type (return_type); + fn->set_length (1); + fn->set_code (TYPE_CODE_FUNC); + + INIT_FUNC_SPECIFIC (fn); if (nparams > 0) { diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index b467190ffb7f..486d62244f6c 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2518,10 +2518,6 @@ extern type *make_pointer_type (type *type); extern struct type *lookup_pointer_type (struct type *); -/* Lookup a function type that returns type RETURN_TYPE. */ - -extern struct type *make_function_type (type *return_type); - /* Create a new function type with return type RETURN_TYPE and unspecified number and types of parameters. diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c index fd4171abac76..3b45c455a8a8 100644 --- a/gdb/z80-tdep.c +++ b/gdb/z80-tdep.c @@ -1142,7 +1142,7 @@ z80_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) type_allocator alloc (gdbarch); tdep->void_type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void"); - tdep->func_void_type = make_function_type (tdep->void_type); + tdep->func_void_type = lookup_function_type (tdep->void_type); tdep->pc_type = init_pointer_type (alloc, tdep->addr_length * TARGET_CHAR_BIT, NULL, tdep->func_void_type); From patchwork Wed Dec 17 15:55:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 126713 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 215204BA2E34 for ; Wed, 17 Dec 2025 15:56:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 215204BA2E34 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 992914BA2E36 for ; Wed, 17 Dec 2025 15:55:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 992914BA2E36 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 992914BA2E36 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986956; cv=none; b=bpqdpQrer0SNUYaaofLK2fB9MCZiUkTII2REVZ/znyPSDIZan113ooONPlClfyp0iwJ3Ykx1mY8P7vPN/hV4ucd46W5qqE1cFyM61iPtvC2cGDg3z+Bdvp2XHikg9lR7vb0738KoZJ4avq1XCWaiIcJNWCtz5u55BsVFTS4oJrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986956; c=relaxed/simple; bh=4sk2XsdL8GfaagKwYRt6Rat6zYN6xA9S5in1C8By6PI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=qXbzWzaY/G+33ohxNyOR8i+wWBs+PzaoRhDxmaGYQWw5aTyUMIuohPaIJbta0CxqvJS6z9YjKqQWMf9Z1NG4eJOSmz2WrZZEONlQM1k5OacHCGZ625XPv+sTyv6HxENo1LTluInjORELLaZly3d//6aj1zvVF8QR3YfA2iEi28c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 992914BA2E36 Received: by simark.ca (Postfix) id 3E9FC1E093; Wed, 17 Dec 2025 10:55:56 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 6/7] gdb: remove make_cv_type typeptr parameter Date: Wed, 17 Dec 2025 10:55:00 -0500 Message-ID: <20251217155550.37654-7-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217155550.37654-1-simon.marchi@efficios.com> References: <20251217155550.37654-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1166.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, LOCAL_AUTHENTICATION_FAIL_DMARC, LOCAL_AUTHENTICATION_FAIL_SPF, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org From: Simon Marchi It is always passed nullptr. Change-Id: Iecc170545c0504af35d83bcb06e07d29994d18e1 --- gdb/c-typeprint.c | 2 +- gdb/ctfread.c | 6 +++--- gdb/dwarf2/read.c | 8 +++---- gdb/gdbtypes.c | 45 ++++------------------------------------ gdb/gdbtypes.h | 8 ++++++- gdb/gnu-v3-abi.c | 4 ++-- gdb/guile/scm-type.c | 6 +++--- gdb/opencl-lang.c | 2 +- gdb/python/py-type.c | 10 ++++----- gdb/python/py-xmethods.c | 3 +-- gdb/rust-lang.c | 2 +- gdb/type-stack.c | 4 ++-- gdb/valops.c | 4 ++-- gdb/value.c | 4 ++-- 14 files changed, 38 insertions(+), 70 deletions(-) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 2f921aec8fc3..c7434fa0edc8 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -543,7 +543,7 @@ c_type_print_args (struct type *type, struct ui_file *stream, And the const/volatile qualifiers are not present in the mangled names as produced by GCC. */ - param_type = make_cv_type (0, 0, param_type, NULL); + param_type = make_cv_type (0, 0, param_type); } c_print_type (param_type, "", stream, -1, 0, language, flags); diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 860894bf0a02..8d0dcf09b2f1 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -717,7 +717,7 @@ add_array_cv_type (struct ctf_context *ccp, el_type = inner_array->target_type (); cnst |= TYPE_CONST (el_type); voltl |= TYPE_VOLATILE (el_type); - inner_array->set_target_type (make_cv_type (cnst, voltl, el_type, nullptr)); + inner_array->set_target_type (make_cv_type (cnst, voltl, el_type)); return set_tid_type (ccp->of, tid, base_type); } @@ -783,7 +783,7 @@ read_const_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) base_type = builtin_type (objfile)->builtin_error; } } - cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0); + cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type); return set_tid_type (objfile, tid, cv_type); } @@ -810,7 +810,7 @@ read_volatile_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid) if (ctf_type_kind (dict, btid) == CTF_K_ARRAY) return add_array_cv_type (ccp, tid, base_type, 0, 1); - cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0); + cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type); return set_tid_type (objfile, tid, cv_type); } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 12f3e5f0e3dd..50f626c0fdbc 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13012,7 +13012,7 @@ add_array_cv_type (struct die_info *die, struct dwarf2_cu *cu, el_type = inner_array->target_type (); cnst |= TYPE_CONST (el_type); voltl |= TYPE_VOLATILE (el_type); - inner_array->set_target_type (make_cv_type (cnst, voltl, el_type, NULL)); + inner_array->set_target_type (make_cv_type (cnst, voltl, el_type)); return set_die_type (die, base_type, cu); } @@ -13034,7 +13034,7 @@ read_tag_const_type (struct die_info *die, struct dwarf2_cu *cu) if (base_type->code () == TYPE_CODE_ARRAY) return add_array_cv_type (die, cu, base_type, 1, 0); - cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0); + cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type); return set_die_type (die, cv_type, cu); } @@ -13056,7 +13056,7 @@ read_tag_volatile_type (struct die_info *die, struct dwarf2_cu *cu) if (base_type->code () == TYPE_CODE_ARRAY) return add_array_cv_type (die, cu, base_type, 0, 1); - cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0); + cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type); return set_die_type (die, cv_type, cu); } @@ -13380,7 +13380,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) if (is_this) arg_type = make_cv_type (1, TYPE_VOLATILE (arg_type), - arg_type, 0); + arg_type); } ftype->field (iparams).set_type (arg_type); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index d3e9bbbdcd52..f485dfbc8e14 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -652,25 +652,11 @@ make_type_with_address_space (struct type *type, return make_qualified_type (type, new_flags, NULL); } -/* Make a "c-v" variant of a type -- a type that is identical to the - one supplied except that it may have const or volatile attributes - CNST is a flag for setting the const attribute - VOLTL is a flag for setting the volatile attribute - TYPE is the base type whose variant we are creating. +/* See gdbtypes.h. */ - If TYPEPTR and *TYPEPTR are non-zero, then *TYPEPTR points to - storage to hold the new qualified type; *TYPEPTR and TYPE must be - in the same objfile. Otherwise, allocate fresh memory for the new - type wherever TYPE lives. If TYPEPTR is non-zero, set it to the - new type we construct. */ - -struct type * -make_cv_type (int cnst, int voltl, - struct type *type, - struct type **typeptr) +type * +make_cv_type (int cnst, int voltl, type *type) { - struct type *ntype; /* New type */ - type_instance_flags new_flags = (type->instance_flags () & ~(TYPE_INSTANCE_FLAG_CONST | TYPE_INSTANCE_FLAG_VOLATILE)); @@ -681,30 +667,7 @@ make_cv_type (int cnst, int voltl, if (voltl) new_flags |= TYPE_INSTANCE_FLAG_VOLATILE; - if (typeptr && *typeptr != NULL) - { - /* TYPE and *TYPEPTR must be in the same objfile. We can't have - a C-V variant chain that threads across objfiles: if one - objfile gets freed, then the other has a broken C-V chain. - - This code used to try to copy over the main type from TYPE to - *TYPEPTR if they were in different objfiles, but that's - wrong, too: TYPE may have a field list or member function - lists, which refer to types of their own, etc. etc. The - whole shebang would need to be copied over recursively; you - can't have inter-objfile pointers. The only thing to do is - to leave stub types as stub types, and look them up afresh by - name each time you encounter them. */ - gdb_assert ((*typeptr)->objfile_owner () == type->objfile_owner ()); - } - - ntype = make_qualified_type (type, new_flags, - typeptr ? *typeptr : NULL); - - if (typeptr != NULL) - *typeptr = ntype; - - return ntype; + return make_qualified_type (type, new_flags, nullptr); } /* Make a 'restrict'-qualified version of TYPE. */ diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 486d62244f6c..2ad8d1044336 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2437,7 +2437,13 @@ extern struct type *lookup_rvalue_reference_type (struct type *); extern type *make_reference_type (type *type, type_code refcode); -extern struct type *make_cv_type (int, int, struct type *, struct type **); +/* Make a "c-v" variant of a type -- a type that is identical to the + one supplied except that it may have const or volatile attributes + CNST is a flag for setting the const attribute + VOLTL is a flag for setting the volatile attribute + TYPE is the base type whose variant we are creating. */ + +extern type *make_cv_type (int cnst, int voltl, type *type); extern struct type *make_restrict_type (struct type *); diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 483ae2d98909..337a85ad82d8 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1003,7 +1003,7 @@ build_std_type_info_type (struct gdbarch *arch) struct type *char_type = builtin_type (arch)->builtin_char; struct type *char_ptr_type - = make_pointer_type (make_cv_type (1, 0, char_type, NULL)); + = make_pointer_type (make_cv_type (1, 0, char_type)); t = type_allocator (arch).new_type (TYPE_CODE_STRUCT, 0, nullptr); @@ -1088,7 +1088,7 @@ gnuv3_get_typeid (struct value *value) type = check_typedef (type->target_type ()); /* Ignore top-level cv-qualifiers. */ - type = make_cv_type (0, 0, type, NULL); + type = make_cv_type (0, 0, type); gdbarch = type->arch (); type_name = type_to_string (type); diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 13676cef4f00..e5a1e646db2a 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -895,7 +895,7 @@ gdbscm_type_const (SCM self) gdbscm_gdb_exception exc {}; try { - type = make_cv_type (1, 0, type, NULL); + type = make_cv_type (1, 0, type); } catch (const gdb_exception &except) { @@ -919,7 +919,7 @@ gdbscm_type_volatile (SCM self) gdbscm_gdb_exception exc {}; try { - type = make_cv_type (0, 1, type, NULL); + type = make_cv_type (0, 1, type); } catch (const gdb_exception &except) { @@ -943,7 +943,7 @@ gdbscm_type_unqualified (SCM self) gdbscm_gdb_exception exc {}; try { - type = make_cv_type (0, 0, type, NULL); + type = make_cv_type (0, 0, type); } catch (const gdb_exception &except) { diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index b3286ff4dc56..3765fc988ea6 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -292,7 +292,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside, if (dst_type == NULL) dst_type = init_vector_type (elm_type, n); - make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL); + make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type); if (noside == EVAL_AVOID_SIDE_EFFECTS) ret = value::allocate (dst_type); diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 5a57df41a954..fca99a0f2597 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -719,7 +719,7 @@ typy_const (PyObject *self, PyObject *args) try { - type = make_cv_type (1, TYPE_VOLATILE (type), type, NULL); + type = make_cv_type (1, TYPE_VOLATILE (type), type); } catch (const gdb_exception &except) { @@ -737,7 +737,7 @@ typy_volatile (PyObject *self, PyObject *args) try { - type = make_cv_type (TYPE_CONST (type), 1, type, NULL); + type = make_cv_type (TYPE_CONST (type), 1, type); } catch (const gdb_exception &except) { @@ -755,7 +755,7 @@ typy_unqualified (PyObject *self, PyObject *args) try { - type = make_cv_type (0, 0, type, NULL); + type = make_cv_type (0, 0, type); } catch (const gdb_exception &except) { @@ -895,10 +895,10 @@ typy_lookup_type (struct demangle_component *demangled, rtype = lookup_pointer_type (type); break; case DEMANGLE_COMPONENT_CONST: - rtype = make_cv_type (1, TYPE_VOLATILE (type), type, NULL); + rtype = make_cv_type (1, TYPE_VOLATILE (type), type); break; case DEMANGLE_COMPONENT_VOLATILE: - rtype = make_cv_type (TYPE_CONST (type), 1, type, NULL); + rtype = make_cv_type (TYPE_CONST (type), 1, type); break; } } diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c index afedd0f5008c..3ea82d56d212 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -393,8 +393,7 @@ python_xmethod_worker::do_get_arg_types (std::vector *arg_types) be a 'const' value. Hence, create a 'const' variant of the 'this' pointer type. */ obj_type = type_object_to_type (m_this_type); - (*arg_types)[0] = make_cv_type (1, 0, lookup_pointer_type (obj_type), - NULL); + (*arg_types)[0] = make_cv_type (1, 0, lookup_pointer_type (obj_type)); return EXT_LANG_RC_OK; } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 20dffbe8d206..5aae7ae63582 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1749,7 +1749,7 @@ rust_language::language_arch_info (struct gdbarch *gdbarch, add (init_float_type (alloc, 64, "f64", floatformats_ieee_double)); add (init_integer_type (alloc, 0, 1, "()")); - struct type *tem = make_cv_type (1, 0, u8_type, NULL); + struct type *tem = make_cv_type (1, 0, u8_type); add (rust_slice_type ("&str", tem, usize_type)); lai->set_bool_type (bool_type); diff --git a/gdb/type-stack.c b/gdb/type-stack.c index b9266b83f29e..2a08fc5f06dc 100644 --- a/gdb/type-stack.c +++ b/gdb/type-stack.c @@ -146,11 +146,11 @@ type_stack::follow_types (struct type *follow_type) if (make_const) follow_type = make_cv_type (make_const, TYPE_VOLATILE (follow_type), - follow_type, 0); + follow_type); if (make_volatile) follow_type = make_cv_type (TYPE_CONST (follow_type), make_volatile, - follow_type, 0); + follow_type); if (make_addr_space) follow_type = make_type_with_address_space (follow_type, make_addr_space); diff --git a/gdb/valops.c b/gdb/valops.c index 446c14ff0350..d58ff1133253 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3879,7 +3879,7 @@ value_rtti_indirect_type (struct value *v, int *full, /* Copy qualifiers to the referenced object. */ target_type = target->type (); real_type = make_cv_type (TYPE_CONST (target_type), - TYPE_VOLATILE (target_type), real_type, NULL); + TYPE_VOLATILE (target_type), real_type); if (TYPE_IS_REFERENCE (type)) real_type = lookup_reference_type (real_type, type->code ()); else if (type->code () == TYPE_CODE_PTR) @@ -3889,7 +3889,7 @@ value_rtti_indirect_type (struct value *v, int *full, /* Copy qualifiers to the pointer/reference. */ real_type = make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), - real_type, NULL); + real_type); } return real_type; diff --git a/gdb/value.c b/gdb/value.c index b7ca663d998e..93e928a7debc 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1600,8 +1600,8 @@ make_cv_value (int cnst, int voltl, struct value *v) struct type *m_enclosing_type = v->enclosing_type (); struct value *cv_val = v->copy (); - cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL)); - cv_val->set_enclosing_type (make_cv_type (cnst, voltl, m_enclosing_type, NULL)); + cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type)); + cv_val->set_enclosing_type (make_cv_type (cnst, voltl, m_enclosing_type)); return cv_val; } From patchwork Wed Dec 17 15:55:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 126712 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 75DF74BA2E39 for ; Wed, 17 Dec 2025 15:56:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75DF74BA2E39 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 21FB54BA2E21 for ; Wed, 17 Dec 2025 15:55:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 21FB54BA2E21 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 21FB54BA2E21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986957; cv=none; b=ABpCiVDGjbPp+Pnv1ff+7r8xB49qwRei6RY7YzA4tOVa2OHWZ5kZ0iUiiKuMdH3QE1A/8nMVZnvBYgqcA4IMabdpQ8pPvox8yzpcrXgE2pStcsC3OYpadyHBgpuv0J40POje9m6OIV5mL9Tf1nzID3PvWjHthLGpERJIu7kj91Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1765986957; c=relaxed/simple; bh=W4jIwjvMpqbv8mnUQVUPBcgj2liGg02bacyyimEwA4g=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=hH40PpXjjEBcw/8ClK3Mto1r87eG6YaoPsyu4CeJSK7J9QhDdK4OT2GIqhMwziHtMI5r3E0HhTXpWBEgDCxxRyiNhM1/5I+rsS/TIA0/6uwaRtg0gz1dBg3nPIjj8Zum4yO5u9esi0IMFQENwbA6tETn0iVIqz1AJhxgTyuSO1Q= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21FB54BA2E21 Received: by simark.ca (Postfix) id A28A61E0C3; Wed, 17 Dec 2025 10:55:56 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 7/7] gdb: remove smash_to_memberptr_type Date: Wed, 17 Dec 2025 10:55:01 -0500 Message-ID: <20251217155550.37654-8-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251217155550.37654-1-simon.marchi@efficios.com> References: <20251217155550.37654-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1165.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, LOCAL_AUTHENTICATION_FAIL_DMARC, LOCAL_AUTHENTICATION_FAIL_SPF, PROLO_LEO1, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org 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~patchwork=sourceware.org@sourceware.org From: Simon Marchi smash_to_memberptr_type is only used by lookup_memberptr_type, remove it and inline its code there. Change-Id: I8bc1b8da38f1124e231451aed183d957ea1c37af --- gdb/gdbtypes.c | 45 ++++++++++++--------------------------------- gdb/gdbtypes.h | 9 +++++---- 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f485dfbc8e14..c64fe2fbae99 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -751,18 +751,21 @@ replace_type (struct type *ntype, struct type *type) gdb_assert (ntype->instance_flags () == type->instance_flags ()); } -/* Implement direct support for MEMBER_TYPE in GNU C++. - May need to construct such a type if this is the first use. - The TYPE is the type of the member. The DOMAIN is the type - of the aggregate that the member belongs to. */ +/* See gdbtypes.h. */ -struct type * -lookup_memberptr_type (struct type *type, struct type *domain) +type * +lookup_memberptr_type (type *to_type, type *domain) { - struct type *mtype; + type *mtype = type_allocator (to_type).new_type (); + + mtype->set_code (TYPE_CODE_MEMBERPTR); + mtype->set_target_type (to_type); + set_type_self_type (mtype, domain); + + /* Assume that a data member pointer is the same size as a normal + pointer. */ + mtype->set_length (gdbarch_ptr_bit (to_type->arch ()) / TARGET_CHAR_BIT); - mtype = type_allocator (type).new_type (); - smash_to_memberptr_type (mtype, domain, type); return mtype; } @@ -1443,30 +1446,6 @@ set_type_self_type (struct type *type, struct type *self_type) } } -/* Smash TYPE to be a type of pointers to members of SELF_TYPE with type - TO_TYPE. A member pointer is a weird thing -- it amounts to a - typed offset into a struct, e.g. "an int at offset 8". A MEMBER - TYPE doesn't include the offset (that's the value of the MEMBER - itself), but does include the structure type into which it points - (for some reason). - - When "smashing" the type, we preserve the objfile that the old type - pointed to, since we aren't changing where the type is actually - allocated. */ - -void -smash_to_memberptr_type (struct type *type, struct type *self_type, - struct type *to_type) -{ - smash_type (type); - type->set_code (TYPE_CODE_MEMBERPTR); - type->set_target_type (to_type); - set_type_self_type (type, self_type); - /* Assume that a data member pointer is the same size as a normal - pointer. */ - type->set_length (gdbarch_ptr_bit (to_type->arch ()) / TARGET_CHAR_BIT); -} - /* Smash TYPE to be a type of pointer to methods type TO_TYPE. When "smashing" the type, we preserve the objfile that the old type diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 2ad8d1044336..f5e7de4d4664 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2462,7 +2462,11 @@ extern const char *address_space_type_instance_flags_to_name extern struct type *make_type_with_address_space (struct type *type, type_instance_flags space_identifier); -extern struct type *lookup_memberptr_type (struct type *, struct type *); +/* Implement direct support for MEMBER_TYPE in GNU C++. + TO_TYPE is the type of the member. DOMAIN is the type of the aggregate that + the member belongs to. */ + +extern type *lookup_memberptr_type (type *to_type, type *domain); extern struct type *lookup_methodptr_type (struct type *); @@ -2471,9 +2475,6 @@ extern void smash_to_method_type (struct type *type, struct type *self_type, gdb::array_view args, int varargs); -extern void smash_to_memberptr_type (struct type *, struct type *, - struct type *); - extern void smash_to_methodptr_type (struct type *, struct type *); extern const char *type_name_or_error (struct type *type);