Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] more output from remote-sim dump_mem
@ 2012-10-02 21:07 Andrew Burgess
  2012-10-02 21:20 ` Mike Frysinger
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Burgess @ 2012-10-02 21:07 UTC (permalink / raw)
  To: gdb-patches

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");
     }
 }
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-10-02 21:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-02 21:07 [PATCH] more output from remote-sim dump_mem Andrew Burgess
2012-10-02 21:20 ` Mike Frysinger
2012-10-02 21:54   ` Andrew Burgess

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox