From c8145da0b24a7bd8cb589cb727499764003fb92c Mon Sep 17 00:00:00 2001 From: krakjoe Date: Wed, 27 Nov 2013 13:15:52 +0000 Subject: [PATCH] reset hit counters implicitly on run --- phpdbg_bp.c | 20 ++++++++++++++++++++ phpdbg_bp.h | 1 + phpdbg_prompt.c | 3 +++ 3 files changed, 24 insertions(+) diff --git a/phpdbg_bp.c b/phpdbg_bp.c index 298508098c5..333569b77bd 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -56,6 +56,26 @@ static void phpdbg_class_breaks_dtor(void *data) /* {{{ */ efree((char*)bp->func_name); } /* }}} */ +PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D) /* {{{ */ +{ + if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) { + HashPosition position[2]; + HashTable **table = NULL; + + for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0]); + zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void**)&table, &position[0]) == SUCCESS; + zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) { + phpdbg_breakbase_t *brake; + + for (zend_hash_internal_pointer_reset_ex((*table), &position[1]); + zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; + zend_hash_move_forward_ex((*table), &position[1])) { + brake->hits = 0; + } + } + } +} /* }}} */ + PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ { HashPosition position[2]; diff --git a/phpdbg_bp.h b/phpdbg_bp.h index ef1049ea9af..90635398a21 100644 --- a/phpdbg_bp.h +++ b/phpdbg_bp.h @@ -104,6 +104,7 @@ phpdbg_breakbase_t* phpdbg_find_breakpoint(zend_execute_data* TSRMLS_DC); PHPDBG_API void phpdbg_delete_breakpoint(zend_ulong num TSRMLS_DC); PHPDBG_API void phpdbg_clear_breakpoints(TSRMLS_D); +PHPDBG_API void phpdbg_reset_breakpoints(TSRMLS_D); PHPDBG_API void phpdbg_hit_breakpoint(phpdbg_breakbase_t* brake, zend_bool output TSRMLS_DC); PHPDBG_API void phpdbg_print_breakpoint(phpdbg_breakbase_t* brake TSRMLS_DC); PHPDBG_API void phpdbg_print_breakpoints(zend_ulong type TSRMLS_DC); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index b9c22b90f5c..b5a93a650a8 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -573,6 +573,9 @@ PHPDBG_COMMAND(run) /* {{{ */ zend_hash_clean( &PHPDBG_G(seek)); + /* reset hit counters */ + phpdbg_reset_breakpoints(TSRMLS_C); + zend_try { php_output_activate(TSRMLS_C); PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE;