From patchwork Sun Dec 8 18:29:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36597 Received: (qmail 101458 invoked by alias); 8 Dec 2019 18:30:25 -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 101217 invoked by uid 89); 8 Dec 2019 18:30:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.4 required=5.0 tests=AWL, BAYES_00, FORGED_SPF_HELO, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=sk:3289a8e, 21467 X-HELO: gateway22.websitewelcome.com Received: from gateway34.websitewelcome.com (HELO gateway22.websitewelcome.com) (192.185.46.126) 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 gateway22.websitewelcome.com (Postfix) with ESMTP id 0415647A0 for ; Sun, 8 Dec 2019 12:30:03 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id e1JiipQjOqNtve1JiiYrMf; Sun, 08 Dec 2019 12:30:03 -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=+A2wtkyJaMvKXWoGNzJDq0bMuyrr2dEW083DbGIMbZ8=; b=gR2xy4e6LZAXoXemk3eQfeHYXz 54vKZspyyMweNm1OHcSdnvWYd33uAEpqlI/DnFZsqM944Yh5IhRMFn1S8aVCpPliwx7LtrGlRteO9 VAsd3gsHSVZ+08GKwYlnCwThb; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:53620 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1ie1Ji-0045Dk-QK; Sun, 08 Dec 2019 11:30:02 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 10/55] Introduce la_value_print_inner Date: Sun, 8 Dec 2019 11:29:13 -0700 Message-Id: <20191208182958.10181-11-tom@tromey.com> In-Reply-To: <20191208182958.10181-1-tom@tromey.com> References: <20191208182958.10181-1-tom@tromey.com> The plan for removing val_print is, essentially, to first duplicate printing code as needed to use the value API; and then remove the val_print code. This makes it possible to do the changes incrementally while keeping everything working. This adds a new la_value_print_inner function pointer to struct language_defn. Eventually this will replace la_val_print. This patch also changes printing to prefer this API, when available -- but no language defines it yet. gdb/ChangeLog 2019-12-08 Tom Tromey * valprint.c (do_val_print): Call la_value_print_inner, if available. * rust-lang.c (rust_language_defn): Update. * p-lang.c (pascal_language_defn): Update. * opencl-lang.c (opencl_language_defn): Update. * objc-lang.c (objc_language_defn): Update. * m2-lang.c (m2_language_defn): Update. * language.h (struct language_defn) : New member. * language.c (unknown_language_defn, auto_language_defn): Update. * go-lang.c (go_language_defn): Update. * f-lang.c (f_language_defn): Update. * d-lang.c (d_language_defn): Update. * c-lang.c (c_language_defn, cplus_language_defn) (asm_language_defn, minimal_language_defn): Update. * ada-lang.c (ada_language_defn): Update. Change-Id: I63727fa194511c3d7297db62efe23f8a503ba770 --- gdb/ChangeLog | 19 +++++++++++++++++++ gdb/ada-lang.c | 1 + gdb/c-lang.c | 4 ++++ gdb/d-lang.c | 1 + gdb/f-lang.c | 1 + gdb/go-lang.c | 1 + gdb/language.c | 2 ++ gdb/language.h | 7 +++++++ gdb/m2-lang.c | 1 + gdb/objc-lang.c | 1 + gdb/opencl-lang.c | 1 + gdb/p-lang.c | 1 + gdb/rust-lang.c | 1 + gdb/valprint.c | 10 +++++++--- 14 files changed, 48 insertions(+), 3 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 3289a8e5c8e..eeccfae69ac 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -14114,6 +14114,7 @@ extern const struct language_defn ada_language_defn = { ada_print_type, /* Print a type using appropriate syntax */ ada_print_typedef, /* Print a typedef using appropriate syntax */ ada_val_print, /* Print a value using appropriate syntax */ + nullptr, /* la_value_print_inner */ ada_value_print, /* Print a top-level value */ ada_read_var_value, /* la_read_var_value */ NULL, /* Language specific skip_trampoline */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 846970af7b9..24c2eef747a 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -904,6 +904,7 @@ extern const struct language_defn c_language_defn = c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ c_val_print, /* Print a value using appropriate syntax */ + nullptr, /* 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 */ @@ -1049,6 +1050,7 @@ extern const struct language_defn cplus_language_defn = c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ c_val_print, /* Print a value using appropriate syntax */ + nullptr, /* la_value_print_inner */ c_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ cplus_skip_trampoline, /* Language specific skip_trampoline */ @@ -1103,6 +1105,7 @@ extern const struct language_defn asm_language_defn = c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ c_val_print, /* Print a value using appropriate syntax */ + nullptr, /* 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 */ @@ -1157,6 +1160,7 @@ extern const struct language_defn minimal_language_defn = c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ c_val_print, /* Print a value using appropriate syntax */ + nullptr, /* 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.c b/gdb/d-lang.c index 1701976da78..5ce2314ae14 100644 --- a/gdb/d-lang.c +++ b/gdb/d-lang.c @@ -225,6 +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 */ 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/f-lang.c b/gdb/f-lang.c index 022918efa2d..b8a684e5cf5 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -647,6 +647,7 @@ extern const struct language_defn f_language_defn = f_print_type, /* Print a type using appropriate syntax */ f_print_typedef, /* Print a typedef using appropriate syntax */ f_val_print, /* Print a value using appropriate syntax */ + nullptr, /* la_value_print_inner */ c_value_print, /* FIXME */ default_read_var_value, /* la_read_var_value */ NULL, /* Language specific skip_trampoline */ diff --git a/gdb/go-lang.c b/gdb/go-lang.c index bf2eb1b6f71..38eb0d74836 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -596,6 +596,7 @@ extern const struct language_defn go_language_defn = c_print_typedef, /* Print a typedef using appropriate syntax. */ go_val_print, /* Print a value using appropriate syntax. */ + nullptr, /* 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/language.c b/gdb/language.c index 6ab0ca323d2..00b301e46e2 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -858,6 +858,7 @@ const struct language_defn unknown_language_defn = unk_lang_print_type, /* Print a type using appropriate syntax */ default_print_typedef, /* Print a typedef using appropriate syntax */ unk_lang_val_print, /* Print a value using appropriate syntax */ + nullptr, /* la_value_print_inner */ unk_lang_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ unk_lang_trampoline, /* Language specific skip_trampoline */ @@ -909,6 +910,7 @@ const struct language_defn auto_language_defn = unk_lang_print_type, /* Print a type using appropriate syntax */ default_print_typedef, /* Print a typedef using appropriate syntax */ unk_lang_val_print, /* Print a value using appropriate syntax */ + nullptr, /* la_value_print_inner */ unk_lang_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ unk_lang_trampoline, /* Language specific skip_trampoline */ diff --git a/gdb/language.h b/gdb/language.h index 5fc25a235ff..89cd71c5055 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -231,6 +231,13 @@ struct language_defn struct value *val, const struct value_print_options *options); + /* Print a value using syntax appropriate for this language. + RECURSE is the recursion depth. It is zero-based. */ + + void (*la_value_print_inner) (struct value *, struct ui_file *, + int recurse, + const struct value_print_options *); + /* Print a top-level value using syntax appropriate for this language. */ void (*la_value_print) (struct value *, struct ui_file *, diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 2d2dfe31018..924ee0a549c 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -394,6 +394,7 @@ extern const struct language_defn m2_language_defn = m2_print_type, /* Print a type using appropriate syntax */ m2_print_typedef, /* Print a typedef using appropriate syntax */ m2_val_print, /* Print a value using appropriate syntax */ + nullptr, /* 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/objc-lang.c b/gdb/objc-lang.c index e2a6e800b55..e6cb42e60a2 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -382,6 +382,7 @@ extern const struct language_defn objc_language_defn = { c_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ c_val_print, /* Print a value using appropriate syntax */ + nullptr, /* la_value_print_inner */ c_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ objc_skip_trampoline, /* Language specific skip_trampoline */ diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c index 5d03210b569..8ebb35b9e62 100644 --- a/gdb/opencl-lang.c +++ b/gdb/opencl-lang.c @@ -1061,6 +1061,7 @@ extern const struct language_defn opencl_language_defn = opencl_print_type, /* Print a type using appropriate syntax */ c_print_typedef, /* Print a typedef using appropriate syntax */ c_val_print, /* Print a value using appropriate syntax */ + nullptr, /* 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/p-lang.c b/gdb/p-lang.c index 33cb6e635d8..3229c3e9c9f 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -448,6 +448,7 @@ extern const struct language_defn pascal_language_defn = pascal_print_type, /* Print a type using appropriate syntax */ pascal_print_typedef, /* Print a typedef using appropriate syntax */ pascal_val_print, /* Print a value using appropriate syntax */ + nullptr, /* la_value_print_inner */ pascal_value_print, /* Print a top-level value */ default_read_var_value, /* la_read_var_value */ NULL, /* Language specific skip_trampoline */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index f9adb5d07cc..bacd351ef6c 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -2146,6 +2146,7 @@ extern const struct language_defn rust_language_defn = rust_print_type, /* Print a type using appropriate syntax */ rust_print_typedef, /* Print a typedef using appropriate syntax */ rust_val_print, /* Print a value using appropriate syntax */ + nullptr, /* 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/valprint.c b/gdb/valprint.c index 20763338aff..d595a1d54e6 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1066,9 +1066,13 @@ do_val_print (struct value *full_value, try { - language->la_val_print (type, embedded_offset, address, - stream, recurse, val, - &local_opts); + if (full_value != nullptr && language->la_value_print_inner != nullptr) + language->la_value_print_inner (full_value, stream, recurse, + &local_opts); + else + language->la_val_print (type, embedded_offset, address, + stream, recurse, val, + &local_opts); } catch (const gdb_exception_error &except) {