com php-src: Added support for command line arg passing "phpdbg -- arg" in shell "run arg" in phpdbg prompt: phpdbg.c phpdbg_help.c phpdbg_prompt.c

From: Date: Sat, 12 Apr 2014 22:27:46 +0000
Subject: com php-src: Added support for command line arg passing "phpdbg -- arg" in shell "run arg" in phpdbg prompt: phpdbg.c phpdbg_help.c phpdbg_prompt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77015@lists.php.net to get a copy of this message
Commit: 3db29ee43960a4e164244a55b0e2a4b23a112e49 Author: Bob Weinand <bobwei9@hotmail.com> Sun, 13 Apr 2014 00:27:46 +0200 Parents: 86a77317630255a254888de4437a8b060efdb863 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3db29ee43960a4e164244a55b0e2a4b23a112e49 Log: Added support for command line arg passing "phpdbg -- arg" in shell "run arg" in phpdbg prompt Changed paths: M phpdbg.c M phpdbg_help.c M phpdbg_prompt.c Diff: diff --git a/phpdbg.c b/phpdbg.c index 7676687..ba12d94 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -1139,8 +1139,16 @@ phpdbg_main: phpdbg->ini_entries = ini_entries; if (phpdbg->startup(phpdbg) == SUCCESS) { - php_request_startup(TSRMLS_C); + int i; + SG(request_info).argc = argc - php_optind + 1; + SG(request_info).argv = emalloc(SG(request_info).argc * sizeof(char *)); + for (i = SG(request_info).argc; --i;) { + SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]); + } + SG(request_info).argv[php_optind - 1] = exec?exec:""; + php_request_startup(TSRMLS_C); + /* do not install sigint handlers for remote consoles */ /* sending SIGINT then provides a decent way of shutting down the server */ #ifdef ZEND_SIGNALS @@ -1289,6 +1297,12 @@ phpdbg_out: } #endif + /* free argv */ + for (i = SG(request_info).argc; --i;) { + efree(SG(request_info).argv[i]); + } + efree(SG(request_info).argv); + #ifndef ZTS /* force cleanup of auto and core globals */ zend_hash_clean(CG(auto_globals)); diff --git a/phpdbg_help.c b/phpdbg_help.c index 3aa8284..dd8e530 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -379,7 +379,9 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **-S** **-S**cli Override SAPI name, careful!" CR " **-l** **-l**4000 Setup remote console ports" CR " **-a** **-a**192.168.0.3 Setup remote console bind address" CR -" **-V** Print version number" CR CR +" **-V** Print version number" CR +" **--** **--** arg1 arg2 Use to delimit phpdbg arguments and php $argv; append any $argv " +"argument after it" CR CR "**Remote Console Mode**" CR CR @@ -838,11 +840,13 @@ phpdbg_help_text_t phpdbg_help_text[] = { {"run", "Enter the vm, startinging execution. Execution will then continue until the next breakpoint " -"or completion of the script" +"or completion of the script. Add parameters you want to use as $argv" "**Examples**" CR CR " $P run" CR " $P r" CR -" Will cause execution of the context, if it is set." CR CR +" Will cause execution of the context, if it is set" CR CR +" $P r test" CR +" Will execute with $argv[1] == \"test\"" CR CR "Note that the execution context must be set. If not previously compiled, then the script will " "be compiled before execution." CR CR diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index e53a5e6..c088535 100644 --- a/phpdbg_prompt..c +++ b/phpdbg_prompt.c @@ -289,6 +289,9 @@ PHPDBG_COMMAND(exec) /* {{{ */ PHPDBG_G(exec) = res; PHPDBG_G(exec_len) = res_len; + *SG(request_info).argv = PHPDBG_G(exec); + php_hash_environment(TSRMLS_C); + phpdbg_notice("Set execution context: %s", PHPDBG_G(exec)); } else { phpdbg_notice("Execution context not changed"); @@ -579,6 +582,29 @@ PHPDBG_COMMAND(run) /* {{{ */ /* reset hit counters */ phpdbg_reset_breakpoints(TSRMLS_C); + if (param->type != EMPTY_PARAM) { + char **argv = emalloc(5 * sizeof(char *)); + int argc = 0; + int i; + char *argv_str = strtok(input->string, " "); + while (argv_str) { + if (argc >= 4 && argc == (argc & -argc)) { + argv = erealloc(argv, (argc * 2 + 1) * sizeof(char *)); + } + argv[++argc] = argv_str; + argv_str = strtok(0, " "); + argv[argc] = estrdup(argv[argc]); + } + argv[0] = SG(request_info).argv[0]; + for (i = SG(request_info).argc; --i;) { + efree(SG(request_info).argv[i]); + } + efree(SG(request_info).argv); + SG(request_info).argv = erealloc(argv, ++argc * sizeof(char *)); + SG(request_info).argc = argc; + php_hash_environment(TSRMLS_C); + } + zend_try { php_output_activate(TSRMLS_C); PHPDBG_G(flags) ^= PHPDBG_IS_INTERACTIVE;

« previous php.cvs (#77015) next »