dap/events.rs
1#[cfg(feature = "client")]
2use serde::Deserialize;
3use serde::Serialize;
4use serde_json::Value;
5
6use crate::types::{
7 Breakpoint, BreakpointEventReason, Capabilities, InvalidatedAreas, LoadedSourceEventReason,
8 Module, ModuleEventReason, OutputEventCategory, OutputEventGroup, ProcessEventStartMethod,
9 Source, StoppedEventReason, ThreadEventReason,
10};
11
12/// Arguments for a Breakpoint event.
13#[cfg_attr(feature = "client", derive(Deserialize))]
14#[derive(Serialize, Debug, Clone)]
15#[serde(rename_all = "camelCase")]
16pub struct BreakpointEventBody {
17 /// The reason for the event.
18 /// Values: 'changed', 'new', 'removed', etc.
19 pub reason: BreakpointEventReason,
20 /// The `id` attribute is used to find the target breakpoint, the other
21 /// attributes are used as the new values.
22 pub breakpoint: Breakpoint,
23}
24
25/// Arguments for a Capabilities event
26#[cfg_attr(feature = "client", derive(Deserialize))]
27#[derive(Serialize, Debug, Default, Clone)]
28#[serde(rename_all = "camelCase")]
29pub struct CapabilitiesEventBody {
30 pub capabilities: Capabilities,
31}
32
33/// Arguments for a Continued event.
34#[cfg_attr(feature = "client", derive(Deserialize))]
35#[derive(Serialize, Debug, Default, Clone)]
36#[serde(rename_all = "camelCase")]
37pub struct ContinuedEventBody {
38 /// The thread which was continued.
39 pub thread_id: i64,
40 /// If `allThreadsContinued` is true, a debug adapter can announce that all threads have
41 /// continued.
42 pub all_threads_continued: Option<bool>,
43}
44
45/// Arguments for a Exited event
46#[cfg_attr(feature = "client", derive(Deserialize))]
47#[derive(Serialize, Debug, Default, Clone)]
48#[serde(rename_all = "camelCase")]
49pub struct ExitedEventBody {
50 /// The exit code returned from the debuggee.
51 pub exit_code: i64,
52}
53
54/// Arguments for a Invalidated event
55#[cfg_attr(feature = "client", derive(Deserialize))]
56#[derive(Serialize, Debug, Default, Clone)]
57#[serde(rename_all = "camelCase")]
58pub struct InvalidatedEventBody {
59 /// Set of logical areas that got invalidated. This property has a hint
60 /// characteristic: a client can only be expected to make a 'best effort' in
61 /// honouring the areas but there are no guarantees. If this property is
62 /// missing, empty, or if values are not understood, the client should assume
63 /// a single value `all`.
64 pub areas: Option<Vec<InvalidatedAreas>>,
65 /// If specified, the client only needs to refetch data related to this
66 /// thread.
67 pub thread_id: Option<i64>,
68 /// If specified, the client only needs to refetch data related to this stack
69 /// frame (and the `threadId` is ignored).
70 pub stack_frame_id: Option<i64>,
71}
72
73/// Arguments for a LoadedSource event.
74#[cfg_attr(feature = "client", derive(Deserialize))]
75#[derive(Serialize, Debug, Clone)]
76#[serde(rename_all = "camelCase")]
77pub struct LoadedSourceEventBody {
78 /// The reason for the event.
79 /// Values: 'new', 'changed', 'removed'
80 pub reason: LoadedSourceEventReason,
81 /// The new, changed, or removed source.
82 pub source: Source,
83}
84
85/// Arguments for a Memory event.
86#[cfg_attr(feature = "client", derive(Deserialize))]
87#[derive(Serialize, Debug, Default, Clone)]
88#[serde(rename_all = "camelCase")]
89pub struct MemoryEventBody {
90 /// Memory reference of a memory range that has been updated.
91 pub memory_reference: String,
92 /// Starting offset in bytes where memory has been updated. Can be negative.
93 pub offset: i64,
94 /// Number of bytes updated.
95 pub count: i64,
96}
97
98/// Arguments for a Module event.
99#[cfg_attr(feature = "client", derive(Deserialize))]
100#[derive(Serialize, Debug, Clone)]
101#[serde(rename_all = "camelCase")]
102pub struct ModuleEventBody {
103 /// The reason for the event.
104 /// Values: 'new', 'changed', 'removed'
105 pub reason: ModuleEventReason,
106 /// The new, changed, or removed module. In case of `removed` only the module
107 /// id is used.
108 pub module: Module,
109}
110
111/// Arguments for an Output event.
112#[cfg_attr(feature = "client", derive(Deserialize))]
113#[derive(Serialize, Debug, Default, Clone)]
114#[serde(rename_all = "camelCase")]
115pub struct OutputEventBody {
116 /// The output category. If not specified or if the category is not
117 /// understood by the client, `console` is assumed.
118 /// Values:
119 /// 'console': Show the output in the client's default message UI, e.g. a
120 /// 'debug console'. This category should only be used for informational
121 /// output from the debugger (as opposed to the debuggee).
122 /// 'important': A hint for the client to show the output in the client's UI
123 /// for important and highly visible information, e.g. as a popup
124 /// notification. This category should only be used for important messages
125 /// from the debugger (as opposed to the debuggee). Since this category value
126 /// is a hint, clients might ignore the hint and assume the `console`
127 /// category.
128 /// 'stdout': Show the output as normal program output from the debuggee.
129 /// 'stderr': Show the output as error program output from the debuggee.
130 /// 'telemetry': Send the output to telemetry instead of showing it to the
131 /// user.
132 /// etc.
133 pub category: Option<OutputEventCategory>,
134 /// The output to report.
135 pub output: String,
136 /// Support for keeping an output log organized by grouping related messages.
137 /// Values:
138 /// 'start': Start a new group in expanded mode. Subsequent output events are
139 /// members of the group and should be shown indented.
140 /// The `output` attribute becomes the name of the group and is not indented.
141 /// 'startCollapsed': Start a new group in collapsed mode. Subsequent output
142 /// events are members of the group and should be shown indented (as soon as
143 /// the group is expanded).
144 /// The `output` attribute becomes the name of the group and is not indented.
145 /// 'end': End the current group and decrease the indentation of subsequent
146 /// output events.
147 /// A non-empty `output` attribute is shown as the unindented end of the
148 /// group.
149 pub group: Option<OutputEventGroup>,
150 /// If an attribute `variablesReference` exists and its value is > 0, the
151 /// output contains objects which can be retrieved by passing
152 /// `variablesReference` to the `variables` request. The value should be less
153 /// than or equal to 2147483647 (2^31-1).
154 pub variables_reference: Option<i64>,
155 /// The source location where the output was produced.
156 pub source: Option<Source>,
157 /// The source location's line where the output was produced.
158 pub line: Option<i64>,
159 /// The position in `line` where the output was produced. It is measured in
160 /// UTF-16 code units and the client capability `columnsStartAt1` determines
161 /// whether it is 0- or 1-based.
162 pub column: Option<i64>,
163 /// Additional data to report. For the `telemetry` category the data is sent
164 /// to telemetry, for the other categories the data is shown in JSON format.
165 pub data: Option<Value>,
166}
167
168/// Arguments for an Process event.
169#[cfg_attr(feature = "client", derive(Deserialize))]
170#[derive(Serialize, Debug, Default, Clone)]
171#[serde(rename_all = "camelCase")]
172pub struct ProcessEventBody {
173 /// The logical name of the process. This is usually the full path to
174 /// process's executable file. Example: /home/example/myproj/program.js.
175 pub name: String,
176 /// The system process id of the debugged process. This property is missing
177 /// for non-system processes.
178 pub system_process_id: Option<i64>,
179 /// If true, the process is running on the same computer as the debug
180 /// adapter.
181 pub is_local_process: Option<bool>,
182 /// Describes how the debug engine started debugging this process.
183 /// Values:
184 /// 'launch': Process was launched under the debugger.
185 /// 'attach': Debugger attached to an existing process.
186 /// 'attachForSuspendedLaunch': A project launcher component has launched a
187 /// new process in a suspended state and then asked the debugger to attach.
188 pub start_method: Option<ProcessEventStartMethod>,
189 /// The size of a pointer or address for this process, in bits. This value
190 /// may be used by clients when formatting addresses for display.
191 pub pointer_size: Option<i64>,
192}
193
194/// Arguments for a ProgressEnd event.
195#[cfg_attr(feature = "client", derive(Deserialize))]
196#[derive(Serialize, Debug, Default, Clone)]
197#[serde(rename_all = "camelCase")]
198pub struct ProgressEndEventBody {
199 /// The ID that was introduced in the initial `ProgressStartEvent`.
200 pub progress_id: String,
201 /// More detailed progress message. If omitted, the previous message (if any)
202 /// is used.
203 pub message: Option<String>,
204}
205
206/// Arguments for a ProgressStart event.
207#[cfg_attr(feature = "client", derive(Deserialize))]
208#[derive(Serialize, Debug, Default, Clone)]
209#[serde(rename_all = "camelCase")]
210pub struct ProgressStartEventBody {
211 /// An ID that can be used in subsequent `progressUpdate` and `progressEnd`
212 /// events to make them refer to the same progress reporting.
213 /// IDs must be unique within a debug session.
214 pub progress_id: String,
215 /// Short title of the progress reporting. Shown in the UI to describe the
216 /// long running operation.
217 pub title: String,
218 /// The request ID that this progress report is related to. If specified a
219 /// debug adapter is expected to emit progress events for the long running
220 /// request until the request has been either completed or cancelled.
221 /// If the request ID is omitted, the progress report is assumed to be
222 /// related to some general activity of the debug adapter.
223 pub request_id: Option<i64>,
224 /// If true, the request that reports progress may be cancelled with a
225 /// `cancel` request.
226 /// So this property basically controls whether the client should use UX that
227 /// supports cancellation.
228 /// Clients that don't support cancellation are allowed to ignore the
229 /// setting.
230 pub cancellable: Option<bool>,
231 /// More detailed progress message.
232 pub message: Option<String>,
233 /// Progress percentage to display (value range: 0 to 100). If omitted no
234 /// percentage is shown.
235 pub percentage: Option<i64>,
236}
237
238/// Arguments for a ProgressUpdate event.
239#[cfg_attr(feature = "client", derive(Deserialize))]
240#[derive(Serialize, Debug, Default, Clone)]
241#[serde(rename_all = "camelCase")]
242pub struct ProgressUpdateEventBody {
243 /// The ID that was introduced in the initial `progressStart` event.
244 pub progress_id: String,
245 /// More detailed progress message. If omitted, the previous message (if any)
246 /// is used.
247 pub message: Option<String>,
248 /// Progress percentage to display (value range: 0 to 100). If omitted no
249 /// percentage is shown.
250 pub percentage: Option<i64>,
251}
252
253/// Arguments for a Stopped event.
254#[cfg_attr(feature = "client", derive(Deserialize))]
255#[derive(Serialize, Debug, Clone)]
256#[serde(rename_all = "camelCase")]
257pub struct StoppedEventBody {
258 /// The reason for the event.
259 /// For backward compatibility this String is shown in the UI if the
260 /// `description` attribute is missing (but it must not be translated).
261 /// Values: 'step', 'breakpoint', 'exception', 'pause', 'entry', 'goto',
262 /// 'function breakpoint', 'data breakpoint', 'instruction breakpoint', etc.
263 pub reason: StoppedEventReason,
264 /// The full reason for the event, e.g. 'Paused on exception'. This String is
265 /// shown in the UI as is and can be translated.
266 pub description: Option<String>,
267 /// The thread which was stopped.
268 pub thread_id: Option<i64>,
269 /// A value of true hints to the client that this event should not change the
270 /// focus.
271 pub preserve_focus_hint: Option<bool>,
272 /// Additional information. E.g. if reason is `exception`, text contains the
273 /// exception name. This String is shown in the UI.
274 pub text: Option<String>,
275 /// If `allThreadsStopped` is true, a debug adapter can announce that all
276 /// threads have stopped.
277 ///
278 /// - The client should use this information to enable that all threads can
279 /// be expanded to access their stacktraces.
280 /// - If the attribute is missing or false, only the thread with the given
281 /// `threadId` can be expanded.
282 pub all_threads_stopped: Option<bool>,
283 /// Ids of the breakpoints that triggered the event. In most cases there is
284 /// only a single breakpoint but here are some examples for multiple
285 /// breakpoints:
286 ///
287 /// - Different types of breakpoints map to the same location.
288 /// - Multiple source breakpoints get collapsed to the same instruction by
289 /// the compiler/runtime.
290 /// - Multiple function breakpoints with different function names map to the
291 /// same location.
292 pub hit_breakpoint_ids: Option<Vec<i64>>,
293}
294
295/// Arguments for a Terminated event.
296#[cfg_attr(feature = "client", derive(Deserialize))]
297#[derive(Serialize, Debug, Default, Clone)]
298#[serde(rename_all = "camelCase")]
299pub struct TerminatedEventBody {
300 /// A debug adapter may set `restart` to true (or to an arbitrary object) to
301 /// request that the client restarts the session.
302 /// The value is not interpreted by the client and passed unmodified as an
303 /// attribute `__restart` to the `launch` and `attach` requests.
304 pub restart: Option<Value>,
305}
306
307/// Arguments for a Thread event.
308#[cfg_attr(feature = "client", derive(Deserialize))]
309#[derive(Serialize, Debug, Clone)]
310#[serde(rename_all = "camelCase")]
311pub struct ThreadEventBody {
312 /// The reason for the event.
313 /// Values: 'started', 'exited', etc.
314 pub reason: ThreadEventReason,
315 /// The identifier of the thread.
316 pub thread_id: i64,
317}
318
319#[cfg_attr(feature = "client", derive(Deserialize))]
320#[derive(Serialize, Debug, Clone)]
321#[serde(tag = "event", content = "body", rename_all = "camelCase")]
322pub enum Event {
323 /// This event indicates that the debug adapter is ready to accept configuration requests (e.g.
324 /// `setBreakpoints`, `setExceptionBreakpoints`).
325 /// A debug adapter is expected to send this event when it is ready to accept configuration
326 /// requests (but not before the initialize request has finished).
327 ///
328 /// Specification: [Initialized event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Initialized)
329 Initialized,
330 /// The event indicates that one or more capabilities have changed.
331 /// Since the capabilities are dependent on the client and its UI, it might not be possible to
332 /// change that at random times (or too late).
333 /// Consequently this event has a hint characteristic: a client can only be expected to make a
334 /// ‘best effort’ in honouring individual capabilities but there are no guarantees.
335 /// Only changed capabilities need to be included, all other capabilities keep their values.
336 ///
337 /// Specification: [Capabilities event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Capabilities)
338 Capabilities(CapabilitiesEventBody),
339 /// The event indicates that some information about a breakpoint has changed.
340 ///
341 /// Specification: [Breakpoint event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Breakpoint)
342 Breakpoint(BreakpointEventBody),
343 /// The event indicates that the execution of the debuggee has continued.
344 /// Please note: a debug adapter is not expected to send this event in response to a request that
345 /// implies that execution continues, e.g. launch or continue.
346 /// It is only necessary to send a continued event if there was no previous request that implied this.
347 ///
348 /// Specification: [Continued event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Continued)
349 Continued(ContinuedEventBody),
350 /// The event indicates that the debuggee has exited and returns its exit code.
351 ///
352 /// Specification: [Exited event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Exited)
353 Exited(ExitedEventBody),
354 /// This event signals that some state in the debug adapter has changed and requires that the
355 /// client needs to re-render the data snapshot previously requested.
356 /// Debug adapters do not have to emit this event for runtime changes like stopped or thread
357 /// events because in that case the client refetches the new state anyway. But the event can be
358 /// used for example to refresh the UI after rendering formatting has changed in the debug adapter.
359 ///
360 /// Specification: [Invalidated event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Invalidated)
361 Invalidated(InvalidatedEventBody),
362 /// The event indicates that some source has been added, changed, or removed from the set of all
363 /// loaded sources.
364 ///
365 /// Specification: [LoadedSource event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_LoadedSource)
366 LoadedSource(LoadedSourceEventBody),
367 /// This event indicates that some memory range has been updated. It should only be sent if the
368 /// corresponding capability supportsMemoryEvent is true.
369 /// Clients typically react to the event by re-issuing a readMemory request if they show the
370 /// memory identified by the memoryReference and if the updated memory range overlaps the
371 /// displayed range. Clients should not make assumptions how individual memory references relate
372 /// to each other, so they should not assume that they are part of a single continuous address
373 /// range and might overlap.
374 ///
375 /// Specification: [Memory event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Memory)
376 Memory(MemoryEventBody),
377 /// The event indicates that some information about a module has changed.
378 ///
379 /// Specification: [Module event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Module)
380 Module(ModuleEventBody),
381 /// The event indicates that the target has produced some output.
382 ///
383 /// Specification: [Output event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Output)
384 Output(OutputEventBody),
385 /// The event indicates that the debugger has begun debugging a new process. Either one that it
386 /// has launched, or one that it has attached to.
387 ///
388 /// Specification: [Process event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Process)
389 Process(ProcessEventBody),
390 /// The event signals the end of the progress reporting with a final message.
391 /// This event should only be sent if the corresponding capability supportsProgressReporting is
392 /// true.
393 ///
394 /// Specification: [ProgressEnd event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_ProgressEnd)
395 ProgressEnd(ProgressEndEventBody),
396 /// The event signals that a long running operation is about to start and provides additional
397 /// information for the client to set up a corresponding progress and cancellation UI.
398 /// The client is free to delay the showing of the UI in order to reduce flicker.
399 /// This event should only be sent if the corresponding capability `supportsProgressReporting` is
400 /// true.
401 ///
402 /// Specification: [ProgressStart event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_ProgressStart)
403 ProgressStart(ProgressStartEventBody),
404 /// The event signals that the progress reporting needs to be updated with a new message and/or
405 /// percentage.
406 /// The client does not have to update the UI immediately, but the clients needs to keep track of
407 /// the message and/or percentage values.
408 /// This event should only be sent if the corresponding capability supportsProgressReporting is
409 /// true.
410 ///
411 /// Specification: [ProgressUpdate event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_ProgressUpdate)
412 ProgressUpdate(ProgressUpdateEventBody),
413 /// The event indicates that the execution of the debuggee has stopped due to some condition.
414 /// This can be caused by a breakpoint previously set, a stepping request has completed, by
415 /// executing a debugger statement etc.
416 ///
417 /// Specification: [Stopped event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Stopped)
418 Stopped(StoppedEventBody),
419 /// The event indicates that debugging of the debuggee has terminated. This does not mean that
420 /// the debuggee itself has exited.
421 ///
422 /// Specification: [Terminated event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Terminated)
423 Terminated(Option<TerminatedEventBody>),
424 /// The event indicates that a thread has started or exited.
425 ///
426 /// Specification: [Thread event](https://microsoft.github.io/debug-adapter-protocol/specification#Events_Thread)
427 Thread(ThreadEventBody),
428 /// Custom Miden event: server-pushed bundled UI state snapshot.
429 ///
430 /// Emitted immediately before a `Stopped` event so the DAP client can
431 /// update its UI from the snapshot without an extra evaluate round-trip.
432 #[serde(rename = "miden/uiState")]
433 MidenUiState(Value),
434}