mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Pass orig filename and line through to emalloc and friends
This commit is contained in:
parent
7d900356e9
commit
d6e421f6a6
2 changed files with 29 additions and 28 deletions
|
@ -65,8 +65,8 @@ const char * mysqlnd_debug_std_no_trace_funcs[] =
|
|||
|
||||
#if ZEND_DEBUG
|
||||
#else
|
||||
#define __zend_filename "/unknown/unknown"
|
||||
#define __zend_lineno 0
|
||||
#define __zend_orig_filename "/unknown/unknown"
|
||||
#define __zend_orig_lineno 0
|
||||
#endif
|
||||
|
||||
#define REAL_SIZE(s) (collect_memory_statistics? (s) + sizeof(size_t) : (s))
|
||||
|
@ -83,13 +83,13 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
|
|||
#endif
|
||||
DBG_ENTER(mysqlnd_emalloc_name);
|
||||
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
|
||||
#if PHP_DEBUG
|
||||
/* -1 is also "true" */
|
||||
if (*threshold) {
|
||||
#endif
|
||||
ret = emalloc(REAL_SIZE(size));
|
||||
ret = _emalloc(REAL_SIZE(size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
#if PHP_DEBUG
|
||||
--*threshold;
|
||||
} else if (*threshold == 0) {
|
||||
|
@ -117,13 +117,13 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D)
|
|||
long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
|
||||
#endif
|
||||
DBG_ENTER(mysqlnd_pemalloc_name);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
|
||||
#if PHP_DEBUG
|
||||
/* -1 is also "true" */
|
||||
if (*threshold) {
|
||||
#endif
|
||||
ret = pemalloc(REAL_SIZE(size), persistent);
|
||||
ret = (persistent) ? __zend_malloc(REAL_SIZE(size)) : _emalloc(REAL_SIZE(size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
#if PHP_DEBUG
|
||||
--*threshold;
|
||||
} else if (*threshold == 0) {
|
||||
|
@ -154,14 +154,14 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
|
|||
long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
|
||||
#endif
|
||||
DBG_ENTER(mysqlnd_ecalloc_name);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
DBG_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
|
||||
|
||||
#if PHP_DEBUG
|
||||
/* -1 is also "true" */
|
||||
if (*threshold) {
|
||||
#endif
|
||||
ret = ecalloc(nmemb, REAL_SIZE(size));
|
||||
ret = _ecalloc(nmemb, REAL_SIZE(size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
#if PHP_DEBUG
|
||||
--*threshold;
|
||||
} else if (*threshold == 0) {
|
||||
|
@ -189,13 +189,13 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M
|
|||
long * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
|
||||
#endif
|
||||
DBG_ENTER(mysqlnd_pecalloc_name);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
|
||||
#if PHP_DEBUG
|
||||
/* -1 is also "true" */
|
||||
if (*threshold) {
|
||||
#endif
|
||||
ret = pecalloc(nmemb, REAL_SIZE(size), persistent);
|
||||
ret = (persistent) ? __zend_calloc(nmemb, REAL_SIZE(size)) : _ecalloc(nmemb, REAL_SIZE(size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
#if PHP_DEBUG
|
||||
--*threshold;
|
||||
} else if (*threshold == 0) {
|
||||
|
@ -227,14 +227,14 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
|
|||
long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
|
||||
#endif
|
||||
DBG_ENTER(mysqlnd_erealloc_name);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
DBG_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size, new_size);
|
||||
|
||||
#if PHP_DEBUG
|
||||
/* -1 is also "true" */
|
||||
if (*threshold) {
|
||||
#endif
|
||||
ret = erealloc(REAL_PTR(ptr), REAL_SIZE(new_size));
|
||||
ret = _erealloc(REAL_PTR(ptr), REAL_SIZE(new_size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
#if PHP_DEBUG
|
||||
--*threshold;
|
||||
} else if (*threshold == 0) {
|
||||
|
@ -262,7 +262,7 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
|
|||
long * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
|
||||
#endif
|
||||
DBG_ENTER(mysqlnd_perealloc_name);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
DBG_INF_FMT("ptr=%p old_size=%lu new_size=%lu persistent=%u", ptr, old_size, new_size, persistent);
|
||||
|
||||
#if PHP_DEBUG
|
||||
|
@ -296,7 +296,7 @@ void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
|
|||
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("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
DBG_INF_FMT("ptr=%p", ptr);
|
||||
|
||||
if (ptr) {
|
||||
|
@ -304,7 +304,7 @@ void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
|
|||
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));
|
||||
_efree(REAL_PTR(ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
|
||||
if (collect_memory_statistics) {
|
||||
|
@ -321,7 +321,7 @@ void _mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D)
|
|||
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("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
DBG_INF_FMT("ptr=%p persistent=%u", ptr, persistent);
|
||||
|
||||
if (ptr) {
|
||||
|
@ -329,7 +329,7 @@ void _mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D)
|
|||
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);
|
||||
(persistent) ? free(REAL_PTR(ptr)) : _efree(REAL_PTR(ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
}
|
||||
|
||||
if (collect_memory_statistics) {
|
||||
|
@ -338,6 +338,7 @@ void _mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D)
|
|||
}
|
||||
DBG_VOID_RETURN;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ _mysqlnd_malloc */
|
||||
|
@ -349,7 +350,7 @@ void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D)
|
|||
long * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
|
||||
#endif
|
||||
DBG_ENTER(mysqlnd_malloc_name);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
|
||||
#if PHP_DEBUG
|
||||
/* -1 is also "true" */
|
||||
|
@ -382,7 +383,7 @@ void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
|
|||
long * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
|
||||
#endif
|
||||
DBG_ENTER(mysqlnd_calloc_name);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
|
||||
#if PHP_DEBUG
|
||||
/* -1 is also "true" */
|
||||
|
@ -415,7 +416,7 @@ void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D)
|
|||
long * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
|
||||
#endif
|
||||
DBG_ENTER(mysqlnd_realloc_name);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_filename, PHP_DIR_SEPARATOR) + 1, __zend_lineno);
|
||||
DBG_INF_FMT("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
DBG_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr);
|
||||
DBG_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC));
|
||||
|
||||
|
@ -448,7 +449,7 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D)
|
|||
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("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
DBG_INF_FMT("ptr=%p", ptr);
|
||||
|
||||
if (ptr) {
|
||||
|
@ -477,10 +478,10 @@ char * _mysqlnd_pestrndup(const char * const ptr, size_t length, zend_bool persi
|
|||
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("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_lineno);
|
||||
DBG_INF_FMT("ptr=%p", ptr);
|
||||
|
||||
ret = pemalloc(REAL_SIZE(length) + 1, persistent);
|
||||
ret = (persistent) ? __zend_malloc(REAL_SIZE(length + 1)) : _emalloc(REAL_SIZE(length + 1) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
{
|
||||
size_t l = length;
|
||||
char * p = (char *) ptr;
|
||||
|
@ -509,13 +510,13 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME
|
|||
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("file=%-15s line=%4d", strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR) + 1, __zend_orig_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);
|
||||
ret = (persistent) ? __zend_malloc(tmp_str.len + sizeof(size_t)) : _emalloc(REAL_SIZE(tmp_str.len + sizeof(size_t)) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
|
||||
memcpy(FAKE_PTR(ret), tmp_str.c, tmp_str.len);
|
||||
|
||||
if (ret && collect_memory_statistics) {
|
||||
|
@ -549,7 +550,7 @@ PHPAPI void _mysqlnd_sprintf_free(char * p)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
/* {{{ _mysqlnd_vsprintf */
|
||||
PHPAPI int _mysqlnd_vsprintf(char ** pbuf, size_t max_len, const char * format, va_list ap)
|
||||
{
|
||||
return vspprintf(pbuf, max_len, format, ap);
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
|
||||
extern const char * mysqlnd_debug_std_no_trace_funcs[];
|
||||
|
||||
#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 MYSQLND_MEM_D TSRMLS_DC ZEND_FILE_LINE_ORIG_DC
|
||||
#define MYSQLND_MEM_C TSRMLS_CC ZEND_FILE_LINE_CC
|
||||
|
||||
struct st_mysqlnd_allocator_methods
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue