From patchwork Sun Dec 8 18:29:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36612 Received: (qmail 102906 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 101282 invoked by uid 89); 8 Dec 2019 18:30:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 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=Doesnt, Doesn't, differ X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.87) 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 gateway33.websitewelcome.com (Postfix) with ESMTP id D08C43F6CAB for ; Sun, 8 Dec 2019 12:30:06 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id e1JmiNEm1OdBHe1JmiXAEW; Sun, 08 Dec 2019 12:30:06 -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=ae8vX3gY4tu2ejKDzBwLAVndTxkcktxIfT0B0qD20xQ=; b=OKS9O5oEkF4B0VqCPGvrk13Pcy IiToXdlAA64ve3sGxcZ1V3crIfIdxJ9Xv8+Hqatfiw8jlHaElcmOLB5hyIcVy31f2c3yVtoJnAjvA zvHLzwaH7RhUF9z2Zu1FgW5sM; 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 1ie1Jm-0045GG-Lx; Sun, 08 Dec 2019 11:30:06 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 29/55] Initial rewrite of generic_value_print Date: Sun, 8 Dec 2019 11:29:32 -0700 Message-Id: <20191208182958.10181-30-tom@tromey.com> In-Reply-To: <20191208182958.10181-1-tom@tromey.com> References: <20191208182958.10181-1-tom@tromey.com> This rewrites generic_value_print, by copying in the body of generic_val_print and making the needed adjustments. gdb/ChangeLog 2019-12-08 Tom Tromey * valprint.c (generic_value_print): Rewrite. Change-Id: I4bef96d94afee1ff4673f995d0306e059863a03d --- gdb/ChangeLog | 4 ++ gdb/valprint.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 106 insertions(+), 3 deletions(-) diff --git a/gdb/valprint.c b/gdb/valprint.c index b2506dc6fc4..562a2acdda1 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -1014,9 +1014,108 @@ 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); + struct type *type = value_type (val); + struct type *unresolved_type = type; + + type = check_typedef (type); + switch (TYPE_CODE (type)) + { + case TYPE_CODE_ARRAY: + generic_val_print_array (type, 0, value_address (val), stream, + recurse, val, options, decorations); + break; + + case TYPE_CODE_MEMBERPTR: + generic_val_print_memberptr (type, 0, stream, + val, options); + break; + + case TYPE_CODE_PTR: + generic_val_print_ptr (type, 0, stream, + val, options); + break; + + case TYPE_CODE_REF: + case TYPE_CODE_RVALUE_REF: + generic_val_print_ref (type, 0, stream, recurse, + val, options); + break; + + case TYPE_CODE_ENUM: + generic_val_print_enum (type, 0, stream, + val, options); + break; + + case TYPE_CODE_FLAGS: + generic_val_print_flags (type, 0, stream, + val, options); + break; + + case TYPE_CODE_FUNC: + case TYPE_CODE_METHOD: + generic_val_print_func (type, 0, value_address (val), stream, + val, options); + break; + + case TYPE_CODE_BOOL: + generic_val_print_bool (type, 0, stream, + val, options, decorations); + break; + + case TYPE_CODE_RANGE: + /* FIXME: create_static_range_type does not set the unsigned bit in a + range type (I think it probably should copy it from the + target type), so we won't print values which are too large to + fit in a signed integer correctly. */ + /* FIXME: Doesn't handle ranges of enums correctly. (Can't just + print with the target type, though, because the size of our + type and the target type might differ). */ + + /* FALLTHROUGH */ + + case TYPE_CODE_INT: + generic_val_print_int (type, 0, stream, + val, options); + break; + + case TYPE_CODE_CHAR: + generic_val_print_char (type, unresolved_type, 0, + stream, val, options); + break; + + case TYPE_CODE_FLT: + case TYPE_CODE_DECFLOAT: + generic_val_print_float (type, 0, stream, + val, options); + break; + + case TYPE_CODE_VOID: + fputs_filtered (decorations->void_name, stream); + break; + + case TYPE_CODE_ERROR: + fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); + break; + + case TYPE_CODE_UNDEF: + /* This happens (without TYPE_STUB set) on systems which don't use + dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" + and no complete type for struct foo in that file. */ + fprintf_styled (stream, metadata_style.style (), _("")); + break; + + case TYPE_CODE_COMPLEX: + generic_val_print_complex (type, 0, stream, + val, options, decorations); + break; + + case TYPE_CODE_UNION: + case TYPE_CODE_STRUCT: + case TYPE_CODE_METHODPTR: + default: + error (_("Unhandled type code %d in symbol table."), + TYPE_CODE (type)); + } } /* Helper function for val_print and common_val_print that does the