Skip to content

API Reference

Sans-IO Client

Debug Adapter Protocol (DAP) Client implementation without connection handling.

The client is responsible for sending requests and receiving events from the debug adapter. It is up to the user to handle the connection to the debug adapter, making it more flexible.

The client can be used in a synchronous or asynchronous manner, depending on the user's needs.

Source code in src\dap\client.py
 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
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
class Client:
    """Debug Adapter Protocol (DAP) Client implementation without connection handling.

    The client is responsible for sending requests and receiving events from the debug adapter.
    It is up to the user to handle the connection to the debug adapter, making it more flexible.

    The client can be used in a synchronous or asynchronous manner, depending on the user's needs.
    """

    def __init__(
        self,
        adapter_id: str,
        client_id: Optional[str] = None,
        client_name: Optional[str] = None,
        locale: Optional[str] = None,
        lines_start_at1: Optional[bool] = None,
        columns_start_at1: Optional[bool] = None,
        path_format: Optional[Literal["path", "uri"] | str] = None,
    ) -> None:
        """Initializes the debug adapter client.

        Args:
            adapter_id: The ID of the debug adapter.
            client_id: The ID of the client.
            client_name: The name of the client.
            locale: The locale of the client.
            lines_start_at1: Whether the lines start at 1.
            columns_start_at1: Whether the columns start at 1.
            path_format: The format of the paths.
        """

        self._seq: int = 1
        self._send_buf = bytearray()
        self._receive_buf = bytearray()
        self._pending_requests: dict[int, Request] = {}

        self.handler = Handler(self)

        self.initialize(
            adapter_id=adapter_id,
            client_id=client_id,
            client_name=client_name,
            locale=locale,
            lines_start_at1=lines_start_at1,
            columns_start_at1=columns_start_at1,
            path_format=path_format,
            supports_variable_type=True,
            supports_variable_paging=True,
            supports_run_in_terminal_request=True,
            supports_memory_references=True,
            supports_progress_reporting=True,
            supports_invalidated_event=True,
            supports_memory_event=True,
            supports_args_can_be_interpreted_by_shell=True,
            supports_start_debugging_request=True,
        )

    def send_request(
        self, command: str, arguments: Optional[dict[str, Any]] = None
    ) -> int:
        """Send a request to the debug adapter.

        This can be useful for sending requests that are not yet implemented in the client or
        for sending custom requests to the debug adapter that are specific to the adapter.

        Args:
            command: The command to send.
            arguments: The arguments to send.

        Returns:
            The sequence number of the request.
        """

        seq = self._seq
        self._seq += 1

        self._send_buf += RequestBuffer(seq, command, arguments)
        self._pending_requests[seq] = Request(
            seq=seq, command=command, arguments=arguments
        )
        return seq

    def receive(self, data: bytes) -> Generator[ResponseBody | EventBody, None, None]:
        """Feed data from the debug adapter to the client.

        Args:
            data: The data to receive.

        Yields:
            The response or event body.
        """

        self._receive_buf += data
        yield from self.handler.handle()

    def send(self) -> bytes:
        """Get the data to send to the debug adapter.

        Returns:
            The data to send.
        """

        send_buf = self._send_buf
        self._send_buf = bytearray()
        return send_buf

    # Requests
    def cancel(
        self, request_id: Optional[int] = None, progress_id: Optional[str] = None
    ) -> int:
        """The cancel request is used by the client in two situations:

        - to indicate that it is no longer interested in the result produced by a specific request issued earlier
        - to cancel a progress sequence.

        Both `progress_id` and `request_id` CAN BE specified in the same request.

        Args:
            request_id: The ID (_seq) of the request to cancel. If missing no request is canceled.
            progress_id: The progress ID of the progress sequence to cancel. If missing no progress is canceled.
        """

        return self.send_request(
            "cancel", {"requestId": request_id, "progressId": progress_id}
        )

    def attach(self, __restart: Optional[Any] = None) -> int:
        """attach to a running process.

        Args:
            __restart: Arbitrary data from the previous, restarted session. \
                The data is sent as the `restart` attribute of the `terminated` event."""

        return self.send_request("attach", {"__restart": __restart})

    def breakpoint_locations(
        self,
        source: Source,
        line: int,
        column: Optional[int] = None,
        end_line: Optional[int] = None,
        end_column: Optional[int] = None,
    ) -> int:
        """Retrieve all possible locations for source breakpoints in a given range.

        Args:
            source: The source location of the breakpoints.
            line: The source line of the breakpoints.
            column: An optional source column of the breakpoints.
            end_line: An optional end line of the range covered by the breakpoint.
            end_column: An optional end column of the range covered by the breakpoint.
        """

        return self.send_request(
            "breakpointLocations",
            {
                "source": source,
                "line": line,
                "column": column,
                "endLine": end_line,
                "endColumn": end_column,
            },
        )

    def completions(
        self,
        text: str,
        column: int,
        line: Optional[int],
        frame_id: Optional[int] = None,
    ) -> int:
        """Returns a list of possible completions for a given caret position and text.

        Args:
            text: One or more source lines. Typically this is the text users have typed into \
                the debug console before they asked for completion.
            column: The position within `text` for which to determine the completion proposals.
            line: A line for which to determine the completion proposals. If missing the \
                first line of the text is assumed.
            frame_id: An optional frameId of the stack frame, if specified returns \
                completions in the scope of this stack frame.
        """

        return self.send_request(
            "completions",
            {
                "frameId": frame_id,
                "text": text,
                "column": column,
                "line": line,
            },
        )

    def configuration_done(self) -> int:
        """This request indicates that the client has finished initialization of the debug adapter."""

        return self.send_request("configurationDone")

    def continue_(self, thread_id: int, single_thread: Optional[bool] = None) -> int:
        """The request resumes execution of all threads.
        If the debug adapter supports single thread execution, setting `single_thread` true resumes only the specified thread.

        Args:
            thread_id: the active thread.
            single_thread: Execute only this thread.
        """

        return self.send_request(
            "continue", {"threadId": thread_id, "singleThread": single_thread}
        )

    def data_breakpoint_info(
        self,
        name: str,
        variables_reference: Optional[int] = None,
        frameId: Optional[int] = None,
        bytes: Optional[int] = None,
        asAddress: Optional[bool] = None,
        mode: Optional[str] = None,
    ) -> int:
        """Retrieve the information of a data breakpoint.

        Args:
            variables_reference: Reference to the variable container if the data breakpoint is requested for \
                a child of the container.
            name: The name of the variable's child to obtain data breakpoint information for.
            frameId: When `name` is an expression, evaluate it in the scope of this stack frame.
            bytes: If specified, a debug adapter should return information for the range of memory extending \
                `bytes` number of bytes from the address or variable specified by `name`. \
                Breakpoints set using the resulting data ID should pause on data access anywhere within that range.
            asAddress: If true, `name` is an address.
            mode: The mode of the desired breakpoint.
        """

        return self.send_request(
            "dataBreakpointInfo",
            {
                "variablesReference": variables_reference,
                "name": name,
                "frameId": frameId,
                "bytes": bytes,
                "asAddress": asAddress,
                "mode": mode,
            },
        )

    def disassemble(
        self,
        memory_reference: str,
        instruction_count: Optional[int] = None,
        offset: Optional[int] = None,
        instruction_offset: Optional[int] = None,
        resolve_symbols: Optional[bool] = None,
    ) -> int:
        """Disassembles code stored at the provided location.

        Args:
            memory_reference: Memory reference to the base location containing the instructions to disassemble.
            instruction_count: The number of instructions to disassemble starting at the specified location and offset.
            offset: The offset (in bytes) of the first instruction to disassemble.
            instruction_offset: The offset (in instructions) of the first instruction to disassemble.
            resolve_symbols: If set to true, the adapter should attempt to resolve memory addresses \
                to function names and line numbers.
        """

        return self.send_request(
            "disassemble",
            {
                "memoryReference": memory_reference,
                "offset": offset,
                "instructionCount": instruction_count,
            },
        )

    def disconnect(
        self,
        restart: Optional[bool] = None,
        terminal_debuggee: Optional[bool] = None,
        suspend_debuggee: Optional[bool] = None,
    ) -> int:
        """Asks the debug adapter to disconnect from the debuggee (thus ending the debug session) and then to shut down.

        In addition, the debug adapter must terminate the debuggee if it was started with the launch request.
        If an attach request was used to connect to the debuggee, then the debug adapter must not terminate the debuggee.

        Args:
            restart: A value of true indicates that this 'disconnect' request is part of a restart sequence.
            terminal_debuggee: Indicates whether the debuggee should be terminated when the debugger is disconnected.
            suspend_debuggee: Indicates whether the debuggee should be allowed to run after the debugger is disconnected.
        """

        return self.send_request(
            "disconnect",
            {
                "restart": restart,
                "terminateDebuggee": terminal_debuggee,
                "suspendDebuggee": suspend_debuggee,
            },
        )

    def evaluate(
        self,
        expression: str,
        frame_id: Optional[int] = None,
        line: Optional[int] = None,
        column: Optional[int] = None,
        source: Optional[Source] = None,
        context: Optional[
            Literal["watch", "repl", "hover", "clipboard", "variables"] | str
        ] = None,
        format: Optional[ValueFormat] = None,
    ) -> int:
        """Evaluate the given expression in the context of topmost stack frame.
        The expression has access to any variables and arguments that are in scope.

        Args:
            expression: The expression to evaluate.
            frame_id: Evaluate the expression in the scope of this stack frame. \
                If not specified, the expression is evaluated in the global scope.
            line: The contextual line where the expression should be evaluated. \
                In the 'hover' context, this should be set to the start of the expression being hovered.
            column: The contextual column where the expression should be evaluated. \
                This may be provided if `line` is also provided.
            source: The contextual source in which the `line` is found. \
                This must be provided if `line` is provided.
            context: The context in which the evaluate request is used.
            format: Specifies details on how to format the result.
        """

        return self.send_request(
            "evaluate",
            {
                "expression": expression,
                "frameId": frame_id,
                "line": line,
                "column": column,
                "source": source,
                "context": context,
                "format": format,
            },
        )

    def exception_info(self, thread_id: int) -> int:
        """Retrieves the details of the exception that caused this event to be raised.

        Args:
            thread_id: Thread for which exception information should be retrieved.
        """

        return self.send_request("exceptionInfo", {"threadId": thread_id})

    def goto(self, thread_id: int, target_id: str) -> int:
        """The request sets the location where the debuggee will continue to run.

        Args:
            thread_id: The thread to continue.
            target_id: The location where the debuggee will continue to run.
        """

        return self.send_request("goto", {"threadId": thread_id, "targetId": target_id})

    def goto_targets(
        self, source: Source, line: int, column: Optional[int] = None
    ) -> int:
        """Retrieve possible goto targets for the specified location.

        Args:
            source: The source location for which the goto targets are determined.
            line: The line for which the goto targets are determined.
            column: An optional column for which the goto targets are determined.
        """

        return self.send_request(
            "gotoTargets", {"source": source, "line": line, "column": column}
        )

    def initialize(
        self,
        adapter_id: str,
        client_id: Optional[str] = None,
        client_name: Optional[str] = None,
        locale: Optional[str] = None,
        lines_start_at1: Optional[bool] = None,
        columns_start_at1: Optional[bool] = None,
        path_format: Optional[Literal["path", "uri"] | str] = None,
        supports_variable_type: Optional[bool] = None,
        supports_variable_paging: Optional[bool] = None,
        supports_run_in_terminal_request: Optional[bool] = None,
        supports_memory_references: Optional[bool] = None,
        supports_progress_reporting: Optional[bool] = None,
        supports_invalidated_event: Optional[bool] = None,
        supports_memory_event: Optional[bool] = None,
        supports_args_can_be_interpreted_by_shell: Optional[bool] = None,
        supports_start_debugging_request: Optional[bool] = None,
    ) -> int:
        """Initializes the debug adapter with the client capabilities."""

        return self.send_request(
            "initialize",
            {
                "adapterID": adapter_id,
                "clientID": client_id,
                "clientName": client_name,
                "locale": locale,
                "linesStartAt1": lines_start_at1,
                "columnsStartAt1": columns_start_at1,
                "pathFormat": path_format,
                "supportsVariableType": supports_variable_type,
                "supportsVariablePaging": supports_variable_paging,
                "supportsRunInTerminalRequest": supports_run_in_terminal_request,
                "supportsMemoryReferences": supports_memory_references,
                "supportsProgressReporting": supports_progress_reporting,
                "supportsInvalidatedEvent": supports_invalidated_event,
                "supportsMemoryEvent": supports_memory_event,
                "supportsArgsCanBeInterpretedByShell": supports_args_can_be_interpreted_by_shell,
                "supportsStartDebuggingRequest": supports_start_debugging_request,
            },
        )

    def launch(
        self,
        no_debug: Optional[bool] = None,
        __restart: Optional[Any] = None,
    ) -> int:
        """The launch request is used to start the debuggee with or without debugging enabled.

        Args:
            no_debug: Set to true if the launch request is used to just start the debuggee \
                for the purpose of collecting output. The debuggee is not supposed to stop at breakpoints.
            __restart: Arbitrary data from the previous, restarted session. \
                The data is sent as the `restart` attribute of the `terminated` event.
        """

        return self.send_request(
            "launch",
            {"noDebug": no_debug, "__restart": __restart},
        )

    def loaded_sources(self) -> int:
        """Retrieves the set of all sources currently loaded by the debugged process."""

        return self.send_request("loadedSources")

    def modules(
        self, start_module: Optional[int] = None, module_count: Optional[int] = None
    ) -> int:
        """Modules can be retrieved from the debug adapter with this request which can either
        return all modules or a range of modules to support paging.

        Args:
            start_module: The 0-based index of the first module to return; if omitted modules start at 0.
            module_count: The number of modules to return. If moduleCount is not specified or 0, \
                all modules are returned.
        """

        return self.send_request(
            "modules", {"startModule": start_module, "moduleCount": module_count}
        )

    def next(
        self,
        thread_id: int,
        single_thread: Optional[bool] = None,
        granularity: Optional[str] = None,
    ) -> int:
        """The request steps through the program.

        Args:
            thread_id: Specifies the thread for which to resume execution for one step.
            single_thread: If this is true, all other suspended threads are not resumed.
            granularity: The granularity of the step, assumed to be 'statement' if not specified.
        """

        return self.send_request(
            "next",
            {
                "threadId": thread_id,
                "singleThread": single_thread,
                "granularity": granularity,
            },
        )

    def pause(self, thread_id: int) -> int:
        """Suspends the debuggee.

        Args:
            thread_id: The thread to pause.
        """

        return self.send_request("pause", {"threadId": thread_id})

    def read_memory(
        self, memory_reference: str, count: int, offset: Optional[int] = None
    ) -> int:
        """Reads memory from the debuggee.

        Args:
            memory_reference: The memory reference to the base location from which to read memory.
            count: The number of bytes to read at the specified location and offset.
            offset: The offset (in bytes) of the first byte to read.
        """

        return self.send_request(
            "readMemory",
            {"memoryReference": memory_reference, "offset": offset, "count": count},
        )

    def restart(
        self,
        arguments: Optional[LaunchRequestArguments | AttachRequestArguments] = None,
    ) -> int:
        """Restarts a debug session.

        Args:
            arguments: Use either arguments for the 'launch' or 'attach' request.
        """

        return self.send_request("restart", arguments)

    def restart_frame(self, frame_id: int) -> int:
        """Restart the stack frame identified by the given frame ID.
        The frame ID must have been obtained in the current suspended state.

        Args:
            frame_id: The frame to restart.
        """

        return self.send_request("restartFrame", {"frameId": frame_id})

    def reverse_continue(
        self, thread_id: int, single_thread: Optional[bool] = None
    ) -> int:
        """The request starts the debuggee to run backward.

        Args:
            thread_id: ID of the active thread.
            single_thread: If true, backward execution is limited to the specified thread.
        """

        return self.send_request(
            "reverseContinue",
            {"threadId": thread_id, "singleThread": single_thread},
        )

    def scopes(self, frame_id: int) -> int:
        """The request returns the variable scopes for a given stack frame.

        Args:
            frame_id: Retrieve the scopes for this stackframe.
        """

        return self.send_request("scopes", {"frameId": frame_id})

    def set_breakpoints(
        self,
        source: Source,
        breakpoints: List[SourceBreakpoint],
        lines: Optional[List[int]] = None,
        source_modified: Optional[bool] = None,
    ) -> int:
        """Sets multiple breakpoints for a single source and clears all previous breakpoints in that source.

        Args:
            source: The source location of the breakpoints.
            breakpoints: The code locations of the breakpoints.
            lines: Deprecated: The code locations of the breakpoints.
            source_modified: A value of true indicates that the underlying source has been modified \
                which results in new breakpoint locations.
        """

        return self.send_request(
            "setBreakpoints",
            {
                "source": source,
                "breakpoints": breakpoints,
                "lines": lines,
                "sourceModified": source_modified,
            },
        )

    def set_data_breakpoints(self, breakpoints: List[DataBreakpoint]) -> int:
        """Replaces all existing data breakpoints with new data breakpoints.

        Args:
            breakpoints: The data breakpoints to set.
        """

        return self.send_request("setDataBreakpoints", {"breakpoints": breakpoints})

    def set_exception_breakpoints(
        self,
        filters: List[str],
        filter_options: Optional[List[ExceptionFilterOptions]],
        exception_options: Optional[List[ExceptionOptions]],
    ) -> int:
        """The request configures the debugger's response to thrown exceptions.

        Each of the filters, filterOptions, and exceptionOptions in the request are independent configurations
        to a debug adapter indicating a kind of exception to catch. An exception thrown in a program should result
        in a stopped event from the debug adapter (with reason exception) if any of the configured filters match.

        Args:
            filters: Set of exception filters specified by their ID.
            filter_options: An array of ExceptionFilterOptions. The set of all possible exception filters \
                is defined by the `exceptionBreakpointFilters` capability.
            exception_options: An array of ExceptionOptions. Configuration options for selected exceptions.
        """

        return self.send_request(
            "setExceptionBreakpoints",
            {
                "filters": filters,
                "filterOptions": filter_options,
                "exceptionOptions": exception_options,
            },
        )

    def set_expression(
        self,
        expression: str,
        value: str,
        frame_id: Optional[int] = None,
        format: Optional[ValueFormat] = None,
    ) -> int:
        """Evaluates the given value expression and assigns it to the expression which must be a modifiable l-value.

        The expressions have access to any variables and arguments that are in scope of the specified frame.

        Args:
            expression: The l-value expression to assign the result to.
            value: The value expression to assign to the l-value expression.
            frame_id: Evaluate the expressions in the scope of this stack frame. \
                If not specified, the expressions are evaluated in the global scope.
            format: Specifies details on how to format the result.
        """

        return self.send_request(
            "setExpression",
            {
                "expression": expression,
                "value": value,
                "frameId": frame_id,
                "format": format,
            },
        )

    def set_function_breakpoints(
        self, breakpoints: List[FunctionBreakpoint] = []
    ) -> int:
        """Replaces all existing function breakpoints with new function breakpoints.

        To clear all function breakpoints, call this without arguments.
        When a function breakpoint is hit, a stopped event (with reason function breakpoint) is generated.

        Args:
            breakpoints: The function breakpoints to set.
        """

        return self.send_request("setFunctionBreakpoints", {"breakpoints": breakpoints})

    def set_instruction_breakpoints(
        self, breakpoints: List[InstructionBreakpoint]
    ) -> int:
        """Replaces all existing instruction breakpoints. Typically, instruction breakpoints would be set from a disassembly window.

        To clear all instruction breakpoints, specify an empty array.
        When an instruction breakpoint is hit, a stopped event (with reason instruction breakpoint) is generated.

        Args:
            breakpoints: The instruction breakpoints to set.
        """

        return self.send_request(
            "setInstructionBreakpoints", {"breakpoints": breakpoints}
        )

    def set_variable(
        self,
        variables_reference: int,
        name: str,
        value: str,
        format: Optional[ValueFormat] = None,
    ) -> int:
        """Set the variable with the given name in the variable container to a new value.

        Args:
            variables_reference: The reference of the variable container.
            name: The name of the variable to set.
            value: The value to set.
            format: Specifies details on how to format the response value.
        """

        return self.send_request(
            "setVariable",
            {
                "variablesReference": variables_reference,
                "name": name,
                "value": value,
                "format": format,
            },
        )

    def source(self, source_reference: int, source: Optional[Source] = None) -> int:
        """The request retrieves the source code for a given source reference.

        Args:
            source_reference: The reference to the source. This is the same as `source.sourceReference`.
            source: Specifies the source content to load. Either `source.path` or `source.sourceReference` must be specified.
        """

        return self.send_request(
            "source", {"sourceReference": source_reference, "source": source}
        )

    def stack_trace(
        self,
        thread_id: Optional[int] = None,
        start_frame: Optional[int] = None,
        levels: Optional[int] = None,
        format: Optional[StackFrameFormat] = None,
    ) -> int:
        """The request returns a stack trace from the current execution state.

        Request all stack frames by omitting the startFrame and levels arguments.

        Args:
            thread_id: Retrieve the stacktrace for this thread.
            start_frame: The index of the first frame to return; if omitted frames start at 0.
            levels: The maximum number of frames to return. If levels is not specified or 0, all frames are returned.
            format: Specifies details on how to format the stack frames.
        """

        return self.send_request(
            "stackTrace",
            {
                "threadId": thread_id,
                "startFrame": start_frame,
                "levels": levels,
                "format": format,
            },
        )

    def step_back(
        self,
        thread_id: int,
        single_thread: Optional[bool] = None,
        granularity: Optional[SteppingGranularity] = None,
    ) -> int:
        """The request executes one backward step (in the given granularity) for the specified thread
        and allows all other threads to run backward freely by resuming them.

        If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`),
        setting the singleThread argument to true prevents other suspended threads from resuming.
        The debug adapter first sends the response and then a stopped event (with reason step) after the step has completed.

        Args:
            thread_id: ID of the active thread.
            single_thread: If true, backward execution is limited to the specified thread.
            granularity: The granularity of the step, assumed to be 'statement' if not specified.
        """

        return self.send_request(
            "stepBack",
            {
                "threadId": thread_id,
                "singleThread": single_thread,
                "granularity": granularity,
            },
        )

    def step_in(
        self,
        thread_id: int,
        single_thread: Optional[bool] = None,
        target_id: Optional[int] = None,
        granularity: Optional[SteppingGranularity] = None,
    ) -> int:
        """The request resumes the given thread to step into a function/method and allows all other threads to run freely by resuming them.

        If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`),
        setting the singleThread argument to true prevents other suspended threads from resuming.

        If the request cannot step into a target, stepIn behaves like the next request.
        The debug adapter first sends the response and then a stopped event (with reason step) after the step has completed.

        If there are multiple function/method calls (or other targets) on the source line,
        the argument targetId can be used to control into which target the stepIn should occur.

        Args:
            thread_id: ID of the active thread.
            single_thread: If true, stepIn is limited to the specified thread.
            target_id: The stepIn target for this step.
            granularity: The granularity of the step, assumed to be 'statement' if not specified.
        """

        return self.send_request(
            "stepIn",
            {
                "threadId": thread_id,
                "singleThread": single_thread,
                "targetId": target_id,
                "granularity": granularity,
            },
        )

    def step_in_targets(self, frame_id: int) -> int:
        """The request retrieves the possible stepIn targets for the specified stack frame.
        These targets can be used in the stepIn request.

        Args:
            frame_id: The stack frame for which to retrieve the possible stepIn targets.
        """

        return self.send_request("stepInTargets", {"frameId": frame_id})

    def step_out(
        self,
        thread_id: int,
        single_thread: Optional[bool] = None,
        granularity: Optional[SteppingGranularity] = None,
    ) -> int:
        """The request resumes the given thread to step out of the current function/method and allows all other threads to run freely by resuming them.

        If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`),
        setting the singleThread argument to true prevents other suspended threads from resuming.

        The debug adapter first sends the response and then a stopped event (with reason step) after the step has completed.

        Args:
            thread_id: ID of the active thread.
            single_thread: If true, stepOut is limited to the specified thread.
            granularity: The granularity of the step, assumed to be 'statement' if not specified.
        """

        return self.send_request(
            "stepOut",
            {
                "threadId": thread_id,
                "singleThread": single_thread,
                "granularity": granularity,
            },
        )

    def terminate(self, restart: Optional[bool] = None) -> int:
        """The terminate request is sent from the client to the debug adapter in order to shut down the debuggee gracefully.

        Typically a debug adapter implements terminate by sending a software signal which the debuggee intercepts in order
        to clean things up properly before terminating itself.

        Please note that this request does not directly affect the state of the debug session: if the debuggee decides to
        veto the graceful shutdown for any reason by not terminating itself, then the debug session just continues.

        Args:
            restart: A value of true indicates that this 'terminate' request is part of a restart sequence.
        """

        return self.send_request("terminate", {"restart": restart})

    def terminate_threads(self, thread_ids: List[int]) -> int:
        """The request terminates the threads with the given ids.

        Args:
            thread_ids: The threads to terminate.
        """

        return self.send_request("terminateThreads", {"threadIds": thread_ids})

    def threads(self) -> int:
        """The request retrieves a list of all threads."""

        return self.send_request("threads")

    def variables(
        self,
        variables_reference: int,
        filter: Optional[Literal["indexed", "named"]] | str = None,
        start: Optional[int] = None,
        count: Optional[int] = None,
        format: Optional[ValueFormat] = None,
    ) -> int:
        """Retrieves all child variables for the given variable reference.

        A filter can be used to limit the fetched children to either named or indexed children.

        Args:
            variables_reference: The variable for which to retrieve its children.
            filter: Filter to limit the child variables to either named or indexed. If not specified, both types are fetched.
            start: The index of the first variable to return; if omitted variables start at 0.
            count: The number of variables to return. If not passed or 0, all variables are returned.
            format: Specifies details on how to format the response value.
        """

        return self.send_request(
            "variables",
            {
                "variablesReference": variables_reference,
                "filter": filter,
                "start": start,
                "count": count,
                "format": format,
            },
        )

    def write_memory(
        self,
        memory_reference: str,
        data: str,
        offset: Optional[int] = None,
        allow_partial: Optional[bool] = None,
    ) -> int:
        """Writes bytes to memory at the provided location.

        Args:
            memory_reference: The memory reference to the base location to write memory.
            data: Bytes to write, encoded using base64.
            offset: The offset (in bytes) of the first byte to write. Can be negative.
            allow_partial: Property to control partial writes. If true, the debug adapter should \
                attempt to write memory even if the entire memory region is not writable.
        """

        return self.send_request(
            "writeMemory",
            {
                "memoryReference": memory_reference,
                "offset": offset,
                "data": data,
                "allowPartial": allow_partial,
            },
        )

