From bccac3774bade617d88da45e7f1781151bb16160 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 23 Sep 2015 18:30:13 +0200 Subject: [PATCH] Fixed bug #70531 (-rr should not fallback to interactive mode in phpdbg) --- NEWS | 2 ++ sapi/phpdbg/phpdbg.c | 5 +++++ sapi/phpdbg/phpdbg.h | 15 ++++++++------- sapi/phpdbg/phpdbg_help.c | 2 +- sapi/phpdbg/phpdbg_prompt.c | 5 +++++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 31e7ad9b706..89899805b77 100644 --- a/NEWS +++ b/NEWS @@ -30,6 +30,8 @@ PHP NEWS - Phpdbg: . Fixed bug #70532 (phpdbg must respect set_exception_handler). (Bob) + . Fixed bug #70531 (Run and quit mode (-qrr) should not fallback to + interactive mode). (Bob) - Session: . Fixed bug #70529 (Session read causes "String is not zero-terminated" error). diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index bf3a45184e0..a66576c61e8 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1835,6 +1835,11 @@ phpdbg_interact: if (phpdbg_startup_run) { quit_immediately = phpdbg_startup_run > 1; phpdbg_startup_run = 0; + if (quit_immediately) { + PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE | PHPDBG_PREVENT_INTERACTIVE; + } else { + PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE; + } PHPDBG_COMMAND_HANDLER(run)(NULL); if (quit_immediately) { /* if -r is on the command line more than once just quit */ diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 01b0cbb3ca1..56a0714758b 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -183,16 +183,17 @@ int phpdbg_do_parse(phpdbg_param_t *stack, char *input); #define PHPDBG_IS_INITIALIZING (1ULL<<25) #define PHPDBG_IS_SIGNALED (1ULL<<26) #define PHPDBG_IS_INTERACTIVE (1ULL<<27) -#define PHPDBG_IS_BP_ENABLED (1ULL<<28) -#define PHPDBG_IS_REMOTE (1ULL<<29) -#define PHPDBG_IS_DISCONNECTED (1ULL<<30) -#define PHPDBG_WRITE_XML (1ULL<<31) +#define PHPDBG_PREVENT_INTERACTIVE (1ULL<<28) +#define PHPDBG_IS_BP_ENABLED (1ULL<<29) +#define PHPDBG_IS_REMOTE (1ULL<<30) +#define PHPDBG_IS_DISCONNECTED (1ULL<<31) +#define PHPDBG_WRITE_XML (1ULL<<32) -#define PHPDBG_SHOW_REFCOUNTS (1ULL<<32) +#define PHPDBG_SHOW_REFCOUNTS (1ULL<<33) -#define PHPDBG_IN_SIGNAL_HANDLER (1ULL<<33) +#define PHPDBG_IN_SIGNAL_HANDLER (1ULL<<34) -#define PHPDBG_DISCARD_OUTPUT (1ULL<<34) +#define PHPDBG_DISCARD_OUTPUT (1ULL<<35) #define PHPDBG_SEEK_MASK (PHPDBG_IN_UNTIL | PHPDBG_IN_FINISH | PHPDBG_IN_LEAVE) #define PHPDBG_BP_RESOLVE_MASK (PHPDBG_HAS_FUNCTION_OPLINE_BP | PHPDBG_HAS_METHOD_OPLINE_BP | PHPDBG_HAS_FILE_OPLINE_BP) diff --git a/sapi/phpdbg/phpdbg_help.c b/sapi/phpdbg/phpdbg_help.c index ea3df17c013..a99191d5103 100644 --- a/sapi/phpdbg/phpdbg_help.c +++ b/sapi/phpdbg/phpdbg_help.c @@ -383,7 +383,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **-I** Ignore default .phpdbginit" CR " **-O** **-O**my.oplog Sets oplog output file" CR " **-r** Run execution context" CR -" **-rr** Run execution context and quit after execution" CR +" **-rr** Run execution context and quit after execution (not respecting breakpoints)" CR " **-e** Generate extended information for debugger/profiler" CR " **-E** Enable step through eval, careful!" CR " **-S** **-S**cli Override SAPI name, careful!" CR diff --git a/sapi/phpdbg/phpdbg_prompt.c b/sapi/phpdbg/phpdbg_prompt.c index 0314d39f24f..f5341075d0e 100644 --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@ -1476,6 +1476,11 @@ void phpdbg_execute_ex(zend_execute_data *execute_data) /* {{{ */ } #endif + if (PHPDBG_G(flags) & PHPDBG_PREVENT_INTERACTIVE) { + phpdbg_print_opline_ex(execute_data, 0); + goto next; + } + /* check for uncaught exceptions */ if (exception && PHPDBG_G(handled_exception) != exception && !(PHPDBG_G(flags) & PHPDBG_IN_EVAL)) { zend_execute_data *prev_ex = execute_data;