From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9611 invoked by alias); 28 Jan 2011 15:52:30 -0000 Received: (qmail 9597 invoked by uid 22791); 28 Jan 2011 15:52:29 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Jan 2011 15:52:24 +0000 Received: (qmail 23837 invoked from network); 28 Jan 2011 15:52:22 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 28 Jan 2011 15:52:22 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [mips-tdep] Re: s/print_scalar_formatted/val_print_scalar_formatted/, mostly Date: Fri, 28 Jan 2011 16:01:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.35-24-generic; KDE/4.5.1; x86_64; ; ) References: <201101251801.43081.pedro@codesourcery.com> In-Reply-To: <201101251801.43081.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201101281552.20545.pedro@codesourcery.com> X-IsSubscribed: yes 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: 2011-01/txt/msg00550.txt.bz2 On Friday 28 January 2011 18:01:42, Pedro Alves wrote: > Only a handful of print_scalar_formatted calls are left in the > tree after this. mips-tdep.c has 3 that could/should be converted > to val_print_scalar_formatted, but I didn't bother yet as I'd need to > make them construct a value too. I had actually started doing it for mips-tdep.c, but stopped after the first conversion. Might as well push it. I've applied the patch below. The advantage is that val_print_scalar_formatted will magically know to print "" for register that haven't been collected, when unavailable registers support is glued with unavailable values support. This suspicious bit, if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) offset = register_size (gdbarch, regnum) - register_size (gdbarch, regnum); else offset = 0; which always ends up with offset == 0, had me go look through history, and find out that a long sequence of cleanups and architecture changes over the years ended up with equal register_size calls on both terms of the subtraction, while they were different things originally. I'm not planning on converting the other print_scalar_formatted calls in mips-tdep.c myself. -- Pedro Alves 2011-01-28 Pedro Alves gdb/ * mips-tdep.c (mips_print_register): Use get_frame_register_value and val_print_scalar_formatted. --- gdb/mips-tdep.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) Index: src/gdb/mips-tdep.c =================================================================== --- src.orig/gdb/mips-tdep.c 2011-01-13 15:07:28.726075000 +0000 +++ src/gdb/mips-tdep.c 2011-01-28 13:47:09.541415001 +0000 @@ -4683,9 +4683,9 @@ mips_print_register (struct ui_file *fil int regnum) { struct gdbarch *gdbarch = get_frame_arch (frame); - gdb_byte raw_buffer[MAX_REGISTER_SIZE]; int offset; struct value_print_options opts; + struct value *val; if (TYPE_CODE (register_type (gdbarch, regnum)) == TYPE_CODE_FLT) { @@ -4693,8 +4693,8 @@ mips_print_register (struct ui_file *fil return; } - /* Get the data in raw format. */ - if (!frame_register_read (frame, regnum, raw_buffer)) + val = get_frame_register_value (frame, regnum); + if (value_optimized_out (val)) { fprintf_filtered (file, "%s: [Invalid]", gdbarch_register_name (gdbarch, regnum)); @@ -4712,16 +4712,12 @@ mips_print_register (struct ui_file *fil else fprintf_filtered (file, ": "); - if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) - offset = - register_size (gdbarch, regnum) - register_size (gdbarch, regnum); - else - offset = 0; - get_formatted_print_options (&opts, 'x'); - print_scalar_formatted (raw_buffer + offset, - register_type (gdbarch, regnum), &opts, 0, - file); + val_print_scalar_formatted (value_type (val), + value_contents_for_printing (val), + value_embedded_offset (val), + val, + &opts, 0, file); } /* Replacement for generic do_registers_info.