__init__(adapter_id, client_id=None, client_name=None, locale=None, lines_start_at1=None, columns_start_at1=None, path_format=None)

Initializes the debug adapter client.

Parameters:

Name Type Description Default
adapter_id str

The ID of the debug adapter.

required
client_id Optional[str]

The ID of the client.

None
client_name Optional[str]

The name of the client.

None
locale Optional[str]

The locale of the client.

None
lines_start_at1 Optional[bool]

Whether the lines start at 1.

None
columns_start_at1 Optional[bool]

Whether the columns start at 1.

None
path_format Optional[Literal[path, uri] | str]

The format of the paths.

None
Source code in src\dap\client.py
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
def __init__(
    self,
    adapter_id: str,
    client_id: Optional[str] = None,
    client_name: Optional[str] = None,
    locale: Optional[str] = None,
    lines_start_at1: Optional[bool] = None,
    columns_start_at1: Optional[bool] = None,
    path_format: Optional[Literal["path", "uri"] | str] = None,
) -> None:
    """Initializes the debug adapter client.

    Args:
        adapter_id: The ID of the debug adapter.
        client_id: The ID of the client.
        client_name: The name of the client.
        locale: The locale of the client.
        lines_start_at1: Whether the lines start at 1.
        columns_start_at1: Whether the columns start at 1.
        path_format: The format of the paths.
    """

    self._seq: int = 1
    self._send_buf = bytearray()
    self._receive_buf = bytearray()
    self._pending_requests: dict[int, Request] = {}

    self.handler = Handler(self)

    self.initialize(
        adapter_id=adapter_id,
        client_id=client_id,
        client_name=client_name,
        locale=locale,
        lines_start_at1=lines_start_at1,
        columns_start_at1=columns_start_at1,
        path_format=path_format,
        supports_variable_type=True,
        supports_variable_paging=True,
        supports_run_in_terminal_request=True,
        supports_memory_references=True,
        supports_progress_reporting=True,
        supports_invalidated_event=True,
        supports_memory_event=True,
        supports_args_can_be_interpreted_by_shell=True,
        supports_start_debugging_request=True,
    )

