Skip to contentSkip to conversation

additional gdbstub fixes

PATCH New Hollis Blanchard 1 participant 1 message Mar 6, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 additional gdbstub fixes

Fix additional gdbstub issues.
- gdbstub.h uses atomic_t and PAGE_SIZE, so include those headers
- do not lie about setting breakpoints
- fix memory writing

Given that breakpoints/stepping and memory writing completely did not work, I think a little more testing could have gone in to the common gdbstub.

Note that when the stub does not support the "Z" (breakpoint) command, GDB falls back to writing trap instructions directly into memory (which was also broken). I have no idea why that comment about "gdb won't let you continue the process" was there.

Please apply.

# HG changeset patch
# User [email protected]
# Node ID c26f6df8adc48b0559f036a803b4c79894303bec # Parent 2307bf2a4bfc615488a9a606753fbcb021532fcf fix gdbstub breakpoints, memory writing, and build

xen/common/gdbstub.c +11 -9
diff -r 2307bf2a4bfc -r c26f6df8adc4 xen/common/gdbstub.c
@@ -348,7 +348,10 @@
         }
     }
 
-    gdb_write_to_packet_str((x != length) ? "OK" : "E11", ctx);
+    if (x == length)
+        gdb_write_to_packet_str("OK", ctx);
+    else
+        gdb_write_to_packet_str("E11", ctx);
 
     dbg_printk("Write done.\n");
 
@@ -397,13 +400,18 @@
         break;
     case 'M': /* Write memory */
         addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16);
-        if ( (ptr == (ctx->in_buf + 1)) || (ptr[0] != ':') )
+        if ( (ptr == (ctx->in_buf + 1)) || (ptr[0] != ',') )
         {
             gdb_send_reply("E03", ctx);
             return 0;
         }
         length = simple_strtoul(ptr + 1, &ptr, 16);
-        gdb_cmd_write_mem(addr, length, ptr, ctx);
+        if ( ptr[0] != ':')
+        {
+            gdb_send_reply("E04", ctx);
+            return 0;
+        }
+        gdb_cmd_write_mem(addr, length, ptr + 1, ctx);
         break;
     case 'p': /* read register */
         addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16);
@@ -419,12 +427,6 @@
         }
         gdb_arch_read_reg(addr, regs, ctx);
         break;
-    case 'Z': /* We need to claim to support these or gdb
-                 won't let you continue the process. */
-    case 'z':
-        gdb_send_reply("OK", ctx);
-        break;
-
     case 'D':
         ctx->currently_attached = 0;
         gdb_send_reply("OK", ctx);
xen/include/xen/gdbstub.h +3 -0
diff -r 2307bf2a4bfc -r c26f6df8adc4 xen/include/xen/gdbstub.h
@@ -20,6 +20,9 @@
 
 #ifndef __XEN_GDBSTUB_H__
 #define __XEN_GDBSTUB_H__
+
+#include <asm/atomic.h>
+#include <asm/page.h>
 
 #ifdef CRASH_DEBUG
 
Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center