Skip to content

Commit a0b75a2

Browse files
committed
- Passing input ptr to handlers
1 parent c10796e commit a0b75a2

File tree

4 files changed

+35
-33
lines changed

4 files changed

+35
-33
lines changed

phpdbg.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,23 @@ static void php_phpdbg_destroy_bp_condition(void *data) /* {{{ */
102102
static void php_phpdbg_destroy_registered(void *data)
103103
{
104104
TSRMLS_FETCH();
105-
105+
106106
zend_function *function = (zend_function*) data;
107-
107+
108108
destroy_zend_function(
109109
function TSRMLS_CC);
110110
}
111111

112112
static PHP_RINIT_FUNCTION(phpdbg) /* {{{ */
113-
{
113+
{
114114
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], 8, NULL, php_phpdbg_destroy_bp_file, 0);
115115
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], 8, NULL, php_phpdbg_destroy_bp_symbol, 0);
116116
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE], 8, NULL, NULL, 0);
117117
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], 8, NULL, php_phpdbg_destroy_bp_methods, 0);
118118
zend_hash_init(&PHPDBG_G(bp)[PHPDBG_BREAK_COND], 8, NULL, php_phpdbg_destroy_bp_condition, 0);
119119
zend_hash_init(&PHPDBG_G(seek), 8, NULL, NULL, 0);
120120
zend_hash_init(&PHPDBG_G(registered), 8, NULL, php_phpdbg_destroy_registered, 0);
121-
121+
122122
return SUCCESS;
123123
} /* }}} */
124124

@@ -131,7 +131,7 @@ static PHP_RSHUTDOWN_FUNCTION(phpdbg) /* {{{ */
131131
zend_hash_destroy(&PHPDBG_G(bp)[PHPDBG_BREAK_COND]);
132132
zend_hash_destroy(&PHPDBG_G(seek));
133133
zend_hash_destroy(&PHPDBG_G(registered));
134-
134+
135135
if (PHPDBG_G(exec)) {
136136
efree(PHPDBG_G(exec));
137137
PHPDBG_G(exec) = NULL;
@@ -170,19 +170,19 @@ static PHP_FUNCTION(phpdbg_break)
170170

171171
switch (type) {
172172
case METHOD_PARAM:
173-
phpdbg_do_break_method(&param TSRMLS_CC);
173+
phpdbg_do_break_method(&param, NULL TSRMLS_CC);
174174
break;
175175

176176
case FILE_PARAM:
177-
phpdbg_do_break_file(&param TSRMLS_CC);
177+
phpdbg_do_break_file(&param, NULL TSRMLS_CC);
178178
break;
179179

180180
case NUMERIC_PARAM:
181-
phpdbg_do_break_lineno(&param TSRMLS_CC);
181+
phpdbg_do_break_lineno(&param, NULL TSRMLS_CC);
182182
break;
183183

184184
case STR_PARAM:
185-
phpdbg_do_break_func(&param TSRMLS_CC);
185+
phpdbg_do_break_func(&param, NULL TSRMLS_CC);
186186
break;
187187

188188
default: zend_error(
@@ -616,7 +616,7 @@ int main(int argc, char **argv) /* {{{ */
616616

617617
/* print blurb */
618618
phpdbg_welcome((cleaning > 0) TSRMLS_CC);
619-
619+
620620
zend_try {
621621
/* activate globals, they can be overwritten */
622622
zend_activate_auto_globals(TSRMLS_C);

phpdbg_cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void phpdbg_destroy_input(phpdbg_input_t **input TSRMLS_DC) /*{{{ */
303303
}
304304
} /* }}} */
305305

306-
int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_DC) /* {{{ */
306+
int phpdbg_do_cmd(const phpdbg_command_t *command, const phpdbg_input_t *input TSRMLS_DC) /* {{{ */
307307
{
308308
int rc = FAILURE;
309309

@@ -357,7 +357,7 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, phpdbg_input_t *input TSRMLS_
357357
&PHPDBG_G(lparam) TSRMLS_CC);
358358
PHPDBG_G(lparam) = param;
359359

360-
rc = command->handler(&param TSRMLS_CC);
360+
rc = command->handler(&param, input TSRMLS_CC);
361361
break;
362362
}
363363
command++;

phpdbg_cmd.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef struct _phpdbg_param {
6666
size_t len;
6767
} phpdbg_param_t;
6868

69-
typedef int (*phpdbg_command_handler_t)(phpdbg_param_t* TSRMLS_DC);
69+
typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t*, const phpdbg_input_t* TSRMLS_DC);
7070

