debug

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package debug is the debug model of the editor (SPEC §10.31, D39, D41, D43): the data of Run and Debug (sessions, threads, stack frames loaded on demand, scopes and variables loaded lazily and in pages, watch expressions, breakpoints of every kind with their verification and the moves the adapter makes), the session driver that runs VS Code's sequence over the DAP client of core/dap (initialize, launch or attach, the initialized event, the breakpoints, configurationDone, the events, restart, stop, disconnect, child sessions and compounds), the launch configurations (launch.json, the launch setting, the variables and the inputs) and the state that is saved with the workspace (§10.10).

It has no user interface and imports no Glutter. Everything that belongs to the window comes through callbacks in Options: how to reach the adapter of a type, the configuration providers of the debuggers, the tasks that run before and after a session, the prompts of the inputs, the terminal of runInTerminal, the active editor for ${file}. Nothing here touches the real configuration of the user.

Threads. The model is safe for use from several goroutines. A session reads its adapter on a goroutine of its own and makes all its requests on other goroutines, never from the loop that takes the events (the event channel of core/dap is bounded and a request made from that loop could wait behind events nobody takes). Changes are announced to the subscribers (Service.Subscribe) from the goroutine that made them, after the lock is released; a subscriber must not block, and the window hands the work over to its UI thread (CLAUDE.md). The documents belong to the UI thread: the Tracker, which moves breakpoints with the edits of their documents, is called from it.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (the model), browser/debugSession.ts and browser/rawDebugSession.ts (the session), browser/debugService.ts (starting, restarting and stopping, the breakpoints), browser/debugConfigurationManager.ts (the launches and the selected configuration), common/debugStorage.ts (the state), common/debugUtils.ts (the configurations by platform, their order), and the configuration resolver of src/vs/workbench/services/configurationResolver/ (the variables and the inputs).

Index

Constants

View Source
const BaseChunkSize = 100

BaseChunkSize is how many children are fetched at once; a container with more indexed children shows them as chunks that are fetched when opened (variable paging, VS Code's issue 9537).

View Source
const DisconnectTimeout = 2 * time.Second

DisconnectTimeout is how long the disconnect request of a shutdown may take; 200 ms when the adapter is already known to be gone.

View Source
const InputMemoryCapacity = 5

InputMemoryCapacity is how many inputs' last values are kept (VS Code's LAST_INPUT_CACHE_SIZE).

View Source
const LaunchFileName = ".emetos/launch.json"

LaunchFileName is the path of the launch file below a folder (SPEC §10.31, D41): VS Code's format in the folder of Emetos. ".vscode/launch.json" is not read (D12).

View Source
const MaxInlineLength = 150

MaxInlineLength is the number of characters of the text after a line; a longer text is cut and ends with "...".

View Source
const MaxInlineValues = 100

MaxInlineValues is the number of variables of a scope that are looked for (the global scope of JavaScript has 700 or more).

View Source
const MaxReplHistory = 100

MaxReplHistory is how many expressions of the Debug Console's history are kept.

View Source
const MaxStateBreakpoints = 10000

MaxStateBreakpoints bounds the breakpoints a saved state may hold, so that a damaged file cannot make the model huge.

View Source
const NotAvailable = "not available"

