From 6c317b771e5e342497a39e5610c8fe49cfd628a0 Mon Sep 17 00:00:00 2001 From: krakjoe Date: Tue, 12 Nov 2013 04:53:04 +0000 Subject: [PATCH] more command line options --- phpdbg.c | 34 +++++++++++++++++++++++++++++++++- phpdbg_prompt.c | 2 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/phpdbg.c b/phpdbg.c index ca38078b14..52998a6527 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -262,6 +262,10 @@ const opt_struct OPTIONS[] = { /* {{{ */ {'d', 1, "define ini entry on command line"}, {'n', 0, "no php.ini"}, {'z', 1, "load zend_extension"}, + /* phpdbg options */ + {'e', 1, "exec"}, + {'v', 0, "verbose"}, + {'s', 0, "step"}, {'-', 0, NULL} }; /* }}} */ @@ -291,6 +295,9 @@ int main(int argc, char *argv[]) /* {{{ */ sapi_module_struct *phpdbg = &phpdbg_sapi_module; char *ini_entries = NULL; int ini_entries_len = 0; + char *exec = NULL; + size_t exec_len = 0L; + zend_ulong flags = PHPDBG_IS_QUIET; char *php_optarg = NULL; int php_optind = 1; int opt; @@ -311,7 +318,7 @@ int main(int argc, char *argv[]) /* {{{ */ tsrm_ls = ts_resource(0); #endif - + while ((opt = php_getopt(argc, argv, OPTIONS, &php_optarg, &php_optind, 0, 2)) != -1) { switch (opt) { case 'n': @@ -355,6 +362,21 @@ int main(int argc, char *argv[]) /* {{{ */ case 'z': zend_load_extension(php_optarg); break; + + case 'e': /* set execution context */ + exec_len = strlen(php_optarg); + if (exec_len) { + exec = strdup(php_optarg); + } + break; + + case 'v': /* set quietness off */ + flags &= ~PHPDBG_IS_QUIET; + break; + + case 's': /* set stepping on */ + flags |= PHPDBG_IS_STEPPING; + break; } } @@ -395,6 +417,16 @@ int main(int argc, char *argv[]) /* {{{ */ PG(modules_activated) = 0; + if (exec) { /* set execution context */ + PHPDBG_G(exec) = estrndup(exec, exec_len); + PHPDBG_G(exec_len) = exec_len; + + free(exec); + } + + /* set flags from command line */ + PHPDBG_G(flags) = flags; + zend_try { zend_activate_modules(TSRMLS_C); } zend_end_try(); diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index e438072c2a..d255a9d873 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -604,7 +604,7 @@ phpdbg_interactive_enter: #ifdef HAVE_LIBREADLINE add_history(cmd); #endif - + switch (phpdbg_do_cmd(phpdbg_prompt_commands, cmd, cmd_len TSRMLS_CC)) { case FAILURE: if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) { -- 2.40.0