Skip to content

Commit

Permalink
HHVM Debuggers: hphp_debug_break should work in VS and hphpd
Browse files Browse the repository at this point in the history
Summary: Merging these functions so that the hard breakpoint works in whichever debugger happens to be attached.

Reviewed By: velocityboy

Differential Revision: D12944722

fbshipit-source-id: 6ca309dcd4136067f17b7019bc389029c17d9823
  • Loading branch information
ebluestein authored and hhvm-bot committed Nov 12, 2018
1 parent d080125 commit 2ff4427
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions hphp/runtime/ext/debugger/ext_debugger.cpp
Expand Up @@ -65,33 +65,40 @@ String HHVM_FUNCTION(hphp_debug_session_auth) {

void HHVM_FUNCTION(hphpd_break, bool condition /* = true */) {
TRACE(5, "in f_hphpd_break()\n");
if (!RuntimeOption::EnableHphpdDebugger || !condition ||
g_context->m_dbgNoBreak) {
TRACE(5, "bail !%d || !%d || %d\n", RuntimeOption::EnableHphpdDebugger,
condition, g_context->m_dbgNoBreak);
return;
}
VMRegAnchor _;
Debugger::InterruptVMHook(HardBreakPoint);
if (RuntimeOption::EvalJit && DEBUGGER_FORCE_INTR) {
TRACE(5, "switch mode\n");
throw VMSwitchModeBuiltin();
}
f_hphp_debug_break(condition);
TRACE(5, "out f_hphpd_break()\n");
}

// Hard breakpoint for the VSDebug extension debugger.
bool HHVM_FUNCTION(hphp_debug_break, bool condition /* = true */) {
if (!condition) {
TRACE(5, "in f_hphp_debug_break()\n");
if (!condition || g_context->m_dbgNoBreak) {
TRACE(5, "bail !%d || !%d || %d\n", RuntimeOption::EnableHphpdDebugger,
condition, g_context->m_dbgNoBreak);
return false;
}

// Try breaking into the VS Debug Extenstion, if available.
auto debugger = HPHP::VSDEBUG::VSDebugExtension::getDebugger();
if (debugger == nullptr) {
return false;
if (debugger != nullptr) {
if (debugger->onHardBreak()) {
return true;
}
}

// Try breaking into hphpd, if attached.
if (RuntimeOption::EnableHphpdDebugger) {
VMRegAnchor _;
Debugger::InterruptVMHook(HardBreakPoint);
if (RuntimeOption::EvalJit && DEBUGGER_FORCE_INTR) {
TRACE(5, "switch mode\n");
throw VMSwitchModeBuiltin();
}
return true;
}

return debugger->onHardBreak();
TRACE(5, "out f_hphp_debug_break()\n");
return false;
}

// Quickly determine if a debugger is attached to the current thread.
Expand Down

0 comments on commit 2ff4427

Please sign in to comment.