attach(__restart=None)

attach to a running process.

Parameters:

Name Type Description Default
__restart Optional[Any]

Arbitrary data from the previous, restarted session. The data is sent as the restart attribute of the terminated event.

None
Source code in src\dap\client.py
136
137
138
139
140
141
142
143
def attach(self, __restart: Optional[Any] = None) -> int:
    """attach to a running process.

    Args:
        __restart: Arbitrary data from the previous, restarted session. \
            The data is sent as the `restart` attribute of the `terminated` event."""

    return self.send_request("attach", {"__restart": __restart})

breakpoint_locations(source, line, column=None, end_line=None, end_column=None)

Retrieve all possible locations for source breakpoints in a given range.

Parameters:

Name Type Description Default
source Source

The source location of the breakpoints.

required
line int

The source line of the breakpoints.

required
column Optional[int]

An optional source column of the breakpoints.

None
end_line Optional[int]

An optional end line of the range covered by the breakpoint.

None
end_column Optional[int]

An optional end column of the range covered by the breakpoint.

None
Source code in src\dap\client.py
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
def breakpoint_locations(
    self,
    source: Source,
    line: int,
    column: Optional[int] = None,
    end_line: Optional[int] = None,
    end_column: Optional[int] = None,
) -> int:
    """Retrieve all possible locations for source breakpoints in a given range.

    Args:
        source: The source location of the breakpoints.
        line: The source line of the breakpoints.
        column: An optional source column of the breakpoints.
        end_line: An optional end line of the range covered by the breakpoint.
        end_column: An optional end column of the range covered by the breakpoint.
    """

    return self.send_request(
        "breakpointLocations",
        {
            "source": source,
            "line": line,
            "column": column,
            "endLine": end_line,
            "endColumn": end_column,
        },
    )

cancel(request_id=None, progress_id=None)

The cancel request is used by the client in two situations:

  • to indicate that it is no longer interested in the result produced by a specific request issued earlier
  • to cancel a progress sequence.

Both progress_id and request_id CAN BE specified in the same request.

Parameters:

Name Type Description Default
request_id Optional[int]

The ID (_seq) of the request to cancel. If missing no request is canceled.

None
progress_id Optional[str]

The progress ID of the progress sequence to cancel. If missing no progress is canceled.

None
Source code in src\dap\client.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
def cancel(
    self, request_id: Optional[int] = None, progress_id: Optional[str] = None
) -> int:
    """The cancel request is used by the client in two situations:

    - to indicate that it is no longer interested in the result produced by a specific request issued earlier
    - to cancel a progress sequence.

    Both `progress_id` and `request_id` CAN BE specified in the same request.

    Args:
        request_id: The ID (_seq) of the request to cancel. If missing no request is canceled.
        progress_id: The progress ID of the progress sequence to cancel. If missing no progress is canceled.
    """

    return self.send_request(
        "cancel", {"requestId": request_id, "progressId": progress_id}
    )

completions(text, column, line, frame_id=None)

Returns a list of possible completions for a given caret position and text.

Parameters:

Name Type Description Default
text str

One or more source lines. Typically this is the text users have typed into the debug console before they asked for completion.

required
column int

The position within text for which to determine the completion proposals.

required
line Optional[int]

A line for which to determine the completion proposals. If missing the first line of the text is assumed.

required
frame_id Optional[int]

An optional frameId of the stack frame, if specified returns completions in the scope of this stack frame.

None
Source code in src\dap\client.py
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
def completions(
    self,
    text: str,
    column: int,
    line: Optional[int],
    frame_id: Optional[int] = None,
) -> int:
    """Returns a list of possible completions for a given caret position and text.

    Args:
        text: One or more source lines. Typically this is the text users have typed into \
            the debug console before they asked for completion.
        column: The position within `text` for which to determine the completion proposals.
        line: A line for which to determine the completion proposals. If missing the \
            first line of the text is assumed.
        frame_id: An optional frameId of the stack frame, if specified returns \
            completions in the scope of this stack frame.
    """

    return self.send_request(
        "completions",
        {
            "frameId": frame_id,
            "text": text,
            "column": column,
            "line": line,
        },
    )

configuration_done()

This request indicates that the client has finished initialization of the debug adapter.

Source code in src\dap\client.py
203
204
205
206
def configuration_done(self) -> int:
    """This request indicates that the client has finished initialization of the debug adapter."""

    return self.send_request("configurationDone")

continue_(thread_id, single_thread=None)

The request resumes execution of all threads. If the debug adapter supports single thread execution, setting single_thread true resumes only the specified thread.

Parameters:

Name Type Description Default
thread_id int

the active thread.

required
single_thread Optional[bool]

Execute only this thread.

None
Source code in src\dap\client.py
208
209
210
211
212
213
214
215
216
217
218
219
def continue_(self, thread_id: int, single_thread: Optional[bool] = None) -> int:
    """The request resumes execution of all threads.
    If the debug adapter supports single thread execution, setting `single_thread` true resumes only the specified thread.

    Args:
        thread_id: the active thread.
        single_thread: Execute only this thread.
    """

    return self.send_request(
        "continue", {"threadId": thread_id, "singleThread": single_thread}
    )

data_breakpoint_info(name, variables_reference=None, frameId=None, bytes=None, asAddress=None, mode=None)

Retrieve the information of a data breakpoint.

Parameters:

Name Type Description Default
variables_reference Optional[int]

Reference to the variable container if the data breakpoint is requested for a child of the container.

None
name str

The name of the variable's child to obtain data breakpoint information for.

required
frameId Optional[int]

When name is an expression, evaluate it in the scope of this stack frame.

None
bytes Optional[int]

If specified, a debug adapter should return information for the range of memory extending bytes number of bytes from the address or variable specified by name. Breakpoints set using the resulting data ID should pause on data access anywhere within that range.

None
asAddress Optional[bool]

If true, name is an address.

None
mode Optional[str]

The mode of the desired breakpoint.

None
Source code in src\dap\client.py
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
def data_breakpoint_info(
    self,
    name: str,
    variables_reference: Optional[int] = None,
    frameId: Optional[int] = None,
    bytes: Optional[int] = None,
    asAddress: Optional[bool] = None,
    mode: Optional[str] = None,
) -> int:
    """Retrieve the information of a data breakpoint.

    Args:
        variables_reference: Reference to the variable container if the data breakpoint is requested for \
            a child of the container.
        name: The name of the variable's child to obtain data breakpoint information for.
        frameId: When `name` is an expression, evaluate it in the scope of this stack frame.
        bytes: If specified, a debug adapter should return information for the range of memory extending \
            `bytes` number of bytes from the address or variable specified by `name`. \
            Breakpoints set using the resulting data ID should pause on data access anywhere within that range.
        asAddress: If true, `name` is an address.
        mode: The mode of the desired breakpoint.
    """

    return self.send_request(
        "dataBreakpointInfo",
        {
            "variablesReference": variables_reference,
            "name": name,
            "frameId": frameId,
            "bytes": bytes,
            "asAddress": asAddress,
            "mode": mode,
        },
    )

disassemble(memory_reference, instruction_count=None, offset=None, instruction_offset=None, resolve_symbols=None)

Disassembles code stored at the provided location.

Parameters:

Name Type Description Default
memory_reference str

Memory reference to the base location containing the instructions to disassemble.

required
instruction_count Optional[int]

The number of instructions to disassemble starting at the specified location and offset.

None
offset Optional[int]

The offset (in bytes) of the first instruction to disassemble.

None
instruction_offset Optional[int]

The offset (in instructions) of the first instruction to disassemble.

None
resolve_symbols Optional[bool]

If set to true, the adapter should attempt to resolve memory addresses to function names and line numbers.

None
Source code in src\dap\client.py
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
def disassemble(
    self,
    memory_reference: str,
    instruction_count: Optional[int] = None,
    offset: Optional[int] = None,
    instruction_offset: Optional[int] = None,
    resolve_symbols: Optional[bool] = None,
) -> int:
    """Disassembles code stored at the provided location.

    Args:
        memory_reference: Memory reference to the base location containing the instructions to disassemble.
        instruction_count: The number of instructions to disassemble starting at the specified location and offset.
        offset: The offset (in bytes) of the first instruction to disassemble.
        instruction_offset: The offset (in instructions) of the first instruction to disassemble.
        resolve_symbols: If set to true, the adapter should attempt to resolve memory addresses \
            to function names and line numbers.
    """

    return self.send_request(
        "disassemble",
        {
            "memoryReference": memory_reference,
            "offset": offset,
            "instructionCount": instruction_count,
        },
    )

disconnect(restart=None, terminal_debuggee=None, suspend_debuggee=None)

Asks the debug adapter to disconnect from the debuggee (thus ending the debug session) and then to shut down.

In addition, the debug adapter must terminate the debuggee if it was started with the launch request. If an attach request was used to connect to the debuggee, then the debug adapter must not terminate the debuggee.

Parameters:

Name Type Description Default
restart Optional[bool]

A value of true indicates that this 'disconnect' request is part of a restart sequence.

None
terminal_debuggee Optional[bool]

Indicates whether the debuggee should be terminated when the debugger is disconnected.

None
suspend_debuggee Optional[bool]

Indicates whether the debuggee should be allowed to run after the debugger is disconnected.

None
Source code in src\dap\client.py
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
def disconnect(
    self,
    restart: Optional[bool] = None,
    terminal_debuggee: Optional[bool] = None,
    suspend_debuggee: Optional[bool] = None,
) -> int:
    """Asks the debug adapter to disconnect from the debuggee (thus ending the debug session) and then to shut down.

    In addition, the debug adapter must terminate the debuggee if it was started with the launch request.
    If an attach request was used to connect to the debuggee, then the debug adapter must not terminate the debuggee.

    Args:
        restart: A value of true indicates that this 'disconnect' request is part of a restart sequence.
        terminal_debuggee: Indicates whether the debuggee should be terminated when the debugger is disconnected.
        suspend_debuggee: Indicates whether the debuggee should be allowed to run after the debugger is disconnected.
    """

    return self.send_request(
        "disconnect",
        {
            "restart": restart,
            "terminateDebuggee": terminal_debuggee,
            "suspendDebuggee": suspend_debuggee,
        },
    )

evaluate(expression, frame_id=None, line=None, column=None, source=None, context=None, format=None)

Evaluate the given expression in the context of topmost stack frame. The expression has access to any variables and arguments that are in scope.

Parameters:

Name Type Description Default
expression str

The expression to evaluate.

required
frame_id Optional[int]

Evaluate the expression in the scope of this stack frame. If not specified, the expression is evaluated in the global scope.

None
line Optional[int]

The contextual line where the expression should be evaluated. In the 'hover' context, this should be set to the start of the expression being hovered.

None
column Optional[int]

The contextual column where the expression should be evaluated. This may be provided if line is also provided.

None
source Optional[Source]

The contextual source in which the line is found. This must be provided if line is provided.

None
context Optional[Literal[watch, repl, hover, clipboard, variables] | str]

The context in which the evaluate request is used.

None
format Optional[ValueFormat]

Specifies details on how to format the result.

None
Source code in src\dap\client.py
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
def evaluate(
    self,
    expression: str,
    frame_id: Optional[int] = None,
    line: Optional[int] = None,
    column: Optional[int] = None,
    source: Optional[Source] = None,
    context: Optional[
        Literal["watch", "repl", "hover", "clipboard", "variables"] | str
    ] = None,
    format: Optional[ValueFormat] = None,
) -> int:
    """Evaluate the given expression in the context of topmost stack frame.
    The expression has access to any variables and arguments that are in scope.

    Args:
        expression: The expression to evaluate.
        frame_id: Evaluate the expression in the scope of this stack frame. \
            If not specified, the expression is evaluated in the global scope.
        line: The contextual line where the expression should be evaluated. \
            In the 'hover' context, this should be set to the start of the expression being hovered.
        column: The contextual column where the expression should be evaluated. \
            This may be provided if `line` is also provided.
        source: The contextual source in which the `line` is found. \
            This must be provided if `line` is provided.
        context: The context in which the evaluate request is used.
        format: Specifies details on how to format the result.
    """

    return self.send_request(
        "evaluate",
        {
            "expression": expression,
            "frameId": frame_id,
            "line": line,
            "column": column,
            "source": source,
            "context": context,
            "format": format,
        },
    )

exception_info(thread_id)

Retrieves the details of the exception that caused this event to be raised.

Parameters:

Name Type Description Default
thread_id int

Thread for which exception information should be retrieved.

required
Source code in src\dap\client.py
352
353
354
355
356
357
358
359
def exception_info(self, thread_id: int) -> int:
    """Retrieves the details of the exception that caused this event to be raised.

    Args:
        thread_id: Thread for which exception information should be retrieved.
    """

    return self.send_request("exceptionInfo", {"threadId": thread_id})

goto(thread_id, target_id)

The request sets the location where the debuggee will continue to run.

Parameters:

Name Type Description Default
thread_id int

The thread to continue.

required
target_id str

The location where the debuggee will continue to run.

required
Source code in src\dap\client.py
361
362
363
364
365
366
367
368
369
def goto(self, thread_id: int, target_id: str) -> int:
    """The request sets the location where the debuggee will continue to run.

    Args:
        thread_id: The thread to continue.
        target_id: The location where the debuggee will continue to run.
    """

    return self.send_request("goto", {"threadId": thread_id, "targetId": target_id})

goto_targets(source, line, column=None)

Retrieve possible goto targets for the specified location.

Parameters:

Name Type Description Default
source Source

The source location for which the goto targets are determined.

required
line int

The line for which the goto targets are determined.

required
column Optional[int]

An optional column for which the goto targets are determined.

None
Source code in src\dap\client.py
371
372
373
374
375
376
377
378
379
380
381
382
383
384
def goto_targets(
    self, source: Source, line: int, column: Optional[int] = None
) -> int:
    """Retrieve possible goto targets for the specified location.

    Args:
        source: The source location for which the goto targets are determined.
        line: The line for which the goto targets are determined.
        column: An optional column for which the goto targets are determined.
    """

    return self.send_request(
        "gotoTargets", {"source": source, "line": line, "column": column}
    )

initialize(adapter_id, client_id=None, client_name=None, locale=None, lines_start_at1=None, columns_start_at1=None, path_format=None, supports_variable_type=None, supports_variable_paging=None, supports_run_in_terminal_request=None, supports_memory_references=None, supports_progress_reporting=None, supports_invalidated_event=None, supports_memory_event=None, supports_args_can_be_interpreted_by_shell=None, supports_start_debugging_request=None)

Initializes the debug adapter with the client capabilities.

Source code in src\dap\client.py
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
def initialize(
    self,
    adapter_id: str,
    client_id: Optional[str] = None,
    client_name: Optional[str] = None,
    locale: Optional[str] = None,
    lines_start_at1: Optional[bool] = None,
    columns_start_at1: Optional[bool] = None,
    path_format: Optional[Literal["path", "uri"] | str] = None,
    supports_variable_type: Optional[bool] = None,
    supports_variable_paging: Optional[bool] = None,
    supports_run_in_terminal_request: Optional[bool] = None,
    supports_memory_references: Optional[bool] = None,
    supports_progress_reporting: Optional[bool] = None,
    supports_invalidated_event: Optional[bool] = None,
    supports_memory_event: Optional[bool] = None,
    supports_args_can_be_interpreted_by_shell: Optional[bool] = None,
    supports_start_debugging_request: Optional[bool] = None,
) -> int:
    """Initializes the debug adapter with the client capabilities."""

    return self.send_request(
        "initialize",
        {
            "adapterID": adapter_id,
            "clientID": client_id,
            "clientName": client_name,
            "locale": locale,
            "linesStartAt1": lines_start_at1,
            "columnsStartAt1": columns_start_at1,
            "pathFormat": path_format,
            "supportsVariableType": supports_variable_type,
            "supportsVariablePaging": supports_variable_paging,
            "supportsRunInTerminalRequest": supports_run_in_terminal_request,
            "supportsMemoryReferences": supports_memory_references,
            "supportsProgressReporting": supports_progress_reporting,
            "supportsInvalidatedEvent": supports_invalidated_event,
            "supportsMemoryEvent": supports_memory_event,
            "supportsArgsCanBeInterpretedByShell": supports_args_can_be_interpreted_by_shell,
            "supportsStartDebuggingRequest": supports_start_debugging_request,
        },
    )

launch(no_debug=None, __restart=None)

The launch request is used to start the debuggee with or without debugging enabled.

Parameters:

Name Type Description Default
no_debug Optional[bool]

Set to true if the launch request is used to just start the debuggee for the purpose of collecting output. The debuggee is not supposed to stop at breakpoints.

None
__restart Optional[Any]

Arbitrary data from the previous, restarted session. The data is sent as the restart attribute of the terminated event.

None
Source code in src\dap\client.py
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
def launch(
    self,
    no_debug: Optional[bool] = None,
    __restart: Optional[Any] = None,
) -> int:
    """The launch request is used to start the debuggee with or without debugging enabled.

    Args:
        no_debug: Set to true if the launch request is used to just start the debuggee \
            for the purpose of collecting output. The debuggee is not supposed to stop at breakpoints.
        __restart: Arbitrary data from the previous, restarted session. \
            The data is sent as the `restart` attribute of the `terminated` event.
    """

    return self.send_request(
        "launch",
        {"noDebug": no_debug, "__restart": __restart},
    )

loaded_sources()

Retrieves the set of all sources currently loaded by the debugged process.

Source code in src\dap\client.py
448
449
450
451
def loaded_sources(self) -> int:
    """Retrieves the set of all sources currently loaded by the debugged process."""

    return self.send_request("loadedSources")

modules(start_module=None, module_count=None)

Modules can be retrieved from the debug adapter with this request which can either return all modules or a range of modules to support paging.

Parameters:

Name Type Description Default
start_module Optional[int]

The 0-based index of the first module to return; if omitted modules start at 0.

None
module_count Optional[int]

The number of modules to return. If moduleCount is not specified or 0, all modules are returned.

None
Source code in src\dap\client.py
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
def modules(
    self, start_module: Optional[int] = None, module_count: Optional[int] = None
) -> int:
    """Modules can be retrieved from the debug adapter with this request which can either
    return all modules or a range of modules to support paging.

    Args:
        start_module: The 0-based index of the first module to return; if omitted modules start at 0.
        module_count: The number of modules to return. If moduleCount is not specified or 0, \
            all modules are returned.
    """

    return self.send_request(
        "modules", {"startModule": start_module, "moduleCount": module_count}
    )

next(thread_id, single_thread=None, granularity=None)

The request steps through the program.

Parameters:

Name Type Description Default
thread_id int

Specifies the thread for which to resume execution for one step.

required
single_thread Optional[bool]

If this is true, all other suspended threads are not resumed.

None
granularity Optional[str]

The granularity of the step, assumed to be 'statement' if not specified.

None
Source code in src\dap\client.py
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
def next(
    self,
    thread_id: int,
    single_thread: Optional[bool] = None,
    granularity: Optional[str] = None,
) -> int:
    """The request steps through the program.

    Args:
        thread_id: Specifies the thread for which to resume execution for one step.
        single_thread: If this is true, all other suspended threads are not resumed.
        granularity: The granularity of the step, assumed to be 'statement' if not specified.
    """

    return self.send_request(
        "next",
        {
            "threadId": thread_id,
            "singleThread": single_thread,
            "granularity": granularity,
        },
    )

pause(thread_id)

Suspends the debuggee.

Parameters:

Name Type Description Default
thread_id int

The thread to pause.

required
Source code in src\dap\client.py
492
493
494
495
496
497
498
499
def pause(self, thread_id: int) -> int:
    """Suspends the debuggee.

    Args:
        thread_id: The thread to pause.
    """

    return self.send_request("pause", {"threadId": thread_id})

read_memory(memory_reference, count, offset=None)

Reads memory from the debuggee.

Parameters:

Name Type Description Default
memory_reference str

The memory reference to the base location from which to read memory.

required
count int

The number of bytes to read at the specified location and offset.

required
offset Optional[int]

The offset (in bytes) of the first byte to read.

None
Source code in src\dap\client.py
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
def read_memory(
    self, memory_reference: str, count: int, offset: Optional[int] = None
) -> int:
    """Reads memory from the debuggee.

    Args:
        memory_reference: The memory reference to the base location from which to read memory.
        count: The number of bytes to read at the specified location and offset.
        offset: The offset (in bytes) of the first byte to read.
    """

    return self.send_request(
        "readMemory",
        {"memoryReference": memory_reference, "offset": offset, "count": count},
    )

receive(data)

Feed data from the debug adapter to the client.

Parameters:

Name Type Description Default
data bytes

The data to receive.

required

Yields:

Type Description
ResponseBody | EventBody

The response or event body.

Source code in src\dap\client.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
def receive(self, data: bytes) -> Generator[ResponseBody | EventBody, None, None]:
    """Feed data from the debug adapter to the client.

    Args:
        data: The data to receive.

    Yields:
        The response or event body.
    """

    self._receive_buf += data
    yield from self.handler.handle()

restart(arguments=None)

Restarts a debug session.

Parameters:

Name Type Description Default
arguments Optional[LaunchRequestArguments | AttachRequestArguments]

Use either arguments for the 'launch' or 'attach' request.

None
Source code in src\dap\client.py
517
518
519
520
521
522
523
524
525
526
527
def restart(
    self,
    arguments: Optional[LaunchRequestArguments | AttachRequestArguments] = None,
) -> int:
    """Restarts a debug session.

    Args:
        arguments: Use either arguments for the 'launch' or 'attach' request.
    """

    return self.send_request("restart", arguments)

restart_frame(frame_id)

Restart the stack frame identified by the given frame ID. The frame ID must have been obtained in the current suspended state.

Parameters:

Name Type Description Default
frame_id int

The frame to restart.

required
Source code in src\dap\client.py
529
530
531
532
533
534
535
536
537
def restart_frame(self, frame_id: int) -> int:
    """Restart the stack frame identified by the given frame ID.
    The frame ID must have been obtained in the current suspended state.

    Args:
        frame_id: The frame to restart.
    """

    return self.send_request("restartFrame", {"frameId": frame_id})

reverse_continue(thread_id, single_thread=None)

The request starts the debuggee to run backward.

Parameters:

Name Type Description Default
thread_id int

ID of the active thread.

required
single_thread Optional[bool]

If true, backward execution is limited to the specified thread.

None
Source code in src\dap\client.py
539
540
541
542
543
544
545
546
547
548
549
550
551
552
def reverse_continue(
    self, thread_id: int, single_thread: Optional[bool] = None
) -> int:
    """The request starts the debuggee to run backward.

    Args:
        thread_id: ID of the active thread.
        single_thread: If true, backward execution is limited to the specified thread.
    """

    return self.send_request(
        "reverseContinue",
        {"threadId": thread_id, "singleThread": single_thread},
    )

scopes(frame_id)

The request returns the variable scopes for a given stack frame.

Parameters:

Name Type Description Default
frame_id int

Retrieve the scopes for this stackframe.

required
Source code in src\dap\client.py
554
555
556
557
558
559
560
561
def scopes(self, frame_id: int) -> int:
    """The request returns the variable scopes for a given stack frame.

    Args:
        frame_id: Retrieve the scopes for this stackframe.
    """

    return self.send_request("scopes", {"frameId": frame_id})

send()

Get the data to send to the debug adapter.

Returns:

Type Description
bytes

The data to send.

Source code in src\dap\client.py
105
106
107
108
109
110
111
112
113
114
def send(self) -> bytes:
    """Get the data to send to the debug adapter.

    Returns:
        The data to send.
    """

    send_buf = self._send_buf
    self._send_buf = bytearray()
    return send_buf

send_request(command, arguments=None)

Send a request to the debug adapter.

This can be useful for sending requests that are not yet implemented in the client or for sending custom requests to the debug adapter that are specific to the adapter.

Parameters:

Name Type Description Default
command str

The command to send.

required
arguments Optional[dict[str, Any]]

The arguments to send.

None

Returns:

Type Description
int

The sequence number of the request.

Source code in src\dap\client.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
def send_request(
    self, command: str, arguments: Optional[dict[str, Any]] = None
) -> int:
    """Send a request to the debug adapter.

    This can be useful for sending requests that are not yet implemented in the client or
    for sending custom requests to the debug adapter that are specific to the adapter.

    Args:
        command: The command to send.
        arguments: The arguments to send.

    Returns:
        The sequence number of the request.
    """

    seq = self._seq
    self._seq += 1

    self._send_buf += RequestBuffer(seq, command, arguments)
    self._pending_requests[seq] = Request(
        seq=seq, command=command, arguments=arguments
    )
    return seq

set_breakpoints(source, breakpoints, lines=None, source_modified=None)

Sets multiple breakpoints for a single source and clears all previous breakpoints in that source.

Parameters:

Name Type Description Default
source Source

The source location of the breakpoints.

required
breakpoints List[SourceBreakpoint]

The code locations of the breakpoints.

required
lines Optional[List[int]]

Deprecated: The code locations of the breakpoints.

None
source_modified Optional[bool]

A value of true indicates that the underlying source has been modified which results in new breakpoint locations.

None
Source code in src\dap\client.py
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
def set_breakpoints(
    self,
    source: Source,
    breakpoints: List[SourceBreakpoint],
    lines: Optional[List[int]] = None,
    source_modified: Optional[bool] = None,
) -> int:
    """Sets multiple breakpoints for a single source and clears all previous breakpoints in that source.

    Args:
        source: The source location of the breakpoints.
        breakpoints: The code locations of the breakpoints.
        lines: Deprecated: The code locations of the breakpoints.
        source_modified: A value of true indicates that the underlying source has been modified \
            which results in new breakpoint locations.
    """

    return self.send_request(
        "setBreakpoints",
        {
            "source": source,
            "breakpoints": breakpoints,
            "lines": lines,
            "sourceModified": source_modified,
        },
    )

set_data_breakpoints(breakpoints)

Replaces all existing data breakpoints with new data breakpoints.

Parameters:

Name Type Description Default
breakpoints List[DataBreakpoint]

The data breakpoints to set.

required
Source code in src\dap\client.py
590
591
592
593
594
595
596
597
def set_data_breakpoints(self, breakpoints: List[DataBreakpoint]) -> int:
    """Replaces all existing data breakpoints with new data breakpoints.

    Args:
        breakpoints: The data breakpoints to set.
    """

    return self.send_request("setDataBreakpoints", {"breakpoints": breakpoints})

set_exception_breakpoints(filters, filter_options, exception_options)

The request configures the debugger's response to thrown exceptions.

Each of the filters, filterOptions, and exceptionOptions in the request are independent configurations to a debug adapter indicating a kind of exception to catch. An exception thrown in a program should result in a stopped event from the debug adapter (with reason exception) if any of the configured filters match.

Parameters:

Name Type Description Default
filters List[str]

Set of exception filters specified by their ID.

required
filter_options Optional[List[ExceptionFilterOptions]]

An array of ExceptionFilterOptions. The set of all possible exception filters is defined by the exceptionBreakpointFilters capability.

required
exception_options Optional[List[ExceptionOptions]]

An array of ExceptionOptions. Configuration options for selected exceptions.

required
Source code in src\dap\client.py
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
def set_exception_breakpoints(
    self,
    filters: List[str],
    filter_options: Optional[List[ExceptionFilterOptions]],
    exception_options: Optional[List[ExceptionOptions]],
) -> int:
    """The request configures the debugger's response to thrown exceptions.

    Each of the filters, filterOptions, and exceptionOptions in the request are independent configurations
    to a debug adapter indicating a kind of exception to catch. An exception thrown in a program should result
    in a stopped event from the debug adapter (with reason exception) if any of the configured filters match.

    Args:
        filters: Set of exception filters specified by their ID.
        filter_options: An array of ExceptionFilterOptions. The set of all possible exception filters \
            is defined by the `exceptionBreakpointFilters` capability.
        exception_options: An array of ExceptionOptions. Configuration options for selected exceptions.
    """

    return self.send_request(
        "setExceptionBreakpoints",
        {
            "filters": filters,
            "filterOptions": filter_options,
            "exceptionOptions": exception_options,
        },
    )

set_expression(expression, value, frame_id=None, format=None)

Evaluates the given value expression and assigns it to the expression which must be a modifiable l-value.

The expressions have access to any variables and arguments that are in scope of the specified frame.

