Don't go back to the interpreter after the end of pseudo main when debugging

Fix a long-standing bug where if you step off of the end of pseudo main we'd segfault in the interpreter loop. To get this we have to have a breakpoint in the final TC in pseudo main, and have that called from another TC, then Step or Next off the end. We'd end up with a PC of zero after the ret, which makes sense, but the logic after interpreting a block of code to stay in the interpreter when debugging was blind to this case.
Esse commit está contido em:
Mike Magruder
2013-07-12 15:04:40 -07:00
commit de Sara Golemon
commit f051e2fe04
5 arquivos alterados com 33 adições e 10 exclusões
+1
Ver Arquivo
@@ -687,6 +687,7 @@ private:
bool prepareArrayArgs(ActRec* ar, ArrayData* args);
void recordCodeCoverage(PC pc);
bool isReturnHelper(uintptr_t address);
void switchModeForDebugger();
int m_coverPrevLine;
HPHP::Unit* m_coverPrevUnit;
Array m_evaledArgs;
+11 -10
Ver Arquivo
@@ -7134,22 +7134,23 @@ void VMExecutionContext::dispatch() {
}
}
void VMExecutionContext::dispatchN(int numInstrs) {
dispatchImpl<LimitInstrs | BreakOnCtlFlow>(numInstrs);
// We are about to go back to Jit, check whether we should
// stick with interpreter
if (DEBUGGER_FORCE_INTR) {
// We are about to go back to translated code, check whether we should
// stick with the interpreter. NB: if we've just executed a return
// from pseudomain, then there's no PC and no more code to interpret.
void VMExecutionContext::switchModeForDebugger() {
if (DEBUGGER_FORCE_INTR && (getPC() != 0)) {
throw VMSwitchMode();
}
}
void VMExecutionContext::dispatchN(int numInstrs) {
dispatchImpl<LimitInstrs | BreakOnCtlFlow>(numInstrs);
switchModeForDebugger();
}
void VMExecutionContext::dispatchBB() {
dispatchImpl<BreakOnCtlFlow>(0);
// We are about to go back to Jit, check whether we should
// stick with interpreter
if (DEBUGGER_FORCE_INTR) {
throw VMSwitchMode();
}
switchModeForDebugger();
}
void VMExecutionContext::recordCodeCoverage(PC pc) {
@@ -0,0 +1,5 @@
<?php
// Copyright 2004-present Facebook. All Rights Reserved.
$x = 1;
echo $x;
@@ -0,0 +1,13 @@
Program %s/flow_pseudomain.php loaded. Type '[r]un' or '[c]ontinue' to go.
break 5
Breakpoint 1 set on line 5 of %s/flow_pseudomain.php
But wont break until file %s/flow_pseudomain.php has been loaded.
continue
Breakpoint 1 reached on line 5 of %s/flow_pseudomain.php
4 $x = 1;
5 echo $x;
6 (END)
step
1Program %s/flow_pseudomain.php exited normally.
quit
@@ -0,0 +1,3 @@
break 5
continue
step