Back to index

php5  5.3.10
Classes | Defines | Functions | Variables
mysqlnd_debug.h File Reference
#include "zend_stack.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  st_mysqlnd_debug_methods
struct  st_mysqlnd_debug
struct  st_mysqlnd_allocator_methods

Defines

#define DBG_BLOCK_ENTER(bname)   {
#define DBG_RETURN_EX(dbg_obj, value)   return (value)
#define DBG_VOID_RETURN_EX(dbg_obj)   return
#define DBG_BLOCK_LEAVE_EX(dbg_obj)   }
#define DBG_BLOCK_ENTER(bname)   {
#define DBG_RETURN(value)   return (value)
#define DBG_VOID_RETURN   return
#define DBG_BLOCK_LEAVE   }
#define MYSQLND_MEM_D   TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC
#define MYSQLND_MEM_C   TSRMLS_CC ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC
#define mnd_emalloc(size)   mysqlnd_allocator.m_emalloc((size) MYSQLND_MEM_C)
#define mnd_pemalloc(size, pers)   mysqlnd_allocator.m_pemalloc((size), (pers) MYSQLND_MEM_C)
#define mnd_ecalloc(nmemb, size)   mysqlnd_allocator.m_ecalloc((nmemb), (size) MYSQLND_MEM_C)
#define mnd_pecalloc(nmemb, size, p)   mysqlnd_allocator.m_pecalloc((nmemb), (size), (p) MYSQLND_MEM_C)
#define mnd_erealloc(ptr, new_size)   mysqlnd_allocator.m_erealloc((ptr), (new_size) MYSQLND_MEM_C)
#define mnd_perealloc(ptr, new_size, p)   mysqlnd_allocator.m_perealloc((ptr), (new_size), (p) MYSQLND_MEM_C)
#define mnd_efree(ptr)   mysqlnd_allocator.m_efree((ptr) MYSQLND_MEM_C)
#define mnd_pefree(ptr, pers)   mysqlnd_allocator.m_pefree((ptr), (pers) MYSQLND_MEM_C)
#define mnd_malloc(size)   mysqlnd_allocator.m_malloc((size) MYSQLND_MEM_C)
#define mnd_calloc(nmemb, size)   mysqlnd_allocator.m_calloc((nmemb), (size) MYSQLND_MEM_C)
#define mnd_realloc(ptr, new_size)   mysqlnd_allocator.m_realloc((ptr), (new_size) MYSQLND_MEM_C)
#define mnd_free(ptr)   mysqlnd_allocator.m_free((ptr) MYSQLND_MEM_C)
#define mnd_pestrndup(ptr, size, pers)   mysqlnd_allocator.m_pestrndup((ptr), (size), (pers) MYSQLND_MEM_C)
#define mnd_pestrdup(ptr, pers)   mysqlnd_allocator.m_pestrdup((ptr), (pers) MYSQLND_MEM_C)

Functions

