From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30953 invoked by alias); 28 Aug 2012 09:07:48 -0000 Received: (qmail 30938 invoked by uid 22791); 28 Aug 2012 09:07:45 -0000 X-SWARE-Spam-Status: No, hits=-7.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Aug 2012 09:07:27 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7S97PrB003366 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 28 Aug 2012 05:07:25 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q7S97M3L018462; Tue, 28 Aug 2012 05:07:23 -0400 Message-ID: <503C8A4A.6060004@redhat.com> Date: Tue, 28 Aug 2012 09:07:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Ulrich Weigand CC: Sergio Durigan Junior , GDB Patches , Tom Tromey , Jan Kratochvil Subject: Re: info registers output References: <201208280041.q7S0fRb3026972@d06av02.portsmouth.uk.ibm.com> In-Reply-To: <201208280041.q7S0fRb3026972@d06av02.portsmouth.uk.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2012-08/txt/msg00825.txt.bz2 On 08/28/2012 01:41 AM, Ulrich Weigand wrote: > Looks good to me. The only minor nit would be: > >> +/* Print out the register NAME, of GDBARCH, with value VAL, to FILE, >> + in the default fashion. */ >> + >> +static void >> +default_print_one_register_info (struct gdbarch *gdbarch, >> + struct ui_file *file, >> + const char *name, >> + struct value *val) > > Does this really need a GDBARCH argument? It's only used here: > >> + for (j = 0; j < TYPE_LENGTH (regtype); j++) >> + { >> + int idx; >> + >> + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) >> + idx = j; >> + else >> + idx = TYPE_LENGTH (regtype) - 1 - j; >> + fprintf_filtered (file, "%02x", (unsigned char) valaddr[idx]); >> + } > > where we really want the type's byte order anyway ... Indeed, thanks. I've applied with that change, as below. 2012-08-28 Pedro Alves PR gdb/14428 gdb/ * infcmd.c (default_print_one_register_info): New, factored out from default_print_registers_info. (default_print_registers_info): Use it. Mark value unavailable if necessary. (registers_info): Print user registers with default_print_one_register_info. gdb/testsuite/ * gdb.base/pc-fp.exp: Adjust expected output of 'info registers pc fp'. --- gdb/infcmd.c | 167 +++++++++++++++++++++----------------- gdb/testsuite/gdb.base/pc-fp.exp | 2 2 files changed, 93 insertions(+), 76 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 9d43193..8e2f74e 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2015,6 +2015,84 @@ path_command (char *dirname, int from_tty) } +/* Print out the register NAME with value VAL, to FILE, in the default + fashion. */ + +static void +default_print_one_register_info (struct ui_file *file, + const char *name, + struct value *val) +{ + struct type *regtype = value_type (val); + + fputs_filtered (name, file); + print_spaces_filtered (15 - strlen (name), file); + + if (!value_entirely_available (val)) + { + fprintf_filtered (file, "*value not available*\n"); + return; + } + + /* If virtual format is floating, print it that way, and in raw + hex. */ + if (TYPE_CODE (regtype) == TYPE_CODE_FLT + || TYPE_CODE (regtype) == TYPE_CODE_DECFLOAT) + { + int j; + struct value_print_options opts; + const gdb_byte *valaddr = value_contents_for_printing (val); + enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (regtype)); + + get_user_print_options (&opts); + opts.deref_ref = 1; + + val_print (regtype, + value_contents_for_printing (val), + value_embedded_offset (val), 0, + file, 0, val, &opts, current_language); + + fprintf_filtered (file, "\t(raw 0x"); + for (j = 0; j < TYPE_LENGTH (regtype); j++) + { + int idx; + + if (byte_order == BFD_ENDIAN_BIG) + idx = j; + else + idx = TYPE_LENGTH (regtype) - 1 - j; + fprintf_filtered (file, "%02x", (unsigned char) valaddr[idx]); + } + fprintf_filtered (file, ")"); + } + else + { + struct value_print_options opts; + + /* Print the register in hex. */ + get_formatted_print_options (&opts, 'x'); + opts.deref_ref = 1; + val_print (regtype, + value_contents_for_printing (val), + value_embedded_offset (val), 0, + file, 0, val, &opts, current_language); + /* If not a vector register, print it also according to its + natural format. */ + if (TYPE_VECTOR (regtype) == 0) + { + get_user_print_options (&opts); + opts.deref_ref = 1; + fprintf_filtered (file, "\t"); + val_print (regtype, + value_contents_for_printing (val), + value_embedded_offset (val), 0, + file, 0, val, &opts, current_language); + } + } + + fprintf_filtered (file, "\n"); +} + /* Print out the machine register regnum. If regnum is -1, print all registers (print_all == 1) or all non-float and non-vector registers (print_all == 0). @@ -2068,76 +2146,16 @@ default_print_registers_info (struct gdbarch *gdbarch, || *(gdbarch_register_name (gdbarch, i)) == '\0') continue; - fputs_filtered (gdbarch_register_name (gdbarch, i), file); - print_spaces_filtered (15 - strlen (gdbarch_register_name - (gdbarch, i)), file); - regtype = register_type (gdbarch, i); val = allocate_value (regtype); /* Get the data in raw format. */ if (! frame_register_read (frame, i, value_contents_raw (val))) - { - fprintf_filtered (file, "*value not available*\n"); - continue; - } - - /* If virtual format is floating, print it that way, and in raw - hex. */ - if (TYPE_CODE (regtype) == TYPE_CODE_FLT - || TYPE_CODE (regtype) == TYPE_CODE_DECFLOAT) - { - int j; - struct value_print_options opts; - const gdb_byte *valaddr = value_contents_for_printing (val); - - get_user_print_options (&opts); - opts.deref_ref = 1; - - val_print (regtype, - value_contents_for_printing (val), - value_embedded_offset (val), 0, - file, 0, val, &opts, current_language); - - fprintf_filtered (file, "\t(raw 0x"); - for (j = 0; j < register_size (gdbarch, i); j++) - { - int idx; - - if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) - idx = j; - else - idx = register_size (gdbarch, i) - 1 - j; - fprintf_filtered (file, "%02x", (unsigned char) valaddr[idx]); - } - fprintf_filtered (file, ")"); - } - else - { - struct value_print_options opts; - - /* Print the register in hex. */ - get_formatted_print_options (&opts, 'x'); - opts.deref_ref = 1; - val_print (regtype, - value_contents_for_printing (val), - value_embedded_offset (val), 0, - file, 0, val, &opts, current_language); - /* If not a vector register, print it also according to its - natural format. */ - if (TYPE_VECTOR (regtype) == 0) - { - get_user_print_options (&opts); - opts.deref_ref = 1; - fprintf_filtered (file, "\t"); - val_print (regtype, - value_contents_for_printing (val), - value_embedded_offset (val), 0, - file, 0, val, &opts, current_language); - } - } + mark_value_bytes_unavailable (val, 0, TYPE_LENGTH (value_type (val))); - fprintf_filtered (file, "\n"); + default_print_one_register_info (file, + gdbarch_register_name (gdbarch, i), + val); } } @@ -2198,17 +2216,16 @@ registers_info (char *addr_exp, int fpregs) if (regnum >= gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch)) { - struct value_print_options opts; - struct value *val = value_of_user_reg (regnum, frame); - - printf_filtered ("%.*s: ", (int) (end - start), start); - get_formatted_print_options (&opts, 'x'); - val_print_scalar_formatted (check_typedef (value_type (val)), - value_contents_for_printing (val), - value_embedded_offset (val), - val, - &opts, 0, gdb_stdout); - printf_filtered ("\n"); + struct value *regval = value_of_user_reg (regnum, frame); + const char *regname = user_reg_map_regnum_to_name (gdbarch, + regnum); + + /* Print in the same fashion + gdbarch_print_registers_info's default + implementation prints. */ + default_print_one_register_info (gdb_stdout, + regname, + regval); } else gdbarch_print_registers_info (gdbarch, gdb_stdout, diff --git a/gdb/testsuite/gdb.base/pc-fp.exp b/gdb/testsuite/gdb.base/pc-fp.exp index beb5087..685e2d9 100644 --- a/gdb/testsuite/gdb.base/pc-fp.exp +++ b/gdb/testsuite/gdb.base/pc-fp.exp @@ -66,4 +66,4 @@ gdb_test "info register \$fp" "${valueof_fp}.*" # Regression test for # http://sourceware.org/bugzilla/show_bug.cgi?id=12659 gdb_test "info register pc fp" \ - "pc(:)?( |\t)+${valueof_pc}(( |\t)+${valueof_pc} <.*>)?\[\r\n\]+fp(:)?( |\t)+${valueof_fp}(( |\t)+${valueof_fp})?\[\r\n\]+" + "pc +${valueof_pc}\t${valueof_pc} <.*>\[\r\n\]+fp +${valueof_fp}\t${valueof_fp}\[\r\n\]+"