com php-src: - Passing input ptr to handlers: phpdbg.c phpdbg_cmd.c phpdbg_cmd.h phpdbg_prompt.c
| From: | Bob Weinand | Date: | Wed, 20 Nov 2013 13:28:41 +0000 |
| Subject: | com php-src: - Passing input ptr to handlers: phpdbg.c phpdbg_cmd.c phpdbg_cmd.h phpdbg_prompt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74771@lists.php.net to get a copy of this message | ||
Commit: a0b75a24e5c45264eb9c2c551cfd599e6646ca65
Author: Felipe Pena <felipensp@gmail.com> Wed, 20 Nov 2013 11:28:41 -0200
Parents: c10796e7e9306b08d6280c3b39c9b315c7df91cc
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a0b75a24e5c45264eb9c2c551cfd599e6646ca65
Log:
- Passing input ptr to handlers
Changed paths:
M phpdbg.c
M phpdbg_cmd.c
M phpdbg_cmd.h
M phpdbg_prompt.c
Diff:
diff --git a/phpdbg.c b/phpdbg.c
index c8a3995..200c48d 100644
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -102,15 +102,15 @@ static void php_phpdbg_destroy_bp_condition(void *data) /* {{{ */
static void php_phpdbg_destroy_registered(void *data)
{
TSRMLS_FETCH();
-
+
zend_function *function = (zend_function*) data;
-
+
destroy_zend_function(
function TSRMLS_CC);
}
static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
-{
+{
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0);
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, NULL, 0);
@@ -118,7 +118,7 @@ static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition,
0);
zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0);
zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0);
-
+
return SUCCESS;
} /* }}} */
@@ -131,7 +131,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]);
zend_hash_destroy(&PHPDBG_G(seek));
zend_hash_destroy(&PHPDBG_G(registered));
-
+
if (PHPDBG_G(exec)) {
efree(PHPDBG_G(exec));
PHPDBG_G(exec) = NULL;
@@ -170,19 +170,19 @@ static PHP_FUNCTION(phpdbg_break)
switch (type) {
case METHOD_PARAM:
- phpdbg_do_break_method(¶m TSRMLS_CC);
+ phpdbg_do_break_method(¶m, NULL TSRMLS_CC);
break;
case FILE_PARAM:
- phpdbg_do_break_file(¶m TSRMLS_CC);
+ phpdbg_do_break_file(¶m, NULL TSRMLS_CC);
break;
case NUMERIC_PARAM:
- phpdbg_do_break_lineno(¶m TSRMLS_CC);
+ phpdbg_do_break_lineno(¶m, NULL TSRMLS_CC);
break;
case STR_PARAM:
- phpdbg_do_break_func(¶m TSRMLS_CC);
+ phpdbg_do_break_func(¶m, NULL TSRMLS_CC);
break;
default: zend_error(
@@ -616,7 +616,7 @@ phpdbg_main:
/* print blurb */
phpdbg_welcome((cleaning > 0) TSRMLS_CC);
-
+
zend_try {
/* activate globals, they can be overwritten */
zend_activate_auto_globals(TSRMLS_C);
diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c
index 32e99f1..90d8c1e 100644
--- a/phpdbg_cmd.c
+++ b/phpdbg_cmd.c
@@ -303,7 +303,7 @@ void phpdbg_destroy_input(phpdbg_input_t **input TSRMLS_DC) /*{{{ */
}
} /* }}} */
-int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_DC) /* {{{ */
+int phpdbg_do_cmd(const phpdbg_command_t *command, const phpdbg_input_t *input TSRMLS_DC) /* {{{ */
{
int rc = FAILURE;
@@ -357,7 +357,7 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_
&PHPDBG_G(lparam) TSRMLS_CC);
PHPDBG_G(lparam) = param;
- rc = command->handler(¶m TSRMLS_CC);
+ rc = command->handler(¶m, input TSRMLS_CC);
break;
}
command++;
diff --git a/phpdbg_cmd.h b/phpdbg_cmd.h
index 696a49a..259078a 100644
--- a/phpdbg_cmd.h
+++ b/phpdbg_cmd.h
@@ -66,7 +66,7 @@ typedef struct _phpdbg_param {
size_t len;
} phpdbg_param_t;
-typedef int (*phpdbg_command_handler_t)(phpdbg_param_t* TSRMLS_DC);
+typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t*, const phpdbg_input_t* TSRMLS_DC);
struct _phpdbg_command_t {
const char *name; /* Command name */
@@ -114,7 +114,7 @@ const char* phpdbg_get_param_type(const phpdbg_param_t* TSRMLS_DC);
/*
* Command Executor
*/
-int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t *input TSRMLS_DC);
+int phpdbg_do_cmd(const phpdbg_command_t*, const phpdbg_input_t* TSRMLS_DC);
/**
* Command Declarators
@@ -127,7 +127,9 @@ int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t *input TSRMLS_DC);
#define PHPDBG_COMMAND_D(name, tip, alias, children, has_args) \
{PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, has_args}
-#define PHPDBG_COMMAND(name) int phpdbg_do_##name(phpdbg_param_t *param TSRMLS_DC)
+#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param, const phpdbg_input_t
*input TSRMLS_DC)
+
+#define PHPDBG_COMMAND_ARGS param, input TSRMLS_CC
#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0'}
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index cda710a..8532a8a 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -899,17 +899,17 @@ static PHPDBG_COMMAND(list) /* {{{ */
switch (param->type) {
case NUMERIC_PARAM:
case EMPTY_PARAM:
- return PHPDBG_LIST_HANDLER(lines)(param TSRMLS_CC);
+ return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS);
case FILE_PARAM:
- return PHPDBG_LIST_HANDLER(lines)(param TSRMLS_CC);
+ return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS);
case STR_PARAM:
phpdbg_list_function_byname(param->str, param->len TSRMLS_CC);
break;
case METHOD_PARAM:
- return PHPDBG_LIST_HANDLER(method)(param TSRMLS_CC);
+ return PHPDBG_LIST_HANDLER(method)(PHPDBG_COMMAND_ARGS);
phpdbg_default_switch_case();
}
@@ -926,7 +926,7 @@ int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
zval fname, *fretval;
zend_fcall_info *fci = ecalloc(1, sizeof(zend_fcall_info));
-
+
ZVAL_STRINGL(&fname, function->string, function->length, 1);
fci->size = sizeof(zend_fcall_info);
@@ -936,36 +936,36 @@ int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
fci->object_ptr = NULL;
fci->retval_ptr_ptr = &fretval;
fci->no_separation = 1;
-
+
if (input->argc > 1) {
int param;
zval params;
-
+
array_init(¶ms);
-
+
for (param = 0; param < (input->argc-1); param++) {
add_next_index_stringl(
- ¶ms,
+ ¶ms,
input->argv[param+1]->string,
input->argv[param+1]->length, 1);
-
+
phpdbg_debug(
- "created param[%d] from argv[%d]: %s",
+ "created param[%d] from argv[%d]: %s",
param, param+1, input->argv[param+1]->string);
}
-
+
zend_fcall_info_args(fci, ¶ms TSRMLS_CC);
} else {
fci->params = NULL;
fci->param_count = 0;
}
-
+
phpdbg_debug(
- "created %d params from %d argvuments",
+ "created %d params from %d argvuments",
fci->param_count, input->argc);
-
+
zend_call_function(fci, NULL TSRMLS_CC);
-
+
if (fretval) {
zend_print_zval_r(
fretval, 0 TSRMLS_CC);
@@ -977,9 +977,9 @@ int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
if (fci->params) {
efree(fci->params);
}
-
+
efree(fci);
-
+
return SUCCESS;
}
@@ -1024,7 +1024,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
last:
if (PHPDBG_G(lcmd)) {
ret = PHPDBG_G(lcmd)->handler(
- &PHPDBG_G(lparam) TSRMLS_CC);
+ &PHPDBG_G(lparam), input TSRMLS_CC);
goto out;
}
}