ia64/xen-unstable

view xen/include/asm-x86/debugger.h @ 4730:2621a06f6d37

bitkeeper revision 1.1389.1.26 (42764ebcQUGB5SU0NuOL0gHMTOa--A)

Fix int3 handling in cdb. They're harmless.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon May 02 16:01:00 2005 +0000 (2005-05-02)
parents 604df558b783
children 79b7835ac75d f0d5219e295c 487de0451d2b
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 <asm/processor.h>
35 /* The main trap handlers use these helper macros which include early bail. */
36 #define DEBUGGER_trap_entry(_v, _r) \
37 if ( debugger_trap_entry(_v, _r) ) return EXCRET_fault_fixed;
38 #define DEBUGGER_trap_fatal(_v, _r) \
39 if ( debugger_trap_fatal(_v, _r) ) return EXCRET_fault_fixed;
41 #if defined(CRASH_DEBUG)
43 extern int __trap_to_cdb(struct cpu_user_regs *r);
44 #define debugger_trap_entry(_v, _r) (0)
46 static inline int debugger_trap_fatal(
47 unsigned int vector, struct cpu_user_regs *regs)
48 {
49 (void)__trap_to_cdb(regs);
50 return (vector == TRAP_int3); /* int3 is harmless */
51 }
53 /* Int3 is a trivial way to gather cpu_user_regs context. */
54 #define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
56 #elif defined(DOMU_DEBUG)
58 #include <xen/softirq.h>
60 static inline int debugger_trap_entry(
61 unsigned int vector, struct cpu_user_regs *regs)
62 {
63 struct exec_domain *ed = current;
65 if ( !KERNEL_MODE(ed, regs) || (ed->domain->id == 0) )
66 return 0;
68 switch ( vector )
69 {
70 case TRAP_int3:
71 case TRAP_debug:
72 set_bit(EDF_CTRLPAUSE, &ed->ed_flags);
73 raise_softirq(SCHEDULE_SOFTIRQ);
74 return 1;
75 }
77 return 0;
78 }
80 #define debugger_trap_fatal(_v, _r) (0)
81 #define debugger_trap_immediate()
84 #elif 0
86 extern int kdb_trap(int, int, struct cpu_user_regs *);
88 static inline int debugger_trap_entry(
89 unsigned int vector, struct cpu_user_regs *regs)
90 {
91 return 0;
92 }
94 static inline int debugger_trap_fatal(
95 unsigned int vector, struct cpu_user_regs *regs)
96 {
97 return kdb_trap(vector, 0, regs);
98 }
100 #else
102 #define debugger_trap_entry(_v, _r) (0)
103 #define debugger_trap_fatal(_v, _r) (0)
104 #define debugger_trap_immediate()
106 #endif
108 #endif /* __X86_DEBUGGER_H__ */