Parameters:

Name Type Description Default
expression str

The l-value expression to assign the result to.

required
value str

The value expression to assign to the l-value expression.

required
frame_id Optional[int]

Evaluate the expressions in the scope of this stack frame. If not specified, the expressions are evaluated in the global scope.

None
format Optional[ValueFormat]

Specifies details on how to format the result.

None
Source code in src\dap\client.py
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
def set_expression(
    self,
    expression: str,
    value: str,
    frame_id: Optional[int] = None,
    format: Optional[ValueFormat] = None,
) -> int:
    """Evaluates the given value expression and assigns it to the expression which must be a modifiable l-value.

    The expressions have access to any variables and arguments that are in scope of the specified frame.

    Args:
        expression: The l-value expression to assign the result to.
        value: The value expression to assign to the l-value expression.
        frame_id: Evaluate the expressions in the scope of this stack frame. \
            If not specified, the expressions are evaluated in the global scope.
        format: Specifies details on how to format the result.
    """

    return self.send_request(
        "setExpression",
        {
            "expression": expression,
            "value": value,
            "frameId": frame_id,
            "format": format,
        },
    )

set_function_breakpoints(breakpoints=[])

Replaces all existing function breakpoints with new function breakpoints.

To clear all function breakpoints, call this without arguments. When a function breakpoint is hit, a stopped event (with reason function breakpoint) is generated.

Parameters:

Name Type Description Default
breakpoints List[FunctionBreakpoint]

The function breakpoints to set.

[]
Source code in src\dap\client.py
656
657
658
659
660
661
662
663
664
665
666
667
668
def set_function_breakpoints(
    self, breakpoints: List[FunctionBreakpoint] = []
) -> int:
    """Replaces all existing function breakpoints with new function breakpoints.

    To clear all function breakpoints, call this without arguments.
    When a function breakpoint is hit, a stopped event (with reason function breakpoint) is generated.

    Args:
        breakpoints: The function breakpoints to set.
    """

    return self.send_request("setFunctionBreakpoints", {"breakpoints": breakpoints})

set_instruction_breakpoints(breakpoints)

Replaces all existing instruction breakpoints. Typically, instruction breakpoints would be set from a disassembly window.

To clear all instruction breakpoints, specify an empty array. When an instruction breakpoint is hit, a stopped event (with reason instruction breakpoint) is generated.

Parameters:

Name Type Description Default
breakpoints List[InstructionBreakpoint]

The instruction breakpoints to set.

required
Source code in src\dap\client.py
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
def set_instruction_breakpoints(
    self, breakpoints: List[InstructionBreakpoint]
) -> int:
    """Replaces all existing instruction breakpoints. Typically, instruction breakpoints would be set from a disassembly window.

    To clear all instruction breakpoints, specify an empty array.
    When an instruction breakpoint is hit, a stopped event (with reason instruction breakpoint) is generated.

    Args:
        breakpoints: The instruction breakpoints to set.
    """

    return self.send_request(
        "setInstructionBreakpoints", {"breakpoints": breakpoints}
    )

set_variable(variables_reference, name, value, format=None)

Set the variable with the given name in the variable container to a new value.

Parameters:

Name Type Description Default
variables_reference int

The reference of the variable container.

required
name str

The name of the variable to set.

required
value str

The value to set.

required
format Optional[ValueFormat]

Specifies details on how to format the response value.

None
Source code in src\dap\client.py
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
def set_variable(
    self,
    variables_reference: int,
    name: str,
    value: str,
    format: Optional[ValueFormat] = None,
) -> int:
    """Set the variable with the given name in the variable container to a new value.

    Args:
        variables_reference: The reference of the variable container.
        name: The name of the variable to set.
        value: The value to set.
        format: Specifies details on how to format the response value.
    """

    return self.send_request(
        "setVariable",
        {
            "variablesReference": variables_reference,
            "name": name,
            "value": value,
            "format": format,
        },
    )

source(source_reference, source=None)

The request retrieves the source code for a given source reference.

Parameters:

Name Type Description Default
source_reference int

The reference to the source. This is the same as source.sourceReference.

required
source Optional[Source]

Specifies the source content to load. Either source.path or source.sourceReference must be specified.

None
Source code in src\dap\client.py
712
713
714
715
716
717
718
719
720
721
722
def source(self, source_reference: int, source: Optional[Source] = None) -> int:
    """The request retrieves the source code for a given source reference.

    Args:
        source_reference: The reference to the source. This is the same as `source.sourceReference`.
        source: Specifies the source content to load. Either `source.path` or `source.sourceReference` must be specified.
    """

    return self.send_request(
        "source", {"sourceReference": source_reference, "source": source}
    )

stack_trace(thread_id=None, start_frame=None, levels=None, format=None)

The request returns a stack trace from the current execution state.

Request all stack frames by omitting the startFrame and levels arguments.

Parameters:

Name Type Description Default
thread_id Optional[int]

Retrieve the stacktrace for this thread.

None
start_frame Optional[int]

The index of the first frame to return; if omitted frames start at 0.

None
levels Optional[int]

The maximum number of frames to return. If levels is not specified or 0, all frames are returned.

None
format Optional[StackFrameFormat]

Specifies details on how to format the stack frames.

None
Source code in src\dap\client.py
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
def stack_trace(
    self,
    thread_id: Optional[int] = None,
    start_frame: Optional[int] = None,
    levels: Optional[int] = None,
    format: Optional[StackFrameFormat] = None,
) -> int:
    """The request returns a stack trace from the current execution state.

    Request all stack frames by omitting the startFrame and levels arguments.

    Args:
        thread_id: Retrieve the stacktrace for this thread.
        start_frame: The index of the first frame to return; if omitted frames start at 0.
        levels: The maximum number of frames to return. If levels is not specified or 0, all frames are returned.
        format: Specifies details on how to format the stack frames.
    """

    return self.send_request(
        "stackTrace",
        {
            "threadId": thread_id,
            "startFrame": start_frame,
            "levels": levels,
            "format": format,
        },
    )

step_back(thread_id, single_thread=None, granularity=None)

The request executes one backward step (in the given granularity) for the specified thread and allows all other threads to run backward freely by resuming them.

If the debug adapter supports single thread execution (see capability supportsSingleThreadExecutionRequests), setting the singleThread argument to true prevents other suspended threads from resuming. The debug adapter first sends the response and then a stopped event (with reason step) after the step has completed.

Parameters:

Name Type Description Default
thread_id int

ID of the active thread.

required
single_thread Optional[bool]

If true, backward execution is limited to the specified thread.

None
granularity Optional[SteppingGranularity]

The granularity of the step, assumed to be 'statement' if not specified.

None
Source code in src\dap\client.py
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
def step_back(
    self,
    thread_id: int,
    single_thread: Optional[bool] = None,
    granularity: Optional[SteppingGranularity] = None,
) -> int:
    """The request executes one backward step (in the given granularity) for the specified thread
    and allows all other threads to run backward freely by resuming them.

    If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`),
    setting the singleThread argument to true prevents other suspended threads from resuming.
    The debug adapter first sends the response and then a stopped event (with reason step) after the step has completed.

    Args:
        thread_id: ID of the active thread.
        single_thread: If true, backward execution is limited to the specified thread.
        granularity: The granularity of the step, assumed to be 'statement' if not specified.
    """

    return self.send_request(
        "stepBack",
        {
            "threadId": thread_id,
            "singleThread": single_thread,
            "granularity": granularity,
        },
    )

step_in(thread_id, single_thread=None, target_id=None, granularity=None)

The request resumes the given thread to step into a function/method and allows all other threads to run freely by resuming them.

If the debug adapter supports single thread execution (see capability supportsSingleThreadExecutionRequests), setting the singleThread argument to true prevents other suspended threads from resuming.

If the request cannot step into a target, stepIn behaves like the next request. The debug adapter first sends the response and then a stopped event (with reason step) after the step has completed.

If there are multiple function/method calls (or other targets) on the source line, the argument targetId can be used to control into which target the stepIn should occur.

Parameters:

Name Type Description Default
thread_id int

ID of the active thread.

required
single_thread Optional[bool]

If true, stepIn is limited to the specified thread.

None
target_id Optional[int]

The stepIn target for this step.

None
granularity Optional[SteppingGranularity]

The granularity of the step, assumed to be 'statement' if not specified.

None
Source code in src\dap\client.py
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
def step_in(
    self,
    thread_id: int,
    single_thread: Optional[bool] = None,
    target_id: Optional[int] = None,
    granularity: Optional[SteppingGranularity] = None,
) -> int:
    """The request resumes the given thread to step into a function/method and allows all other threads to run freely by resuming them.

    If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`),
    setting the singleThread argument to true prevents other suspended threads from resuming.

    If the request cannot step into a target, stepIn behaves like the next request.
    The debug adapter first sends the response and then a stopped event (with reason step) after the step has completed.

    If there are multiple function/method calls (or other targets) on the source line,
    the argument targetId can be used to control into which target the stepIn should occur.

    Args:
        thread_id: ID of the active thread.
        single_thread: If true, stepIn is limited to the specified thread.
        target_id: The stepIn target for this step.
        granularity: The granularity of the step, assumed to be 'statement' if not specified.
    """

    return self.send_request(
        "stepIn",
        {
            "threadId": thread_id,
            "singleThread": single_thread,
            "targetId": target_id,
            "granularity": granularity,
        },
    )

step_in_targets(frame_id)

The request retrieves the possible stepIn targets for the specified stack frame. These targets can be used in the stepIn request.

Parameters:

Name Type Description Default
frame_id int

The stack frame for which to retrieve the possible stepIn targets.

required
Source code in src\dap\client.py
815
816
817
818
819
820
821
822
823
def step_in_targets(self, frame_id: int) -> int:
    """The request retrieves the possible stepIn targets for the specified stack frame.
    These targets can be used in the stepIn request.

    Args:
        frame_id: The stack frame for which to retrieve the possible stepIn targets.
    """

    return self.send_request("stepInTargets", {"frameId": frame_id})

step_out(thread_id, single_thread=None, granularity=None)

The request resumes the given thread to step out of the current function/method and allows all other threads to run freely by resuming them.

If the debug adapter supports single thread execution (see capability supportsSingleThreadExecutionRequests), setting the singleThread argument to true prevents other suspended threads from resuming.

The debug adapter first sends the response and then a stopped event (with reason step) after the step has completed.

Parameters:

Name Type Description Default
thread_id int

ID of the active thread.

required
single_thread Optional[bool]

If true, stepOut is limited to the specified thread.

None
granularity Optional[SteppingGranularity]

The granularity of the step, assumed to be 'statement' if not specified.

None
Source code in src\dap\client.py
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
def step_out(
    self,
    thread_id: int,
    single_thread: Optional[bool] = None,
    granularity: Optional[SteppingGranularity] = None,
) -> int:
    """The request resumes the given thread to step out of the current function/method and allows all other threads to run freely by resuming them.

    If the debug adapter supports single thread execution (see capability `supportsSingleThreadExecutionRequests`),
    setting the singleThread argument to true prevents other suspended threads from resuming.

    The debug adapter first sends the response and then a stopped event (with reason step) after the step has completed.

    Args:
        thread_id: ID of the active thread.
        single_thread: If true, stepOut is limited to the specified thread.
        granularity: The granularity of the step, assumed to be 'statement' if not specified.
    """

    return self.send_request(
        "stepOut",
        {
            "threadId": thread_id,
            "singleThread": single_thread,
            "granularity": granularity,
        },
    )

terminate(restart=None)

The terminate request is sent from the client to the debug adapter in order to shut down the debuggee gracefully.

Typically a debug adapter implements terminate by sending a software signal which the debuggee intercepts in order to clean things up properly before terminating itself.

Please note that this request does not directly affect the state of the debug session: if the debuggee decides to veto the graceful shutdown for any reason by not terminating itself, then the debug session just continues.

Parameters:

Name Type Description Default
restart Optional[bool]

A value of true indicates that this 'terminate' request is part of a restart sequence.

None
Source code in src\dap\client.py
853
854
855
856
857
858
859
860
861
862
863
864
865
866
def terminate(self, restart: Optional[bool] = None) -> int:
    """The terminate request is sent from the client to the debug adapter in order to shut down the debuggee gracefully.

    Typically a debug adapter implements terminate by sending a software signal which the debuggee intercepts in order
    to clean things up properly before terminating itself.

    Please note that this request does not directly affect the state of the debug session: if the debuggee decides to
    veto the graceful shutdown for any reason by not terminating itself, then the debug session just continues.

    Args:
        restart: A value of true indicates that this 'terminate' request is part of a restart sequence.
    """

    return self.send_request("terminate", {"restart": restart})

terminate_threads(thread_ids)

The request terminates the threads with the given ids.

Parameters:

Name Type Description Default
thread_ids List[int]

The threads to terminate.

required
Source code in src\dap\client.py
868
869
870
871
872
873
874
875
def terminate_threads(self, thread_ids: List[int]) -> int:
    """The request terminates the threads with the given ids.

    Args:
        thread_ids: The threads to terminate.
    """

    return self.send_request("terminateThreads", {"threadIds": thread_ids})

threads()

The request retrieves a list of all threads.

Source code in src\dap\client.py
877
878
879
880
def threads(self) -> int:
    """The request retrieves a list of all threads."""

    return self.send_request("threads")

variables(variables_reference, filter=None, start=None, count=None, format=None)

Retrieves all child variables for the given variable reference.

A filter can be used to limit the fetched children to either named or indexed children.

Parameters:

Name Type Description Default
variables_reference int

The variable for which to retrieve its children.

required
filter Optional[Literal[indexed, named]] | str

Filter to limit the child variables to either named or indexed. If not specified, both types are fetched.

None
start Optional[int]

The index of the first variable to return; if omitted variables start at 0.

None
count Optional[int]

The number of variables to return. If not passed or 0, all variables are returned.

None
format Optional[ValueFormat]

Specifies details on how to format the response value.

None
Source code in src\dap\client.py
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
def variables(
    self,
    variables_reference: int,
    filter: Optional[Literal["indexed", "named"]] | str = None,
    start: Optional[int] = None,
    count: Optional[int] = None,
    format: Optional[ValueFormat] = None,
) -> int:
    """Retrieves all child variables for the given variable reference.

    A filter can be used to limit the fetched children to either named or indexed children.

    Args:
        variables_reference: The variable for which to retrieve its children.
        filter: Filter to limit the child variables to either named or indexed. If not specified, both types are fetched.
        start: The index of the first variable to return; if omitted variables start at 0.
        count: The number of variables to return. If not passed or 0, all variables are returned.
        format: Specifies details on how to format the response value.
    """

    return self.send_request(
        "variables",
        {
            "variablesReference": variables_reference,
            "filter": filter,
            "start": start,
            "count": count,
            "format": format,
        },
    )

