diff options
author | Anatol Belski <ab@php.net> | 2015-09-02 22:08:24 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2015-09-02 22:08:24 +0200 |
commit | 6ef7c6358fc37579d329268cbb56ab730bed2159 (patch) | |
tree | 2fe3452647d7450c867de9eab62f456ed77a2553 /sapi/phpdbg/phpdbg.c | |
parent | b7e910e9696001ae6fa728c10362f657b4b97742 (diff) | |
parent | fcece2a7bb0ecf1af1034a737bf5686a354e01d7 (diff) | |
download | php-git-6ef7c6358fc37579d329268cbb56ab730bed2159.tar.gz |
Merge branch 'master' into PHP-7.0.0
* master: (201 commits)
sync NEWS
Add missing variable from birdstep_commit() which got removed in e8fcd52ef
Align NEWS entries format
Add CVE for #70140 (PHP 7.0.0 Beta 3)
Seems master is not affected
We should keep one refcount to resource
Fixed bug #70398 (SIGSEGV, Segmentation fault zend_ast_destroy_ex)
Fixed test
Partially fix bug #67167 - Wrong return value...
move the phpdbg NEWS entry to the correct version
add missing news entries
Skip if ext/filter isn't loaded
Merge branch 'PHP-5.6'
5.5.30 next
Use ZSTR_VAL
fix dir separators in test
use correct api
fix leak
cleanup an atavism
add overflow check
...
Diffstat (limited to 'sapi/phpdbg/phpdbg.c')
-rw-r--r-- | sapi/phpdbg/phpdbg.c | 66 |
1 files changed, 46 insertions, 20 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 831d4fc472..a8247844c8 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); @@ -220,7 +225,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ zend_llist_destroy(&PHPDBG_G(watchlist_mem)); if (PHPDBG_G(buffer)) { - efree(PHPDBG_G(buffer)); + free(PHPDBG_G(buffer)); PHPDBG_G(buffer) = NULL; } @@ -287,11 +292,11 @@ static PHP_FUNCTION(phpdbg_exec) ZVAL_TRUE(return_value); } } else { - zend_error(E_WARNING, "Failed to set execution context (%s), not a regular file or symlink", exec); + zend_error(E_WARNING, "Failed to set execution context (%s), not a regular file or symlink", ZSTR_VAL(exec)); ZVAL_FALSE(return_value); } } else { - zend_error(E_WARNING, "Failed to set execution context (%s) the file does not exist", exec); + zend_error(E_WARNING, "Failed to set execution context (%s) the file does not exist", ZSTR_VAL(exec)); ZVAL_FALSE(return_value); } @@ -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) */ @@ -1085,17 +1096,21 @@ static inline void phpdbg_sigint_handler(int signo) /* {{{ */ } } else { /* set signalled only when not interactive */ - if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { - if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { - char mem[PHPDBG_SIGSAFE_MEM_SIZE + 1]; - - phpdbg_set_sigsafe_mem(mem); - zend_try { - phpdbg_force_interruption(); - } zend_end_try() - phpdbg_clear_sigsafe_mem(); - return; + if (PHPDBG_G(flags) & PHPDBG_IS_SIGNALED) { + char mem[PHPDBG_SIGSAFE_MEM_SIZE + 1]; + + phpdbg_set_sigsafe_mem(mem); + zend_try { + phpdbg_force_interruption(); + } zend_end_try() + phpdbg_clear_sigsafe_mem(); + + PHPDBG_G(flags) &= ~PHPDBG_IS_SIGNALED; + + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + zend_bailout(); } + } else { PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; } } @@ -1182,9 +1197,13 @@ void phpdbg_sigio_handler(int sig, siginfo_t *info, void *context) /* {{{ */ phpdbg_force_interruption(); } zend_end_try(); phpdbg_clear_sigsafe_mem(); - break; - } - if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { + + PHPDBG_G(flags) &= ~PHPDBG_IS_SIGNALED; + + if (PHPDBG_G(flags) & PHPDBG_IS_STOPPING) { + zend_bailout(); + } + } else if (!(PHPDBG_G(flags) & PHPDBG_IS_INTERACTIVE)) { PHPDBG_G(flags) |= PHPDBG_IS_SIGNALED; } break; @@ -1281,6 +1300,7 @@ int main(int argc, char **argv) /* {{{ */ zend_bool ext_stmt = 0; zend_bool use_mm_wrappers = 0; zend_bool is_exit; + int exit_status = 0; #ifdef ZTS void ***tsrm_ls; @@ -1312,6 +1332,10 @@ int main(int argc, char **argv) /* {{{ */ tsrm_ls = ts_resource(0); #endif +#ifdef ZEND_SIGNALS + zend_signal_startup(); +#endif + phpdbg_main: ini_entries = NULL; ini_entries_len = 0; @@ -1803,6 +1827,7 @@ phpdbg_interact: if (quit_immediately) { /* if -r is on the command line more than once just quit */ EG(bailout) = __orig_bailout; /* reset zend_try */ + exit_status = EG(exit_status); break; } } @@ -1979,5 +2004,6 @@ phpdbg_out: free(PHPDBG_G(sapi_name_ptr)); } - return 0; + /* usually 0; just for -rr */ + return exit_status; } /* }}} */ |