Dillo v3.1.1-99-gf3103cc4
Loading...
Searching...
No Matches
debug.hh
Go to the documentation of this file.
1#ifndef __LOUT_DEBUG_H__
2#define __LOUT_DEBUG_H__
3
4/*
5 * Simple debug messages. Add:
6 *
7 * #define DEBUG_LEVEL <n>
8 * #include "debug.h"
9 *
10 * to the file you are working on, or let DEBUG_LEVEL undefined to
11 * disable all messages. A higher level denotes a greater importance
12 * of the message.
13 */
14
15#include <stdio.h>
16
17#define D_STMT_START do
18#define D_STMT_END while (0)
19
20#define D_STMT_NOP D_STMT_START { } D_STMT_END
21
22# ifdef DEBUG_LEVEL
23# define DEBUG_MSG(level, ...) \
24 D_STMT_START { \
25 if (DEBUG_LEVEL && (level) >= DEBUG_LEVEL) \
26 printf(__VA_ARGS__); \
27 } D_STMT_END
28# else
29# define DEBUG_MSG(level, ...)
30# endif /* DEBUG_LEVEL */
31
32#include "debug_rtfl.hh"
33
34/* Some extensions for RTFL dealing with static stuff. */
35
36#ifdef DBG_RTFL
37
38#define DBG_OBJ_MSG_S(aspect, prio, msg) \
39 RTFL_OBJ_PRINT ("msg", "s:s:d:s", "<static>", aspect, prio, msg)
40
41#define DBG_OBJ_MSGF_S(aspect, prio, fmt, ...) \
42 STMT_START { \
43 char msg[256]; \
44 snprintf (msg, sizeof (msg), fmt, __VA_ARGS__); \
45 RTFL_OBJ_PRINT ("msg", "s:s:d:s", "<static>", aspect, prio, msg) \
46 } STMT_END
47
48#define DBG_OBJ_ENTER0_S(aspect, prio, funname) \
49 RTFL_OBJ_PRINT ("enter", "s:s:d:s:", "<static>", aspect, prio, funname);
50
51#define DBG_OBJ_ENTER_S(aspect, prio, funname, fmt, ...) \
52 STMT_START { \
53 char args[256]; \
54 snprintf (args, sizeof (args), fmt, __VA_ARGS__); \
55 RTFL_OBJ_PRINT ("enter", "s:s:d:s:s", "<static>", aspect, prio, funname, \
56 args); \
57 } STMT_END
58
59#define DBG_OBJ_LEAVE_S() \
60 RTFL_OBJ_PRINT ("leave", "s", "<static>");
61
62#define DBG_OBJ_LEAVE_VAL_S(fmt, ...) \
63 STMT_START { \
64 char vals[256]; \
65 snprintf (vals, sizeof (vals), fmt, __VA_ARGS__); \
66 RTFL_OBJ_PRINT ("leave", "s:s", "<static>", vals); \
67 } STMT_END
68
69#else /* DBG_RTFL */
70
71#define STMT_NOP do { } while (0)
72
73#define DBG_IF_RTFL if(0)
74
75#define DBG_OBJ_MSG_S(aspect, prio, msg) STMT_NOP
76#define DBG_OBJ_MSGF_S(aspect, prio, fmt, ...) STMT_NOP
77#define DBG_OBJ_ENTER0_S(aspect, prio, funname) STMT_NOP
78#define DBG_OBJ_ENTER_S(aspect, prio, funname, fmt, ...) STMT_NOP
79#define DBG_OBJ_LEAVE_S() STMT_NOP
80#define DBG_OBJ_LEAVE_VAL_S(fmt, ...) STMT_NOP
81
82#endif /* DBG_RTFL */
83
84#endif /* __LOUT_DEBUG_H__ */
85
86