PHPAPI MYSQLND_DEBUG * mysqlnd_debug_init (const char *skip_functions[] TSRMLS_DC)
PHPAPI char * mysqlnd_get_backtrace (uint max_levels, size_t *length TSRMLS_DC)
static void DBG_INF_EX (MYSQLND_DEBUG *dbg_obj, const char *const msg)
static void DBG_ERR_EX (MYSQLND_DEBUG *dbg_obj, const char *const msg)
static void DBG_INF_FMT_EX (MYSQLND_DEBUG *dbg_obj,...)
static void DBG_ERR_FMT_EX (MYSQLND_DEBUG *dbg_obj,...)
static void DBG_ENTER_EX (MYSQLND_DEBUG *dbg_obj, const char *const func_name)
static void DBG_INF (const char *const msg)
static void DBG_ERR (const char *const msg)
static void DBG_INF_FMT (const char *const format,...)
static void DBG_ERR_FMT (const char *const format,...)
static void DBG_ENTER (const char *const func_name)
PHPAPI void * _mysqlnd_emalloc (size_t size MYSQLND_MEM_D)
PHPAPI void * _mysqlnd_pemalloc (size_t size, zend_bool persistent MYSQLND_MEM_D)
PHPAPI void * _mysqlnd_ecalloc (unsigned int nmemb, size_t size MYSQLND_MEM_D)
PHPAPI void * _mysqlnd_pecalloc (unsigned int nmemb, size_t size, zend_bool persistent MYSQLND_MEM_D)
PHPAPI void * _mysqlnd_erealloc (void *ptr, size_t new_size MYSQLND_MEM_D)
PHPAPI void * _mysqlnd_perealloc (void *ptr, size_t new_size, zend_bool persistent MYSQLND_MEM_D)
PHPAPI void _mysqlnd_efree (void *ptr MYSQLND_MEM_D)
PHPAPI void _mysqlnd_pefree (void *ptr, zend_bool persistent MYSQLND_MEM_D)
PHPAPI void * _mysqlnd_malloc (size_t size MYSQLND_MEM_D)
PHPAPI void * _mysqlnd_calloc (unsigned int nmemb, size_t size MYSQLND_MEM_D)
PHPAPI void * _mysqlnd_realloc (void *ptr, size_t new_size MYSQLND_MEM_D)
PHPAPI void _mysqlnd_free (void *ptr MYSQLND_MEM_D)
PHPAPI char * _mysqlnd_pestrndup (const char *const ptr, size_t size, zend_bool persistent MYSQLND_MEM_D)
PHPAPI char * _mysqlnd_pestrdup (const char *const ptr, zend_bool persistent MYSQLND_MEM_D)

Variables

PHPAPI const char * mysqlnd_debug_std_no_trace_funcs []
PHPAPI struct st_mysqlnd_allocator_methods

Class Documentation

struct st_mysqlnd_debug

Definition at line 44 of file mysqlnd_debug.h.

Collaboration diagram for st_mysqlnd_debug:
Class Members
zend_stack call_stack
zend_stack call_time_stack
char * file_name
unsigned int flags
HashTable function_profiles
struct st_mysqlnd_debug_methods * m
unsigned int nest_level_limit
HashTable not_filtered_functions
int pid
const char ** skip_functions
php_stream * stream

Define Documentation

#define DBG_BLOCK_ENTER (   bname)    {

Definition at line 168 of file mysqlnd_debug.h.

#define DBG_BLOCK_ENTER (   bname)    {

Definition at line 168 of file mysqlnd_debug.h.

#define DBG_BLOCK_LEAVE   }

Definition at line 171 of file mysqlnd_debug.h.

#define DBG_BLOCK_LEAVE_EX (   dbg_obj)    }

Definition at line 142 of file mysqlnd_debug.h.

#define DBG_RETURN (   value)    return (value)

Definition at line 169 of file mysqlnd_debug.h.

#define DBG_RETURN_EX (   dbg_obj,
  value 
)    return (value)

Definition at line 140 of file mysqlnd_debug.h.

#define DBG_VOID_RETURN   return

Definition at line 170 of file mysqlnd_debug.h.

#define DBG_VOID_RETURN_EX (   dbg_obj)    return

Definition at line 141 of file mysqlnd_debug.h.

#define mnd_calloc (   nmemb,
  size 
)    mysqlnd_allocator.m_calloc((nmemb), (size) MYSQLND_MEM_C)

Definition at line 225 of file mysqlnd_debug.h.

#define mnd_ecalloc (   nmemb,
  size 
)    mysqlnd_allocator.m_ecalloc((nmemb), (size) MYSQLND_MEM_C)

Definition at line 218 of file mysqlnd_debug.h.

#define mnd_efree (   ptr)    mysqlnd_allocator.m_efree((ptr) MYSQLND_MEM_C)

Definition at line 222 of file mysqlnd_debug.h.

#define mnd_emalloc (   size)    mysqlnd_allocator.m_emalloc((size) MYSQLND_MEM_C)

