introduce proper support for file:#opline

This commit is contained in:
krakjoe 2014-02-21 18:01:50 +00:00
parent a6eee49326
commit c3a897bf3d
8 changed files with 124 additions and 96 deletions

View file

@ -86,6 +86,11 @@ parameter
$$.file.name = $1.str; $$.file.name = $1.str;
$$.file.line = $3.num; $$.file.line = $3.num;
} }
| T_ID T_COLON T_POUND T_DIGITS {
$$.type = NUMERIC_FILE_PARAM;
$$.file.name = $1.str;
$$.file.line = $4.num;
}
| T_ID T_DCOLON T_ID { | T_ID T_DCOLON T_ID {
$$.type = METHOD_PARAM; $$.type = METHOD_PARAM;
$$.method.class = $1.str; $$.method.class = $1.str;

View file

@ -35,19 +35,11 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
* Commands * Commands
*/ */
const phpdbg_command_t phpdbg_break_commands[] = { const phpdbg_command_t phpdbg_break_commands[] = {
PHPDBG_BREAK_COMMAND_D(address, "specify breakpoint by address", 'a', break_address, NULL, "f"),
PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", 'A', break_at, NULL, "*c"), PHPDBG_BREAK_COMMAND_D(at, "specify breakpoint by location and condition", 'A', break_at, NULL, "*c"),
PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", 'd', break_del, NULL, "n"), PHPDBG_BREAK_COMMAND_D(del, "delete breakpoint by identifier number", 'd', break_del, NULL, "n"),
PHPDBG_END_COMMAND PHPDBG_END_COMMAND
}; };
PHPDBG_BREAK(address) /* {{{ */
{
phpdbg_set_breakpoint_file_opline(param->file.name, param->file.line TSRMLS_CC);
return SUCCESS;
} /* }}} */
PHPDBG_BREAK(at) /* {{{ */ PHPDBG_BREAK(at) /* {{{ */
{ {
phpdbg_set_breakpoint_at(param TSRMLS_CC); phpdbg_set_breakpoint_at(param TSRMLS_CC);

View file

@ -29,7 +29,6 @@
/** /**
* Printer Forward Declarations * Printer Forward Declarations
*/ */
PHPDBG_BREAK(address);
PHPDBG_BREAK(at); PHPDBG_BREAK(at);
PHPDBG_BREAK(del); PHPDBG_BREAK(del);

View file

@ -418,6 +418,10 @@ PHPDBG_API void phpdbg_param_debug(const phpdbg_param_t *param, const char *msg)
fprintf(stderr, "%s ADDR_PARAM(%lu)\n", msg, param->addr); fprintf(stderr, "%s ADDR_PARAM(%lu)\n", msg, param->addr);
break; break;
case NUMERIC_FILE_PARAM:
fprintf(stderr, "%s NUMERIC_FILE_PARAM(%s:#%lu)\n", msg, param->file.name, param->file.line);
break;
case FILE_PARAM: case FILE_PARAM:
fprintf(stderr, "%s FILE_PARAM(%s:%lu)\n", msg, param->file.name, param->file.line); fprintf(stderr, "%s FILE_PARAM(%s:%lu)\n", msg, param->file.name, param->file.line);
break; break;
@ -465,16 +469,25 @@ PHPDBG_API void phpdbg_stack_free(phpdbg_param_t *stack) {
next = remove->next; next = remove->next;
switch (remove->type) { switch (remove->type) {
case STR_PARAM: case NUMERIC_METHOD_PARAM:
if (remove->str) { case METHOD_PARAM:
free(remove->str); if (remove->method.class)
} free(remove->method.class);
if (remove->method.name)
free(remove->method.name);
break; break;
case NUMERIC_FUNCTION_PARAM:
case STR_PARAM:
case OP_PARAM:
if (remove->str)
free(remove->str);
break;
case NUMERIC_FILE_PARAM:
case FILE_PARAM: case FILE_PARAM:
if (remove->file.name) { if (remove->file.name)
free(remove->file.name); free(remove->file.name);
}
break; break;
default: { default: {

View file

@ -34,6 +34,7 @@ typedef enum {
EMPTY_PARAM = 0, EMPTY_PARAM = 0,
ADDR_PARAM, ADDR_PARAM,
FILE_PARAM, FILE_PARAM,
NUMERIC_FILE_PARAM,
METHOD_PARAM, METHOD_PARAM,
STR_PARAM, STR_PARAM,
NUMERIC_PARAM, NUMERIC_PARAM,

View file

@ -540,9 +540,9 @@ phpdbg_help_text_t phpdbg_help_text[] = {
" $P b \\\\my\\\\class::method#2" CR " $P b \\\\my\\\\class::method#2" CR
" Break at the opline #2 of the method \\\\my\\\\class::method" CR CR " Break at the opline #2 of the method \\\\my\\\\class::method" CR CR
" $P break address test.php:3" CR " $P break test.php:#3" CR
" $P b a test.php:3" CR " $P b test.php:#3" CR
" Break at the 3rd opline in test.php" CR CR " Break at opline #3 in test.php" CR CR
" $P break if $cnt > 10" CR " $P break if $cnt > 10" CR
" $P b if $cnt > 10" CR " $P b if $cnt > 10" CR

View file

@ -399,16 +399,16 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */ /* YYFINAL -- State number of the termination state. */
#define YYFINAL 20 #define YYFINAL 20
/* YYLAST -- Last index in YYTABLE. */ /* YYLAST -- Last index in YYTABLE. */
#define YYLAST 23 #define YYLAST 25
/* YYNTOKENS -- Number of terminals. */ /* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 19 #define YYNTOKENS 19
/* YYNNTS -- Number of nonterminals. */ /* YYNNTS -- Number of nonterminals. */
#define YYNNTS 4 #define YYNNTS 4
/* YYNRULES -- Number of rules. */ /* YYNRULES -- Number of rules. */
#define YYNRULES 19 #define YYNRULES 20
/* YYNRULES -- Number of states. */ /* YYNRULES -- Number of states. */
#define YYNSTATES 27 #define YYNSTATES 29
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
#define YYUNDEFTOK 2 #define YYUNDEFTOK 2
@ -455,26 +455,28 @@ static const yytype_uint8 yytranslate[] =
YYRHS. */ YYRHS. */
static const yytype_uint8 yyprhs[] = static const yytype_uint8 yyprhs[] =
{ {
0, 0, 3, 5, 6, 8, 11, 15, 19, 25, 0, 0, 3, 5, 6, 8, 11, 15, 20, 24,
29, 32, 35, 38, 40, 42, 44, 46, 48, 50 30, 34, 37, 40, 43, 45, 47, 49, 51, 53,
55
}; };
/* YYRHS -- A `-1'-separated list of the rules' RHS. */ /* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const yytype_int8 yyrhs[] = static const yytype_int8 yyrhs[] =
{ {
20, 0, -1, 21, -1, -1, 22, -1, 21, 22, 20, 0, -1, 21, -1, -1, 22, -1, 21, 22,
-1, 16, 9, 12, -1, 16, 10, 16, -1, 16, -1, 16, 9, 12, -1, 16, 9, 11, 12, -1,
10, 16, 11, 12, -1, 16, 11, 12, -1, 5, 16, 10, 16, -1, 16, 10, 16, 11, 12, -1,
17, -1, 3, 17, -1, 4, 17, -1, 15, -1, 16, 11, 12, -1, 5, 17, -1, 3, 17, -1,
14, -1, 13, -1, 6, -1, 7, -1, 12, -1, 4, 17, -1, 15, -1, 14, -1, 13, -1, 6,
16, -1 -1, 7, -1, 12, -1, 16, -1
}; };
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] = static const yytype_uint8 yyrline[] =
{ {
0, 74, 74, 75, 79, 80, 84, 89, 94, 100, 0, 74, 74, 75, 79, 80, 84, 89, 94, 99,
106, 111, 116, 121, 122, 123, 124, 125, 126, 127 105, 111, 116, 121, 126, 127, 128, 129, 130, 131,
132
}; };
#endif #endif
@ -509,14 +511,16 @@ static const yytype_uint16 yytoknum[] =
static const yytype_uint8 yyr1[] = static const yytype_uint8 yyr1[] =
{ {
0, 19, 20, 20, 21, 21, 22, 22, 22, 22, 0, 19, 20, 20, 21, 21, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22
}; };
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] = static const yytype_uint8 yyr2[] =
{ {
0, 2, 1, 0, 1, 2, 3, 3, 5, 3, 0, 2, 1, 0, 1, 2, 3, 4, 3, 5,
2, 2, 2, 1, 1, 1, 1, 1, 1, 1 3, 2, 2, 2, 1, 1, 1, 1, 1, 1,
1
}; };
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
@ -524,9 +528,9 @@ static const yytype_uint8 yyr2[] =
means the default is an error. */ means the default is an error. */
static const yytype_uint8 yydefact[] = static const yytype_uint8 yydefact[] =
{ {
3, 0, 0, 0, 16, 17, 18, 15, 14, 13, 3, 0, 0, 0, 17, 18, 19, 16, 15, 14,
19, 0, 2, 4, 11, 12, 10, 0, 0, 0, 20, 0, 2, 4, 12, 13, 11, 0, 0, 0,
1, 5, 6, 7, 9, 0, 8 1, 5, 0, 6, 8, 10, 7, 0, 9
}; };
/* YYDEFGOTO[NTERM-NUM]. */ /* YYDEFGOTO[NTERM-NUM]. */
@ -540,15 +544,15 @@ static const yytype_int8 yydefgoto[] =
#define YYPACT_NINF -10 #define YYPACT_NINF -10
static const yytype_int8 yypact[] = static const yytype_int8 yypact[] =
{ {
-3, -9, -2, -1, -10, -10, -10, -10, -10, -10, -3, -9, -1, 0, -10, -10, -10, -10, -10, -10,
-4, 14, -3, -10, -10, -10, -10, 5, 2, 7, -4, 18, -3, -10, -10, -10, -10, 3, 4, 7,
-10, -10, -10, 9, -10, 10, -10 -10, -10, 9, -10, 11, -10, -10, 12, -10
}; };
/* YYPGOTO[NTERM-NUM]. */ /* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] = static const yytype_int8 yypgoto[] =
{ {
-10, -10, -10, 11 -10, -10, -10, 13
}; };
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -558,8 +562,8 @@ static const yytype_int8 yypgoto[] =
static const yytype_uint8 yytable[] = static const yytype_uint8 yytable[] =
{ {
1, 2, 3, 4, 5, 17, 18, 19, 14, 6, 1, 2, 3, 4, 5, 17, 18, 19, 14, 6,
7, 8, 9, 10, 20, 15, 16, 22, 23, 24, 7, 8, 9, 10, 22, 23, 15, 16, 20, 25,
25, 0, 26, 21 24, 26, 27, 0, 28, 21
}; };
#define yypact_value_is_default(yystate) \ #define yypact_value_is_default(yystate) \
@ -571,8 +575,8 @@ static const yytype_uint8 yytable[] =
static const yytype_int8 yycheck[] = static const yytype_int8 yycheck[] =
{ {
3, 4, 5, 6, 7, 9, 10, 11, 17, 12, 3, 4, 5, 6, 7, 9, 10, 11, 17, 12,
13, 14, 15, 16, 0, 17, 17, 12, 16, 12, 13, 14, 15, 16, 11, 12, 17, 17, 0, 12,
11, -1, 12, 12 16, 12, 11, -1, 12, 12
}; };
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@ -581,7 +585,7 @@ static const yytype_uint8 yystos[] =
{ {
0, 3, 4, 5, 6, 7, 12, 13, 14, 15, 0, 3, 4, 5, 6, 7, 12, 13, 14, 15,
16, 20, 21, 22, 17, 17, 17, 9, 10, 11, 16, 20, 21, 22, 17, 17, 17, 9, 10, 11,
0, 22, 12, 16, 12, 11, 12 0, 22, 11, 12, 16, 12, 12, 11, 12
}; };
#define yyerrok (yyerrstatus = 0) #define yyerrok (yyerrstatus = 0)
@ -1457,9 +1461,9 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 89 "sapi/phpdbg/dev/phpdbg_parser.y" #line 89 "sapi/phpdbg/dev/phpdbg_parser.y"
{ {
(yyval).type = METHOD_PARAM; (yyval).type = NUMERIC_FILE_PARAM;
(yyval).method.class = (yyvsp[(1) - (3)]).str; (yyval).file.name = (yyvsp[(1) - (4)]).str;
(yyval).method.name = (yyvsp[(3) - (3)]).str; (yyval).file.line = (yyvsp[(4) - (4)]).num;
} }
break; break;
@ -1467,6 +1471,17 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 94 "sapi/phpdbg/dev/phpdbg_parser.y" #line 94 "sapi/phpdbg/dev/phpdbg_parser.y"
{
(yyval).type = METHOD_PARAM;
(yyval).method.class = (yyvsp[(1) - (3)]).str;
(yyval).method.name = (yyvsp[(3) - (3)]).str;
}
break;
case 9:
/* Line 1806 of yacc.c */
#line 99 "sapi/phpdbg/dev/phpdbg_parser.y"
{ {
(yyval).type = NUMERIC_METHOD_PARAM; (yyval).type = NUMERIC_METHOD_PARAM;
(yyval).method.class = (yyvsp[(1) - (5)]).str; (yyval).method.class = (yyvsp[(1) - (5)]).str;
@ -1475,10 +1490,10 @@ yyreduce:
} }
break; break;
case 9: case 10:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 100 "sapi/phpdbg/dev/phpdbg_parser.y" #line 105 "sapi/phpdbg/dev/phpdbg_parser.y"
{ {
(yyval).type = NUMERIC_FUNCTION_PARAM; (yyval).type = NUMERIC_FUNCTION_PARAM;
(yyval).str = (yyvsp[(1) - (3)]).str; (yyval).str = (yyvsp[(1) - (3)]).str;
@ -1487,23 +1502,12 @@ yyreduce:
} }
break; break;
case 10:
/* Line 1806 of yacc.c */
#line 106 "sapi/phpdbg/dev/phpdbg_parser.y"
{
(yyval).type = COND_PARAM;
(yyval).str = (yyvsp[(2) - (2)]).str;
(yyval).len = (yyvsp[(2) - (2)]).len;
}
break;
case 11: case 11:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 111 "sapi/phpdbg/dev/phpdbg_parser.y" #line 111 "sapi/phpdbg/dev/phpdbg_parser.y"
{ {
(yyval).type = EVAL_PARAM; (yyval).type = COND_PARAM;
(yyval).str = (yyvsp[(2) - (2)]).str; (yyval).str = (yyvsp[(2) - (2)]).str;
(yyval).len = (yyvsp[(2) - (2)]).len; (yyval).len = (yyvsp[(2) - (2)]).len;
} }
@ -1514,7 +1518,7 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 116 "sapi/phpdbg/dev/phpdbg_parser.y" #line 116 "sapi/phpdbg/dev/phpdbg_parser.y"
{ {
(yyval).type = SHELL_PARAM; (yyval).type = EVAL_PARAM;
(yyval).str = (yyvsp[(2) - (2)]).str; (yyval).str = (yyvsp[(2) - (2)]).str;
(yyval).len = (yyvsp[(2) - (2)]).len; (yyval).len = (yyvsp[(2) - (2)]).len;
} }
@ -1524,55 +1528,66 @@ yyreduce:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 121 "sapi/phpdbg/dev/phpdbg_parser.y" #line 121 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); } {
(yyval).type = SHELL_PARAM;
(yyval).str = (yyvsp[(2) - (2)]).str;
(yyval).len = (yyvsp[(2) - (2)]).len;
}
break; break;
case 14: case 14:
/* Line 1806 of yacc.c */
#line 122 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 15:
/* Line 1806 of yacc.c */
#line 123 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 16:
/* Line 1806 of yacc.c */
#line 124 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 17:
/* Line 1806 of yacc.c */
#line 125 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 18:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 126 "sapi/phpdbg/dev/phpdbg_parser.y" #line 126 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); } { (yyval) = (yyvsp[(1) - (1)]); }
break; break;
case 19: case 15:
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 127 "sapi/phpdbg/dev/phpdbg_parser.y" #line 127 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); } { (yyval) = (yyvsp[(1) - (1)]); }
break; break;
case 16:
/* Line 1806 of yacc.c */
#line 128 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 17:
/* Line 1806 of yacc.c */
#line 129 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 18:
/* Line 1806 of yacc.c */
#line 130 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 19:
/* Line 1806 of yacc.c */
#line 131 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 20:
/* Line 1806 of yacc.c */
#line 132 "sapi/phpdbg/dev/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
/* Line 1806 of yacc.c */ /* Line 1806 of yacc.c */
#line 1576 "sapi/phpdbg/phpdbg_parser.c" #line 1591 "sapi/phpdbg/phpdbg_parser.c"
default: break; default: break;
} }
/* User semantic actions sometimes alter yychar, and that requires /* User semantic actions sometimes alter yychar, and that requires
@ -1803,6 +1818,6 @@ yyreturn:
/* Line 2067 of yacc.c */ /* Line 2067 of yacc.c */
#line 130 "sapi/phpdbg/dev/phpdbg_parser.y" #line 135 "sapi/phpdbg/dev/phpdbg_parser.y"

View file

@ -778,6 +778,9 @@ PHPDBG_COMMAND(break) /* {{{ */
case FILE_PARAM: case FILE_PARAM:
phpdbg_set_breakpoint_file(param->file.name, param->file.line TSRMLS_CC); phpdbg_set_breakpoint_file(param->file.name, param->file.line TSRMLS_CC);
break; break;
case NUMERIC_FILE_PARAM:
phpdbg_set_breakpoint_file_opline(param->file.name, param->file.line TSRMLS_CC);
break;
case COND_PARAM: case COND_PARAM:
phpdbg_set_breakpoint_expression(param->str, param->len TSRMLS_CC); phpdbg_set_breakpoint_expression(param->str, param->len TSRMLS_CC);
break; break;