From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96072 invoked by alias); 9 Jul 2015 15:32:09 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 96054 invoked by uid 89); 9 Jul 2015 15:32:08 -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; Thu, 09 Jul 2015 15:32:02 +0000 Received: from EUSAAHC007.ericsson.se (Unknown_Domain [147.117.188.93]) by usevmg21.ericsson.net (Symantec Mail Security) with SMTP id BE.D2.07675.E8C2E955; Thu, 9 Jul 2015 10:10:54 +0200 (CEST) Received: from [142.133.110.144] (147.117.188.8) by smtp-am.internal.ericsson.com (147.117.188.95) with Microsoft SMTP Server id 14.3.210.2; Thu, 9 Jul 2015 11:31:59 -0400 Message-ID: <559E93EF.60005@ericsson.com> Date: Thu, 09 Jul 2015 15:32:00 -0000 From: Simon Marchi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gdb-patches Subject: Re: [PATCH 4/7] Factor out pointer printing code from c_val_print References: <1436389629-18754-1-git-send-email-simon.marchi@ericsson.com> <1436389629-18754-5-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <1436389629-18754-5-git-send-email-simon.marchi@ericsson.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg00295.txt.bz2 On 15-07-08 05:07 PM, Simon Marchi wrote: > gdb/ChangeLog: > > * c-valprint.c (c_val_print): Factor out pointer printing code > to ... > (c_val_print_ptr): ... this new function. > --- > gdb/c-valprint.c | 62 +++++++++++++++++++++++++++++++++----------------------- > 1 file changed, 37 insertions(+), 25 deletions(-) > > diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c > index 0b95a7f..9f68815 100644 > --- a/gdb/c-valprint.c > +++ b/gdb/c-valprint.c > @@ -334,6 +334,41 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr, > } > } > > +/* c_val_print helper for TYPE_CODE_PTR. */ > + > +static void > +c_val_print_ptr (struct type *type, const gdb_byte *valaddr, > + int embedded_offset, struct ui_file *stream, int recurse, > + const struct value *original_value, > + const struct value_print_options *options) > +{ > + if (options->format && options->format != 's') > + { > + val_print_scalar_formatted (type, valaddr, embedded_offset, > + original_value, options, 0, stream); > + } > + else 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 + embedded_offset, type); > + struct gdbarch *gdbarch = get_type_arch (type); > + > + print_function_pointer_address (options, gdbarch, 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 + embedded_offset); > + print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr, > + embedded_offset, addr, stream, recurse, options); > + } > +} > + > /* See val_print for a description of the various parameters of this > function; they are identical. */ > > @@ -345,9 +380,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, > const struct value_print_options *options) > { > struct gdbarch *gdbarch = get_type_arch (type); > - struct type *elttype, *unresolved_elttype; > struct type *unresolved_type = type; > - CORE_ADDR addr; > > CHECK_TYPEDEF (type); > switch (TYPE_CODE (type)) > @@ -362,29 +395,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, > break; > > case TYPE_CODE_PTR: > - if (options->format && options->format != 's') > - { > - val_print_scalar_formatted (type, valaddr, embedded_offset, > - original_value, options, 0, stream); > - break; > - } > - 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 + embedded_offset, type); > - > - print_function_pointer_address (options, gdbarch, addr, stream); > - break; > - } > - unresolved_elttype = TYPE_TARGET_TYPE (type); > - elttype = check_typedef (unresolved_elttype); > - addr = unpack_pointer (type, valaddr + embedded_offset); > - print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr, > - embedded_offset, addr, stream, recurse, options); > + c_val_print_ptr (type, valaddr, embedded_offset, stream, recurse, > + original_value, options); > break; > > case TYPE_CODE_UNION: > Updated diff of what was pushed, I added a new line before a variable declaration. >From 1c67f0326351d9c521692ceca92f93cb0de9bf2e Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 9 Jul 2015 11:18:12 -0400 Subject: [PATCH] Factor out pointer printing code from c_val_print gdb/ChangeLog: * c-valprint.c (c_val_print): Factor out pointer printing code to ... (c_val_print_ptr): ... this new function. --- gdb/ChangeLog | 6 ++++++ gdb/c-valprint.c | 63 ++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f2ac3a6..54f7374 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2015-07-09 Simon Marchi + * c-valprint.c (c_val_print): Factor out pointer printing code + to ... + (c_val_print_ptr): ... this new function. + +2015-07-09 Simon Marchi + * c-valprint.c (c_valprint): Factor our array printing code from c_val_print to ... (c_val_print_array): ... this new function. diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index 9f9d999..4853575 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -334,6 +334,42 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr, } } +/* c_val_print helper for TYPE_CODE_PTR. */ + +static void +c_val_print_ptr (struct type *type, const gdb_byte *valaddr, + int embedded_offset, struct ui_file *stream, int recurse, + const struct value *original_value, + const struct value_print_options *options) +{ + if (options->format && options->format != 's') + { + val_print_scalar_formatted (type, valaddr, embedded_offset, + original_value, options, 0, stream); + } + else 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 + embedded_offset, type); + struct gdbarch *gdbarch = get_type_arch (type); + + print_function_pointer_address (options, gdbarch, 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 + embedded_offset); + + print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr, + embedded_offset, addr, stream, recurse, options); + } +} + /* See val_print for a description of the various parameters of this function; they are identical. */ @@ -345,9 +381,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, const struct value_print_options *options) { struct gdbarch *gdbarch = get_type_arch (type); - struct type *elttype, *unresolved_elttype; struct type *unresolved_type = type; - CORE_ADDR addr; CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) @@ -362,29 +396,8 @@ c_val_print (struct type *type, const gdb_byte *valaddr, break; case TYPE_CODE_PTR: - if (options->format && options->format != 's') - { - val_print_scalar_formatted (type, valaddr, embedded_offset, - original_value, options, 0, stream); - break; - } - 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 + embedded_offset, type); - - print_function_pointer_address (options, gdbarch, addr, stream); - break; - } - unresolved_elttype = TYPE_TARGET_TYPE (type); - elttype = check_typedef (unresolved_elttype); - addr = unpack_pointer (type, valaddr + embedded_offset); - print_unpacked_pointer (type, elttype, unresolved_elttype, valaddr, - embedded_offset, addr, stream, recurse, options); + c_val_print_ptr (type, valaddr, embedded_offset, stream, recurse, + original_value, options); break; case TYPE_CODE_UNION: -- 2.1.4