Skip to content

Commit 0bdc9e6

Browse files
authored
[lldb-dap] Replace GetBreakpointLabel with kDAPBreakpointLabel constant (NFC) (#133746)
Replace GetBreakpointLabel with kDAPBreakpointLabel constant to avoid an unnecessary function call.
1 parent 76e7bdd commit 0bdc9e6

File tree

5 files changed

+21
-27
lines changed

5 files changed

+21
-27
lines changed

lldb/tools/lldb-dap/Breakpoint.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ void Breakpoint::CreateJsonObject(llvm::json::Object &object) {
7272
bool Breakpoint::MatchesName(const char *name) { return bp.MatchesName(name); }
7373

7474
void Breakpoint::SetBreakpoint() {
75-
// See comments in BreakpointBase::GetBreakpointLabel() for details of why
76-
// we add a label to our breakpoints.
77-
bp.AddName(GetBreakpointLabel());
75+
bp.AddName(kDAPBreakpointLabel);
7876
if (!condition.empty())
7977
SetCondition();
8078
if (!hitCondition.empty())

lldb/tools/lldb-dap/BreakpointBase.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,3 @@ void BreakpointBase::UpdateBreakpoint(const BreakpointBase &request_bp) {
2626
SetHitCondition();
2727
}
2828
}
29-
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.
43-
return "dap";
44-
}

lldb/tools/lldb-dap/BreakpointBase.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H
1111

1212
#include "DAPForward.h"
13+
#include "llvm/ADT/StringRef.h"
1314
#include <string>
1415

1516
namespace lldb_dap {
@@ -34,7 +35,20 @@ struct BreakpointBase {
3435

3536
void UpdateBreakpoint(const BreakpointBase &request_bp);
3637

37-
static const char *GetBreakpointLabel();
38+
/// Breakpoints in LLDB can have names added to them which are kind of like
39+
/// labels or categories. All breakpoints that are set through DAP get sent
40+
/// through the various DAP set*Breakpoint packets, and these breakpoints will
41+
/// be labeled with this name so if breakpoint update events come in for
42+
/// breakpoints that the client doesn't know about, like if a breakpoint is
43+
/// set manually using the debugger console, we won't report any updates on
44+
/// them and confused the client. This label gets added by all of the
45+
/// breakpoint classes after they set breakpoints to mark a breakpoint as a
46+
/// DAP breakpoint. We can later check a lldb::SBBreakpoint object that comes
47+
/// in via LLDB breakpoint changed events and check the breakpoint by calling
48+
/// "bool lldb::SBBreakpoint::MatchesName(const char *)" to check if a
49+
/// breakpoint in one of the DAP breakpoints that we should report changes
50+
/// for.
51+
static constexpr const char *kDAPBreakpointLabel = "dap";
3852
};
3953

4054
} // namespace lldb_dap

lldb/tools/lldb-dap/ExceptionBreakpoint.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ void ExceptionBreakpoint::SetBreakpoint() {
2020
bool throw_value = filter.find("_throw") != std::string::npos;
2121
bp = dap.target.BreakpointCreateForException(language, catch_value,
2222
throw_value);
23-
// See comments in BreakpointBase::GetBreakpointLabel() for details of why
24-
// we add a label to our breakpoints.
25-
bp.AddName(BreakpointBase::GetBreakpointLabel());
23+
bp.AddName(BreakpointBase::kDAPBreakpointLabel);
2624
}
2725

2826
void ExceptionBreakpoint::ClearBreakpoint() {

lldb/tools/lldb-dap/Handler/InitializeRequestHandler.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ static void EventThreadFunction(DAP &dap) {
197197
auto bp = Breakpoint(
198198
dap, lldb::SBBreakpoint::GetBreakpointFromEvent(event));
199199
// If the breakpoint was set through DAP, it will have the
200-
// BreakpointBase::GetBreakpointLabel() label. Regardless
201-
// of whether locations were added, removed, or resolved, the
202-
// breakpoint isn't going away and the reason is always "changed".
200+
// BreakpointBase::kDAPBreakpointLabel. Regardless of whether
201+
// locations were added, removed, or resolved, the breakpoint isn't
202+
// going away and the reason is always "changed".
203203
if ((event_type & lldb::eBreakpointEventTypeLocationsAdded ||
204204
event_type & lldb::eBreakpointEventTypeLocationsRemoved ||
205205
event_type & lldb::eBreakpointEventTypeLocationsResolved) &&
206-
bp.MatchesName(BreakpointBase::GetBreakpointLabel())) {
206+
bp.MatchesName(BreakpointBase::kDAPBreakpointLabel)) {
207207
// As the DAP client already knows the path of this breakpoint, we
208208
// don't need to send it back as part of the "changed" event. This
209209
// avoids sending paths that should be source mapped. Note that

0 commit comments

Comments
 (0)