View Source edb_dap (edb v0.3.0)

Support for the DAP Protocol

The Debug Adapter Protocol (DAP) defines the abstract protocol used between a development tool (e.g. IDE or editor) and a debugger, using JSON-RPC as the underlying transport protocol.

This module implements the types and functions required to encode and decode messages to and from the DAP protocol.

For the full specification, please refer to:

https://microsoft.github.io/debug-adapter-protocol/specification

Summary

Types

arguments/0

-type arguments() :: map().

body/0

-type body() :: map().

breakpoint/0

-type breakpoint() ::
          #{id => number(),
            verified := boolean(),
            message => binary(),
            source => source(),
            line => number(),
            column => number(),
            endLine => number(),
            endColumn => number(),
            instructionReference => binary(),
            offset => number(),
            reason => binary()}.

breakpointMode/0

-type breakpointMode() ::
          #{mode := binary(),
            label := binary(),
            description => binary(),
            appliesTo => [breakpointModeApplicability()]}.

breakpointModeApplicability/0

-type breakpointModeApplicability() :: source | exception | data | instruction.

breakpoints/0

-type breakpoints() :: #{breakpoints := [breakpoint()]}.

cancel_request_arguments/0

-type cancel_request_arguments() :: #{requestId => seq(), progressId => binary()}.

cancel_response/0

-type cancel_response() :: response().

capabilities/0

-type capabilities() ::
          #{supportsConfigurationDoneRequest => boolean(),
            supportsFunctionBreakpoints => boolean(),
            supportsConditionalBreakpoints => boolean(),
            supportsHitConditionalBreakpoints => boolean(),
            supportsEvaluateForHovers => boolean(),
            exceptionBreakpointFilters => [exceptionBreakpointsFilter()],
            supportsStepBack => boolean(),
            supportsSetVariable => boolean(),
            supportsRestartFrame => boolean(),
            supportsGotoTargetsRequest => boolean(),
            supportsStepInTargetsRequest => boolean(),
            supportsCompletionsRequest => boolean(),
            completionTriggerCharacters => [binary()],
            supportsModulesRequest => boolean(),
            additionalModuleColumns => [columnDescriptor()],
            supportedChecksumAlgorithms => [checksumAlgorithm()],
            supportsRestartRequest => boolean(),
            supportsExceptionOptions => boolean(),
            supportsValueFormattingOptions => boolean(),
            supportsExceptionInfoRequest => boolean(),
            supportTerminateDebuggee => boolean(),
            supportSuspendDebuggee => boolean(),
            supportsDelayedStackTraceLoading => boolean(),
            supportsLoadedSourcesRequest => boolean(),
            supportsLogPoints => boolean(),
            supportsTerminateThreadsRequest => boolean(),
            supportsSetExpression => boolean(),
            supportsTerminateRequest => boolean(),
            supportsDataBreakpoints => boolean(),
            supportsReadMemoryRequest => boolean(),
            supportsWriteMemoryRequest => boolean(),
            supportsDisassembleRequest => boolean(),
            supportsCancelRequest => boolean(),
            supportsBreakpointLocationsRequest => boolean(),
            supportsClipboardContext => boolean(),
            supportsSteppingGranularity => boolean(),
            supportsInstructionBreakpoints => boolean(),
            supportsExceptionFilterOptions => boolean(),
            supportsSingleThreadExecutionRequests => boolean(),
            supportsDataBreakpointBytes => boolean(),
            breakpointModes => [breakpointMode()]}.

checksum/0

-type checksum() :: #{algorithm := checksumAlgorithm(), checksum := binary()}.

checksumAlgorithm/0

-type checksumAlgorithm() :: binary().

'MD5' | 'SHA1' | 'SHA256' | timestamp.

columnDescriptor/0

-type columnDescriptor() ::
          #{attributeName := binary(),
            label := string(),
            format => binary(),
            type => string | number | boolean | unixTimestampUTC,
            width => number()}.

command/0

-type command() :: binary().

continue_request_arguments/0

-type continue_request_arguments() :: #{threadId := thread_id(), singleThread => boolean()}.

continue_response/0

-type continue_response() ::
          #{success := boolean(), message => binary(), body := #{allThreadsContinued => boolean()}}.

disconnect_request_arguments/0

