-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add infinite loop detection * Optimize test.php * Optimize add_executed_opline_num * Add tests * Fix test * Set environment USE_ZEND_ALLOC=0
- Loading branch information
1 parent
67bc1d2
commit 45eaa7b
Showing
10 changed files
with
179 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tests/yasd_debugger/remote_mode/infinite_loop_detection/for_loop.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
// Suppose the business code calls a function to determine whether to end the loop, | ||
// but the business code always returns false | ||
function test() { | ||
return false; | ||
} | ||
|
||
$a = 0; | ||
while (true) { | ||
$a++; | ||
if (test() || $a > 100000) { | ||
break; | ||
} | ||
} | ||
?> |
32 changes: 32 additions & 0 deletions
32
tests/yasd_debugger/remote_mode/infinite_loop_detection/for_loop.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
infinite_loop_detection: for_loop | ||
--SKIPIF-- | ||
--FILE-- | ||
<?php | ||
|
||
use Yasd\DbgpClient; | ||
|
||
require dirname(__DIR__, 3) . '/Include/bootstrap.php'; | ||
|
||
$basename = basename(__FILE__, '.php'); | ||
$filename = realpath(dirname(__FILE__) . "/{$basename}.inc"); | ||
|
||
$commands = [ | ||
'run', | ||
'stop', | ||
]; | ||
|
||
$client = (new DbgpClient())->setCommands($commands)->setTestFile($filename)->start(); | ||
|
||
?> | ||
--EXPECTF-- | ||
<?xml version="1.0" encoding="iso-8859-1"?> | ||
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri=%s language="PHP" xdebug:language_version=%s protocol_version="1.0" appid=%s idekey=%s><engine version=%s><![CDATA[Yasd]]></engine><author><![CDATA[Codinghuang]]></author><url><![CDATA[https://github.com/swoole/yasd]]></url><copyright><![CDATA[Copyright (c) 2020-2021 by Codinghuang]]></copyright></init> | ||
|
||
-> run -i 1 | ||
<?xml version="1.0" encoding="iso-8859-1"?> | ||
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="1" status="break" reason="ok"><xdebug:message filename="file://%s" lineno="%d"/></response> | ||
|
||
-> stop -i 2 | ||
<?xml version="1.0" encoding="iso-8859-1"?> | ||
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="2" status="stopped" reason="ok"/> |
21 changes: 21 additions & 0 deletions
21
tests/yasd_debugger/remote_mode/infinite_loop_detection/goto_label_loop.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
// Suppose the business code calls a function to determine whether to end the loop, | ||
// but the business code always returns false | ||
function test() { | ||
return false; | ||
} | ||
|
||
$a = 0; | ||
|
||
LABEL: | ||
|
||
$a++; | ||
if (test() || $a > 100000) { | ||
goto END; | ||
} | ||
|
||
goto LABEL; | ||
|
||
END: | ||
?> |
32 changes: 32 additions & 0 deletions
32
tests/yasd_debugger/remote_mode/infinite_loop_detection/goto_label_loop.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
infinite_loop_detection: goto_label_loop | ||
--SKIPIF-- | ||
--FILE-- | ||
<?php | ||
|
||
use Yasd\DbgpClient; | ||
|
||
require dirname(__DIR__, 3) . '/Include/bootstrap.php'; | ||
|
||
$basename = basename(__FILE__, '.php'); | ||
$filename = realpath(dirname(__FILE__) . "/{$basename}.inc"); | ||
|
||
$commands = [ | ||
'run', | ||
'stop', | ||
]; | ||
|
||
$client = (new DbgpClient())->setCommands($commands)->setTestFile($filename)->start(); | ||
|
||
?> | ||
--EXPECTF-- | ||
<?xml version="1.0" encoding="iso-8859-1"?> | ||
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri=%s language="PHP" xdebug:language_version=%s protocol_version="1.0" appid=%s idekey=%s><engine version=%s><![CDATA[Yasd]]></engine><author><![CDATA[Codinghuang]]></author><url><![CDATA[https://github.com/swoole/yasd]]></url><copyright><![CDATA[Copyright (c) 2020-2021 by Codinghuang]]></copyright></init> | ||
|
||
-> run -i 1 | ||
<?xml version="1.0" encoding="iso-8859-1"?> | ||
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="1" status="break" reason="ok"><xdebug:message filename="file://%s" lineno="%d"/></response> | ||
|
||
-> stop -i 2 | ||
<?xml version="1.0" encoding="iso-8859-1"?> | ||
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="2" status="stopped" reason="ok"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters