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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
#ifndef __PRACRO_DEBUG_H__
#define __PRACRO_DEBUG_H__
#include <stdarg.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#ifdef USE_EFENCE
#include <new>
#include <stdlib.h>
#include <efencepp.h>
#include <efence.h>
#endif
#endif
void pracro_debug_init(void);
void pracro_debug_parse(const char *fmt);
enum __pracro_debug_class
{
__pracro_class_fixme,
__pracro_class_info,
__pracro_class_warn,
__pracro_class_err,
__pracro_class_debug
};
#ifndef __GNUC__
#error "Need gcc for special debug macro expansions. Please define for other compilers."
#endif
#ifdef WITH_DEBUG
int __pracro_debug(const char *func, const int line, enum __pracro_debug_class cl, const char *ch, const char *fmt, ...) __attribute__((format (printf,5,6)));
int __pracro_debug_va(const char *func, const int line, enum __pracro_debug_class cl, const char *ch, const char *fmt, va_list va);
#define __PRACRO_DEBUG_PRINT(cl, ch, fmt...) \
do { __pracro_debug(__func__, __LINE__, cl, ch, fmt); } while(0)
#define __PRACRO_DEBUG_PRINT_VA(cl, ch, fmt, a) \
do { __pracro_debug_va(__func__, __LINE__, cl, ch, fmt, a); } while(0)
#define __PRACRO_DEBUG(cl, ch, fmt...) __PRACRO_DEBUG_PRINT(__pracro_class##cl, #ch, fmt)
#define __PRACRO_DEBUG_VA(cl, ch, fmt, a) __PRACRO_DEBUG_PRINT_VA(__pracro_class##cl, #ch, fmt, a)
#define PRACRO_FIXME(ch, fmt...) __PRACRO_DEBUG(_fixme, ch, fmt)
#define PRACRO_INFO(ch, fmt...) __PRACRO_DEBUG(_info, ch, fmt)
#define PRACRO_WARN(ch, fmt...) __PRACRO_DEBUG(_warn, ch, fmt)
#define PRACRO_ERR(ch, fmt...) __PRACRO_DEBUG(_err, ch, fmt)
#define PRACRO_DEBUG(ch, fmt...) __PRACRO_DEBUG(_debug, ch, fmt)
#define PRACRO_FIXME_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_fixme, ch, fmt, a)
#define PRACRO_INFO_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_info, ch, fmt, a)
#define PRACRO_WARN_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_warn, ch, fmt, a)
#define PRACRO_ERR_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_err, ch, fmt, a)
#define PRACRO_DEBUG_VA(ch, fmt, a) __PRACRO_DEBUG_VA(_debug, ch, fmt, a)
#define PRACRO_INFO_LOG(ch, fmt...) PRACRO_INFO(ch, fmt)
#define PRACRO_WARN_LOG(ch, fmt...) PRACRO_WARN(ch, fmt)
#define PRACRO_ERR_LOG(ch, fmt...) PRACRO_ERR(ch, fmt)
#define PRACRO_INFO_LOG_VA(ch, fmt, a) PRACRO_INFO_VA(ch, fmt, a)
#define PRACRO_WARN_LOG_VA(ch, fmt, a) PRACRO_WARN_VA(ch, fmt, a)
#define PRACRO_ERR_LOG_VA(ch, fmt, a) PRACRO_ERR_VA(ch, fmt, a)
#else
#define PRACRO_FIXME(ch, fmt...)
#define PRACRO_INFO(ch, fmt...)
#define PRACRO_WARN(ch, fmt...)
#define PRACRO_ERR(ch, fmt...)
#define PRACRO_DEBUG(ch, fmt...)
#define PRACRO_FIXME_VA(ch, fmt...)
#define PRACRO_INFO_VA(ch, fmt...)
#define PRACRO_WARN_VA(ch, fmt...)
#define PRACRO_ERR_VA(ch, fmt...)
#define PRACRO_DEBUG_VA(ch, fmt...)
int __pracro_log(const char *func, const int line, enum __pracro_debug_class cl, const char *ch, const char *fmt, ...) __attribute__((format (printf,5,6)));
int __pracro_log_va(const char *func, const int line, enum __pracro_debug_class cl, const char *ch, const char *fmt, va_list va);
#define __PRACRO_LOG_PRINT(cl, ch, fmt...) \
do { __pracro_log(__func__, __LINE__, cl, ch, fmt); } while(0)
#define __PRACRO_LOG_PRINT_VA(cl, ch, fmt, a) \
do { __pracro_log_va(__func__, __LINE__, cl, ch, fmt, a); } while(0)
#define __PRACRO_LOG(cl, ch, fmt...) __PRACRO_LOG_PRINT(__pracro_class##cl, #ch, fmt)
#define __PRACRO_LOG_VA(cl, ch, fmt, a) __PRACRO_LOG_PRINT_VA(__pracro_class##cl, #ch, fmt, a)
#define PRACRO_INFO_LOG(ch, fmt...) __PRACRO_LOG(_info, ch, fmt)
#define PRACRO_WARN_LOG(ch, fmt...) __PRACRO_LOG(_warn, ch, fmt)
#define PRACRO_ERR_LOG(ch, fmt...) __PRACRO_LOG(_err, ch, fmt)
#define PRACRO_INFO_LOG_VA(ch, fmt, a) __PRACRO_LOG_VA(_info, ch, fmt, a)
#define PRACRO_WARN_LOG_VA(ch, fmt, a) __PRACRO_LOG_VA(_warn, ch, fmt, a)
#define PRACRO_ERR_LOG_VA(ch, fmt, a) __PRACRO_LOG_VA(_err, ch, fmt, a)
#endif
#endif
|