slirp: add a callback to log guest errors
[qemu/ar7.git] / slirp / debug.h
blobca3a4b04dae2c6094d894ab49fe2048e22e531f0
1 /*
2 * Copyright (c) 1995 Danny Gasparovski.
4 * Please read the file COPYRIGHT for the
5 * terms and conditions of the copyright.
6 */
8 //#define DEBUG 1
10 #ifdef DEBUG
12 #define DBG_CALL 0x1
13 #define DBG_MISC 0x2
14 #define DBG_ERROR 0x4
16 #define dfd stderr
18 extern int slirp_debug;
20 #define DEBUG_CALL(fmt, ...) do { \
21 if (slirp_debug & DBG_CALL) { \
22 fprintf(dfd, fmt, ##__VA_ARGS__); \
23 fprintf(dfd, "...\n"); \
24 fflush(dfd); \
25 } \
26 } while (0)
28 #define DEBUG_ARG(fmt, ...) do { \
29 if (slirp_debug & DBG_CALL) { \
30 fputc(' ', dfd); \
31 fprintf(dfd, fmt, ##__VA_ARGS__); \
32 fputc('\n', dfd); \
33 fflush(dfd); \
34 } \
35 } while (0)
37 #define DEBUG_ARGS(fmt, ...) DEBUG_ARG(fmt, ##__VA_ARGS__)
39 #define DEBUG_MISC(fmt, ...) do { \
40 if (slirp_debug & DBG_MISC) { \
41 fprintf(dfd, fmt, ##__VA_ARGS__); \
42 fflush(dfd); \
43 } \
44 } while (0)
46 #define DEBUG_ERROR(fmt, ...) do { \
47 if (slirp_debug & DBG_ERROR) { \
48 fprintf(dfd, fmt, ##__VA_ARGS__); \
49 fflush(dfd); \
50 } \
51 } while (0)
53 #else
55 #define DEBUG_CALL(fmt, ...)
56 #define DEBUG_ARG(fmt, ...)
57 #define DEBUG_ARGS(fmt, ...)
58 #define DEBUG_MISC(fmt, ...)
59 #define DEBUG_ERROR(fmt, ...)
61 #endif