From: Caz Yokoyama Subject: [PATCH] Keep running Xen when quit gdb Date: Wed, 7 Oct 2009 14:25:58 -0700 Message-ID: <989B9C17DAB24A9B81817AB52FA3C18A@xpjpn> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0169_01CA475A.16DD96D0" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_0169_01CA475A.16DD96D0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_016A_01CA475A.16DD96D0" ------=_NextPart_001_016A_01CA475A.16DD96D0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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). ------=_NextPart_001_016A_01CA475A.16DD96D0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

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.cazte= ch.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-interrupt_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=3Dcom1L,vga com1=3D115200,8n1 = gdb=3Dcom1H

        module /vmlinuz-2.6.31.1 ro root=3D/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).

 

------=_NextPart_001_016A_01CA475A.16DD96D0-- ------=_NextPart_000_0169_01CA475A.16DD96D0 Content-Type: application/octet-stream; name="QuitKeepRunning.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="QuitKeepRunning.patch" diff -r f9cbb5a274d6 xen/common/gdbstub.c=0A= --- a/xen/common/gdbstub.c Wed Oct 07 10:26:39 2009 +0100=0A= +++ b/xen/common/gdbstub.c Wed Oct 07 13:07:27 2009 -0700=0A= @@ -45,6 +45,7 @@=0A= #include =0A= #include =0A= #include =0A= +#include "xen/keyhandler.h"=0A= =0A= /* Printk isn't particularly safe just after we've trapped to the=0A= debugger. so avoid it. */=0A= @@ -515,9 +516,8 @@=0A= case 'D':=0A= case 'k':=0A= gdbstub_detach(ctx);=0A= - gdb_send_reply("OK", ctx);=0A= - ctx->connected =3D 0;=0A= resume =3D 1;=0A= + gdb_arch_resume(regs, ~((unsigned long)0), GDB_CONTINUE, ctx);=0A= break;=0A= case 's': /* Single step */=0A= type =3D GDB_STEP;=0A= @@ -639,6 +639,12 @@=0A= return rc;=0A= }=0A= =0A= +static void gdb_serial_rx(char c, struct cpu_user_regs *regs)=0A= +{=0A= + if (c =3D=3D 0x03) /* activate gdb on Ctrl-C, otherwise ignore */=0A= + do_debug_key('\x03', regs); /* '\x03' is for console message */=0A= +}=0A= +=0A= void __init=0A= initialise_gdb(void)=0A= {=0A= @@ -654,6 +660,8 @@=0A= =0A= serial_start_sync(gdb_ctx->serhnd);=0A= =0A= + serial_set_rx_handler(gdb_ctx->serhnd, gdb_serial_rx);=0A= +=0A= printk("GDB stub initialised.\n");=0A= }=0A= =0A= diff -r f9cbb5a274d6 xen/common/keyhandler.c=0A= --- a/xen/common/keyhandler.c Wed Oct 07 10:26:39 2009 +0100=0A= +++ b/xen/common/keyhandler.c Wed Oct 07 13:07:27 2009 -0700=0A= @@ -397,9 +397,21 @@=0A= .desc =3D "print all diagnostics"=0A= };=0A= =0A= -static void do_debug_key(unsigned char key, struct cpu_user_regs *regs)=0A= +void do_debug_key(unsigned char key, struct cpu_user_regs *regs)=0A= {=0A= - printk("'%c' pressed -> trapping into debugger\n", key);=0A= + if (isprint(key))=0A= + printk("'%c'", key);=0A= + else {=0A= + switch (key) {=0A= + case '\x03':=0A= + printk("Ctrl-C");=0A= + break;=0A= + default:=0A= + printk("0x%02x", key);=0A= + break;=0A= + }=0A= + }=0A= + printk(" pressed -> trapping into debugger\n");=0A= (void)debugger_trap_fatal(0xf001, regs);=0A= nop(); /* Prevent the compiler doing tail call=0A= optimisation, as that confuses xendbg a=0A= diff -r f9cbb5a274d6 xen/include/xen/keyhandler.h=0A= --- a/xen/include/xen/keyhandler.h Wed Oct 07 10:26:39 2009 +0100=0A= +++ b/xen/include/xen/keyhandler.h Wed Oct 07 13:07:27 2009 -0700=0A= @@ -40,6 +40,8 @@=0A= char *desc;=0A= };=0A= =0A= +extern void do_debug_key(unsigned char key, struct cpu_user_regs *regs);=0A= +=0A= /* Initialize keytable with default handlers */=0A= extern void initialize_keytable(void);=0A= =0A= ------=_NextPart_000_0169_01CA475A.16DD96D0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ------=_NextPart_000_0169_01CA475A.16DD96D0--