From patchwork Wed Sep 10 09:21:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keven Boell X-Patchwork-Id: 2740 Received: (qmail 32380 invoked by alias); 10 Sep 2014 09:22:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 31492 invoked by uid 89); 10 Sep 2014 09:22:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga01.intel.com Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 10 Sep 2014 09:22:25 +0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 10 Sep 2014 02:22:18 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 10 Sep 2014 02:17:09 -0700 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [172.28.50.14]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s8A9MBX2008354; Wed, 10 Sep 2014 10:22:11 +0100 Received: from ullecvh004g04.iul.intel.com (ullecvh004g04.iul.intel.com [127.0.0.1]) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8) with ESMTP id s8A9MFcn020716; Wed, 10 Sep 2014 11:22:15 +0200 Received: (from kboell@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s8A9MFL7020715; Wed, 10 Sep 2014 11:22:15 +0200 From: Keven Boell To: gdb-patches@sourceware.org Cc: sanimir.agovic@intel.com, Keven Boell Subject: [V3 08/21] vla: get Fortran dynamic strings working. Date: Wed, 10 Sep 2014 11:21:56 +0200 Message-Id: <1410340929-20653-9-git-send-email-keven.boell@intel.com> In-Reply-To: <1410340929-20653-1-git-send-email-keven.boell@intel.com> References: <1410340929-20653-1-git-send-email-keven.boell@intel.com> This patch enables the correct calculation of dynamic string length. Old: (gdb) p my_dyn_string $1 = (PTR TO -> ( character*23959136 )) 0x605fc0 (gdb) p *my_dyn_string Cannot access memory at address 0x605fc0 New: (gdb) p my_dyn_string $1 = (PTR TO -> ( character*10 )) 0x605fc0 (gdb) p *my_dyn_string $2 = 'foo' 2014-05-28 Keven Boell Sanimir Agovic * gdbtypes.c (resolve_dynamic_type): Add conditions to support string types. (resolve_dynamic_array): Add conditions for dynamic strings and create a new string type. (is_dynamic_type): Follow pointer if a string type was detected, as Fortran strings are represented as pointers to strings internally. --- gdb/gdbtypes.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 9653c6f..29c1dbd 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1677,6 +1677,17 @@ is_dynamic_type_internal (struct type *type, int top_level) && is_dynamic_type_internal (TYPE_FIELD_TYPE (type, i), 0)) return 1; } + case TYPE_CODE_PTR: + { + if (TYPE_TARGET_TYPE (type) + && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRING) + return is_dynamic_type (check_typedef (TYPE_TARGET_TYPE (type))); + + return 0; + break; + } + default: + return 0; break; } @@ -1759,7 +1770,8 @@ resolve_dynamic_array (struct type *type, CORE_ADDR addr) struct dynamic_prop *prop; struct type *copy = copy_type (type); - gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY); + gdb_assert (TYPE_CODE (type) == TYPE_CODE_ARRAY + || TYPE_CODE (type) == TYPE_CODE_STRING); elt_type = type; range_type = check_typedef (TYPE_INDEX_TYPE (elt_type)); @@ -1781,14 +1793,20 @@ resolve_dynamic_array (struct type *type, CORE_ADDR addr) ary_dim = check_typedef (TYPE_TARGET_TYPE (elt_type)); - if (ary_dim != NULL && TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY) + if (ary_dim != NULL && (TYPE_CODE (ary_dim) == TYPE_CODE_ARRAY + || TYPE_CODE (ary_dim) == TYPE_CODE_STRING)) elt_type = resolve_dynamic_array (TYPE_TARGET_TYPE (copy), addr); else elt_type = TYPE_TARGET_TYPE (type); - return create_array_type (copy, - elt_type, - range_type); + if (TYPE_CODE (type) == TYPE_CODE_STRING) + return create_string_type (copy, + elt_type, + range_type); + else + return create_array_type (copy, + elt_type, + range_type); } /* Resolve dynamic bounds of members of the union TYPE to static @@ -1927,6 +1945,7 @@ resolve_dynamic_type_internal (struct type *type, CORE_ADDR addr, } case TYPE_CODE_ARRAY: + case TYPE_CODE_STRING: resolved_type = resolve_dynamic_array (type, addr); break;