Definition at line 216 of file mysqlnd_debug.h.

#define mnd_erealloc (   ptr,
  new_size 
)    mysqlnd_allocator.m_erealloc((ptr), (new_size) MYSQLND_MEM_C)

Definition at line 220 of file mysqlnd_debug.h.

#define mnd_free (   ptr)    mysqlnd_allocator.m_free((ptr) MYSQLND_MEM_C)

Definition at line 227 of file mysqlnd_debug.h.

#define mnd_malloc (   size)    mysqlnd_allocator.m_malloc((size) MYSQLND_MEM_C)

Definition at line 224 of file mysqlnd_debug.h.

#define mnd_pecalloc (   nmemb,
  size,
 
)    mysqlnd_allocator.m_pecalloc((nmemb), (size), (p) MYSQLND_MEM_C)

Definition at line 219 of file mysqlnd_debug.h.

#define mnd_pefree (   ptr,
  pers 
)    mysqlnd_allocator.m_pefree((ptr), (pers) MYSQLND_MEM_C)

Definition at line 223 of file mysqlnd_debug.h.

#define mnd_pemalloc (   size,
  pers 
)    mysqlnd_allocator.m_pemalloc((size), (pers) MYSQLND_MEM_C)

Definition at line 217 of file mysqlnd_debug.h.

#define mnd_perealloc (   ptr,
  new_size,
 
)    mysqlnd_allocator.m_perealloc((ptr), (new_size), (p) MYSQLND_MEM_C)

Definition at line 221 of file mysqlnd_debug.h.

#define mnd_pestrdup (   ptr,
  pers 
)    mysqlnd_allocator.m_pestrdup((ptr), (pers) MYSQLND_MEM_C)

Definition at line 229 of file mysqlnd_debug.h.

#define mnd_pestrndup (   ptr,
  size,
  pers 
)    mysqlnd_allocator.m_pestrndup((ptr), (size), (pers) MYSQLND_MEM_C)

Definition at line 228 of file mysqlnd_debug.h.

#define mnd_realloc (   ptr,
  new_size 
)    mysqlnd_allocator.m_realloc((ptr), (new_size) MYSQLND_MEM_C)

Definition at line 226 of file mysqlnd_debug.h.

Definition at line 177 of file mysqlnd_debug.h.

Definition at line 176 of file mysqlnd_debug.h.


Function Documentation

PHPAPI void* _mysqlnd_calloc ( unsigned int  nmemb,
size_t size  MYSQLND_MEM_D 
)

Definition at line 1105 of file mysqlnd_debug.c.

{
       void *ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       long * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
       DBG_ENTER(mysqlnd_calloc_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);

#ifdef PHP_DEBUG
       /* -1 is also "true" */
       if (*threshold) {
#endif
              ret = calloc(nmemb, REAL_SIZE(size));
#ifdef PHP_DEBUG
              --*threshold;
       } else if (*threshold == 0) {
              ret = NULL;
       }
#endif

       DBG_INF_FMT("size=%lu ptr=%p", size, ret);
       if (ret && collect_memory_statistics) {
              *(size_t *) ret = size;
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_CALLOC_COUNT, 1, STAT_MEM_CALLOC_AMOUNT, size);
       }
       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI void* _mysqlnd_ecalloc ( unsigned int  nmemb,
size_t size  MYSQLND_MEM_D 
)

Definition at line 887 of file mysqlnd_debug.c.

{
       void *ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
       DBG_ENTER(mysqlnd_ecalloc_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
       DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));

#ifdef PHP_DEBUG
       /* -1 is also "true" */
       if (*threshold) {
#endif
              ret = ecalloc(nmemb, REAL_SIZE(size));
#ifdef PHP_DEBUG
              --*threshold;
       } else if (*threshold == 0) {
              ret = NULL;
       }
