#include "phpdbg.h"
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
+#include "phpdbg_cmd.h"
#include "phpdbg_prompt.h"
#define YYSTYPE phpdbg_param_t
int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) {
phpdbg_error("Parse Error: %s", msg);
+ {
+ const phpdbg_param_t *top = stack;
+ zend_ulong position = 0L;
+
+ while (top) {
+ phpdbg_param_debug(
+ top, "--> ");
+ top = top->next;
+ }
+ }
}
-
-void phpdbg_debug_param(const phpdbg_param_t *param, const char *msg) {
- if (param && param->type) {
- switch (param->type) {
- case STR_PARAM:
- fprintf(stderr, "%s STR_PARAM(%s=%d)\n", msg, param->str, param->len);
- break;
-
- case ADDR_PARAM:
- fprintf(stderr, "%s ADDR_PARAM(%lu)\n", msg, param->addr);
- break;
-
- case FILE_PARAM:
- fprintf(stderr, "%s FILE_PARAM(%s:%d)\n", msg, param->file.name, param->file.line);
- break;
-
- case METHOD_PARAM:
- fprintf(stderr, "%s METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
- break;
-
- case NUMERIC_METHOD_PARAM:
- fprintf(stderr, "%s NUMERIC_METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
- break;
-
- case NUMERIC_FUNCTION_PARAM:
- fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%s)\n", msg, param->str, param->num);
- break;
-
- case NUMERIC_PARAM:
- fprintf(stderr, "%s NUMERIC_PARAM(%ld)\n", msg, param->num);
- break;
-
- case COND_PARAM:
- fprintf(stderr, "%s COND_PARAM(%s=%d)\n", msg, param->str, param->len);
- break;
- }
- }
-}
-
-void phpdbg_stack_free(phpdbg_param_t *stack) {
- if (stack && stack->next) {
- phpdbg_param_t *remove = stack->next;
-
- while (remove) {
- phpdbg_param_t *next = NULL;
-
- if (remove->next)
- next = remove->next;
-
- switch (remove->type) {
- case STR_PARAM:
- if (remove->str) {
- free(remove->str);
- }
- break;
-
- case FILE_PARAM:
- if (remove->file.name) {
- free(remove->file.name);
- }
- break;
- }
-
- free(remove);
-
- if (next)
- remove = next;
- else break;
- }
- }
-}
-
-static void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param) {
- phpdbg_param_t *next = calloc(1, sizeof(phpdbg_param_t));
-
- if (!next)
- return;
-
- *(next) = *(param);
-
- if (stack->top == NULL) {
- stack->top = next;
- stack->next = next;
- } else {
- stack->top->next = next;
- next->top = stack->top;
- stack->top = next;
- }
-
- stack->len++;
-}
-
-phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, 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};
- 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) {
- matched[matches] = command;
- matches++;
- } else break;
- }
- }
- command++;
- }
-
- switch (matches) {
- case 0: {
- asprintf(
- why,
- "The command %s could not be found",
- name->str);
- } break;
-
- case 1: {
- (*top) = (*top)->next;
- if (matched[0]->subs && (*top) && ((*top)->type == STR_PARAM)) {
- command = phpdbg_stack_resolve(matched[0]->subs, top, why);
- if (command) {
- return command;
- }
- }
-
- return matched[0];
- } break;
-
- default: {
- asprintf(
- why,
- "The command %s is ambigious, matching %d commands",
- name->str, matches);
- }
- }
-
- return NULL;
-}
-
-int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
- phpdbg_param_t *command = NULL,
- *params = NULL;
- phpdbg_command_t *handler = NULL;
-
- if (stack->type != STACK_PARAM) {
- asprintf(
- why, "the passed argument was not a stack !!");
- return FAILURE;
- }
-
- if (!stack->len) {
- asprintf(
- why, "the stack contains nothing !!");
- return FAILURE;
- }
-
- command = (phpdbg_param_t*) stack->next;
-
- switch (command->type) {
- case EVAL_PARAM:
- return PHPDBG_COMMAND_HANDLER(eval)(command, NULL TSRMLS_CC);
-
- case SHELL_PARAM:
- return PHPDBG_COMMAND_HANDLER(shell)(command, NULL TSRMLS_CC);
-
- case STR_PARAM: {
- handler = phpdbg_stack_resolve(
- phpdbg_prompt_commands, &command, why);
-
- if (handler) {
- return handler->handler(command, NULL TSRMLS_CC);
- } else {
- return FAILURE;
- }
- } break;
-
- default:
- asprintf(
- why, "the first parameter makes no sense !!");
- return FAILURE;
- }
-
- return SUCCESS;
-}
-
%}
%code requires {
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
#include "phpdbg_set.h"
+#include "phpdbg_prompt.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
return 0;
} /* }}} */
+/* {{{ */
+PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg) {
+ if (param && param->type) {
+ switch (param->type) {
+ case STR_PARAM:
+ fprintf(stderr, "%s STR_PARAM(%s=%d)\n", msg, param->str, param->len);
+ break;
+
+ case ADDR_PARAM:
+ fprintf(stderr, "%s ADDR_PARAM(%lu)\n", msg, param->addr);
+ break;
+
+ case FILE_PARAM:
+ fprintf(stderr, "%s FILE_PARAM(%s:%d)\n", msg, param->file.name, param->file.line);
+ break;
+
+ case METHOD_PARAM:
+ fprintf(stderr, "%s METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
+ break;
+
+ case NUMERIC_METHOD_PARAM:
+ fprintf(stderr, "%s NUMERIC_METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
+ break;
+
+ case NUMERIC_FUNCTION_PARAM:
+ fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%s)\n", msg, param->str, param->num);
+ break;
+
+ case NUMERIC_PARAM:
+ fprintf(stderr, "%s NUMERIC_PARAM(%ld)\n", msg, param->num);
+ break;
+
+ case COND_PARAM:
+ fprintf(stderr, "%s COND_PARAM(%s=%d)\n", msg, param->str, param->len);
+ break;
+ }
+ }
+} /* }}} */
+
+/* {{{ */
+PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) {
+ if (stack && stack->next) {
+ phpdbg_param_t *remove = stack->next;
+
+ while (remove) {
+ phpdbg_param_t *next = NULL;
+
+ if (remove->next)
+ next = remove->next;
+
+ switch (remove->type) {
+ case STR_PARAM:
+ if (remove->str) {
+ free(remove->str);
+ }
+ break;
+
+ case FILE_PARAM:
+ if (remove->file.name) {
+ free(remove->file.name);
+ }
+ break;
+ }
+
+ free(remove);
+
+ if (next)
+ remove = next;
+ else break;
+ }
+ }
+} /* }}} */
+
+/* {{{ */
+PHPDBG_API void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param) {
+ phpdbg_param_t *next = calloc(1, sizeof(phpdbg_param_t));
+
+ if (!next)
+ return;
+
+ *(next) = *(param);
+
+ if (stack->top == NULL) {
+ stack->top = next;
+ stack->next = next;
+ } else {
+ stack->top->next = next;
+ next->top = stack->top;
+ stack->top = next;
+ }
+
+ stack->len++;
+} /* }}} */
+
+/* {{{ */
+PHPDBG_API phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, 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};
+ 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) {
+ matched[matches] = command;
+ matches++;
+ } else break;
+ }
+ }
+ command++;
+ }
+
+ switch (matches) {
+ case 0: {
+ asprintf(
+ why,
+ "The command %s could not be found",
+ name->str);
+ } break;
+
+ case 1: {
+ (*top) = (*top)->next;
+ if (matched[0]->subs && (*top) && ((*top)->type == STR_PARAM)) {
+ command = phpdbg_stack_resolve(matched[0]->subs, top, why);
+ if (command) {
+ return command;
+ }
+ }
+
+ return matched[0];
+ } break;
+
+ default: {
+ asprintf(
+ why,
+ "The command %s is ambigious, matching %d 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;
+
+ if (stack->type != STACK_PARAM) {
+ asprintf(
+ why, "the passed argument was not a stack !!");
+ return FAILURE;
+ }
+
+ if (!stack->len) {
+ asprintf(
+ why, "the stack contains nothing !!");
+ return FAILURE;
+ }
+
+ command = (phpdbg_param_t*) stack->next;
+
+ switch (command->type) {
+ case EVAL_PARAM:
+ return PHPDBG_COMMAND_HANDLER(eval)(command, NULL TSRMLS_CC);
+
+ case SHELL_PARAM:
+ return PHPDBG_COMMAND_HANDLER(shell)(command, NULL TSRMLS_CC);
+
+ case STR_PARAM: {
+ handler = phpdbg_stack_resolve(
+ phpdbg_prompt_commands, &command, why);
+
+ if (handler) {
+ return handler->handler(command, NULL TSRMLS_CC);
+ } else {
+ return FAILURE;
+ }
+ } break;
+
+ default:
+ asprintf(
+ why, "the first parameter makes no sense !!");
+ return FAILURE;
+ }
+
+ return SUCCESS;
+} /* }}} */
+
PHPDBG_API char* phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */
{
char *cmd = NULL;
#include "phpdbg.h"
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
+#include "phpdbg_cmd.h"
#include "phpdbg_prompt.h"
#define YYSTYPE phpdbg_param_t
int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) {
phpdbg_error("Parse Error: %s", msg);
+ {
+ const phpdbg_param_t *top = stack;
+ zend_ulong position = 0L;
+
+ while (top) {
+ phpdbg_param_debug(
+ top, "--> ");
+ top = top->next;
+ }
+ }
}
-void phpdbg_debug_param(const phpdbg_param_t *param, const char *msg) {
- if (param && param->type) {
- switch (param->type) {
- case STR_PARAM:
- fprintf(stderr, "%s STR_PARAM(%s=%d)\n", msg, param->str, param->len);
- break;
-
- case ADDR_PARAM:
- fprintf(stderr, "%s ADDR_PARAM(%lu)\n", msg, param->addr);
- break;
-
- case FILE_PARAM:
- fprintf(stderr, "%s FILE_PARAM(%s:%d)\n", msg, param->file.name, param->file.line);
- break;
-
- case METHOD_PARAM:
- fprintf(stderr, "%s METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
- break;
-
- case NUMERIC_METHOD_PARAM:
- fprintf(stderr, "%s NUMERIC_METHOD_PARAM(%s::%s)\n", msg, param->method.class, param->method.name);
- break;
-
- case NUMERIC_FUNCTION_PARAM:
- fprintf(stderr, "%s NUMERIC_FUNCTION_PARAM(%s::%s)\n", msg, param->str, param->num);
- break;
-
- case NUMERIC_PARAM:
- fprintf(stderr, "%s NUMERIC_PARAM(%ld)\n", msg, param->num);
- break;
-
- case COND_PARAM:
- fprintf(stderr, "%s COND_PARAM(%s=%d)\n", msg, param->str, param->len);
- break;
- }
- }
-}
-
-void phpdbg_stack_free(phpdbg_param_t *stack) {
- if (stack && stack->next) {
- phpdbg_param_t *remove = stack->next;
-
- while (remove) {
- phpdbg_param_t *next = NULL;
-
- if (remove->next)
- next = remove->next;
-
- switch (remove->type) {
- case STR_PARAM:
- if (remove->str) {
- free(remove->str);
- }
- break;
-
- case FILE_PARAM:
- if (remove->file.name) {
- free(remove->file.name);
- }
- break;
- }
-
- free(remove);
-
- if (next)
- remove = next;
- else break;
- }
- }
-}
-
-static void phpdbg_stack_push(phpdbg_param_t *stack, phpdbg_param_t *param) {
- phpdbg_param_t *next = calloc(1, sizeof(phpdbg_param_t));
-
- if (!next)
- return;
-
- *(next) = *(param);
-
- if (stack->top == NULL) {
- stack->top = next;
- stack->next = next;
- } else {
- stack->top->next = next;
- next->top = stack->top;
- stack->top = next;
- }
-
- stack->len++;
-}
-
-phpdbg_command_t* phpdbg_stack_resolve(const phpdbg_command_t *commands, 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};
- 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) {
- matched[matches] = command;
- matches++;
- } else break;
- }
- }
- command++;
- }
-
- switch (matches) {
- case 0: {
- asprintf(
- why,
- "The command %s could not be found",
- name->str);
- } break;
-
- case 1: {
- (*top) = (*top)->next;
- if (matched[0]->subs && (*top) && ((*top)->type == STR_PARAM)) {
- command = phpdbg_stack_resolve(matched[0]->subs, top, why);
- if (command) {
- return command;
- }
- }
-
- return matched[0];
- } break;
-
- default: {
- asprintf(
- why,
- "The command %s is ambigious, matching %d commands",
- name->str, matches);
- }
- }
-
- return NULL;
-}
-
-int phpdbg_stack_execute(phpdbg_param_t *stack, char **why) {
- phpdbg_param_t *command = NULL,
- *params = NULL;
- phpdbg_command_t *handler = NULL;
-
- if (stack->type != STACK_PARAM) {
- asprintf(
- why, "the passed argument was not a stack !!");
- return FAILURE;
- }
-
- if (!stack->len) {
- asprintf(
- why, "the stack contains nothing !!");
- return FAILURE;
- }
-
- command = (phpdbg_param_t*) stack->next;
-
- switch (command->type) {
- case EVAL_PARAM:
- return PHPDBG_COMMAND_HANDLER(eval)(command, NULL TSRMLS_CC);
-
- case SHELL_PARAM:
- return PHPDBG_COMMAND_HANDLER(shell)(command, NULL TSRMLS_CC);
-
- case STR_PARAM: {
- handler = phpdbg_stack_resolve(
- phpdbg_prompt_commands, &command, why);
-
- if (handler) {
- return handler->handler(command, NULL TSRMLS_CC);
- } else {
- return FAILURE;
- }
- } break;
-
- default:
- asprintf(
- why, "the first parameter makes no sense !!");
- return FAILURE;
- }
-
- return SUCCESS;
-}
-
-
/* Line 268 of yacc.c */
-#line 285 "sapi/phpdbg/phpdbg_parser.c"
+#line 109 "sapi/phpdbg/phpdbg_parser.c"
/* Enabling traces. */
#ifndef YYDEBUG
/* "%code requires" blocks. */
/* Line 288 of yacc.c */
-#line 215 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 39 "sapi/phpdbg/dev/phpdbg_parser.y"
#include "phpdbg.h"
#ifndef YY_TYPEDEF_YY_SCANNER_T
/* Line 288 of yacc.c */
-#line 319 "sapi/phpdbg/phpdbg_parser.c"
+#line 143 "sapi/phpdbg/phpdbg_parser.c"
/* Tokens. */
#ifndef YYTOKENTYPE
/* Line 343 of yacc.c */
-#line 360 "sapi/phpdbg/phpdbg_parser.c"
+#line 184 "sapi/phpdbg/phpdbg_parser.c"
#ifdef short
# undef short
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const yytype_uint16 yyrline[] =
+static const yytype_uint8 yyrline[] =
{
- 0, 251, 251, 255, 256, 260, 261, 265, 266, 270,
- 271, 275, 276, 280, 281, 282, 283, 284, 285, 286,
- 287, 288, 289, 290, 294
+ 0, 75, 75, 79, 80, 84, 85, 89, 90, 94,
+ 95, 99, 100, 104, 105, 106, 107, 108, 109, 110,
+ 111, 112, 113, 114, 118
};
#endif
case 3:
/* Line 1806 of yacc.c */
-#line 255 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 79 "sapi/phpdbg/dev/phpdbg_parser.y"
{ phpdbg_stack_push(stack, &(yyvsp[(1) - (1)])); }
break;
case 4:
/* Line 1806 of yacc.c */
-#line 256 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 80 "sapi/phpdbg/dev/phpdbg_parser.y"
{ phpdbg_stack_push(stack, &(yyvsp[(2) - (2)])); }
break;
case 7:
/* Line 1806 of yacc.c */
-#line 265 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 89 "sapi/phpdbg/dev/phpdbg_parser.y"
{ phpdbg_stack_push(stack, &(yyvsp[(1) - (1)])); }
break;
case 8:
/* Line 1806 of yacc.c */
-#line 266 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 90 "sapi/phpdbg/dev/phpdbg_parser.y"
{ phpdbg_stack_push(stack, &(yyvsp[(2) - (2)])); }
break;
case 9:
/* Line 1806 of yacc.c */
-#line 270 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 94 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(2) - (2)]); (yyval).type = EVAL_PARAM; }
break;
case 10:
/* Line 1806 of yacc.c */
-#line 271 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 95 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(2) - (2)]); (yyval).type = SHELL_PARAM; }
break;
case 12:
/* Line 1806 of yacc.c */
-#line 276 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 100 "sapi/phpdbg/dev/phpdbg_parser.y"
{ phpdbg_stack_push(stack, &(yyvsp[(1) - (1)])); }
break;
case 13:
/* Line 1806 of yacc.c */
-#line 280 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 104 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 14:
/* Line 1806 of yacc.c */
-#line 281 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 105 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 15:
/* Line 1806 of yacc.c */
-#line 282 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 106 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 16:
/* Line 1806 of yacc.c */
-#line 283 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 107 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 17:
/* Line 1806 of yacc.c */
-#line 284 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 108 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 18:
/* Line 1806 of yacc.c */
-#line 285 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 109 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 19:
/* Line 1806 of yacc.c */
-#line 286 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 110 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 20:
/* Line 1806 of yacc.c */
-#line 287 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 111 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 21:
/* Line 1806 of yacc.c */
-#line 288 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 112 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 22:
/* Line 1806 of yacc.c */
-#line 289 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 113 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 23:
/* Line 1806 of yacc.c */
-#line 290 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 114 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(2) - (2)]); (yyval).type = COND_PARAM; }
break;
/* Line 1806 of yacc.c */
-#line 1740 "sapi/phpdbg/phpdbg_parser.c"
+#line 1564 "sapi/phpdbg/phpdbg_parser.c"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
/* Line 2067 of yacc.c */
-#line 296 "sapi/phpdbg/dev/phpdbg_parser.y"
+#line 120 "sapi/phpdbg/dev/phpdbg_parser.y"