O2 2.0
A communication protocol for interactive music and media applications.
debug.h
1/* debug.h -- debug support */
2
3/* Roger B. Dannenberg
4 * April 2020
5 */
6
7// o2_message_print() is included in debug versions automatically.
8// It is also included if O2_MSGPRINT is defined.
9
10#ifndef O2_NO_DEBUG
11#ifndef O2_MSGPRINT
12#define O2_MSGPRINT 1
13#endif
14#endif
15
16#ifdef O2_NO_DEBUG
17#define O2_DB(flags, x)
18#define O2_DBc(x)
19#define O2_DBr(x)
20#define O2_DBs(x)
21#define O2_DBsS(x)
22#define O2_DBR(x)
23#define O2_DBS(x)
24#define O2_DBk(x)
25#define O2_DBd(x)
26#define O2_DBdo(x)
27#define O2_DBh(x)
28#define O2_DBt(x)
29#define O2_DBT(x)
30#define O2_DBl(x)
31#define O2_DBm(x)
32#define O2_DBn(x)
33#define O2_DBo(x)
34#define O2_DBO(x)
35#define O2_DBoO(x)
36#define O2_DBq(x)
37#define O2_DBw(x)
38#define O2_DBz(x)
39#define O2_DBG(x)
40// special multiple category tests:
41#define O2_DBoO(x)
42#else
43const char *o2_tag_to_string(int tag);
44
45extern int o2_debug;
46extern const char *o2_debug_prefix;
47void o2_dbg_msg(const char *src, O2message_ptr msg, o2_msg_data_ptr data,
48 const char *extra_label, const char *extra_data);
49void o2_print_path_tree();
50void o2_print_bytes(const char* prefix, const char* bytes, int len);
51
52// Note: The ordering of these flags is coordinated with debug_chars,
53// defined in debug.c. See o2_debug_flags() implementation there too.
54#define O2_DBc_FLAG 1
55#define O2_DBr_FLAG 2
56#define O2_DBs_FLAG 4
57#define O2_DBR_FLAG 8
58#define O2_DBS_FLAG 0x10
59#define O2_DBk_FLAG 0x20
60#define O2_DBd_FLAG 0x40
61#define O2_DBh_FLAG 0x80
62#define O2_DBt_FLAG 0x100
63#define O2_DBT_FLAG 0x200
64#define O2_DBl_FLAG 0x400
65#define O2_DBm_FLAG 0x800
66#define O2_DBn_FLAGS (O2_DBr_FLAG | O2_DBR_FLAG | O2_DBs_FLAG | O2_DBS_FLAG)
67#define O2_DBo_FLAG 0x1000
68#define O2_DBO_FLAG 0x2000
69#define O2_DBq_FLAG 0x4000
70#define O2_DBw_FLAG 0x8000
71#define O2_DBz_FLAG 0x10000
72#define O2_DBg_FLAG 0x20000
73#define O2_DBG_FLAGS 0x3FFFF
74// All flags but malloc, schedulers, o2_msg_deliver, enabled by "A"
75#define O2_DBA_FLAGS (O2_DBG_FLAGS-O2_DBm_FLAG-O2_DBl_FLAG-O2_DBt_FLAG-O2_DBT_FLAG)
76// All flags but DBm (malloc/free) and DBl (o2_msg_deliver) enabled by "a"
77#define O2_DBa_FLAGS (O2_DBG_FLAGS-O2_DBm_FLAG-O2_DBl_FLAG)
78
79// macro to surround debug print statements:
80#define O2_DB(flags, x) if (o2_debug & (flags)) { x; }
81#define O2_DBA(x) O2_DB(O2_DBA_FLAGS, x)
82#define O2_DBa(x) O2_DB(O2_DBa_FLAGS, x)
83#define O2_DBc(x) O2_DB(O2_DBc_FLAG | O2_DBo_FLAG, x)
84#define O2_DBr(x) O2_DB(O2_DBr_FLAG, x)
85#define O2_DBs(x) O2_DB(O2_DBs_FLAG, x)
86#define O2_DBR(x) O2_DB(O2_DBR_FLAG, x)
87#define O2_DBS(x) O2_DB(O2_DBS_FLAG, x)
88#define O2_DBk(x) O2_DB(O2_DBk_FLAG, x)
89#define O2_DBd(x) O2_DB(O2_DBd_FLAG, x)
90#define O2_DBh(x) O2_DB(O2_DBh_FLAG, x)
91#define O2_DBt(x) O2_DB(O2_DBt_FLAG, x)
92#define O2_DBT(x) O2_DB(O2_DBT_FLAG, x)
93#define O2_DBl(x) O2_DB(O2_DBl_FLAG, x)
94#define O2_DBm(x) O2_DB(O2_DBm_FLAG, x)
95#define O2_DBn(x) O2_DB(O2_DBn_FLAGS, x)
96#define O2_DBo(x) O2_DB(O2_DBo_FLAG, x)
97#define O2_DBO(x) O2_DB(O2_DBO_FLAG, x)
98#define O2_DBq(x) O2_DB(O2_DBq_FLAG, x)
99#define O2_DBw(x) O2_DB(O2_DBw_FLAG, x)
100#define O2_DBz(x) O2_DB(O2_DBz_FLAG, x)
101
102// O2_DBg is specifically NOT defined. Instead, 'g' is assumed
103// if ANY debugging is enabled (including O2_DBg_FLAG).
104// Instead of O2_DBg, use O2_DBG which prints if any flag is set.
105#define O2_DBG(x) O2_DB(O2_DBG_FLAGS, x)
106// special multiple category tests:
107#define O2_DBoO(x) O2_DB(O2_DBo_FLAG | O2_DBO_FLAG, x)
108#define O2_DBdo(x) O2_DB(O2_DBd_FLAG | O2_DBo_FLAG, x)
109#define O2_DBsS(x) O2_DB(O2_DBs_FLAG | O2_DBS_FLAG, x)
110#endif
111
an O2 message container
Definition: o2.h:690
data part of an O2 message
Definition: o2.h:638