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
- Variables
- func ByteOfColumn(line string, column int) int
- func ColumnOfByte(line string, off int) int
- func EvaluatableExpression(line string, column int) (text string, startColumn, endColumn int)
- func ExactExpression(line string, looseStart, looseEnd int) (start, end int)
- func InlineHover(full string) string
- func InlineText(values []InlineVariable, maxChars int) (shown, full string)
- func LaunchFilePath(folder string) string
- func LaunchFromSetting(value any) (LaunchFile, []Problem)
- func ParseLaunch(text string) (LaunchFile, []Problem)
- func ReadLaunchFile(ctx context.Context, folder string) (f LaunchFile, problems []Problem, found bool, err error)
- func ResolveString(ctx context.Context, vc *VariableContext, value string, opts ResolveOptions) (resolved string, ok bool, err error)
- func WithSession(ctx context.Context, s *Session) context.Context
- type Breakpoint
- type BreakpointData
- type BreakpointFilter
- type BreakpointUpdate
- type BreakpointsChange
- type CompletionKind
- type Compound
- type CompoundRef
- type CompoundRoot
- type Config
- type ConnectFunc
- type Debugger
- type DebuggerSchema
- type DynamicSelection
- type DynamicType
- type Event
- type EventKind
- type ExceptionBreakpoint
- type ExceptionInfo
- type Expression
- func (e *Expression) Available() bool
- func (c *Expression) Children(ctx context.Context) ([]*Variable, error)
- func (e *Expression) Evaluate(ctx context.Context, s *Session, frame *StackFrame, evalContext string, ...) error
- func (c *Expression) EvaluateLazy(ctx context.Context) error
- func (c *Expression) HasChildren() bool
- func (c *Expression) ID() string
- func (c *Expression) IndexedVariables() int
- func (c *Expression) MemoryReference() string
- func (c *Expression) NamedVariables() int
- func (c *Expression) PresentationHint() *dap.VariablePresentationHint
- func (c *Expression) Reference() int
- func (c *Expression) Session() *Session
- func (e *Expression) SetValue(ctx context.Context, frame *StackFrame, value string) error
- func (e *Expression) String() string
- func (c *Expression) Type() string
- func (c *Expression) Value() string
- func (c *Expression) ValueChanged() bool
- type Focus
- type Folder
- type FunctionBreakpoint
- type FunctionBreakpointOptions
- type GuessResult
- type InlineLine
- type InlineScope
- type InlineVariable
- type Input
- type InputMemory
- type InputOption
- type LRUInputMemory
- type Launch
- type LaunchCompletion
- type LaunchFile
- type LaunchKind
- type LaunchSources
- type Launches
- func (l *Launches) All() []struct{ ... }
- func (l *Launches) Launch(folderOrKey string) *Launch
- func (l *Launches) Launches() []*Launch
- func (l *Launches) RecentDynamic() []DynamicSelection
- func (l *Launches) Reload(ctx context.Context, src LaunchSources) error
- func (l *Launches) RemoveRecentDynamic(name, typ string)
- func (l *Launches) ResolveByProviders(ctx context.Context, folder, typ string, cfg Config) (Config, error)
- func (l *Launches) Select(launch *Launch, name string, opts SelectOptions)
- func (l *Launches) Selected() Selected
- func (l *Launches) SelectedConfig(ctx context.Context) (Config, error)
- type Model
- func (m *Model) AddReplHistory(expr string)
- func (m *Model) AddWatchExpression(name string) *Expression
- func (m *Model) Breakpoint(id string) (Breakpoint, bool)
- func (m *Model) BreakpointModes(kind string) []dap.BreakpointMode
- func (m *Model) Breakpoints(f BreakpointFilter) []Breakpoint
- func (m *Model) BreakpointsActivated() bool
- func (m *Model) ExceptionBreakpoints(sessionID string) []ExceptionBreakpoint
- func (m *Model) Focus() Focus
- func (m *Model) FunctionBreakpoints() []FunctionBreakpoint
- func (m *Model) MoveWatchExpression(id string, position int)
- func (m *Model) RemoveWatchExpressions(id string)
- func (m *Model) RenameWatchExpression(id, name string)
- func (m *Model) ReplHistory() []string
- func (m *Model) Session(id string) *Session
- func (m *Model) Sessions(includeInactive bool) []*Session
- func (m *Model) SetDocumentDirty(path string, dirty bool)
- func (m *Model) Subscribe(fn func(Event)) (cancel func())
- func (m *Model) WatchExpressions() []*Expression
- type Node
- type Options
- type PickItem
- type PickRequest
- type Presentation
- type Problem
- type PromptRequest
- type Range
- type Reference
- func (c *Reference) Children(ctx context.Context) ([]*Variable, error)
- func (c *Reference) EvaluateLazy(ctx context.Context) error
- func (c *Reference) HasChildren() bool
- func (c *Reference) ID() string
- func (c *Reference) IndexedVariables() int
- func (c *Reference) MemoryReference() string
- func (c *Reference) NamedVariables() int
- func (c *Reference) PresentationHint() *dap.VariablePresentationHint
- func (c *Reference) Reference() int
- func (c *Reference) Session() *Session
- func (c *Reference) Type() string
- func (c *Reference) Value() string
- func (c *Reference) ValueChanged() bool
- type ReplConfig
- type ReplData
- type ReplElement
- type ReplFilter
- type ReplGroup
- type ReplInput
- type ReplModel
- func (m *ReplModel) AddExpression(ctx context.Context, s *Session, frame *StackFrame, expression string)
- func (m *ReplModel) Append(s *Session, d ReplData)
- func (m *ReplModel) Clear()
- func (m *ReplModel) Elements() []ReplElement
- func (m *ReplModel) EndGroup()
- func (m *ReplModel) Len() int
- func (m *ReplModel) StartGroup(s *Session, name string, autoExpand bool, src *ReplSource)
- func (m *ReplModel) Subscribe(fn func()) (cancel func())
- func (m *ReplModel) Version() uint64
- type ReplOutput
- type ReplResult
- type ReplSeverity
- type ReplSource
- type ReplVariable
- type Replacement
- type ResolveOptions
- type Scope
- func (c *Scope) Children(ctx context.Context) ([]*Variable, error)
- func (s *Scope) ChildrenLoaded() bool
- func (c *Scope) EvaluateLazy(ctx context.Context) error
- func (c *Scope) HasChildren() bool
- func (c *Scope) ID() string
- func (c *Scope) IndexedVariables() int
- func (c *Scope) MemoryReference() string
- func (c *Scope) NamedVariables() int
- func (c *Scope) PresentationHint() *dap.VariablePresentationHint
- func (c *Scope) Reference() int
- func (c *Scope) Session() *Session
- func (c *Scope) Type() string
- func (c *Scope) Value() string
- func (c *Scope) ValueChanged() bool
- type SelectOptions
- type Selected
- type Service
- func (s *Service) AddBreakpoints(ctx context.Context, path string, data []BreakpointData) ([]Breakpoint, error)
- func (s *Service) AddFunctionBreakpoint(ctx context.Context, opts FunctionBreakpointOptions) (FunctionBreakpoint, error)
- func (s *Service) AppendConsole(text string)
- func (s *Service) DocumentDeleted(path string)
- func (s *Service) DocumentSaved(ctx context.Context, path string) error
- func (s *Service) EnableOrDisableBreakpoints(ctx context.Context, enable bool, id string) error
- func (s *Service) EvaluateWatchExpressions(ctx context.Context)
- func (s *Service) FirstSessionStart() bool
- func (s *Service) FocusStackFrame(frame *StackFrame, thread *Thread, session *Session)
- func (s *Service) HasDebugged() bool
- func (s *Service) Launches() *Launches
- func (s *Service) Model() *Model
- func (s *Service) RemoveBreakpoints(ctx context.Context, ids ...string) error
- func (s *Service) RemoveFunctionBreakpoints(ctx context.Context, id string) error
- func (s *Service) RestartSession(ctx context.Context, sess *Session, restartData any) error
- func (s *Service) RestoreState(data []byte) error
- func (s *Service) RunTo(ctx context.Context, path string, line, column int) error
- func (s *Service) SaveState() ([]byte, error)
- func (s *Service) SetBreakpointsActivated(ctx context.Context, on bool) error
- func (s *Service) SetExceptionBreakpointCondition(ctx context.Context, id, condition string) error
- func (s *Service) SetExceptionBreakpointFallbackSession(sessionID string)
- func (s *Service) StartDebugging(ctx context.Context, launch *Launch, target Target, opts SessionOptions) (bool, error)
- func (s *Service) State() State
- func (s *Service) Stop(ctx context.Context, sess *Session, disconnect, suspend bool) error
- func (s *Service) Subscribe(fn func(Event)) (cancel func())
- func (s *Service) UpdateBreakpoints(ctx context.Context, path string, updates map[string]BreakpointUpdate, ...) error
- func (s *Service) UpdateFunctionBreakpoint(ctx context.Context, id string, name, condition, hitCondition *string) error
- type Session
- func (s *Session) AddOutput(category, text string)
- func (s *Session) AddReplExpression(ctx context.Context, frame *StackFrame, expression string)
- func (s *Session) AppendToRepl(output string, sev ReplSeverity)
- func (s *Session) BreakpointLocations(ctx context.Context, path string, line int) ([]dap.BreakpointLocation, error)
- func (s *Session) CancelProgress(ctx context.Context, progressID string) error
- func (s *Session) Capabilities() dap.Capabilities
- func (s *Session) Completions(ctx context.Context, frameID int, text string, column int) ([]dap.CompletionItem, error)
- func (s *Session) CompletionsAt(ctx context.Context, frameID int, text string, line, column int) ([]dap.CompletionItem, error)
- func (s *Session) Configuration() Config
- func (s *Session) ConsoleRoot() *Session
- func (s *Session) Continue(ctx context.Context, threadID int) error
- func (s *Session) CustomRequest(ctx context.Context, command string, args any) (json.RawMessage, error)
- func (s *Session) Disconnect(ctx context.Context, restart, suspend bool) error
- func (s *Session) Evaluate(ctx context.Context, expr string, frame *StackFrame, evalContext string) (*Expression, error)
- func (s *Session) ExceptionInfo(ctx context.Context, threadID int) (*ExceptionInfo, error)
- func (s *Session) Goto(ctx context.Context, threadID, targetID int) error
- func (s *Session) GotoTargets(ctx context.Context, path string, line, column int) ([]dap.GotoTarget, error)
- func (s *Session) HasSeparateRepl() bool
- func (s *Session) ID() string
- func (s *Session) Idle(ctx context.Context) error
- func (s *Session) IsAttach() bool
- func (s *Session) Label() string
- func (s *Session) LoadMoreFrames(ctx context.Context, t *Thread, levels int) error
- func (s *Session) LoadSource(ctx context.Context, src Source) (string, error)
- func (s *Session) LoadedSources(ctx context.Context) ([]Source, error)
- func (s *Session) Name() string
- func (s *Session) Next(ctx context.Context, threadID int, granularity string) error
- func (s *Session) Options() SessionOptions
- func (s *Session) Parent() *Session
- func (s *Session) Pause(ctx context.Context, threadID int) error
- func (s *Session) Repl() *ReplModel
- func (s *Session) Restart(ctx context.Context) error
- func (s *Session) RestartFrame(ctx context.Context, frameID, threadID int) error
- func (s *Session) ReverseContinue(ctx context.Context, threadID int) error
- func (s *Session) Root() string
- func (s *Session) SetConfiguration(resolved, unresolved Config)
- func (s *Session) SetName(name string)
- func (s *Session) SourceUnavailable(key string)
- func (s *Session) State() State
- func (s *Session) StepBack(ctx context.Context, threadID int, granularity string) error
- func (s *Session) StepIn(ctx context.Context, threadID, targetID int, granularity string) error
- func (s *Session) StepInTargets(ctx context.Context, frameID int) ([]dap.StepInTarget, error)
- func (s *Session) StepOut(ctx context.Context, threadID int, granularity string) error
- func (s *Session) StoppedDetails() *StoppedDetails
- func (s *Session) Terminate(ctx context.Context, restart bool) error
- func (s *Session) TerminateThreads(ctx context.Context, threadIDs []int) error
- func (s *Session) Thread(id int) *Thread
- func (s *Session) Threads() []*Thread
- func (s *Session) Type() string
- func (s *Session) UnresolvedConfiguration() Config
- type SessionData
- type SessionOptions
- type Severity
- type Snippet
- type Source
- type StackFrame
- func (f *StackFrame) Deemphasized() bool
- func (f *StackFrame) Equals(o *StackFrame) bool
- func (f *StackFrame) Key() string
- func (f *StackFrame) MostSpecificScopes(ctx context.Context, r Range) ([]*Scope, error)
- func (f *StackFrame) Restart(ctx context.Context) error
- func (f *StackFrame) Scopes(ctx context.Context) ([]*Scope, error)
- func (f *StackFrame) String() string
- type State
- type StoppedDetails
- type Target
- type TaskRef
- type TaskResult
- type Thread
- func (t *Thread) CallStack() []*StackFrame
- func (t *Thread) Continue(ctx context.Context) error
- func (t *Thread) ExceptionInfo(ctx context.Context) (*ExceptionInfo, error)
- func (t *Thread) FetchCallStack(ctx context.Context, levels int) error
- func (t *Thread) Key() string
- func (t *Thread) LastSteppingGranularity() string
- func (t *Thread) Name() string
- func (t *Thread) Next(ctx context.Context, granularity string) error
- func (t *Thread) Pause(ctx context.Context) error
- func (t *Thread) ReachedEndOfCallStack() bool
- func (t *Thread) ReverseContinue(ctx context.Context) error
- func (t *Thread) Session() *Session
- func (t *Thread) StaleCallStack() []*StackFrame
- func (t *Thread) StateLabel() string
- func (t *Thread) StepBack(ctx context.Context, granularity string) error
- func (t *Thread) StepIn(ctx context.Context, granularity string) error
- func (t *Thread) StepOut(ctx context.Context, granularity string) error
- func (t *Thread) Stopped() bool
- func (t *Thread) StoppedDetails() *StoppedDetails
- func (t *Thread) Terminate(ctx context.Context) error
- func (t *Thread) TopStackFrame() *StackFrame
- type Tracker
- type Variable
- func (c *Variable) Children(ctx context.Context) ([]*Variable, error)
- func (v *Variable) ErrorMessage() string
- func (c *Variable) EvaluateLazy(ctx context.Context) error
- func (c *Variable) HasChildren() bool
- func (c *Variable) ID() string
- func (c *Variable) IndexedVariables() int
- func (c *Variable) MemoryReference() string
- func (c *Variable) NamedVariables() int
- func (c *Variable) PresentationHint() *dap.VariablePresentationHint
- func (c *Variable) Reference() int
- func (c *Variable) Session() *Session
- func (v *Variable) SetExpression(ctx context.Context, frame *StackFrame, value string) error
- func (v *Variable) SetValue(ctx context.Context, frame *StackFrame, value string) error
- func (v *Variable) String() string
- func (v *Variable) ThreadID() int
- func (c *Variable) Type() string
- func (c *Variable) Value() string
- func (c *Variable) ValueChanged() bool
- type VariableContext
Constants ¶
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).
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.
const InputMemoryCapacity = 5
InputMemoryCapacity is how many inputs' last values are kept (VS Code's LAST_INPUT_CACHE_SIZE).
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).
const MaxInlineLength = 150
MaxInlineLength is the number of characters of the text after a line; a longer text is cut and ends with "...".
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).
const MaxReplHistory = 100
MaxReplHistory is how many expressions of the Debug Console's history are kept.
const MaxStateBreakpoints = 10000
MaxStateBreakpoints bounds the breakpoints a saved state may hold, so that a damaged file cannot make the model huge.
const NotAvailable = "not available"
NotAvailable is the value of a watch expression that has not been evaluated (VS Code's "not available").
const StateVersion = 1
StateVersion is the version of the saved debug state.
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.
const UnknownSourceLabel = "Unknown Source"
UnknownSourceLabel is the name of the source of a frame that has none.
Variables ¶
var DefaultReplConfig = ReplConfig{CollapseIdenticalLines: true, MaximumLines: 10000}
DefaultReplConfig is VS Code's default of the two settings.
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 ¶
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 ¶
ColumnOfByte is the column, counted from 1 in UTF-16 code units, of a byte offset in a line.
func EvaluatableExpression ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) Presentation ¶
func (c Config) Presentation() *Presentation
Presentation reads the presentation attribute; a configuration without one gives nil.
type ConnectFunc ¶
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 ¶
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 ¶
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) 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 ¶
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) 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) 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 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 ¶
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 ¶
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) Configuration ¶
Configuration returns a copy of the configuration with a name, with the attributes of the platform applied, or false.
func (*Launch) ConfigurationNames ¶
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.
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 ¶
All lists every configuration and compound the dropdown shows, with the launch it is in.
func (*Launches) 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 ¶
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 ¶
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)
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 ¶
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 ¶
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) FunctionBreakpoints ¶
func (m *Model) FunctionBreakpoints() []FunctionBreakpoint
FunctionBreakpoints returns the function breakpoints in the order they were added.
func (*Model) MoveWatchExpression ¶
MoveWatchExpression moves a watch expression to a position of the list.
func (*Model) RemoveWatchExpressions ¶
RemoveWatchExpressions removes the watch expression with an id, or all of them when id is empty.
func (*Model) RenameWatchExpression ¶
RenameWatchExpression changes the text of a watch expression; its value is forgotten until the next evaluation.
func (*Model) ReplHistory ¶
ReplHistory returns the expressions the user typed in the Debug Console, the oldest first.
func (*Model) Sessions ¶
Sessions returns the sessions that are not inactive (all, with includeInactive), the children after their parent.
func (*Model) SetDocumentDirty ¶
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 ¶
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 PickRequest ¶
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.
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) EvaluateLazy ¶
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) 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) ValueChanged ¶
func (c *Reference) ValueChanged() bool
ValueChanged is true when the value differs from the one the node had before.
type ReplConfig ¶
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) 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.
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)
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 ¶
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) 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.
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) 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) 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 ¶
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) Source ¶
func (v *ReplVariable) Source() *ReplSource
Source 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) ChildrenLoaded ¶
ChildrenLoaded tells whether the children of the scope have been loaded.
func (*Scope) EvaluateLazy ¶
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) 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) 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 ¶
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 ¶
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 ¶
DocumentDeleted removes the breakpoints of a file that was deleted.
func (*Service) DocumentSaved ¶
DocumentSaved sends, for a file that was saved, the breakpoints that moved with its edits (with sourceModified).
func (*Service) EnableOrDisableBreakpoints ¶
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 ¶
EvaluateWatchExpressions evaluates every watch expression in the focused stack frame (the Watch view does it when the focus changes).
func (*Service) FirstSessionStart ¶
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 ¶
HasDebugged tells whether a session was started in this window (the context key debuggersAvailable / hasDebugged).
func (*Service) RemoveBreakpoints ¶
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 ¶
RemoveFunctionBreakpoints removes the function breakpoint with an id, or all of them.
func (*Service) RestartSession ¶
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 ¶
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 ¶
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) SetBreakpointsActivated ¶
SetBreakpointsActivated turns all breakpoints on or off without changing them ("Toggle Activate Breakpoints").
func (*Service) SetExceptionBreakpointCondition ¶
SetExceptionBreakpointCondition sets the condition of an exception filter.
func (*Service) SetExceptionBreakpointFallbackSession ¶
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 ¶
State is the state of the focused session; without one, Initializing while a session is being made, else Inactive.
func (*Service) Stop ¶
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 ¶
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.
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 ¶
SessionFromContext returns the session that a context of Debugger.Connect carries.
func (*Session) AddOutput ¶
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 ¶
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 ¶
Configuration returns the resolved configuration the session runs.
func (*Session) ConsoleRoot ¶
ConsoleRoot is the session whose Debug Console the session writes to: itself, or the nearest parent with a console of its own.
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 ¶
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 ¶
ExceptionInfo asks for the exception a thread stopped on.
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 ¶
HasSeparateRepl tells whether the session has a Debug Console of its own.
func (*Session) Idle ¶
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 ¶
IsAttach reports whether the session attached to a program instead of launching it; the toolbar then offers Disconnect.
func (*Session) LoadMoreFrames ¶
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 ¶
LoadSource reads a source the adapter serves (a source with a sourceReference).
func (*Session) LoadedSources ¶
LoadedSources asks for the sources the debuggee has loaded (Loaded Scripts), when the adapter can.
func (*Session) Name ¶
Name is the name of the session (the configuration's name, made unique among the sessions).
func (*Session) Options ¶
func (s *Session) Options() SessionOptions
Options returns the options the session was made with.
func (*Session) Repl ¶
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 ¶
Restart asks the adapter to restart the debuggee (restart); the adapter must support it.
func (*Session) RestartFrame ¶
RestartFrame restarts a stack frame, when the adapter can.
func (*Session) ReverseContinue ¶
ReverseContinue resumes the thread backwards.
func (*Session) SetConfiguration ¶
SetConfiguration replaces the configurations (a restart that read launch.json again).
func (*Session) SourceUnavailable ¶
SourceUnavailable notes that the source at a key (Source.Key) could not be opened.
func (*Session) StepIn ¶
StepIn steps into; targetID picks the target when the adapter offered several (stepInTargets).
func (*Session) StepInTargets ¶
StepInTargets asks for the targets a step into can go to in a frame.
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 ¶
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 ¶
TerminateThreads ends threads of the debuggee, when the adapter can.
func (*Session) UnresolvedConfiguration ¶
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 Snippet ¶
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 ¶
InMemory reports whether the source is not a file (the adapter serves its content with the source request).
func (Source) Key ¶
Key identifies the source: its path, or debug:<name>?session=<id>&ref=<reference> for one the adapter serves.
func (Source) PresentationHint ¶
PresentationHint is the adapter's hint (normal, emphasize, deemphasize).
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 ¶
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 )
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 ¶
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.
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) 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 ¶
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) LastSteppingGranularity ¶
LastSteppingGranularity is the granularity of the last step of the thread.
func (*Thread) ReachedEndOfCallStack ¶
ReachedEndOfCallStack tells whether the whole call stack is loaded.
func (*Thread) ReverseContinue ¶
ReverseContinue resumes backwards.
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 ¶
StateLabel is "Running", "Paused" or "Paused on <reason>" (or the adapter's description).
func (*Thread) StoppedDetails ¶
func (t *Thread) StoppedDetails() *StoppedDetails
StoppedDetails returns why the thread stopped, or nil while it runs.
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 (*Tracker) Sync ¶
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.
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) ErrorMessage ¶
ErrorMessage is the message of the adapter when the last SetValue failed.
func (*Variable) EvaluateLazy ¶
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) 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 ¶
SetExpression changes the value with setExpression, for the variable's EvaluateName.
func (*Variable) SetValue ¶
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) 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.