From patchwork Sun Dec 8 18:29:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36604 Received: (qmail 101674 invoked by alias); 8 Dec 2019 18:30:26 -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 101242 invoked by uid 89); 8 Dec 2019 18:30:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: gateway34.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway34.websitewelcome.com) (192.185.150.114) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Dec 2019 18:30:13 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway34.websitewelcome.com (Postfix) with ESMTP id E3F902EFBC for ; Sun, 8 Dec 2019 12:30:05 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id e1JlipQrQqNtve1JliYrUg; Sun, 08 Dec 2019 12:30:05 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=pZs3GyRjwnFz4WK7k/mPw9GQGfiyN4PptspSNRy+K98=; b=RNVSkn0941Jh31RfVViOVtyz8+ fwnCUif/X79618h684QLNqI4cGhYhxRnDEG62qjB2w9yb1MEgGCPENfmLEaseU5T7MzjNRXboMppn Hb3vg9bOtF5mwBw+RZl/2fvgg; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:53622 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1ie1Jl-0045GG-OY; Sun, 08 Dec 2019 11:30:05 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 24/55] Convert D printing to value-based API Date: Sun, 8 Dec 2019 11:29:27 -0700 Message-Id: <20191208182958.10181-25-tom@tromey.com> In-Reply-To: <20191208182958.10181-1-tom@tromey.com> References: <20191208182958.10181-1-tom@tromey.com> As with Rust and Go, it was straightforward to convert D to the value-based API directly. gdb/ChangeLog 2019-12-08 Tom Tromey * d-valprint.c (dynamic_array_type): Call d_value_print_inner. (d_value_print_inner): New function. * d-lang.h (d_value_print_inner): Declare. * d-lang.c (d_language_defn): Use d_value_print_inner. Change-Id: I9f9fefdf804f3fba17452ec55ef1d05bbcf03c92 --- gdb/ChangeLog | 7 +++++++ gdb/d-lang.c | 2 +- gdb/d-lang.h | 6 ++++++ gdb/d-valprint.c | 28 +++++++++++++++++++++++++--- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/gdb/d-lang.c b/gdb/d-lang.c index 5ce2314ae14..ce4324c3f86 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -225,7 +225,7 @@ extern const struct language_defn d_language_defn = c_print_typedef, /* Print a typedef using appropriate syntax. */ d_val_print, /* Print a value using appropriate syntax. */ - nullptr, /* la_value_print_inner */ + d_value_print_inner, /* la_value_print_inner */ c_value_print, /* Print a top-level value. */ default_read_var_value, /* la_read_var_value */ NULL, /* Language specific skip_trampoline. */ diff --git a/gdb/d-lang.h b/gdb/d-lang.h index 956c1923a69..51d3f17aa51 100644 --- a/gdb/d-lang.h +++ b/gdb/d-lang.h @@ -84,4 +84,10 @@ extern void d_val_print (struct type *type, struct value *val, const struct value_print_options *options); +/* Implement la_value_print_inner for D. */ + +extern void d_value_print_inner (struct value *val, + struct ui_file *stream, int recurse, + const struct value_print_options *options); + #endif /* !defined (D_LANG_H) */ diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index 54652364a8f..5dbaf700eeb 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -63,9 +63,7 @@ dynamic_array_type (struct type *type, ival = value_at (true_type, addr); true_type = value_type (ival); - d_val_print (true_type, - value_embedded_offset (ival), addr, - stream, recurse + 1, ival, options); + d_value_print_inner (ival, stream, recurse + 1, options); return 0; } return 1; @@ -94,3 +92,27 @@ d_val_print (struct type *type, int embedded_offset, recurse, val, options); } } + +/* See d-lang.h. */ + +void +d_value_print_inner (struct value *val, struct ui_file *stream, int recurse, + const struct value_print_options *options) +{ + int ret; + + struct type *type = check_typedef (value_type (val)); + switch (TYPE_CODE (type)) + { + case TYPE_CODE_STRUCT: + ret = dynamic_array_type (type, value_embedded_offset (val), + value_address (val), + stream, recurse, val, options); + if (ret == 0) + break; + /* Fall through. */ + default: + c_value_print_inner (val, stream, recurse, options); + break; + } +}