summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg.c
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2016-10-02 12:45:20 +0100
committerBob Weinand <bobwei9@hotmail.com>2016-10-02 12:45:20 +0100
commit417a8ef6b45ed8510faf5ebfb7b4f8c76cb97934 (patch)
tree6e92374e9258aeb296a52f64340109516b1bbb91 /sapi/phpdbg/phpdbg.c
parent9d537951c5e4af5e453dd4d60e74dad039856b80 (diff)
downloadphp-git-417a8ef6b45ed8510faf5ebfb7b4f8c76cb97934.tar.gz
Fix run command args passing when inmidst execution
Diffstat (limited to 'sapi/phpdbg/phpdbg.c')
-rw-r--r--sapi/phpdbg/phpdbg.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 234d0f912e..618a72f429 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -834,7 +834,7 @@ static void php_sapi_phpdbg_log_message(char *message) /* {{{ */
}
do {
- switch (phpdbg_interactive(1)) {
+ switch (phpdbg_interactive(1, NULL)) {
case PHPDBG_LEAVE:
case PHPDBG_FINISH:
case PHPDBG_UNTIL:
@@ -942,7 +942,7 @@ static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */
} /* }}} */
/* copied from sapi/cli/php_cli.c cli_register_file_handles */
-static void phpdbg_register_file_handles(void) /* {{{ */
+void phpdbg_register_file_handles(void) /* {{{ */
{
zval zin, zout, zerr;
php_stream *s_in, *s_out, *s_err;
@@ -974,18 +974,21 @@ static void phpdbg_register_file_handles(void) /* {{{ */
ic.flags = CONST_CS;
ic.name = zend_string_init(ZEND_STRL("STDIN"), 0);
ic.module_number = 0;
+ zend_hash_del(EG(zend_constants), ic.name);
zend_register_constant(&ic);
oc.value = zout;
oc.flags = CONST_CS;
oc.name = zend_string_init(ZEND_STRL("STDOUT"), 0);
oc.module_number = 0;
+ zend_hash_del(EG(zend_constants), oc.name);
zend_register_constant(&oc);
ec.value = zerr;
ec.flags = CONST_CS;
ec.name = zend_string_init(ZEND_STRL("STDERR"), 0);
ec.module_number = 0;
+ zend_hash_del(EG(zend_constants), ec.name);
zend_register_constant(&ec);
}
/* }}} */
@@ -1318,6 +1321,7 @@ int main(int argc, char **argv) /* {{{ */
zend_bool ini_ignore;
char *ini_override;
char *exec = NULL;
+ char *first_command = NULL;
char *init_file;
size_t init_file_len;
zend_bool init_file_default;
@@ -1800,7 +1804,6 @@ phpdbg_main:
/* set default prompt */
phpdbg_set_prompt(PHPDBG_DEFAULT_PROMPT);
-/* refactor to preserve run commands on force run command */
{
php_stream_wrapper *wrapper = zend_hash_str_find_ptr(php_stream_get_url_stream_wrappers_hash(), ZEND_STRL("php"));
PHPDBG_G(orig_url_wrap_php) = wrapper->wops->stream_opener;
@@ -1886,7 +1889,11 @@ phpdbg_interact:
PHPDBG_G(flags) |= PHPDBG_IS_INTERACTIVE;
}
zend_try {
- PHPDBG_COMMAND_HANDLER(run)(NULL);
+ if (first_command) {
+ phpdbg_interactive(1, estrdup(first_command));
+ } else {
+ PHPDBG_COMMAND_HANDLER(run)(NULL);
+ }
} zend_end_try();
if (quit_immediately) {
/* if -r is on the command line more than once just quit */
@@ -1897,7 +1904,7 @@ phpdbg_interact:
}
CG(unclean_shutdown) = 0;
- phpdbg_interactive(1);
+ phpdbg_interactive(1, NULL);
} zend_catch {
if ((PHPDBG_G(flags) & PHPDBG_IS_CLEANING)) {
char *bp_tmp_str;
@@ -1955,6 +1962,11 @@ phpdbg_out:
phpdbg_out:
#endif
+ if (first_command) {
+ free(first_command);
+ first_command = NULL;
+ }
+
if (cleaning <= 0) {
PHPDBG_G(flags) &= ~PHPDBG_IS_CLEANING;
cleaning = -1;
@@ -2006,6 +2018,7 @@ phpdbg_out:
settings->input_buflen = PHPDBG_G(input_buflen);
memcpy(settings->input_buffer, PHPDBG_G(input_buffer), settings->input_buflen);
settings->flags = PHPDBG_G(flags) & PHPDBG_PRESERVE_FLAGS_MASK;
+ first_command = PHPDBG_G(cur_command);
} else {
if (PHPDBG_G(prompt)[0]) {
free(PHPDBG_G(prompt)[0]);
@@ -2013,6 +2026,9 @@ phpdbg_out:
if (PHPDBG_G(prompt)[1]) {
free(PHPDBG_G(prompt)[1]);
}
+ if (PHPDBG_G(cur_command)) {
+ free(PHPDBG_G(cur_command));
+ }
}
/* hack to restore mm_heap->use_custom_heap in order to receive memory leak info */