mirror of
https://github.com/php/php-src.git
synced 2024-11-25 10:54:15 +08:00
Fix phpdbg_break_next() and add test
This commit is contained in:
parent
4df6f26442
commit
e9f21a3388
@ -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) */
|
||||
|
@ -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));
|
||||
|
||||
|
22
sapi/phpdbg/tests/phpdbg_break_next.phpt
Normal file
22
sapi/phpdbg/tests/phpdbg_break_next.phpt
Normal file
@ -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';
|
Loading…
Reference in New Issue
Block a user