Skip to contentSkip to conversation

Keep running Xen when quit gdb

PATCH New Caz Yokoyama 1 participant 1 message Oct 7, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Keep running Xen when quit gdb

Hello,

This patch keeps running Xen when you quit from gdb. When you debug Xen and dom0 by gdb in host-target configuration, you can interrupt Xen by ^A^A^A%, then you can examine/set breakpoint/etc Xen by gdb. By this patch, you can also interrupt Xen on "target remote" command. In near future, gdb is going to integrate my patch,
http://sourceware.org/ml/gdb-patches/2009-10/msg00038.html and have a new command, "set/show remote interrupt-on-connect". When interrupt-on-connect is ON, gdb sends Ctrl-C to target on "target remote" command. As you see in the screen shots in http://www.caztech.com/xen/ScreenShot-20091007/, you can continue running Xen by both of continue command and quit gdb. In the screen shots, I use ssplitd to split the console messages and gdb interaction.

Patched gdb-7.0 is available in

http://kgdb-light.svn.sourceforge.net/viewvc/kgdb-light/branches/gdb-7.0-int
errupt_sequence/

Corresponding .gdbinit is

set prompt (xgdb)

add-symbol-file ../JeremyDom0/vmlinux 0

set remote interrupt-sequence Ctrl-C

set remote interrupt-on-connect on

set remotebaud 115200

target remote 127.0.0.1:4000

Note: you don't need to set interrupt-sequence. Ctrl-C is a default.

Corresponding menu.lst is

title xen-3.5-unstable.gz with kernel 2.6.31.1

        root (hd0,0) 

        kernel /xen-3.5-unstable.gz console=com1L,vga com1=115200,8n1

gdb=com1H

        module /vmlinuz-2.6.31.1 ro root=/dev/mapper/vg_tragi-lv_root rhgb

        module /initrd-2.6.31.1.img

Let me know if you have any question.

Thank you.

-Caz Yokoyama, caz at caztech dot com. 503-804-1028(m).

xen/common/gdbstub.c +10 -2
diff -r f9cbb5a274d6 xen/common/gdbstub.c
@@ -45,6 +45,7 @@
 #include <xen/errno.h>
 #include <xen/delay.h>
 #include <asm/byteorder.h>
+#include "xen/keyhandler.h"
 
 /* Printk isn't particularly safe just after we've trapped to the
    debugger. so avoid it. */
@@ -515,9 +516,8 @@
     case 'D':
     case 'k':
         gdbstub_detach(ctx);
-        gdb_send_reply("OK", ctx);
-        ctx->connected = 0;
         resume = 1;
+        gdb_arch_resume(regs, ~((unsigned long)0), GDB_CONTINUE, ctx);
         break;
     case 's': /* Single step */
         type = GDB_STEP;
@@ -639,6 +639,12 @@
     return rc;
 }
 
+static void gdb_serial_rx(char c, struct cpu_user_regs *regs)
+{
+	if (c == 0x03) /* activate gdb on Ctrl-C, otherwise ignore */
+		do_debug_key('\x03', regs); /* '\x03' is for console message */
+}
+
 void __init
 initialise_gdb(void)
 {
@@ -654,6 +660,8 @@
 
     serial_start_sync(gdb_ctx->serhnd);
 
+	serial_set_rx_handler(gdb_ctx->serhnd, gdb_serial_rx);
+
     printk("GDB stub initialised.\n");
 }
 
xen/common/keyhandler.c +14 -2
diff -r f9cbb5a274d6 xen/common/keyhandler.c
@@ -397,9 +397,21 @@
     .desc = "print all diagnostics"
 };
 
-static void do_debug_key(unsigned char key, struct cpu_user_regs *regs)
+void do_debug_key(unsigned char key, struct cpu_user_regs *regs)
 {
-    printk("'%c' pressed -> trapping into debugger\n", key);
+    if (isprint(key))
+        printk("'%c'", key);
+    else {
+        switch (key) {
+        case '\x03':
+            printk("Ctrl-C");
+            break;
+        default:
+            printk("0x%02x", key);
+            break;
+        }
+    }
+    printk(" pressed -> trapping into debugger\n");
     (void)debugger_trap_fatal(0xf001, regs);
     nop(); /* Prevent the compiler doing tail call
                              optimisation, as that confuses xendbg a
xen/include/xen/keyhandler.h +2 -0
diff -r f9cbb5a274d6 xen/include/xen/keyhandler.h
@@ -40,6 +40,8 @@
     char *desc;
 };
 
+extern void do_debug_key(unsigned char key, struct cpu_user_regs *regs);
+
 /* Initialize keytable with default handlers */
 extern void initialize_keytable(void);
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel