From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id A784C3857C50 for ; Tue, 18 Jan 2022 13:26:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A784C3857C50 X-IronPort-AV: E=McAfee;i="6200,9189,10230"; a="331163645" X-IronPort-AV: E=Sophos;i="5.88,297,1635231600"; d="scan'208";a="331163645" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 05:26:47 -0800 X-IronPort-AV: E=Sophos;i="5.88,297,1635231600"; d="scan'208";a="476976494" Received: from labpcdell3650-003.iul.intel.com (HELO localhost) ([172.28.49.87]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2022 05:26:46 -0800 From: Nils-Christian Kempke To: gdb-patches@sourceware.org Subject: [PATCH 1/2] gdb/types: Resolve dynamic properties of pointer types. Date: Tue, 18 Jan 2022 14:26:25 +0100 Message-Id: <20220118132626.3786176-2-nils-christian.kempke@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220118132626.3786176-1-nils-christian.kempke@intel.com> References: <20220118132626.3786176-1-nils-christian.kempke@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2022 13:26:50 -0000 Mark pointers with target type that is considered as a dynamic type as dynamic types themselves (on the outmost level). Resolve dynamic type pointers. Since ifx and ifort emit the DW_AT_associated for pointers we treat this as well when resolving dynamic pointers. This commit prepares the next one which will resolve dynamic target types of pointers when printing them enabling the print of e.g. array dimension when printing a pointer pointing to a dynamic array. --- gdb/gdbtypes.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 8af96c79e6..cd72a23c6f 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2077,8 +2077,10 @@ is_dynamic_type_internal (struct type *type, int top_level) { type = check_typedef (type); - /* We only want to recognize references at the outermost level. */ - if (top_level && type->code () == TYPE_CODE_REF) + /* We only want to recognize references and pointers at the outermost + level. */ + if (top_level && + (type->code () == TYPE_CODE_REF || type->code () == TYPE_CODE_PTR)) type = check_typedef (TYPE_TARGET_TYPE (type)); /* Types that have a dynamic TYPE_DATA_LOCATION are considered @@ -2664,6 +2666,25 @@ resolve_dynamic_struct (struct type *type, return resolved_type; } +/* Worker for pointer types. */ + +static struct type * +resolve_dynamic_pointer (struct type *type, + struct property_addr_info *addr_stack) +{ + struct dynamic_prop *prop; + CORE_ADDR value; + + type = copy_type (type); + + /* Resolve associated property. */ + prop = TYPE_ASSOCIATED_PROP (type); + if (prop != NULL && dwarf2_evaluate_property (prop, NULL, addr_stack, &value)) + prop->set_const_val (value); + + return type; +} + /* Worker for resolved_dynamic_type. */ static struct type * @@ -2719,6 +2740,10 @@ resolve_dynamic_type_internal (struct type *type, break; } + case TYPE_CODE_PTR: + resolved_type = resolve_dynamic_pointer (type, addr_stack); + break; + case TYPE_CODE_STRING: /* Strings are very much like an array of characters, and can be treated as one here. */ -- 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928