From patchwork Sun Dec 8 18:29:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36621 Received: (qmail 104597 invoked by alias); 8 Dec 2019 18:31:11 -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 101783 invoked by uid 89); 8 Dec 2019 18:30:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 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: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.51.31) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Dec 2019 18:30:22 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 4D1651D0B for ; Sun, 8 Dec 2019 12:30:10 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id e1JqiQt0W3Qi0e1JqifI9F; Sun, 08 Dec 2019 12:30:10 -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=8E459FYJiNC54+0C5U7vqzLEDz4RUFZBm4/iBWNWkNs=; b=lotKolGTA/sUkbCJWVdjPgkpMz xVf4jdQM3LcKdGRSImtdROJ2Hp5raQ/WGKshThgFR8DxghRl+thSESvrY16c4tZifYS4kDIV24eZq D3wNKwWOQ6gbMxvvwG6NJ1mli; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:53626 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1ie1Jq-0045L6-48; Sun, 08 Dec 2019 11:30:10 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 40/55] Introduce c_value_print_ptr Date: Sun, 8 Dec 2019 11:29:43 -0700 Message-Id: <20191208182958.10181-41-tom@tromey.com> In-Reply-To: <20191208182958.10181-1-tom@tromey.com> References: <20191208182958.10181-1-tom@tromey.com> This adds c_value_print_ptr, a value-based analogue of c_val_print_ptr. gdb/ChangeLog 2019-12-08 Tom Tromey * c-valprint.c (c_value_print_ptr): New function. (c_value_print_inner): Use it. Change-Id: Iba7917a57d5d67c51a76014c4bcb82c0353f6453 --- gdb/ChangeLog | 5 +++++ gdb/c-valprint.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index af7a386fb78..f50c49abbfd 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -375,6 +375,43 @@ c_val_print_ptr (struct type *type, const gdb_byte *valaddr, } } +/* c_val_print helper for TYPE_CODE_PTR. */ + +static void +c_value_print_ptr (struct value*val, struct ui_file *stream, int recurse, + const struct value_print_options *options) +{ + if (options->format && options->format != 's') + { + value_print_scalar_formatted (val, options, 0, stream); + return; + } + + struct type *type = check_typedef (value_type (val)); + struct gdbarch *arch = get_type_arch (type); + const gdb_byte *valaddr = value_contents_for_printing (val); + + if (options->vtblprint && cp_is_vtbl_ptr_type (type)) + { + /* Print the unmangled name if desired. */ + /* Print vtable entry - we only get here if we ARE using + -fvtable_thunks. (Otherwise, look under + TYPE_CODE_STRUCT.) */ + CORE_ADDR addr = extract_typed_address (valaddr, type); + + print_function_pointer_address (options, arch, addr, stream); + } + else + { + struct type *unresolved_elttype = TYPE_TARGET_TYPE (type); + struct type *elttype = check_typedef (unresolved_elttype); + CORE_ADDR addr = unpack_pointer (type, valaddr); + + print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr, + 0, addr, stream, recurse, options); + } +} + /* c_val_print helper for TYPE_CODE_STRUCT. */ static void @@ -582,8 +619,7 @@ c_value_print_inner (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_PTR: - c_val_print_ptr (type, valaddr, 0, stream, recurse, - val, options); + c_value_print_ptr (val, stream, recurse, options); break; case TYPE_CODE_UNION: