1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
use crate::{
types::{Breakpoint, Capabilities, InvalidatedAreas, Module, Source},
utils::eq_default,
ProtocolMessageContent,
};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use typed_builder::TypedBuilder;
/// A debug adapter initiated event.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase", tag = "event", content = "body")]
pub enum Event {
/// The event indicates that some information about a breakpoint has changed.
Breakpoint(BreakpointEventBody),
/// The event indicates that one or more capabilities have changed.
///
/// Since the capabilities are dependent on the frontend and its UI, it might not be possible to change that at random times (or too late).
///
/// Consequently this event has a hint characteristic: a frontend can only be expected to make a 'best effort' in honouring individual capabilities but there are no guarantees.
///
/// Only changed capabilities need to be included, all other capabilities keep their values.
Capabilities(CapabilitiesEventBody),
/// The event indicates that the execution of the debuggee has continued.
///
/// Please note: a debug adapter is not expected to send this event in response to a request that implies that execution continues, e.g. 'launch' or 'continue'.
///
/// It is only necessary to send a 'continued' event if there was no previous request that implied this.
Continued(ContinuedEventBody),
/// The event indicates that the debuggee has exited and returns its exit code.
Exited(ExitedEventBody),
/// This event indicates that the debug adapter is ready to accept configuration requests (e.g. SetBreakpointsRequest, SetExceptionBreakpointsRequest).
///
/// A debug adapter is expected to send this event when it is ready to accept configuration requests (but not before the 'initialize' request has finished).
///
/// The sequence of events/requests is as follows:
///
/// - adapters sends 'initialized' event (after the 'initialize' request has returned)
///
/// - frontend sends zero or more 'setBreakpoints' requests
///
/// - frontend sends one 'setFunctionBreakpoints' request (if capability 'supportsFunctionBreakpoints' is true)
///
/// - frontend sends a 'setExceptionBreakpoints' request if one or more 'exceptionBreakpointFilters' have been defined (or if 'supportsConfigurationDoneRequest' is not defined or false)
///
/// - frontend sends other future configuration requests
///
/// - frontend sends one 'configurationDone' request to indicate the end of the configuration.
Initialized,
/// This event signals that some state in the debug adapter has changed and requires that the client needs to re-render the data snapshot previously requested.
///
/// Debug adapters do not have to emit this event for runtime changes like stopped or thread events because in that case the client refetches the new state anyway. But the event can be used for example to refresh the UI after rendering formatting has changed in the debug adapter.
///
/// This event should only be sent if the debug adapter has received a value true for the 'supportsInvalidatedEvent' capability of the 'initialize' request.
Invalidated(InvalidatedEventBody),
/// The event indicates that some source has been added, changed, or removed from the set of all loaded sources.
LoadedSource(LoadedSourceEventBody),
/// The event indicates that some information about a module has changed.
Module(ModuleEventBody),
/// The event indicates that the target has produced some output.
Output(OutputEventBody),
/// The event indicates that the debugger has begun debugging a new process. Either one that it has launched, or one that it has attached to.
Process(ProcessEventBody),
/// The event signals the end of the progress reporting with an optional final message.
///
/// This event should only be sent if the client has passed the value true for the 'supportsProgressReporting' capability of the 'initialize' request.
ProgressEnd(ProgressEndEventBody),
/// The event signals that a long running operation is about to start and
///
/// provides additional information for the client to set up a corresponding progress and cancellation UI.
///
/// The client is free to delay the showing of the UI in order to reduce flicker.
///
/// This event should only be sent if the client has passed the value true for the 'supportsProgressReporting' capability of the 'initialize' request.
ProgressStart(ProgressStartEventBody),
/// The event signals that the progress reporting needs to updated with a new message and/or percentage.
///
/// The client does not have to update the UI immediately, but the clients needs to keep track of the message and/or percentage values.
///
/// This event should only be sent if the client has passed the value true for the 'supportsProgressReporting' capability of the 'initialize' request.
ProgressUpdate(ProgressUpdateEventBody),
/// The event indicates that the execution of the debuggee has stopped due to some condition.
///
/// This can be caused by a break point previously set, a stepping request has completed, by executing a debugger statement etc.
Stopped(StoppedEventBody),
/// The event indicates that debugging of the debuggee has terminated. This does **not** mean that the debuggee itself has exited.
Terminated(TerminatedEventBody),
/// The event indicates that a thread has started or exited.
Thread(ThreadEventBody),
}
impl From<Event> for ProtocolMessageContent {
fn from(event: Event) -> Self {
Self::Event(event)
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct BreakpointEventBody {
/// The reason for the event.
#[serde(rename = "reason")]
pub reason: BreakpointEventReason,
/// The 'id' attribute is used to find the target breakpoint and the other attributes are used as the new values.
#[serde(rename = "breakpoint")]
pub breakpoint: Breakpoint,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<BreakpointEventBody> for Event {
fn from(body: BreakpointEventBody) -> Self {
Self::Breakpoint(body)
}
}
impl From<BreakpointEventBody> for ProtocolMessageContent {
fn from(body: BreakpointEventBody) -> Self {
Self::from(Event::from(body))
}
}
/// The reason for the event.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum BreakpointEventReason {
#[serde(rename = "changed")]
Changed,
#[serde(rename = "new")]
New,
#[serde(rename = "removed")]
Removed,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct CapabilitiesEventBody {
/// The set of updated capabilities.
#[serde(rename = "capabilities")]
pub capabilities: Capabilities,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<CapabilitiesEventBody> for Event {
fn from(body: CapabilitiesEventBody) -> Self {
Self::Capabilities(body)
}
}
impl From<CapabilitiesEventBody> for ProtocolMessageContent {
fn from(body: CapabilitiesEventBody) -> Self {
Self::from(Event::from(body))
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ContinuedEventBody {
/// The thread which was continued.
#[serde(rename = "threadId")]
pub thread_id: i32,
/// If 'allThreadsContinued' is true, a debug adapter can announce that all threads have continued.
#[serde(
rename = "allThreadsContinued",
default,
skip_serializing_if = "eq_default"
)]
#[builder(default)]
pub all_threads_continued: bool,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<ContinuedEventBody> for Event {
fn from(body: ContinuedEventBody) -> Self {
Self::Continued(body)
}
}
impl From<ContinuedEventBody> for ProtocolMessageContent {
fn from(body: ContinuedEventBody) -> Self {
Self::from(Event::from(body))
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ExitedEventBody {
/// The exit code returned from the debuggee.
#[serde(rename = "exitCode")]
pub exit_code: i32,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<ExitedEventBody> for Event {
fn from(body: ExitedEventBody) -> Self {
Self::Exited(body)
}
}
impl From<ExitedEventBody> for ProtocolMessageContent {
fn from(body: ExitedEventBody) -> Self {
Self::from(Event::from(body))
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct InvalidatedEventBody {
/// Optional set of logical areas that got invalidated. This property has a hint characteristic: a client can only be expected to make a 'best effort' in honouring the areas but there are no guarantees. If this property is missing, empty, or if values are not understand the client should assume a single value 'all'.
#[serde(rename = "areas", default, skip_serializing_if = "Vec::is_empty")]
#[builder(default)]
pub areas: Vec<InvalidatedAreas>,
/// If specified, the client only needs to refetch data related to this thread.
#[serde(rename = "threadId", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub thread_id: Option<i32>,
/// If specified, the client only needs to refetch data related to this stack frame (and the 'threadId' is ignored).
#[serde(rename = "stackFrameId", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub stack_frame_id: Option<i32>,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<InvalidatedEventBody> for Event {
fn from(body: InvalidatedEventBody) -> Self {
Self::Invalidated(body)
}
}
impl From<InvalidatedEventBody> for ProtocolMessageContent {
fn from(body: InvalidatedEventBody) -> Self {
Self::from(Event::from(body))
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct LoadedSourceEventBody {
/// The reason for the event.
#[serde(rename = "reason")]
pub reason: LoadedSourceEventReason,
/// The new, changed, or removed source.
#[serde(rename = "source")]
pub source: Source,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<LoadedSourceEventBody> for Event {
fn from(body: LoadedSourceEventBody) -> Self {
Self::LoadedSource(body)
}
}
impl From<LoadedSourceEventBody> for ProtocolMessageContent {
fn from(body: LoadedSourceEventBody) -> Self {
Self::from(Event::from(body))
}
}
/// The reason for the event.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum LoadedSourceEventReason {
#[serde(rename = "new")]
New,
#[serde(rename = "changed")]
Changed,
#[serde(rename = "removed")]
Removed,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ModuleEventBody {
/// The reason for the event.
#[serde(rename = "reason")]
pub reason: ModuleEventReason,
/// The new, changed, or removed module. In case of 'removed' only the module id is used.
#[serde(rename = "module")]
pub module: Module,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<ModuleEventBody> for Event {
fn from(body: ModuleEventBody) -> Self {
Self::Module(body)
}
}
impl From<ModuleEventBody> for ProtocolMessageContent {
fn from(body: ModuleEventBody) -> Self {
Self::from(Event::from(body))
}
}
/// The reason for the event.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum ModuleEventReason {
#[serde(rename = "new")]
New,
#[serde(rename = "changed")]
Changed,
#[serde(rename = "removed")]
Removed,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct OutputEventBody {
/// The output category. If not specified, 'console' is assumed.
#[serde(rename = "category", default, skip_serializing_if = "eq_default")]
#[builder(default)]
pub category: OutputCategory,
/// The output to report.
#[serde(rename = "output")]
pub output: String,
/// Support for keeping an output log organized by grouping related messages.
#[serde(rename = "group", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub group: Option<OutputGroup>,
/// If an attribute 'variablesReference' exists and its value is > 0, the output contains objects which can be retrieved by passing 'variablesReference' to the 'variables' request. The value should be less than or equal to 2147483647 (2^31-1).
#[serde(rename = "variablesReference", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub variables_reference: Option<i32>,
/// An optional source location where the output was produced.
#[serde(rename = "source", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub source: Option<Source>,
/// An optional source location line where the output was produced.
#[serde(rename = "line", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub line: Option<i32>,
/// An optional source location column where the output was produced.
#[serde(rename = "column", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub column: Option<i32>,
/// Optional data to report. For the 'telemetry' category the data will be sent to telemetry, for the other categories the data is shown in JSON format.
#[serde(rename = "data", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub data: Option<Value>,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<OutputEventBody> for Event {
fn from(body: OutputEventBody) -> Self {
Self::Output(body)
}
}
impl From<OutputEventBody> for ProtocolMessageContent {
fn from(body: OutputEventBody) -> Self {
Self::from(Event::from(body))
}
}
/// The output category. If not specified, 'console' is assumed.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum OutputCategory {
/// Show the output in the client's default message UI, e.g. a 'debug console'. This category should only be used for informational output from the debugger (as opposed to the debuggee).
#[serde(rename = "console")]
Console,
/// A hint for the client to show the ouput in the client's UI for important and highly visible information, e.g. as a popup notification. This category should only be used for important messages from the debugger (as opposed to the debuggee). Since this category value is a hint, clients might ignore the hint and assume the 'console' category.
#[serde(rename = "important")]
Important,
/// Show the output as normal program output from the debuggee.
#[serde(rename = "stdout")]
Stdout,
/// Show the output as error program output from the debuggee.
#[serde(rename = "stderr")]
Stderr,
/// Send the output to telemetry instead of showing it to the user.
#[serde(rename = "telemetry")]
Telemetry,
}
impl Default for OutputCategory {
fn default() -> Self {
OutputCategory::Console
}
}
/// Support for keeping an output log organized by grouping related messages.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum OutputGroup {
/// Start a new group in expanded mode. Subsequent output events are members of the group and should be shown indented.
///
/// The 'output' attribute becomes the name of the group and is not indented.
#[serde(rename = "start")]
Start,
/// Start a new group in collapsed mode. Subsequent output events are members of the group and should be shown indented (as soon as the group is expanded).
///
/// The 'output' attribute becomes the name of the group and is not indented.
#[serde(rename = "startCollapsed")]
StartCollapsed,
/// End the current group and decreases the indentation of subsequent output events.
///
/// A non empty 'output' attribute is shown as the unindented end of the group.
#[serde(rename = "end")]
End,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ProcessEventBody {
/// The logical name of the process. This is usually the full path to process's executable file. Example: /home/example/myproj/program.js.
#[serde(rename = "name")]
pub name: String,
/// The system process id of the debugged process. This property will be missing for non-system processes.
#[serde(rename = "systemProcessId", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub system_process_id: Option<i32>,
/// If true, the process is running on the same computer as the debug adapter.
#[serde(rename = "isLocalProcess", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub is_local_process: Option<bool>,
/// Describes how the debug engine started debugging this process.
#[serde(rename = "startMethod", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub start_method: Option<ProcessStartMethod>,
/// The size of a pointer or address for this process, in bits. This value may be used by clients when formatting addresses for display.
#[serde(rename = "pointerSize", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub pointer_size: Option<i32>,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<ProcessEventBody> for Event {
fn from(body: ProcessEventBody) -> Self {
Self::Process(body)
}
}
impl From<ProcessEventBody> for ProtocolMessageContent {
fn from(body: ProcessEventBody) -> Self {
Self::from(Event::from(body))
}
}
/// Describes how the debug engine started debugging this process.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum ProcessStartMethod {
/// Process was launched under the debugger.
#[serde(rename = "launch")]
Launch,
/// Debugger attached to an existing process.
#[serde(rename = "attach")]
Attach,
/// A project launcher component has launched a new process in a suspended state and then asked the debugger to attach.
#[serde(rename = "attachForSuspendedLaunch")]
AttachForSuspendedLaunch,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ProgressEndEventBody {
/// The ID that was introduced in the initial 'ProgressStartEvent'.
#[serde(rename = "progressId")]
pub progress_id: String,
/// Optional, more detailed progress message. If omitted, the previous message (if any) is used.
#[serde(rename = "message", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub message: Option<String>,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<ProgressEndEventBody> for Event {
fn from(body: ProgressEndEventBody) -> Self {
Self::ProgressEnd(body)
}
}
impl From<ProgressEndEventBody> for ProtocolMessageContent {
fn from(body: ProgressEndEventBody) -> Self {
Self::from(Event::from(body))
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ProgressStartEventBody {
/// An ID that must be used in subsequent 'progressUpdate' and 'progressEnd' events to make them refer to the same progress reporting.
///
/// IDs must be unique within a debug session.
#[serde(rename = "progressId")]
pub progress_id: String,
/// Mandatory (short) title of the progress reporting. Shown in the UI to describe the long running operation.
#[serde(rename = "title")]
pub title: String,
/// The request ID that this progress report is related to. If specified a debug adapter is expected to emit
///
/// progress events for the long running request until the request has been either completed or cancelled.
///
/// If the request ID is omitted, the progress report is assumed to be related to some general activity of the debug adapter.
#[serde(rename = "requestId", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub request_id: Option<i32>,
/// If true, the request that reports progress may be canceled with a 'cancel' request.
///
/// So this property basically controls whether the client should use UX that supports cancellation.
///
/// Clients that don't support cancellation are allowed to ignore the setting.
#[serde(rename = "cancellable", default, skip_serializing_if = "eq_default")]
#[builder(default)]
pub cancellable: bool,
/// Optional, more detailed progress message.
#[serde(rename = "message", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub message: Option<String>,
/// Optional progress percentage to display (value range: 0 to 100). If omitted no percentage will be shown.
#[serde(rename = "percentage", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub percentage: Option<u8>,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<ProgressStartEventBody> for Event {
fn from(body: ProgressStartEventBody) -> Self {
Self::ProgressStart(body)
}
}
impl From<ProgressStartEventBody> for ProtocolMessageContent {
fn from(body: ProgressStartEventBody) -> Self {
Self::from(Event::from(body))
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ProgressUpdateEventBody {
/// The ID that was introduced in the initial 'progressStart' event.
#[serde(rename = "progressId")]
pub progress_id: String,
/// Optional, more detailed progress message. If omitted, the previous message (if any) is used.
#[serde(rename = "message", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub message: Option<String>,
/// Optional progress percentage to display (value range: 0 to 100). If omitted no percentage will be shown.
#[serde(rename = "percentage", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub percentage: Option<u8>,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<ProgressUpdateEventBody> for Event {
fn from(body: ProgressUpdateEventBody) -> Self {
Self::ProgressUpdate(body)
}
}
impl From<ProgressUpdateEventBody> for ProtocolMessageContent {
fn from(body: ProgressUpdateEventBody) -> Self {
Self::from(Event::from(body))
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct StoppedEventBody {
/// The reason for the event.
///
/// For backward compatibility this string is shown in the UI if the 'description' attribute is missing (but it must not be translated).
#[serde(rename = "reason")]
pub reason: StoppedEventReason,
/// The full reason for the event, e.g. 'Paused on exception'. This string is shown in the UI as is and must be translated.
#[serde(rename = "description", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub description: Option<String>,
/// The thread which was stopped.
#[serde(rename = "threadId", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub thread_id: Option<i32>,
/// A value of true hints to the frontend that this event should not change the focus.
#[serde(
rename = "preserveFocusHint",
default,
skip_serializing_if = "eq_default"
)]
#[builder(default)]
pub preserve_focus_hint: bool,
/// Additional information. E.g. if reason is 'exception', text contains the exception name. This string is shown in the UI.
#[serde(rename = "text", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub text: Option<String>,
/// If 'allThreadsStopped' is true, a debug adapter can announce that all threads have stopped.
///
/// - The client should use this information to enable that all threads can be expanded to access their stacktraces.
///
/// - If the attribute is missing or false, only the thread with the given threadId can be expanded.
#[serde(
rename = "allThreadsStopped",
default,
skip_serializing_if = "eq_default"
)]
#[builder(default)]
pub all_threads_stopped: bool,
/// Ids of the breakpoints that triggered the event. In most cases there will be only a single breakpoint but here are some examples for multiple breakpoints:
///
/// - Different types of breakpoints map to the same location.
///
/// - Multiple source breakpoints get collapsed to the same instruction by the compiler/runtime.
///
/// - Multiple function breakpoints with different function names map to the same location.
#[serde(
rename = "hitBreakpointIds",
default,
skip_serializing_if = "Vec::is_empty"
)]
#[builder(default)]
pub hit_breakpoint_ids: Vec<i32>,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<StoppedEventBody> for Event {
fn from(body: StoppedEventBody) -> Self {
Self::Stopped(body)
}
}
impl From<StoppedEventBody> for ProtocolMessageContent {
fn from(body: StoppedEventBody) -> Self {
Self::from(Event::from(body))
}
}
/// The reason for the event.
///
/// For backward compatibility this string is shown in the UI if the 'description' attribute is missing (but it must not be translated).
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum StoppedEventReason {
#[serde(rename = "step")]
Step,
#[serde(rename = "breakpoint")]
Breakpoint,
#[serde(rename = "exception")]
Exception,
#[serde(rename = "pause")]
Pause,
#[serde(rename = "entry")]
Entry,
#[serde(rename = "goto")]
Goto,
#[serde(rename = "function breakpoint")]
FunctionBreakpoint,
#[serde(rename = "data breakpoint")]
DataBreakpoint,
#[serde(rename = "instruction breakpoint")]
InstructionBreakpoint,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct TerminatedEventBody {
/// A debug adapter may set 'restart' to true (or to an arbitrary object) to request that the front end restarts the session.
///
/// The value is not interpreted by the client and passed unmodified as an attribute '__restart' to the 'launch' and 'attach' requests.
#[serde(rename = "restart", skip_serializing_if = "Option::is_none")]
#[builder(default)]
pub restart: Option<Value>,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<TerminatedEventBody> for Event {
fn from(body: TerminatedEventBody) -> Self {
Self::Terminated(body)
}
}
impl From<TerminatedEventBody> for ProtocolMessageContent {
fn from(body: TerminatedEventBody) -> Self {
Self::from(Event::from(body))
}
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize, TypedBuilder)]
pub struct ThreadEventBody {
/// The reason for the event.
#[serde(rename = "reason")]
pub reason: ThreadEventReason,
/// The identifier of the thread.
#[serde(rename = "threadId")]
pub thread_id: i32,
#[serde(skip)]
#[builder(default, setter(skip))]
private: (),
}
impl From<ThreadEventBody> for Event {
fn from(body: ThreadEventBody) -> Self {
Self::Thread(body)
}
}
impl From<ThreadEventBody> for ProtocolMessageContent {
fn from(body: ThreadEventBody) -> Self {
Self::from(Event::from(body))
}
}
/// The reason for the event.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub enum ThreadEventReason {
#[serde(rename = "started")]
Started,
#[serde(rename = "exited")]
Exited,
}