From patchwork Wed Jun 4 05:54:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keven Boell X-Patchwork-Id: 1285 Received: (qmail 27711 invoked by alias); 4 Jun 2014 05:54:42 -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 27360 invoked by uid 89); 4 Jun 2014 05:54:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mga02.intel.com Received: from mga02.intel.com (HELO mga02.intel.com) (134.134.136.20) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Jun 2014 05:54:37 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 03 Jun 2014 22:54:37 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 03 Jun 2014 22:54:36 -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 s545sZc8020276; Wed, 4 Jun 2014 06:54:35 +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 s545sYpe006311; Wed, 4 Jun 2014 07:54:34 +0200 Received: (from kboell@localhost) by ullecvh004g04.iul.intel.com (8.13.8/8.13.8/Submit) id s545sYRZ006310; Wed, 4 Jun 2014 07:54:34 +0200 From: Keven Boell To: gdb-patches@sourceware.org Cc: sanimir.agovic@intel.com, keven.boell@intel.com Subject: [PATCH 10/23] vla: get Fortran dynamic strings working. Date: Wed, 4 Jun 2014 07:54:13 +0200 Message-Id: <1401861266-6240-11-git-send-email-keven.boell@intel.com> In-Reply-To: <1401861266-6240-1-git-send-email-keven.boell@intel.com> References: <1401861266-6240-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 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 79cd1be..5aa6582 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1663,6 +1663,15 @@ is_dynamic_type (struct type *type) return is_dynamic_type (TYPE_TARGET_TYPE (type)); break; } + 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; @@ -1730,7 +1739,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)); @@ -1757,9 +1767,14 @@ resolve_dynamic_array (struct type *type, CORE_ADDR 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); } /* Resolves dynamic compound types, e.g. STRUCTS's to static ones. @@ -1855,6 +1870,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;