From: Felipe Pena Date: Sun, 8 Dec 2013 18:47:53 +0000 (-0200) Subject: - Splitting prototype dumping code X-Git-Tag: php-5.6.0alpha1~110^2~24^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1fc10b5706422e4a59788040b7fbba497e5939a6;p=php - Splitting prototype dumping code --- diff --git a/phpdbg_frame.c b/phpdbg_frame.c index bbd7d340b7..c35a4f96f1 100644 --- a/phpdbg_frame.c +++ b/phpdbg_frame.c @@ -100,14 +100,58 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */ ); } /* }}} */ +static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */ +{ + zval **funcname, **class, **type, **args, **argstmp; + char is_class; + + zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), + (void **)&funcname); + + if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp), + "object", sizeof("object"), (void **)&class)) == FAILURE) { + is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"), + (void **)&class); + } else { + zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class), + (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC); + } + + if (is_class == SUCCESS) { + zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type); + } + + phpdbg_write("%s%s%s(", + is_class == FAILURE?"":Z_STRVAL_PP(class), + is_class == FAILURE?"":Z_STRVAL_PP(type), + Z_STRVAL_PP(funcname) + ); + + if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), + (void **)&args) == SUCCESS) { + HashPosition iterator; + int j = 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 (j++) { + phpdbg_write(", "); + } + zend_print_flat_zval_r(*argstmp TSRMLS_CC); + zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator); + } + } + phpdbg_write(")"); +} + void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ { zval zbacktrace; - zval **tmp, **argstmp; - zval **file, **line, **funcname, **class, **type, **args; + zval **tmp; + zval **file, **line; HashPosition position; int i = 0, limit = num; - char is_class; if (limit < 0) { phpdbg_error("Invalid backtrace size %d", limit); @@ -122,45 +166,16 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **)&file); zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **)&line); zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position); + + phpdbg_write("frame #%d: ", i++); + if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position) == FAILURE) { - phpdbg_write( - "frame #%d: {main} at %s:%ld", - i, Z_STRVAL_PP(file), Z_LVAL_PP(line)); + phpdbg_write("{main} at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); break; } - zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), (void **)&funcname); - if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "object", sizeof("object"), (void **)&class)) == FAILURE) { - is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"), (void **)&class); - } else { - zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class), (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC); - } - if (is_class == SUCCESS) { - zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type); - } - - phpdbg_write( - "frame #%d: %s%s%s(", - i++, - is_class == FAILURE?"":Z_STRVAL_PP(class), - is_class == FAILURE?"":Z_STRVAL_PP(type), - Z_STRVAL_PP(funcname) - ); - - if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), (void **)&args) == SUCCESS) { - HashPosition iterator; - int j = 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 (j++) { - phpdbg_write(", "); - } - zend_print_flat_zval_r(*argstmp TSRMLS_CC); - zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator); - } - } - phpdbg_writeln(") at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); + phpdbg_dump_prototype(tmp TSRMLS_CC); + phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); } phpdbg_writeln(EMPTY); diff --git a/phpdbg_frame.h b/phpdbg_frame.h index 4b874b0ee9..fbccd5404f 100644 --- a/phpdbg_frame.h +++ b/phpdbg_frame.h @@ -22,7 +22,6 @@ #define PHPDBG_FRAME_H #include "TSRM.h" -#include "phpdbg_cmd.h" void phpdbg_restore_frame(TSRMLS_D); void phpdbg_switch_frame(int TSRMLS_DC);