#endif

       DBG_INF_FMT("after : %lu", zend_memory_usage(FALSE TSRMLS_CC));
       DBG_INF_FMT("size=%lu ptr=%p", size, ret);
       if (ret && collect_memory_statistics) {
              *(size_t *) ret = size;
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_ECALLOC_COUNT, 1, STAT_MEM_ECALLOC_AMOUNT, size);
       }
       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI void _mysqlnd_efree ( void *ptr  MYSQLND_MEM_D)

Definition at line 1024 of file mysqlnd_debug.c.

{
       size_t free_amount = 0;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       DBG_ENTER(mysqlnd_efree_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
       DBG_INF_FMT("ptr=%p", ptr); 

       if (ptr) {
              if (collect_memory_statistics) {
                     free_amount = *(size_t *)(((char*)ptr) - sizeof(size_t));
                     DBG_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount);
              }
              efree(REAL_PTR(ptr));
       }

       if (collect_memory_statistics) {
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_EFREE_COUNT, 1, STAT_MEM_EFREE_AMOUNT, free_amount);
       }
       DBG_VOID_RETURN;
}

Here is the call graph for this function:

PHPAPI void* _mysqlnd_emalloc ( size_t size  MYSQLND_MEM_D)

Definition at line 819 of file mysqlnd_debug.c.

{
       void *ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       long * threshold = &MYSQLND_G(debug_emalloc_fail_threshold);
       DBG_ENTER(mysqlnd_emalloc_name);

       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);

#ifdef PHP_DEBUG
       /* -1 is also "true" */
       if (*threshold) {
#endif
              ret = emalloc(REAL_SIZE(size));
#ifdef PHP_DEBUG
              --*threshold;
       } else if (*threshold == 0) {
              ret = NULL;
       }
#endif

       DBG_INF_FMT("size=%lu ptr=%p", size, ret);

       if (ret && collect_memory_statistics) {
              *(size_t *) ret = size;
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_EMALLOC_COUNT, 1, STAT_MEM_EMALLOC_AMOUNT, size);
       }
       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI void* _mysqlnd_erealloc ( void *  ptr,
size_t new_size  MYSQLND_MEM_D 
)

Definition at line 955 of file mysqlnd_debug.c.

{
       void *ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
       long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
       DBG_ENTER(mysqlnd_erealloc_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
       DBG_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size, new_size); 

#ifdef PHP_DEBUG
       /* -1 is also "true" */
       if (*threshold) {
#endif
              ret = erealloc(REAL_PTR(ptr), REAL_SIZE(new_size));
#ifdef PHP_DEBUG
              --*threshold;
       } else if (*threshold == 0) {
              ret = NULL;
       }
#endif

       DBG_INF_FMT("new_ptr=%p", (char*)ret);
       if (ret && collect_memory_statistics) {
              *(size_t *) ret = new_size;
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_EREALLOC_COUNT, 1, STAT_MEM_EREALLOC_AMOUNT, new_size);
       }
       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI void _mysqlnd_free ( void *ptr  MYSQLND_MEM_D)

Definition at line 1170 of file mysqlnd_debug.c.

{
       size_t free_amount = 0;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       DBG_ENTER(mysqlnd_free_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
       DBG_INF_FMT("ptr=%p", ptr); 

       if (ptr) {
              if (collect_memory_statistics) {
                     free_amount = *(size_t *)(((char*)ptr) - sizeof(size_t));
                     DBG_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount);
              }
              free(REAL_PTR(ptr));
       }

       if (collect_memory_statistics) {
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_FREE_COUNT, 1, STAT_MEM_FREE_AMOUNT, free_amount);
       }
       DBG_VOID_RETURN;
}

Here is the call graph for this function:

PHPAPI void* _mysqlnd_malloc ( size_t size  MYSQLND_MEM_D)

Definition at line 1074 of file mysqlnd_debug.c.

