This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[mips-tdep] Re: s/print_scalar_formatted/val_print_scalar_formatted/, mostly
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Fri, 28 Jan 2011 15:52:20 +0000
- Subject: [mips-tdep] Re: s/print_scalar_formatted/val_print_scalar_formatted/, mostly
- References: <201101251801.43081.pedro@codesourcery.com>
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 "<unavailable>" 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 <pedro@codesourcery.com>
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.