28
28
struct st_mysqlnd_debug_methods
30
enum_func_status (*open)(MYSQLND_DEBUG *self, zend_bool reopen);
31
void (*set_mode)(MYSQLND_DEBUG *self, const char * const mode);
32
enum_func_status (*log)(MYSQLND_DEBUG *self, unsigned int line, const char * const file,
30
enum_func_status (*open)(MYSQLND_DEBUG * self, zend_bool reopen);
31
void (*set_mode)(MYSQLND_DEBUG * self, const char * const mode);
32
enum_func_status (*log)(MYSQLND_DEBUG * self, unsigned int line, const char * const file,
33
33
unsigned int level, const char * type, const char *message);
34
enum_func_status (*log_va)(MYSQLND_DEBUG *self, unsigned int line, const char * const file,
34
enum_func_status (*log_va)(MYSQLND_DEBUG * self, unsigned int line, const char * const file,
35
35
unsigned int level, const char * type, const char *format, ...);
36
zend_bool (*func_enter)(MYSQLND_DEBUG *self, unsigned int line, const char * const file,
36
zend_bool (*func_enter)(MYSQLND_DEBUG * self, unsigned int line, const char * const file,
37
37
const char * const func_name, unsigned int func_name_len);
38
enum_func_status (*func_leave)(MYSQLND_DEBUG *self, unsigned int line, const char * const file);
39
enum_func_status (*close)(MYSQLND_DEBUG *self);
40
enum_func_status (*free_handle)(MYSQLND_DEBUG *self);
38
enum_func_status (*func_leave)(MYSQLND_DEBUG * self, unsigned int line, const char * const file, uint64_t call_time);
39
enum_func_status (*close)(MYSQLND_DEBUG * self);
40
enum_func_status (*free_handle)(MYSQLND_DEBUG * self);
64
66
PHPAPI char * mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC);
68
#if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1400))
70
#include "win32/time.h"
71
#elif defined(NETWARE)
72
#include <sys/timeval.h>
78
#ifndef MYSQLND_PROFILING_DISABLED
79
#define DBG_PROFILE_TIMEVAL_TO_DOUBLE(tp) ((tp.tv_sec * 1000000LL)+ tp.tv_usec)
80
#define DBG_PROFILE_START_TIME() gettimeofday(&__dbg_prof_tp, NULL); __dbg_prof_start = DBG_PROFILE_TIMEVAL_TO_DOUBLE(__dbg_prof_tp);
81
#define DBG_PROFILE_END_TIME(duration) gettimeofday(&__dbg_prof_tp, NULL); (duration) = (DBG_PROFILE_TIMEVAL_TO_DOUBLE(__dbg_prof_tp) - __dbg_prof_start);
83
#define DBG_PROFILE_TIMEVAL_TO_DOUBLE(tp)
84
#define DBG_PROFILE_START_TIME()
85
#define DBG_PROFILE_END_TIME(duration)
67
88
#define DBG_INF_EX(dbg_obj, msg) do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "info : ", (msg)); } while (0)
68
89
#define DBG_ERR_EX(dbg_obj, msg) do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log((dbg_obj), __LINE__, __FILE__, -1, "error: ", (msg)); } while (0)
69
90
#define DBG_INF_FMT_EX(dbg_obj, ...) do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "info : ", __VA_ARGS__); } while (0)
70
91
#define DBG_ERR_FMT_EX(dbg_obj, ...) do { if (dbg_skip_trace == FALSE) (dbg_obj)->m->log_va((dbg_obj), __LINE__, __FILE__, -1, "error: ", __VA_ARGS__); } while (0)
72
#define DBG_ENTER_EX(dbg_obj, func_name) zend_bool dbg_skip_trace = TRUE; if ((dbg_obj)) dbg_skip_trace = !(dbg_obj)->m->func_enter((dbg_obj), __LINE__, __FILE__, func_name, strlen(func_name));
73
#define DBG_RETURN_EX(dbg_obj, value) do { if ((dbg_obj)) (dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__); return (value); } while (0)
74
#define DBG_VOID_RETURN_EX(dbg_obj) do { if ((dbg_obj)) (dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__); return; } while (0)
93
#define DBG_ENTER_EX(dbg_obj, func_name) \
94
struct timeval __dbg_prof_tp = {0}; \
95
uint64_t __dbg_prof_start = 0; /* initialization is needed */ \
96
zend_bool dbg_skip_trace = TRUE; \
98
dbg_skip_trace = !(dbg_obj)->m->func_enter((dbg_obj), __LINE__, __FILE__, func_name, strlen(func_name)); \
101
if ((dbg_obj) && (dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \
102
DBG_PROFILE_START_TIME(); \
106
#define DBG_RETURN_EX(dbg_obj, value) \
109
uint64_t this_call_duration = 0; \
110
if ((dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \
111
DBG_PROFILE_END_TIME(this_call_duration); \
113
(dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__, this_call_duration); \
117
#define DBG_VOID_RETURN_EX(dbg_obj) \
120
uint64_t this_call_duration = 0; \
121
if ((dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \
122
DBG_PROFILE_END_TIME(this_call_duration); \
124
(dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__, this_call_duration); \
77
130
static inline void DBG_INF_EX(MYSQLND_DEBUG * dbg_obj, const char * const msg) {}