From patchwork Mon Aug 18 17:38:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 2422 Received: (qmail 17638 invoked by alias); 18 Aug 2014 17:38:50 -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 17554 invoked by uid 89); 18 Aug 2014 17:38:50 -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, SPF_PASS autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 18 Aug 2014 17:38:48 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 3D2D111632B for ; Mon, 18 Aug 2014 13:38:46 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id qIPds8-OfWnx for ; Mon, 18 Aug 2014 13:38:46 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 128921162A9 for ; Mon, 18 Aug 2014 13:38:46 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 0660B410E6; Mon, 18 Aug 2014 19:38:45 +0200 (CEST) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [pushed 3/4] [Ada] "ptype" of array where bound value uses DW_OP_push_object_address Date: Mon, 18 Aug 2014 19:38:36 +0200 Message-Id: <1408383517-29205-4-git-send-email-brobecker@adacore.com> In-Reply-To: <1408383517-29205-1-git-send-email-brobecker@adacore.com> References: <1408383517-29205-1-git-send-email-brobecker@adacore.com> Consider an Ada array type where the DWARF debugging info for at least one of the bounds involves an expression containing a DW_OP_push_object_address operation. Trying to "ptype" that type currently yields: (gdb) ptype foo.array_type type = array (Location address is not set. This patch improves ada-typeprint by adding handling of the situation where an array range type has dynamic bounds. In that case, it prints the array bounds using Ada's typical syntax for unbounded ranges "<>": (gdb) ptype array_type type = array (<>) of integer gdb/ChangeLog: * ada-typeprint.c (type_is_full_subrange_of_target_type): Return 0 if TYPE is dynamic. (print_range): Add handling of dynamic ranges. --- gdb/ChangeLog | 6 ++++++ gdb/ada-typeprint.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1d35ac3..c14fd5c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2014-08-18 Joel Brobecker + + * ada-typeprint.c (type_is_full_subrange_of_target_type): + Return 0 if TYPE is dynamic. + (print_range): Add handling of dynamic ranges. + 2014-08-18 Keven Boell Joel Brobecker diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 305e39c..57c8d93 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -115,6 +115,9 @@ type_is_full_subrange_of_target_type (struct type *type) if (subtype == NULL) return 0; + if (is_dynamic_type (type)) + return 0; + if (ada_discrete_type_low_bound (type) != ada_discrete_type_low_bound (subtype)) return 0; @@ -156,15 +159,33 @@ print_range (struct type *type, struct ui_file *stream, case TYPE_CODE_ENUM: { struct type *target_type; + volatile struct gdb_exception e; + LONGEST lo, hi; target_type = TYPE_TARGET_TYPE (type); if (target_type == NULL) target_type = type; - ada_print_scalar (target_type, ada_discrete_type_low_bound (type), - stream); - fprintf_filtered (stream, " .. "); - ada_print_scalar (target_type, ada_discrete_type_high_bound (type), - stream); + + TRY_CATCH (e, RETURN_MASK_ERROR) + { + lo = ada_discrete_type_low_bound (type); + hi = ada_discrete_type_high_bound (type); + } + if (e.reason < 0) + { + /* This can happen when the range is dynamic. Sometimes, + resolving dynamic property values requires us to have + access to an actual object, which is not available + when the user is using the "ptype" command on a type. + Print the range as an unbounded range. */ + fprintf_filtered (stream, "<>"); + } + else + { + ada_print_scalar (target_type, lo, stream); + fprintf_filtered (stream, " .. "); + ada_print_scalar (target_type, hi, stream); + } } break; default: