From patchwork Sun Dec 8 18:29:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36611 Received: (qmail 102828 invoked by alias); 8 Dec 2019 18:31:01 -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 101192 invoked by uid 89); 8 Dec 2019 18:30:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 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: gateway36.websitewelcome.com Received: from gateway36.websitewelcome.com (HELO gateway36.websitewelcome.com) (192.185.187.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Dec 2019 18:30:13 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 936FA4023013F for ; Sun, 8 Dec 2019 11:40:21 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id e1JhiNEbMOdBHe1JhiXA3z; Sun, 08 Dec 2019 12:30:01 -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=QQsmiQpeZMq2BO1IbqMwUt33AM8kebFis4FyNg2Vk4c=; b=xJcem9Vtno99CucoNHnA++c5/1 lMTVu9+gOxTd0037QSzDNmi3bAyC5vZ5h1C9vm94MzNob/N4xK3kVzAItEgLovNvMVfcW0h8RnTbg BGeuw+Bssvd8Y21k8t5yv0546; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:53618 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1ie1Jh-00456j-0x; Sun, 08 Dec 2019 11:30:01 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 03/55] Introduce common_val_print_checked Date: Sun, 8 Dec 2019 11:29:06 -0700 Message-Id: <20191208182958.10181-4-tom@tromey.com> In-Reply-To: <20191208182958.10181-1-tom@tromey.com> References: <20191208182958.10181-1-tom@tromey.com> A (much) later patch will remove the call to value_check_printable from common_val_print. This will needed to preserve some details of how optimized-out structures are printed. However, doing this will also break dw2-op-out-param.exp. Making the change causes "bt" to print: However, the test wants to see: ... operand2= That is, a wholly-optimized out structure should not print its fields. So, this patch introduces a new common_val_print_checked, which calls value_check_printable first, and then arranges to use it in the one spot that affects the test suite. I was not completely sure if it would be preferable to change the test. However, I reasoned that, assuming this output was intentional in the first place, in a backtrace space is at a premium and so this is a reasonable approach. In other spots calling common_val_print, this behavior is probably unintended, or at least a "don't care". gdb/ChangeLog 2019-12-08 Tom Tromey * valprint.h (common_val_print_checked): Declare. * valprint.c (common_val_print_checked): New function. * stack.c (print_frame_arg): Use common_val_print_checked. Change-Id: I6802b6bf9b4aa30b399bb133e5c848b24ad16d7a --- gdb/ChangeLog | 6 ++++++ gdb/stack.c | 2 +- gdb/valprint.c | 13 +++++++++++++ gdb/valprint.h | 8 ++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gdb/stack.c b/gdb/stack.c index cc7b7e5bbe0..26229983f8b 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -486,7 +486,7 @@ print_frame_arg (const frame_print_options &fp_opts, vp_opts.summary = fp_opts.print_frame_arguments == print_frame_arguments_scalars; - common_val_print (arg->val, &stb, 2, &vp_opts, language); + common_val_print_checked (arg->val, &stb, 2, &vp_opts, language); } catch (const gdb_exception_error &except) { diff --git a/gdb/valprint.c b/gdb/valprint.c index 62c78b95ad2..20763338aff 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1210,6 +1210,19 @@ common_val_print (struct value *val, struct ui_file *stream, int recurse, val, options, language); } +/* See valprint.h. */ + +void +common_val_print_checked (struct value *val, struct ui_file *stream, + int recurse, + const struct value_print_options *options, + const struct language_defn *language) +{ + if (!value_check_printable (val, stream, options)) + return; + common_val_print (val, stream, recurse, options, language); +} + /* Print on stream STREAM the value VAL according to OPTIONS. The value is printed using the current_language syntax. */ diff --git a/gdb/valprint.h b/gdb/valprint.h index 24b731ab357..c63ac8de19b 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -282,4 +282,12 @@ extern bool val_print_check_max_depth (struct ui_file *stream, int recurse, const struct value_print_options *opts, const struct language_defn *language); +/* Like common_val_print, but call value_check_printable first. */ + +extern void common_val_print_checked + (struct value *val, + struct ui_file *stream, int recurse, + const struct value_print_options *options, + const struct language_defn *language); + #endif