Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Andrew Burgess" <aburgess@broadcom.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [PATCH] more output from remote-sim dump_mem
Date: Tue, 02 Oct 2012 21:07:00 -0000	[thread overview]
Message-ID: <506B577B.5030306@broadcom.com> (raw)

The dump_mem function in gdb/remote-sim.c is only used for debugging but has a couple of interesting features,

(1) It casts an array of bytes to an array of long in order to print the original array in 4 byte chunks, this is fine except long might not be 4 bytes in size.  I've changed this to use uint32_t.

(2) The function produces no output at all if the original buffer is more than 8 bytes in length.  I've changed this so we always get some output from the function.

Ok to apply ?

Thanks,
Andrew


gdb/ChangeLog

2012-10-02  Andrew Burgess  <aburgess@broadcom.com>

	* remote-sim.c (dump_mem): Always dump buffer contents, zero fill
	output and use uint32_t not long to ensure 4 byte size.


diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c
index d87f668..962420e 100644
--- a/gdb/remote-sim.c
+++ b/gdb/remote-sim.c
@@ -273,27 +273,24 @@ sim_inferior_data_cleanup (struct inferior *inf, void *data)
 static void
 dump_mem (char *buf, int len)
 {
-  if (len <= 8)
+  if (len == 8 || len == 4)
     {
-      if (len == 8 || len == 4)
-	{
-	  long l[2];
+      uint32_t l[2];
 
-	  memcpy (l, buf, len);
-	  printf_filtered ("\t0x%lx", l[0]);
-	  if (len == 8)
-	    printf_filtered (" 0x%lx", l[1]);
-	  printf_filtered ("\n");
-	}
-      else
-	{
-	  int i;
+      memcpy (l, buf, len);
+      printf_filtered ("\t0x%08x", l[0]);
+      if (len == 8)
+	printf_filtered (" 0x%08x", l[1]);
+      printf_filtered ("\n");
+    }
+  else
+    {
+      int i;
 
-	  printf_filtered ("\t");
-	  for (i = 0; i < len; i++)
-	    printf_filtered ("0x%x ", buf[i]);
-	  printf_filtered ("\n");
-	}
+      printf_filtered ("\t");
+      for (i = 0; i < len; i++)
+	printf_filtered ("0x%02x ", buf[i]);
+      printf_filtered ("\n");
     }
 }
 


             reply	other threads:[~2012-10-02 21:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-02 21:07 Andrew Burgess [this message]
2012-10-02 21:20 ` Mike Frysinger
2012-10-02 21:54   ` Andrew Burgess

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=506B577B.5030306@broadcom.com \
    --to=aburgess@broadcom.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