From patchwork Wed Jul 8 21:07:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 7601 Received: (qmail 6673 invoked by alias); 8 Jul 2015 21:08:27 -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 6629 invoked by uid 89); 8 Jul 2015 21:08:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: usevmg21.ericsson.net Received: from usevmg21.ericsson.net (HELO usevmg21.ericsson.net) (198.24.6.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 08 Jul 2015 21:08:25 +0000 Received: from EUSAAHC005.ericsson.se (Unknown_Domain [147.117.188.87]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id BB.A4.07675.8E92D955; Wed, 8 Jul 2015 15:47:20 +0200 (CEST) Received: from elxcz23q12-y4.dyn.mo.ca.am.ericsson.se (147.117.188.8) by smtps-am.internal.ericsson.com (147.117.188.87) with Microsoft SMTP Server (TLS) id 14.3.210.2; Wed, 8 Jul 2015 17:08:12 -0400 From: Simon Marchi To: CC: Simon Marchi Subject: [PATCH 6/7] Factor out int printing code from c_val_print Date: Wed, 8 Jul 2015 17:07:08 -0400 Message-ID: <1436389629-18754-7-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1436389629-18754-1-git-send-email-simon.marchi@ericsson.com> References: <1436389629-18754-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 X-IsSubscribed: yes gdb/ChangeLog: * c-valprint.c (c_val_print): Factor out int printing code to ... (c_val_print_int): ... this new function. --- gdb/c-valprint.c | 60 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index d950de3..0afd292 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -421,6 +421,40 @@ c_val_print_union (struct type *type, const gdb_byte *valaddr, } } +/* c_val_print helper for TYPE_CODE_INT. */ + +static void +c_val_print_int (struct type *type, struct type *unresolved_type, + const gdb_byte *valaddr, int embedded_offset, + struct ui_file *stream, const struct value *original_value, + const struct value_print_options *options) +{ + if (options->format || options->output_format) + { + struct value_print_options opts = *options; + + opts.format = (options->format ? options->format + : options->output_format); + val_print_scalar_formatted (type, valaddr, embedded_offset, + original_value, &opts, 0, stream); + } + else + { + val_print_type_code_int (type, valaddr + embedded_offset, + stream); + /* C and C++ has no single byte int type, char is used + instead. Since we don't know whether the value is really + intended to be used as an integer or a character, print + the character equivalent as well. */ + if (c_textual_element_type (unresolved_type, options->format)) + { + fputs_filtered (" ", stream); + LA_PRINT_CHAR (unpack_long (type, valaddr + embedded_offset), + unresolved_type, stream); + } + } +} + /* See val_print for a description of the various parameters of this function; they are identical. */ @@ -461,30 +495,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, break; case TYPE_CODE_INT: - if (options->format || options->output_format) - { - struct value_print_options opts = *options; - - opts.format = (options->format ? options->format - : options->output_format); - val_print_scalar_formatted (type, valaddr, embedded_offset, - original_value, &opts, 0, stream); - } - else - { - val_print_type_code_int (type, valaddr + embedded_offset, - stream); - /* C and C++ has no single byte int type, char is used - instead. Since we don't know whether the value is really - intended to be used as an integer or a character, print - the character equivalent as well. */ - if (c_textual_element_type (unresolved_type, options->format)) - { - fputs_filtered (" ", stream); - LA_PRINT_CHAR (unpack_long (type, valaddr + embedded_offset), - unresolved_type, stream); - } - } + c_val_print_int (type, unresolved_type, valaddr, embedded_offset, stream, + original_value, options); break; case TYPE_CODE_MEMBERPTR: