From patchwork Fri Jul 11 09:21:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keven Boell X-Patchwork-Id: 2014 Received: (qmail 29697 invoked by alias); 11 Jul 2014 09:21:47 -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 29559 invoked by uid 89); 11 Jul 2014 09:21:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga11.intel.com Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Jul 2014 09:21:44 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 11 Jul 2014 02:21:44 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 11 Jul 2014 02:21:43 -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 s6B9LgCD020733; Fri, 11 Jul 2014 10:21:42 +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 s6B9LhnN007033; Fri, 11 Jul 2014 11:21:43 +0200 Received: (from kboell@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s6B9Lh8L007032; Fri, 11 Jul 2014 11:21:43 +0200 From: Keven Boell To: gdb-patches@sourceware.org Cc: keven.boell@intel.com, sanimir.agovic@intel.com Subject: [V2 10/23] vla: get Fortran dynamic strings working. Date: Fri, 11 Jul 2014 11:21:22 +0200 Message-Id: <1405070495-6948-11-git-send-email-keven.boell@intel.com> In-Reply-To: <1405070495-6948-1-git-send-email-keven.boell@intel.com> References: <1405070495-6948-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. Change-Id: I7d54d762a081ce034be37ac3e368bac8111dc4e6 Signed-off-by: Keven Boell --- gdb/gdbtypes.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index c7c5c3b..da773f6 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1675,6 +1675,17 @@ is_dynamic_type (struct type *type) && is_dynamic_type (TYPE_FIELD_TYPE (type, i))) 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; } @@ -1745,7 +1756,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)); @@ -1767,14 +1779,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 @@ -1901,6 +1919,7 @@ resolve_dynamic_type (struct type *type, CORE_ADDR addr) } case TYPE_CODE_ARRAY: + case TYPE_CODE_STRING: resolved_type = resolve_dynamic_array (type, addr); break;