From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 4988E3AAA084; Sat, 14 Mar 2020 00:06:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4988E3AAA084 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1584144414; bh=YUw4QODU83DWJ8MaYi+7gV8+JP7QpOH3QKm9NEs/d/8=; h=From:To:Subject:Date:From; b=H8Y0ZkOHdk3rq4SQ2G7qqBbpabHoTCVTFQ8m0HqFQ6/33pPXncawXrqMaRf4qrz5j eUGBUtAki6+PbvtN8Uhcp78yCzEmdvCC7eVboyJSYbJ5gW+LtNHvSPTc/EWOf2xd1+ tIsv6KHu4kHfDY09LkC5Qogld8FFm0PSOo/vLgFM= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Introduce generic_value_print_ptr X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: abc66ce95eee79db058123b985e19dcfc03dc1a7 X-Git-Newrev: 2a5b130bcb6f376b6a28d8378172ed3f9b92e9d9 Message-Id: <20200314000654.4988E3AAA084@sourceware.org> Date: Sat, 14 Mar 2020 00:06:54 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2020 00:06:54 -0000 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2a5b130bcb6f376b6a28d8378172ed3f9b92e9d9 commit 2a5b130bcb6f376b6a28d8378172ed3f9b92e9d9 Author: Tom Tromey Date: Fri Mar 13 17:39:52 2020 -0600 Introduce generic_value_print_ptr This introduces generic_value_print_ptr, a value-based analogue of generic_val_print_ptr, and changes generic_value_print to use it. gdb/ChangeLog 2020-03-13 Tom Tromey * valprint.c (generic_value_print): Call generic_value_print_ptr. * valprint.c (generic_value_print_ptr): New function. Diff: --- gdb/ChangeLog | 5 +++++ gdb/valprint.c | 26 ++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bfeec8112e6..322d4c77397 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-03-13 Tom Tromey + + * valprint.c (generic_value_print): Call generic_value_print_ptr. + * valprint.c (generic_value_print_ptr): New function. + 2020-03-13 Tom Tromey * valprint.c (generic_value_print): Rewrite. diff --git a/gdb/valprint.c b/gdb/valprint.c index 50b5a1ff50d..0063bb5e0cb 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -489,6 +489,26 @@ generic_val_print_ptr (struct type *type, } } +/* generic_value_print helper for TYPE_CODE_PTR. */ + +static void +generic_value_print_ptr (struct value *val, struct ui_file *stream, + const struct value_print_options *options) +{ + + if (options->format && options->format != 's') + value_print_scalar_formatted (val, options, 0, stream); + else + { + struct type *type = check_typedef (value_type (val)); + struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type)); + const gdb_byte *valaddr = value_contents_for_printing (val); + CORE_ADDR addr = unpack_pointer (type, valaddr); + + print_unpacked_pointer (type, elttype, addr, stream, options); + } +} + /* generic_val_print helper for TYPE_CODE_MEMBERPTR. */ @@ -1052,13 +1072,11 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse, break; case TYPE_CODE_MEMBERPTR: - generic_val_print_memberptr (type, 0, stream, - val, options); + value_print_scalar_formatted (val, options, 0, stream); break; case TYPE_CODE_PTR: - generic_val_print_ptr (type, 0, stream, - val, options); + generic_value_print_ptr (val, stream, options); break; case TYPE_CODE_REF: