Skip to content

Commit fd0ce16

Browse files
committed
return exception breakpoints list
1 parent ccd4a46 commit fd0ce16

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

lldb/tools/lldb-dap/Handler/RequestHandler.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,16 @@ class SetBreakpointsRequestHandler
354354
};
355355

356356
class SetExceptionBreakpointsRequestHandler
357-
: public RequestHandler<protocol::SetExceptionBreakpointsArguments,
358-
protocol::SetExceptionBreakpointsResponseBody> {
357+
: public RequestHandler<
358+
protocol::SetExceptionBreakpointsArguments,
359+
llvm::Expected<protocol::SetExceptionBreakpointsResponseBody>> {
359360
public:
360361
using RequestHandler::RequestHandler;
361362
static llvm::StringLiteral GetCommand() { return "setExceptionBreakpoints"; }
362363
FeatureSet GetSupportedFeatures() const override {
363364
return {protocol::eAdapterFeatureExceptionOptions};
364365
}
365-
protocol::SetExceptionBreakpointsResponseBody
366+
llvm::Expected<protocol::SetExceptionBreakpointsResponseBody>
366367
Run(const protocol::SetExceptionBreakpointsArguments &args) const override;
367368
};
368369

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ namespace lldb_dap {
2121
/// from the debug adapter (with reason exception) if any of the configured
2222
/// filters match. Clients should only call this request if the corresponding
2323
/// capability exceptionBreakpointFilters returns one or more filters.
24-
llvm::Error SetExceptionBreakpointsRequestHandler::Run(
24+
llvm::Expected<protocol::SetExceptionBreakpointsResponseBody>
25+
SetExceptionBreakpointsRequestHandler::Run(
2526
const protocol::SetExceptionBreakpointsArguments &args) const {
27+
std::vector<protocol::Breakpoint> response_breakpoints;
2628
// Keep a list of any exception breakpoint filter names that weren't set
2729
// so we can clear any exception breakpoints if needed.
2830
std::set<llvm::StringRef> unset_filters;
@@ -32,18 +34,21 @@ llvm::Error SetExceptionBreakpointsRequestHandler::Run(
3234
for (const auto &value : args.filters) {
3335
const auto filter = GetAsString(value);
3436
auto *exc_bp = dap.GetExceptionBreakpoint(std::string(filter));
37+
protocol::Breakpoint response_bp;
3538
if (exc_bp) {
3639
exc_bp->SetBreakpoint();
3740
unset_filters.erase(std::string(filter));
41+
response_bp.verified = true;
3842
}
43+
response_breakpoints.push_back(response_bp);
3944
}
4045
for (const auto &filter : unset_filters) {
4146
auto *exc_bp = dap.GetExceptionBreakpoint(filter);
4247
if (exc_bp)
4348
exc_bp->ClearBreakpoint();
4449
}
4550

46-
return llvm::Error::success();
51+
return protocol::SetExceptionBreakpointsResponseBody{response_breakpoints};
4752
}
4853

4954
} // namespace lldb_dap

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,12 @@ bool fromJSON(const llvm::json::Value &Params,
335335
O.map("exceptionOptions", SEBA.exceptionOptions);
336336
}
337337

338+
llvm::json::Value toJSON(const SetExceptionBreakpointsResponseBody &SEBR) {
339+
json::Object result;
340+
result["breakpoints"] = SEBR.breakpoints;
341+
return result;
342+
}
343+
338344
bool fromJSON(const llvm::json::Value &Params,
339345
SetInstructionBreakpointsArguments &SIBA, llvm::json::Path P) {
340346
json::ObjectMapper O(Params, P);

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

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,31 @@ struct SetExceptionBreakpointsArguments {
448448
bool fromJSON(const llvm::json::Value &, SetExceptionBreakpointsArguments &,
449449
llvm::json::Path);
450450

451-
/// Response to `setExceptionBreakpoints` request can be empty, for backwards
452-
/// compatability with older client.
453-
using SetExceptionBreakpointsResponseBody = VoidResponse;
451+
/// Response to `setExceptionBreakpoints` request.
452+
/// The response contains an array of Breakpoint objects with information about
453+
/// each exception breakpoint or filter. The Breakpoint objects are in the same
454+
/// order as the elements of the filters, filterOptions, exceptionOptions arrays
455+
/// given as arguments. If both filters and filterOptions are given, the
456+
/// returned array must start with filters information first, followed by
457+
/// filterOptions information.
458+
/// The verified property of a Breakpoint object signals whether the exception
459+
/// breakpoint or filter could be successfully created and whether the condition
460+
/// is valid. In case of an error the message property explains the problem. The
461+
/// id property can be used to introduce a unique ID for the exception
462+
/// breakpoint or filter so that it can be updated subsequently by sending
463+
/// breakpoint events. For backward compatibility both the breakpoints array and
464+
/// the enclosing body are optional. If these elements are missing a client is
465+
/// not able to show problems for individual exception breakpoints or filters.
466+
struct SetExceptionBreakpointsResponseBody {
467+
/// Information about the exception breakpoints or filters.
468+
/// The breakpoints returned are in the same order as the elements of the
469+
/// `filters`, `filterOptions`, `exceptionOptions` arrays in the arguments.
470+
/// If both `filters` and `filterOptions` are given, the returned array must
471+
/// start with `filters` information first, followed by `filterOptions`
472+
/// information.
473+
std::vector<Breakpoint> breakpoints;
474+
};
475+
llvm::json::Value toJSON(const SetExceptionBreakpointsResponseBody &);
454476

455477
/// Arguments for `setInstructionBreakpoints` request.
456478
struct SetInstructionBreakpointsArguments {

0 commit comments

Comments
 (0)