MySQL 9.1.0
Source Code Documentation
gcs_debug.h File Reference
#include "xcom/xcom_common.h"
#include "xcom/x_platform.h"
#include <stdio.h>
#include <stdlib.h>
#include "xcom/xcom_logger.h"
#include "my_compiler.h"
#include <sys/types.h>
#include <unistd.h>

Go to the source code of this file.

Macros

#define TASK_DBUG_ON   0
 
#define TX_FMT   "{" SY_FMT_DEF " %" PRIu32 "}"
 
#define TX_MEM(x)   SY_MEM((x).cfg), (x).pc
 
#define STR_SIZE   2047
 
#define GET_GOUT
 
#define GET_NEW_GOUT
 
#define FREE_GOUT   xcom_log_buffer[0] = 0
 
#define ADD_GOUT(s)    xcom_temp_buf = mystrcat(xcom_temp_buf, &xcom_log_buffer_size, s)
 
#define COPY_AND_FREE_GOUT(s)
 
#define ADD_F_GOUT(...)
 
#define PRINT_LOUT(level)   xcom_log(level, xcom_log_buffer)
 
#define PRINT_GOUT   xcom_debug("%s", xcom_log_buffer)
 
#define RET_GOUT   return xcom_log_buffer
 
#define G_LOG_LEVEL(level, ...)
 
#define G_DEBUG_LEVEL(level, ...)
 
#define g_critical(...)   G_LOG_LEVEL(XCOM_LOG_FATAL, __VA_ARGS__)
 
#define G_ERROR(...)   G_LOG_LEVEL(XCOM_LOG_ERROR, __VA_ARGS__)
 
#define G_WARNING(...)   G_LOG_LEVEL(XCOM_LOG_WARN, __VA_ARGS__)
 
#define G_MESSAGE(...)   G_LOG_LEVEL(XCOM_LOG_INFO, __VA_ARGS__)
 
#define G_INFO(...)   G_LOG_LEVEL(XCOM_LOG_INFO, __VA_ARGS__)
 
#define G_DEBUG(...)    G_DEBUG_LEVEL(XCOM_DEBUG_BASIC | XCOM_DEBUG_TRACE, __VA_ARGS__)
 
#define G_TRACE(...)   G_DEBUG_LEVEL(XCOM_DEBUG_TRACE, __VA_ARGS__)
 
#define IS_XCOM_DEBUG_WITH(level)   xcom_debug_check(level)
 
#define IDENTIFY
 
#define DBG_IDENTIFY
 
#define BIT(n)   (1L << n)
 
#define INFO(x)
 
#define DBGOUT(x)
 
#define DBGOUT_ASSERT(expr, dbginfo)
 
#define NEW_DBG(x)
 
#define IFDBG(mask, body)
 
#define XDBG   #error
 
#define FN
 
#define PTREXP(x)   ADD_F_GOUT(#x ": %p ", (void const*)(x))
 
#define CONSTPTREXP(x)   PTREXP(x)
 
#define PPUT(x)   ADD_F_GOUT("0x%p ", (void *)(x))
 
#define STREXP(x)   ADD_F_GOUT(#x ": %s ", x)
 
#define STRLIT(x)   ADD_GOUT(x)
 
#define NPUT(x, f)   ADD_F_GOUT("%" #f " ", x)
 
#define NDBG(x, f)
 
#define NDBG64(x)
 
#define NPUT64(x)   ADD_F_GOUT("%" PRIu64 " ", x)
 
#define NEXP(x, f)   ADD_F_GOUT(#x ": %" #f " ", x)
 
#define NUMEXP(x)   NEXP(x, d)
 
#define g_strerror   strerror
 
#define LOUT(pri, x)   ADD_F_GOUT(x);
 
#define SYCEXP(exp)
 
#define TIDCEXP(exp)
 
#define TIMECEXP(exp)   ADD_F_GOUT(#exp "=%f sec ", (exp))
 
#define BALCEXP(exp)   ADD_F_GOUT(#exp "={%d %d} ", (exp).cnt, (exp).node)
 

