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 "DAP.h"
11#include "llvm/ADT/StringExtras.h"
12
13using namespace lldb_dap;
14
15BreakpointBase::BreakpointBase(const llvm::json::Object &obj)
16 : condition(std::string(GetString(obj, key: "condition"))),
17 hitCondition(std::string(GetString(obj, key: "hitCondition"))) {}
18
19void BreakpointBase::UpdateBreakpoint(const BreakpointBase &request_bp) {
20 if (condition != request_bp.condition) {
21 condition = request_bp.condition;
22 SetCondition();
23 }
24 if (hitCondition != request_bp.hitCondition) {
25 hitCondition = request_bp.hitCondition;
26 SetHitCondition();
27 }
28}
29
30const char *BreakpointBase::GetBreakpointLabel() {
31 // Breakpoints in LLDB can have names added to them which are kind of like
32 // labels or categories. All breakpoints that are set through the IDE UI get
33 // sent through the various DAP set*Breakpoint packets, and these
34 // breakpoints will be labeled with this name so if breakpoint update events
35 // come in for breakpoints that the IDE doesn't know about, like if a
36 // breakpoint is set manually using the debugger console, we won't report any
37 // updates on them and confused the IDE. This function gets called by all of
38 // the breakpoint classes after they set breakpoints to mark a breakpoint as
39 // a UI breakpoint. We can later check a lldb::SBBreakpoint object that comes
40 // in via LLDB breakpoint changed events and check the breakpoint by calling
41 // "bool lldb::SBBreakpoint::MatchesName(const char *)" to check if a
42 // breakpoint in one of the UI breakpoints that we should report changes for.
43 return "dap";
44}
45

source code of lldb/tools/lldb-dap/BreakpointBase.cpp