ia64/xen-unstable

view xen/include/asm-x86/debugger.h @ 8400:6b1d39a56c2b

Add debugging flag for domains to make domu debugging a run-time option
Signed-off-by: Kip Macy kmacy@fsmware.ckm
author kaf24@firebug.cl.cam.ac.uk
date Thu Dec 15 21:50:12 2005 +0100 (2005-12-15)
parents fb827128345c
children 1b839e1b1de1
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 * but really these should be hooked off 'debugger_trap_entry'.
20 *
21 * 3. debugger_trap_immediate():
22 * Called if we want to drop into a debugger now. This is essentially the
23 * same as debugger_trap_fatal, except that we use the current register state
24 * rather than the state which was in effect when we took the trap.
25 * Essentially, if we're dying because of an unhandled exception, we call
26 * debugger_trap_fatal; if we're dying because of a panic() we call
27 * debugger_trap_immediate().
28 */
30 #ifndef __X86_DEBUGGER_H__
31 #define __X86_DEBUGGER_H__
33 #include <xen/sched.h>
34 #include <asm/regs.h>
35 #include <asm/processor.h>
37 /* The main trap handlers use these helper macros which include early bail. */
38 #define DEBUGGER_trap_entry(_v, _r) \
39 if ( debugger_trap_entry(_v, _r) ) return EXCRET_fault_fixed;
40 #define DEBUGGER_trap_fatal(_v, _r) \
41 if ( debugger_trap_fatal(_v, _r) ) return EXCRET_fault_fixed;
43 #if defined(CRASH_DEBUG)
45 extern int __trap_to_cdb(struct cpu_user_regs *r);
47 #define __debugger_trap_entry(_v, _r) (0)
49 static inline int __debugger_trap_fatal(
50 unsigned int vector, struct cpu_user_regs *regs)
51 {
52 (void)__trap_to_cdb(regs);
53 return (vector == TRAP_int3); /* int3 is harmless */
54 }
56 /* Int3 is a trivial way to gather cpu_user_regs context. */
57 #define __debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
59 #elif 0
61 extern int kdb_trap(int, int, struct cpu_user_regs *);
63 static inline int __debugger_trap_entry(
64 unsigned int vector, struct cpu_user_regs *regs)
65 {
66 return 0;
67 }
69 static inline int __debugger_trap_fatal(
70 unsigned int vector, struct cpu_user_regs *regs)
71 {
72 return kdb_trap(vector, 0, regs);
73 }
75 /* Int3 is a trivial way to gather cpu_user_regs context. */
76 #define __debugger_trap_immediate() __asm__ __volatile__ ( "int3" )
78 #else
80 #define __debugger_trap_entry(_v, _r) (0)
81 #define __debugger_trap_fatal(_v, _r) (0)
82 #define __debugger_trap_immediate() ((void)0)
84 #endif
86 static inline int debugger_trap_entry(
87 unsigned int vector, struct cpu_user_regs *regs)
88 {
89 struct vcpu *v = current;
91 if ( KERNEL_MODE(v, regs) &&
92 test_bit(_DOMF_debugging, &v->domain->domain_flags) &&
93 ((vector == TRAP_int3) || (vector == TRAP_debug)) )
94 {
95 domain_pause_for_debugger();
96 return 1;
97 }
99 return __debugger_trap_entry(vector, regs);
100 }
102 #define debugger_trap_fatal(v, r) (__debugger_trap_fatal(v, r))
103 #define debugger_trap_immediate() (__debugger_trap_immediate())
105 #endif /* __X86_DEBUGGER_H__ */