Typedefs

typedef enum xcom_dbg_type xcom_dbg_type
 

Enumerations

enum  xcom_dbg_type {
  D_NONE = 0 , D_TASK = BIT(0) , D_BASE = BIT(1) , D_FSM = BIT(2) ,
  D_TRANSPORT = BIT(3) , D_PROPOSE = BIT(4) , D_DISPATCH = BIT(5) , D_SEMA = BIT(6) ,
  D_XDR = BIT(7) , D_STORE = BIT(8) , D_EXEC = BIT(9) , D_DETECT = BIT(10) ,
  D_ALLOC = BIT(11) , D_FILEOP = BIT(12) , D_CACHE = BIT(13) , D_CONS = BIT(14) ,
  D_BUG = ~0L
}
 
enum  { DBG_STACK_SIZE = 256 }
 

Functions

double task_now ()
 
char * mystrcat (char *dest, int *size, const char *src)
 Concatenates two strings and returns pointer to last character of final string, allowing further concatenations without having to cycle through the entire string again. More...
 
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. More...
 
static int do_dbg (xcom_dbg_type x)
 
static void set_dbg (xcom_dbg_type x)
 
static void unset_dbg (xcom_dbg_type x)
 
static long get_dbg ()
 
static void push_dbg (long x)
 
static void pop_dbg ()
 
static int xpid ()
 
static char const * fixpath (char const *x)
 
uint32_t get_my_xcom_id ()
 

Variables

xcom_logger xcom_log
 Callbacks used in the logging macros. More...
 
xcom_debugger xcom_debug
 
xcom_debugger_check xcom_debug_check
 
int64_t xcom_debug_options
 Define the set of debug and trace options that are enabled if there is no debugger check injected. More...
 
long xcom_debug_mask
 
long xcom_dbg_stack [DBG_STACK_SIZE]
 
int xcom_dbg_stack_top
 

Macro Definition Documentation

◆ ADD_F_GOUT

#define ADD_F_GOUT (   ...)
Value:
xcom_temp_buf = \
mystrcat_sprintf(xcom_temp_buf, &xcom_log_buffer_size, __VA_ARGS__)

◆ ADD_GOUT

#define ADD_GOUT (   s)     xcom_temp_buf = mystrcat(xcom_temp_buf, &xcom_log_buffer_size, s)

◆ BALCEXP

#define BALCEXP (   exp)    ADD_F_GOUT(#exp "={%d %d} ", (exp).cnt, (exp).node)

◆ BIT

#define BIT (   n)    (1L << n)

◆ CONSTPTREXP

#define CONSTPTREXP (   x)    PTREXP(x)

◆ COPY_AND_FREE_GOUT

#define COPY_AND_FREE_GOUT (   s)
Value:
{ \
char *__funny = s; \
ADD_GOUT(__funny); \
free(__funny); \
}

◆ DBG_IDENTIFY

#define DBG_IDENTIFY

◆ DBGOUT

#define DBGOUT (   x)
Value:
do { \
} while (0)

◆ DBGOUT_ASSERT

#define DBGOUT_ASSERT (   expr,
  dbginfo 
)

◆ FN

#define FN
Value:
ADD_GOUT(__func__); \
ADD_F_GOUT(" pid %d xcom_id %x %s:%d ", xpid(), get_my_xcom_id(), \
fixpath(__FILE__), __LINE__)
static int xpid()
Definition: gcs_debug.h:287
uint32_t get_my_xcom_id()
Definition: xcom_base.cc:442
static char const * fixpath(char const *x)
Definition: gcs_debug.h:299
#define ADD_GOUT(s)
Definition: gcs_debug.h:107

◆ FREE_GOUT

#define FREE_GOUT   xcom_log_buffer[0] = 0

◆ g_critical

#define g_critical (   ...)    G_LOG_LEVEL(XCOM_LOG_FATAL, __VA_ARGS__)

◆ G_DEBUG

#define G_DEBUG (   ...)     G_DEBUG_LEVEL(XCOM_DEBUG_BASIC | XCOM_DEBUG_TRACE, __VA_ARGS__)

