~clint-fewbar/ubuntu/precise/php5/php5-5.4-merge

« back to all changes in this revision

Viewing changes to ext/mysqlnd/mysqlnd_debug.h

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-02-22 09:46:37 UTC
  • mfrom: (1.1.20) (0.3.18 sid)
  • Revision ID: package-import@ubuntu.com-20110222094637-nlu2tvb7oqgaarl0
Tags: 5.3.5-1ubuntu1
* Merge from debian/unstable. Remaining changes:
 - debian/control:
    * Dropped firebird2.1-dev, libc-client-dev, libmcrypt-dev as it is in universe.
    * Dropped libmysqlclient15-dev, build against mysql 5.1.
    * Dropped libcurl-dev not in the archive.
    * Suggest php5-suhosin rather than recommends.
    * Dropped php5-imap, php5-interbase, php5-mcrypt since we have versions 
      already in universe.
    * Dropped libonig-dev and libqgdbm since its in universe. (will be re-added in lucid+1)
    * Dropped locales-all.
  - modulelist: Drop imap, interbase, sybase, and mcrypt.
  - debian/rules:
    * Dropped building of mcrypt, imap, and interbase.
    * Install apport hook for php5.
    * stop mysql instance on clean just in case we failed in tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
  +----------------------------------------------------------------------+
19
19
*/
20
20
 
21
 
/* $Id: mysqlnd_debug.h 299755 2010-05-25 21:54:21Z andrey $ */
 
21
/* $Id: mysqlnd_debug.h 305878 2010-12-01 10:16:51Z andrey $ */
22
22
 
23
23
#ifndef MYSQLND_DEBUG_H
24
24
#define MYSQLND_DEBUG_H
27
27
 
28
28
struct st_mysqlnd_debug_methods
29
29
{
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);
41
41
};
42
42
 
43
43
 
52
52
        int pid;
53
53
        char * file_name;
54
54
        zend_stack call_stack;
 
55
        zend_stack call_time_stack;     
55
56
        HashTable not_filtered_functions;
 
57
        HashTable function_profiles;
56
58
        struct st_mysqlnd_debug_methods *m;
57
59
        const char ** skip_functions;
58
60
};
63
65
 
64
66
PHPAPI char *   mysqlnd_get_backtrace(uint max_levels, size_t * length TSRMLS_DC);
65
67
 
66
 
#if defined(__GNUC__)
 
68
#if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1400))
 
69
#ifdef PHP_WIN32
 
70
#include "win32/time.h"
 
71
#elif defined(NETWARE)
 
72
#include <sys/timeval.h>
 
73
#include <sys/time.h>
 
74
#else
 
75
#include <sys/time.h>
 
76
#endif
 
77
 
 
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);
 
82
#else
 
83
#define DBG_PROFILE_TIMEVAL_TO_DOUBLE(tp)
 
84
#define DBG_PROFILE_START_TIME()
 
85
#define DBG_PROFILE_END_TIME(duration)
 
86
#endif
 
87
 
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)
71
92
 
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; \
 
97
                                        if ((dbg_obj)) { \
 
98
                                                dbg_skip_trace = !(dbg_obj)->m->func_enter((dbg_obj), __LINE__, __FILE__, func_name, strlen(func_name)); \
 
99
                                        } \
 
100
                                        do { \
 
101
                                                if ((dbg_obj) && (dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \
 
102
                                                        DBG_PROFILE_START_TIME(); \
 
103
                                                } \
 
104
                                        } while (0); 
 
105
 
 
106
#define DBG_RETURN_EX(dbg_obj, value)   \
 
107
                        do {\
 
108
                                if ((dbg_obj)) { \
 
109
                                        uint64_t this_call_duration = 0; \
 
110
                                        if ((dbg_obj)->flags & MYSQLND_DEBUG_PROFILE_CALLS) { \
 
111
                                                DBG_PROFILE_END_TIME(this_call_duration); \
 
112
                                        } \
 
113
                                        (dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__, this_call_duration); \
 
114
                                } \
 
115
                                return (value);\
 
116
                        } while (0)
 
117
#define DBG_VOID_RETURN_EX(dbg_obj)     \
 
118
                        do {\
 
119
                                if ((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); \
 
123
                                        } \
 
124
                                        (dbg_obj)->m->func_leave((dbg_obj), __LINE__, __FILE__, this_call_duration); \
 
125
                                } \
 
126
                                return;\
 
127
                        } while (0)
75
128
 
76
129
#else
77
130
static inline void DBG_INF_EX(MYSQLND_DEBUG * dbg_obj, const char * const msg) {}
82
135
#define DBG_RETURN_EX(dbg_obj, value) return (value)
83
136
#define DBG_VOID_RETURN_EX(dbg_obj) return
84
137
 
85
 
#endif
 
138
#endif /* defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 1400)) */
86
139
 
87
140
#if MYSQLND_DBG_ENABLED == 1
88
141