ia64/xen-unstable

changeset 11649:d78b31dd07e8

[XEN] gdbstub return value is used to determine whether or not
to continue execution.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Sep 27 14:28:26 2006 +0100 (2006-09-27)
parents ed8f53f81e6e
children 000aa9510e55
files xen/common/gdbstub.c xen/include/asm-x86/debugger.h
line diff
     1.1 --- a/xen/common/gdbstub.c	Wed Sep 27 14:01:30 2006 +0100
     1.2 +++ b/xen/common/gdbstub.c	Wed Sep 27 14:28:26 2006 +0100
     1.3 @@ -506,14 +506,13 @@ gdbstub_console_puts(const char *str)
     1.4  int 
     1.5  __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie)
     1.6  {
     1.7 -    int resume = 0;
     1.8 -    int r;
     1.9 +    int rc = 0;
    1.10      unsigned long flags;
    1.11  
    1.12      if ( gdb_ctx->serhnd < 0 )
    1.13      {
    1.14          dbg_printk("Debugger not ready yet.\n");
    1.15 -        return 0;
    1.16 +        return -EBUSY;
    1.17      }
    1.18  
    1.19      /* We rely on our caller to ensure we're only on one processor
    1.20 @@ -532,7 +531,7 @@ int
    1.21      {
    1.22          printk("WARNING WARNING WARNING: Avoiding recursive gdb.\n");
    1.23          atomic_inc(&gdb_ctx->running);
    1.24 -        return 0;
    1.25 +        return -EBUSY;
    1.26      }
    1.27  
    1.28      if ( !gdb_ctx->connected )
    1.29 @@ -565,19 +564,14 @@ int
    1.30          gdb_cmd_signum(gdb_ctx);
    1.31      }
    1.32  
    1.33 -    while ( resume == 0 )
    1.34 -    {
    1.35 -        r = receive_command(gdb_ctx);
    1.36 -        if ( r < 0 )
    1.37 +    do {
    1.38 +        if ( receive_command(gdb_ctx) < 0 )
    1.39          {
    1.40 -            dbg_printk("GDB disappeared, trying to resume Xen...\n");
    1.41 -            resume = 1;
    1.42 +            dbg_printk("Error in GDB session...\n");
    1.43 +            rc = -EIO;
    1.44 +            break;
    1.45          }
    1.46 -        else
    1.47 -        {
    1.48 -            resume = process_command(regs, gdb_ctx);
    1.49 -        }
    1.50 -    }
    1.51 +    } while ( process_command(regs, gdb_ctx) == 0 );
    1.52  
    1.53      gdb_arch_exit(regs);
    1.54      console_end_sync();
    1.55 @@ -586,7 +580,7 @@ int
    1.56  
    1.57      local_irq_restore(flags);
    1.58  
    1.59 -    return 0;
    1.60 +    return rc;
    1.61  }
    1.62  
    1.63  void
     2.1 --- a/xen/include/asm-x86/debugger.h	Wed Sep 27 14:01:30 2006 +0100
     2.2 +++ b/xen/include/asm-x86/debugger.h	Wed Sep 27 14:28:26 2006 +0100
     2.3 @@ -15,14 +15,13 @@
     2.4   * 2. debugger_trap_fatal():
     2.5   *  Called when Xen is about to give up and crash. Typically you will use this
     2.6   *  hook to drop into a debug session. It can also be used to hook off
     2.7 - *  deliberately caused traps (which you then handle and return non-zero)
     2.8 - *  but really these should be hooked off 'debugger_trap_entry'.
     2.9 + *  deliberately caused traps (which you then handle and return non-zero).
    2.10   *
    2.11   * 3. debugger_trap_immediate():
    2.12   *  Called if we want to drop into a debugger now.  This is essentially the
    2.13   *  same as debugger_trap_fatal, except that we use the current register state
    2.14   *  rather than the state which was in effect when we took the trap.
    2.15 - *  Essentially, if we're dying because of an unhandled exception, we call
    2.16 + *  For example: if we're dying because of an unhandled exception, we call
    2.17   *  debugger_trap_fatal; if we're dying because of a panic() we call
    2.18   *  debugger_trap_immediate().
    2.19   */
    2.20 @@ -44,42 +43,19 @@
    2.21  
    2.22  #include <xen/gdbstub.h>
    2.23  
    2.24 -#define __debugger_trap_entry(_v, _r) (0)
    2.25 -
    2.26 -static inline int __debugger_trap_fatal(
    2.27 +static inline int debugger_trap_fatal(
    2.28      unsigned int vector, struct cpu_user_regs *regs)
    2.29  {
    2.30 -    (void)__trap_to_gdb(regs, vector);
    2.31 -    return (vector == TRAP_int3); /* int3 is harmless */
    2.32 +    return (__trap_to_gdb(regs, vector) == 0);
    2.33  }
    2.34  
    2.35  /* Int3 is a trivial way to gather cpu_user_regs context. */
    2.36  #define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
    2.37  
    2.38 -#elif 0
    2.39 -
    2.40 -extern int kdb_trap(int, int, struct cpu_user_regs *);
    2.41 -
    2.42 -static inline int __debugger_trap_entry(
    2.43 -    unsigned int vector, struct cpu_user_regs *regs)
    2.44 -{
    2.45 -    return 0;
    2.46 -}
    2.47 -
    2.48 -static inline int __debugger_trap_fatal(
    2.49 -    unsigned int vector, struct cpu_user_regs *regs)
    2.50 -{
    2.51 -    return kdb_trap(vector, 0, regs);
    2.52 -}
    2.53 -
    2.54 -/* Int3 is a trivial way to gather cpu_user_regs context. */
    2.55 -#define debugger_trap_immediate() __asm__ __volatile__ ( "int3" )
    2.56 -
    2.57  #else
    2.58  
    2.59 -#define __debugger_trap_entry(_v, _r) (0)
    2.60 -#define __debugger_trap_fatal(_v, _r) (0)
    2.61 -#define __debugger_trap_immediate()   ((void)0)
    2.62 +#define debugger_trap_fatal(v, r) (0)
    2.63 +#define debugger_trap_immediate() ((void)0)
    2.64  
    2.65  #endif
    2.66  
    2.67 @@ -96,12 +72,7 @@ static inline int debugger_trap_entry(
    2.68          return 1;
    2.69      }
    2.70  
    2.71 -    return __debugger_trap_entry(vector, regs);
    2.72 +    return 0;
    2.73  }
    2.74  
    2.75 -#define debugger_trap_fatal(v, r) (__debugger_trap_fatal(v, r))
    2.76 -#ifndef debugger_trap_immediate
    2.77 -#define debugger_trap_immediate() (__debugger_trap_immediate())
    2.78 -#endif
    2.79 -
    2.80  #endif /* __X86_DEBUGGER_H__ */