diff options
author | Bob Weinand <bobwei9@hotmail.com> | 2015-08-23 11:58:32 +0100 |
---|---|---|
committer | Bob Weinand <bobwei9@hotmail.com> | 2015-08-23 11:58:45 +0100 |
commit | e9f21a33887e51a7f9c8f871d30425457b34f41f (patch) | |
tree | ada6a6be83f8c3b0c42518679f231773d8f06130 /sapi | |
parent | 4df6f2644252de00d70577c00a120ff674fee029 (diff) | |
download | php-git-e9f21a33887e51a7f9c8f871d30425457b34f41f.tar.gz |
Fix phpdbg_break_next() and add test
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/phpdbg/phpdbg.c | 17 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_bp.c | 3 | ||||
-rw-r--r-- | sapi/phpdbg/tests/phpdbg_break_next.phpt | 22 |
3 files changed, 39 insertions, 3 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 4c5dfdea22..8a22ea29ca 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -155,6 +155,11 @@ static void php_phpdbg_destroy_bp_opcode(zval *brake) /* {{{ */ efree(Z_PTR_P(brake)); } /* }}} */ +static void php_phpdbg_destroy_bp_opline(zval *brake) /* {{{ */ +{ + efree(Z_PTR_P(brake)); +} /* }}} */ + static void php_phpdbg_destroy_bp_methods(zval *brake) /* {{{ */ { zend_hash_destroy(Z_ARRVAL_P(brake)); @@ -188,7 +193,7 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FUNCTION_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_OPLINE], 8, NULL, php_phpdbg_destroy_bp_methods, 0); - zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, NULL, 0); + zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, php_phpdbg_destroy_bp_opline, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPCODE], 8, NULL, php_phpdbg_destroy_bp_opcode, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0); @@ -302,11 +307,17 @@ static PHP_FUNCTION(phpdbg_exec) instructs phpdbg to insert a breakpoint at the next opcode */ static PHP_FUNCTION(phpdbg_break_next) { - if (zend_parse_parameters_none() == FAILURE && EG(current_execute_data)) { + zend_execute_data *ex = EG(current_execute_data); + + while (ex && ex->func && !ZEND_USER_CODE(ex->func->type)) { + ex = ex->prev_execute_data; + } + + if (zend_parse_parameters_none() == FAILURE || !ex) { return; } - phpdbg_set_breakpoint_opline_ex((phpdbg_opline_ptr_t) EG(current_execute_data)->opline + 1); + phpdbg_set_breakpoint_opline_ex((phpdbg_opline_ptr_t) ex->opline + 1); } /* }}} */ /* {{{ proto void phpdbg_break_file(string file, integer line) */ diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index 7e8292b066..c90623a03b 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -212,6 +212,8 @@ PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str) /* {{{ */ phpdbg_asprintf(&new_str, "%sbreak if %s\n", str, conditional->code); } } break; + + default: continue; } if ((*str)[0]) { @@ -784,6 +786,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opline_ex(phpdbg_opline_ptr_t opline) /* { PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_OPLINE); new_break.opline = (zend_ulong) opline; + new_break.base = NULL; zend_hash_index_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], (zend_ulong) opline, &new_break, sizeof(phpdbg_breakline_t)); diff --git a/sapi/phpdbg/tests/phpdbg_break_next.phpt b/sapi/phpdbg/tests/phpdbg_break_next.phpt new file mode 100644 index 0000000000..37ee2e8282 --- /dev/null +++ b/sapi/phpdbg/tests/phpdbg_break_next.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test phpdbg_break_next() function +--PHPDBG-- +r +c +q +--EXPECTF-- +[Successful compilation of %s] +prompt> A +[Breakpoint #0 added at %s] +[Breakpoint #0 in %s at %s:5, hits: 1] +>00005: echo 'B'; + 00006: +prompt> B +[Script ended normally] +prompt> +--FILE-- +<?php + +echo 'A'; +phpdbg_break_next(); +echo 'B'; |