diff options
Diffstat (limited to 'sapi')
-rw-r--r-- | sapi/phpdbg/phpdbg.c | 51 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_watch.c | 2 | ||||
-rw-r--r-- | sapi/phpdbg/tests/commands/0002_set.test | 2 | ||||
-rw-r--r-- | sapi/phpdbg/tests/commands/0103_register.test | 10 | ||||
-rw-r--r-- | sapi/phpdbg/tests/commands/0106_compile.test | 1 | ||||
-rw-r--r-- | sapi/phpdbg/tests/run-tests.php | 28 |
6 files changed, 63 insertions, 31 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index fc121839e..93fdbd742 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -159,8 +159,6 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */ zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0); zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], 8, NULL, NULL, 0); - phpdbg_setup_watchpoints(TSRMLS_C); - zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0); zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0); @@ -879,6 +877,32 @@ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) { } #endif +static inline zend_mm_heap *phpdbg_mm_get_heap() { + zend_mm_heap *mm_heap; + + TSRMLS_FETCH(); + + mm_heap = zend_mm_set_heap(NULL TSRMLS_CC); + zend_mm_set_heap(mm_heap TSRMLS_CC); + + return mm_heap; +} + +void *phpdbg_malloc_wrapper(size_t size) +{ + return zend_mm_alloc(phpdbg_mm_get_heap(), size); +} + +void phpdbg_free_wrapper(void *p) +{ + zend_mm_free(phpdbg_mm_get_heap(), p); +} + +void *phpdbg_realloc_wrapper(void *ptr, size_t size) +{ + return zend_mm_realloc(phpdbg_mm_get_heap(), ptr, size); +} + int main(int argc, char **argv) /* {{{ */ { sapi_module_struct *phpdbg = &phpdbg_sapi_module; @@ -1221,23 +1245,22 @@ phpdbg_main: EXCEPTION_POINTERS *xp; __try { #endif - zend_mm_heap *mm_heap = zend_mm_set_heap(NULL TSRMLS_CC); -#if ZEND_DEBUG - if (!mm_heap->use_zend_alloc) { - mm_heap->_malloc = malloc; - mm_heap->_realloc = realloc; - mm_heap->_free = free; -#endif - PHPDBG_G(original_free_function) = mm_heap->_free; - mm_heap->_free = phpdbg_watch_efree; + zend_mm_heap *mm_heap = phpdbg_mm_get_heap(); + + if (mm_heap->use_zend_alloc) { + mm_heap->_malloc = phpdbg_malloc_wrapper; + mm_heap->_realloc = phpdbg_realloc_wrapper; + mm_heap->_free = phpdbg_free_wrapper; mm_heap->use_zend_alloc = 0; -#if ZEND_DEBUG } -#endif - zend_mm_set_heap(mm_heap TSRMLS_CC); zend_activate(TSRMLS_C); + PHPDBG_G(original_free_function) = mm_heap->_free; + mm_heap->_free = phpdbg_watch_efree; + + phpdbg_setup_watchpoints(TSRMLS_C); + #if defined(ZEND_SIGNALS) && !defined(_WIN32) zend_try { zend_signal_activate(TSRMLS_C); diff --git a/sapi/phpdbg/phpdbg_watch.c b/sapi/phpdbg/phpdbg_watch.c index 2efbb1237..e88622444 100644 --- a/sapi/phpdbg/phpdbg_watch.c +++ b/sapi/phpdbg/phpdbg_watch.c @@ -580,7 +580,7 @@ void phpdbg_setup_watchpoints(TSRMLS_D) { zend_llist_init(&PHPDBG_G(watchlist_mem), sizeof(void *), phpdbg_watch_mem_dtor, 1); phpdbg_btree_init(&PHPDBG_G(watchpoint_tree), sizeof(void *) * 8); phpdbg_btree_init(&PHPDBG_G(watch_HashTables), sizeof(void *) * 8); - _zend_hash_init(&PHPDBG_G(watchpoints), 8, phpdbg_watch_dtor, 0 ZEND_FILE_LINE_CC); + zend_hash_init(&PHPDBG_G(watchpoints), 8, NULL, phpdbg_watch_dtor, 0 ZEND_FILE_LINE_CC); } static void phpdbg_print_changed_zval(phpdbg_watch_memdump *dump TSRMLS_DC) { diff --git a/sapi/phpdbg/tests/commands/0002_set.test b/sapi/phpdbg/tests/commands/0002_set.test index 7720f94ff..468ac6d9e 100644 --- a/sapi/phpdbg/tests/commands/0002_set.test +++ b/sapi/phpdbg/tests/commands/0002_set.test @@ -9,7 +9,6 @@ # setting notice color # Failed to find breakpoint #0 # oplog disabled -# not enabled # opened oplog test.log # nothing ################################################# @@ -19,5 +18,4 @@ set color notice none set prompt promot> set break 0 set oplog -set oplog 0 set oplog test.log diff --git a/sapi/phpdbg/tests/commands/0103_register.test b/sapi/phpdbg/tests/commands/0103_register.test index 38841591c..703a12f77 100644 --- a/sapi/phpdbg/tests/commands/0103_register.test +++ b/sapi/phpdbg/tests/commands/0103_register.test @@ -7,15 +7,15 @@ #[Registered test_function] #array(5) { # [0]=> -# string(1) "1" +# int(1) # [1]=> -# string(1) "2" +# int(2) # [2]=> -# string(1) "3" +# int(3) # [3]=> -# string(1) "4" +# int(4) # [4]=> -# string(1) "5" +# int(5) #} ################################################# <: diff --git a/sapi/phpdbg/tests/commands/0106_compile.test b/sapi/phpdbg/tests/commands/0106_compile.test index d79211ddf..7193600ea 100644 --- a/sapi/phpdbg/tests/commands/0106_compile.test +++ b/sapi/phpdbg/tests/commands/0106_compile.test @@ -14,6 +14,5 @@ define('OUT', file_put_contents(OUT, "<?php echo \"Hello World\"; ?>"); phpdbg_exec(OUT); :> -compile run quit diff --git a/sapi/phpdbg/tests/run-tests.php b/sapi/phpdbg/tests/run-tests.php index 1fb6fa122..47a998cca 100644 --- a/sapi/phpdbg/tests/run-tests.php +++ b/sapi/phpdbg/tests/run-tests.php @@ -284,6 +284,8 @@ namespace phpdbg\testing { $test->purpose, $result ? "PASS" : "FAIL", PHP_EOL); + + return $result; } protected $config; @@ -426,7 +428,7 @@ namespace phpdbg\testing { */ public function getResult() { $options = sprintf( - '-i%s -qb', $this->file); + '-i%s -nqb', $this->file); if ($this->options) { $options = sprintf( @@ -492,13 +494,18 @@ namespace phpdbg\testing { * */ protected function writeDiff() { - $diff = sprintf( - '%s/%s.diff', - dirname($this->file), basename($this->file)); - if (count($this->diff['wants'])) { - if (!in_array('nodiff', $this->config['flags'])) { - if (($diff = fopen($diff, 'w+'))) { + if (!$this->config->hasFlag('nodiff')) { + if ($this->config->hasFlag('diff2stdout')) { + $difffile = "php://stdout"; + file_put_contents($difffile, "====DIFF====\n"); + } else { + $difffile = sprintf( + '%s/%s.diff', + dirname($this->file), basename($this->file)); + } + + if (($diff = fopen($difffile, 'w+'))) { foreach ($this->diff['wants'] as $line => $want) { $got = $this->diff['gets'][$line]; @@ -552,6 +559,9 @@ namespace { $cwd = dirname(__FILE__); $cmd = $_SERVER['argv']; + + $retval = 0; + { $config = new TestsConfiguration(array( 'exec' => realpath(array_shift($cmd)), @@ -571,7 +581,7 @@ namespace { $tests->logPath($path); foreach ($tests->findTests($path) as $test) { - $tests->logTest($path, $test); + $retval |= !$tests->logTest($path, $test); } $tests->logPathStats($path); @@ -579,5 +589,7 @@ namespace { $tests->logStats(); } + + die($retval); } ?> |