// Removing a breakpoint with the given id.
void XDebugThreadBreakpoints::removeBreakpoint(int id) {
  // Try to grab the breakpoint
  auto bp_iter = BREAKPOINT_MAP.find(id);
  if (bp_iter == BREAKPOINT_MAP.end()) {
    return;
  }
  auto const& bp = bp_iter->second;

  // Remove the breakpoint from the unmatched set. This will return 0
  // if the breakpoint is not in the set and so the breakpoint is not unmatched
  if (UNMATCHED.erase(id) == 0) {
    switch (bp.type) {
      case BreakType::CALL:
        FUNC_ENTRY.erase(bp.funcId);
        phpRemoveBreakPointFuncEntry(Func::fromFuncId(bp.funcId));
        break;
      case BreakType::RETURN:
        FUNC_EXIT.erase(bp.funcId);
        phpRemoveBreakPointFuncExit(Func::fromFuncId(bp.funcId));
        break;
      case BreakType::EXCEPTION:
        EXCEPTION_MAP.erase(bp.exceptionName.toCppString());
        break;
      case BreakType::LINE: {
        auto filepath = bp.unit->filepath()->toCppString();
        auto& unit_map = LINE_MAP[filepath];

        // Need to ensure we don't delete breakpoints on the same line
        auto range = LINE_MAP[filepath].equal_range(bp.line);
        for (auto iter = range.first; iter != range.second; ++iter) {
          if (iter->second != id) {
            continue;
          }

          // If this is the only breakpoint on this line, unregister the line
          if (std::distance(range.first, range.second) == 1) {
            phpRemoveBreakPointLine(bp.unit, bp.line);
          }
          unit_map.erase(iter);
          break;
        }
        break;
      }
    }
  }

  // This deletes the breakpoint
  BREAKPOINT_MAP.erase(id);
}
bool XDebugThreadBreakpoints::updateBreakpointLine(int id, int newLine) {
  auto iter = BREAKPOINT_MAP.find(id);
  if (iter == BREAKPOINT_MAP.end()) {
    return false;
  }
  XDebugBreakpoint& bp = iter->second;

  // Determine if we need to unregister the line
  auto filepath = bp.unit->filepath()->toCppString();
  if (LINE_MAP[filepath].count(bp.line) == 1) {
    phpRemoveBreakPointLine(bp.unit, bp.line);
  }

  // Register the new line
  bp.line = newLine;
  LINE_MAP[filepath].insert(std::make_pair(bp.line, id));
  phpAddBreakPointLine(bp.unit, bp.line);
  return true;
}
Example #3
0
bool XDebugThreadBreakpoints::updateBreakpointLine(int id, int newLine) {
  auto iter = BREAKPOINT_MAP.find(id);
  if (iter == BREAKPOINT_MAP.end()) {
    return false;
  }
  auto& bp = iter->second;

  // Determine if we need to unregister the line.
  auto filepath = bp.unit->filepath()->toCppString();
  if (LINE_MAP[filepath].count(bp.line) == 1) {
    phpRemoveBreakPointLine(bp.unit, bp.line);
  }

  // Register the new line.
  bp.line = tightestLoc(bp.unit, newLine).line1;
  assertx(bp.line != -1);

  LINE_MAP[filepath].emplace(bp.line, id);
  phpAddBreakPointLine(bp.unit, bp.line);
  return true;
}