diff options
Diffstat (limited to 'sapi/phpdbg/phpdbg_frame.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_frame.c | 83 |
1 files changed, 47 insertions, 36 deletions
diff --git a/sapi/phpdbg/phpdbg_frame.c b/sapi/phpdbg/phpdbg_frame.c index 2c2d9e6177..a235fe8cb0 100644 --- a/sapi/phpdbg/phpdbg_frame.c +++ b/sapi/phpdbg/phpdbg_frame.c @@ -39,10 +39,11 @@ void phpdbg_restore_frame(TSRMLS_D) /* {{{ */ EG(opline_ptr) = &PHPDBG_EX(opline); EG(active_op_array) = PHPDBG_EX(op_array); + EG(return_value_ptr_ptr) = PHPDBG_EX(original_return_value); EG(active_symbol_table) = PHPDBG_EX(symbol_table); - Z_OBJ(EG(This)) = PHPDBG_EX(object); - EG(scope) = PHPDBG_EX(scope); - EG(called_scope) = PHPDBG_EX(called_scope); + EG(This) = PHPDBG_EX(current_this); + EG(scope) = PHPDBG_EX(current_scope); + EG(called_scope) = PHPDBG_EX(current_called_scope); } /* }}} */ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */ @@ -81,10 +82,12 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */ EG(opline_ptr) = &PHPDBG_EX(opline); EG(active_op_array) = PHPDBG_EX(op_array); + PHPDBG_FRAME(execute_data)->original_return_value = EG(return_value_ptr_ptr); + EG(return_value_ptr_ptr) = PHPDBG_EX(original_return_value); EG(active_symbol_table) = PHPDBG_EX(symbol_table); - Z_OBJ(EG(This)) = PHPDBG_EX(object); - EG(scope) = PHPDBG_EX(scope); - EG(called_scope) = PHPDBG_EX(called_scope); + EG(This) = PHPDBG_EX(current_this); + EG(scope) = PHPDBG_EX(current_scope); + EG(called_scope) = PHPDBG_EX(current_called_scope); } phpdbg_notice("Switched to frame #%d", frame); @@ -97,38 +100,45 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */ ); } /* }}} */ -static void phpdbg_dump_prototype(zval *tmp TSRMLS_DC) /* {{{ */ +static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */ { - zval *funcname, *class, *type, *args, *argstmp; - zend_string *class_name; + zval **funcname, **class, **type, **args, **argstmp; + char is_class; - funcname = zend_hash_str_find(Z_ARRVAL_P(tmp), "function", sizeof("function") - 1); + zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), + (void **)&funcname); - if ((class = zend_hash_str_find(Z_ARRVAL_P(tmp), "object", sizeof("object") - 1)) == NULL) { - class = zend_hash_str_find(Z_ARRVAL_P(tmp), "class", sizeof("class") - 1); + 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 { - class_name = zend_get_object_classname(Z_OBJ_P(class) TSRMLS_CC); + zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class), + (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC); } - if (class) { - type = zend_hash_str_find(Z_ARRVAL_P(tmp), "type", sizeof("type") - 1); + if (is_class == SUCCESS) { + zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type); } phpdbg_write("%s%s%s(", - class == NULL?"":Z_STRVAL_P(class), - class == NULL?"":Z_STRVAL_P(type), - Z_STRVAL_P(funcname)); + is_class == FAILURE?"":Z_STRVAL_PP(class), + is_class == FAILURE?"":Z_STRVAL_PP(type), + Z_STRVAL_PP(funcname) + ); - if ((args = zend_hash_str_find(Z_ARRVAL_P(tmp), "args", sizeof("args") - 1)) != NULL) { + if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), + (void **)&args) == SUCCESS) { HashPosition iterator; const zend_function *func = phpdbg_get_function( - Z_STRVAL_P(funcname), class == NULL ? NULL : Z_STRVAL_P(class) TSRMLS_CC); + 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_bool is_variadic = 0; - zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &iterator); - while ((argstmp = zend_hash_get_current_data_ex(Z_ARRVAL_P(args), &iterator)) != NULL) { + 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(", "); } @@ -141,8 +151,8 @@ static void phpdbg_dump_prototype(zval *tmp TSRMLS_DC) /* {{{ */ } ++j; - zend_print_flat_zval_r(argstmp TSRMLS_CC); - zend_hash_move_forward_ex(Z_ARRVAL_P(args), &iterator); + zend_print_flat_zval_r(*argstmp TSRMLS_CC); + zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator); } if (is_variadic) { phpdbg_write("]"); @@ -150,15 +160,15 @@ static void phpdbg_dump_prototype(zval *tmp TSRMLS_DC) /* {{{ */ } phpdbg_write(")"); } -/* }}} */ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ { zval zbacktrace; - zval *tmp; - zval *file, *line; + zval **tmp; + zval **file, **line; HashPosition position; - int i = 1, limit = num; + int i = 0, limit = num; + int user_defined; if (limit < 0) { phpdbg_error("Invalid backtrace size %d", limit); @@ -168,21 +178,22 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ &zbacktrace, 0, 0, limit TSRMLS_CC); zend_hash_internal_pointer_reset_ex(Z_ARRVAL(zbacktrace), &position); - tmp = zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), &position); + zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position); while (1) { - file = zend_hash_str_find(Z_ARRVAL_P(tmp), "file", sizeof("file") - 1); - line = zend_hash_str_find(Z_ARRVAL_P(tmp), "line", sizeof("line") - 1); + user_defined = 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); - if ((tmp = zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), &position)) == NULL) { - phpdbg_write("frame #0: {main} at %s:%ld", Z_STRVAL_P(file), Z_LVAL_P(line)); + 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)); break; } - if (file) { + if (user_defined == SUCCESS) { phpdbg_write("frame #%d: ", i++); phpdbg_dump_prototype(tmp TSRMLS_CC); - phpdbg_writeln(" at %s:%ld", Z_STRVAL_P(file), Z_LVAL_P(line)); + phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line)); } else { phpdbg_write(" => "); phpdbg_dump_prototype(tmp TSRMLS_CC); @@ -191,5 +202,5 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */ } phpdbg_writeln(EMPTY); - zval_ptr_dtor(&zbacktrace); + zval_dtor(&zbacktrace); } /* }}} */ |