ia64/xen-unstable

changeset 3865:ac04aeeaf462

bitkeeper revision 1.1205.1.5 (42160256WLh3PYM-V5i-QJliGUxICA)

Added a toggle so that debugtrace_printk's can be redirected to the
console or to their own private buffer.
author maf46@burn.cl.cam.ac.uk
date Fri Feb 18 14:57:26 2005 +0000 (2005-02-18)
parents 7d995f85672d
children be663b5d36ee
files xen/common/keyhandler.c xen/drivers/char/console.c xen/include/xen/lib.h
line diff
     1.1 --- a/xen/common/keyhandler.c	Fri Feb 18 14:10:50 2005 +0000
     1.2 +++ b/xen/common/keyhandler.c	Fri Feb 18 14:57:26 2005 +0000
     1.3 @@ -158,7 +158,10 @@ void do_debug_key(unsigned char key, str
     1.4  #ifndef NDEBUG
     1.5  void debugtrace_key(unsigned char key)
     1.6  {
     1.7 -    debugtrace_dump();
     1.8 +    static int send_to_console = 0;
     1.9 +
    1.10 +    send_to_console = !send_to_console;
    1.11 +    debugtrace_dump(send_to_console);
    1.12  }
    1.13  #endif
    1.14  
     2.1 --- a/xen/drivers/char/console.c	Fri Feb 18 14:10:50 2005 +0000
     2.2 +++ b/xen/drivers/char/console.c	Fri Feb 18 14:57:26 2005 +0000
     2.3 @@ -479,23 +479,35 @@ void console_force_lock(void)
     2.4  static unsigned char *debugtrace_buf; /* Debug-trace buffer */
     2.5  static unsigned int   debugtrace_prd; /* Producer index     */
     2.6  static unsigned int   debugtrace_kilobytes = 128, debugtrace_bytes;
     2.7 +static int            debugtrace_send_to_console = 0;
     2.8  static spinlock_t debugtrace_lock = SPIN_LOCK_UNLOCKED;
     2.9  integer_param("debugtrace", debugtrace_kilobytes);
    2.10  
    2.11 -void debugtrace_reset(void)
    2.12 +
    2.13 +static void _debugtrace_reset(int send_to_console)
    2.14  {
    2.15 -    unsigned long  flags;
    2.16 -
    2.17 -    spin_lock_irqsave(&debugtrace_lock, flags);
    2.18 +    if (send_to_console)
    2.19 +        printk("debugtrace_printk now writting to console\n");
    2.20 +    else
    2.21 +        printk("debugtrace_printk now writting to buffer\n");
    2.22  
    2.23      if ( debugtrace_bytes != 0 )
    2.24          memset(debugtrace_buf, '\0', debugtrace_bytes);
    2.25 +
    2.26      debugtrace_prd = 0;
    2.27 +    debugtrace_send_to_console = send_to_console;
    2.28 +}
    2.29  
    2.30 +void debugtrace_reset(int send_to_console)
    2.31 +{
    2.32 +    unsigned long flags;
    2.33 +
    2.34 +    spin_lock_irqsave(&debugtrace_lock, flags);
    2.35 +    _debugtrace_reset(send_to_console);
    2.36      spin_unlock_irqrestore(&debugtrace_lock, flags);
    2.37  }
    2.38  
    2.39 -void debugtrace_dump(void)
    2.40 +void debugtrace_dump(int send_to_console)
    2.41  {
    2.42      int _watchdog_on = watchdog_on;
    2.43  
    2.44 @@ -514,8 +526,7 @@ void debugtrace_dump(void)
    2.45      debugtrace_buf[debugtrace_prd] = '\0';
    2.46      serial_puts(sercon_handle, &debugtrace_buf[0]);
    2.47  
    2.48 -    memset(debugtrace_buf, '\0', debugtrace_bytes);
    2.49 -    debugtrace_prd = 0;
    2.50 +    _debugtrace_reset(send_to_console);
    2.51  
    2.52      spin_unlock(&debugtrace_lock);
    2.53  
    2.54 @@ -537,15 +548,22 @@ void debugtrace_printk(const char *fmt, 
    2.55  
    2.56      va_start(args, fmt);
    2.57      (void)vsnprintf(buf, sizeof(buf), fmt, args);
    2.58 -    va_end(args);        
    2.59 +    va_end(args);
    2.60  
    2.61 -    for ( p = buf; *p != '\0'; p++ )
    2.62 +    if (debugtrace_send_to_console)
    2.63 +    {
    2.64 +        serial_puts(sercon_handle, buf);
    2.65 +    }
    2.66 +    else
    2.67      {
    2.68 -        debugtrace_buf[debugtrace_prd++] = *p;
    2.69 -
    2.70 -        /* always leave a null byte at the end of the buffer */
    2.71 -        if (debugtrace_prd == debugtrace_bytes-1)
    2.72 -            debugtrace_prd = 0;
    2.73 +        for ( p = buf; *p != '\0'; p++ )
    2.74 +        {
    2.75 +            debugtrace_buf[debugtrace_prd++] = *p;
    2.76 +            
    2.77 +            /* always leave a null byte at the end of the buffer */
    2.78 +            if (debugtrace_prd == debugtrace_bytes-1)
    2.79 +                debugtrace_prd = 0;
    2.80 +        }
    2.81      }
    2.82  
    2.83      spin_unlock_irqrestore(&debugtrace_lock, flags);
    2.84 @@ -568,7 +586,7 @@ static int __init debugtrace_init(void)
    2.85      debugtrace_buf = (unsigned char *)alloc_xenheap_pages(order);
    2.86      ASSERT(debugtrace_buf != NULL);
    2.87  
    2.88 -    memset(debugtrace_buf, '\0', debugtrace_bytes);
    2.89 +    debugtrace_reset(0);
    2.90  
    2.91      return 0;
    2.92  }
    2.93 @@ -593,6 +611,8 @@ void panic(const char *fmt, ...)
    2.94      unsigned long flags;
    2.95      extern void machine_restart(char *);
    2.96      
    2.97 +    debugtrace_dump(0);
    2.98 +
    2.99      va_start(args, fmt);
   2.100      (void)vsnprintf(buf, sizeof(buf), fmt, args);
   2.101      va_end(args);
   2.102 @@ -611,8 +631,6 @@ void panic(const char *fmt, ...)
   2.103      __putstr("Reboot in five seconds...\n");
   2.104      spin_unlock_irqrestore(&console_lock, flags);
   2.105  
   2.106 -    debugtrace_dump();
   2.107 -
   2.108      mdelay(5000);
   2.109      machine_restart(0);
   2.110  }
     3.1 --- a/xen/include/xen/lib.h	Fri Feb 18 14:10:50 2005 +0000
     3.2 +++ b/xen/include/xen/lib.h	Fri Feb 18 14:57:26 2005 +0000
     3.3 @@ -7,8 +7,8 @@
     3.4  #include <xen/string.h>
     3.5  
     3.6  #define BUG() do {					\
     3.7 +    debugtrace_dump(0);                                 \
     3.8      printk("BUG at %s:%d\n", __FILE__, __LINE__);	\
     3.9 -    debugtrace_dump();                                  \
    3.10      FORCE_CRASH();                                      \
    3.11  } while ( 0 )
    3.12  
    3.13 @@ -28,13 +28,13 @@ struct domain;
    3.14  void cmdline_parse(char *cmdline);
    3.15  
    3.16  #ifndef NDEBUG
    3.17 -extern void debugtrace_reset(void);
    3.18 -extern void debugtrace_dump(void);
    3.19 +extern void debugtrace_reset(int send_to_console);
    3.20 +extern void debugtrace_dump(int send_to_console);
    3.21  extern void debugtrace_printk(const char *fmt, ...);
    3.22  #else
    3.23 -#define debugtrace_reset()         ((void)0)
    3.24 -#define debugtrace_dump()          ((void)0)
    3.25 -#define debugtrace_printk(_f, ...) ((void)0)
    3.26 +#define debugtrace_reset(_send_to_console) ((void)0)
    3.27 +#define debugtrace_dump(_send_to_console)  ((void)0)
    3.28 +#define debugtrace_printk(_f, ...)         ((void)0)
    3.29  #endif
    3.30  
    3.31  #define printk printf