◆ G_DEBUG_LEVEL

#define G_DEBUG_LEVEL (   level,
  ... 
)
Value:
{ \
if (IS_XCOM_DEBUG_WITH(level)) { \
xcom_debug(__VA_ARGS__); \
} \
}
#define IS_XCOM_DEBUG_WITH(level)
Definition: gcs_debug.h:157

◆ G_ERROR

#define G_ERROR (   ...)    G_LOG_LEVEL(XCOM_LOG_ERROR, __VA_ARGS__)

◆ G_INFO

#define G_INFO (   ...)    G_LOG_LEVEL(XCOM_LOG_INFO, __VA_ARGS__)

◆ G_LOG_LEVEL

#define G_LOG_LEVEL (   level,
  ... 
)
Value:
{ \
GET_GOUT; \
ADD_F_GOUT(__VA_ARGS__); \
PRINT_LOUT(level); \
FREE_GOUT; \
}

◆ G_MESSAGE

#define G_MESSAGE (   ...)    G_LOG_LEVEL(XCOM_LOG_INFO, __VA_ARGS__)

◆ g_strerror

#define g_strerror   strerror

◆ G_TRACE

#define G_TRACE (   ...)    G_DEBUG_LEVEL(XCOM_DEBUG_TRACE, __VA_ARGS__)

◆ G_WARNING

#define G_WARNING (   ...)    G_LOG_LEVEL(XCOM_LOG_WARN, __VA_ARGS__)

◆ GET_GOUT

#define GET_GOUT
Value:
char xcom_log_buffer[STR_SIZE + 1]; \
char *xcom_temp_buf = xcom_log_buffer; \
int xcom_log_buffer_size = 0; \
xcom_log_buffer[0] = 0
#define STR_SIZE
Definition: gcs_debug.h:94

◆ GET_NEW_GOUT

#define GET_NEW_GOUT
Value:
char *xcom_log_buffer = (char *)malloc((STR_SIZE + 1) * sizeof(char)); \
char *xcom_temp_buf = xcom_log_buffer; \
int xcom_log_buffer_size = 0; \
xcom_log_buffer[0] = 0
#define malloc(A)
Definition: lexyy.cc:914

◆ IDENTIFY

#define IDENTIFY

◆ IFDBG

#define IFDBG (   mask,
  body 
)

◆ INFO

#define INFO (   x)
Value:
do { \
GET_GOUT; \
ADD_F_GOUT("%f ", task_now()); \
x; \
PRINT_LOUT(XCOM_LOG_INFO); \
FREE_GOUT; \
} while (0)
double task_now()
Definition: task.cc:318
@ XCOM_LOG_INFO
Definition: xcom_logger.h:42

◆ IS_XCOM_DEBUG_WITH

#define IS_XCOM_DEBUG_WITH (   level)    xcom_debug_check(level)

◆ LOUT

#define LOUT (   pri,
 
)    ADD_F_GOUT(x);

◆ NDBG

