From c1d638ade5fd0f102b3858ad0a1fe566fba201fd Mon Sep 17 00:00:00 2001 From: Eric Bluestein Date: Wed, 27 Dec 2017 22:17:54 -0800 Subject: [PATCH] Fix HHVM not hitting certain breakpoints Summary: HHVM is not hitting breakpoints put on lines with multiple opcodes if the first opcode of the line is not executed by the interpreter. This is because the PC of the first opcode in the line is added to the line breakpoints PC filter, but the subsequent opcodes are not. We'll therefore only hit the breakpoint if the PC lands on the first opcode in the line, and miss it if we jump elsewhere in the range. Reviewed By: rightparen Differential Revision: D6455132 fbshipit-source-id: ac520763fd5b90f0b6ad1a2d81957ec7a20c786a --- hphp/runtime/vm/debugger-hook.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/hphp/runtime/vm/debugger-hook.cpp b/hphp/runtime/vm/debugger-hook.cpp index a8257909621..63154f90627 100644 --- a/hphp/runtime/vm/debugger-hook.cpp +++ b/hphp/runtime/vm/debugger-hook.cpp @@ -186,7 +186,8 @@ void phpDebuggerOpcodeHook(const unsigned char* pc) { } // Check if we are hitting a line breakpoint. - if (UNLIKELY(req_data.m_lineBreakPointFilter.checkPC(pc))) { + if (UNLIKELY(active_line != line && + req_data.m_lineBreakPointFilter.checkPC(pc))) { req_data.setActiveLineBreak(line); hook->onLineBreak(unit, line); return; @@ -568,11 +569,29 @@ bool phpAddBreakPointLine(const Unit* unit, int line) { // Add to the breakpoint filter and the line filter. assertx(offsets.size() > 0); - auto bpOffset = offsets[0].base; - phpAddBreakPoint(unit, bpOffset); + bool containsEntryNop = false; + for (auto const offset : offsets) { + auto bpOffset = offset.base; + auto op = unit->getOp(bpOffset); + if (op == Op::EntryNop) { + containsEntryNop = true; + } + + if (containsEntryNop) { + phpAddBreakPoint(unit, offset.base); + } + } + + if (containsEntryNop) { + RID().m_lineBreakPointFilter.addRanges(unit, offsets); + } else { + auto bpOffset = offsets[0].base; + phpAddBreakPoint(unit, bpOffset); + + auto pc = unit->at(bpOffset); + RID().m_lineBreakPointFilter.addPC(pc); + } - auto pc = unit->at(bpOffset); - RID().m_lineBreakPointFilter.addPC(pc); return true; } -- 2.11.4.GIT