write_memory(memory_reference, data, offset=None, allow_partial=None)

Writes bytes to memory at the provided location.

Parameters:

Name Type Description Default
memory_reference str

The memory reference to the base location to write memory.

required
data str

Bytes to write, encoded using base64.

required
offset Optional[int]

The offset (in bytes) of the first byte to write. Can be negative.

None
allow_partial Optional[bool]

Property to control partial writes. If true, the debug adapter should attempt to write memory even if the entire memory region is not writable.

None
Source code in src\dap\client.py
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
def write_memory(
    self,
    memory_reference: str,
    data: str,
    offset: Optional[int] = None,
    allow_partial: Optional[bool] = None,
) -> int:
    """Writes bytes to memory at the provided location.

    Args:
        memory_reference: The memory reference to the base location to write memory.
        data: Bytes to write, encoded using base64.
        offset: The offset (in bytes) of the first byte to write. Can be negative.
        allow_partial: Property to control partial writes. If true, the debug adapter should \
            attempt to write memory even if the entire memory region is not writable.
    """

    return self.send_request(
        "writeMemory",
        {
            "memoryReference": memory_reference,
            "offset": offset,
            "data": data,
            "allowPartial": allow_partial,
        },
    )

Responses

Attached

Bases: Response

Response to 'attach' request.

Source code in src\dap\responses.py
52
53
54
55
class Attached(Response):
    """Response to 'attach' request."""

    ...

BreakpointLocationsResponse

Bases: ResponseBody

Body of a 'breakpointLocations' response.

Source code in src\dap\responses.py
58
59
60
61
62
63
class BreakpointLocationsResponse(ResponseBody):
    """Body of a 'breakpointLocations' response."""

    breakpoints: list[BreakpointLocation] = Field(
        ..., description="List of breakpoints."
    )

Cancelled

Bases: Response

Response to 'cancel' request.

Source code in src\dap\responses.py
46
47
48
49
class Cancelled(Response):
    """Response to 'cancel' request."""

    ...

CompletionsResponse

Bases: ResponseBody

Body of a 'completions' response.

Source code in src\dap\responses.py
66
67
68
69
class CompletionsResponse(ResponseBody):
    """Body of a 'completions' response."""

    targets: list[CompletionItem] = Field(..., description="List of completion items.")

ConfigurationDone

Bases: Response

Response to 'configurationDone' request.

Source code in src\dap\responses.py
72
73
74
75
class ConfigurationDone(Response):
    """Response to 'configurationDone' request."""

    ...

Continued

Bases: ResponseBody

Body of a 'continue' response.

Source code in src\dap\responses.py
78
79
80
81
82
83
class Continued(ResponseBody):
    """Body of a 'continue' response."""

    allThreadsContinued: Optional[bool] = Field(
        None, description="If all threads were continued."
    )

DataBreakpointInfoResponse

Bases: ResponseBody

Body of a 'dataBreakpoint' response.

Source code in src\dap\responses.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
class DataBreakpointInfoResponse(ResponseBody):
    """Body of a 'dataBreakpoint' response."""

    dataId: Optional[str] = Field(
        None, description="An identifier for the data breakpoint."
    )
    description: str = Field(
        ..., description="A user-visible description of the breakpoint."
    )
    accessTypes: Optional[list[DataBreakpointAccessType]] = Field(
        None, description="The access types of the data breakpoint."
    )
    canPersist: Optional[bool] = Field(
        None, description="Whether the data breakpoint can be persisted."
    )

DisassembleResponse

Bases: ResponseBody

Body of a 'disassemble' response.

Source code in src\dap\responses.py
103
104
105
106
107
108
class DisassembleResponse(ResponseBody):
    """Body of a 'disassemble' response."""

    instructions: list[DisassembledInstruction] = Field(
        ..., description="List of disassembled instructions."
    )

Disconnected

Bases: Response

Response to 'disconnect' request.

Source code in src\dap\responses.py
111
112
113
114
class Disconnected(Response):
    """Response to 'disconnect' request."""

    ...

EvaluateResponse

Bases: ResponseBody

Body of an 'evaluate' response.

Source code in src\dap\responses.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
class EvaluateResponse(ResponseBody):
    """Body of an 'evaluate' response."""

    result: str = Field(..., description="The result of the evaluation.")
    type: Optional[str] = Field(None, description="The type of the result.")
    presentationHint: Optional[VariablePresentationHint] = Field(
        None, description="The presentation hint of the result."
    )
    variablesReference: int = Field(
        ...,
        description="The reference to the variables of the evaluation result.",
    )
    namedVariables: Optional[int] = Field(
        None, description="The number of named variables."
    )
    indexedVariables: Optional[int] = Field(
        None, description="The number of indexed variables."
    )
    memoryReference: Optional[str] = Field(
        None, description="The memory reference of the result."
    )

GotoDone

Bases: Response

Response to 'goto' request.

Source code in src\dap\responses.py
153
154
155
156
class GotoDone(Response):
    """Response to 'goto' request."""

    ...

GotoTargetsResponse

Bases: ResponseBody

Body of a 'gotoTargets' response.

Source code in src\dap\responses.py
159
160
161
162
class GotoTargetsResponse(ResponseBody):
    """Body of a 'gotoTargets' response."""

    targets: list[GotoTarget] = Field(..., description="List of goto targets.")

Initialized

Bases: Capabilities

Response to 'initialize' request.

Source code in src\dap\responses.py
165
166
167
168
class Initialized(Capabilities):
    """Response to 'initialize' request."""

    ...

LaunchDone

Bases: Response

Response to 'launch' request.

Source code in src\dap\responses.py
171
172
173
174
class LaunchDone(Response):
    """Response to 'launch' request."""

    ...

LoadedSourcesResponse

Bases: ResponseBody

Body of a 'loadedSources' response.

Source code in src\dap\responses.py
177
178
179
180
class LoadedSourcesResponse(ResponseBody):
    """Body of a 'loadedSources' response."""

    sources: list[Source] = Field(..., description="List of loaded sources.")

ModulesResponse

Bases: ResponseBody

Body of a 'modules' response.

Source code in src\dap\responses.py
183
184
185
186
187
188
189
class ModulesResponse(ResponseBody):
    """Body of a 'modules' response."""

    modules: list[Module] = Field(..., description="List of modules.")
    totalModules: Optional[int] = Field(
        None, description="The total number of modules."
    )

NextResponse

Bases: Response

Response to 'next' request.

Source code in src\dap\responses.py
192
193
194
195
class NextResponse(Response):
    """Response to 'next' request."""

    ...

Paused

Bases: Response

Response to 'pause' request.

Source code in src\dap\responses.py
198
199
200
201
class Paused(Response):
    """Response to 'pause' request."""

    ...

ReadMemoryResponse

Bases: ResponseBody

Body of a 'readMemory' response.

Source code in src\dap\responses.py
204
205
206
207
208
209
210
211
class ReadMemoryResponse(ResponseBody):
    """Body of a 'readMemory' response."""

    address: str = Field(..., description="The address of the memory read.")
    unreadableBytes: Optional[int] = Field(
        None, description="The number of unreadable bytes."
    )
    data: Optional[str] = Field(None, description="The data read from memory.")

RestartFrameDone

Bases: Response

Response to 'restartFrame' request.

Source code in src\dap\responses.py
220
221
222
223
class RestartFrameDone(Response):
    """Response to 'restartFrame' request."""

    ...

Restarted

Bases: Response

Response to 'restart' request.

Source code in src\dap\responses.py
214
215
216
217
class Restarted(Response):
    """Response to 'restart' request."""

    ...

ReverseContinueDone

Bases: Response

Response to 'reverseContinue' request.

Source code in src\dap\responses.py
226
227
228
229
class ReverseContinueDone(Response):
    """Response to 'reverseContinue' request."""

    ...

RunInTerminalResponse

Bases: Response

Response to 'runInTerminal' request.

Source code in src\dap\responses.py
20
21
22
23
24
25
26
27
28
29
30
class RunInTerminalResponse(Response):
    """Response to 'runInTerminal' request."""

    request_seq: int = Field(
        ..., description="Sequence number of the corresponding request."
    )
    success: bool = Field(
        ..., description="Indicates whether the request was successful."
    )
    command: str = "runInTerminal"
    body: RunInTerminalResponseBody

RunInTerminalResponseBody

Bases: ResponseBody

Body of a 'runInTerminal' response.

Source code in src\dap\responses.py
 9
10
11
12
13
14
15
16
17
class RunInTerminalResponseBody(ResponseBody):
    """Body of a 'runInTerminal' response."""

    processId: Optional[int] = Field(
        None, description="The process ID of the terminal."
    )
    shellProcessId: Optional[int] = Field(
        None, description="The process ID of the shell."
    )

ScopesResponse

Bases: ResponseBody

Body of a 'scopes' response.

Source code in src\dap\responses.py
232
233
234
235
class ScopesResponse(ResponseBody):
    """Body of a 'scopes' response."""

    scopes: list[Scope] = Field(..., description="List of scopes.")

SetBreakpointsResponse

Bases: ResponseBody

Body of a 'setBreakpoints' response.

Source code in src\dap\responses.py
238
239
240
241
class SetBreakpointsResponse(ResponseBody):
    """Body of a 'setBreakpoints' response."""

    breakpoints: list[Breakpoint]

SetDataBreakpointsResponse

Bases: ResponseBody

Body of a 'setDataBreakpoints' response.

Source code in src\dap\responses.py
244
245
246
247
class SetDataBreakpointsResponse(ResponseBody):
    """Body of a 'setDataBreakpoints' response."""

    breakpoints: list[Breakpoint]

SetExceptionBreakpointsResponse

Bases: Response

Response to 'setExceptionBreakpoints' request.

Source code in src\dap\responses.py
256
257
258
259
class SetExceptionBreakpointsResponse(Response):
    """Response to 'setExceptionBreakpoints' request."""

    ...

SetExpressionResponse

Bases: ResponseBody

Body of a 'setExpression' response.

Source code in src\dap\responses.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
class SetExpressionResponse(ResponseBody):
    """Body of a 'setExpression' response."""

    value: str = Field(..., description="The value of the expression.")
    type: Optional[str] = Field(None, description="The type of the expression.")
    presentationHint: Optional[VariablePresentationHint] = Field(
        None, description="The presentation hint of the expression."
    )
    variablesReference: Optional[int] = Field(
        None,
        description="The reference to the variables of the expression result.",
    )
    namedVariables: Optional[int] = Field(
        None, description="The number of named variables."
    )
    indexedVariables: Optional[int] = Field(
        None, description="The number of indexed variables."
    )
    memoryReference: Optional[str] = Field(
        None, description="The memory reference of the expression."
    )

SetFunctionBreakpointsResponse

Bases: ResponseBody

Body of a 'setFunctionBreakpoints' response.

Source code in src\dap\responses.py
285
286
287
288
289
290
class SetFunctionBreakpointsResponse(ResponseBody):
    """Body of a 'setFunctionBreakpoints' response."""

    breakpoints: list[FunctionBreakpoint] = Field(
        ..., description="List of function breakpoints."
    )

SetInstructionBreakpointsResponse

Bases: ResponseBody

Body of a 'setInstructionBreakpoints' response.

Source code in src\dap\responses.py
293
294
295
296
class SetInstructionBreakpointsResponse(ResponseBody):
    """Body of a 'setInstructionBreakpoints' response."""

    breakpoints: list[Breakpoint]

SetVariableResponse

Bases: ResponseBody

Body of a 'setVariable' response.

Source code in src\dap\responses.py
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
class SetVariableResponse(ResponseBody):
    """Body of a 'setVariable' response."""

    value: str = Field(..., description="The value of the variable.")
    type: Optional[str] = Field(None, description="The type of the variable.")
    variablesReference: Optional[int] = Field(
        None,
        description="The reference to the variables of the variable result.",
    )
    namedVariables: Optional[int] = Field(
        None, description="The number of named variables."
    )
    indexedVariables: Optional[int] = Field(
        None, description="The number of indexed variables."
    )
    memoryReference: Optional[str] = Field(
        None, description="The memory reference of the variable."
    )

SourceResponse

Bases: ResponseBody

Body of a 'source' response.

Source code in src\dap\responses.py
319
320
321
322
323
class SourceResponse(ResponseBody):
    """Body of a 'source' response."""

    content: str = Field(..., description="The content of the source.")
    mimeType: Optional[str] = Field(None, description="The MIME type of the source.")

StackTraceResponse

Bases: ResponseBody

Body of a 'stackTrace' response.

Source code in src\dap\responses.py
326
327
328
329
330
class StackTraceResponse(ResponseBody):
    """Body of a 'stackTrace' response."""

    stackFrames: list[StackFrame] = Field(..., description="List of stack frames.")
    totalFrames: Optional[int] = Field(None, description="The total number of frames.")

StartDebuggingResponse

Bases: Response

Body of a 'startDebugging' response.

Source code in src\dap\responses.py
33
34
35
36
37
38
39
40
41
42
class StartDebuggingResponse(Response):
    """Body of a 'startDebugging' response."""

    request_seq: int = Field(
        ..., description="Sequence number of the corresponding request."
    )
    success: bool = Field(
        ..., description="Indicates whether the request was successful."
    )
    command: str = "startDebugging"

StepBackDone

Bases: Response

Response to 'stepBack' request.

Source code in src\dap\responses.py
333
334
335
336
class StepBackDone(Response):
    """Response to 'stepBack' request."""

    ...

StepInDone

Bases: Response

Response to 'stepIn' request.

Source code in src\dap\responses.py
339
340
341
342
class StepInDone(Response):
    """Response to 'stepIn' request."""

    ...

StepInTargetsResponse

Bases: ResponseBody

Body of a 'stepInTargets' response.

Source code in src\dap\responses.py
345
346
347
348
class StepInTargetsResponse(ResponseBody):
    """Body of a 'stepInTargets' response."""

    targets: list[StepInTarget] = Field(..., description="List of step in targets.")

StepOutDone

Bases: Response