{
       void *ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       long * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
       DBG_ENTER(mysqlnd_malloc_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);

#ifdef PHP_DEBUG
       /* -1 is also "true" */
       if (*threshold) {
#endif
              ret = malloc(REAL_SIZE(size));
#ifdef PHP_DEBUG
              --*threshold;
       } else if (*threshold == 0) {
              ret = NULL;
       }
#endif

       DBG_INF_FMT("size=%lu ptr=%p", size, ret);
       if (ret && collect_memory_statistics) {
              *(size_t *) ret = size;
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_MALLOC_COUNT, 1, STAT_MEM_MALLOC_AMOUNT, size);
       }
       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI void* _mysqlnd_pecalloc ( unsigned int  nmemb,
size_t  size,
zend_bool persistent  MYSQLND_MEM_D 
)

Definition at line 920 of file mysqlnd_debug.c.

{
       void *ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       long * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
       DBG_ENTER(mysqlnd_pecalloc_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);

#ifdef PHP_DEBUG
       /* -1 is also "true" */
       if (*threshold) {
#endif
              ret = pecalloc(nmemb, REAL_SIZE(size), persistent);
#ifdef PHP_DEBUG
              --*threshold;
       } else if (*threshold == 0) {
              ret = NULL;
       }
#endif

       DBG_INF_FMT("size=%lu ptr=%p", size, ret);

       if (ret && collect_memory_statistics) {
              enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_CALLOC_COUNT:STAT_MEM_ECALLOC_COUNT;
              enum mysqlnd_collected_stats s2 = persistent? STAT_MEM_CALLOC_AMOUNT:STAT_MEM_ECALLOC_AMOUNT;
              *(size_t *) ret = size;
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(s1, 1, s2, size);
       }

       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI void _mysqlnd_pefree ( void *  ptr,
zend_bool persistent  MYSQLND_MEM_D 
)

Definition at line 1049 of file mysqlnd_debug.c.

{
       size_t free_amount = 0;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       DBG_ENTER(mysqlnd_pefree_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
       DBG_INF_FMT("ptr=%p persistent=%u", ptr, persistent); 

       if (ptr) {
              if (collect_memory_statistics) {
                     free_amount = *(size_t *)(((char*)ptr) - sizeof(size_t));
                     DBG_INF_FMT("ptr=%p size=%u", ((char*)ptr) - sizeof(size_t), (unsigned int) free_amount);
              }
              pefree(REAL_PTR(ptr), persistent);
       }

       if (collect_memory_statistics) {
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(persistent? STAT_MEM_FREE_COUNT:STAT_MEM_EFREE_COUNT, 1,
                                                                               persistent? STAT_MEM_FREE_AMOUNT:STAT_MEM_EFREE_AMOUNT, free_amount);
       }
       DBG_VOID_RETURN;
}

Here is the call graph for this function:

PHPAPI void* _mysqlnd_pemalloc ( size_t  size,
zend_bool persistent  MYSQLND_MEM_D 
)

Definition at line 852 of file mysqlnd_debug.c.

{
       void *ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
       DBG_ENTER(mysqlnd_pemalloc_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);

#ifdef PHP_DEBUG
       /* -1 is also "true" */
       if (*threshold) {
#endif
              ret = pemalloc(REAL_SIZE(size), persistent);
#ifdef PHP_DEBUG
              --*threshold;
       } else if (*threshold == 0) {
              ret = NULL;
       }
#endif

       DBG_INF_FMT("size=%lu ptr=%p persistent=%u", size, ret, persistent);

       if (ret && collect_memory_statistics) {
              enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_MALLOC_COUNT:STAT_MEM_EMALLOC_COUNT;
              enum mysqlnd_collected_stats s2 = persistent? STAT_MEM_MALLOC_AMOUNT:STAT_MEM_EMALLOC_AMOUNT;
              *(size_t *) ret = size;
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(s1, 1, s2, size);
       }

       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI void* _mysqlnd_perealloc ( void *  ptr,
size_t  new_size,
zend_bool persistent  MYSQLND_MEM_D 
)

Definition at line 988 of file mysqlnd_debug.c.

{
       void *ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       size_t old_size = collect_memory_statistics && ptr? *(size_t *) (((char*)ptr) - sizeof(size_t)) : 0;
       long * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
       DBG_ENTER(mysqlnd_perealloc_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
       DBG_INF_FMT("ptr=%p old_size=%lu new_size=%lu persistent=%u", ptr, old_size, new_size, persistent); 

#ifdef PHP_DEBUG
       /* -1 is also "true" */
       if (*threshold) {
#endif
              ret = perealloc(REAL_PTR(ptr), REAL_SIZE(new_size), persistent);
#ifdef PHP_DEBUG
              --*threshold;
       } else if (*threshold == 0) {
              ret = NULL;
       }
#endif

       DBG_INF_FMT("new_ptr=%p", (char*)ret);

       if (ret && collect_memory_statistics) {
              enum mysqlnd_collected_stats s1 = persistent? STAT_MEM_REALLOC_COUNT:STAT_MEM_EREALLOC_COUNT;
              enum mysqlnd_collected_stats s2 = persistent? STAT_MEM_REALLOC_AMOUNT:STAT_MEM_EREALLOC_AMOUNT;
              *(size_t *) ret = new_size;
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(s1, 1, s2, new_size);
       }
       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI char* _mysqlnd_pestrdup ( const char *const  ptr,
zend_bool persistent  MYSQLND_MEM_D 
)

Definition at line 1229 of file mysqlnd_debug.c.

{
       char * ret;
       smart_str tmp_str = {0, 0, 0};
       const char * p = ptr;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       DBG_ENTER(mysqlnd_pestrdup_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
       DBG_INF_FMT("ptr=%p", ptr);
       do {
              smart_str_appendc(&tmp_str, *p);
       } while (*p++);

       ret = pemalloc(tmp_str.len + sizeof(size_t), persistent);
       memcpy(FAKE_PTR(ret), tmp_str.c, tmp_str.len);

       if (ret && collect_memory_statistics) {
              *(size_t *) ret = tmp_str.len;
              MYSQLND_INC_GLOBAL_STATISTIC(persistent? STAT_MEM_STRDUP_COUNT : STAT_MEM_ESTRDUP_COUNT);
       }
       smart_str_free(&tmp_str);

       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI char* _mysqlnd_pestrndup ( const char *const  ptr,
size_t  size,
zend_bool persistent  MYSQLND_MEM_D 
)

Definition at line 1199 of file mysqlnd_debug.c.

{
       char * ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       DBG_ENTER(mysqlnd_pestrndup_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
       DBG_INF_FMT("ptr=%p", ptr); 

       ret = pemalloc(REAL_SIZE(length) + 1, persistent);
       {
              size_t l = length;
              char * p = (char *) ptr;
              char * dest = (char *) FAKE_PTR(ret);
              while (*p && l--) {
                     *dest++ = *p++;
              }
              *dest = '\0';
       }

       if (collect_memory_statistics) {
              *(size_t *) ret = length;
              MYSQLND_INC_GLOBAL_STATISTIC(persistent? STAT_MEM_STRNDUP_COUNT : STAT_MEM_ESTRNDUP_COUNT);
       }

       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

PHPAPI void* _mysqlnd_realloc ( void *  ptr,
size_t new_size  MYSQLND_MEM_D 
)

Definition at line 1136 of file mysqlnd_debug.c.

{
       void *ret;
       zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
       long * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
       DBG_ENTER(mysqlnd_realloc_name);
       DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
       DBG_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr); 
       DBG_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC));

#ifdef PHP_DEBUG
       /* -1 is also "true" */
       if (*threshold) {
#endif
              ret = realloc(REAL_PTR(ptr), REAL_SIZE(new_size));
#ifdef PHP_DEBUG
              --*threshold;
       } else if (*threshold == 0) {
              ret = NULL;
       }
#endif

       DBG_INF_FMT("new_ptr=%p", (char*)ret);

       if (ret && collect_memory_statistics) {
              *(size_t *) ret = new_size;
              MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(STAT_MEM_REALLOC_COUNT, 1, STAT_MEM_REALLOC_AMOUNT, new_size);
       }
       DBG_RETURN(FAKE_PTR(ret));
}

Here is the call graph for this function:

static void DBG_ENTER ( const char *const  func_name) [inline, static]

Definition at line 167 of file mysqlnd_debug.h.

{}
static void DBG_ENTER_EX ( MYSQLND_DEBUG *  dbg_obj,
const char *const  func_name 
) [inline, static]

Definition at line 138 of file mysqlnd_debug.h.

{}
static void DBG_ERR ( const char *const  msg) [inline, static]

Definition at line 164 of file mysqlnd_debug.h.

{}

Here is the caller graph for this function:

static void DBG_ERR_EX ( MYSQLND_DEBUG *  dbg_obj,
const char *const  msg 
) [inline, static]

Definition at line 135 of file mysqlnd_debug.h.

{}
static void DBG_ERR_FMT ( const char *const  format,
  ... 
) [inline, static]

Definition at line 166 of file mysqlnd_debug.h.

{}

Here is the caller graph for this function:

static void DBG_ERR_FMT_EX ( MYSQLND_DEBUG *  dbg_obj,
  ... 
) [inline, static]

Definition at line 137 of file mysqlnd_debug.h.

{}
static void DBG_INF ( const char *const  msg) [inline, static]

Definition at line 163 of file mysqlnd_debug.h.

{}

Here is the caller graph for this function:

static void DBG_INF_EX ( MYSQLND_DEBUG *  dbg_obj,
const char *const  msg 
) [inline, static]

Definition at line 134 of file mysqlnd_debug.h.

{}
static void DBG_INF_FMT ( const char *const  format,
  ... 
) [inline, static]

Definition at line 165 of file mysqlnd_debug.h.

{}
static void DBG_INF_FMT_EX ( MYSQLND_DEBUG *  dbg_obj,
  ... 
) [inline, static]

Definition at line 136 of file mysqlnd_debug.h.

{}
PHPAPI MYSQLND_DEBUG* mysqlnd_debug_init ( const char *skip_functions[]  TSRMLS_DC)

Definition at line 762 of file mysqlnd_debug.c.

{
       MYSQLND_DEBUG *ret = ecalloc(1, sizeof(MYSQLND_DEBUG));
#ifdef ZTS
       ret->TSRMLS_C = TSRMLS_C;
#endif
       ret->nest_level_limit = 0;
       ret->pid = getpid();
       zend_stack_init(&ret->call_stack);
       zend_stack_init(&ret->call_time_stack);
       zend_hash_init(&ret->not_filtered_functions, 0, NULL, NULL, 0);
       zend_hash_init(&ret->function_profiles, 0, NULL, NULL, 0);

       ret->m = & mysqlnd_mysqlnd_debug_methods;
       ret->skip_functions = skip_functions;

       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI char* mysqlnd_get_backtrace ( uint  max_levels,
size_t *length  TSRMLS_DC 
)

Definition at line 1831 of file mysqlnd_debug.c.

{
       zval *trace;
       char *res = estrdup(""), **str = &res, *s_tmp;
       int res_len = 0, *len = &res_len, num = 0;
       if (max_levels == 0) {
              max_levels = 99999;
       }

       MAKE_STD_ZVAL(trace);
       zend_fetch_debug_backtrace(trace, 0, 0 TSRMLS_CC);

       zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC, (apply_func_args_t)mysqlnd_build_trace_string, 4, &max_levels, str, len, &num);
       zval_ptr_dtor(&trace);

       if (max_levels) {
              s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1);
              sprintf(s_tmp, "#%d {main}", num);
              TRACE_APPEND_STRL(s_tmp, strlen(s_tmp));
              efree(s_tmp);
       }

       res[res_len] = '\0';
       *length = res_len;

       return res;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 54 of file mysqlnd_debug.c.

Definition at line 1373 of file mysqlnd_debug.c.