From patchwork Sun Dec 8 18:29:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36610 Received: (qmail 102600 invoked by alias); 8 Dec 2019 18:30:47 -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 101216 invoked by uid 89); 8 Dec 2019 18:30:18 -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: gateway20.websitewelcome.com Received: from gateway20.websitewelcome.com (HELO gateway20.websitewelcome.com) (192.185.54.2) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Dec 2019 18:30:13 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway20.websitewelcome.com (Postfix) with ESMTP id CD951400C6471 for ; Sun, 8 Dec 2019 11:19:48 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id e1JjiZZ084kpje1Jji9UwO; 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=dCbibIdQX2mIwXD0m7yebywD7wxYI7nbf0CEW5jsq38=; b=gIp2vJMejpFd6r3eihMXyTocug 12pn7/nw0nwONiDuvB0Z5gfiTQ7Um4whU7puilL11nV3GR3qUCgBe+8l4TZAYSqlbl/ElJzeH8TaU K0OKhaB3/yTXzBc3bjvi9syQn; 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 1ie1Jj-0045Dk-0B; Sun, 08 Dec 2019 11:30:03 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 11/55] Introduce generic_value_print Date: Sun, 8 Dec 2019 11:29:14 -0700 Message-Id: <20191208182958.10181-12-tom@tromey.com> In-Reply-To: <20191208182958.10181-1-tom@tromey.com> References: <20191208182958.10181-1-tom@tromey.com> This introduces generic_value_print, which is a value-based analogue to generic_val_print. For now this is unused and simply calls generic_val_print, but subsequent patches will both change this function to work using the value API directly, and convert callers of generic_val_print to call this instead. gdb/ChangeLog 2019-12-08 Tom Tromey * valprint.h (generic_value_print): Declare. * valprint.c (generic_value_print): New function. Change-Id: I00b9ef91c1f3bf351b0e13e9873b849e80dfd944 --- gdb/ChangeLog | 5 +++++ gdb/valprint.c | 12 ++++++++++++ gdb/valprint.h | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/gdb/valprint.c b/gdb/valprint.c index d595a1d54e6..0e13e2b2d62 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1007,6 +1007,18 @@ generic_val_print (struct type *type, } } +/* See valprint.h. */ + +void +generic_value_print (struct value *val, struct ui_file *stream, int recurse, + const struct value_print_options *options, + const struct generic_val_print_decorations *decorations) +{ + generic_val_print (value_type (val), value_embedded_offset (val), + value_address (val), stream, recurse, val, options, + decorations); +} + /* Helper function for val_print and common_val_print that does the work. Arguments are as to val_print, but FULL_VALUE, if given, is the value to be printed. */ diff --git a/gdb/valprint.h b/gdb/valprint.h index c63ac8de19b..e4b90404fa2 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -211,6 +211,17 @@ extern void generic_val_print (struct type *type, const struct value_print_options *options, const struct generic_val_print_decorations *); +/* Print a value in a generic way. VAL is the value, STREAM is where + to print it, RECURSE is the recursion depth, OPTIONS describe how + the printing should be done, and D is the language-specific + decorations object. Note that structs and unions cannot be printed + by this function. */ + +extern void generic_value_print (struct value *val, struct ui_file *stream, + int recurse, + const struct value_print_options *options, + const struct generic_val_print_decorations *d); + extern void generic_emit_char (int c, struct type *type, struct ui_file *stream, int quoter, const char *encoding);