1 //===-- BreakpointBase.cpp --------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "BreakpointBase.h"
10 #include "JSONUtils.h"
11 #include "llvm/ADT/StringRef.h"
13 using namespace lldb_dap
;
15 BreakpointBase::BreakpointBase(DAP
&d
, const llvm::json::Object
&obj
)
16 : dap(d
), condition(std::string(GetString(obj
, "condition"))),
17 hitCondition(std::string(GetString(obj
, "hitCondition"))) {}
19 void BreakpointBase::UpdateBreakpoint(const BreakpointBase
&request_bp
) {
20 if (condition
!= request_bp
.condition
) {
21 condition
= request_bp
.condition
;
24 if (hitCondition
!= request_bp
.hitCondition
) {
25 hitCondition
= request_bp
.hitCondition
;
30 const 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.