Browse Source

Merge sapi/phpdbg into PHP-5.6

pull/705/head
Bob Weinand 12 years ago
parent
commit
1dd3bab1df
  1. 7
      sapi/phpdbg/phpdbg_help.c
  2. 1005
      sapi/phpdbg/phpdbg_lexer.c
  3. 38
      sapi/phpdbg/phpdbg_lexer.l
  4. 23
      sapi/phpdbg/phpdbg_list.c
  5. 80
      sapi/phpdbg/phpdbg_parser.c
  6. 12
      sapi/phpdbg/phpdbg_parser.y

7
sapi/phpdbg/phpdbg_help.c

@ -318,8 +318,9 @@ phpdbg_help_text_t phpdbg_help_text[] = {
"**Information**" CR
" **list** list PHP source" CR
" **info** displays information on the debug session" CR
" **print** show opcodes " CR
" **print** show opcodes" CR
" **frame** select a stack frame and print a stack frame summary" CR
" **back** shows the current backtrace" CR
" **help** provide help on a topic" CR CR
"**Starting and Stopping Execution**" CR
@ -613,7 +614,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
{"finish",
"The **finish** command causes control to be passed back to the vm, continuing execution. Any "
"breakpoints that are encountered within the current stack frame will be skipped. Execution "
"will then continue until the next breakpoint after leaving the stack frame or unitil "
"will then continue until the next breakpoint after leaving the stack frame or until "
"completion of the script" CR CR
"Note when **step**ping is enabled, any opcode steps within the current stack frame are also "
@ -629,7 +630,7 @@ phpdbg_help_text_t phpdbg_help_text[] = {
"**Examples**" CR CR
" $P frame 2" CR
" $P E $count" CR
" $P ev $count" CR
" Go to frame 2 and print out variable **$count** in that frame" CR CR
"Note that this frame scope is discarded when execution continues, with the execution frame "

1005
sapi/phpdbg/phpdbg_lexer.c
File diff suppressed because it is too large
View File

38
sapi/phpdbg/phpdbg_lexer.l

@ -43,21 +43,21 @@ restart:
/*!re2c
re2c:yyfill:check = 0;
T_TRUE "true"
T_YES "yes"
T_ON "on"
T_ENABLED "enabled"
T_FALSE "false"
T_NO "no"
T_OFF "off"
T_DISABLED "disabled"
T_EVAL "ev"
T_SHELL "sh"
T_IF "if"
T_RUN "run"
T_TRUE 'true'
T_YES 'yes'
T_ON 'on'
T_ENABLED 'enabled'
T_FALSE 'false'
T_NO 'no'
T_OFF 'off'
T_DISABLED 'disabled'
T_EVAL 'ev'
T_SHELL 'sh'
T_IF 'if'
T_RUN 'run'
T_RUN_SHORT "r"
WS [ \r\n\t]+
DIGITS [0-9\.]+
DIGITS [-]?[0-9\.]+
ID [^ \r\n\t:#\000]+
ADDR [0][x][a-fA-F0-9]+
OPCODE (ZEND_|zend_)([A-Za-z])+
@ -69,7 +69,7 @@ INPUT [^\n\000]+
return 0;
}
<NORMAL>{T_IF} {
<NORMAL>{T_IF}{WS} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_IF;
@ -91,13 +91,13 @@ INPUT [^\n\000]+
return T_COLON;
}
<NORMAL>{T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} {
<NORMAL>({T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE}){WS} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = 1;
return T_TRUTHY;
}
<NORMAL>{T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} {
<NORMAL>({T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE}){WS} {
phpdbg_init_param(yylval, NUMERIC_PARAM);
yylval->num = 0;
return T_FALSY;
@ -142,17 +142,17 @@ INPUT [^\n\000]+
goto restart;
}
<INITIAL>{T_EVAL} {
<INITIAL>{T_EVAL}{WS} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_EVAL;
}
<INITIAL>{T_SHELL} {
<INITIAL>{T_SHELL}{WS} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_SHELL;
}
<INITIAL>{T_RUN}|{T_RUN_SHORT} {
<INITIAL>({T_RUN}|{T_RUN_SHORT}){WS} {
YYSETCONDITION(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
return T_RUN;

23
sapi/phpdbg/phpdbg_list.c

@ -130,14 +130,14 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
char *opened = NULL;
char buffer[8096] = {0,};
long line = 0;
php_stream *stream = NULL;
if (VCWD_STAT(filename, &st) == FAILURE) {
phpdbg_error("Failed to stat file %s", filename);
return;
}
stream = php_stream_open_wrapper(filename, "rb", USE_PATH, &opened);
if (!stream) {
@ -145,11 +145,17 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
return;
}
if (offset < 0) {
count += offset;
offset = 0;
}
while (php_stream_gets(stream, buffer, sizeof(buffer)) != NULL) {
long linelen = strlen(buffer);
++line;
if (!offset || offset <= line) {
/* Without offset, or offset reached */
if (offset <= line) {
if (!highlight) {
phpdbg_write("%05ld: %s", line, buffer);
} else {
@ -159,10 +165,15 @@ void phpdbg_list_file(const char *filename, long count, long offset, int highlig
phpdbg_write(">%05ld: %s", line, buffer);
}
}
if (buffer[linelen - 1] != '\n') {
phpdbg_write("\n");
}
}
if ((count + (offset-1)) == line)
if (count > 0 && count + offset - 1 < line) {
break;
}
}
php_stream_close(stream);

80
sapi/phpdbg/phpdbg_parser.c

@ -436,7 +436,7 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 25
/* YYLAST -- Last index in YYTABLE. */
#define YYLAST 41
#define YYLAST 42
/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS 21
@ -493,8 +493,8 @@ static const yytype_uint8 yytranslate[] =
static const yytype_uint8 yyprhs[] =
{
0, 0, 3, 5, 7, 8, 10, 13, 17, 22,
27, 33, 37, 43, 47, 49, 51, 53, 55, 57,
59, 61, 64, 67, 70, 72
27, 33, 37, 43, 47, 50, 52, 54, 56, 58,
60, 62, 64, 67, 70, 72
};
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
@ -504,9 +504,9 @@ static const yytype_int8 yyrhs[] =
23, 24, -1, 18, 10, 14, -1, 18, 10, 12,
14, -1, 13, 18, 10, 14, -1, 13, 18, 10,
12, 14, -1, 18, 11, 18, -1, 18, 11, 18,
12, 14, -1, 18, 12, 14, -1, 17, -1, 16,
-1, 15, -1, 7, -1, 8, -1, 14, -1, 18,
-1, 6, 19, -1, 3, 19, -1, 5, 19, -1,
12, 14, -1, 18, 12, 14, -1, 6, 19, -1,
17, -1, 16, -1, 15, -1, 7, -1, 8, -1,
14, -1, 18, -1, 3, 19, -1, 5, 19, -1,
4, -1, 4, 19, -1
};
@ -514,8 +514,8 @@ static const yytype_int8 yyrhs[] =
static const yytype_uint8 yyrline[] =
{
0, 66, 66, 67, 68, 72, 73, 77, 82, 87,
97, 107, 112, 118, 124, 125, 126, 127, 128, 129,
130, 134, 139, 144, 149, 153
97, 107, 112, 118, 124, 129, 130, 131, 132, 133,
134, 135, 139, 144, 149, 153
};
#endif
@ -552,15 +552,15 @@ static const yytype_uint8 yyr1[] =
{
0, 21, 22, 22, 22, 23, 23, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 25, 25, 25, 25, 25
24, 24, 25, 25, 25, 25
};
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const yytype_uint8 yyr2[] =
{
0, 2, 1, 1, 0, 1, 2, 3, 4, 4,
5, 3, 5, 3, 1, 1, 1, 1, 1, 1,
1, 2, 2, 2, 1, 2
5, 3, 5, 3, 2, 1, 1, 1, 1, 1,
1, 1, 2, 2, 1, 2
};
/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
@ -568,9 +568,9 @@ static const yytype_uint8 yyr2[] =
means the default is an error. */
static const yytype_uint8 yydefact[] =
{
4, 0, 24, 0, 0, 17, 18, 0, 19, 16,
15, 14, 20, 0, 2, 5, 3, 22, 25, 23,
21, 0, 0, 0, 0, 1, 6, 0, 0, 7,
4, 0, 24, 0, 0, 18, 19, 0, 20, 17,
16, 15, 21, 0, 2, 5, 3, 22, 25, 23,
14, 0, 0, 0, 0, 1, 6, 0, 0, 7,
11, 13, 0, 9, 8, 0, 10, 12
};
@ -585,16 +585,16 @@ static const yytype_int8 yydefgoto[] =
#define YYPACT_NINF -11
static const yytype_int8 yypact[] =
{
-3, -10, 10, 11, 12, -11, -11, 14, -11, -11,
-11, -11, -4, 28, 9, -11, -11, -11, -11, -11,
-11, 23, 6, 16, 21, -11, -11, 7, 22, -11,
25, -11, 24, -11, -11, 26, -11, -11
-3, -10, 11, 12, 13, -11, -11, 15, -11, -11,
-11, -11, -4, 29, 10, -11, -11, -11, -11, -11,
-11, 24, 7, 17, 22, -11, -11, 8, 23, -11,
26, -11, 25, -11, -11, 27, -11, -11
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int8 yypgoto[] =
{
-11, -11, -11, 27, -11
-11, -11, -11, 28, -11
};
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
@ -604,10 +604,10 @@ static const yytype_int8 yypgoto[] =
static const yytype_uint8 yytable[] =
{
1, 2, 3, 4, 5, 6, 22, 23, 24, 17,
7, 8, 9, 10, 11, 12, 5, 6, 28, 32,
29, 33, 7, 8, 9, 10, 11, 12, 25, 18,
19, 20, 21, 27, 30, 31, 34, 35, 36, 0,
37, 26
7, 8, 9, 10, 11, 12, 4, 5, 6, 28,
32, 29, 33, 7, 8, 9, 10, 11, 12, 25,
18, 19, 20, 21, 27, 30, 31, 34, 35, 36,
0, 37, 26
};
#define yypact_value_is_default(yystate) \
@ -619,10 +619,10 @@ static const yytype_uint8 yytable[] =
static const yytype_int8 yycheck[] =
{
3, 4, 5, 6, 7, 8, 10, 11, 12, 19,
13, 14, 15, 16, 17, 18, 7, 8, 12, 12,
14, 14, 13, 14, 15, 16, 17, 18, 0, 19,
19, 19, 18, 10, 18, 14, 14, 12, 14, -1,
14, 14
13, 14, 15, 16, 17, 18, 6, 7, 8, 12,
12, 14, 14, 13, 14, 15, 16, 17, 18, 0,
19, 19, 19, 18, 10, 18, 14, 14, 12, 14,
-1, 14, 14
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@ -1563,53 +1563,53 @@ yyreduce:
case 14:
/* Line 1802 of yacc.c */
#line 124 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
{
(yyval).type = COND_PARAM;
(yyval).str = (yyvsp[(2) - (2)]).str;
(yyval).len = (yyvsp[(2) - (2)]).len;
}
break;
case 15:
/* Line 1802 of yacc.c */
#line 125 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
#line 129 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 16:
/* Line 1802 of yacc.c */
#line 126 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
#line 130 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 17:
/* Line 1802 of yacc.c */
#line 127 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
#line 131 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 18:
/* Line 1802 of yacc.c */
#line 128 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
#line 132 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 19:
/* Line 1802 of yacc.c */
#line 129 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
#line 133 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 20:
/* Line 1802 of yacc.c */
#line 130 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
#line 134 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 21:
/* Line 1802 of yacc.c */
#line 134 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{
(yyval).type = COND_PARAM;
(yyval).str = (yyvsp[(2) - (2)]).str;
(yyval).len = (yyvsp[(2) - (2)]).len;
}
#line 135 "/var/root/php-src/sapi/phpdbg/phpdbg_parser.y"
{ (yyval) = (yyvsp[(1) - (1)]); }
break;
case 22:

12
sapi/phpdbg/phpdbg_parser.y

@ -121,6 +121,11 @@ parameter
$$.len = $1.len;
$$.num = $3.num;
}
| T_IF T_INPUT {
$$.type = COND_PARAM;
$$.str = $2.str;
$$.len = $2.len;
}
| T_OPCODE { $$ = $1; }
| T_ADDR { $$ = $1; }
| T_LITERAL { $$ = $1; }
@ -131,12 +136,7 @@ parameter
;
full_expression
: T_IF T_INPUT {
$$.type = COND_PARAM;
$$.str = $2.str;
$$.len = $2.len;
}
| T_EVAL T_INPUT {
: T_EVAL T_INPUT {
$$.type = EVAL_PARAM;
$$.str = $2.str;
$$.len = $2.len;

Loading…
Cancel
Save