-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrace_utils.h
More file actions
39 lines (36 loc) · 1.99 KB
/
trace_utils.h
File metadata and controls
39 lines (36 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "trace.h"
/// Sends @c SIGABRT to the process, then loops forever.
/// This function is necessary because plain @c abort() unblocks SIGABRT,
/// making it impossible to guarantee signal delivery to a specific thread.
static void myabort () {
kill (getpid (), SIGABRT);
for (;;) pause ();
}
#define ASSERT( cond ) TRACE_ASSERT (cond, myabort ());
#define ENSURE_SYSCALL( syscall, args ) \
do { \
if (-1 == (syscall args)) { \
TRACE_PERROR (TRACE_FATAL, #syscall); myabort (); \
} \
} while (0)
#define ENSURE_SYSCALL_AND_SAVE( syscall, args, rc ) \
do { \
if (-1 == (rc = (syscall args))) { \
TRACE_PERROR (TRACE_FATAL, #syscall); myabort (); \
} \
} while (0)
// E.g. ENSURE_CALL (myfun, (arg1, arg2) != 0)
#define ENSURE_CALL( call, args) \
do { \
if (call args) { \
TRACE (TRACE_FATAL, #call " failed (%s:%d)", __FILE__, __LINE__); \
myabort (); \
} \
} while (0)
#define ENSURE_CALL_AND_SAVE( call, args, rc, bad ) \
do { \
if (bad == (rc = (call args))) { \
TRACE (TRACE_FATAL, #call " failed (%s:%d)", __FILE__, __LINE__); \
abort (); \
} \
} while (0)