Skip to content

Commit baa13ed

Browse files
committed
Moving CreateExceptionBreakpointFilter into ProtocolUtils.h and removing empty fields.
1 parent 0a788bf commit baa13ed

File tree

7 files changed

+35
-34
lines changed

7 files changed

+35
-34
lines changed

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "Protocol/ProtocolBase.h"
1919
#include "Protocol/ProtocolRequests.h"
2020
#include "Protocol/ProtocolTypes.h"
21+
#include "ProtocolUtils.h"
2122
#include "Transport.h"
2223
#include "lldb/API/SBBreakpoint.h"
2324
#include "lldb/API/SBCommandInterpreter.h"

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -482,18 +482,6 @@ llvm::json::Object CreateEventObject(const llvm::StringRef event_name) {
482482
return event;
483483
}
484484

485-
protocol::ExceptionBreakpointsFilter
486-
CreateExceptionBreakpointFilter(const ExceptionBreakpoint &bp) {
487-
protocol::ExceptionBreakpointsFilter filter;
488-
filter.filter = bp.GetFilter();
489-
filter.label = bp.GetLabel();
490-
filter.description = bp.GetLabel();
491-
filter.defaultState = ExceptionBreakpoint::kDefaultValue;
492-
filter.supportsCondition = true;
493-
filter.conditionDescription = "";
494-
return filter;
495-
}
496-
497485
// "StackFrame": {
498486
// "type": "object",
499487
// "description": "A Stackframe contains the source location.",

lldb/tools/lldb-dap/JSONUtils.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,6 @@ llvm::json::Value CreateModule(lldb::SBTarget &target, lldb::SBModule &module,
224224
/// definition outlined by Microsoft.
225225
llvm::json::Object CreateEventObject(const llvm::StringRef event_name);
226226

227-
/// Create a "ExceptionBreakpointsFilter" JSON object as described in
228-
/// the debug adapter definition.
229-
///
230-
/// \param[in] bp
231-
/// The exception breakpoint object to use
232-
///
233-
/// \return
234-
/// A "ExceptionBreakpointsFilter" JSON object with that follows
235-
/// the formal JSON definition outlined by Microsoft.
236-
protocol::ExceptionBreakpointsFilter
237-
CreateExceptionBreakpointFilter(const ExceptionBreakpoint &bp);
238-
239227
/// Create a "StackFrame" object for a LLDB frame object.
240228
///
241229
/// This function will fill in the following keys in the returned

lldb/tools/lldb-dap/Protocol/ProtocolTypes.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ bool fromJSON(const llvm::json::Value &Params, ExceptionBreakpointsFilter &EBF,
8686
json::Value toJSON(const ExceptionBreakpointsFilter &EBF) {
8787
json::Object result{{"filter", EBF.filter}, {"label", EBF.label}};
8888

89-
if (EBF.description)
90-
result.insert({"description", *EBF.description});
89+
if (!EBF.description.empty())
90+
result.insert({"description", EBF.description});
9191
if (EBF.defaultState)
92-
result.insert({"default", *EBF.defaultState});
92+
result.insert({"default", EBF.defaultState});
9393
if (EBF.supportsCondition)
94-
result.insert({"supportsCondition", *EBF.supportsCondition});
95-
if (EBF.conditionDescription)
96-
result.insert({"conditionDescription", *EBF.conditionDescription});
94+
result.insert({"supportsCondition", EBF.supportsCondition});
95+
if (!EBF.conditionDescription.empty())
96+
result.insert({"conditionDescription", EBF.conditionDescription});
9797

9898
return result;
9999
}

lldb/tools/lldb-dap/Protocol/ProtocolTypes.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ struct ExceptionBreakpointsFilter {
4343

4444
/// A help text providing additional information about the exception filter.
4545
/// This string is typically shown as a hover and can be translated.
46-
std::optional<std::string> description;
46+
std::string description;
4747

4848
/// Initial value of the filter option. If not specified a value false is
4949
/// assumed.
50-
std::optional<bool> defaultState;
50+
bool defaultState = false;
5151

5252
/// Controls whether a condition can be specified for this filter option. If
5353
/// false or missing, a condition can not be set.
54-
std::optional<bool> supportsCondition;
54+
bool supportsCondition = false;
5555

5656
/// A help text providing information about the condition. This string is
5757
/// shown as the placeholder text for a text box and can be translated.
58-
std::optional<std::string> conditionDescription;
58+
std::string conditionDescription;
5959
};
6060
bool fromJSON(const llvm::json::Value &, ExceptionBreakpointsFilter &,
6161
llvm::json::Path);

lldb/tools/lldb-dap/ProtocolUtils.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,15 @@ std::vector<protocol::Thread> GetThreads(lldb::SBProcess process,
161161
return threads;
162162
}
163163

164+
protocol::ExceptionBreakpointsFilter
165+
CreateExceptionBreakpointFilter(const ExceptionBreakpoint &bp) {
166+
protocol::ExceptionBreakpointsFilter filter;
167+
filter.filter = bp.GetFilter();
168+
filter.label = bp.GetLabel();
169+
filter.description = bp.GetLabel();
170+
filter.defaultState = ExceptionBreakpoint::kDefaultValue;
171+
filter.supportsCondition = true;
172+
return filter;
173+
}
174+
164175
} // namespace lldb_dap

lldb/tools/lldb-dap/ProtocolUtils.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLDB_TOOLS_LLDB_DAP_PROTOCOL_PROTOCOL_UTILS_H
1414
#define LLDB_TOOLS_LLDB_DAP_PROTOCOL_PROTOCOL_UTILS_H
1515

16+
#include "ExceptionBreakpoint.h"
1617
#include "Protocol/ProtocolTypes.h"
1718

1819
#include "lldb/API/SBAddress.h"
@@ -74,6 +75,18 @@ protocol::Thread CreateThread(lldb::SBThread &thread, lldb::SBFormat &format);
7475
std::vector<protocol::Thread> GetThreads(lldb::SBProcess process,
7576
lldb::SBFormat &format);
7677

78+
/// Create a "ExceptionBreakpointsFilter" JSON object as described in
79+
/// the debug adapter definition.
80+
///
81+
/// \param[in] bp
82+
/// The exception breakpoint object to use
83+
///
84+
/// \return
85+
/// A "ExceptionBreakpointsFilter" JSON object with that follows
86+
/// the formal JSON definition outlined by Microsoft.
87+
protocol::ExceptionBreakpointsFilter
88+
CreateExceptionBreakpointFilter(const ExceptionBreakpoint &bp);
89+
7790
} // namespace lldb_dap
7891

7992
#endif

0 commit comments

Comments
 (0)