Response to 'stepOut' request.

Source code in src\dap\responses.py
351
352
353
354
class StepOutDone(Response):
    """Response to 'stepOut' request."""

    ...

TerminateThreadsDone

Bases: Response

Response to 'terminateThreads' request.

Source code in src\dap\responses.py
363
364
365
366
class TerminateThreadsDone(Response):
    """Response to 'terminateThreads' request."""

    ...

Terminated

Bases: Response

Response to 'terminate' request.

Source code in src\dap\responses.py
357
358
359
360
class Terminated(Response):
    """Response to 'terminate' request."""

    ...

ThreadsResponse

Bases: ResponseBody

Body of a 'threads' response.

Source code in src\dap\responses.py
369
370
371
372
class ThreadsResponse(ResponseBody):
    """Body of a 'threads' response."""

    threads: list[Thread] = Field(..., description="List of threads.")

VariablesResponse

Bases: ResponseBody

Body of a 'variables' response.

Source code in src\dap\responses.py
375
376
377
378
class VariablesResponse(ResponseBody):
    """Body of a 'variables' response."""

    variables: list[Variable] = Field(..., description="List of variables.")

WriteMemoryResponse

Bases: ResponseBody

Body of a 'writeMemory' response.

Source code in src\dap\responses.py
381
382
383
384
385
386
387
class WriteMemoryResponse(ResponseBody):
    """Body of a 'writeMemory' response."""

    offset: Optional[int] = Field(None, description="The offset of the memory write.")
    bytesWritten: Optional[int] = Field(
        None, description="The number of bytes written."
    )

Events

BreakpointEvent

Bases: EventBody

Event sent when a breakpoint is hit.

Source code in src\dap\events.py
 7
 8
 9
10
11
12
13
14
class BreakpointEvent(EventBody):
    """Event sent when a breakpoint is hit."""

    reason: Literal["changed", "new", "removed"] | str = Field(
        ...,
        description="The reason the event was sent. 'changed' for a changed breakpoint, 'new' for a new breakpoint, 'removed' for a removed breakpoint.",
    )
    breakpoint: Breakpoint = Field(..., description="The breakpoint that was hit.")

CapabilitiesEvent

Bases: EventBody

Event sent when capabilities are requested.

Source code in src\dap\events.py
17
18
19
20
21
22
class CapabilitiesEvent(EventBody):
    """Event sent when capabilities are requested."""

    capabilities: Capabilities = Field(
        ..., description="The capabilities of the debug adapter."
    )

ContinuedEvent

Bases: EventBody

Event sent when the execution is continued.

Source code in src\dap\events.py
25
26
27
28
29
30
31
32
class ContinuedEvent(EventBody):
    """Event sent when the execution is continued."""

    threadId: int = Field(..., description="The thread that continued.")
    allThreadsContinued: Optional[bool] = Field(
        None,
        description="If all threads continued, the attribute is omitted. If a specific thread continued, the attribute contains the thread ID.",
    )

ExitedEvent

Bases: EventBody

Event sent when the debuggee has exited.

Source code in src\dap\events.py
35
36
37
38
class ExitedEvent(EventBody):
    """Event sent when the debuggee has exited."""

    exitCode: int = Field(..., description="The exit code of the debuggee.")

InitializedEvent

Bases: EventBody

Event sent when the debug adapter is initialized.

Source code in src\dap\events.py
41
42
43
44
class InitializedEvent(EventBody):
    """Event sent when the debug adapter is initialized."""

    ...

InvalidatedEvent

Bases: EventBody

Event sent when breakpoints are invalidated.

Source code in src\dap\events.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class InvalidatedEvent(EventBody):
    """Event sent when breakpoints are invalidated."""

    areas: Optional[list[InvalidatedAreas]] = Field(
        None, description="The invalidated areas."
    )
    threadId: Optional[int] = Field(
        None,
        description="The thread ID of the invalidated areas. If omitted, the invalidated areas are not specific to a thread.",
    )
    stackFrameId: Optional[int] = Field(
        None,
        description="The stack frame ID of the invalidated areas. If omitted, the invalidated areas are not specific to a stack frame.",
    )

LoadedSourceEvent

Bases: EventBody

Event sent when a source is loaded.

Source code in src\dap\events.py
63
64
65
66
67
68
69
70
class LoadedSourceEvent(EventBody):
    """Event sent when a source is loaded."""

    reason: Literal["new", "changed", "removed"] = Field(
        ...,
        description="The reason the event was sent. 'new' for a new source, 'changed' for a changed source, 'removed' for a removed source.",
    )
    source: Source = Field(..., description="The source that was loaded.")

MemoryEvent

Bases: EventBody

Event sent when memory is accessed.

Source code in src\dap\events.py
73
74
75
76
77
78
class MemoryEvent(EventBody):
    """Event sent when memory is accessed."""

    memoryReference: str = Field(..., description="The memory reference.")
    offset: int = Field(..., description="The memory offset.")
    count: int = Field(..., description="The number of bytes.")

ModuleEvent

Bases: EventBody

Event sent when a module is loaded or unloaded.

Source code in src\dap\events.py
81
82
83
84
85
86
87
88
class ModuleEvent(EventBody):
    """Event sent when a module is loaded or unloaded."""

    reason: Literal["new", "changed", "removed"] = Field(
        ...,
        description="The reason the event was sent. 'new' for a new module, 'changed' for a changed module, 'removed' for a removed module.",
    )
    module: Module = Field(..., description="The module that was loaded or unloaded.")

OutputEvent

Bases: EventBody

Event sent when output is produced.

Source code in src\dap\events.py
 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
class OutputEvent(EventBody):
    """Event sent when output is produced."""

    category: Optional[
        Literal["console", "important", "stdout", "stderr", "telemetry"] | str
    ] = Field(
        ...,
        description="The category of the output.",
    )
    output: str = Field(..., description="The output text.")
    group: Optional[Literal["start", "startCollapsed", "end"]] = Field(
        None,
        description="The output group.",
    )
    variablesReference: Optional[int] = Field(
        None,
        description="The reference to a variable.",
    )
    source: Optional[Source] = Field(
        None,
        description="The source of the output.",
    )
    line: Optional[int] = Field(
        None,
        description="The line of the output.",
    )
    column: Optional[int] = Field(
        None,
        description="The column of the output.",
    )
    data: Optional[Any] = Field(None, description="Additional data.")

ProcessEvent

Bases: EventBody

Event sent when a process is created or exited.

Source code in src\dap\events.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
class ProcessEvent(EventBody):
    """Event sent when a process is created or exited."""

    name: str = Field(..., description="The name of the process.")
    systemProcessId: Optional[int] = Field(
        None,
        description="The system process ID.",
    )
    isLocalProcess: Optional[bool] = Field(
        None,
        description="If the process is local.",
    )
    startMethod: Optional[Literal["launch", "attach", "attachForSuspendedLaunch"]] = (
        Field(
            None,
            description="The start method.",
        )
    )
    pointerSize: Optional[int] = Field(
        None,
        description="The pointer size.",
    )

ProgressEndEvent

Bases: EventBody

Event sent when a progress ends.

Source code in src\dap\events.py
148
149
150
151
152
class ProgressEndEvent(EventBody):
    """Event sent when a progress ends."""

    progressId: str = Field(..., description="The progress ID.")
    message: Optional[str] = Field(None, description="The message.")

ProgressStartEvent

Bases: EventBody

Event sent when a progress starts.

Source code in src\dap\events.py
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
class ProgressStartEvent(EventBody):
    """Event sent when a progress starts."""

    progressId: str = Field(..., description="The progress ID.")
    title: str = Field(..., description="The title of the progress.")
    requestId: Optional[str] = Field(
        None,
        description="The request ID.",
    )
    cancellable: Optional[bool] = Field(
        None,
        description="If the progress is cancellable.",
    )
    message: Optional[str] = Field(None, description="The message.")
    percentage: Optional[int] = Field(
        None,
        description="The percentage of the progress.",
    )

ProgressUpdateEvent

Bases: EventBody

Event sent when a progress updates.

Source code in src\dap\events.py
175
176
177
178
179
180
181
182
183
class ProgressUpdateEvent(EventBody):
    """Event sent when a progress updates."""

    progressId: str = Field(..., description="The progress ID.")
    message: Optional[str] = Field(None, description="The message.")
    percentage: Optional[int] = Field(
        None,
        description="The percentage of the progress.",
    )

StoppedEvent

Bases: EventBody

Event sent when the execution is stopped.

Source code in src\dap\events.py
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
class StoppedEvent(EventBody):
    """Event sent when the execution is stopped."""

    reason: Literal[
        "step",
        "breakpoint",
        "exception",
        "pause",
        "entry",
        "goto",
        "function breakpoint",
        "data breakpoint",
        "instruction breakpoint",
    ] = Field(
        ...,
        description="The reason the execution was stopped.",
    )
    description: Optional[str] = Field(
        None,
        description="The description of the stop event.",
    )
    threadId: Optional[int] = Field(
        None,
        description="The thread that stopped.",
    )
    preserveFocusHint: Optional[bool] = Field(
        None,
        description="If the focus should be preserved.",
    )
    text: Optional[str] = Field(
        None,
        description="The text of the stop event.",
    )
    allThreadsStopped: Optional[bool] = Field(
        None,
        description="If all threads stopped, the attribute is omitted. If a specific thread stopped, the attribute contains the thread ID.",
    )
    hitBreakpointIds: Optional[list[str]] = Field(
        None,
        description="The hit breakpoint IDs.",
    )

TerminatedEvent

Bases: EventBody

Event sent when the debuggee is terminated.

Source code in src\dap\events.py
229
230
231
232
233
234
235
class TerminatedEvent(EventBody):
    """Event sent when the debuggee is terminated."""

    restart: Optional[bool] = Field(
        None,
        description="If the debuggee should be restarted.",
    )

ThreadEvent

Bases: EventBody

Event sent when a thread is created or exited.

Source code in src\dap\events.py
238
239
240
241
242
243
244
245
class ThreadEvent(EventBody):
    """Event sent when a thread is created or exited."""

    reason: Literal["started", "exited"] | str = Field(
        ...,
        description="The reason the event was sent. 'started' for a started thread, 'exited' for an exited thread.",
    )
    threadId: int = Field(..., description="The thread ID.")

Requests

AttachRequestArguments

Bases: TypedDict

Arguments for 'attach' request.

Source code in src\dap\requests.py
13
14
15
16
class AttachRequestArguments(TypedDict):
    """Arguments for 'attach' request."""

    __restart: Optional[bool] = None

LaunchRequestArguments

Bases: TypedDict

Arguments for 'launch' request.

Source code in src\dap\requests.py
19
20
21
22
23
class LaunchRequestArguments(TypedDict):
    """Arguments for 'launch' request."""

    noDebug: Optional[bool] = None
    __restart: Optional[bool] = None

RunInTerminalRequest

Bases: Request

Request for 'runInTerminal' reverse request.

Source code in src\dap\requests.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
class RunInTerminalRequest(Request):
    """Request for 'runInTerminal' reverse request."""

    command: Literal["runInTerminal"] = "runInTerminal"
    arguments: RunInTerminalRequestArguments

    def reply(
        self,
        success: bool,
        processId: Optional[int] = None,
        shellProcessId: Optional[int] = None,
    ) -> RunInTerminalResponse:
        return RunInTerminalResponse(
            seq=self.seq,
            request_seq=self.seq,
            success=success,
            body=RunInTerminalResponseBody(
                processId=processId,
                shellProcessId=shellProcessId,
            ),
        )

RunInTerminalRequestArguments

Bases: RequestArguments

Arguments for 'runInTerminal' reverse request.

Source code in src\dap\requests.py
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
class RunInTerminalRequestArguments(RequestArguments):
    """Arguments for 'runInTerminal' reverse request."""

    kind: Optional[str] = Field(
        None,
        description="The kind of terminal to run the command in.",
    )
    title: Optional[str] = Field(
        None,
        description="The title of the terminal.",
    )
    cwd: str = Field(
        ...,
        description="The working directory of the terminal.",
    )
    args: list[str] = Field(
        ...,
        description="The command to run in the terminal.",
    )
    env: Optional[dict[str, str | None]] = Field(
        None,
        description="Environment key-value pairs that should be added to or removed from the default environment.",
    )
    argsCanBeInterpretedByShell: Optional[bool] = Field(
        None,
        description="Whether the arguments can be interpreted as shell commands.",
    )

StartDebuggingRequest

Bases: Request

Request for 'startDebugging' request.

Source code in src\dap\requests.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
class StartDebuggingRequest(Request):
    """Request for 'startDebugging' request."""

    command: Literal["startDebugging"] = "startDebugging"
    arguments: StartDebuggingRequestArguments

    def reply(self, success: bool) -> StartDebuggingResponse:
        return StartDebuggingResponse(
            seq=self.seq,
            request_seq=self.seq,
            success=success,
        )

StartDebuggingRequestArguments

Bases: RequestArguments

Arguments for 'startDebugging' request.

Source code in src\dap\requests.py
81
82
83
84
85
86
87
88
89
90
91
92
93
class StartDebuggingRequestArguments(RequestArguments):
    """Arguments for 'startDebugging' request."""

    configuration: dict[str, str] = Field(
        ...,
        description="Arguments passed to the new debug session. The arguments must only contain properties understood by "
        "the `launch` or `attach` requests of the debug adapter and they must not contain any client-specific properties "
        "(e.g. `type`) or client-specific features (e.g. substitutable 'variables')",
    )
    request: Literal["launch", "attach"] = Field(
        ...,
        description="The request type: 'launch' or 'attach'.",
    )

Base Protocol

EventBody

Bases: BaseModel

Base class of event bodies

Source code in src\dap\base.py
38
39
40
41
class EventBody(BaseModel):
    """Base class of event bodies"""

    ...

Events

Bases: StrEnum

Enumeration of DAP events.

Source code in src\dap\base.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
class Events(StrEnum):
    """Enumeration of DAP events."""

    BREAKPOINT = "breakpoint"
    CAPABILITIES = "capabilities"
    CONTINUED = "continued"
    EXITED = "exited"
    INITIALIZED = "initialized"
    INVALIDATED = "invalidated"
    LOADED_SOURCE = "loadedSource"
    MEMORY = "memory"
    MODULE = "module"
    OUTPUT = "output"
    PROCESS = "process"
    PROGRESS_END = "progressEnd"
    PROGRESS_START = "progressStart"
    PROGRESS_UPDATE = "progressUpdate"
    STOPPED = "stopped"
    TERMINATED = "terminated"
    THREAD = "thread"

