|
14 | 14 |
|
15 | 15 | namespace lldb_dap { |
16 | 16 |
|
17 | | -/// The request configures the debugger’s response to thrown exceptions. Each of |
18 | | -/// the `filters`, `filterOptions`, and `exceptionOptions` in the request are |
19 | | -/// independent configurations to a debug adapter indicating a kind of exception |
20 | | -/// to catch. An exception thrown in a program should result in a stopped event |
21 | | -/// from the debug adapter (with reason exception) if any of the configured |
22 | | -/// filters match. Clients should only call this request if the corresponding |
23 | | -/// capability exceptionBreakpointFilters returns one or more filters. |
24 | | -llvm::Expected<protocol::SetExceptionBreakpointsResponseBody> |
25 | | -SetExceptionBreakpointsRequestHandler::Run( |
26 | | - const protocol::SetExceptionBreakpointsArguments &args) const { |
27 | | - std::vector<protocol::Breakpoint> response_breakpoints; |
| 17 | +// "SetExceptionBreakpointsRequest": { |
| 18 | +// "allOf": [ { "$ref": "#/definitions/Request" }, { |
| 19 | +// "type": "object", |
| 20 | +// "description": "SetExceptionBreakpoints request; value of command field |
| 21 | +// is 'setExceptionBreakpoints'. The request configures the debuggers |
| 22 | +// response to thrown exceptions. If an exception is configured to break, a |
| 23 | +// StoppedEvent is fired (event type 'exception').", "properties": { |
| 24 | +// "command": { |
| 25 | +// "type": "string", |
| 26 | +// "enum": [ "setExceptionBreakpoints" ] |
| 27 | +// }, |
| 28 | +// "arguments": { |
| 29 | +// "$ref": "#/definitions/SetExceptionBreakpointsArguments" |
| 30 | +// } |
| 31 | +// }, |
| 32 | +// "required": [ "command", "arguments" ] |
| 33 | +// }] |
| 34 | +// }, |
| 35 | +// "SetExceptionBreakpointsArguments": { |
| 36 | +// "type": "object", |
| 37 | +// "description": "Arguments for 'setExceptionBreakpoints' request.", |
| 38 | +// "properties": { |
| 39 | +// "filters": { |
| 40 | +// "type": "array", |
| 41 | +// "items": { |
| 42 | +// "type": "string" |
| 43 | +// }, |
| 44 | +// "description": "IDs of checked exception options. The set of IDs is |
| 45 | +// returned via the 'exceptionBreakpointFilters' capability." |
| 46 | +// }, |
| 47 | +// "exceptionOptions": { |
| 48 | +// "type": "array", |
| 49 | +// "items": { |
| 50 | +// "$ref": "#/definitions/ExceptionOptions" |
| 51 | +// }, |
| 52 | +// "description": "Configuration options for selected exceptions." |
| 53 | +// } |
| 54 | +// }, |
| 55 | +// "required": [ "filters" ] |
| 56 | +// }, |
| 57 | +// "SetExceptionBreakpointsResponse": { |
| 58 | +// "allOf": [ { "$ref": "#/definitions/Response" }, { |
| 59 | +// "type": "object", |
| 60 | +// "description": "Response to 'setExceptionBreakpoints' request. This is |
| 61 | +// just an acknowledgement, so no body field is required." |
| 62 | +// }] |
| 63 | +// } |
| 64 | +void SetExceptionBreakpointsRequestHandler::operator()( |
| 65 | + const llvm::json::Object &request) const { |
| 66 | + llvm::json::Object response; |
| 67 | + lldb::SBError error; |
| 68 | + FillResponse(request, response); |
| 69 | + const auto *arguments = request.getObject("arguments"); |
| 70 | + const auto *filters = arguments->getArray("filters"); |
28 | 71 | // Keep a list of any exception breakpoint filter names that weren't set |
29 | 72 | // so we can clear any exception breakpoints if needed. |
30 | 73 | std::set<llvm::StringRef> unset_filters; |
31 | 74 | for (const auto &bp : *dap.exception_breakpoints) |
32 | 75 | unset_filters.insert(bp.GetFilter()); |
33 | 76 |
|
34 | | - for (const auto &value : args.filters) { |
| 77 | + for (const auto &value : *filters) { |
35 | 78 | const auto filter = GetAsString(value); |
36 | 79 | auto *exc_bp = dap.GetExceptionBreakpoint(std::string(filter)); |
37 | | - protocol::Breakpoint response_bp; |
38 | 80 | if (exc_bp) { |
39 | 81 | exc_bp->SetBreakpoint(); |
40 | 82 | unset_filters.erase(std::string(filter)); |
41 | | - response_bp.verified = true; |
42 | 83 | } |
43 | | - response_breakpoints.push_back(response_bp); |
44 | 84 | } |
45 | 85 | for (const auto &filter : unset_filters) { |
46 | 86 | auto *exc_bp = dap.GetExceptionBreakpoint(filter); |
47 | 87 | if (exc_bp) |
48 | 88 | exc_bp->ClearBreakpoint(); |
49 | 89 | } |
50 | | - |
51 | | - return protocol::SetExceptionBreakpointsResponseBody{response_breakpoints}; |
| 90 | + dap.SendJSON(llvm::json::Value(std::move(response))); |
52 | 91 | } |
53 | 92 |
|
54 | 93 | } // namespace lldb_dap |
0 commit comments