Skip to content

Commit 0a788bf

Browse files
committed
Creating an enum for exception breakpoint kinds (catch, throw) instead of a bool.
1 parent e54b230 commit 0a788bf

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "DAP.h"
1010
#include "DAPLog.h"
1111
#include "EventHelper.h"
12+
#include "ExceptionBreakpoint.h"
1213
#include "Handler/RequestHandler.h"
1314
#include "Handler/ResponseHandler.h"
1415
#include "JSONUtils.h"
@@ -131,28 +132,28 @@ void DAP::PopulateExceptionBreakpoints() {
131132
if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
132133
exception_breakpoints.emplace_back(*this, "cpp_catch", "C++ Catch",
133134
lldb::eLanguageTypeC_plus_plus,
134-
/*is_throw=*/false, /*is_catch=*/true);
135+
eExceptionKindCatch);
135136
exception_breakpoints.emplace_back(*this, "cpp_throw", "C++ Throw",
136137
lldb::eLanguageTypeC_plus_plus,
137-
/*is_throw=*/true, /*is_catch=*/false);
138+
eExceptionKindThrow);
138139
}
139140

140141
if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeObjC)) {
141142
exception_breakpoints.emplace_back(*this, "objc_catch", "Objective-C Catch",
142143
lldb::eLanguageTypeObjC,
143-
/*is_throw=*/false, /*is_catch=*/true);
144+
eExceptionKindCatch);
144145
exception_breakpoints.emplace_back(*this, "objc_throw", "Objective-C Throw",
145146
lldb::eLanguageTypeObjC,
146-
/*is_throw=*/true, /*is_catch=*/false);
147+
eExceptionKindThrow);
147148
}
148149

149150
if (lldb::SBDebugger::SupportsLanguage(lldb::eLanguageTypeSwift)) {
150151
exception_breakpoints.emplace_back(*this, "swift_catch", "Swift Catch",
151152
lldb::eLanguageTypeSwift,
152-
/*is_throw=*/false, /*is_catch=*/true);
153+
eExceptionKindCatch);
153154
exception_breakpoints.emplace_back(*this, "swift_throw", "Swift Throw",
154155
lldb::eLanguageTypeSwift,
155-
/*is_throw=*/true, /*is_catch=*/false);
156+
eExceptionKindThrow);
156157
}
157158

158159
// Besides handling the hardcoded list of languages from above, we try to find
@@ -184,7 +185,7 @@ void DAP::PopulateExceptionBreakpoints() {
184185
exception_breakpoints.emplace_back(
185186
*this, raw_lang_name + "_" + throw_keyword,
186187
capitalized_lang_name + " " + capitalize(throw_keyword), lang,
187-
/*is_throw=*/true, /*is_catch=*/false);
188+
eExceptionKindThrow);
188189
}
189190

190191
if (lldb::SBLanguageRuntime::SupportsExceptionBreakpointsOnCatch(lang)) {
@@ -196,7 +197,7 @@ void DAP::PopulateExceptionBreakpoints() {
196197
exception_breakpoints.emplace_back(
197198
*this, raw_lang_name + "_" + catch_keyword,
198199
capitalized_lang_name + " " + capitalize(catch_keyword), lang,
199-
/*is_throw=*/true, /*is_catch=*/false);
200+
eExceptionKindCatch);
200201
}
201202
}
202203
}

lldb/tools/lldb-dap/ExceptionBreakpoint.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ protocol::Breakpoint ExceptionBreakpoint::SetBreakpoint(StringRef condition) {
2424
std::lock_guard<lldb::SBMutex> guard(lock);
2525

2626
if (!m_bp.IsValid()) {
27-
m_bp = m_dap.target.BreakpointCreateForException(m_language, m_is_catch,
28-
m_is_throw);
27+
m_bp = m_dap.target.BreakpointCreateForException(
28+
m_language, m_kind == eExceptionKindCatch,
29+
m_kind == eExceptionKindThrow);
2930
m_bp.AddName(BreakpointBase::kDAPBreakpointLabel);
3031
}
3132

lldb/tools/lldb-dap/ExceptionBreakpoint.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@
1919

2020
namespace lldb_dap {
2121

22+
enum ExceptionKind : unsigned {
23+
eExceptionKindCatch,
24+
eExceptionKindThrow,
25+
};
26+
2227
class ExceptionBreakpoint {
2328
public:
2429
ExceptionBreakpoint(DAP &d, std::string f, std::string l,
25-
lldb::LanguageType lang, bool is_throw, bool is_catch)
30+
lldb::LanguageType lang, ExceptionKind kind)
2631
: m_dap(d), m_filter(std::move(f)), m_label(std::move(l)),
27-
m_language(lang), m_is_throw(is_throw), m_is_catch(is_catch), m_bp() {}
32+
m_language(lang), m_kind(kind), m_bp() {}
2833

2934
protocol::Breakpoint SetBreakpoint() { return SetBreakpoint(""); };
3035
protocol::Breakpoint SetBreakpoint(llvm::StringRef condition);
@@ -41,8 +46,7 @@ class ExceptionBreakpoint {
4146
std::string m_filter;
4247
std::string m_label;
4348
lldb::LanguageType m_language;
44-
bool m_is_throw;
45-
bool m_is_catch;
49+
ExceptionKind m_kind;
4650
lldb::SBBreakpoint m_bp;
4751
};
4852

0 commit comments

Comments
 (0)