ProtocolMessage

Bases: BaseModel

Base class of requests, responses, and events

Source code in src\dap\base.py
11
12
13
14
15
16
17
class ProtocolMessage(BaseModel):
    """Base class of requests, responses, and events"""

    seq: int = Field(..., description="Sequence number (message ID) of the message.")
    type: Literal["request", "response", "event"] | str = Field(
        ..., description="Message type."
    )

Request

Bases: ProtocolMessage

Source code in src\dap\base.py
24
25
26
27
28
29
30
31
32
33
34
35
class Request(ProtocolMessage):
    type: str = "request"  # type: ignore
    command: str = Field(..., description="The command to execute.")
    arguments: Optional[Any] = Field(
        None, description="Object containing arguments for the command."
    )

    def reply(self, *a, **kw) -> Response:
        """Create a response message for the request.

        This method is for reverse requests only."""
        ...

reply(*a, **kw)

Create a response message for the request.

This method is for reverse requests only.

Source code in src\dap\base.py
31
32
33
34
35
def reply(self, *a, **kw) -> Response:
    """Create a response message for the request.

    This method is for reverse requests only."""
    ...

RequestArguments

Bases: BaseModel

Base class of request arguments

Source code in src\dap\base.py
20
21
class RequestArguments(BaseModel):
    """Base class of request arguments"""

Requests

Bases: StrEnum

Enumeration of DAP requests.

Source code in src\dap\base.py
 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
class Requests(StrEnum):
    """Enumeration of DAP requests."""

    CANCEL = "cancel"
    ATTACH = "attach"
    BREAKPOINTLOCATIONS = "breakpointLocations"
    COMPLETIONS = "completions"
    CONFIGURATIONDONE = "configurationDone"
    CONTINUE = "continue"
    DATABREAKPOINTINFO = "dataBreakpointInfo"
    DISASSEMBLE = "disassemble"
    DISCONNECT = "disconnect"
    EVALUATE = "evaluate"
    EXCEPTIONINFO = "exceptionInfo"
    GOTO = "goto"
    GOTOTARGETS = "gotoTargets"
    INITIALIZE = "initialize"
    LAUNCH = "launch"
    LOADEDSOURCES = "loadedSources"
    MODULES = "modules"
    NEXT = "next"
    PAUSE = "pause"
    READMEMORY = "readMemory"
    RESTART = "restart"
    RESTARTFRAME = "restartFrame"
    REVERSECONTINUE = "reverseContinue"
    SCOPES = "scopes"
    SETBREAKPOINTS = "setBreakpoints"
    SETDATABREAKPOINTS = "setDataBreakpoints"
    SETEXCEPTIONBREAKPOINTS = "setExceptionBreakpoints"
    SETEXPRESSION = "setExpression"
    SETFUNCTIONBREAKPOINTS = "setFunctionBreakpoints"
    SETINSTRUCTIONBREAKPOINTS = "setInstructionBreakpoints"
    SETVARIABLE = "setVariable"
    SOURCE = "source"
    STACKTRACE = "stackTrace"
    STEPBACK = "stepBack"
    STEPIN = "stepIn"
    STEPINTARGETS = "stepInTargets"
    STEPOUT = "stepOut"
    TERMINATE = "terminate"
    TERMINATETHREADS = "terminateThreads"
    THREADS = "threads"
    VARIABLES = "variables"
    WRITEMEMORY = "writeMemory"

    # Reverse requests
    RUNINTERMINAL = "runInTerminal"
    STARTDEBUGGING = "startDebugging"

ResponseBody

Bases: BaseModel

Base class of response bodies

Source code in src\dap\base.py
52
53
54
55
class ResponseBody(BaseModel):
    """Base class of response bodies"""

    ...

Connection

AsyncConnection

Asyncio-based connection to a debug adapter server.

This class is used to connect to a debug adapter server using asyncio. It provides methods to start, stop, read and write to the server.

Source code in src\dap\connection.py
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
class AsyncConnection:
    """Asyncio-based connection to a debug adapter server.

    This class is used to connect to a debug adapter server using asyncio.
    It provides methods to start, stop, read and write to the server."""

    def __init__(self, host: str, port: int) -> None:
        self.host = host
        self.port = port
        self.reader: Optional[asyncio.StreamReader] = None
        self.writer: Optional[asyncio.StreamWriter] = None
        self.alive = False

    async def start(self):
        """Start the connection to the server."""

        self.reader, self.writer = await asyncio.open_connection(self.host, self.port)
        self.alive = True

    async def stop(self):
        """Stop the connection to the server."""

        self.writer.close()
        await self.writer.wait_closed()
        self.alive = False

    async def write(self, data: bytes):
        """Write data to the server

        Args:
            data (bytes): The data to write to the server.
        """

        self.writer.write(data)
        await self.writer.drain()

    async def read(self) -> bytes:
        """Read data from the server

        Returns:
            bytes: The data read from the server.
        """

        return await self.reader.read(1024)

read() async

Read data from the server

Returns:

Name Type Description
bytes bytes

The data read from the server.

Source code in src\dap\connection.py
46
47
48
49
50
51
52
53
async def read(self) -> bytes:
    """Read data from the server

    Returns:
        bytes: The data read from the server.
    """

    return await self.reader.read(1024)

start() async

Start the connection to the server.

Source code in src\dap\connection.py
23
24
25
26
27
async def start(self):
    """Start the connection to the server."""

    self.reader, self.writer = await asyncio.open_connection(self.host, self.port)
    self.alive = True

stop() async

Stop the connection to the server.

Source code in src\dap\connection.py
29
30
31
32
33
34
async def stop(self):
    """Stop the connection to the server."""

    self.writer.close()
    await self.writer.wait_closed()
    self.alive = False

write(data) async

Write data to the server

Parameters:

Name Type Description Default
data bytes

The data to write to the server.

required
Source code in src\dap\connection.py
36
37
38
39
40
41
42
43
44
async def write(self, data: bytes):
    """Write data to the server

    Args:
        data (bytes): The data to write to the server.
    """

    self.writer.write(data)
    await self.writer.drain()

Connection

Connection to a debug adapter server.

This class is used to connect to a debug adapter server using threads. It provides methods to start, stop, read and write to the server.

Source code in src\dap\connection.py
 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
class Connection:
    """Connection to a debug adapter server.

    This class is used to connect to a debug adapter server using threads.
    It provides methods to start, stop, read and write to the server."""

    def __init__(self, host="localhost", port=6789):
        self.alive = True
        self.host = host
        self.port = port

        self.out_queue = queue.Queue()

    def write(self, buf: bytes) -> None:
        """Write data to the server

        Args:
            buf (bytes): The data to write to the server.
        """

        self.sock.sendall(buf)

    def read(self) -> None:
        """Read data from the server

        Returns:
            bytes: The data read from the server.
        """

        buf = bytearray()
        while True:
            try:
                buf += self.out_queue.get(block=False)
            except queue.Empty:
                break

        if self.t_out.is_alive() and not buf:
            return None
        return bytes(buf)

    def start(self, *_) -> None:
        """Start the connection to the server."""

        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.sock.connect((self.host, self.port))

        self.t_out = Thread(target=self._process_output, daemon=True)
        self.t_out.start()

    def stop(self, *_) -> None:
        """Stop the connection to the server."""

        self.alive = False
        self.sock.close()

    def _process_output(self) -> None:
        while self.alive:
            try:
                data = self.sock.recv(1024)
            except ConnectionAbortedError:
                break
            except ConnectionResetError:
                break

            if not data:
                break

            self.out_queue.put(data)

read()

Read data from the server

Returns:

Name Type Description
bytes None

The data read from the server.

Source code in src\dap\connection.py
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def read(self) -> None:
    """Read data from the server

    Returns:
        bytes: The data read from the server.
    """

    buf = bytearray()
    while True:
        try:
            buf += self.out_queue.get(block=False)
        except queue.Empty:
            break

    if self.t_out.is_alive() and not buf:
        return None
    return bytes(buf)

start(*_)

Start the connection to the server.

Source code in src\dap\connection.py
 96
 97
 98
 99
100
101
102
103
def start(self, *_) -> None:
    """Start the connection to the server."""

    self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    self.sock.connect((self.host, self.port))

    self.t_out = Thread(target=self._process_output, daemon=True)
    self.t_out.start()

stop(*_)

Stop the connection to the server.

Source code in src\dap\connection.py
105
106
107
108
109
def stop(self, *_) -> None:
    """Stop the connection to the server."""

    self.alive = False
    self.sock.close()

write(buf)

Write data to the server

Parameters:

Name Type Description Default
buf bytes

The data to write to the server.

required
Source code in src\dap\connection.py
69
70
71
72
73
74
75
76
def write(self, buf: bytes) -> None:
    """Write data to the server

    Args:
        buf (bytes): The data to write to the server.
    """

    self.sock.sendall(buf)

Threaded Socket IO Client

Abstract Threaded server implementation of the DAP Client

It is meant to be used as a base class for creating a server. It handles the connection and the client. Following methods need to be implemented by the child class: - handle_message

Source code in src\dap\server.py
 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
class ThreadedServer:
    """Abstract Threaded server implementation of the DAP Client

    It is meant to be used as a base class for creating a server. It handles the connection and the client.
    Following methods need to be implemented by the child class:
    - handle_message
    """

    def __init__(self, adapter_id: str, host="localhost", port=6789) -> None:
        """Initializes the server with the given adapter_id, host and port

        Args:
            adapter_id (str): The adapter id
            host (str, optional): The host to connect to. Defaults to "localhost".
            port (int, optional): The port to connect to. Defaults to 6789.
        """

        self.connection = Connection(host, port)
        self.connection.start()

        self.client = Client(adapter_id)
        self.running = False

    def start(self):
        """Starts the server"""

        self.running = True
        threading.Thread(target=self._run_loop, daemon=True).start()

    def stop(self):
        """Stops the server"""

        self.running = False
        self.client.terminate()
        self.connection.stop()

    def _run_loop(self):
        while self.running and self.connection.alive and self.run_single():
            ...

    def run_single(self):
        if s := self.client.send():
            self.connection.write(s)

        r = self.connection.read()
        if not r:
            return False

        for result in self.client.receive(r):
            self.handle_message(result)

        return True

    def handle_message(self, message):
        """Handles the message received from the client

        To be implemented by child classes
        Args:
            message (Any): The message to handle
        """

        print(type(message), flush=True)

__init__(adapter_id, host='localhost', port=6789)

Initializes the server with the given adapter_id, host and port

Parameters:

Name Type Description Default
adapter_id str

The adapter id

required
host str

The host to connect to. Defaults to "localhost".

'localhost'
port int

The port to connect to. Defaults to 6789.

6789
Source code in src\dap\server.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def __init__(self, adapter_id: str, host="localhost", port=6789) -> None:
    """Initializes the server with the given adapter_id, host and port

    Args:
        adapter_id (str): The adapter id
        host (str, optional): The host to connect to. Defaults to "localhost".
        port (int, optional): The port to connect to. Defaults to 6789.
    """

    self.connection = Connection(host, port)
    self.connection.start()

    self.client = Client(adapter_id)
    self.running = False

handle_message(message)

Handles the message received from the client

To be implemented by child classes Args: message (Any): The message to handle

Source code in src\dap\server.py
60
61
62
63
64
65
66
67
68
def handle_message(self, message):
    """Handles the message received from the client

    To be implemented by child classes
    Args:
        message (Any): The message to handle
    """

    print(type(message), flush=True)

start()

Starts the server

Source code in src\dap\server.py
30
31
32
33
34
def start(self):
    """Starts the server"""

    self.running = True
    threading.Thread(target=self._run_loop, daemon=True).start()

stop()

Stops the server

Source code in src\dap\server.py
36
37
38
39
40
41
def stop(self):
    """Stops the server"""

    self.running = False
    self.client.terminate()
    self.connection.stop()

Asyncio Client

Abstract Asyncio-based DAP server.

Handles communication between the client and the adapter. Child classes should implement the following methods:

  • handle_message: Handle a message from the client or adapter.

Example:

class MyServer(AsyncServer):
    def handle_message(self, message):
        print(message)
Source code in src\dap\asyncserver.py
 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
class AsyncServer:
    """Abstract Asyncio-based DAP server.

    Handles communication between the client and the adapter. Child classes should
    implement the following methods:

    - handle_message: Handle a message from the client or adapter.

    Example:

    ```python
    class MyServer(AsyncServer):
        def handle_message(self, message):
            print(message)
    ```
    """

    def __init__(
        self, adapter_id: str, host: str = "localhost", port: int = 6789
    ) -> None:
        self.connection = AsyncConnection(host, port)
        self.client = Client(adapter_id)
        self.running = False
        self.loop: Optional[asyncio.AbstractEventLoop] = None

    async def start(self):
        """Start the server."""

        await self.connection.start()
        self.running = True
        self.loop = asyncio.get_running_loop()
        await self._run_loop()

    async def stop(self):
        """Stop the server."""

        self.running = False
        self.client.terminate()
        await self.connection.stop()

    async def _run_loop(self):
        while self.running and self.connection.alive:
            await self.run_single()
            await asyncio.sleep(0.1)

    async def run_single(self):
        s = self.client.send()
        if s:
            await self.connection.write(s)

        r = await self.connection.read()
        for event in self.client.receive(r):
            self.handle_message(event)

        return True

    def handle_message(self, message):
        """Handle a message from the client or adapter.

        To be implemented by subclasses.
        """

        print(type(message), flush=True)

handle_message(message)

Handle a message from the client or adapter.

To be implemented by subclasses.

Source code in src\dap\asyncserver.py
64
65
66
67
68
69
70
def handle_message(self, message):
    """Handle a message from the client or adapter.

    To be implemented by subclasses.
    """

    print(type(message), flush=True)

start() async

Start the server.

Source code in src\dap\asyncserver.py
33
34
35
36
37
38
39
async def start(self):
    """Start the server."""

    await self.connection.start()
    self.running = True
    self.loop = asyncio.get_running_loop()
    await self._run_loop()

stop() async

Stop the server.

Source code in src\dap\asyncserver.py
41
42
43
44
45
46
async def stop(self):
    """Stop the server."""

    self.running = False
    self.client.terminate()
    await self.connection.stop()