From patchwork Tue Apr 21 15:44:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 6342 Received: (qmail 41567 invoked by alias); 21 Apr 2015 15:44:37 -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 41473 invoked by uid 89); 21 Apr 2015 15:44:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD 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; Tue, 21 Apr 2015 15:44:35 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 6307E11653B for ; Tue, 21 Apr 2015 11:44:33 -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 mhMTqBGXc0gl for ; Tue, 21 Apr 2015 11:44:33 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 35D6211648E for ; Tue, 21 Apr 2015 11:44:33 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 4361C40EAD; Tue, 21 Apr 2015 08:44:33 -0700 (PDT) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [FYI 3/6] [Ada] Resolve dynamic type before trying to print it. Date: Tue, 21 Apr 2015 08:44:21 -0700 Message-Id: <1429631064-4196-4-git-send-email-brobecker@adacore.com> In-Reply-To: <1429631064-4196-1-git-send-email-brobecker@adacore.com> References: <1429631064-4196-1-git-send-email-brobecker@adacore.com> This is another required step towards trying to print the value of an array of variant records. For instance: A1 : Array_Type := (1 => (I => 0, S => <>), 2 => (I => 1, S => "A"), 3 => (I => 2, S => "AB")); ... where Array_Type is an array of records whose size is variable: subtype Small_Type is Integer range 0 .. 10; type Record_Type (I : Small_Type := 0) is record S : String (1 .. I); end record; type Array_Type is array (Integer range <>) of Record_Type; What happens is that the ada-valprint modules gets passed an array whose element type is not resolved yet (since each element of the array needs to be resolved separately). the module then recurses, and eventually gets called with the first element of the array. But because the element hasn't been resolved yet, we end up having trouble printing its value soon after. This patch fixes the issue by calling resolve_dynamic_type before trying to print it. With this patch, GDB is finally able to print the complete value for variable "A1": (gdb) p a1 $1 = ((i => 0, s => ""), (i => 1, s => "A"), (i => 2, s => "AB")) gdb/ChangeLog: * ada-valprint.c (ada_val_print_1): Resolve TYPE before trying to print it. --- gdb/ada-valprint.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 34539de..720854e 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -1095,6 +1095,8 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr, offset_aligned = offset + ada_aligned_value_addr (type, valaddr) - valaddr; type = printable_val_type (type, valaddr + offset_aligned); + type = resolve_dynamic_type (type, valaddr + offset_aligned, + address + offset_aligned); switch (TYPE_CODE (type)) {