summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrakjoe <joe.watkins@live.co.uk>2014-04-13 08:06:42 +0100
committerkrakjoe <joe.watkins@live.co.uk>2014-04-13 08:06:42 +0100
commitef86b57f3b6745d5215e1316512c108f46df8668 (patch)
tree5a7c8cf1061c0977ae1c99bce2bc49437d24319c
parent2fde2ada50a00512490511349389d08ede9822f8 (diff)
parent3db29ee43960a4e164244a55b0e2a4b23a112e49 (diff)
downloadphp-git-ef86b57f3b6745d5215e1316512c108f46df8668.tar.gz
Merge branch 'master' of https://github.com/krakjoe/phpdbg into lexer
Conflicts: phpdbg_prompt.c
-rw-r--r--phpdbg.c16
-rw-r--r--phpdbg_bp.c2
-rw-r--r--phpdbg_frame.c4
-rw-r--r--phpdbg_help.c10
-rw-r--r--phpdbg_opcode.c5
-rw-r--r--phpdbg_prompt.c35
6 files changed, 65 insertions, 7 deletions
diff --git a/phpdbg.c b/phpdbg.c
index d830092797..37a938f555 100644
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -1119,8 +1119,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
@@ -1269,6 +1277,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_bp.c b/phpdbg_bp.c
index 111d5ca1c9..15b00c1d01 100644
--- a/phpdbg_bp.c
+++ b/phpdbg_bp.c
@@ -361,7 +361,7 @@ PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline TSRMLS_DC) /* {{{
PHPDBG_API int phpdbg_resolve_op_array_break(phpdbg_breakopline_t *brake, zend_op_array *op_array TSRMLS_DC) /* {{{ */
{
phpdbg_breakline_t opline_break;
- if (op_array->last < brake->opline_num) {
+ if (op_array->last <= brake->opline_num) {
if (brake->class_name == NULL) {
phpdbg_error("There are only %d oplines in function %s (breaking at opline %ld impossible)", op_array->last, brake->func_name, brake->opline_num);
} else if (brake->func_name == NULL) {
diff --git a/phpdbg_frame.c b/phpdbg_frame.c
index de02addc1b..a235fe8cb0 100644
--- a/phpdbg_frame.c
+++ b/phpdbg_frame.c
@@ -167,7 +167,7 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
zval **tmp;
zval **file, **line;
HashPosition position;
- int i = 1, limit = num;
+ int i = 0, limit = num;
int user_defined;
if (limit < 0) {
@@ -186,7 +186,7 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace),
(void**)&tmp, &position) == FAILURE) {
- phpdbg_write("frame #0: {main} at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line));
+ phpdbg_write("frame #%d: {main} at %s:%ld", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
break;
}
diff --git a/phpdbg_help.c b/phpdbg_help.c
index 941d58ce67..72038dc0fd 100644
--- a/phpdbg_help.c
+++ b/phpdbg_help.c
@@ -378,7 +378,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
@@ -793,11 +795,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_opcode.c b/phpdbg_opcode.c
index 50073eb22b..6b13625fc1 100644
--- a/phpdbg_opcode.c
+++ b/phpdbg_opcode.c
@@ -183,6 +183,7 @@ void phpdbg_print_opline(zend_execute_data *execute_data, zend_bool ignore_flags
const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */
{
+#if ZEND_EXTENSION_API_NO <= PHP_5_5_API_NO
#define CASE(s) case s: return #s
switch (opcode) {
CASE(ZEND_NOP);
@@ -360,4 +361,8 @@ const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */
default:
return "UNKNOWN";
}
+#else
+ const char *ret = zend_get_opcode_name(opcode);
+ return ret?ret:"UNKNOWN";
+#endif
} /* }}} */
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index 31c5d25122..3010c088a5 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -356,6 +356,7 @@ PHPDBG_COMMAND(exec) /* {{{ */
if ((res_len != PHPDBG_G(exec_len)) || (memcmp(res, PHPDBG_G(exec), res_len) != SUCCESS)) {
+<<<<<<< HEAD
if (PHPDBG_G(exec)) {
phpdbg_notice("Unsetting old execution context: %s", PHPDBG_G(exec));
efree(PHPDBG_G(exec));
@@ -366,6 +367,17 @@ PHPDBG_COMMAND(exec) /* {{{ */
if (PHPDBG_G(ops)) {
phpdbg_notice("Destroying compiled opcodes");
phpdbg_clean(0 TSRMLS_CC);
+=======
+ *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");
+ }
+ } else {
+ phpdbg_error("Cannot use %s as execution context, not a valid file or symlink", param->str);
+>>>>>>> 3db29ee43960a4e164244a55b0e2a4b23a112e49
}
PHPDBG_G(exec) = res;
@@ -641,6 +653,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;