FreeBSD/Linux Kernel Cross Reference
sys/kernel/debug.h
1 #ifndef DEBUG_H
2 #define DEBUG_H
3
4 /* This header file defines all debugging constants and macros, and declares
5 * some variables. Certain debugging features redefine standard constants
6 * and macros. Therefore, this header file should be included after the
7 * other kernel headers.
8 */
9
10 #include "config.h"
11
12 /* It's interesting to measure the time spent withing locked regions, because
13 * this is the time that the system is deaf to interrupts.
14 */
15 #if DEBUG_TIME_LOCKS
16
17 #define TIMING_POINTS 20 /* timing resolution */
18 #define TIMING_CATEGORIES 20
19 #define TIMING_NAME 10
20
21 /* Enable prints such as
22 * . send/receive failed due to deadlock or dead source or dead destination
23 * . trap not allowed
24 * . bogus message pointer
25 * . kernel call number not allowed by this process
26 *
27 * Of course the call still fails, but nothing is printed if these warnings
28 * are disabled.
29 */
30 #define DEBUG_ENABLE_IPC_WARNINGS 0
31
32 /* Definition of the data structure to store lock() timing data. */
33 struct lock_timingdata {
34 char names[TIMING_NAME];
35 unsigned long lock_timings[TIMING_POINTS];
36 unsigned long lock_timings_range[2];
37 unsigned long binsize, resets, misses, measurements;
38 };
39
40 /* The data is declared here, but allocated in debug.c. */
41 extern struct lock_timingdata timingdata[TIMING_CATEGORIES];
42
43 /* Prototypes for the timing functionality. */
44 _PROTOTYPE( void timer_start, (int cat, char *name) );
45 _PROTOTYPE( void timer_end, (int cat) );
46
47 #define locktimestart(c, v) timer_start(c, v)
48 #define locktimeend(c) timer_end(c)
49 #else
50 #define locktimestart(c, v)
51 #define locktimeend(c)
52 #endif /* DEBUG_TIME_LOCKS */
53
54 /* The locking checks counts relocking situation, which are dangerous because
55 * the inner lock may unlock the outer one.
56 */
57 #if DEBUG_LOCK_CHECK
58 #define lockcheck if (!(read_cpu_flags() & X86_FLAG_I)) kinfo.relocking++;
59 #else
60 #define lockcheck
61 #endif /* DEBUG_LOCK_CHECK */
62
63 /* This check makes sure that the scheduling queues are in a consistent state.
64 * The check is run when the queues are updated with ready() and unready().
65 */
66 #if DEBUG_SCHED_CHECK
67 _PROTOTYPE( void check_runqueues, (char *when) );
68 #endif /* DEBUG_SCHED_CHECK */
69
70 /* The timing and checking of kernel locking requires a redefine of the lock()
71 * and unlock() macros. That's done here. This redefine requires that this
72 * header is included after the other kernel headers.
73 */
74 #if (DEBUG_TIME_LOCKS || DEBUG_LOCK_CHECK)
75 # undef lock
76 # define lock(c, v) do { lockcheck; \
77 intr_disable(); \
78 locktimestart(c, v); \
79 } while(0)
80 # undef unlock
81 # define unlock(c) do { locktimeend(c); \
82 intr_enable();\
83 } while(0)
84 #endif
85
86 #endif /* DEBUG_H */
Cache object: 027799a2b3ef53df0845aee7173bd878
|