com php-src: - Added argument name to backtrace dump: phpdbg_frame.c phpdbg_utils.c phpdbg_utils.h

From: Date: Sun, 08 Dec 2013 19:37:35 +0000
Subject: com php-src: - Added argument name to backtrace dump: phpdbg_frame.c phpdbg_utils.c phpdbg_utils.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-75280@lists.php.net to get a copy of this message
Commit: 50e8a47c901a262eee0ff88677730723ffdd9e25 Author: Felipe Pena <felipensp@gmail.com> Sun, 8 Dec 2013 17:37:35 -0200 Parents: 508772840e6a5a11b29d314fb4134aac2a5120dd Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=50e8a47c901a262eee0ff88677730723ffdd9e25 Log: - Added argument name to backtrace dump Changed paths: M phpdbg_frame.c M phpdbg_utils.c M phpdbg_utils.h Diff: diff --git a/phpdbg_frame.c b/phpdbg_frame.c index 1037265..1bc1f9c 100644 --- a/phpdbg_frame.c +++ b/phpdbg_frame.c @@ -130,11 +130,19 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */ if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), (void **)&args) == SUCCESS) { HashPosition iterator; - int j = 0; + const zend_function *func = phpdbg_get_function( + Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC); + const zend_arg_info *arginfo = func ? func->common.arg_info : NULL; + int j = 0, m = func ? func->common.num_args : 0; zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator); while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args), (void **) &argstmp, &iterator) == SUCCESS) { + + if (m && j < m) { + phpdbg_write("%s=", arginfo[j].name); + } + if (j++) { phpdbg_write(", "); } diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 67e1cbc..f543af0 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -144,6 +144,33 @@ PHPDBG_API const char *phpdbg_current_file(TSRMLS_D) /* {{{ */ return file; } /* }}} */ +PHPDBG_API const zend_function *phpdbg_get_function(const char *fname, const char *cname TSRMLS_DC) /* {{{ */ +{ + zend_function *func = NULL; + size_t fname_len = strlen(fname); + char *lcname = zend_str_tolower_dup(fname, fname_len); + + if (cname) { + zend_class_entry **ce; + size_t cname_len = strlen(cname); + char *lc_cname = zend_str_tolower_dup(cname, cname_len); + int ret = zend_lookup_class(lc_cname, cname_len, &ce TSRMLS_CC); + + efree(lc_cname); + + if (ret == SUCCESS) { + zend_hash_find(&(*ce)->function_table, lcname, fname_len+1, + (void**)&func); + } + } else { + zend_hash_find(EG(function_table), lcname, fname_len+1, + (void**)&func); + } + + efree(lcname); + return func; +} /* }}} */ + PHPDBG_API char *phpdbg_trim(const char *str, size_t len, size_t *new_len) /* {{{ */ { const char *p = str; @@ -245,18 +272,18 @@ PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *format, .. PHPDBG_API int phpdbg_rlog(FILE *fp, const char *fmt, ...) { /* {{{ */ int rc = 0; - + va_list args; struct timeval tp; - + va_start(args, fmt); if (gettimeofday(&tp, NULL) == SUCCESS) { char friendly[100]; char *format = NULL, *buffer = NULL; - + strftime(friendly, 100, "%a %b %d %T.%%04d %Y", localtime(&tp..tv_sec)); asprintf( - &buffer, friendly, tp.tv_usec/1000); + &buffer, friendly, tp.tv_usec/1000); asprintf( &format, "[%s]: %s\n", buffer, fmt); rc = vfprintf( @@ -266,7 +293,7 @@ PHPDBG_API int phpdbg_rlog(FILE *fp, const char *fmt, ...) { /* {{{ */ free(buffer); } va_end(args); - + return rc; } /* }}} */ @@ -327,7 +354,7 @@ PHPDBG_API void phpdbg_set_prompt(const char *prompt TSRMLS_DC) /* {{{ */ } /* }}} */ PHPDBG_API const char *phpdbg_get_prompt(TSRMLS_D) /* {{{ */ -{ +{ /* find cached prompt */ if (PHPDBG_G(prompt)[1]) { return PHPDBG_G(prompt)[1]; diff --git a/phpdbg_utils.h b/phpdbg_utils.h index 3252f36..3126d0c 100644 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@ -30,6 +30,7 @@ PHPDBG_API int phpdbg_is_class_method(const char*, size_t, char**, char**); PHPDBG_API const char *phpdbg_current_file(TSRMLS_D); PHPDBG_API char *phpdbg_resolve_path(const char* TSRMLS_DC); PHPDBG_API char *phpdbg_trim(const char*, size_t, size_t*); +PHPDBG_API const zend_function *phpdbg_get_function(const char*, const char* TSRMLS_DC); /** * Error/notice/formatting helpers

« previous php.cvs (#75280) next »