#define NDBG (   x,
 
)
Value:
ADD_F_GOUT(#x " = "); \
NPUT(x, f)
#define ADD_F_GOUT(...)
Definition: gcs_debug.h:115

◆ NDBG64

#define NDBG64 (   x)
Value:
ADD_F_GOUT(#x " = "); \
NPUT64(x);

◆ NEW_DBG

#define NEW_DBG (   x)

◆ NEXP

#define NEXP (   x,
 
)    ADD_F_GOUT(#x ": %" #f " ", x)

◆ NPUT

#define NPUT (   x,
 
)    ADD_F_GOUT("%" #f " ", x)

◆ NPUT64

#define NPUT64 (   x)    ADD_F_GOUT("%" PRIu64 " ", x)

◆ NUMEXP

#define NUMEXP (   x)    NEXP(x, d)

◆ PPUT

#define PPUT (   x)    ADD_F_GOUT("0x%p ", (void *)(x))

◆ PRINT_GOUT

#define PRINT_GOUT   xcom_debug("%s", xcom_log_buffer)

◆ PRINT_LOUT

#define PRINT_LOUT (   level)    xcom_log(level, xcom_log_buffer)

◆ PTREXP

#define PTREXP (   x)    ADD_F_GOUT(#x ": %p ", (void const*)(x))

◆ RET_GOUT

#define RET_GOUT   return xcom_log_buffer

◆ STR_SIZE

#define STR_SIZE   2047

◆ STREXP

#define STREXP (   x)    ADD_F_GOUT(#x ": %s ", x)

◆ STRLIT

#define STRLIT (   x)    ADD_GOUT(x)

◆ SYCEXP

#define SYCEXP (   exp)
Value:
ADD_F_GOUT(#exp "={%x %" PRIu64 " %u} ", (exp).group_id, ((exp).msgno), \
((exp).node))

◆ TASK_DBUG_ON

#define TASK_DBUG_ON   0

◆ TIDCEXP

#define TIDCEXP (   exp)
Value:
ADD_F_GOUT(#exp "={%x %" PRIu64 " %u %u} ", (exp).cfg.group_id, \
(exp).cfg.msgno, (exp).cfg.node, (exp).pc)

◆ TIMECEXP

#define TIMECEXP (   exp)    ADD_F_GOUT(#exp "=%f sec ", (exp))

◆ TX_FMT

#define TX_FMT   "{" SY_FMT_DEF " %" PRIu32 "}"

◆ TX_MEM

#define TX_MEM (   x)    SY_MEM((x).cfg), (x).pc

◆ XDBG

#define XDBG   #error

Typedef Documentation

◆ xcom_dbg_type

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
DBG_STACK_SIZE 

◆ xcom_dbg_type

Enumerator
D_NONE 
D_TASK 
D_BASE 
D_FSM 
D_TRANSPORT 
D_PROPOSE 
D_DISPATCH 
D_SEMA 
D_XDR 
D_STORE 
D_EXEC 
D_DETECT 
D_ALLOC 
D_FILEOP 
D_CACHE 
D_CONS 
D_BUG 

Function Documentation

◆ do_dbg()

static int do_dbg ( xcom_dbg_type  x)
inlinestatic

◆ fixpath()

static char const * fixpath ( char const *  x)
inlinestatic

◆ get_dbg()

static long get_dbg ( )
inlinestatic

◆ get_my_xcom_id()

uint32_t get_my_xcom_id ( )

◆ mystrcat()

char * mystrcat ( char *  dest,
int *  size,
const char *  src 
)

Concatenates two strings and returns pointer to last character of final string, allowing further concatenations without having to cycle through the entire string again.

Parameters
destpointer to last character of destination string
sizepointer to the number of characters currently added to xcom_log_buffer
srcpointer to the string to append to dest
Returns
pointer to the last character of destination string after appending dest, which corresponds to the position of the '\0' character

◆ mystrcat_sprintf()

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.

Finally, it invokes mystr_cat to concatenate the rendered string to the string received in the first parameter.

◆ pop_dbg()

static void pop_dbg ( )
inlinestatic

◆ push_dbg()

static void push_dbg ( long  x)
inlinestatic

◆ set_dbg()

static void set_dbg ( xcom_dbg_type  x)
inlinestatic

◆ task_now()

double task_now ( )

◆ unset_dbg()

static void unset_dbg ( xcom_dbg_type  x)
inlinestatic

◆ xpid()

static int xpid ( )
inlinestatic

Variable Documentation

◆ xcom_dbg_stack

long xcom_dbg_stack[DBG_STACK_SIZE]
extern

◆ xcom_dbg_stack_top

int xcom_dbg_stack_top
extern

◆ xcom_debug

xcom_debugger xcom_debug
extern

◆ xcom_debug_check

xcom_debugger_check xcom_debug_check
extern

◆ xcom_debug_mask

long xcom_debug_mask
extern

◆ xcom_debug_options

int64_t xcom_debug_options
extern

Define the set of debug and trace options that are enabled if there is no debugger check injected.

◆ xcom_log

xcom_logger xcom_log
extern

Callbacks used in the logging macros.