7171
struct _phpdbg_command_t {
7272
const char *name; /* Command name */
@@ -114,7 +114,7 @@ const char* phpdbg_get_param_type(const phpdbg_param_t* TSRMLS_DC);
114114
/*
115115
* Command Executor
116116
*/
117-
int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t *input TSRMLS_DC);
117+
int phpdbg_do_cmd(const phpdbg_command_t*, const phpdbg_input_t* TSRMLS_DC);
118118

119119
/**
120120
* Command Declarators
@@ -127,7 +127,9 @@ int phpdbg_do_cmd(const phpdbg_command_t*, phpdbg_input_t *input TSRMLS_DC);
127127
#define PHPDBG_COMMAND_D(name, tip, alias, children, has_args) \
128128
{PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, has_args}
129129

130-
#define PHPDBG_COMMAND(name) int phpdbg_do_##name(phpdbg_param_t *param TSRMLS_DC)
130+
#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC)
131+
132+
#define PHPDBG_COMMAND_ARGS param, input TSRMLS_CC
131133

132134
#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0'}
133135

phpdbg_prompt.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -899,17 +899,17 @@ static PHPDBG_COMMAND(list) /* {{{ */
899899
switch (param->type) {
900900
case NUMERIC_PARAM:
901901
case EMPTY_PARAM:
902-
return PHPDBG_LIST_HANDLER(lines)(param TSRMLS_CC);
902+
return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS);
903903

904904
case FILE_PARAM:
905-
return PHPDBG_LIST_HANDLER(lines)(param TSRMLS_CC);
905+
return PHPDBG_LIST_HANDLER(lines)(PHPDBG_COMMAND_ARGS);
906906

907907
case STR_PARAM:
908908
phpdbg_list_function_byname(param->str, param->len TSRMLS_CC);
909909
break;
910910

911911
case METHOD_PARAM:
912-
return PHPDBG_LIST_HANDLER(method)(param TSRMLS_CC);
912+
return PHPDBG_LIST_HANDLER(method)(PHPDBG_COMMAND_ARGS);
913913

914914
phpdbg_default_switch_case();
915915
}
@@ -926,7 +926,7 @@ int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
926926

927927
zval fname, *fretval;
928928
zend_fcall_info *fci = ecalloc(1, sizeof(zend_fcall_info));
929-
929+
930930
ZVAL_STRINGL(&fname, function->string, function->length, 1);
931931

932932
fci->size = sizeof(zend_fcall_info);
@@ -936,36 +936,36 @@ int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
936936
fci->object_ptr = NULL;
937937
fci->retval_ptr_ptr = &fretval;
938938
fci->no_separation = 1;
939-
939+
940940
if (input->argc > 1) {
941941
int param;
942942
zval params;
943-
943+
944944
array_init(&params);
945-
945+
946946
for (param = 0; param < (input->argc-1); param++) {
947947
add_next_index_stringl(
948-
&params,
948+
&params,
949949
input->argv[param+1]->string,
950950
input->argv[param+1]->length, 1);
951-
951+
952952
phpdbg_debug(
953-
"created param[%d] from argv[%d]: %s",
953+
"created param[%d] from argv[%d]: %s",
954954
param, param+1, input->argv[param+1]->string);
955955
}
956-
956+
957957
zend_fcall_info_args(fci, &params TSRMLS_CC);
958958
} else {
959959
fci->params = NULL;
960960
fci->param_count = 0;
961961
}
962-
962+
963963
phpdbg_debug(
964-
"created %d params from %d argvuments",
964+
"created %d params from %d argvuments",
965965
fci->param_count, input->argc);
966-
966+
967967
zend_call_function(fci, NULL TSRMLS_CC);
968-
968+
969969
if (fretval) {
970970
zend_print_zval_r(
971971
fretval, 0 TSRMLS_CC);
@@ -977,9 +977,9 @@ int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
977977
if (fci->params) {
978978
efree(fci->params);
979979
}
980-
980+
981981
efree(fci);
982-
982+
983983
return SUCCESS;
984984
}
985985

@@ -1024,7 +1024,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
10241024
last:
10251025
if (PHPDBG_G(lcmd)) {
10261026
ret = PHPDBG_G(lcmd)->handler(
1027-
&PHPDBG_G(lparam) TSRMLS_CC);
1027+
&PHPDBG_G(lparam), input TSRMLS_CC);
10281028
goto out;
10291029
}
10301030
}

0 commit comments

Comments
 (0)