diff options
author | Andrey Hristov <andrey@php.net> | 2010-01-13 14:06:02 +0000 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2010-01-13 14:06:02 +0000 |
commit | 176e6dd2f2eac6df475a106eb201bf503796b267 (patch) | |
tree | b585828b015d232dde492cbacc5722d16f6ef840 /ext/mysqlnd/mysqlnd_debug.h | |
parent | 62543788306c6a0c3190eb146de9d7a6cfeec4fd (diff) | |
download | php-git-176e6dd2f2eac6df475a106eb201bf503796b267.tar.gz |
make mysqlnd's tracing API more reusable
Diffstat (limited to 'ext/mysqlnd/mysqlnd_debug.h')
-rw-r--r-- | ext/mysqlnd/mysqlnd_debug.h | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/ext/mysqlnd/mysqlnd_debug.h b/ext/mysqlnd/mysqlnd_debug.h index f872099d4a..2ac2f46679 100644 --- a/ext/mysqlnd/mysqlnd_debug.h +++ b/ext/mysqlnd/mysqlnd_debug.h @@ -36,7 +36,7 @@ struct st_mysqlnd_debug_methods enum_func_status (*log_va)(MYSQLND_DEBUG *self, unsigned int line, const char * const file, unsigned int level, const char * type, const char *format, ...); zend_bool (*func_enter)(MYSQLND_DEBUG *self, unsigned int line, const char * const file, - char * func_name, unsigned int func_name_len); + const char * const func_name, unsigned int func_name_len); enum_func_status (*func_leave)(MYSQLND_DEBUG *self, unsigned int line, const char * const file); enum_func_status (*close)(MYSQLND_DEBUG *self); enum_func_status (*free_handle)(MYSQLND_DEBUG *self); @@ -55,10 +55,12 @@ struct st_mysqlnd_debug zend_stack call_stack; HashTable not_filtered_functions; struct st_mysqlnd_debug_methods *m; + const char ** skip_functions; }; +extern const char * mysqlnd_debug_std_no_trace_funcs[]; -PHPAPI MYSQLND_DEBUG *mysqlnd_debug_init(TSRMLS_D); +PHPAPI MYSQLND_DEBUG * mysqlnd_debug_init(const char * skip_functions[] TSRMLS_DC); #define MYSQLND_MEM_D TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC @@ -78,20 +80,29 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D); char * mysqlnd_get_backtrace(TSRMLS_D); +#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) +#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) +#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) +#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) + +#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)); +#define DBG_RETURN_EX(dbg_obj, value) do { if ((dbg_obj)) (dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__); return (value); } while (0) +#define DBG_VOID_RETURN_EX(dbg_obj) do { if ((dbg_obj)) (dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__); return; } while (0) + + #if MYSQLND_DBG_ENABLED == 1 -#define DBG_INF(msg) do { if (dbg_skip_trace == FALSE) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "info : ", (msg)); } while (0) -#define DBG_ERR(msg) do { if (dbg_skip_trace == FALSE) MYSQLND_G(dbg)->m->log(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "error: ", (msg)); } while (0) -#define DBG_INF_FMT(...) do { if (dbg_skip_trace == FALSE) MYSQLND_G(dbg)->m->log_va(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "info : ", __VA_ARGS__); } while (0) -#define DBG_ERR_FMT(...) do { if (dbg_skip_trace == FALSE) MYSQLND_G(dbg)->m->log_va(MYSQLND_G(dbg), __LINE__, __FILE__, -1, "error: ", __VA_ARGS__); } while (0) +#define DBG_INF(msg) DBG_INF_EX(MYSQLND_G(dbg), (msg)) +#define DBG_ERR(msg) DBG_ERR_EX(MYSQLND_G(dbg), (msg)) +#define DBG_INF_FMT(...) DBG_INF_FMT_EX(MYSQLND_G(dbg), __VA_ARGS__) +#define DBG_ERR_FMT(...) DBG_ERR_FMT_EX(MYSQLND_G(dbg), __VA_ARGS__) -#define DBG_ENTER(func_name) zend_bool dbg_skip_trace = TRUE; if (MYSQLND_G(dbg)) dbg_skip_trace = !MYSQLND_G(dbg)->m->func_enter(MYSQLND_G(dbg), __LINE__, __FILE__, func_name, strlen(func_name)); -#define DBG_RETURN(value) do { if (MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->func_leave(MYSQLND_G(dbg), __LINE__, __FILE__); return (value); } while (0) -#define DBG_VOID_RETURN do { if (MYSQLND_G(dbg)) MYSQLND_G(dbg)->m->func_leave(MYSQLND_G(dbg), __LINE__, __FILE__); return; } while (0) +#define DBG_ENTER(func_name) DBG_ENTER_EX(MYSQLND_G(dbg), (func_name)) +#define DBG_RETURN(value) DBG_RETURN_EX(MYSQLND_G(dbg), (value)) +#define DBG_VOID_RETURN DBG_VOID_RETURN_EX(MYSQLND_G(dbg)) #elif MYSQLND_DBG_ENABLED == 0 - static inline void DBG_INF(const char * const msg) {} static inline void DBG_ERR(const char * const msg) {} static inline void DBG_INF_FMT(const char * const format, ...) {} @@ -99,6 +110,7 @@ static inline void DBG_ERR_FMT(const char * const format, ...) {} static inline void DBG_ENTER(const char * const func_name) {} #define DBG_RETURN(value) return (value) #define DBG_VOID_RETURN return + #endif |