dap

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package dap provides a small yottacode-owned Debug Adapter Protocol client. It delegates protocol structs and message framing to github.com/google/go-dap, while this package owns request correlation, event delivery, timeouts, and debug-adapter process teardown policy.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRequestTimeout marks a DAP request that did not receive a response
	// before the configured request deadline.
	ErrRequestTimeout = errors.New("DAP request timed out")

	// ErrProtocolMalformed marks invalid DAP framing or a message that could not
	// be decoded by the go-dap protocol codec.
	ErrProtocolMalformed = errors.New("malformed DAP protocol message")

	// ErrSessionClosed marks attempts to use a client after its transport has
	// closed or after the adapter process has exited.
	ErrSessionClosed = errors.New("DAP session closed")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client speaks DAP over one bidirectional stream. It is safe for concurrent requests; asynchronous adapter events are delivered through Events.

func NewClient

func NewClient(conn io.ReadWriteCloser, opts ClientOptions) (*Client, error)

NewClient starts the reader loop for conn and returns a DAP client bound to that transport. The caller remains responsible for closing process resources unless it uses StartSession.

func (*Client) Attach

func (c *Client) Attach(ctx context.Context, args map[string]any) error

Attach connects to a debuggee through implementation-specific adapter arguments.

func (*Client) Close

func (c *Client) Close(context.Context) error

Close closes the underlying transport and releases pending requests. It does not send a DAP disconnect request; callers that need protocol-level teardown should call Disconnect first.

func (*Client) ConfigurationDone

func (c *Client) ConfigurationDone(ctx context.Context) error

ConfigurationDone tells the adapter that breakpoint configuration is complete.

func (*Client) Continue

Continue resumes execution for a thread.

func (*Client) Disconnect

func (c *Client) Disconnect(ctx context.Context, args godap.DisconnectArguments) error

Disconnect requests protocol-level teardown from the debug adapter.

func (*Client) Done

func (c *Client) Done() <-chan error

Done reports why the reader loop ended. A nil error means the client was closed intentionally.

func (*Client) Evaluate

Evaluate evaluates an expression in the adapter-selected context.

func (*Client) EventOverflow

func (c *Client) EventOverflow() bool

EventOverflow reports whether any adapter events were dropped because the consumer fell behind. Lifecycle events are preserved preferentially.

func (*Client) Events

func (c *Client) Events() <-chan godap.EventMessage

Events returns the asynchronous event stream from the debug adapter. The stream closes when the client closes or the adapter transport fails.

func (*Client) Initialize

Initialize sends DAP initialize and returns the adapter capabilities.

func (*Client) Launch

func (c *Client) Launch(ctx context.Context, args map[string]any) error

Launch starts a debuggee through implementation-specific adapter arguments.

func (*Client) Next

func (c *Client) Next(ctx context.Context, args godap.NextArguments) error

Next steps over the next source statement for a thread.

func (*Client) Scopes

Scopes returns variable scopes for a stack frame.

func (*Client) SetBreakpoints

SetBreakpoints replaces breakpoints for one source file.

func (*Client) StackTrace

StackTrace returns frames for a stopped thread.

func (*Client) StepIn

func (c *Client) StepIn(ctx context.Context, args godap.StepInArguments) error

StepIn steps into the next call target for a thread.

func (*Client) StepOut

func (c *Client) StepOut(ctx context.Context, args godap.StepOutArguments) error

StepOut steps out of the current frame for a thread.

func (*Client) Variables

Variables returns children for a DAP variables reference.

type ClientOptions

type ClientOptions struct {
	RequestTimeout time.Duration
}

ClientOptions tunes request behavior for an already-open DAP transport.

type Session

type Session struct {
	*Client
	Cmd *exec.Cmd
	// contains filtered or unexported fields
}

Session owns a debug adapter process and its DAP client. Closing the session first attempts protocol-level disconnect, then kills the process if needed.

func StartSession

func StartSession(ctx context.Context, opts SessionOptions) (*Session, error)

StartSession starts a debug adapter process and wires its stdio to a Client.

func (*Session) Close

func (s *Session) Close(ctx context.Context) error

Close disconnects from the adapter and guarantees process teardown. A failed graceful disconnect does not prevent forceful cleanup.

type SessionOptions

type SessionOptions struct {
	Command string
	Args    []string
	Dir     string
	Env     []string

	// StartupTimeout is reserved for future adapter readiness probing. The first
	// initialize request currently proves protocol readiness and is bounded by
	// RequestTimeout.
	StartupTimeout time.Duration
	RequestTimeout time.Duration
}

SessionOptions configures a supervised debug adapter process.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL