disassembler: fix bug omitting exported vars not used in module
[rofl0r-agsutils.git] / debug.h
blob5620bde74def36d5e986ab8716b86a8822696050
1 #ifndef DEBUG_H
2 #define DEBUG_H
4 #define empty_body do {} while(0)
5 #if defined(__x86_64) || defined(__x86_64__)
6 # define INTEL_CPU 64
7 #elif defined(__x86) || defined(__x86__) || defined(__i386) || defined(__i386__)
8 # define INTEL_CPU 32
9 #endif
11 //#define NO_BREAKPOINTS
12 #ifdef NO_BREAKPOINTS
13 # define breakpoint() empty_body
14 #else
15 # ifdef INTEL_CPU
16 # define breakpoint() __asm__("int3")
17 # else
18 # include <signal.h>
19 # include <unistd.h>
20 # define breakpoint() kill(getpid(), SIGTRAP)
21 # endif
22 #endif
24 //#define NO_ASSERT
25 #ifdef NO_ASSERT
26 # define assert_dbg(exp) empty_body
27 # define assert_lt(exp) empty_body
28 # define assert_lte(exp) empty_body
29 # define assert(x) empty_body
30 #else
31 # include <stdio.h>
32 # define assert_dbg(exp) do { if (!(exp)) breakpoint(); } while(0)
33 # define assert_op(val, op, max) do { if(!((val) op (max))) { \
34 fprintf(stderr, "[%s:%d] %s: assert failed: %s < %s\n", \
35 __FILE__, __LINE__, __FUNCTION__, # val, # max); \
36 breakpoint();}} while(0)
38 # define assert_lt (val, max) assert_op(val, <, max)
39 # define assert_lte(val, max) assert_op(val, <= ,max)
40 #endif
42 #endif