switch (type) {
case METHOD_PARAM:
- phpdbg_do_break_method(¶m, NULL TSRMLS_CC);
+ phpdbg_do_break_method(¶m TSRMLS_CC);
break;
case FILE_PARAM:
- phpdbg_do_break_file(¶m, NULL TSRMLS_CC);
+ phpdbg_do_break_file(¶m TSRMLS_CC);
break;
case NUMERIC_PARAM:
- phpdbg_do_break_lineno(¶m, NULL TSRMLS_CC);
+ phpdbg_do_break_lineno(¶m TSRMLS_CC);
break;
case STR_PARAM:
- phpdbg_do_break_func(¶m, NULL TSRMLS_CC);
+ phpdbg_do_break_func(¶m TSRMLS_CC);
break;
default: zend_error(
if (run) {
/* no need to try{}, run does it ... */
- PHPDBG_COMMAND_HANDLER(run)(NULL, NULL TSRMLS_CC);
+ PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC);
if (run > 1) {
/* if -r is on the command line more than once just quit */
goto phpdbg_out;
}
} /* }}} */
-PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC) /* {{{ */
+PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param TSRMLS_DC) /* {{{ */
{
/*
if (input->argc > 3 && phpdbg_argv_is(2, "if")) {
PHPDBG_API void phpdbg_set_breakpoint_function_opline(const char *function, zend_ulong opline TSRMLS_DC);
PHPDBG_API void phpdbg_set_breakpoint_file_opline(const char *file, zend_ulong opline TSRMLS_DC);
PHPDBG_API void phpdbg_set_breakpoint_expression(const char* expression, size_t expression_len TSRMLS_DC);
-PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC); /* }}} */
+PHPDBG_API void phpdbg_set_breakpoint_at(const phpdbg_param_t *param TSRMLS_DC); /* }}} */
/* {{{ Breakpoint Detection API */
PHPDBG_API phpdbg_breakbase_t* phpdbg_find_breakpoint(zend_execute_data* TSRMLS_DC); /* }}} */
PHPDBG_COMMAND_D_EX(op, "specify breakpoint by opcode", 'O', break_op, NULL, "s"),
PHPDBG_COMMAND_D_EX(on, "specify breakpoint by condition", 'o', break_on, NULL, "c"),
PHPDBG_COMMAND_D_EX(at, "specify breakpoint by location and condition", 'A', break_at, NULL, "*c"),
- PHPDBG_COMMAND_D_EX(lineno, "specify breakpoint by line of currently executing file", 'l', break_lineno, NULL, "l"),
- PHPDBG_COMMAND_D_EX(del, "delete breakpoint by identifier number", 'd', break_del, NULL, "l"),
+ PHPDBG_COMMAND_D_EX(lineno, "specify breakpoint by line of currently executing file", 'l', break_lineno, NULL, "n"),
+ PHPDBG_COMMAND_D_EX(del, "delete breakpoint by identifier number", 'd', break_del, NULL, "n"),
PHPDBG_END_COMMAND
};
PHPDBG_BREAK(at) /* {{{ */
{
- phpdbg_set_breakpoint_at(param, input TSRMLS_CC);
+ phpdbg_set_breakpoint_at(param TSRMLS_CC);
return SUCCESS;
} /* }}} */
break;
case EMPTY_PARAM: { /* do nothing */ } break;
+
+ default: {
+ /* not yet */
+ }
}
} /* }}} */
break;
case EMPTY_PARAM: { /* do nothing */ } break;
+
+ default: {
+ /* not yet */
+ }
}
return hash;
case EMPTY_PARAM:
return 1;
+
+ default: {
+ /* not yet */
+ }
}
}
}
if (param && param->type) {
switch (param->type) {
case STR_PARAM:
- fprintf(stderr, "%s STR_PARAM(%s=%d)\n", msg, param->str, param->len);
+ fprintf(stderr, "%s STR_PARAM(%s=%lu)\n", msg, param->str, param->len);
break;
case ADDR_PARAM:
break;
case FILE_PARAM:
- fprintf(stderr, "%s FILE_PARAM(%s:%d)\n", msg, param->file.name, param->file.line);
+ fprintf(stderr, "%s FILE_PARAM(%s:%lu)\n", msg, param->file.name, param->file.line);
break;
case METHOD_PARAM:
break;
case NUMERIC_FUNCTION_PARAM:
- fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%s)\n", msg, param->str, param->num);
+ fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%ld)\n", msg, param->str, param->num);
break;
case NUMERIC_PARAM:
break;
case COND_PARAM:
- fprintf(stderr, "%s COND_PARAM(%s=%d)\n", msg, param->str, param->len);
+ fprintf(stderr, "%s COND_PARAM(%s=%lu)\n", msg, param->str, param->len);
break;
+
+ default: {
+ /* not yet */
+ }
}
}
} /* }}} */
free(remove->file.name);
}
break;
+
+ default: {
+ /* nothing */
+ }
}
free(remove);
stack->len++;
} /* }}} */
-PHPDBG_API int phpdbg_stack_verify(phpdbg_command_t *command, const phpdbg_param_t **stack, char **why TSRMLS_DC) {
+PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack, char **why TSRMLS_DC) {
if (command && command->args) {
const phpdbg_param_t *top = (stack != NULL) ? *stack : NULL;
const char *arg = command->args;
case 'i': if (top->type != STR_PARAM) {
asprintf(why,
- "%s expected raw input and got %s at parameter %d",
+ "%s expected raw input and got %s at parameter %lu",
command->name, phpdbg_get_param_type(top TSRMLS_CC),
(command->args - arg) + 1);
return FAILURE;
case 's': if (top->type != STR_PARAM) {
asprintf(why,
- "%s expected string and got %s at parameter %d",
+ "%s expected string and got %s at parameter %lu",
command->name, phpdbg_get_param_type(top TSRMLS_CC),
(command->args - arg) + 1);
return FAILURE;
case 'n': if (top->type != NUMERIC_PARAM) {
asprintf(why,
- "%s expected number and got %s at parameter %d",
+ "%s expected number and got %s at parameter %lu",
command->name, phpdbg_get_param_type(top TSRMLS_CC),
(command->args - arg) + 1);
return FAILURE;
case 'm': if (top->type != METHOD_PARAM) {
asprintf(why,
- "%s expected method and got %s at parameter %d",
+ "%s expected method and got %s at parameter %lu",
command->name, phpdbg_get_param_type(top TSRMLS_CC),
(command->args - arg) + 1);
return FAILURE;
case 'a': if (top->type != ADDR_PARAM) {
asprintf(why,
- "%s expected address and got %s at parameter %d",
+ "%s expected address and got %s at parameter %lu",
command->name, phpdbg_get_param_type(top TSRMLS_CC),
(command->args - arg) + 1);
return FAILURE;
case 'f': if (top->type != FILE_PARAM) {
asprintf(why,
- "%s expected file:line and got %s at parameter %d",
+ "%s expected file:line and got %s at parameter %lu",
command->name, phpdbg_get_param_type(top TSRMLS_CC),
(command->args - arg) + 1);
return FAILURE;
case 'c': if (top->type != COND_PARAM) {
asprintf(why,
- "%s expected condition and got %s at parameter %d",
+ "%s expected condition and got %s at parameter %lu",
command->name, phpdbg_get_param_type(top TSRMLS_CC),
(command->args - arg) + 1);
return FAILURE;
case 'b': if (top->type != NUMERIC_PARAM) {
asprintf(why,
- "%s expected boolean and got %s at parameter %d",
+ "%s expected boolean and got %s at parameter %lu",
command->name, phpdbg_get_param_type(top TSRMLS_CC),
(command->args - arg) + 1);
return FAILURE;
} else if (top->num > 1 || top->num < 0) {
asprintf(why,
- "%s expected boolean and got number at parameter %d",
- command->name, phpdbg_get_param_type(top TSRMLS_CC),
+ "%s expected boolean and got number at parameter %lu",
+ command->name,
(command->args - arg) + 1);
return FAILURE;
} break;
if ((received < expected) && (arg && *arg) && !optional) {
asprintf(why,
- "%s expected %d arguments (%s) and received %d",
+ "%s expected %lu arguments (%s) and received %lu",
command->name,
expected,
command->args,
}
/* {{{ */
-PHPDBG_API phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why) {
+PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why) {
const phpdbg_command_t *command = commands;
phpdbg_param_t *name = *top;
- phpdbg_command_t *matched[3] = {NULL, NULL, NULL};
-
+ const phpdbg_command_t *matched[3] = {NULL, NULL, NULL};
ulong matches = 0L;
while (command && command->name && command->handler) {
- if (command->name_len >= name->len) {
- if (memcmp(command->name, name->str, name->len) == SUCCESS) {
- if (matches < 3) {
+ if ((name->len == 1) || (command->name_len >= name->len)) {
+ /* match single letter alias */
+ if (command->alias && (name->len == 1)) {
+ if (command->alias == (*name->str)) {
matched[matches] = command;
matches++;
- } else break;
+ }
+ } else {
+ /* match full command name */
+ if (memcmp(command->name, name->str, name->len) == SUCCESS) {
+ if (matches < 3) {
+ matched[matches] = command;
+ matches++;
+ } else break;
+ }
}
}
command++;
default: {
asprintf(
why,
- "The command %s is ambigious, matching %d commands",
+ "The command %s is ambigious, matching %lu commands",
name->str, matches);
} return NULL;
}
/* {{{ */
PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
- phpdbg_param_t *command = NULL,
- *params = NULL;
- phpdbg_command_t *handler = NULL;
+ phpdbg_param_t *command = NULL;
+ const phpdbg_command_t *handler = NULL;
if (stack->type != STACK_PARAM) {
asprintf(
switch (command->type) {
case EVAL_PARAM:
- return PHPDBG_COMMAND_HANDLER(eval)(command, NULL TSRMLS_CC);
+ return PHPDBG_COMMAND_HANDLER(eval)(command TSRMLS_CC);
case SHELL_PARAM:
- return PHPDBG_COMMAND_HANDLER(shell)(command, NULL TSRMLS_CC);
+ return PHPDBG_COMMAND_HANDLER(shell)(command TSRMLS_CC);
case STR_PARAM: {
handler = phpdbg_stack_resolve(
if (handler) {
if (phpdbg_stack_verify(handler, &command, why) == SUCCESS) {
- return handler->handler(command, NULL TSRMLS_CC);
+ return handler->handler(command TSRMLS_CC);
}
}
} return FAILURE;
#include "TSRM.h"
-typedef struct _phpdbg_command_t phpdbg_command_t;
-
/* {{{ Command and Parameter */
enum {
NO_ARG = 0,
ORIG_PARAM
} phpdbg_param_type;
-typedef struct _phpdbg_input_t phpdbg_input_t;
-
-struct _phpdbg_input_t {
- char * const *start;
- char *string;
- size_t length;
- phpdbg_input_t **argv;
- int argc;
-};
-
typedef struct _phpdbg_param phpdbg_param_t;
struct _phpdbg_param {
phpdbg_param_type type;
#define YYSTYPE phpdbg_param_t
#endif
-typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t*, const phpdbg_input_t* TSRMLS_DC);
+typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t* TSRMLS_DC);
+typedef struct _phpdbg_command_t phpdbg_command_t;
struct _phpdbg_command_t {
const char *name; /* Command name */
size_t name_len; /* Command name length */
* Stack Management
*/
PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param);
-PHPDBG_API phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why);
+PHPDBG_API const phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, const phpdbg_command_t *parent, phpdbg_param_t **top, char **why);
+PHPDBG_API int phpdbg_stack_verify(const phpdbg_command_t *command, phpdbg_param_t **stack, char **why TSRMLS_DC);
PHPDBG_API int phpdbg_stack_execute(phpdbg_param_t *stack, char **why);
PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack);
#define PHPDBG_COMMAND_D(name, tip, alias, children, args) \
{PHPDBG_STRL(#name), tip, sizeof(tip)-1, alias, phpdbg_do_##name, children, args}
-#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param, const phpdbg_input_t *input TSRMLS_DC)
+#define PHPDBG_COMMAND(name) int phpdbg_do_##name(const phpdbg_param_t *param TSRMLS_DC)
-#define PHPDBG_COMMAND_ARGS param, input TSRMLS_CC
+#define PHPDBG_COMMAND_ARGS param TSRMLS_CC
-#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0', '\0'}
+#define PHPDBG_END_COMMAND {NULL, 0, NULL, 0, '\0', NULL, NULL, '\0'}
/*
* Default Switch Case
if (n>0) {
if (cmd->alias == 'a') { /* help aliases executes a canned routine */
- return cmd->handler(param, NULL TSRMLS_CC);
+ return cmd->handler(param TSRMLS_CC);
} else {
pretty_print(get_help(cmd->name TSRMLS_CC) TSRMLS_CC);
return SUCCESS;
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
-static inline int phpdbg_call_register(phpdbg_input_t *input TSRMLS_DC) /* {{{ */
+static inline int phpdbg_call_register(phpdbg_param_t *stack TSRMLS_DC) /* {{{ */
{
- phpdbg_input_t *function = input->argv[0];
-
- if (zend_hash_exists(
- &PHPDBG_G(registered), function->string, function->length+1)) {
-
- zval fname, *fretval;
- zend_fcall_info fci;
-
- ZVAL_STRINGL(&fname, function->string, function->length, 1);
-
- memset(&fci, 0, sizeof(zend_fcall_info));
-
- fci.size = sizeof(zend_fcall_info);
- fci.function_table = &PHPDBG_G(registered);
- fci.function_name = &fname;
- fci.symbol_table = EG(active_symbol_table);
- 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,
- input->argv[param+1]->string,
- input->argv[param+1]->length, 1);
+ phpdbg_param_t *name = stack;
+
+ if (name->type == STR_PARAM) {
+ if (zend_hash_exists(
+ &PHPDBG_G(registered), name->str, name->len+1)) {
+
+ zval fname, *fretval;
+ zend_fcall_info fci;
+
+ ZVAL_STRINGL(&fname, name->str, name->len, 1);
+
+ memset(&fci, 0, sizeof(zend_fcall_info));
+
+ fci.size = sizeof(zend_fcall_info);
+ fci.function_table = &PHPDBG_G(registered);
+ fci.function_name = &fname;
+ fci.symbol_table = EG(active_symbol_table);
+ fci.object_ptr = NULL;
+ fci.retval_ptr_ptr = &fretval;
+ fci.no_separation = 1;
+
+ if (stack->next) {
+ zval params;
+ phpdbg_param_t *next = stack->next;
+
+ array_init(¶ms);
+
+ while (next) {
+ switch (next->type) {
+ case STR_PARAM:
+ add_next_index_stringl(
+ ¶ms,
+ next->str,
+ next->len, 1);
+ break;
+
+ case NUMERIC_PARAM:
+ add_next_index_long(¶ms, next->num);
+ break;
+
+ default: {
+ /* not yet */
+ }
+ }
+
+ phpdbg_debug(
+ "created param[%d] from argv[%d]: %s",
+ param, param+1, next->str);
+ next = next->next;
+ }
- phpdbg_debug(
- "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;
}
- zend_fcall_info_args(&fci, ¶ms TSRMLS_CC);
- } else {
- fci.params = NULL;
- fci.param_count = 0;
- }
-
- phpdbg_debug(
- "created %d params from %d arguments",
- fci.param_count, input->argc);
+ phpdbg_debug(
+ "created %d params from arguments",
+ fci.param_count);
- zend_call_function(&fci, NULL TSRMLS_CC);
+ zend_call_function(&fci, NULL TSRMLS_CC);
- if (fretval) {
- zend_print_zval_r(
- fretval, 0 TSRMLS_CC);
- phpdbg_writeln(EMPTY);
- }
+ if (fretval) {
+ zend_print_zval_r(
+ fretval, 0 TSRMLS_CC);
+ phpdbg_writeln(EMPTY);
+ }
- zval_dtor(&fname);
+ zval_dtor(&fname);
- return SUCCESS;
+ return SUCCESS;
+ }
}
return FAILURE;
last:
if (PHPDBG_G(lcmd)) {
ret = PHPDBG_G(lcmd)->handler(
- &PHPDBG_G(lparam), input TSRMLS_CC);
+ &PHPDBG_G(lparam) TSRMLS_CC);
goto out;
}
}
break;
case NUMERIC_PARAM: {
- if (input && input->argc > 2) {
+ if (param->next) {
/*
if (phpdbg_argv_is(2, "on")) {
phpdbg_enable_breakpoint(param->num TSRMLS_CC);
#ifndef _WIN32
PHPDBG_SET(color) /* {{{ */
{
- if ((param->type == STR_PARAM) && (input->argc == 3)) {
+ /*if ((param->type == STR_PARAM) && (input->argc == 3)) {
const phpdbg_color_t *color = phpdbg_get_color(
input->argv[2]->string, input->argv[2]->length TSRMLS_CC);
int element = PHPDBG_COLOR_INVALID;
- /* @TODO(anyone) make this consistent with other set commands */
if (color) {
- /*if (phpdbg_argv_is(1, "prompt")) {
+ if (phpdbg_argv_is(1, "prompt")) {
phpdbg_notice(
"setting prompt color to %s (%s)", color->name, color->code);
element = PHPDBG_COLOR_PROMPT;
element = PHPDBG_COLOR_NOTICE;
} else goto usage;
-*/
- /* set color for element */
- /* phpdbg_set_color(element, color TSRMLS_CC); */
+
+ phpdbg_set_color(element, color TSRMLS_CC);
} else {
phpdbg_error(
"Failed to find the requested color (%s)", input->argv[2]->string);
usage:
phpdbg_error(
"set color used incorrectly: set color <prompt|error|notice> <color>");
- }
+ } */
+
return SUCCESS;
} /* }}} */