public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
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	[thread overview]
Message-ID: <201101281552.20545.pedro@codesourcery.com> (raw)
In-Reply-To: <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.

      parent reply	other threads:[~2011-01-28 15:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25 18:19 Pedro Alves
2011-01-25 19:38 ` TUI, always pass a value to val_print & co (Re: s/print_scalar_formatted/val_print_scalar_formatted/, mostly) Pedro Alves
2011-01-28 16:01 ` Pedro Alves [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201101281552.20545.pedro@codesourcery.com \
    --to=pedro@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).