31#error "TASK_DBUG_ON already defined"
36#define TX_FMT "{" SY_FMT_DEF " %" PRIu32 "}"
37#define TX_MEM(x) SY_MEM((x).cfg), (x).pc
45#error "DBGOUT defined"
50#ifndef XCOM_STANDALONE
81char *
mystrcat(
char *dest,
int *size,
const char *src);
91 MY_ATTRIBUTE((format(printf, 3, 4)));
96 char xcom_log_buffer[STR_SIZE + 1]; \
97 char *xcom_temp_buf = xcom_log_buffer; \
98 int xcom_log_buffer_size = 0; \
99 xcom_log_buffer[0] = 0
100#define GET_NEW_GOUT \
101 char *xcom_log_buffer = (char *)malloc((STR_SIZE + 1) * sizeof(char)); \
102 char *xcom_temp_buf = xcom_log_buffer; \
103 int xcom_log_buffer_size = 0; \
104 xcom_log_buffer[0] = 0
105#define FREE_GOUT xcom_log_buffer[0] = 0
107 xcom_temp_buf = mystrcat(xcom_temp_buf, &xcom_log_buffer_size, s)
108#define COPY_AND_FREE_GOUT(s) \
114#define ADD_F_GOUT(...) \
116 mystrcat_sprintf(xcom_temp_buf, &xcom_log_buffer_size, __VA_ARGS__)
117#define PRINT_LOUT(level) xcom_log(level, xcom_log_buffer)
118#define PRINT_GOUT xcom_debug("%s", xcom_log_buffer)
119#define RET_GOUT return xcom_log_buffer
121#define G_LOG_LEVEL(level, ...) \
124 ADD_F_GOUT(__VA_ARGS__); \
129#ifndef XCOM_STANDALONE
130#define G_DEBUG_LEVEL(level, ...) \
132 if (IS_XCOM_DEBUG_WITH(level)) { \
133 xcom_debug(__VA_ARGS__); \
137#define G_DEBUG_LEVEL(level, ...) \
139 if (IS_XCOM_DEBUG_WITH(level)) { \
141 ADD_F_GOUT(__VA_ARGS__); \
148#define g_critical(...) G_LOG_LEVEL(XCOM_LOG_FATAL, __VA_ARGS__)
149#define G_ERROR(...) G_LOG_LEVEL(XCOM_LOG_ERROR, __VA_ARGS__)
150#define G_WARNING(...) G_LOG_LEVEL(XCOM_LOG_WARN, __VA_ARGS__)
151#define G_MESSAGE(...) G_LOG_LEVEL(XCOM_LOG_INFO, __VA_ARGS__)
152#define G_INFO(...) G_LOG_LEVEL(XCOM_LOG_INFO, __VA_ARGS__)
153#define G_DEBUG(...) \
154 G_DEBUG_LEVEL(XCOM_DEBUG_BASIC | XCOM_DEBUG_TRACE, __VA_ARGS__)
155#define G_TRACE(...) G_DEBUG_LEVEL(XCOM_DEBUG_TRACE, __VA_ARGS__)
156#define IS_XCOM_DEBUG_WITH(level) xcom_debug_check(level)
159#error "IDENTIFY already defined!"
165#error "DBG_IDENTIFY already defined!"
170#define BIT(n) (1L << n)
219#error "INFO already defined!"
224 ADD_F_GOUT("%f ", task_now()); \
226 PRINT_LOUT(XCOM_LOG_INFO); \
235 if (IS_XCOM_DEBUG_WITH(XCOM_DEBUG_TRACE)) { \
237 ADD_F_GOUT("%f ", task_now()); \
244 long dbg_save = get_dbg(); \
246#define RESTORE_DBG set_dbg(dbg_save)
249#error "IFDBG already defined!"
251#define IFDBG(mask, body) \
253 if (do_dbg(mask)) DBGOUT(body); \
258#error "DBGOUT_ASSERT already defined"
260#define DBGOUT_ASSERT(expr, dbginfo) \
265 PRINT_LOUT(XCOM_LOG_ERROR); \
276#define DBGOUT_ASSERT(expr, dbginfo)
278#define IFDBG(mask, body)
281#include <sys/types.h>
288 if (!pid) pid = getpid();
293static inline char const *
fixpath(
char const *x) {
294 char const *s = strrchr(x,
'\\');
295 return s ? s + 1 : x;
298static inline char const *
fixpath(
char const *x) {
299 char const *s = strrchr(x,
'/');
300 return s ? s + 1 : x;
308 ADD_GOUT(__func__); \
309 ADD_F_GOUT(" pid %d xcom_id %x %s:%d ", xpid(), get_my_xcom_id(), \
310 fixpath(__FILE__), __LINE__)
311#define PTREXP(x) ADD_F_GOUT(#x ": %p ", (void const*)(x))
312#define CONSTPTREXP(x) PTREXP(x)
313#define PPUT(x) ADD_F_GOUT("0x%p ", (void *)(x))
314#define STREXP(x) ADD_F_GOUT(#x ": %s ", x)
315#define STRLIT(x) ADD_GOUT(x)
316#define NPUT(x, f) ADD_F_GOUT("%" #f " ", x)
318 ADD_F_GOUT(#x " = "); \
321 ADD_F_GOUT(#x " = "); \
323#define NPUT64(x) ADD_F_GOUT("%" PRIu64 " ", x)
324#define NEXP(x, f) ADD_F_GOUT(#x ": %" #f " ", x)
325#define NUMEXP(x) NEXP(x, d)
326#define g_strerror strerror
327#define LOUT(pri, x) ADD_F_GOUT(x);
329 ADD_F_GOUT(#exp "={%x %" PRIu64 " %u} ", (exp).group_id, ((exp).msgno), \
331#define TIDCEXP(exp) \
332 ADD_F_GOUT(#exp "={%x %" PRIu64 " %u %u} ", (exp).cfg.group_id, \
333 (exp).cfg.msgno, (exp).cfg.node, (exp).pc)
334#define TIMECEXP(exp) ADD_F_GOUT(#exp "=%f sec ", (exp))
335#define BALCEXP(exp) ADD_F_GOUT(#exp "={%d %d} ", (exp).cnt, (exp).node)
#define L
Definition: ctype-tis620.cc:74
static int xpid()
Definition: gcs_debug.h:286
uint32_t get_my_xcom_id()
Definition: xcom_base.cc:441
static long get_dbg()
Definition: gcs_debug.h:201
xcom_debugger xcom_debug
Definition: xcom_interface.cc:101
#define BIT(n)
Definition: gcs_debug.h:170
static char const * fixpath(char const *x)
Definition: gcs_debug.h:298
char * mystrcat_sprintf(char *dest, int *size, const char *format,...)
This function allocates a new string where the format string and optional arguments are rendered to.
Definition: task_debug.cc:77
static void set_dbg(xcom_dbg_type x)
Definition: gcs_debug.h:199
xcom_debugger_check xcom_debug_check
Definition: xcom_interface.cc:102
xcom_dbg_type
Definition: gcs_debug.h:172
@ D_TRANSPORT
Definition: gcs_debug.h:177
@ D_PROPOSE
Definition: gcs_debug.h:178
@ D_ALLOC
Definition: gcs_debug.h:185
@ D_STORE
Definition: gcs_debug.h:182
@ D_FSM
Definition: gcs_debug.h:176
@ D_BUG
Definition: gcs_debug.h:189
@ D_DETECT
Definition: gcs_debug.h:184
@ D_DISPATCH
Definition: gcs_debug.h:179
@ D_XDR
Definition: gcs_debug.h:181
@ D_EXEC
Definition: gcs_debug.h:183
@ D_SEMA
Definition: gcs_debug.h:180
@ D_CONS
Definition: gcs_debug.h:188
@ D_BASE
Definition: gcs_debug.h:175
@ D_NONE
Definition: gcs_debug.h:173
@ D_FILEOP
Definition: gcs_debug.h:186
@ D_CACHE
Definition: gcs_debug.h:187
@ D_TASK
Definition: gcs_debug.h:174
int64_t xcom_debug_options
Define the set of debug and trace options that are enabled if there is no debugger check injected.
Definition: xcom_interface.cc:103
char * mystrcat(char *dest, int *size, const char *src)
Concatenates two strings and returns pointer to last character of final string, allowing further conc...
Definition: task_debug.cc:37
long xcom_dbg_stack[DBG_STACK_SIZE]
Definition: xcom_base.cc:415
int xcom_dbg_stack_top
Definition: xcom_base.cc:416
static void unset_dbg(xcom_dbg_type x)
Definition: gcs_debug.h:200
@ DBG_STACK_SIZE
Definition: gcs_debug.h:193
long xcom_debug_mask
Definition: xcom_base.cc:413
static void pop_dbg()
Definition: gcs_debug.h:211
double task_now()
Definition: task.cc:317
static void push_dbg(long x)
Definition: gcs_debug.h:203
xcom_logger xcom_log
Callbacks used in the logging macros.
Definition: xcom_interface.cc:100
static int do_dbg(xcom_dbg_type x)
Definition: gcs_debug.h:198
Header for compiler-dependent features.
int(* xcom_debugger_check)(const int64_t debug_options)
Definition: xcom_logger.h:78
void(* xcom_debugger)(const char *format,...)
Definition: xcom_logger.h:76
void(* xcom_logger)(const int64_t level, const char *message)
Definition: xcom_logger.h:75