From: Caz Yokoyama Subject: RE: [PATCH] break-in to Xen 1) when gdb is invoked and 2) ^C on gdb Date: Mon, 17 Aug 2009 13:56:38 -0700 Message-ID: <8F5BFC614D7C4B34A8768DF69BB6D65D@xpjpn> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0269_01CA1F42.8B771420" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: 'Keir Fraser' Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. ------=_NextPart_000_0269_01CA1F42.8B771420 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello Keir, This patch makes gdb break-in to Xen when 1) it is invoked and 2) ^C is typed on gdb or clicking interrupt on ddd. diff -r 8b0f1f37e145 xen/common/keyhandler.c --- a/xen/common/keyhandler.c Sun Aug 16 08:46:08 2009 +0100 +++ b/xen/common/keyhandler.c Mon Aug 17 10:07:04 2009 -0700 @@ -397,7 +397,11 @@ .desc = "print all diagnostics" }; +#if 1 +void do_debug_key(unsigned char key, struct cpu_user_regs *regs) +#else static void do_debug_key(unsigned char key, struct cpu_user_regs *regs) +#endif { printk("'%c' pressed -> trapping into debugger\n", key); (void)debugger_trap_fatal(0xf001, regs); diff -r 8b0f1f37e145 xen/drivers/char/ns16550.c --- a/xen/drivers/char/ns16550.c Sun Aug 16 08:46:08 2009 +0100 +++ b/xen/drivers/char/ns16550.c Mon Aug 17 10:07:04 2009 -0700 @@ -16,6 +16,7 @@ #include #include #include +#include /* * Configure serial port with a string: @@ -125,10 +126,16 @@ { struct serial_port *port = dev_id; struct ns16550 *uart = port->uart; + char lsr; while ( !(ns_read_reg(uart, IIR) & IIR_NOINT) ) { - char lsr = ns_read_reg(uart, LSR); + lsr = ns_read_reg(uart, LSR); +#if 1 + if ( lsr & LSR_BI ) { /* on BREAK */ + do_debug_key('g', regs); /* g is meaningless */ + } +#endif if ( lsr & LSR_THRE ) serial_tx_interrupt(port, regs); if ( lsr & LSR_DR ) diff -r 8b0f1f37e145 xen/include/xen/keyhandler.h --- a/xen/include/xen/keyhandler.h Sun Aug 16 08:46:08 2009 +0100 +++ b/xen/include/xen/keyhandler.h Mon Aug 17 10:07:04 2009 -0700 @@ -40,6 +40,10 @@ char *desc; }; +#if 1 +extern void do_debug_key(unsigned char key, struct cpu_user_regs *regs); +#endif + /* Initialize keytable with default handlers */ extern void initialize_keytable(void); Xen expects BREAK and 'g' which is the same sequence of the one on Linux kernel. I submitted a patch which sends BREAK and 'g' to gdb-patches on 08/07, but it is not approved yet. You can't use ssplitd/nsplitd because it does not pass BREAK. Therefore, you lose console output and corresponding ^A^A^A functions. My associated lines for the patch are menu.lst kernel /boot/xen-3.5-unstable.gz com1=115200,8n1 gdb=com1 .gdbinit set remotebreak BREAK-g target remote /dev/ttyS0 ddd --gdb --debugger "/home/caz/lightfleet/kgdb/gdb-KgdbLight/gdb/gdb" xen/xen-syms -caz ------=_NextPart_000_0269_01CA1F42.8B771420 Content-Type: application/octet-stream; name="BREAK-g.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="BREAK-g.patch" diff -r 8b0f1f37e145 xen/common/keyhandler.c=0A= --- a/xen/common/keyhandler.c Sun Aug 16 08:46:08 2009 +0100=0A= +++ b/xen/common/keyhandler.c Mon Aug 17 10:07:04 2009 -0700=0A= @@ -397,7 +397,11 @@=0A= .desc =3D "print all diagnostics"=0A= };=0A= =0A= +#if 1=0A= +void do_debug_key(unsigned char key, struct cpu_user_regs *regs)=0A= +#else=0A= static void do_debug_key(unsigned char key, struct cpu_user_regs *regs)=0A= +#endif=0A= {=0A= printk("'%c' pressed -> trapping into debugger\n", key);=0A= (void)debugger_trap_fatal(0xf001, regs);=0A= diff -r 8b0f1f37e145 xen/drivers/char/ns16550.c=0A= --- a/xen/drivers/char/ns16550.c Sun Aug 16 08:46:08 2009 +0100=0A= +++ b/xen/drivers/char/ns16550.c Mon Aug 17 10:07:04 2009 -0700=0A= @@ -16,6 +16,7 @@=0A= #include =0A= #include =0A= #include =0A= +#include =0A= =0A= /*=0A= * Configure serial port with a string:=0A= @@ -125,10 +126,16 @@=0A= {=0A= struct serial_port *port =3D dev_id;=0A= struct ns16550 *uart =3D port->uart;=0A= + char lsr;=0A= =0A= while ( !(ns_read_reg(uart, IIR) & IIR_NOINT) )=0A= {=0A= - char lsr =3D ns_read_reg(uart, LSR);=0A= + lsr =3D ns_read_reg(uart, LSR);=0A= +#if 1=0A= + if ( lsr & LSR_BI ) { /* on BREAK */=0A= + do_debug_key('g', regs); /* g is meaningless */=0A= + }=0A= +#endif=0A= if ( lsr & LSR_THRE )=0A= serial_tx_interrupt(port, regs);=0A= if ( lsr & LSR_DR )=0A= diff -r 8b0f1f37e145 xen/include/xen/keyhandler.h=0A= --- a/xen/include/xen/keyhandler.h Sun Aug 16 08:46:08 2009 +0100=0A= +++ b/xen/include/xen/keyhandler.h Mon Aug 17 10:07:04 2009 -0700=0A= @@ -40,6 +40,10 @@=0A= char *desc;=0A= };=0A= =0A= +#if 1=0A= +extern void do_debug_key(unsigned char key, struct cpu_user_regs *regs);=0A= +#endif=0A= +=0A= /* Initialize keytable with default handlers */=0A= extern void initialize_keytable(void);=0A= =0A= ------=_NextPart_000_0269_01CA1F42.8B771420 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_0269_01CA1F42.8B771420--