Coverage Report

Created: 2022-01-15 10:30

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/tools/lldb-vscode/BreakpointBase.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- BreakpointBase.cpp --------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "BreakpointBase.h"
10
#include "llvm/ADT/StringExtras.h"
11
12
using namespace lldb_vscode;
13
14
BreakpointBase::BreakpointBase(const llvm::json::Object &obj)
15
    : condition(std::string(GetString(obj, "condition"))),
16
      hitCondition(std::string(GetString(obj, "hitCondition"))),
17
0
      logMessage(std::string(GetString(obj, "logMessage"))) {}
18
19
0
void BreakpointBase::SetCondition() { bp.SetCondition(condition.c_str()); }
20
21
0
void BreakpointBase::SetHitCondition() {
22
0
  uint64_t hitCount = 0;
23
0
  if (llvm::to_integer(hitCondition, hitCount))
24
0
    bp.SetIgnoreCount(hitCount - 1);
25
0
}
26
27
0
void BreakpointBase::UpdateBreakpoint(const BreakpointBase &request_bp) {
28
0
  if (condition != request_bp.condition) {
29
0
    condition = request_bp.condition;
30
0
    SetCondition();
31
0
  }
32
0
  if (hitCondition != request_bp.hitCondition) {
33
0
    hitCondition = request_bp.hitCondition;
34
0
    SetHitCondition();
35
0
  }
36
0
}
37
38
0
const char *BreakpointBase::GetBreakpointLabel() {
39
  // Breakpoints in LLDB can have names added to them which are kind of like
40
  // labels or categories. All breakpoints that are set through the IDE UI get
41
  // sent through the various VS code DAP set*Breakpoint packets, and these
42
  // breakpoints will be labeled with this name so if breakpoint update events
43
  // come in for breakpoints that the IDE doesn't know about, like if a
44
  // breakpoint is set manually using the debugger console, we won't report any
45
  // updates on them and confused the IDE. This function gets called by all of
46
  // the breakpoint classes after they set breakpoints to mark a breakpoint as
47
  // a UI breakpoint. We can later check a lldb::SBBreakpoint object that comes
48
  // in via LLDB breakpoint changed events and check the breakpoint by calling
49
  // "bool lldb::SBBreakpoint::MatchesName(const char *)" to check if a
50
  // breakpoint in one of the UI breakpoints that we should report changes for.
51
0
  return "vscode";
52
0
}