Hello All,
        When GDB is atatched to the serial console you loose the output
from printk()'s.  Below is a quick patch that uses GDBs "O" packet to
pass this data out to GDB.

Currently it only works for Xen printk()'s (I'll work on dom0).  It's
not complete but I'll dump it here for a quick review to ensure I'm not
doing anything too horrendous.

---
diff -r f8233165fb80 xen/common/gdbstub.c
--- a/xen/common/gdbstub.c      Sun Aug 27 16:12:00 2006 -0400
+++ b/xen/common/gdbstub.c      Mon Aug 28 17:07:02 2006 +1000
@@ -470,6 +470,28 @@ __gdb_ctx = {
 };
 static struct gdb_context *gdb_ctx = &__gdb_ctx;
 
+/* FIXME: const? */
+/* FIXME: does this need to be protected by a lock?
+ *        Can it clobber another packet? */
+void
+gdb_puts(const char *str)
+{
+    char *p;
+   
+    /* FIXME Also check that console=gdb */
+    if ( gdb_ctx->currently_attached ) {
+       gdb_start_packet(gdb_ctx);
+        gdb_write_to_packet_char('O', gdb_ctx);
+
+        for(p=(char *)str; *p != '\x0'; p++) {
+           gdb_write_to_packet_char(hex2char((*p>>4) & 0x0f), gdb_ctx );
+           gdb_write_to_packet_char(hex2char((*p) & 0x0f), gdb_ctx );
+        }
+
+       gdb_send_packet(gdb_ctx);
+    }
+}
+
 /* trap handler: main entry point */
 int 
 __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie)
diff -r f8233165fb80 xen/drivers/char/console.c
--- a/xen/drivers/char/console.c        Sun Aug 27 16:12:00 2006 -0400
+++ b/xen/drivers/char/console.c        Mon Aug 28 17:07:02 2006 +1000
@@ -26,6 +26,8 @@
 #include <asm/current.h>
 #include <asm/debugger.h>
 #include <asm/io.h>
+
+#include <xen/gdbstub.h>
 
 /* console: comma-separated list of console outputs. */
 static char opt_console[30] = OPT_CONSOLE_STR;
@@ -258,6 +260,8 @@ static inline void __putstr(const char *
     int c;
 
     serial_puts(sercon_handle, str);
+    /* FIXME: Make sure this builds without debug=y */
+    gdb_puts(str);
 
     while ( (c = *str++) != '\0' )
     {
diff -r f8233165fb80 xen/include/xen/gdbstub.h
--- a/xen/include/xen/gdbstub.h Sun Aug 27 16:12:00 2006 -0400
+++ b/xen/include/xen/gdbstub.h Mon Aug 28 17:07:02 2006 +1000
@@ -90,10 +90,12 @@ void gdb_arch_exit(struct cpu_user_regs 
 #define SIGTERM         15
 
 void initialise_gdb(void);
+void gdb_puts(const char *str);
 
 #else
 
 #define initialise_gdb() ((void)0)
+#define gdb_puts(str) ((void)0)
 
 #endif
 
---

Yours Tony

   linux.conf.au       http://linux.conf.au/ || http://lca2007.linux.org.au/
   Jan 15-20 2007      The Australian Linux Technical Conference!


_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@lists.xensource.com
http://lists.xensource.com/xen-ppc-devel

Reply via email to