From 4e6a8eeffa4cdec4b75303788e676468fdf6129e Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 25 Nov 2013 23:38:43 +0100 Subject: Breakpoints are now persistent over cleans --- phpdbg.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'phpdbg.c') diff --git a/phpdbg.c b/phpdbg.c index ebe7cafb7b..9215e4342b 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -552,6 +552,7 @@ int main(int argc, char **argv) /* {{{ */ long cleaning = 0; int run = 0; int step = 0; + char *bp_tmp_file; #ifdef ZTS void ***tsrm_ls; @@ -570,6 +571,12 @@ int main(int argc, char **argv) /* {{{ */ tsrm_ls = ts_resource(0); #endif + bp_tmp_file = malloc(L_tmpnam); + tmpnam(bp_tmp_file); + if (bp_tmp_file == NULL) { + phpdbg_error("Unable to create temporary file"); + } + phpdbg_main: ini_entries = NULL; ini_entries_len = 0; @@ -772,9 +779,8 @@ phpdbg_main: /* initialize from file */ zend_try { PHPDBG_G(flags) |= PHPDBG_IS_INITIALIZING; - phpdbg_init( - init_file, init_file_len, - init_file_default TSRMLS_CC); + phpdbg_init(init_file, init_file_len, init_file_default TSRMLS_CC); + phpdbg_try_file_init(bp_tmp_file, strlen(bp_tmp_file), 0 TSRMLS_CC); PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; } zend_catch { PHPDBG_G(flags) &= ~PHPDBG_IS_INITIALIZING; @@ -803,9 +809,14 @@ phpdbg_main: phpdbg_interactive(TSRMLS_C); } zend_catch { if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) { + FILE *bp_tmp_fp = fopen(bp_tmp_file, "w"); + phpdbg_export_breakpoints(bp_tmp_fp TSRMLS_CC); + fclose(bp_tmp_fp); cleaning = 1; goto phpdbg_out; - } else cleaning = 0; + } else { + cleaning = 0; + } if (PHPDBG_G(flags) & PHPDBG_IS_QUITTING) { goto phpdbg_out; @@ -851,6 +862,8 @@ phpdbg_out: goto phpdbg_main; } + free(bp_tmp_file); + #ifdef ZTS /* bugggy */ /* tsrm_shutdown(); */ -- cgit v1.2.1 From 02ae3f8de1799d5ae4a6fa2cc86a34acb4767e9c Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Mon, 25 Nov 2013 23:45:55 +0100 Subject: Merge branch 'master' of https://github.com/krakjoe/phpdbg --- phpdbg.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'phpdbg.c') diff --git a/phpdbg.c b/phpdbg.c index 9215e4342b..275d91a795 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -78,7 +78,7 @@ static PHP_MINIT_FUNCTION(phpdbg) /* {{{ */ REGISTER_LONG_CONSTANT("PHPDBG_COLOR_PROMPT", PHPDBG_COLOR_PROMPT, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PHPDBG_COLOR_NOTICE", PHPDBG_COLOR_NOTICE, CONST_CS|CONST_PERSISTENT); REGISTER_LONG_CONSTANT("PHPDBG_COLOR_ERROR", PHPDBG_COLOR_ERROR, CONST_CS|CONST_PERSISTENT); - + return SUCCESS; } /* }}} */ @@ -162,6 +162,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */ if (PHPDBG_G(prompt)[0]) { free(PHPDBG_G(prompt)[0]); } + if (PHPDBG_G(prompt)[1]) { free(PHPDBG_G(prompt)[1]); } @@ -249,32 +250,32 @@ static PHP_FUNCTION(phpdbg_color) long element; char *color; zend_uint color_len; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls", &element, &color, &color_len) == FAILURE) { return; } - + switch (element) { case PHPDBG_COLOR_NOTICE: case PHPDBG_COLOR_ERROR: case PHPDBG_COLOR_PROMPT: phpdbg_set_color_ex(element, color, color_len TSRMLS_CC); break; - + default: zend_error(E_ERROR, "phpdbg detected an incorrect color constant"); } } /* }}} */ /* {{{ proto void phpdbg_prompt(string prompt) */ -static PHP_FUNCTION(phpdbg_prompt) +static PHP_FUNCTION(phpdbg_prompt) { char *prompt; zend_uint prompt_len; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &prompt, &prompt_len) == FAILURE) { return; } - + phpdbg_set_prompt(prompt TSRMLS_CC); } /* }}} */ @@ -565,19 +566,21 @@ int main(int argc, char **argv) /* {{{ */ setmode(_fileno(stderr), O_BINARY); /* make the stdio mode be binary */ #endif +phpdbg_main: #ifdef ZTS tsrm_startup(1, 1, 0, NULL); tsrm_ls = ts_resource(0); #endif - bp_tmp_file = malloc(L_tmpnam); - tmpnam(bp_tmp_file); - if (bp_tmp_file == NULL) { - phpdbg_error("Unable to create temporary file"); + if (!cleaning) { + bp_tmp_file = malloc(L_tmpnam); + tmpnam(bp_tmp_file); + if (bp_tmp_file == NULL) { + phpdbg_error("Unable to create temporary file"); + } } -phpdbg_main: ini_entries = NULL; ini_entries_len = 0; ini_ignore = 0; @@ -858,16 +861,15 @@ phpdbg_out: sapi_shutdown(); } +#ifdef ZTS + tsrm_shutdown(); +#endif + if (cleaning) { goto phpdbg_main; } free(bp_tmp_file); -#ifdef ZTS - /* bugggy */ - /* tsrm_shutdown(); */ -#endif - return 0; } /* }}} */ -- cgit v1.2.1