Skip to content

Commit

Permalink
PHPDBG: fix bug parsing 3-word opcodes
Browse files Browse the repository at this point in the history
PHPDBG won't parse opcodes correctly if they are more than two words
separated by underscores (as many opcodes, like ZEND_POST_INC, are).

Now opcodes that have more than one underscore (e.g. ZEND_POST_INC) are
parsed correctly.

Closes GH-6895.
  • Loading branch information
davidrans authored and nikic committed Apr 22, 2021
1 parent 1fcea24 commit 054fad6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sapi/phpdbg/phpdbg_lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ DIGITS [-]?[0-9\.]+
ID [^ \r\n\t:#\000]+
GENERIC_ID ([^ \r\n\t:#\000"']|":\\")+|["]([^\n\000"\\]|"\\\\"|"\\"["])+["]|[']([^\n\000'\\]|"\\\\"|"\\"['])+[']
ADDR [0][x][a-fA-F0-9]+
OPCODE (ZEND_|zend_)([A-Za-z])+
OPCODE (ZEND_|zend_)([A-Z_a-z])+
INPUT ("\\"[#"']|["]("\\\\"|"\\"["]|[^\n\000"])+["]|[']("\\"[']|"\\\\"|[^\n\000'])+[']|[^\n\000#"'])+
<!*> := yyleng = (size_t) YYCURSOR - (size_t) yytext;
Expand Down
41 changes: 41 additions & 0 deletions sapi/phpdbg/tests/breakpoints_009.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
--TEST--
Test parsing longer opcode
--PHPDBG--
b ZEND_POST_INC
r
c



q
--EXPECTF--
[Successful compilation of %s]
prompt> [Breakpoint #0 added at ZEND_POST_INC]
prompt> [Breakpoint #0 in ZEND_POST_INC at %s:3, hits: 1]
>00003: echo $i++;
00004: echo $i++;
00005: echo $i++;
prompt> 1
[Breakpoint #0 in ZEND_POST_INC at %s:4, hits: 2]
>00004: echo $i++;
00005: echo $i++;
00006: echo $i++;
prompt> 2
[Breakpoint #0 in ZEND_POST_INC at %s:5, hits: 3]
>00005: echo $i++;
00006: echo $i++;
00007:
prompt> 3
[Breakpoint #0 in ZEND_POST_INC at %s:6, hits: 4]
>00006: echo $i++;
00007:
prompt> 4
[Script ended normally]
prompt>
--FILE--
<?php
$i = 1;
echo $i++;
echo $i++;
echo $i++;
echo $i++;

0 comments on commit 054fad6

Please sign in to comment.