public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@codesourcery.com>
To: gdb-patches@sourceware.org
Subject: MI, always pass a value to val_print & co
Date: Tue, 25 Jan 2011 17:06:00 -0000	[thread overview]
Message-ID: <201101251700.58483.pedro@codesourcery.com> (raw)

Here's another case where we were passing a NULL value to
val_print.

Tested on x86_64-linux and checked in.

-- 
Pedro Alves

2011-01-25  Pedro Alves  <pedro@codesourcery.com>

	gdb/
	* mi/mi-main.c (get_register): Use get_frame_register_value rather
	than frame_register, and always pass a valid value to val_print.

---
 gdb/mi/mi-main.c |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

Index: src/gdb/mi/mi-main.c
===================================================================
--- src.orig/gdb/mi/mi-main.c	2011-01-25 12:26:25.547640002 +0000
+++ src/gdb/mi/mi-main.c	2011-01-25 16:46:47.587640006 +0000
@@ -1116,27 +1116,26 @@ static void
 get_register (struct frame_info *frame, int regnum, int format)
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
-  gdb_byte buffer[MAX_REGISTER_SIZE];
-  int optim;
-  int realnum;
   CORE_ADDR addr;
   enum lval_type lval;
   static struct ui_stream *stb = NULL;
+  struct value *val;
 
   stb = ui_out_stream_new (uiout);
 
   if (format == 'N')
     format = 0;
 
-  frame_register (frame, regnum, &optim, &lval, &addr, &realnum, buffer);
+  val = get_frame_register_value (frame, regnum);
 
-  if (optim)
+  if (value_optimized_out (val))
     error ("Optimized out");
 
   if (format == 'r')
     {
       int j;
       char *ptr, buf[1024];
+      const gdb_byte *valaddr = value_contents_for_printing (val);
 
       strcpy (buf, "0x");
       ptr = buf + 2;
@@ -1145,7 +1144,7 @@ get_register (struct frame_info *frame,
 	  int idx = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ?
 		    j : register_size (gdbarch, regnum) - 1 - j;
 
-	  sprintf (ptr, "%02x", (unsigned char) buffer[idx]);
+	  sprintf (ptr, "%02x", (unsigned char) valaddr[idx]);
 	  ptr += 2;
 	}
       ui_out_field_string (uiout, "value", buf);
@@ -1157,8 +1156,10 @@ get_register (struct frame_info *frame,
 
       get_formatted_print_options (&opts, format);
       opts.deref_ref = 1;
-      val_print (register_type (gdbarch, regnum), buffer, 0, 0,
-		 stb->stream, 0, NULL, &opts, current_language);
+      val_print (value_type (val),
+		 value_contents_for_printing (val),
+		 value_embedded_offset (val), 0,
+		 stb->stream, 0, val, &opts, current_language);
       ui_out_field_stream (uiout, "value", stb);
       ui_out_stream_delete (stb);
     }

                 reply	other threads:[~2011-01-25 17:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201101251700.58483.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).