9 #define ALIGNED(n) __attribute__((__aligned__(n)))
10 #define VASSERT_TRIGGER_OFFSET 1221
11 #define VASSERT_PAGE_SIZE 4096
13 /* Need to align at 4K. */
14 /* Ensure the inReplay flag is on its own page. */
16 typedef struct VAssert_StateWrapper
{
17 char space1
[VASSERT_TRIGGER_OFFSET
];
18 volatile char inReplay
;
19 char space
[VASSERT_PAGE_SIZE
- VASSERT_TRIGGER_OFFSET
- sizeof(char)];
20 } VAssert_StateWrapper
;
23 extern VAssert_StateWrapper vassert_state
;
26 * User-selectable standard functions.
27 * XXX: Document these, in coordination with the SDK docs.
30 #if defined(__KERNEL__)
31 # define KERNEL_VASSERT
36 # ifndef VASSERT_CUSTOM_ASSERT
37 # define VASSERT_CUSTOM_ASSERT(expr)
40 # ifndef VASSERT_CUSTOM_ABORT
41 # include <linux/kernel.h>
42 # define VASSERT_CUSTOM_ABORT() ((void)0) // printk(KERN_ALERT"VAssert abort at %s: %d", __FILE__, __LINE__)
45 # ifndef VASSERT_CUSTOM_LOG
46 # include <linux/kernel.h>
47 # define VASSERT_CUSTOM_LOG printk
51 # ifndef VASSERT_CUSTOM_ASSERT
53 # define VASSERT_CUSTOM_ASSERT assert
56 # ifndef VASSERT_CUSTOM_ABORT
58 # define VASSERT_CUSTOM_ABORT abort
61 # ifndef VASSERT_CUSTOM_LOG
63 # define VASSERT_CUSTOM_LOG printf
67 /* Results: 0 if successful, -1 if not. */
68 // XXX need to automatic de-register trigger page when the program quits
69 extern char VAssert_Init(void);
70 extern char VAssert_Uninit(void);
73 * These functions should not be called directly; they need to be wrapped.
75 extern void VAssert_LogMain(const char *format
, ...);
76 extern void VAssert_GoLiveMain(void);
77 extern void VAssert_ReturnToReplayMain(void);
78 extern char VAssert_Trace(size_t max_size
);
80 #ifdef VASSERT_ALWAYS_EXECUTE
82 #define VAssert_Assert(expr) \
84 VASSERT_CUSTOM_ASSERT(expr); \
87 #define VAssert_Log(args) \
89 VASSERT_CUSTOM_LOG args; \
92 #define VAssert_BeginBlock
93 #define VAssert_EndBlock
95 #else /* VASSERT_ALWAYS_EXECUTE */
97 #define VAssert_Assert(expr) \
99 if (vassert_state.inReplay) { \
101 VAssert_GoLiveMain(); \
102 VASSERT_CUSTOM_ABORT(); \
104 VAssert_ReturnToReplayMain(); \
109 #define VAssert_Log(args) \
111 if (vassert_state.inReplay) { \
112 VAssert_LogMain args; \
113 VAssert_ReturnToReplayMain(); \
117 #define VAssert_BeginBlock if (vassert_state.inReplay)
118 #define VAssert_EndBlock VAssert_ReturnToReplayMain()
120 #endif /* VASSERT_ALWAYS_EXECUTE */
123 * Record/Replay functionality
126 * Results: True if successful, false if not.
127 * Input: True to start recording, false to stop.
129 extern char VAssert_SetRecordingMain(char start
);
131 #define VAssert_StartRecording() VAssert_SetRecordingMain(1)
132 #define VAssert_StopRecording() VAssert_SetRecordingMain(0)
136 #endif /*__cplusplus*/
138 #endif /*_VASSERT_H_*/