dap

package
v0.1.155 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(lang languages.Language, cfg *LanguageConfig)

Register adds a language config to the DAP registry.

Types

type BreakpointResult

type BreakpointResult struct {
	ID       int
	Verified bool
	File     string
	Line     int
	Message  string
}

BreakpointResult represents a verified breakpoint.

type Client

type Client interface {
	// Launch starts a new debug target process.
	Launch(ctx context.Context, program string, args []string, env map[string]string) error

	// Attach connects to an already-running process.
	Attach(ctx context.Context, pid int) error

	// SetBreakpoints sets breakpoints for a file, replacing any previous ones.
	SetBreakpoints(ctx context.Context, file string, lines []int) ([]BreakpointResult, error)

	// SetFunctionBreakpoints sets breakpoints by function name.
	SetFunctionBreakpoints(ctx context.Context, names []string) ([]BreakpointResult, error)

	// Continue resumes execution until next breakpoint or termination.
	Continue(ctx context.Context, threadID int) error

	// Next steps over one source line.
	Next(ctx context.Context, threadID int) error

	// StepIn steps into a function call.
	StepIn(ctx context.Context, threadID int) error

	// StepOut steps out of the current function.
	StepOut(ctx context.Context, threadID int) error

	// Pause suspends execution of a thread.
	Pause(ctx context.Context, threadID int) error

	// Threads returns all threads in the debuggee.
	Threads(ctx context.Context) ([]ThreadInfo, error)

	// StackTrace returns the call stack for a thread.
	StackTrace(ctx context.Context, threadID int) ([]StackFrame, error)

	// Scopes returns the variable scopes for a stack frame.
	Scopes(ctx context.Context, frameID int) ([]Scope, error)

	// Variables returns child variables for a variablesReference.
	Variables(ctx context.Context, ref int) ([]Variable, error)

	// Evaluate evaluates an expression in the context of a frame.
	Evaluate(ctx context.Context, frameID int, expression string) (*Variable, error)

	// OnStopped registers a callback for stopped events.
	OnStopped(handler func(StoppedEvent))

	// OnOutput registers a callback for output events.
	OnOutput(handler func(OutputEvent))

	// OnTerminated registers a callback for when the debuggee exits.
	OnTerminated(handler func())

	// Close terminates the debug session and shuts down the adapter.
	Close(ctx context.Context) error
}

Client is a language-agnostic DAP client interface. Implementations talk to a debug adapter (e.g. dlv dap, debugpy) running inside a companion environment (Docker, Nix, or local).

func NewClient

func NewClient(ctx context.Context, lang languages.Language, sourceDir string) (Client, error)

NewClient creates a DAP client for the given language and source directory. The source directory is the root where the language project lives (e.g. where go.mod or pyproject.toml is). Ports are picked dynamically. Backend is auto-detected. The caller must call Close() when done.

type LanguageConfig

type LanguageConfig struct {
	// CompanionImage returns the Docker image for this language companion.
	// May return nil if the language can run locally or via Nix.
	CompanionImage func(ctx context.Context) (*resources.DockerImage, error)

	// DAPBinary is the debug adapter binary (e.g. "dlv").
	DAPBinary string

	// DAPListenArgs returns the arguments to start the DAP server on a given port.
	// Never hardcode a port.
	DAPListenArgs func(port int) []string

	// LanguageID is the language identifier (e.g. "go", "python").
	LanguageID string

	// SetupRunner is an optional hook to configure the companion runner
	// before Init (e.g. mount caches). May be nil.
	// Uses the CompanionRunner interface -- works with any backend.
	SetupRunner func(ctx context.Context, runner runners.CompanionRunner, sourceDir string)
}

LanguageConfig holds per-language settings for the DAP companion.

type OutputEvent

type OutputEvent struct {
	Category string // "console", "stdout", "stderr"
	Output   string
}

OutputEvent is emitted when the debuggee produces output.

type Scope

type Scope struct {
	Name string
	Ref  int // variablesReference to get the scope's variables
}

Scope represents a variable scope within a stack frame.

type StackFrame

type StackFrame struct {
	ID     int
	Name   string
	File   string
	Line   int
	Column int
}

StackFrame represents a frame in a call stack.

type StoppedEvent

type StoppedEvent struct {
	ThreadID int
	Reason   string // "breakpoint", "step", "exception", "pause"
}

StoppedEvent is emitted when the debuggee stops.

type ThreadInfo

type ThreadInfo struct {
	ID   int
	Name string
}

ThreadInfo represents a thread in the debuggee.

type Variable

type Variable struct {
	Name  string
	Value string
	Type  string
	Ref   int // variablesReference for structured types (0 = leaf)
}

Variable represents a variable or expression result.

Jump to

Keyboard shortcuts

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