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);
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;
} /* }}} */
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;
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(
/* print blurb */
phpdbg_welcome((cleaning > 0) TSRMLS_CC);
-
+
zend_try {
/* activate globals, they can be overwritten */
zend_activate_auto_globals(TSRMLS_C);
}
} /* }}} */
-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;
&PHPDBG_G(lparam) TSRMLS_CC);
PHPDBG_G(lparam) = param;
- rc = command->handler(¶m TSRMLS_CC);
+ rc = command->handler(¶m, input TSRMLS_CC);
break;
}
command++;
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 */
/*
* 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
#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'}
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();
}
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);
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);
if (fci->params) {
efree(fci->params);
}
-
+
efree(fci);
-
+
return SUCCESS;
}
last:
if (PHPDBG_G(lcmd)) {
ret = PHPDBG_G(lcmd)->handler(
- &PHPDBG_G(lparam) TSRMLS_CC);
+ &PHPDBG_G(lparam), input TSRMLS_CC);
goto out;
}
}