ia64/xen-unstable

changeset 9117:ec7802acc8c9

Fix up some issues I found when porting PPC to the new common gdb stub code:
- cosmetic changes in the messages printed
- 'flags' must always be unsigned long.
- explicitly calling initialize_gdb() is not difficult. For x86 and ia64 I
placed this call immediately before do_initcalls(), since that's where it's
being called from now so we know it's safe. Architecture people can move it
earlier as appropriate.
- I don't understand all these ASSERT(!local_irq_is_enabled()) statements,
sometimes bracketing a single call like receive_command(). How exactly would
receive_command() manage to re-enable irqs? Also, a failing ASSERT would just
call into the stub again anways...
- initialize_gdb() was overcomplicated. serial_parse_handle() already handles
the parsing for us, and there's no need to panic there.

Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Mar 03 10:53:58 2006 +0100 (2006-03-03)
parents f3661f9a95dd
children 0f368e70b4eb
files xen/arch/ia64/xen/xensetup.c xen/arch/x86/setup.c xen/common/gdbstub.c xen/include/xen/gdbstub.h
line diff
     1.1 --- a/xen/arch/ia64/xen/xensetup.c	Fri Mar 03 10:46:06 2006 +0100
     1.2 +++ b/xen/arch/ia64/xen/xensetup.c	Fri Mar 03 10:53:58 2006 +0100
     1.3 @@ -12,7 +12,7 @@
     1.4  #include <xen/sched.h>
     1.5  #include <xen/mm.h>
     1.6  #include <public/version.h>
     1.7 -//#include <xen/delay.h>
     1.8 +#include <xen/gdbstub.h>
     1.9  #include <xen/compile.h>
    1.10  #include <xen/console.h>
    1.11  #include <xen/serial.h>
    1.12 @@ -360,6 +360,8 @@ printk("About to call __cpu_up(%d)\n",i)
    1.13      smp_cpus_done(max_cpus);
    1.14  #endif
    1.15  
    1.16 +    initialise_gdb(); /* could be moved earlier */
    1.17 +
    1.18      do_initcalls();
    1.19  printk("About to call sort_main_extable()\n");
    1.20      sort_main_extable();
     2.1 --- a/xen/arch/x86/setup.c	Fri Mar 03 10:46:06 2006 +0100
     2.2 +++ b/xen/arch/x86/setup.c	Fri Mar 03 10:53:58 2006 +0100
     2.3 @@ -13,6 +13,7 @@
     2.4  #include <xen/multiboot.h>
     2.5  #include <xen/domain_page.h>
     2.6  #include <xen/compile.h>
     2.7 +#include <xen/gdbstub.h>
     2.8  #include <public/version.h>
     2.9  #include <asm/bitops.h>
    2.10  #include <asm/smp.h>
    2.11 @@ -479,6 +480,8 @@ void __init __start_xen(multiboot_info_t
    2.12      printk("Brought up %ld CPUs\n", (long)num_online_cpus());
    2.13      smp_cpus_done(max_cpus);
    2.14  
    2.15 +    initialise_gdb(); /* could be moved earlier */
    2.16 +
    2.17      do_initcalls();
    2.18  
    2.19      schedulers_start();
     3.1 --- a/xen/common/gdbstub.c	Fri Mar 03 10:46:06 2006 +0100
     3.2 +++ b/xen/common/gdbstub.c	Fri Mar 03 10:53:58 2006 +0100
     3.3 @@ -376,7 +376,6 @@ process_command(struct cpu_user_regs *re
     3.4          break;
     3.5      case 'g': /* Read registers */
     3.6          gdb_arch_read_reg_array(regs, ctx);
     3.7 -        ASSERT(!local_irq_is_enabled());
     3.8          break;
     3.9      case 'G': /* Write registers */
    3.10          gdb_arch_write_reg_array(regs, ctx->in_buf + 1, ctx);
    3.11 @@ -395,7 +394,6 @@ process_command(struct cpu_user_regs *re
    3.12              return 0;
    3.13          }
    3.14          gdb_cmd_read_mem(addr, length, ctx);
    3.15 -        ASSERT(!local_irq_is_enabled());
    3.16          break;
    3.17      case 'M': /* Write memory */
    3.18          addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16);
    3.19 @@ -477,7 +475,7 @@ int
    3.20  {
    3.21      int resume = 0;
    3.22      int r;
    3.23 -    unsigned flags;
    3.24 +    unsigned long flags;
    3.25  
    3.26      if ( gdb_ctx->serhnd < 0 )
    3.27      {
    3.28 @@ -506,7 +504,7 @@ int
    3.29  
    3.30      if ( !gdb_ctx->connected )
    3.31      {
    3.32 -        printk("GDB connection activated\n");
    3.33 +        printk("GDB connection activated.\n");
    3.34          gdb_arch_print_state(regs);
    3.35          gdb_ctx->connected = 1;
    3.36      }
    3.37 @@ -522,7 +520,7 @@ int
    3.38  
    3.39      /* Shouldn't really do this, but otherwise we stop for no
    3.40         obvious reason, which is Bad */
    3.41 -    printk("Waiting for GDB to attach to Gdb\n");
    3.42 +    printk("Waiting for GDB to attach...\n");
    3.43  
    3.44      gdb_arch_enter(regs);
    3.45      gdb_ctx->signum = gdb_arch_signal_num(regs, cookie);
    3.46 @@ -535,9 +533,7 @@ int
    3.47  
    3.48      while ( resume == 0 )
    3.49      {
    3.50 -        ASSERT(!local_irq_is_enabled());
    3.51          r = receive_command(gdb_ctx);
    3.52 -        ASSERT(!local_irq_is_enabled());
    3.53          if ( r < 0 )
    3.54          {
    3.55              dbg_printk("GDB disappeared, trying to resume Xen...\n");
    3.56 @@ -545,9 +541,7 @@ int
    3.57          }
    3.58          else
    3.59          {
    3.60 -            ASSERT(!local_irq_is_enabled());
    3.61              resume = process_command(regs, gdb_ctx);
    3.62 -            ASSERT(!local_irq_is_enabled());
    3.63          }
    3.64      }
    3.65  
    3.66 @@ -561,28 +555,14 @@ int
    3.67      return 0;
    3.68  }
    3.69  
    3.70 -/*
    3.71 - * initialization
    3.72 - * XXX TODO
    3.73 - *     This should be an explicit call from architecture code.               
    3.74 - *     initcall is far too late for some early debugging, and only the 
    3.75 - *     architecture code knows when this call can be made.          
    3.76 - */
    3.77 -static int
    3.78 -initialize_gdb(void)
    3.79 +void
    3.80 +initialise_gdb(void)
    3.81  {
    3.82 -    if ( !strcmp(opt_gdb, "none") )
    3.83 -        return 0;
    3.84      gdb_ctx->serhnd = serial_parse_handle(opt_gdb);
    3.85 -    if ( gdb_ctx->serhnd == -1 )
    3.86 -        panic("Can't parse %s as GDB serial info.\n", opt_gdb);
    3.87 -
    3.88 -    printk("Gdb initialised.\n");
    3.89 -    return 0;
    3.90 +    if ( gdb_ctx->serhnd != -1 )
    3.91 +        printk("GDB stub initialised.\n");
    3.92  }
    3.93  
    3.94 -__initcall(initialize_gdb);
    3.95 -
    3.96  /*
    3.97   * Local variables:
    3.98   * mode: C
     4.1 --- a/xen/include/xen/gdbstub.h	Fri Mar 03 10:46:06 2006 +0100
     4.2 +++ b/xen/include/xen/gdbstub.h	Fri Mar 03 10:53:58 2006 +0100
     4.3 @@ -21,6 +21,8 @@
     4.4  #ifndef __XEN_GDBSTUB_H__
     4.5  #define __XEN_GDBSTUB_H__
     4.6  
     4.7 +#ifdef CRASH_DEBUG
     4.8 +
     4.9  /* value <-> char (de)serialzers for arch specific gdb backends */
    4.10  char hex2char(unsigned long x); 
    4.11  int char2hex(unsigned char c); 
    4.12 @@ -84,6 +86,14 @@ void gdb_arch_exit(struct cpu_user_regs 
    4.13  #define SIGALRM         14
    4.14  #define SIGTERM         15
    4.15  
    4.16 +void initialise_gdb(void);
    4.17 +
    4.18 +#else
    4.19 +
    4.20 +#define initialise_gdb() ((void)0)
    4.21 +
    4.22 +#endif
    4.23 +
    4.24  #endif /* __XEN_GDBSTUB_H__ */
    4.25  
    4.26  /*