-type disconnect_request_arguments() ::
          #{restart => boolean(), terminateDebuggee => boolean(), supportSuspendDebuggee => boolean()}.

disconnect_response/0

-type disconnect_response() :: #{success := boolean()}.

error_response/0

-type error_response() :: #{success := false, body => #{error => message()}}.

event/0

-type event() :: #{seq := seq(), type := event, event := event_type(), body => body()}.

event_type/0

-type event_type() :: binary().

exceptionBreakpointsFilter/0

-type exceptionBreakpointsFilter() ::
          #{filter := binary(),
            label := binary(),
            description => binary(),
            default => boolean(),
            supportsCondition => boolean(),
            conditionDescription => binary()}.

exited_event_body/0

-type exited_event_body() :: #{exitCode := number()}.

frame/0

-opaque frame()

initialize_request_arguments/0

-type initialize_request_arguments() ::
          #{clientID => binary(),
            clientName => binary(),
            adapterID := binary(),
            locale => binary(),
            linesStartAt1 => boolean(),
            columnsStartAt1 => boolean(),
            pathFormat => path | uri,
            supportsVariableType => boolean(),
            supportsVariablePaging => boolean(),
            supportsRunInTerminalRequest => boolean(),
            supportsMemoryReferences => boolean(),
            supportsProgressReporting => boolean(),
            supportsInvalidatedEvent => boolean(),
            supportsMemoryEvent => boolean(),
            supportsArgsCanBeInterpretedByShell => boolean(),
            supportsStartDebuggingRequest => boolean()}.

initialize_response/0

-type initialize_response() :: #{success := boolean(), message => binary(), body => capabilities()}.

initialized_event_body/0

-type initialized_event_body() :: #{}.

launch_request_arguments/0

-type launch_request_arguments() ::
          #{launchCommand :=
                #{cwd := binary(),
                  command := binary(),
                  arguments => [binary()],
                  env => #{binary() => binary()}},
            targetNode := target_node(),
            stripSourcePath => binary()}.

launch_response/0

-type launch_response() :: #{success := boolean()}.

message/0

-type message() ::
          #{id := number(),
            format := binary(),
            variables => #{binary() => binary()},
            sendTelemetry => boolean(),
            showUser => boolean(),
            url => binary(),
            urlLabel => binary()}.

next_request_arguments/0

-type next_request_arguments() ::
          #{threadId := number(), singleThread => boolean(), granularity => stepping_granularity()}.

next_response/0

-type next_response() :: #{success := boolean(), message => binary(), body := #{}}.

protocol_message/0

-type protocol_message() :: #{seq := seq(), type := protocol_message_type()}.

protocol_message_type/0

-type protocol_message_type() :: request | response | event.

request/0

-type request() :: #{seq := seq(), type := request, command := command(), arguments => arguments()}.

response/0

-type response() ::
          #{seq := seq(),
            type := response,
            request_seq := seq(),
            success := boolean(),
            command := command(),
            message => binary(),
            body => body()}.

run_in_terminal_request_arguments/0

-type run_in_terminal_request_arguments() ::
          #{kind => binary(),
            title => binary(),
            cwd => binary(),
            args := [binary()],
            env => #{binary() => binary()},
            argsCanBeInterpretedByShell => boolean()}.

run_in_terminal_response/0

-type run_in_terminal_response() ::
          #{success := boolean(),
            message => binary(),
            body := #{processId => number(), shellProcessId => number()}}.

scope/0

-type scope() ::
          #{name := binary(),
            presentationHint => binary(),
            variablesReference := number(),
            namedVariables => number(),
            indexedVariables => number(),
            expensive := boolean(),
            source => source(),
            line => number(),
            column => number(),
            endLine => number(),
            endColumn => number()}.

scopes_request_arguments/0

-type scopes_request_arguments() :: #{frameId := number()}.

scopes_response/0

-type scopes_response() :: #{success := boolean(), message => binary(), body := #{scopes := [scope()]}}.

seq/0

-type seq() :: pos_integer().

set_breakpoints_request_arguments/0

-type set_breakpoints_request_arguments() ::
          #{source := source(),
            breakpoints => [sourceBreakpoint()],
            lines => [number()],
            sourceModified => boolean()}.

set_breakpoints_response/0

