ia64/xen-unstable

changeset 2957:257ef1dc1ed4

bitkeeper revision 1.1159.172.5 (4194efbdtn0wkhatZ5h3AhSTCQkn2g)

Add hooks for debuggers.
author cl349@freefall.cl.cam.ac.uk
date Fri Nov 12 17:15:41 2004 +0000 (2004-11-12)
parents 03f1a1522408
children 5f89e32f3e9d 9496b19804ae
files .rootkeys xen/arch/x86/traps.c xen/include/xen/debugger_hooks.h
line diff
     1.1 --- a/.rootkeys	Fri Nov 12 16:35:25 2004 +0000
     1.2 +++ b/.rootkeys	Fri Nov 12 17:15:41 2004 +0000
     1.3 @@ -762,6 +762,7 @@ 3f840f12CkbYSlwMrY2S11Mpyxg7Nw xen/inclu
     1.4  3ddb79c259jh8hE7vre_8NuE7nwNSA xen/include/xen/config.h
     1.5  3eb165e0eawr3R-p2ZQtSdLWtLRN_A xen/include/xen/console.h
     1.6  3ddb79c1V44RD26YqCUm-kqIupM37A xen/include/xen/ctype.h
     1.7 +4194efbdvxUXjCLobbopgLOojisO4Q xen/include/xen/debugger_hooks.h
     1.8  3ddb79c05DdHQ0UxX_jKsXdR4QlMCA xen/include/xen/delay.h
     1.9  3ddb79c2O729EttZTYu1c8LcsUO_GQ xen/include/xen/elf.h
    1.10  3ddb79c0HIghfBF8zFUdmXhOU8i6hA xen/include/xen/errno.h
     2.1 --- a/xen/arch/x86/traps.c	Fri Nov 12 16:35:25 2004 +0000
     2.2 +++ b/xen/arch/x86/traps.c	Fri Nov 12 17:15:41 2004 +0000
     2.3 @@ -51,6 +51,7 @@
     2.4  #include <asm/uaccess.h>
     2.5  #include <asm/i387.h>
     2.6  #include <asm/pdb.h>
     2.7 +#include <xen/debugger_hooks.h>
     2.8  
     2.9  extern char opt_nmi[];
    2.10  
    2.11 @@ -243,6 +244,9 @@ static inline void do_trap(int trapnr, c
    2.12          return;
    2.13      }
    2.14  
    2.15 +    if (debugger_trap(trapnr, regs))
    2.16 +	return;
    2.17 +
    2.18      show_registers(regs);
    2.19      panic("CPU%d FATAL TRAP: vector = %d (%s)\n"
    2.20            "[error_code=%08x]\n",
    2.21 @@ -280,10 +284,8 @@ asmlinkage void do_int3(struct xen_regs 
    2.22      struct guest_trap_bounce *gtb = guest_trap_bounce+smp_processor_id();
    2.23      trap_info_t *ti;
    2.24  
    2.25 -#ifdef XEN_DEBUGGER
    2.26 -    if ( pdb_initialized && pdb_handle_exception(3, regs) == 0 )
    2.27 +    if (debugger_trap(3, regs))
    2.28          return;
    2.29 -#endif
    2.30  
    2.31      if ( (regs->cs & 3) != 3 )
    2.32      {
    2.33 @@ -329,6 +331,8 @@ asmlinkage void do_double_fault(void)
    2.34      printk("System needs manual reset.\n");
    2.35      printk("************************************\n");
    2.36  
    2.37 +    debugger_trap(8, NULL);
    2.38 +
    2.39      /* Lock up the console to prevent spurious output from other CPUs. */
    2.40      console_force_lock();
    2.41  
    2.42 @@ -406,6 +410,9 @@ asmlinkage void do_page_fault(struct xen
    2.43          return;
    2.44      }
    2.45  
    2.46 +    if (debugger_trap(14, regs))
    2.47 +	return;
    2.48 +
    2.49      if ( addr >= PAGE_OFFSET )
    2.50      {
    2.51          unsigned long page;
    2.52 @@ -423,17 +430,6 @@ asmlinkage void do_page_fault(struct xen
    2.53  #endif
    2.54      }
    2.55  
    2.56 -#ifdef XEN_DEBUGGER
    2.57 -    if ( pdb_page_fault_possible )
    2.58 -    {
    2.59 -        pdb_page_fault = 1;
    2.60 -        /* make eax & edx valid to complete the instruction */
    2.61 -        regs->eax = (long)&pdb_page_fault_scratch;
    2.62 -        regs->edx = (long)&pdb_page_fault_scratch;
    2.63 -        return;
    2.64 -    }
    2.65 -#endif
    2.66 -
    2.67      show_registers(regs);
    2.68      panic("CPU%d FATAL PAGE FAULT\n"
    2.69            "[error_code=%08x]\n"
    2.70 @@ -520,6 +516,9 @@ asmlinkage void do_general_protection(st
    2.71          return;
    2.72      }
    2.73  
    2.74 +    if (debugger_trap(13, regs))
    2.75 +	return;
    2.76 +
    2.77      die("general protection fault", regs, error_code);
    2.78  }
    2.79  
    2.80 @@ -565,6 +564,9 @@ asmlinkage void io_check_error(struct xe
    2.81  
    2.82  static void unknown_nmi_error(unsigned char reason, struct xen_regs * regs)
    2.83  {
    2.84 +    if (debugger_trap(2, regs))
    2.85 +	return;
    2.86 +
    2.87      printk("Uhhuh. NMI received for unknown reason %02x.\n", reason);
    2.88      printk("Dazed and confused, but trying to continue\n");
    2.89      printk("Do you have a strange power saving mode enabled?\n");
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/include/xen/debugger_hooks.h	Fri Nov 12 17:15:41 2004 +0000
     3.3 @@ -0,0 +1,37 @@
     3.4 +
     3.5 +#ifndef __DEBUGGER_HOOKS_H__
     3.6 +#define __DEBUGGER_HOOKS_H__
     3.7 +
     3.8 +static inline int debugger_trap(int type, struct xen_regs *regs)
     3.9 +{
    3.10 +    int ret = 0;
    3.11 +
    3.12 +#ifdef XEN_DEBUGGER
    3.13 +    switch (type) {
    3.14 +    case 3:
    3.15 +        if ( pdb_initialized && pdb_handle_exception(type, regs) == 0 )
    3.16 +            return 1;
    3.17 +        break;
    3.18 +    case 14:
    3.19 +        if ( pdb_page_fault_possible )
    3.20 +        {
    3.21 +            pdb_page_fault = 1;
    3.22 +            /* make eax & edx valid to complete the instruction */
    3.23 +            regs->eax = (long)&pdb_page_fault_scratch;
    3.24 +            regs->edx = (long)&pdb_page_fault_scratch;
    3.25 +            return 1;
    3.26 +        }
    3.27 +        break;
    3.28 +    }
    3.29 +#endif
    3.30 +
    3.31 +#if 0
    3.32 +    extern int kdb_trap(int, int, struct xen_regs *);
    3.33 +    if ((ret = kdb_trap(type, 0, regs)))
    3.34 +        return ret;
    3.35 +#endif
    3.36 +
    3.37 +    return ret;
    3.38 +}
    3.39 +
    3.40 +#endif /* __DEBUGGER_HOOKS_H__ */