This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] more output from remote-sim dump_mem
- From: "Andrew Burgess" <aburgess at broadcom dot com>
- To: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Tue, 2 Oct 2012 22:07:07 +0100
- Subject: [PATCH] more output from remote-sim dump_mem
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");
}
}