-type set_breakpoints_response() :: #{success := boolean(), message => binary(), body => breakpoints()}.

source/0

-type source() ::
          #{name => binary(),
            path => binary(),
            sourceReference => number(),
            presentationHint => binary(),
            origin => binary(),
            sources => [source()],
            adapterData => map(),
            checksums => [checksum()]}.

sourceBreakpoint/0

-type sourceBreakpoint() ::
          #{line := number(),
            column => number(),
            condition => binary(),
            hitCondition => binary(),
            logMessage => binary(),
            mode => binary()}.

erlfmt:ignore

stack_frame/0

-type stack_frame() ::
          #{id := number(),
            name := binary(),
            source => source(),
            line := number(),
            column := number(),
            endLine => number(),
            endColumn => number(),
            canRestart => boolean(),
            instructionPointerReference => binary(),
            moduleId => number() | binary(),
            presentationHint => binary()}.

stack_frame_format/0

-type stack_frame_format() ::
          #{hex => boolean(),
            parameters => boolean(),
            parameterTypes => boolean(),
            parameterNames => boolean(),
            parameterValues => boolean(),
            line => boolean(),
            module => boolean(),
            includeAll => boolean()}.

stack_trace_request_arguments/0

-type stack_trace_request_arguments() ::
          #{threadId := thread_id(),
            startFrame => number(),
            levels => number(),
            format => stack_frame_format()}.

stack_trace_response/0

-type stack_trace_response() ::
          #{success := boolean(),
            message => binary(),
            body := #{stackFrames := [stack_frame()], totalFrames => number()}}.

step_out_request_arguments/0

-type step_out_request_arguments() ::
          #{threadId := number(), singleThread => boolean(), granularity => stepping_granularity()}.

step_out_response/0

-type step_out_response() :: #{success := boolean(), message => binary(), body := #{}}.

stepping_granularity/0

-type stepping_granularity() :: statement | line | instruction.

stopped_event_body/0

-type stopped_event_body() ::
          #{reason := binary(),
            description => binary(),
            threadId => thread_id(),
            preserveFocusHint => boolean(),
            text => binary(),
            allThreadsStopped => boolean(),
            hitBreakpointIds => [number()]}.

target_node/0

-type target_node() :: #{name := binary(), cookie => binary(), type => binary()}.

terminated_event_body/0

-type terminated_event_body() :: #{restart => true | map()}.

thread/0

-type thread() :: #{id := number(), name := binary()}.

thread_id/0

-type thread_id() :: number().

threads/0

-type threads() :: #{threads := [thread()]}.

threads_request_arguments/0

-type threads_request_arguments() :: #{}.

threads_response/0

-type threads_response() :: #{success := boolean(), body => threads()}.

value_format/0

-type value_format() :: #{hex => boolean()}.

variable/0

-type variable() ::
          #{name := binary(),
            value := binary(),
            type => binary(),
            presentationHint => variable_presentation_hint(),
            evaluateName => binary(),
            variablesReference := number(),
            namedVariables => number(),
            indexedVariables => number(),
            memoryReference => binary(),
            declarationLocationReference => number(),
            valueLocationReference => number()}.

variable_presentation_hint/0

-type variable_presentation_hint() ::
          #{kind => binary(), attributes => [binary()], visibility => binary(), lazy => boolean()}.

variables_request_arguments/0

-type variables_request_arguments() ::
          #{variablesReference := number(),
            filter => binary(),
            start => number(),
            count => number(),
            format => value_format()}.

variables_response/0

-type variables_response() ::
          #{success := boolean(), message => binary(), body := #{variables => [variable()]}}.

Functions

build_error_response(Id, Format)

-spec build_error_response(number(), binary()) -> error_response().

decode_frames(Data)

-spec decode_frames(binary()) -> {[frame()], binary()}.

encode_frame(_)

-spec encode_frame(frame()) -> binary().

frame(Message)

-spec frame(request() | response() | event()) -> frame().

stack_frame(Context, Pid, _)

-spec stack_frame(edb_dap_state:context(), pid(), edb:stack_frame()) -> stack_frame().

thread_name(Pid, Info)

-spec thread_name(pid(), edb:process_info()) -> binary().

to_binary(String)

-spec to_binary(io_lib:chars()) -> binary().

unframe(_)

-spec unframe(frame()) -> request() | response().