ia64/xen-unstable

view xen/include/asm-x86/debugger.h @ 14635:5c52e5ca8459

hvm: Clean up handling of exception intercepts.
Only intercept #DB/#BP if a debugger is attached.
Signed-off-by: Keir Fraser <keir@xensource.com>
author Keir Fraser <keir@xensource.com>
date Wed Mar 28 18:47:17 2007 +0100 (2007-03-28)
parents 74855cdc4a1d
children d4d3b2f1714d
line source
1 /******************************************************************************
2 * asm/debugger.h
3 *
4 * Generic hooks into arch-dependent Xen.
5 *
6 * Each debugger should define two functions here:
7 *
8 * 1. debugger_trap_entry():
9 * Called at start of any synchronous fault or trap, before any other work
10 * is done. The idea is that if your debugger deliberately caused the trap
11 * (e.g. to implement breakpoints or data watchpoints) then you can take
12 * appropriate action and return a non-zero value to cause early exit from
13 * the trap function.
14 *
15 * 2. debugger_trap_fatal():
16 * Called when Xen is about to give up and crash. Typically you will use this
17 * hook to drop into a debug session. It can also be used to hook off
18 * deliberately caused traps (which you then handle and return non-zero).
19 *
20 * 3. debugger_trap_immediate():
21 * Called if we want to drop into a debugger now. This is essentially the
22 * same as debugger_trap_fatal, except that we use the current register state
23 * rather than the state which was in effect when we took the trap.
24 * For example: if we're dying because of an unhandled exception, we call
25 * debugger_trap_fatal; if we're dying because of a panic() we call
26 * debugger_trap_immediate().
27 */
29 #ifndef __X86_DEBUGGER_H__
30 #define __X86_DEBUGGER_H__
32 #include <xen/sched.h>
33 #include <asm/regs.h>
34 #include <asm/processor.h>
36 /* The main trap handlers use these helper macros which include early bail. */
37 #define DEBUGGER_trap_entry(_v, _r) \
38 if ( debugger_trap_entry(_v, _r) ) return EXCRET_fault_fixed;
39 #define DEBUGGER_trap_fatal(_v, _r) \
40 if ( debugger_trap_fatal(_v, _r) ) return EXCRET_fault_fixed;
42 #if defined(CRASH_DEBUG)
44 #include <xen/gdbstub.h>
46 static inline int debugger_trap_fatal(
47 unsigned int vector, struct cpu_user_regs *regs)
48 {
49 int rc = __trap_to_gdb(regs, vector);
50 return ((rc == 0) || (vector == TRAP_int3));
51 }
53 /* Int3 is a trivial way to gather cpu_user_regs context. */
54 #define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
56 #else
58 #define debugger_trap_fatal(v, r) (0)
59 #define debugger_trap_immediate() ((void)0)
61 #endif
63 static inline int debugger_trap_entry(
64 unsigned int vector, struct cpu_user_regs *regs)
65 {
66 struct vcpu *v = current;
68 if ( guest_kernel_mode(v, regs) && v->domain->debugger_attached &&
69 ((vector == TRAP_int3) || (vector == TRAP_debug)) )
70 {
71 domain_pause_for_debugger();
72 return 1;
73 }
75 return 0;
76 }
78 #endif /* __X86_DEBUGGER_H__ */