cb8d51fd2a
The debugger relies on hooks into the interpreter to gain control of threads. If a thread is looping in translated code, though, it will never enter the interpreter. Take advantage of the existing surprise checks emitted on back-branches to pop out of translated code back to the interpreter when trying to interrupt threads due to a Ctrl-C from the client. Also modified TestDebuggerJit to ensure that the thread executing the infinite loop has time to settle into looping in TC's. The signal to interrupt the server is historically fast enough to get there before one of the translations is made. Added a reasonable delay which caused the test to fail deterministically on my machine before the fix.
72 linhas
2.1 KiB
PHP
72 linhas
2.1 KiB
PHP
<?php
|
|
require_once("hphpd.php");
|
|
require_once("hphpd_test_inc.php");
|
|
|
|
error_log("In test ".$_SERVER['PHP_SELF']);
|
|
$client = get_client("web_request", "debugger_tests");
|
|
if (!$client) {
|
|
echo FAIL;
|
|
return;
|
|
}
|
|
|
|
function signal1($c) {
|
|
// Wait for an interrupt with in the request.
|
|
sendToHarness('2');
|
|
$o = $c->processCmd('continue', null);
|
|
VS($o['output_type'], 'code_loc');
|
|
VS(substr($o['file'],-17), 'web_request_t.php');
|
|
// The interrupt could stop the loop on either the 'sleep' or the
|
|
// 'while'. In practice it seems to always hit the 'while', but
|
|
// either is valid so be safe and allow both.
|
|
$line_no = $o['line_no'];
|
|
if (($line_no != 19) && ($line_no != 20)) {
|
|
throw new TestFailure($line_no, '19 or 20');
|
|
}
|
|
$o = $c->processCmd('print', array('$a'));
|
|
VS($o['values']['value'], 1);
|
|
// Break the endless loop in web_request_t.php.
|
|
$c->processCmd('@', array('$a=0'));
|
|
}
|
|
|
|
function signal2($c) {
|
|
// Stop on request and PSP end.
|
|
$c->processCmd('break', array('end', '/web_request_t.php'));
|
|
$c->processCmd('break', array('psp', '/web_request_t.php'));
|
|
$o = $c->processCmd('continue', null);
|
|
|
|
// Should be at request end.
|
|
// Try to print something bogus. Should be undefined.
|
|
VS(substr($o['text'], -7, 5), 'ended');
|
|
$o = $c->processCmd('print', array('$foo'));
|
|
VS(substr($o['text'], 23, 23), 'Undefined variable: foo');
|
|
$o = $c->processCmd('continue', null);
|
|
|
|
// Should be at psp end.
|
|
// Try to print something bogus. Should be undefined.
|
|
VS(substr($o['text'], -7, 5), 'ended');
|
|
$o = $c->processCmd('print', array('$foo'));
|
|
VS(substr($o['text'], 23, 23), 'Undefined variable: foo');
|
|
|
|
// Tell the test harness that we're done messing with the request, and to
|
|
// interrupt us one last time.
|
|
$c->processCmd('break', array('clear', 'all'));
|
|
sendToHarness('3');
|
|
|
|
// Wait for an interrupt after the request is done, controlled by test harness
|
|
$o = $c->processCmd('continue', null);
|
|
VS($o['output_type'], 'code_loc');
|
|
VS($o['file'], '');
|
|
}
|
|
|
|
try {
|
|
signal1($client);
|
|
signal2($client);
|
|
echo PASS;
|
|
} catch (TestFailure $t) {
|
|
error_log($t);
|
|
echo FAIL;
|
|
} catch (Exception $e) {
|
|
error_log($e);
|
|
echo FAIL;
|
|
}
|