NotAvailable is the value of a watch expression that has not been evaluated (VS Code's "not available").

View Source
const StateVersion = 1

StateVersion is the version of the saved debug state.

View Source
const TriggeredBreakpointMaxDelay = 1500 * time.Millisecond

TriggeredBreakpointMaxDelay is how long a step or continue waits for the breakpoints that a hit breakpoint enabled to reach the adapter.

View Source
const UnknownSourceLabel = "Unknown Source"

UnknownSourceLabel is the name of the source of a frame that has none.

Variables

View Source
var DefaultReplConfig = ReplConfig{CollapseIdenticalLines: true, MaximumLines: 10000}

DefaultReplConfig is VS Code's default of the two settings.

View Source
var ErrOpenLaunchFile = &errors.Error{Tag: "DebugOpenLaunchFile"}

ErrOpenLaunchFile is what a configuration provider returns to cancel the launch and have launch.json shown (VS Code's null result).

Functions

func ByteOfColumn

func ByteOfColumn(line string, column int) int

ByteOfColumn is the byte offset in a line of a column counted from 1 in UTF-16 code units (how the protocol counts), clamped to the line.

func ColumnOfByte

func ColumnOfByte(line string, off int) int

ColumnOfByte is the column, counted from 1 in UTF-16 code units, of a byte offset in a line.

func EvaluatableExpression

func EvaluatableExpression(line string, column int) (text string, startColumn, endColumn int)

EvaluatableExpression is the expression to evaluate at a column of a line (counted from 1, in characters): its text and the columns it covers, the end column excluded. The text is empty when the position is not in an expression.

func ExactExpression

func ExactExpression(line string, looseStart, looseEnd int) (start, end int)

ExactExpression finds the expression around the columns looseStart to looseEnd of a line. The columns count characters from 1; the result is the first and the last column of the expression, or 0 and 0 when there is none. When there are non-word characters after the cursor the expression is cut there: in `a.b.c.d` with the cursor under `b`, `a.b` is the expression.

func InlineHover

func InlineHover(full string) string

InlineHover is the text of the hover of the values of a line: each `name = value` on a line of its own when there are several, a value that spans lines indented under its name. A text of one value is shown as it is.

func InlineText

func InlineText(values []InlineVariable, maxChars int) (shown, full string)

InlineText is the text written after a line for its values, `a = 1, b = 2`, cut to maxChars characters (with "..." after it) when it is longer; full is the text before it was cut. A new line or a tab in a value is a space.

func LaunchFilePath

func LaunchFilePath(folder string) string

LaunchFilePath is the launch file of a folder.

func LaunchFromSetting

func LaunchFromSetting(value any) (LaunchFile, []Problem)

LaunchFromSetting reads the value of the launch setting (the user's or the workspace's) as a launch file. The Problems have no place in a text (Offset is -1).

func ParseLaunch

func ParseLaunch(text string) (LaunchFile, []Problem)

ParseLaunch reads the text of a launch.json (JSONC: comments and trailing commas are allowed). It is tolerant: it returns what it could read, and a Problem for each thing that is wrong, with its place.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugSchemas.ts (launchSchema), for the checks.

func ReadLaunchFile

func ReadLaunchFile(ctx context.Context, folder string) (f LaunchFile, problems []Problem, found bool, err error)

ReadLaunchFile reads <folder>/.emetos/launch.json. found is false when the file does not exist (that is not an error: a folder without a launch file has no configurations). It fails with the tag LaunchFileReadFailed.

func ResolveString

func ResolveString(ctx context.Context, vc *VariableContext, value string, opts ResolveOptions) (resolved string, ok bool, err error)

ResolveString is ResolveConfig for one text.

func WithSession

func WithSession(ctx context.Context, s *Session) context.Context

WithSession returns a context that carries the session whose adapter is being reached. The service gives it to Debugger.Connect, so that the debugger of an extension can hand the session to the extension (the descriptor factory and the trackers of step 25.3 are asked about a session, as in VS Code) without changing the signature of ConnectFunc.

Types

type Breakpoint

type Breakpoint struct {
	ID string
	// Path is the file the user set the breakpoint in; SourcePath is the file the adapter verified it in (the same, usually).
	Path       string
	SourcePath string
	// Line and Column count from 1; Column is 0 for a breakpoint of the whole line.
	Line, Column int
	// EndLine and EndColumn are the end of the range the adapter verified, or 0.
	EndLine, EndColumn int
	// RequestedLine and RequestedColumn are the position the user set.
	RequestedLine, RequestedColumn int
	Enabled                        bool
	Condition, HitCondition        string
	LogMessage                     string
	Mode, ModeLabel                string
	// TriggeredBy is the id of the breakpoint whose hit enables this one ("Wait for Breakpoint").
	TriggeredBy string
	// Verified is false while an adapter has not accepted the breakpoint, and for a file with unsaved changes; Message says why.
	Verified bool
	Message  string
	// Pending is true for a triggered breakpoint no session has been asked about yet.
	Pending bool
	// Supported is false when the session that knows the breakpoint cannot do what it asks (a condition, a log message).
	Supported bool
	// AdapterData is what the adapter attached to the source of the breakpoint.
	AdapterData json.RawMessage
}

Breakpoint is a snapshot of a breakpoint of a line or a column, as the views and the editor read it. Line and Column are where the breakpoint is shown (where the adapter put it when it verified it); RequestedLine and RequestedColumn are what the user set, moved with the edits of the document, which is what is saved and sent.

func (Breakpoint) Inline

func (b Breakpoint) Inline() bool

Inline reports whether the breakpoint is at a column.

func (Breakpoint) IsLogpoint

func (b Breakpoint) IsLogpoint() bool

IsLogpoint reports whether the breakpoint prints a message instead of stopping.

type BreakpointData

type BreakpointData struct {
	// ID is kept when it is not empty (a restored breakpoint); else one is made.
	ID           string
	Line, Column int
	Disabled     bool
	Condition    string
	HitCondition string
	LogMessage   string
	Mode         string
	ModeLabel    string
	TriggeredBy  string
}

BreakpointData describes a breakpoint to add.

type BreakpointFilter

type BreakpointFilter struct {
	// Path matches the path where the breakpoint is shown (SourcePath), OriginalPath the path the user set it in.
	Path, OriginalPath string
	Line, Column       int
	// EnabledOnly drops the disabled ones, and all when breakpoints are not activated.
	EnabledOnly bool
	// TriggeredOnly keeps the breakpoints that wait for another.
	TriggeredOnly bool
}

BreakpointFilter selects breakpoints; the zero value selects all.

type BreakpointUpdate

type BreakpointUpdate struct {
	Line         int
	Column       *int
	Condition    *string
	HitCondition *string
	LogMessage   *string
	Mode         *string
	ModeLabel    *string
	TriggeredBy  *string
}

BreakpointUpdate describes what to change in a breakpoint: nil (and 0 for the line) leave a member as it is.

type BreakpointsChange

type BreakpointsChange struct {
	Added, Removed, Changed []string
	// SessionOnly is true when only the data of the sessions changed (verified, moved): nothing to save.
	SessionOnly bool
}

BreakpointsChange lists the breakpoints an EventBreakpoints is about, by id.

type CompletionKind

type CompletionKind string

CompletionKind says what a LaunchCompletion offers.

const (
	// CompleteProperty is the name of an attribute.
	CompleteProperty CompletionKind = "property"
	// CompleteValue is a value: an enum member, a boolean, a default, a debug type or a request.
	CompleteValue CompletionKind = "value"
	// CompleteSnippet is a whole configuration of a debugger.
	CompleteSnippet CompletionKind = "snippet"
)

The kinds of a LaunchCompletion.

type Compound

type Compound struct {
	Name string
	// StopAll makes the end of one session stop all the sessions of the compound.
	StopAll bool
	// PreLaunchTask runs before any configuration of the compound starts.
	PreLaunchTask TaskRef
	// Configurations are the entries to start.
	Configurations []CompoundRef
	Presentation   *Presentation
}

Compound starts several configurations together.

type CompoundRef

type CompoundRef struct {
	Name   string
	Folder string
}

CompoundRef is an entry of the configurations of a compound: a name, with the folder it is in when the entry is an object.

type CompoundRoot

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

CompoundRoot ends all the sessions of a compound with stopAll when one of them is stopped.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debug.ts (DebugCompoundRoot)

func (*CompoundRoot) OnSessionStop

func (c *CompoundRoot) OnSessionStop(fn func())

OnSessionStop registers fn to run, once, when a session of the compound is stopped.

func (*CompoundRoot) SessionStopped

func (c *CompoundRoot) SessionStopped()

SessionStopped tells the compound a session was stopped; the others stop, once.

type Config

type Config map[string]any

Config is a launch configuration: a JSON object whose values are the Go values of encoding/json (string, float64, bool, nil, []any and map[string]any). The attributes are the debugger's; the model reads name, type, request, presentation, the task attributes and noDebug.

func ResolveConfig

func ResolveConfig(ctx context.Context, vc *VariableContext, cfg Config, opts ResolveOptions) (resolved Config, ok bool, err error)

ResolveConfig substitutes the variables in every string of the configuration, in the names of its attributes as well, and returns the substituted copy; the platform attributes (linux) are applied first and the others dropped. A variable it cannot resolve stops the launch with the reason in an error (the tags of resolveBuiltin, command and input); ok is false, with no error, when the user cancelled an input or a command. A variable the resolver does not know stays as written.

Ported from VS Code: src/vs/workbench/services/configurationResolver/common/configurationResolverExpression.ts, common/variableResolver.ts and browser/baseConfigurationResolverService.ts

func (Config) Clone

func (c Config) Clone() Config

Clone is a deep copy of the configuration.

func (Config) Name

func (c Config) Name() string

Name is the name of the configuration, or empty.

func (Config) NoDebug

func (c Config) NoDebug() bool

NoDebug reports whether the configuration runs without debugging.

func (Config) Presentation

func (c Config) Presentation() *Presentation

Presentation reads the presentation attribute; a configuration without one gives nil.

func (Config) Request

func (c Config) Request() string

Request is "launch" or "attach" (or what the file says).

func (Config) String

func (c Config) String(key string) string

String is the string attribute key, or empty.

func (Config) Task

func (c Config) Task(key string) TaskRef

Task reads a task attribute (preLaunchTask, postDebugTask, preRestartTask, postRestartTask); a missing or empty one gives the zero TaskRef.

func (Config) Type

func (c Config) Type() string

Type is the debug type of the configuration, or empty.

type ConnectFunc

type ConnectFunc func(ctx context.Context, cfg Config, opts dap.ClientOptions) (*dap.Client, error)

ConnectFunc reaches the debug adapter of a configuration and starts a client over the connection with the given options (which carry the session's handler of the adapter's requests). The context is the life of the adapter's program.

func AdapterConnector

func AdapterConnector(adapter func(ctx context.Context, cfg Config) (dap.Adapter, error)) ConnectFunc

AdapterConnector makes a ConnectFunc of a function that says where the adapter is (the descriptor of a debugger, step 25.3).

type Debugger

type Debugger struct {
	// Type is the debug type of the configurations it runs.
	Type string
	// Label is the name shown to the user.
	Label string
	// Connect reaches the adapter.
	Connect ConnectFunc
	// Variables maps the names of interactive variables (${command:pickProcess}) to the ids of commands.
	Variables map[string]string
	// Languages are the languages the debugger is the default one for.
	Languages []string
}

Debugger is a debug type that can be started: the contribution of a language extension.

type DebuggerSchema

type DebuggerSchema struct {
	// Type is the debug type.
	Type string
	// Label is its name for the user.
	Label string
	// Attributes are the JSON schemas of the attributes of a configuration, by request ("launch" and "attach"). The schema is an
	// object schema with properties, and may have required, additionalProperties, description and the members described at
	// CheckAttributes.
	Attributes map[string]map[string]any
	// Snippets are the configurations that a new item of "configurations" is offered.
	Snippets []Snippet
}

DebuggerSchema is what the checks and the completion of launch.json need to know of a debug type: the JSON schemas of its attributes (the debugger's configurationAttributes) and the configurations it suggests. The extensions' manifests (Contributes.Debuggers) are turned into these.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugger.ts (the schema built from the contribution) and src/vs/workbench/contrib/debug/common/debugSchemas.ts (launchSchema)

type DynamicSelection

type DynamicSelection struct {
	// Type is the debug type whose provider gave it.
	Type string
	// Name is its name.
	Name string
}

DynamicSelection is a dynamic configuration the selection can point at: provided by a debugger, not written in a launch file.

type DynamicType

type DynamicType struct {
	Type  string
	Label string
}

DynamicType is a debug type that provides dynamic configurations.

type Event

type Event struct {
	Kind        EventKind
	Session     *Session
	Thread      *Thread
	Breakpoints BreakpointsChange
	Expression  *Expression
	Output      *dap.OutputEventBody
	Node        Node
	DAP         *dap.Event
	ExitCode    int
	Restart     bool
	// First is true for the EventSessionStarted of the first session started in the window (debug.internalConsoleOptions has a case for it).
	First bool
	// Err is why an adapter ended when it was not asked to: a crash (EventSessionEnded).
	Err error
}

Event is a change of the model. See Service.Subscribe.

type EventKind

type EventKind int

EventKind says what an Event is about.

const (
	// EventSessions is a change of the list of sessions or of a session's name or state.
	EventSessions EventKind = iota + 1
	// EventCallStack is a change of the threads or their stack frames.
	EventCallStack
	// EventBreakpoints is a change of breakpoints (Event.Breakpoints says which).
	EventBreakpoints
	// EventWatch is a change of the list of watch expressions.
	EventWatch
	// EventWatchValue is a watch expression whose value changed (Event.Expression).
	EventWatchValue
	// EventVariables is a variable whose value was changed or loaded lazily.
	EventVariables
	// EventFocus is a change of the focused session, thread or stack frame.
	EventFocus
	// EventOutput is an output event of the adapter (Event.Output); for a variablesReference Event.Node holds the container.
	EventOutput
	// EventCapabilities is a capabilities event.
	EventCapabilities
	// EventLoadedSource is a loadedSource event (Event.DAP).
	EventLoadedSource
	// EventCustom is an event no one else handles: an adapter's own (Event.DAP).
	EventCustom
	// EventProgress is a progressStart, progressUpdate or progressEnd event (Event.DAP).
	EventProgress
	// EventInvalidated is an invalidated event.
	EventInvalidated
	// EventExited is the exit of the debuggee (Event.ExitCode).
	EventExited
	// EventSessionEnded is the end of a session's adapter (Event.Restart is true when a restart follows).
	EventSessionEnded
	// EventConfiguration is a change of the launches or of the selected configuration.
	EventConfiguration
	// EventSessionStarted is a session whose launch or attach request was answered (VS Code's onDidNewSession).
	EventSessionStarted
	// EventStopped is a thread that stopped and has its top frame (Event.Thread), before the rest of its stack is loaded; the window opens
	// the source then.
	EventStopped
	// EventRepl is a change of the Debug Console of a session (Event.Session is the session that owns the console; see Session.Repl).
	EventRepl
)

func (EventKind) AffectsState

func (k EventKind) AffectsState() bool

AffectsState tells whether an event changes what is saved with the workspace (SaveState).

type ExceptionBreakpoint

type ExceptionBreakpoint struct {
	ID                   string
	Filter               string
	Label                string
	Description          string
	ConditionDescription string
	SupportsCondition    bool
	Enabled              bool
	Condition            string
	// Fallback marks the filters shown when no session runs: those of the session that was focused last.
	Fallback bool
}

ExceptionBreakpoint is a snapshot of an exception filter of an adapter, with the user's choice.

type ExceptionInfo

type ExceptionInfo struct {
	ID          string
	Description string
	BreakMode   string
	Details     *dap.ExceptionDetails
}

ExceptionInfo is the exception a thread stopped on.

type Expression

type Expression struct {

	// Name is the expression's text.
	Name string
	// contains filtered or unexported fields
}

Expression is a watch expression, or an expression the Debug Console evaluates: a name, evaluated in a frame.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (Expression)

func NewExpression

func NewExpression(name string) *Expression

NewExpression makes an expression to evaluate with Evaluate (the Debug Console's input); watch expressions come from the Model.

func (*Expression) Available

func (e *Expression) Available() bool

Available tells whether the last evaluation worked.

func (*Expression) Children

func (c *Expression) Children(ctx context.Context) ([]*Variable, error)

Children loads the children of the node once. See Node.

func (*Expression) Evaluate

func (e *Expression) Evaluate(ctx context.Context, s *Session, frame *StackFrame, evalContext string, keepLazy bool) error

Evaluate evaluates the expression in a frame (or, for the context "repl", in the session alone) and keeps the answer. A failure of the adapter is the value of the expression, as in VS Code; the error is that failure, for the callers that care.

func (*Expression) EvaluateLazy

func (c *Expression) EvaluateLazy(ctx context.Context) error

EvaluateLazy asks the adapter for the value of a lazy variable and takes it over. It fails with the tags of the request.

func (*Expression) HasChildren

func (c *Expression) HasChildren() bool

HasChildren is true for a node with a reference that is not lazy.

func (*Expression) ID

func (c *Expression) ID() string

ID is the id of the node.

func (*Expression) IndexedVariables

func (c *Expression) IndexedVariables() int

IndexedVariables is the number of indexed children the adapter announced.

func (*Expression) MemoryReference

func (c *Expression) MemoryReference() string

MemoryReference is the adapter's memory reference.

func (*Expression) NamedVariables

func (c *Expression) NamedVariables() int

NamedVariables is the number of named children the adapter announced.

func (*Expression) PresentationHint

func (c *Expression) PresentationHint() *dap.VariablePresentationHint

PresentationHint is the adapter's hint.

func (*Expression) Reference

func (c *Expression) Reference() int

Reference is the variablesReference of the node.

func (*Expression) Session

func (c *Expression) Session() *Session

Session is the session that gave the node.

func (*Expression) SetValue

func (e *Expression) SetValue(ctx context.Context, frame *StackFrame, value string) error

SetValue changes the value of the expression in the debuggee with setExpression.

func (*Expression) String

func (e *Expression) String() string

String is the name and the value on two lines.

func (*Expression) Type

func (c *Expression) Type() string

Type is the type of the node.

func (*Expression) Value

func (c *Expression) Value() string

Value is the value of the node.

func (*Expression) ValueChanged

func (c *Expression) ValueChanged() bool

ValueChanged is true when the value differs from the one the node had before.

type Focus

type Focus struct {
	Session *Session
	Thread  *Thread
	Frame   *StackFrame
}

Focus is the session, thread and stack frame the views show (VS Code's view model).

type Folder

type Folder struct {
	Name string
	Path string
}

Folder is a folder of the workspace for ${workspaceFolder:name}.

type FunctionBreakpoint

type FunctionBreakpoint struct {
	ID                      string
	Name                    string
	Enabled                 bool
	Condition, HitCondition string
	Verified                bool
	Message                 string
	Supported               bool
}

FunctionBreakpoint is a snapshot of a breakpoint on a function name.

type FunctionBreakpointOptions

type FunctionBreakpointOptions struct {
	Name                    string
	Disabled                bool
	Condition, HitCondition string
}

FunctionBreakpointOptions describe a function breakpoint to add.

type GuessResult

type GuessResult struct {
	// Type is the debug type.
	Type string
	// Launch and Config are a dynamic configuration the debugger gave, if any.
	Launch *Launch
	Config Config
	// Label is its label.
	Label string
}

GuessResult is the debugger chosen for the active editor when there is no configuration (F5 with no launch.json).

type InlineLine

type InlineLine struct {
	// Line counts from 1.
	Line   int
	Values []InlineVariable
}

InlineLine is a line and the values written after it, in the order the variables come in the line.

func InlineValues

func InlineValues(scopes []InlineScope, stopped, first, last int, words func(line int) []string, content func(line int) string) []InlineLine

InlineValues works out the values to write after the lines first to last (counted from 1) when the program stopped at the line stopped. The scopes are given from the narrowest to the widest, so that a name that is in two of them has the value of the nearest (a shadowed variable is not written twice). words gives the identifiers of a line (those that are not in a string or a comment); content gives the text of a line, to order the values as the names come in it.

type InlineScope

type InlineScope struct {
	// Variables are the children of the scope.
	Variables []InlineVariable
	// FirstLine is the line (counted from 1) the scope starts at, or 0 for a scope that has no range, which starts at the first line.
	FirstLine int
}

InlineScope is the variables of a scope of the frame.

type InlineVariable

type InlineVariable struct{ Name, Value string }

InlineVariable is a variable and its value.

type Input

type Input struct {
	ID   string
	Type string // promptString, pickString, command
	// Description is the prompt or the placeholder.
	Description string
	Default     string
	Password    bool
	Options     []InputOption
	// Command and Args are the command of a command input.
	Command string
	Args    any
}

Input is an entry of the inputs of a launch file (${input:id}).

type InputMemory

type InputMemory interface {
	// Get returns the value remembered under key.
	Get(key string) (string, bool)
	// Set remembers a value.
	Set(key, value string)
}

InputMemory remembers the last value of each input, so that a prompt starts on it (VS Code keeps the last five).

type InputOption

type InputOption struct {
	Label string
	Value string
}

InputOption is an option of a pickString input.

type LRUInputMemory

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

LRUInputMemory is the InputMemory the service uses when the window gives none: the last values of the five inputs used last.

func (*LRUInputMemory) Get

func (l *LRUInputMemory) Get(key string) (string, bool)

Get returns the value remembered under key.

func (*LRUInputMemory) Set

func (l *LRUInputMemory) Set(key, value string)

Set remembers a value; the input used least recently is forgotten beyond InputMemoryCapacity.

type Launch

type Launch struct {
	// Kind is where the configurations come from.
	Kind LaunchKind
	// Folder is the folder of a LaunchFolder, and the folder the other kinds belong to.
	Folder string
	// Name is the folder's name, "workspace" or "user settings".
	Name string
	// Path is the file that holds the configurations: launch.json or the settings file.
	Path string
	// Found is false for a launch file that does not exist.
	Found bool
	// File is what was read.
	File LaunchFile
	// Problems are what is wrong in the file, with the places.
	Problems []Problem
}

Launch is a source of launch configurations: a launch file or the launch key of a settings file. It holds what was read; the Launches that owns it reads again when told.

Ported from VS Code: src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts (AbstractLaunch, Launch, WorkspaceLaunch, UserLaunch)

func (*Launch) Compound

func (l *Launch) Compound(name string) (Compound, bool)

Compound returns the compound with a name.

func (*Launch) Configuration

func (l *Launch) Configuration(name string) (Config, bool)

Configuration returns a copy of the configuration with a name, with the attributes of the platform applied, or false.

func (*Launch) ConfigurationNames

func (l *Launch) ConfigurationNames(ignoreCompoundsAndPresentation bool) []string

ConfigurationNames lists the names shown in the dropdown: the configurations and the compounds that have configurations, the hidden ones left out and the others ordered by their presentation. With ignoreCompoundsAndPresentation only the names of the configurations, in the order of the file.

func (*Launch) Hidden

func (l *Launch) Hidden() bool

Hidden is true for the launch of the user settings.

func (*Launch) Inputs

func (l *Launch) Inputs() []Input

Inputs are the inputs the file defines.

func (*Launch) Key

func (l *Launch) Key() string

Key identifies the launch in the saved state: the folder path for a folder, "workspace" or "user".

type LaunchCompletion

type LaunchCompletion struct {
	Label         string
	Detail        string
	Documentation string
	Kind          CompletionKind
	// InsertText replaces the bytes from Start to End of the text; with Snippet it uses the snippet syntax.
	InsertText string
	Snippet    bool
	Start, End int
}

LaunchCompletion is a suggestion of the completion of launch.json.

func CompleteLaunch

func CompleteLaunch(text string, offset int, debuggers []DebuggerSchema) []LaunchCompletion

CompleteLaunch suggests what can be typed at an offset of a launch.json: the keys of the file, the debug types and the requests, the attributes of the debugger of a configuration with their defaults, the values an attribute accepts (its enum, true and false, its default), and, where a configuration may start, the snippets of the debuggers. It is the JSON language's completion fed with the schemas the debuggers contribute.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugSchemas.ts and the JSON language service (the completion from a schema), for the same suggestions

type LaunchFile

type LaunchFile struct {
	Version        string
	Configurations []Config
	Compounds      []Compound
	Inputs         []Input
}

LaunchFile is the content of a launch.json or of the launch setting: VS Code's version, configurations, compounds and inputs.

type LaunchKind

type LaunchKind int

LaunchKind says where a Launch comes from.

const (
	// LaunchFolder is <folder>/.emetos/launch.json.
	LaunchFolder LaunchKind = iota + 1
	// LaunchWorkspace is the launch key of the workspace settings (<folder>/.emetos/settings.json).
	LaunchWorkspace
	// LaunchUser is the launch key of the user settings; it is hidden from "Add Configuration".
	LaunchUser
)

type LaunchSources

type LaunchSources struct {
	// Folder is the folder of the window, "" when none is open (then there is no launch file).
	Folder string
	// FolderName is the name of the folder; empty uses its base name.
	FolderName string
	// WorkspaceSetting and UserSetting are the values of the launch key in the workspace and the user settings (nil: none), and
	// WorkspaceSettingsPath and UserSettingsPath the files that hold them.
	WorkspaceSetting, UserSetting           any
	WorkspaceSettingsPath, UserSettingsPath string
}

LaunchSources tell Launches.Reload where the launches are. The window reads the settings; the launch file of the folder is read here.

type Launches

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

Launches holds the launches of the window and the selected configuration (VS Code's ConfigurationManager).

Ported from VS Code: src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts (ConfigurationManager)

func (*Launches) All

func (l *Launches) All() []struct {
	Launch *Launch
	Name   string
}

All lists every configuration and compound the dropdown shows, with the launch it is in.

func (*Launches) Launch

func (l *Launches) Launch(folderOrKey string) *Launch

Launch returns the launch with a key (Launch.Key), or the launch of a folder for a folder path, or nil.

func (*Launches) Launches

func (l *Launches) Launches() []*Launch

Launches returns the launches: the folder's launch.json, the workspace settings, the user settings.

func (*Launches) RecentDynamic

func (l *Launches) RecentDynamic() []DynamicSelection

RecentDynamic lists the dynamic configurations used lately, the newest first.

func (*Launches) Reload

func (l *Launches) Reload(ctx context.Context, src LaunchSources) error

Reload reads the launch file of the folder and takes the settings values, makes the launches again, and keeps the selected configuration when it is still there (else it picks the first). It fails with the tag of ReadLaunchFile.

func (*Launches) RemoveRecentDynamic

func (l *Launches) RemoveRecentDynamic(name, typ string)

RemoveRecentDynamic forgets a recent dynamic configuration; when it is the selected one the selection moves on.

func (*Launches) ResolveByProviders

func (l *Launches) ResolveByProviders(ctx context.Context, folder, typ string, cfg Config) (Config, error)

ResolveByProviders runs the resolveDebugConfiguration of the providers of the configuration's type and then of "*", again while a provider changes the type (each type once), as VS Code does. A nil configuration with a nil error means a provider cancelled the launch; ErrOpenLaunchFile means it asks for launch.json to be shown.

Ported from VS Code: src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts (resolveConfigurationByProviders)

func (*Launches) Select

func (l *Launches) Select(launch *Launch, name string, opts SelectOptions)

Select selects a configuration of a launch. A nil launch picks the first launch that has configurations; a name that is not in it selects the first configuration (or none).

Ported from VS Code: src/vs/workbench/contrib/debug/browser/debugConfigurationManager.ts (selectConfiguration)

func (*Launches) Selected

func (l *Launches) Selected() Selected

Selected returns the selected configuration.

func (*Launches) SelectedConfig

func (l *Launches) SelectedConfig(ctx context.Context) (Config, error)

SelectedConfig returns the selected configuration: the one in the launch file, or, for a dynamic selection, the one given with it or the one the provider gives again under that name.

type Model

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

Model is the data of Run and Debug: the sessions, the breakpoints of every kind, the watch expressions and the focus. It is safe for use from several goroutines. The mutators announce their change to the subscribers after releasing the lock.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (DebugModel) and common/debugViewModel.ts

func NewModel

func NewModel() *Model

NewModel makes an empty model: no sessions, no breakpoints, breakpoints activated.

func (*Model) AddReplHistory

func (m *Model) AddReplHistory(expr string)

AddReplHistory adds an expression to the history of the Debug Console (a repeat of the last one is not added).

func (*Model) AddWatchExpression

func (m *Model) AddWatchExpression(name string) *Expression

AddWatchExpression adds a watch expression (an empty name is one the user is still typing) and returns it.

func (*Model) Breakpoint

func (m *Model) Breakpoint(id string) (Breakpoint, bool)

Breakpoint returns the breakpoint of a line or column with an id.

func (*Model) BreakpointModes

func (m *Model) BreakpointModes(kind string) []dap.BreakpointMode

BreakpointModes returns the modes of breakpoints the adapters offered for a kind of breakpoint (source, exception, data, instruction).

func (*Model) Breakpoints

func (m *Model) Breakpoints(f BreakpointFilter) []Breakpoint

Breakpoints returns the breakpoints of lines and columns that match the filter, in the order of the files, lines and columns.

func (*Model) BreakpointsActivated

func (m *Model) BreakpointsActivated() bool

BreakpointsActivated tells whether breakpoints are activated ("Toggle Activate Breakpoints").

func (*Model) ExceptionBreakpoints

func (m *Model) ExceptionBreakpoints(sessionID string) []ExceptionBreakpoint

ExceptionBreakpoints returns the exception filters of a session, or, for an empty session id, those of the session that was focused last (shown when no session runs).

func (*Model) Focus

func (m *Model) Focus() Focus

Focus returns the focused session, thread and stack frame.

func (*Model) FunctionBreakpoints

func (m *Model) FunctionBreakpoints() []FunctionBreakpoint

FunctionBreakpoints returns the function breakpoints in the order they were added.

func (*Model) MoveWatchExpression

func (m *Model) MoveWatchExpression(id string, position int)

MoveWatchExpression moves a watch expression to a position of the list.

func (*Model) RemoveWatchExpressions

func (m *Model) RemoveWatchExpressions(id string)

RemoveWatchExpressions removes the watch expression with an id, or all of them when id is empty.

func (*Model) RenameWatchExpression

func (m *Model) RenameWatchExpression(id, name string)

RenameWatchExpression changes the text of a watch expression; its value is forgotten until the next evaluation.

func (*Model) ReplHistory

func (m *Model) ReplHistory() []string

ReplHistory returns the expressions the user typed in the Debug Console, the oldest first.

func (*Model) Session

func (m *Model) Session(id string) *Session

Session returns the session with an id, or nil.

func (*Model) Sessions

func (m *Model) Sessions(includeInactive bool) []*Session

Sessions returns the sessions that are not inactive (all, with includeInactive), the children after their parent.

func (*Model) SetDocumentDirty

func (m *Model) SetDocumentDirty(path string, dirty bool)

SetDocumentDirty tells the model that the file at path has unsaved changes (or has not): its breakpoints are unverified while it has them (VS Code's textFileService.isDirty).

func (*Model) Subscribe

func (m *Model) Subscribe(fn func(Event)) (cancel func())

Subscribe registers a listener of the changes of the model. It is called from the goroutine that made the change, after the lock was released, so it may read the model; it must not block and must not make requests (the window hands the work to its UI thread).

func (*Model) WatchExpressions

func (m *Model) WatchExpressions() []*Expression

WatchExpressions returns the watch expressions in order.

type Node

type Node interface {
	// ID is the id of the node, the same across stops so that a view keeps what is expanded.
	ID() string
	// Value is the value as the adapter gave it.
	Value() string
	// Type is the type name, or empty.
	Type() string
	// Reference is the variablesReference, 0 for a node without children.
	Reference() int
	// HasChildren tells whether the node can be expanded (and is not lazy).
	HasChildren() bool
	// Children loads the children, once; the answer is kept until the node's reference changes. A failure of the adapter gives one
	// child whose value is the message, as VS Code shows it. The error is only the end of ctx.
	Children(ctx context.Context) ([]*Variable, error)
	// ValueChanged is true when the value is not the one it had at the last stop.
	ValueChanged() bool
	// PresentationHint is the adapter's hint for the node.
	PresentationHint() *dap.VariablePresentationHint
	// NamedVariables and IndexedVariables are the numbers of children the adapter announced, for paging.
	NamedVariables() int
	IndexedVariables() int
	// MemoryReference is the adapter's reference of the node's memory, or empty.
	MemoryReference() string
	// Session is the session that gave the node, nil for an expression nobody has evaluated.
	Session() *Session
}

Node is what the Variables, Watch and Debug Console views show as a tree: a scope, a variable or an expression.

type Options

type Options struct {
	// Logger receives the problems that do not stop a session; nil discards them.
	Logger *slog.Logger
	// Debugger returns the debugger of a debug type (the contributions of the extensions).
	Debugger func(typ string) (Debugger, bool)
	// ResolveConfiguration is resolveDebugConfiguration of the providers of a type (the type "*" asks the generic ones): it may
	// complete the configuration. It returns nil to cancel the launch, or ErrOpenLaunchFile to cancel it and show launch.json.
	ResolveConfiguration func(ctx context.Context, folder, typ string, cfg Config) (Config, error)
	// ResolveSubstituted is resolveDebugConfigurationWithSubstitutedVariables: after the variables, and after the task before.
	ResolveSubstituted func(ctx context.Context, folder, typ string, cfg Config) (Config, error)
	// InitialConfigurations are the configurations a debugger gives for a new launch.json.
	InitialConfigurations func(ctx context.Context, folder, typ string) ([]Config, error)
	// DynamicConfigurations are the configurations a debugger gives for the dropdown without a launch file.
	DynamicConfigurations func(ctx context.Context, folder, typ string) ([]Config, error)
	// DynamicTypes lists the debug types that provide dynamic configurations.
	DynamicTypes func() []DynamicType
	// Guess chooses the debugger for the active editor when a configuration has no type.
	Guess func(ctx context.Context) (GuessResult, bool)
	// Variables returns the values the variables read (the active editor, the folders, the settings); nil resolves with none. ctx
	// is the context the start was asked with, so that the window can answer for the screen that asked (decision 1180).
	Variables func(ctx context.Context) *VariableContext
	// InputMemory remembers the last value of each input.
	InputMemory InputMemory
	// RunTask runs a task of the Tasks extension before or after a session and tells how it ended. checkErrors is true for the tasks whose
	// errors stop the launch (preLaunchTask, postRestartTask: VS Code's runTaskAndCheckErrors) and false for the others (postDebugTask,
	// preRestartTask: runTask); the question about a failed task (debug.onTaskErrors) is the callback's.
	RunTask func(ctx context.Context, folder string, task TaskRef, checkErrors bool) (TaskResult, error)
	// SaveBeforeStart saves the files as debug.saveBeforeStart says.
	SaveBeforeStart func(ctx context.Context) error
	// ConfirmConcurrent asks whether to start a second instance of a configuration that runs; nil means yes.
	ConfirmConcurrent func(ctx context.Context, label string) bool
	// RunInTerminal runs the program of a runInTerminal request in a terminal and returns the process id of its shell, or 0.
	RunInTerminal func(ctx context.Context, args dap.RunInTerminalRequestArguments, sessionID string) (shellPID int, err error)
	// OpenLaunchFile shows launch.json of a launch (after a provider cancelled with ErrOpenLaunchFile); typ is the debug type.
	OpenLaunchFile func(ctx context.Context, l *Launch, typ string)
	// Trace sees every message of every session in the order of the wire (the debug adapter trackers of step 25.3).
	Trace func(s *Session, m dap.TraceMessage)
	// AutoExpandLazyVariables says whether lazy variables are evaluated when they are listed.
	AutoExpandLazyVariables func() bool
	// Console gives the settings of the Debug Console that the model reads when a line comes (debug.console.collapseIdenticalLines and
	// debug.console.maximumLines); DefaultReplConfig when nil.
	Console func() ReplConfig
	// StackDelay is how long after the first frame of a stop the rest of the stack is loaded (VS Code: 420 ms).
	StackDelay time.Duration
	// RestartDelay is how long a restart without a restart request waits between the end and the new start (VS Code: 300 ms).
	RestartDelay time.Duration
	// FocusDelay is how long after a thread continues the focus passes to another stopped one (VS Code: 800 ms); RunningDelay is
	// how long after a session runs the frame is defocused (VS Code: 200 ms).
	FocusDelay, RunningDelay time.Duration
}

Options are the callbacks and settings the window gives the service. Every member is optional.

type PickItem

type PickItem struct {
	Label       string
	Description string
	Value       string
}

PickItem is a choice of a pickString input.

type PickRequest

type PickRequest struct {
	ID          string
	Placeholder string
	Items       []PickItem
}

PickRequest asks the user to pick one of the items; the first is the one to start on.

type Presentation

type Presentation struct {
	// Hidden hides the configuration from the dropdown and the command palette.
	Hidden bool
	// Group groups and sorts the configurations.
	Group string
	// Order sorts the configurations of a group; nil is "no order".
	Order *float64
}

Presentation is the presentation attribute of a configuration or compound: where it shows in the dropdown.

type Problem

type Problem struct {
	Severity Severity
	Message  string
	// Offset and Length are the place in the text in bytes; Offset is -1 when the launch comes from a setting, which has no text.
	Offset, Length int
	// Line and Column are the start of the place, counted from zero, the column in bytes; -1 without text.
	Line, Column int
	// Path is where in the JSON, like configurations[1].type.
	Path string
}

Problem is something wrong in a launch file, with where it is. Step 25.3 shows them in the Problems view (owner launch.json).

func CheckAttributes

func CheckAttributes(text string, debuggers []DebuggerSchema) []Problem

CheckAttributes checks the configurations of a launch.json against the attribute schemas of their debuggers: a type no debugger has, a request the debugger does not support, a required attribute that is missing, an attribute of the wrong type, a value that the enum of the schema does not have, and an attribute the schema does not allow (when it says additionalProperties false). What ParseLaunch reports (a missing name, type or request, the syntax) is not repeated. The problems are warnings, as the JSON language service of VS Code shows schema violations.

The schemas understand type (one or several), enum, const, properties, required, additionalProperties (false or a schema), items, allOf, anyOf, oneOf, minimum, maximum and pattern. A string that holds a variable (${...}) is accepted where another type is expected: the variable is substituted before the debugger reads it.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugSchemas.ts (the schema of launch.json), for the checks

type PromptRequest

type PromptRequest struct {
	// ID is the id of the input.
	ID          string
	Description string
	// Value is the text to start with: the last one given, else the default.
	Value    string
	Password bool
}

PromptRequest asks the user for a text (an input of type promptString).

type Range

type Range struct {
	Line, Column, EndLine, EndColumn int
}

Range is a range of a source, counted from 1.

func (Range) Contains

func (r Range) Contains(o Range) bool

Contains reports whether the range contains the other.

type Reference

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

Reference is a node for a variablesReference with no variable of its own: what an output event with a reference stands for.

func (*Reference) Children

func (c *Reference) Children(ctx context.Context) ([]*Variable, error)

Children loads the children of the node once. See Node.

func (*Reference) EvaluateLazy

func (c *Reference) EvaluateLazy(ctx context.Context) error

EvaluateLazy asks the adapter for the value of a lazy variable and takes it over. It fails with the tags of the request.

func (*Reference) HasChildren

func (c *Reference) HasChildren() bool

HasChildren is true for a node with a reference that is not lazy.

func (*Reference) ID

func (c *Reference) ID() string

ID is the id of the node.

func (*Reference) IndexedVariables

func (c *Reference) IndexedVariables() int

IndexedVariables is the number of indexed children the adapter announced.

func (*Reference) MemoryReference

func (c *Reference) MemoryReference() string

MemoryReference is the adapter's memory reference.

func (*Reference) NamedVariables

func (c *Reference) NamedVariables() int

NamedVariables is the number of named children the adapter announced.

func (*Reference) PresentationHint

func (c *Reference) PresentationHint() *dap.VariablePresentationHint

PresentationHint is the adapter's hint.

func (*Reference) Reference

func (c *Reference) Reference() int

Reference is the variablesReference of the node.

func (*Reference) Session

func (c *Reference) Session() *Session

Session is the session that gave the node.

func (*Reference) Type

func (c *Reference) Type() string

Type is the type of the node.

func (*Reference) Value

func (c *Reference) Value() string

Value is the value of the node.

func (*Reference) ValueChanged

func (c *Reference) ValueChanged() bool

ValueChanged is true when the value differs from the one the node had before.

type ReplConfig

type ReplConfig struct {
	CollapseIdenticalLines bool
	MaximumLines           int
}

ReplConfig is what the console reads of the settings: debug.console.collapseIdenticalLines and debug.console.maximumLines.

type ReplData

type ReplData struct {
	Output     string
	Expression Node
	Severity   ReplSeverity
	Source     *ReplSource
}

ReplData is a new element: the text of an output with its severity and source, and the object behind it when it has one (with no text the object alone is the element).

type ReplElement

type ReplElement interface {
	// ID identifies the element for as long as it lives; the view keeps what is open by it.
	ID() string
	// Text is the text of the element; with includeSource the name of the file it came from follows. The filter looks at it with the
	// source, copying uses it without.
	Text(includeSource bool) string
	// Source is where the element came from, or nil.
	Source() *ReplSource
}

ReplElement is an element of the console: an output, an input, a result, a group or a value.

type ReplFilter

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

ReplFilter is the filter box of the Debug Console: terms separated by commas, each text to look for (fuzzy), `!text` to leave out the lines that match, and `\text` for a text that starts with `!`. A line is shown when no `!` term matches it and, when there are terms to look for, at least one matches. Only outputs and groups are filtered: what the user typed, its results and objects always show.

Ported from VS Code: src/vs/workbench/contrib/debug/browser/replFilter.ts

func NewReplFilter

func NewReplFilter(text string) *ReplFilter

NewReplFilter parses a filter text.

func (*ReplFilter) Empty

func (f *ReplFilter) Empty() bool

Empty tells whether the filter lets everything through.

func (*ReplFilter) Set

func (f *ReplFilter) Set(query string)

Set replaces the filter text.

func (*ReplFilter) Visible

func (f *ReplFilter) Visible(e ReplElement, parentVisible bool) bool

Visible tells whether the element shows. parentVisible is whether its group does (a line of a group that is shown shows when the filter has only terms to leave out).

type ReplGroup

type ReplGroup struct {
	Session *Session
	// Name is the title of the group.
	Name string
	// AutoExpand is true for a group that starts open (group "start"), false for "startCollapsed".
	AutoExpand bool
	Src        *ReplSource
	// contains filtered or unexported fields
}

ReplGroup is a group of lines (console.group): its name, and the elements printed while it was open.

Ported from VS Code: replModel.ts (ReplGroup)

func (*ReplGroup) Children

func (g *ReplGroup) Children() []ReplElement

Children are the elements of the group.

func (*ReplGroup) Ended

func (g *ReplGroup) Ended() bool

Ended tells whether the group was closed.

func (*ReplGroup) ID

func (g *ReplGroup) ID() string

ID implements ReplElement.

func (*ReplGroup) Source

func (g *ReplGroup) Source() *ReplSource

Source implements ReplElement.

func (*ReplGroup) Text

func (g *ReplGroup) Text(includeSource bool) string

Text implements ReplElement: the name.

type ReplInput

type ReplInput struct {
	Value string
	// contains filtered or unexported fields
}

ReplInput is a line the user typed in the console to evaluate.

Ported from VS Code: replModel.ts (ReplEvaluationInput)

func (*ReplInput) ID

func (i *ReplInput) ID() string

ID implements ReplElement.

func (*ReplInput) Source

func (i *ReplInput) Source() *ReplSource

Source implements ReplElement.

func (*ReplInput) Text

func (i *ReplInput) Text(bool) string

Text implements ReplElement.

type ReplModel

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

ReplModel is the list of elements of a console. It is safe for use from several goroutines; its changes are told to the listeners (Subscribe) from the goroutine that made them, after the lock was released.

Ported from VS Code: replModel.ts (ReplModel)

func NewReplModel

func NewReplModel(cfg func() ReplConfig) *ReplModel

NewReplModel makes an empty console; cfg gives the settings it reads when a line comes (DefaultReplConfig when nil).

func (*ReplModel) AddExpression

func (m *ReplModel) AddExpression(ctx context.Context, s *Session, frame *StackFrame, expression string)

AddExpression adds what the user typed, evaluates it in the frame (in the session alone without one) with the context repl, and adds the result. The call returns when the adapter has answered or ctx is done; the input is in the console at once.

func (*ReplModel) Append

func (m *ReplModel) Append(s *Session, d ReplData)

Append adds an output (or an object) to the console, as VS Code's appendToRepl: the text of an earlier line that was not ended goes on, identical lines are counted when debug.console.collapseIdenticalLines is on, and the clear sequence of a terminal clears the console.

func (*ReplModel) Clear

func (m *ReplModel) Clear()

Clear removes every element (VS Code's removeReplExpressions).

func (*ReplModel) Elements

func (m *ReplModel) Elements() []ReplElement

Elements returns the top-level elements, the oldest first. The slice is a copy.

func (*ReplModel) EndGroup

func (m *ReplModel) EndGroup()

EndGroup closes the group that was opened last and is still open.

func (*ReplModel) Len

func (m *ReplModel) Len() int

Len is the number of top-level elements.

func (*ReplModel) StartGroup

func (m *ReplModel) StartGroup(s *Session, name string, autoExpand bool, src *ReplSource)

StartGroup opens a group: what comes next is in it until EndGroup.

func (*ReplModel) Subscribe

func (m *ReplModel) Subscribe(fn func()) (cancel func())

Subscribe calls fn after the elements changed (a line was added, the count of a line changed, the console was cleared). fn must not block. The returned function stops it.

func (*ReplModel) Version

func (m *ReplModel) Version() uint64

Version counts the changes; a reader that kept the elements of a version knows they are current while it is the same.

type ReplOutput

type ReplOutput struct {

	// Value is the text; it ends in a line feed when it is a whole line.
	Value    string
	Severity ReplSeverity
	Src      *ReplSource
	// Expression is the object behind the output (an output event with a variablesReference), or nil.
	Expression Node
	// Session is the session that printed it.
	Session *Session
	// contains filtered or unexported fields
}

ReplOutput is the general case of an output event: a text with its severity and source. A text that is repeated stands once with a count. With an Expression the output is also an object to open.

Ported from VS Code: replModel.ts (ReplOutputElement)

func (*ReplOutput) Count

func (o *ReplOutput) Count() int

Count is how many times the text came in a row (1 without collapsing).

func (*ReplOutput) HasChildren

func (o *ReplOutput) HasChildren() bool

HasChildren tells whether the output stands for an object with children.

func (*ReplOutput) ID

func (o *ReplOutput) ID() string

ID implements ReplElement.

func (*ReplOutput) Source

func (o *ReplOutput) Source() *ReplSource

Source implements ReplElement.

func (*ReplOutput) Text

func (o *ReplOutput) Text(includeSource bool) string

Text implements ReplElement: the text repeated Count times, one after the other.

type ReplResult

type ReplResult struct {
	// Original is the expression that was evaluated.
	Original string
	// Expression holds the value, its type and its children.
	Expression *Expression
}

ReplResult is the result of evaluating a line of the console; it can be opened when the value has children.

Ported from VS Code: replModel.ts (ReplEvaluationResult)

func (*ReplResult) Available

func (r *ReplResult) Available() bool

Available is false when the evaluation failed.

func (*ReplResult) HasChildren

func (r *ReplResult) HasChildren() bool

HasChildren tells whether the value can be opened.

func (*ReplResult) ID

func (r *ReplResult) ID() string

ID implements ReplElement.

func (*ReplResult) Source

func (r *ReplResult) Source() *ReplSource

Source implements ReplElement.

func (*ReplResult) Text

func (r *ReplResult) Text(bool) string

Text implements ReplElement: the value.

type ReplSeverity

type ReplSeverity int

ReplSeverity is how important a line of the console is: it picks the color of the line (debugConsole.*Foreground).

const (
	// ReplIgnore is a line of the console's own (italic, "Console was cleared").
	ReplIgnore ReplSeverity = iota
	// ReplInfo is the output of the program (the categories stdout and the rest).
	ReplInfo
	// ReplWarning is the output of the category console (the adapter's own messages).
	ReplWarning
	// ReplError is the output of the category stderr.
	ReplError
)

func ReplSeverityOfCategory

func ReplSeverityOfCategory(category string) ReplSeverity

ReplSeverityOfCategory is the severity of the category of an output event: stderr is an error, console a warning, the rest information.

type ReplSource

type ReplSource struct {
	Source Source
	Line   int
	Column int
}

ReplSource is where an output came from: the file and the place the adapter named, which the console shows as `name:line` at the end of the line.

type ReplVariable

type ReplVariable struct {
	Expression Node
	Severity   ReplSeverity
	Src        *ReplSource
	Session    *Session
	// contains filtered or unexported fields
}

ReplVariable is a variable logged by the program with no text: a top-level value of the console.

Ported from VS Code: replModel.ts (ReplVariableElement)

func (*ReplVariable) HasChildren

func (v *ReplVariable) HasChildren() bool

HasChildren tells whether the value can be opened.

func (*ReplVariable) ID

func (v *ReplVariable) ID() string

ID implements ReplElement.

func (*ReplVariable) Source

func (v *ReplVariable) Source() *ReplSource

Source implements ReplElement.

func (*ReplVariable) Text

func (v *ReplVariable) Text(bool) string

Text implements ReplElement.

type Replacement

type Replacement struct {
	// ID is the whole text, ${name:arg}.
	ID string
	// Inner is name:arg.
	Inner string
	// Name is the part before the first colon.
	Name string
	// Arg is the part after it; HasArg tells an empty one from none.
	Arg    string
	HasArg bool
}

Replacement is one ${name} or ${name:arg} found in a text.

Ported from VS Code: src/vs/platform/configuration/common/configurationVariables.ts

func Variables

func Variables(value string) []Replacement

Variables lists the variables of a text in the order they appear, each once.

type ResolveOptions

type ResolveOptions struct {
	// Folder is the folder of the launch (an absolute path), or "".
	Folder string
	// Interactive lets ${command:...} and ${input:...} run commands and ask the user; without it they stay as they are.
	Interactive bool
	// Inputs are the inputs of the launch file; nil means the file has none, and ${input:id} then fails.
	Inputs []Input
	// Commands maps the names of ${command:name} to command ids: the interactive variables of the debugger (SPEC §10.31
	// "Contributes.Debuggers... Variables").
	Commands map[string]string
	// Section names the setting an input belongs to ("launch"); it is part of the key under which the last value is remembered.
	Section string
	// Memory remembers the values of inputs; nil forgets them.
	Memory InputMemory
}

ResolveOptions are what a resolution needs besides the values.

type Scope

type Scope struct {

	// Frame is the stack frame the scope belongs to.
	Frame *StackFrame
	// Name is the name of the scope ("Locals").
	Name string
	// Hint is the adapter's presentation hint (arguments, locals, registers, returnValue).
	Hint string
	// Expensive says that the scope is slow to fetch, so a view loads it only when it is opened.
	Expensive bool
	// Range is the part of the source the scope covers, nil when the adapter did not say.
	Range *Range
	// Err is the message of an adapter that failed to give the scopes; the scope is then a message, not a scope.
	Err string
	// contains filtered or unexported fields
}

Scope is a named group of variables of a stack frame (locals, arguments, globals, ...).

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (Scope)

func (*Scope) Children

func (c *Scope) Children(ctx context.Context) ([]*Variable, error)

Children loads the children of the node once. See Node.

func (*Scope) ChildrenLoaded

func (s *Scope) ChildrenLoaded() bool

ChildrenLoaded tells whether the children of the scope have been loaded.

func (*Scope) EvaluateLazy

func (c *Scope) EvaluateLazy(ctx context.Context) error

EvaluateLazy asks the adapter for the value of a lazy variable and takes it over. It fails with the tags of the request.

func (*Scope) HasChildren

func (c *Scope) HasChildren() bool

HasChildren is true for a node with a reference that is not lazy.

func (*Scope) ID

func (c *Scope) ID() string

ID is the id of the node.

func (*Scope) IndexedVariables

func (c *Scope) IndexedVariables() int

IndexedVariables is the number of indexed children the adapter announced.

func (*Scope) MemoryReference

func (c *Scope) MemoryReference() string

MemoryReference is the adapter's memory reference.

func (*Scope) NamedVariables

func (c *Scope) NamedVariables() int

NamedVariables is the number of named children the adapter announced.

func (*Scope) PresentationHint

func (c *Scope) PresentationHint() *dap.VariablePresentationHint

PresentationHint is the adapter's hint.

func (*Scope) Reference

func (c *Scope) Reference() int

Reference is the variablesReference of the node.

func (*Scope) Session

func (c *Scope) Session() *Session

Session is the session that gave the node.

func (*Scope) Type

func (c *Scope) Type() string

Type is the type of the node.

func (*Scope) Value

func (c *Scope) Value() string

Value is the value of the node.

func (*Scope) ValueChanged

func (c *Scope) ValueChanged() bool

ValueChanged is true when the value differs from the one the node had before.

type SelectOptions

type SelectOptions struct {
	// Config is the configuration for a dynamic selection (the one the user picked).
	Config Config
	// Dynamic marks the selection as a dynamic configuration of a provider.
	Dynamic *DynamicSelection
}

SelectOptions are the optional parts of a selection.

type Selected

type Selected struct {
	// Launch is the launch it belongs to, nil when there is none.
	Launch *Launch
	// Name is the name of the configuration, empty when there is none.
	Name string
	// Type is the debug type of the selected configuration (the context key debugConfigurationType).
	Type string
	// Dynamic is true for a configuration a provider gave.
	Dynamic bool
	// Config is the configuration when it was given with the selection (a dynamic one); nil otherwise.
	Config Config
}

Selected is the selected configuration of the dropdown.

type Service

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

Service starts, restarts and stops sessions, keeps the model and the launches, and the breakpoints sent to the adapters. It is the entry point of the window.

Ported from VS Code: src/vs/workbench/contrib/debug/browser/debugService.ts

func NewService

func NewService(ctx context.Context, opts Options) *Service

NewService makes a service. ctx is the life of the window: the adapters' programs end with it.

func (*Service) AddBreakpoints

func (s *Service) AddBreakpoints(ctx context.Context, path string, data []BreakpointData) ([]Breakpoint, error)

AddBreakpoints adds breakpoints to a file and sends them to the sessions. The breakpoints are added even when sending fails.

func (*Service) AddFunctionBreakpoint

func (s *Service) AddFunctionBreakpoint(ctx context.Context, opts FunctionBreakpointOptions) (FunctionBreakpoint, error)

AddFunctionBreakpoint adds a function breakpoint. With an empty name it only adds the row the user is about to name; the name is sent by UpdateFunctionBreakpoint.

func (*Service) AppendConsole

func (s *Service) AppendConsole(text string)

AppendConsole writes a text to the Debug Console on behalf of an extension (vscode.debug.activeDebugConsole.append): it goes to the console of the focused session, in the color of a warning as VS Code writes it, or else of the session that started last. With no session at all there is no console and the text is dropped, as in VS Code. The event of the category "console" that belongs to no session is sent too, for the listeners of the model.

Ported from VS Code: src/vs/workbench/api/browser/mainThreadDebugService.ts ($appendDebugConsole)

func (*Service) DocumentDeleted

func (s *Service) DocumentDeleted(path string)

DocumentDeleted removes the breakpoints of a file that was deleted.

func (*Service) DocumentSaved

func (s *Service) DocumentSaved(ctx context.Context, path string) error

DocumentSaved sends, for a file that was saved, the breakpoints that moved with its edits (with sourceModified).

func (*Service) EnableOrDisableBreakpoints

func (s *Service) EnableOrDisableBreakpoints(ctx context.Context, enable bool, id string) error

EnableOrDisableBreakpoints enables or disables one breakpoint of any kind by id, or all of them when id is empty. A triggered breakpoint and the one that triggers it keep the same state.

func (*Service) EvaluateWatchExpressions

func (s *Service) EvaluateWatchExpressions(ctx context.Context)

EvaluateWatchExpressions evaluates every watch expression in the focused stack frame (the Watch view does it when the focus changes).

func (*Service) FirstSessionStart

func (s *Service) FirstSessionStart() bool

FirstSessionStart tells whether no session has been started since the window opened (debug.openDebug and debug.internalConsoleOptions have a case for the first one).

func (*Service) FocusStackFrame

func (s *Service) FocusStackFrame(frame *StackFrame, thread *Thread, session *Session)

FocusStackFrame focuses a stack frame, a thread (its top frame) or a session (its stopped thread); nil for all three picks what VS Code does: a stopped session, else the first.

func (*Service) HasDebugged

func (s *Service) HasDebugged() bool

HasDebugged tells whether a session was started in this window (the context key debuggersAvailable / hasDebugged).

func (*Service) Launches

func (s *Service) Launches() *Launches

Launches returns the launches and the selected configuration.

func (*Service) Model

func (s *Service) Model() *Model

Model returns the model.

func (*Service) RemoveBreakpoints

func (s *Service) RemoveBreakpoints(ctx context.Context, ids ...string) error

RemoveBreakpoints removes breakpoints by id (all when none is given) and updates the sessions. A triggered breakpoint whose trigger was removed becomes an ordinary one.

func (*Service) RemoveFunctionBreakpoints

func (s *Service) RemoveFunctionBreakpoints(ctx context.Context, id string) error

RemoveFunctionBreakpoints removes the function breakpoint with an id, or all of them.

func (*Service) RestartSession

func (s *Service) RestartSession(ctx context.Context, sess *Session, restartData any) error

RestartSession restarts a session: the adapter's restart when it has one, else it ends the session and starts it again with the configuration read again from launch.json. restartData, when not nil, is what a terminated event asked the restart with (an automatic restart, which runs no task).

Ported from VS Code: src/vs/workbench/contrib/debug/browser/debugService.ts (restartSession)

func (*Service) RestoreState

func (s *Service) RestoreState(data []byte) error

RestoreState replaces the breakpoints, watch expressions and selection with those of a saved state. Entries that cannot be used (a breakpoint with no path or a line below 1) are dropped; a state that is not the JSON of this version fails with the tags DebugStateInvalid and DebugStateUnsupported and leaves the model as it was.

func (*Service) RunTo

func (s *Service) RunTo(ctx context.Context, path string, line, column int) error

RunTo lets the program run to a place of a file: when a session is stopped its thread continues, and when none runs the selected configuration is started. A breakpoint is added at the place for the run, unless one is there already, and removed again as soon as the debugger stops or ends. column is 0 for the whole line. A program that runs (or is being started) is left alone.

func (*Service) SaveState

func (s *Service) SaveState() ([]byte, error)

SaveState encodes what is saved with the workspace's UI state.

func (*Service) SetBreakpointsActivated

func (s *Service) SetBreakpointsActivated(ctx context.Context, on bool) error

SetBreakpointsActivated turns all breakpoints on or off without changing them ("Toggle Activate Breakpoints").

func (*Service) SetExceptionBreakpointCondition

func (s *Service) SetExceptionBreakpointCondition(ctx context.Context, id, condition string) error

SetExceptionBreakpointCondition sets the condition of an exception filter.

func (*Service) SetExceptionBreakpointFallbackSession

func (s *Service) SetExceptionBreakpointFallbackSession(sessionID string)

SetExceptionBreakpointFallbackSession remembers the filters of a session to show when none runs.

func (*Service) StartDebugging

func (s *Service) StartDebugging(ctx context.Context, launch *Launch, target Target, opts SessionOptions) (bool, error)

StartDebugging starts a configuration or a compound. It saves the files first (unless the options say not to or this is a child), asks the providers, substitutes the variables, runs the task before, and starts the session. It returns false with no error when the launch was cancelled (by the user at an input, by a provider, by a failed task); an error says what is wrong with the configuration or the adapter.

Ported from VS Code: src/vs/workbench/contrib/debug/browser/debugService.ts (startDebugging, createSession, doCreateSession)

func (*Service) State

func (s *Service) State() State

State is the state of the focused session; without one, Initializing while a session is being made, else Inactive.

func (*Service) Stop

func (s *Service) Stop(ctx context.Context, sess *Session, disconnect, suspend bool) error

Stop ends a session: Terminate, or Disconnect for an attach (the toolbar's Stop becomes Disconnect then). Without a session it stops all of them; with none it cancels the sessions being started.

Ported from VS Code: src/vs/workbench/contrib/debug/browser/debugService.ts (stopSession)

func (*Service) Subscribe

func (s *Service) Subscribe(fn func(Event)) (cancel func())

Subscribe registers a listener of the changes of the model (Model.Subscribe).

func (*Service) UpdateBreakpoints

func (s *Service) UpdateBreakpoints(ctx context.Context, path string, updates map[string]BreakpointUpdate, sendOnSave bool) error

UpdateBreakpoints changes breakpoints of a file. With sendOnSave the new positions go to the adapters when the file is saved (DocumentSaved), as the breakpoints that moved with edits do; else at once.

func (*Service) UpdateFunctionBreakpoint

func (s *Service) UpdateFunctionBreakpoint(ctx context.Context, id string, name, condition, hitCondition *string) error

UpdateFunctionBreakpoint changes the name, condition or hit condition of a function breakpoint (nil leaves one as it is).

type Session

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

Session is a debug session: one adapter, its threads and what the debuggee reported. The session driver is here: it runs VS Code's sequence (initialize, launch or attach, the initialized event, the breakpoints, configurationDone) and keeps the model up to date from the adapter's events.

A session reads its adapter on a goroutine of its own and never makes a request from it: the follow-up work of an event (the threads and the stack after a stop, the breakpoints after initialized) runs on a serial queue on another goroutine, because the event channel of core/dap is bounded and a request from its consumer could wait behind events nobody takes (decision 1102).

Ported from VS Code: src/vs/workbench/contrib/debug/browser/debugSession.ts and browser/rawDebugSession.ts

func SessionFromContext

func SessionFromContext(ctx context.Context) (*Session, bool)

SessionFromContext returns the session that a context of Debugger.Connect carries.

func (*Session) AddOutput

func (s *Session) AddOutput(category, text string)

AddOutput writes text to the Debug Console of the session as an output event of the category would: "stdout" and "stderr" for what a program prints, "console" for the debugger's own words. It is what the lines of the standard output and error of an adapter that runs the program (Delve) become (step 25.7); it may be called from any goroutine, also before the adapter has answered. The text is a whole line when it ends in a line feed.

func (*Session) AddReplExpression

func (s *Session) AddReplExpression(ctx context.Context, frame *StackFrame, expression string)

AddReplExpression evaluates a line of the Debug Console in the frame (in the session alone with no frame) and puts the line and its result into the console. It returns when the adapter has answered. The history is the caller's (Model.AddReplHistory).

func (*Session) AppendToRepl

func (s *Session) AppendToRepl(output string, sev ReplSeverity)

AppendToRepl puts a text into the Debug Console of the session.

func (*Session) BreakpointLocations

func (s *Session) BreakpointLocations(ctx context.Context, path string, line int) ([]dap.BreakpointLocation, error)

BreakpointLocations asks where a breakpoint can be set on a line (the inline breakpoint candidates), when the adapter can.

func (*Session) CancelProgress

func (s *Session) CancelProgress(ctx context.Context, progressID string) error

CancelProgress cancels a progress the adapter started (cancel with a progressId).

func (*Session) Capabilities

func (s *Session) Capabilities() dap.Capabilities

Capabilities returns the capabilities of the adapter, empty before initialize and after the session ended it keeps what it was.

func (*Session) Completions

func (s *Session) Completions(ctx context.Context, frameID int, text string, column int) ([]dap.CompletionItem, error)

Completions asks the adapter for the completions of the Debug Console's input at a column (counted from 1).

func (*Session) CompletionsAt

func (s *Session) CompletionsAt(ctx context.Context, frameID int, text string, line, column int) ([]dap.CompletionItem, error)

CompletionsAt is Completions for the line of a text of several lines (counted from 1; 0 is the first) and a column in that line.

func (*Session) Configuration

func (s *Session) Configuration() Config

Configuration returns the resolved configuration the session runs.

func (*Session) ConsoleRoot

func (s *Session) ConsoleRoot() *Session

ConsoleRoot is the session whose Debug Console the session writes to: itself, or the nearest parent with a console of its own.

func (*Session) Continue

func (s *Session) Continue(ctx context.Context, threadID int) error

Continue resumes the thread.

func (*Session) CustomRequest

func (s *Session) CustomRequest(ctx context.Context, command string, args any) (json.RawMessage, error)

CustomRequest sends a request the protocol does not define, and returns the body of the response. It is the way of the extensions of a debugger.

func (*Session) Disconnect

func (s *Session) Disconnect(ctx context.Context, restart, suspend bool) error

Disconnect ends the session without ending the debuggee (terminateDebuggee false), with suspendDebuggee when asked and supported.

func (*Session) Evaluate

func (s *Session) Evaluate(ctx context.Context, expr string, frame *StackFrame, evalContext string) (*Expression, error)

Evaluate evaluates an expression in a frame (or in the session alone with a zero frame id and the context "repl") and returns the result as an Expression node. The context is one of the dap.Context... values. A failure is the value of the node and the error.

func (*Session) ExceptionInfo

func (s *Session) ExceptionInfo(ctx context.Context, threadID int) (*ExceptionInfo, error)

ExceptionInfo asks for the exception a thread stopped on.

func (*Session) Goto

func (s *Session) Goto(ctx context.Context, threadID, targetID int) error

Goto jumps to a target of GotoTargets.

func (*Session) GotoTargets

func (s *Session) GotoTargets(ctx context.Context, path string, line, column int) ([]dap.GotoTarget, error)

GotoTargets asks where execution can jump to from a place of a source.

func (*Session) HasSeparateRepl

func (s *Session) HasSeparateRepl() bool

HasSeparateRepl tells whether the session has a Debug Console of its own.

func (*Session) ID

func (s *Session) ID() string

ID is the id of the session.

func (*Session) Idle

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

Idle waits until the follow-up work of the events received so far is done: the breakpoints sent after initialized, the threads and stack loaded after a stop. It fails when ctx ends first.

func (*Session) IsAttach

func (s *Session) IsAttach() bool

IsAttach reports whether the session attached to a program instead of launching it; the toolbar then offers Disconnect.

func (*Session) Label

func (s *Session) Label() string

Label is the name shown in the views and the toolbar.

func (*Session) LoadMoreFrames

func (s *Session) LoadMoreFrames(ctx context.Context, t *Thread, levels int) error

LoadMoreFrames loads more frames of the call stack of a stopped thread ("Show N More Stack Frames"): levels of them, but not more than the thread has left.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (DebugModel.fetchCallstack)

func (*Session) LoadSource

func (s *Session) LoadSource(ctx context.Context, src Source) (string, error)

LoadSource reads a source the adapter serves (a source with a sourceReference).

func (*Session) LoadedSources

func (s *Session) LoadedSources(ctx context.Context) ([]Source, error)

LoadedSources asks for the sources the debuggee has loaded (Loaded Scripts), when the adapter can.

func (*Session) Name

func (s *Session) Name() string

Name is the name of the session (the configuration's name, made unique among the sessions).

func (*Session) Next

func (s *Session) Next(ctx context.Context, threadID int, granularity string) error

Next steps over.

func (*Session) Options

func (s *Session) Options() SessionOptions

Options returns the options the session was made with.

func (*Session) Parent

func (s *Session) Parent() *Session

Parent is the session that started this one, or nil.

func (*Session) Pause

func (s *Session) Pause(ctx context.Context, threadID int) error

Pause pauses the thread.

func (*Session) Repl

func (s *Session) Repl() *ReplModel

Repl is the Debug Console of the session: its own, or its parent's when the session was made to merge with it.

func (*Session) Restart

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

Restart asks the adapter to restart the debuggee (restart); the adapter must support it.

func (*Session) RestartFrame

func (s *Session) RestartFrame(ctx context.Context, frameID, threadID int) error

RestartFrame restarts a stack frame, when the adapter can.

func (*Session) ReverseContinue

func (s *Session) ReverseContinue(ctx context.Context, threadID int) error

ReverseContinue resumes the thread backwards.

func (*Session) Root

func (s *Session) Root() string

Root is the folder of the launch the session belongs to, or "".

func (*Session) SetConfiguration

func (s *Session) SetConfiguration(resolved, unresolved Config)

SetConfiguration replaces the configurations (a restart that read launch.json again).

func (*Session) SetName

func (s *Session) SetName(name string)

SetName renames the session (an extension may).

func (*Session) SourceUnavailable

func (s *Session) SourceUnavailable(key string)

SourceUnavailable notes that the source at a key (Source.Key) could not be opened.

func (*Session) State

func (s *Session) State() State

State is the state of the session.

func (*Session) StepBack

func (s *Session) StepBack(ctx context.Context, threadID int, granularity string) error

StepBack steps back; the adapter must support reverse debugging.

func (*Session) StepIn

func (s *Session) StepIn(ctx context.Context, threadID, targetID int, granularity string) error

StepIn steps into; targetID picks the target when the adapter offered several (stepInTargets).

func (*Session) StepInTargets

func (s *Session) StepInTargets(ctx context.Context, frameID int) ([]dap.StepInTarget, error)

StepInTargets asks for the targets a step into can go to in a frame.

func (*Session) StepOut

func (s *Session) StepOut(ctx context.Context, threadID int, granularity string) error

StepOut steps out.

func (*Session) StoppedDetails

func (s *Session) StoppedDetails() *StoppedDetails

StoppedDetails returns the details of the first stop that is still in effect, or nil.

func (*Session) Terminate

func (s *Session) Terminate(ctx context.Context, restart bool) error

Terminate ends the debuggee: terminate when the adapter supports it for a launch (twice, it disconnects with terminateDebuggee), else disconnect with terminateDebuggee. With restart the session is not over: a restart follows.

func (*Session) TerminateThreads

func (s *Session) TerminateThreads(ctx context.Context, threadIDs []int) error

TerminateThreads ends threads of the debuggee, when the adapter can.

func (*Session) Thread

func (s *Session) Thread(id int) *Thread

Thread returns the thread with an id, or nil.

func (*Session) Threads

func (s *Session) Threads() []*Thread

Threads returns the threads in the order the adapter listed them.

func (*Session) Type

func (s *Session) Type() string

Type is the debug type of the session.

func (*Session) UnresolvedConfiguration

func (s *Session) UnresolvedConfiguration() Config

UnresolvedConfiguration returns the configuration before its variables were substituted.

type SessionData

type SessionData struct {
	dap.Breakpoint
	SessionID                         string
	SupportsConditionalBreakpoints    bool
	SupportsHitConditionalBreakpoints bool
	SupportsLogPoints                 bool
	SupportsFunctionBreakpoints       bool
}

SessionData is what one session knows about a breakpoint: the adapter's answer to setBreakpoints (or its breakpoint event) with what the adapter supports, which decides whether the breakpoint is supported.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (IBreakpointSessionData)

type SessionOptions

type SessionOptions struct {
	// Parent is the session that started this one (startDebugging); a child is shown under it.
	Parent *Session
	// LifecycleManagedByParent makes stop, disconnect and restart of the child act on the parent.
	LifecycleManagedByParent bool
	// Compact shows the child's threads under the parent's session in the call stack, without its own row.
	Compact bool
	// CompoundRoot ties the session to the others of a compound that stops all.
	CompoundRoot *CompoundRoot
	// NoDebug runs without debugging (also the configuration's noDebug).
	NoDebug *bool
	// NoSaveBeforeStart is set when the files are not saved before the session starts (a child never saves).
	NoSaveBeforeStart bool
	// NoSaveBeforeRestart is set when the files are not saved before a restart.
	NoSaveBeforeRestart bool
	// StartedByUser is set for a session the user started (the question about a second instance is asked).
	StartedByUser bool
	// SuppressDebugStatusbar, SuppressDebugToolbar and SuppressDebugView hide those parts for this session.
	SuppressDebugStatusbar, SuppressDebugToolbar, SuppressDebugView bool
	// Repl is "separate" or "mergeWithParent", for the Debug Console (step 25.6).
	Repl string
}

SessionOptions are the options a session is made with (VS Code's IDebugSessionOptions).

type Severity

type Severity int

Severity says how bad a Problem is.

const (
	// SeverityError is a file that cannot be read as it was meant: a syntax error, a value of the wrong type.
	SeverityError Severity = iota + 1
	// SeverityWarning is a file that works but is probably wrong: a missing attribute, a name used twice.
	SeverityWarning
)

type Snippet

type Snippet struct {
	Label       string
	Description string
	Body        Config
}

Snippet is a configuration of a debugger that "Add Configuration" and the completion of launch.json offer; the strings of Body may use the snippet syntax (${1:name}).

type Source

type Source struct {
	// Raw is the source as the adapter gave it.
	Raw dap.Source
	// Path is the file when the source is one, else empty.
	Path string
	// Name is the name to show.
	Name string
	// Available is false for the source of a frame the adapter gave no source for (and for one known to be unavailable).
	Available bool
	// SessionID is the session the source comes from, which a source of the adapter's needs to be read.
	SessionID string
}

Source is the source of a stack frame, a breakpoint or an output: a file, or something the adapter serves.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugSource.ts

func (Source) InMemory

func (s Source) InMemory() bool

InMemory reports whether the source is not a file (the adapter serves its content with the source request).

func (Source) Key

func (s Source) Key() string

Key identifies the source: its path, or debug:<name>?session=<id>&ref=<reference> for one the adapter serves.

func (Source) PresentationHint

func (s Source) PresentationHint() string

PresentationHint is the adapter's hint (normal, emphasize, deemphasize).

func (Source) Reference

func (s Source) Reference() int

Reference is the sourceReference of a source the adapter serves, or 0.

type StackFrame

type StackFrame struct {
	Thread *Thread
	// ID is the adapter's frame id, valid while the thread is stopped.
	ID     int
	Source Source
	Name   string
	// PresentationHint is normal, label or subtle.
	PresentationHint string
	// Range is the place in the source, counted from 1.
	Range Range
	// Index is the position in the call stack, 0 for the top.
	Index      int
	CanRestart bool
	// InstructionPointerReference is the adapter's reference of the frame's instruction.
	InstructionPointerReference string
	// contains filtered or unexported fields
}

StackFrame is a frame of the call stack of a thread; its scopes are loaded when asked.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (StackFrame)

func (*StackFrame) Deemphasized

func (f *StackFrame) Deemphasized() bool

Deemphasized reports whether the frame is shown dimmed: a subtle frame, or one in a source the adapter marks deemphasized.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debug.ts (isFrameDeemphasized)

func (*StackFrame) Equals

func (f *StackFrame) Equals(o *StackFrame) bool

Equals reports whether two frames are the same frame of the same thread.

func (*StackFrame) Key

func (f *StackFrame) Key() string

Key is the id of the frame that stays the same across stops of the same shape, so that a view keeps its selection.

func (*StackFrame) MostSpecificScopes

func (f *StackFrame) MostSpecificScopes(ctx context.Context, r Range) ([]*Scope, error)

MostSpecificScopes returns the scopes that are not expensive and contain the range, the smallest first; when no scope has a range, all the non-expensive scopes (the inline values and the hover use them).

func (*StackFrame) Restart

func (f *StackFrame) Restart(ctx context.Context) error

Restart restarts the frame (restartFrame), when the adapter can.

func (*StackFrame) Scopes

func (f *StackFrame) Scopes(ctx context.Context) ([]*Scope, error)

Scopes loads the scopes of the frame, once. A failure of the adapter gives one scope whose Err says why.

func (*StackFrame) String

func (f *StackFrame) String() string

String is "name (path:line)", or the name alone for a frame with no source.

type State

type State int

State is the state of a session, or of the debugger as a whole: the values of the context key debugState.

const (
	// Inactive is no session at all, or a session whose adapter is gone.
	Inactive State = iota
	// Initializing is a session being started (the adapter is not initialized yet).
	Initializing
	// Stopped is a session with a thread that stopped.
	Stopped
	// Running is a session whose threads run.
	Running
)

func (State) String

func (s State) String() string

String is the label of the context key debugState: inactive, initializing, stopped or running.

type StoppedDetails

type StoppedDetails struct {
	dap.StoppedEventBody
	// TotalFrames is the totalFrames of the stack trace, or 0 when the adapter did not say.
	TotalFrames int
	// FramesErrorMessage is the message of the adapter when the stack trace failed.
	FramesErrorMessage string
}

StoppedDetails says why a thread stopped: the stopped event, with the number of frames the stack trace reported and the message of a failed stack trace.

type Target

type Target struct {
	Name   string
	Config Config
}

Target says what to start: the configuration or compound with a name in the launch, or a configuration given whole.

type TaskRef

type TaskRef struct {
	// Label is the label of the task when the attribute is a string.
	Label string
	// Identifier is the object when the attribute is one.
	Identifier map[string]any
}

TaskRef names a task of the Tasks extension: preLaunchTask, postDebugTask, preRestartTask and postRestartTask are a label or an object that identifies the task by its type and properties.

func (TaskRef) IsZero

func (t TaskRef) IsZero() bool

IsZero reports whether the reference names no task.

func (TaskRef) String

func (t TaskRef) String() string

String is the label, or the identifier's type and label.

type TaskResult

type TaskResult int

TaskResult is how a task before or after a session ended.

const (
	// TaskSuccess is a task that ran and passed, or no task.
	TaskSuccess TaskResult = iota
	// TaskFailure is a task that failed and whose failure stops the launch (after the question of debug.onTaskErrors).
	TaskFailure
)

type Thread

type Thread struct {

	// ID is the adapter's id of the thread.
	ID int
	// contains filtered or unexported fields
}

Thread is a thread of the debuggee. It is stopped or running; a stopped thread has a call stack, loaded from the top as asked.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (Thread)

func (*Thread) CallStack

func (t *Thread) CallStack() []*StackFrame

CallStack returns the frames loaded so far, the top first.

func (*Thread) Continue

func (t *Thread) Continue(ctx context.Context) error

Continue resumes the thread.

func (*Thread) ExceptionInfo

func (t *Thread) ExceptionInfo(ctx context.Context) (*ExceptionInfo, error)

ExceptionInfo asks for the exception the thread stopped on (stopped for an exception only). Without exceptionInfo support the description is the stop's text.

func (*Thread) FetchCallStack

func (t *Thread) FetchCallStack(ctx context.Context, levels int) error

FetchCallStack loads the next levels frames of the call stack of a stopped thread. Calling it again loads the next ones.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (Thread.fetchCallStack)

func (*Thread) Key

func (t *Thread) Key() string

Key is the id of the thread that views use as a key.

func (*Thread) LastSteppingGranularity

func (t *Thread) LastSteppingGranularity() string

LastSteppingGranularity is the granularity of the last step of the thread.

func (*Thread) Name

func (t *Thread) Name() string

Name is the name of the thread.

func (*Thread) Next

func (t *Thread) Next(ctx context.Context, granularity string) error

Next steps over.

func (*Thread) Pause

func (t *Thread) Pause(ctx context.Context) error

Pause pauses the thread.

func (*Thread) ReachedEndOfCallStack

func (t *Thread) ReachedEndOfCallStack() bool

ReachedEndOfCallStack tells whether the whole call stack is loaded.

func (*Thread) ReverseContinue

func (t *Thread) ReverseContinue(ctx context.Context) error

ReverseContinue resumes backwards.

func (*Thread) Session

func (t *Thread) Session() *Session

Session is the session of the thread.

func (*Thread) StaleCallStack

func (t *Thread) StaleCallStack() []*StackFrame

StaleCallStack returns the frames the thread had before it last ran, which views compare to find what changed.

func (*Thread) StateLabel

func (t *Thread) StateLabel() string

StateLabel is "Running", "Paused" or "Paused on <reason>" (or the adapter's description).

func (*Thread) StepBack

func (t *Thread) StepBack(ctx context.Context, granularity string) error

StepBack steps back.

func (*Thread) StepIn

func (t *Thread) StepIn(ctx context.Context, granularity string) error

StepIn steps into.

func (*Thread) StepOut

func (t *Thread) StepOut(ctx context.Context, granularity string) error

StepOut steps out.

func (*Thread) Stopped

func (t *Thread) Stopped() bool

Stopped tells whether the thread is stopped.

func (*Thread) StoppedDetails

func (t *Thread) StoppedDetails() *StoppedDetails

StoppedDetails returns why the thread stopped, or nil while it runs.

func (*Thread) Terminate

func (t *Thread) Terminate(ctx context.Context) error

Terminate ends the thread (terminateThreads).

func (*Thread) TopStackFrame

func (t *Thread) TopStackFrame() *StackFrame

TopStackFrame is the first frame of the call stack that has a source and, unless the stop is a breakpoint or a step, is not deemphasized: where the thread is shown to be.

type Tracker

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

Tracker makes the breakpoints of the open documents follow their edits. Each breakpoint of a document has a decoration (a range of one character at the breakpoint, or at the first character of its line, that never grows when text is typed at its edges), which the document moves with every edit; Sync reads where the decorations are and tells the service, which sends the new places to the adapters when the file is saved.

Documents belong to the UI thread, so a Tracker is used from it only: the window calls Track when an editor opens a document, Sync after its edits (and when the breakpoints change), and Untrack when the document closes.

Ported from VS Code: src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.ts (createBreakpointDecorations, onModelDecorationsChanged)

func NewTracker

func NewTracker(svc *Service) *Tracker

NewTracker makes a tracker for a service.

func (*Tracker) Sync

func (t *Tracker) Sync(ctx context.Context, path string) (int, error)

Sync brings the breakpoints and the decorations of a tracked document in line. First the places the decorations are at become the places of the breakpoints (they moved with the edits); then the decorations of breakpoints that are gone are removed and the breakpoints that have none get one. It reports how many breakpoints moved. A path that is not tracked does nothing.

func (*Tracker) Track

func (t *Tracker) Track(path string, doc *document.Document)

Track starts following the breakpoints of the document that is the file at path and puts a decoration on each of them. Tracking a path again replaces the document.

func (*Tracker) Untrack

func (t *Tracker) Untrack(path string)

Untrack stops following a document and removes its decorations.

type Variable

type Variable struct {

	// Name is the name; empty for a message the model shows in place of children.
	Name string
	// EvaluateName is the expression that evaluates to the variable, or empty.
	EvaluateName string
	// Available is false for the placeholder of a failure or an invalid variable.
	Available bool
	// Start is, for a chunk, the index of its first element.
	Start int
	// DeclarationLocationReference is the adapter's reference of where the variable is declared.
	DeclarationLocationReference int
	// contains filtered or unexported fields
}

Variable is a variable or a property: a child of a scope, of another variable or of an expression.

Ported from VS Code: src/vs/workbench/contrib/debug/common/debugModel.ts (Variable)

func (*Variable) Children

func (c *Variable) Children(ctx context.Context) ([]*Variable, error)

Children loads the children of the node once. See Node.

func (*Variable) ErrorMessage

func (v *Variable) ErrorMessage() string

ErrorMessage is the message of the adapter when the last SetValue failed.

func (*Variable) EvaluateLazy

func (c *Variable) EvaluateLazy(ctx context.Context) error

EvaluateLazy asks the adapter for the value of a lazy variable and takes it over. It fails with the tags of the request.

func (*Variable) HasChildren

func (c *Variable) HasChildren() bool

HasChildren is true for a node with a reference that is not lazy.

func (*Variable) ID

func (c *Variable) ID() string

ID is the id of the node.

func (*Variable) IndexedVariables

func (c *Variable) IndexedVariables() int

IndexedVariables is the number of indexed children the adapter announced.

func (*Variable) MemoryReference

func (c *Variable) MemoryReference() string

MemoryReference is the adapter's memory reference.

func (*Variable) NamedVariables

func (c *Variable) NamedVariables() int

NamedVariables is the number of named children the adapter announced.

func (*Variable) PresentationHint

func (c *Variable) PresentationHint() *dap.VariablePresentationHint

PresentationHint is the adapter's hint.

func (*Variable) Reference

func (c *Variable) Reference() int

Reference is the variablesReference of the node.

func (*Variable) Session

func (c *Variable) Session() *Session

Session is the session that gave the node.

func (*Variable) SetExpression

func (v *Variable) SetExpression(ctx context.Context, frame *StackFrame, value string) error

SetExpression changes the value with setExpression, for the variable's EvaluateName.

func (*Variable) SetValue

func (v *Variable) SetValue(ctx context.Context, frame *StackFrame, value string) error

SetValue changes the value in the debuggee with setVariable (or setExpression for an adapter that has only that) and takes the answer over; a failure of the adapter is kept in ErrorMessage and returned.

func (*Variable) String

func (v *Variable) String() string

String is "name: value", or the value when there is no name.

func (*Variable) ThreadID

func (v *Variable) ThreadID() int

ThreadID is the thread the variable was fetched for.

func (*Variable) Type

func (c *Variable) Type() string

Type is the type of the node.

func (*Variable) Value

func (c *Variable) Value() string

Value is the value of the node.

func (*Variable) ValueChanged

func (c *Variable) ValueChanged() bool

ValueChanged is true when the value differs from the one the node had before.

type VariableContext

type VariableContext struct {
	// Folders are the folders of the workspace; the launch's own folder is given to the resolver.
	Folders []Folder
	// ActiveFile is the path of the file of the active editor, or "".
	ActiveFile string
	// SelectedText, Line and Column are those of the active editor (Line and Column count from 1; 0 is none).
	SelectedText string
	Line, Column int
	// Cwd is the working folder of Emetos, for ${cwd} without a folder; empty reads os.Getwd.
	Cwd string
	// ExecPath is the program of Emetos, InstallFolder its folder, UserHome the home folder.
	ExecPath, InstallFolder, UserHome string
	// Env reads an environment variable; nil reads the process's.
	Env func(name string) (string, bool)
	// Setting reads a setting for ${config:name}; the folder is the launch's folder.
	Setting func(folder, key string) (any, bool)
	// Command runs a command of an extension for ${command:id} and for an input of type command, and gives its result: a string,
	// or nil when the user cancelled it (which cancels the launch). arg is the configuration for ${command:id} and the args of the
	// input otherwise. A result that is not a string fails with VariableCommandResultInvalid.
	Command func(ctx context.Context, id string, arg any) (any, error)
	// PromptString asks for the text of a promptString input; ok is false when the user cancelled.
	PromptString func(ctx context.Context, req PromptRequest) (value string, ok bool, err error)
	// PickString asks for the choice of a pickString input; ok is false when the user cancelled.
	PickString func(ctx context.Context, req PickRequest) (value string, ok bool, err error)
}

VariableContext gives the values the variables read: the window fills what it has, and a variable whose value is missing fails with the reason VS Code gives (no editor, no folder, no selection). Every member is optional.

Jump to

Keyboard shortcuts

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