[php-src] PHP-8.0: PHPDBG: fix bug parsing 3-word opcodes
| From: | David Rans via Nikita Popov | Date: | Thu, 22 Apr 2021 08:12:52 +0000 |
| Subject: | [php-src] PHP-8.0: PHPDBG: fix bug parsing 3-word opcodes | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-115746@lists.php.net to get a copy of this message | ||
Author: David Rans (davidrans)
Committer: Nikita Popov (nikic)
Date: 2021-04-22T10:11:26+02:00
Commit: https://github.com/php/php-src/commit/054fad6d634b0e6ace2638f44b02a0d23e821c36
Raw diff: https://github.com/php/php-src/commit/054fad6d634b0e6ace2638f44b02a0d23e821c36.diff
PHPDBG: fix bug parsing 3-word opcodes
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.
Changed paths:
A sapi/phpdbg/tests/breakpoints_009.phpt
M sapi/phpdbg/phpdbg_lexer.l
Diff:
diff --git a/sapi/phpdbg/phpdbg_lexer.l b/sapi/phpdbg/phpdbg_lexer.l
index 422cda4f2c076..eb159bdef1c7a 100644
--- a/sapi/phpdbg/phpdbg_lexer.l
+++ b/sapi/phpdbg/phpdbg_lexer.l
@@ -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;
diff --git a/sapi/phpdbg/tests/breakpoints_009.phpt b/sapi/phpdbg/tests/breakpoints_009.phpt
new file mode 100644
index 0000000000000..d81ad52e0ed9f
--- /dev/null
+++ b/sapi/phpdbg/tests/breakpoints_009.phpt
@@ -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++;