Documentation
¶
Index ¶
- func DefaultSocketPath() string
- func EnsureDaemon(socketPath string) (string, error)
- func FindJSDebugServer() string
- func FormatJSON(r *ContextResult) string
- func FormatResponse(resp *Response, jsonOutput bool) string
- func FormatText(r *ContextResult) string
- func NewRootCmd(version string) *cobra.Command
- func ReadIPC(r io.Reader, msg any) error
- func SessionSocketPath(name string) string
- func StartDaemon(socketPath string)
- func WriteIPC(w io.Writer, msg any) error
- type Backend
- type BreakAddArgs
- type BreakRemoveArgs
- type Breakpoint
- type BreakpointUpdates
- type ContextArgs
- type ContextResult
- type ContinueArgs
- type DAPClient
- func (c *DAPClient) AttachRequestWithArgs(args map[string]any) error
- func (c *DAPClient) Close()
- func (c *DAPClient) ConfigurationDoneRequest() error
- func (c *DAPClient) ContinueRequest(threadID int) error
- func (c *DAPClient) DisconnectRequest(terminateDebuggee bool) error
- func (c *DAPClient) EvaluateRequest(expression string, frameID int, context string) error
- func (c *DAPClient) ExceptionInfoRequest(threadID int) error
- func (c *DAPClient) InitializeRequest(adapterID string) error
- func (c *DAPClient) LaunchRequestWithArgs(args map[string]any) error
- func (c *DAPClient) NextRequest(threadID int) error
- func (c *DAPClient) PauseRequest(threadID int) error
- func (c *DAPClient) ReadMessage() (godap.Message, error)
- func (c *DAPClient) ScopesRequest(frameID int) error
- func (c *DAPClient) SetBreakpointsRequest(file string, breakpoints []Breakpoint) error
- func (c *DAPClient) SetExceptionBreakpointsRequest(filters []string) error
- func (c *DAPClient) SetFunctionBreakpointsRequest(functions []string) error
- func (c *DAPClient) SetVariableRequest(variablesRef int, name, value string) error
- func (c *DAPClient) StackTraceRequest(threadID, startFrame, levels int) error
- func (c *DAPClient) StepInRequest(threadID int) error
- func (c *DAPClient) StepOutRequest(threadID int) error
- func (c *DAPClient) TerminateRequest() error
- func (c *DAPClient) ThreadsRequest() error
- func (c *DAPClient) VariablesRequest(variablesReference int) error
- type Daemon
- type DebugArgs
- type EvalArgs
- type EvalResult
- type ExceptionInfo
- type InspectArgs
- type InspectResult
- type Location
- type OutputArgs
- type PauseArgs
- type Request
- type Response
- type SourceLine
- type StackFrame
- type StepArgs
- type ThreadArgs
- type ThreadInfo
- type Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSocketPath ¶
func DefaultSocketPath() string
DefaultSocketPath returns the default socket path (session "default").
func EnsureDaemon ¶
EnsureDaemon makes sure a daemon is running, starting one if needed. Returns the socket path.
func FindJSDebugServer ¶
func FindJSDebugServer() string
FindJSDebugServer searches for the js-debug DAP server script. Returns the path or "" if not found.
func FormatJSON ¶
func FormatJSON(r *ContextResult) string
FormatJSON formats a ContextResult as JSON.
func FormatResponse ¶
FormatResponse formats a Response for CLI output.
func FormatText ¶
func FormatText(r *ContextResult) string
FormatText formats a ContextResult as human-readable text.
func NewRootCmd ¶
NewRootCmd creates the cobra root command with all subcommands.
func SessionSocketPath ¶
SessionSocketPath returns the socket path for a named session.
func StartDaemon ¶
func StartDaemon(socketPath string)
StartDaemon starts the daemon process (called from __daemon subcommand).
Types ¶
type Backend ¶
type Backend interface {
Spawn(port string) (cmd *exec.Cmd, addr string, err error)
TransportMode() string
AdapterID() string
LaunchArgs(program string, stopOnEntry bool, args []string) (launchArgs map[string]any, cleanup func(), err error)
RemoteAttachArgs(host string, port int) (map[string]any, error)
// StopOnEntryBreakpoint returns a function name to use as a breakpoint
// for stop-on-entry behavior. If empty, native stopOnEntry is used.
StopOnEntryBreakpoint() string
// PIDAttachArgs returns attach arguments for attaching to a local process by PID.
PIDAttachArgs(pid int) (map[string]any, error)
}
Backend abstracts the debugger-specific logic for spawning a DAP server and building launch/attach argument maps.
func DetectBackend ¶
DetectBackend returns the appropriate backend based on file extension.
func GetBackendByName ¶
GetBackendByName returns a backend by name.
type BreakAddArgs ¶ added in v0.2.0
type BreakAddArgs struct {
Breaks []Breakpoint `json:"breaks,omitempty"`
ExceptionFilters []string `json:"exception_filters,omitempty"`
}
BreakAddArgs are arguments for the "break_add" command.
type BreakRemoveArgs ¶ added in v0.2.0
type BreakRemoveArgs struct {
Breaks []Breakpoint `json:"breaks,omitempty"`
ExceptionFilters []string `json:"exception_filters,omitempty"`
}
BreakRemoveArgs are arguments for the "break_remove" command.
type Breakpoint ¶ added in v0.2.0
type Breakpoint struct {
File string `json:"file"`
Line int `json:"line"`
Condition string `json:"condition,omitempty"`
}
Breakpoint represents a source breakpoint with optional condition.
func (Breakpoint) LocationKey ¶ added in v0.2.0
func (b Breakpoint) LocationKey() string
LocationKey returns "file:line" — the identity key for merging/removing.
func (Breakpoint) String ¶ added in v0.2.0
func (b Breakpoint) String() string
String returns a human-readable representation.
type BreakpointUpdates ¶ added in v0.2.0
type BreakpointUpdates struct {
Breaks []Breakpoint `json:"breaks,omitempty"` // breakpoints to add (additive)
RemoveBreaks []Breakpoint `json:"remove_breaks,omitempty"` // breakpoints to remove
ExceptionFilters []string `json:"exception_filters,omitempty"` // backend-specific filter IDs (additive, merged with existing)
}
BreakpointUpdates holds breakpoint modifications shared across commands.
type ContextArgs ¶
type ContextArgs struct {
Frame int `json:"frame,omitempty"`
ContextLines int `json:"context_lines,omitempty"`
BreakpointUpdates
}
ContextArgs are arguments for the "context" command.
type ContextResult ¶
type ContextResult struct {
Reason string `json:"reason,omitempty"`
Location *Location `json:"location,omitempty"`
Source []SourceLine `json:"source,omitempty"`
Locals []Variable `json:"locals,omitempty"`
Stack []StackFrame `json:"stack,omitempty"`
Output string `json:"output,omitempty"`
ExitCode *int `json:"exit_code,omitempty"`
EvalResult *EvalResult `json:"eval_result,omitempty"`
ExceptionInfo *ExceptionInfo `json:"exception_info,omitempty"`
InspectResult *InspectResult `json:"inspect_result,omitempty"`
// Warnings from unverified breakpoints (drained on each response)
Warnings []string `json:"warnings,omitempty"`
// Thread list results
Threads []ThreadInfo `json:"threads,omitempty"`
IsThreadList bool `json:"is_thread_list,omitempty"`
// Break list results
Breakpoints []Breakpoint `json:"breakpoints,omitempty"`
ExceptionFilters []string `json:"exception_filters,omitempty"`
IsBreakList bool `json:"is_break_list,omitempty"`
}
ContextResult holds the auto-context returned by execution commands.
type ContinueArgs ¶
type ContinueArgs struct {
ContinueTo *Breakpoint `json:"continue_to,omitempty"`
ContextLines int `json:"context_lines,omitempty"`
BreakpointUpdates
}
ContinueArgs are arguments for the "continue" command.
type DAPClient ¶
type DAPClient struct {
// contains filtered or unexported fields
}
DAPClient is a DAP protocol client built on google/go-dap. All send methods are fire-and-forget; responses come through ReadMessage.
func (*DAPClient) AttachRequestWithArgs ¶
AttachRequestWithArgs sends an 'attach' request with backend-specific args.
func (*DAPClient) ConfigurationDoneRequest ¶
ConfigurationDoneRequest sends a 'configurationDone' request.
func (*DAPClient) ContinueRequest ¶
ContinueRequest sends a 'continue' request.
func (*DAPClient) DisconnectRequest ¶
DisconnectRequest sends a 'disconnect' request.
func (*DAPClient) EvaluateRequest ¶
EvaluateRequest sends an 'evaluate' request.
func (*DAPClient) ExceptionInfoRequest ¶ added in v0.3.0
ExceptionInfoRequest sends an 'exceptionInfo' request.
func (*DAPClient) InitializeRequest ¶
InitializeRequest sends an 'initialize' request.
func (*DAPClient) LaunchRequestWithArgs ¶
LaunchRequestWithArgs sends a 'launch' request with backend-specific args.
func (*DAPClient) NextRequest ¶
NextRequest sends a 'next' (step over) request.
func (*DAPClient) PauseRequest ¶
PauseRequest sends a 'pause' request.
func (*DAPClient) ReadMessage ¶
ReadMessage reads the next DAP protocol message. It skips messages with unsupported event/command types (e.g. debugpy's custom events).
func (*DAPClient) ScopesRequest ¶
ScopesRequest sends a 'scopes' request.
func (*DAPClient) SetBreakpointsRequest ¶
func (c *DAPClient) SetBreakpointsRequest(file string, breakpoints []Breakpoint) error
SetBreakpointsRequest sends a 'setBreakpoints' request.
func (*DAPClient) SetExceptionBreakpointsRequest ¶
SetExceptionBreakpointsRequest sends a 'setExceptionBreakpoints' request.
func (*DAPClient) SetFunctionBreakpointsRequest ¶
SetFunctionBreakpointsRequest sends a 'setFunctionBreakpoints' request.
func (*DAPClient) SetVariableRequest ¶
SetVariableRequest sends a 'setVariable' request.
func (*DAPClient) StackTraceRequest ¶
StackTraceRequest sends a 'stackTrace' request.
func (*DAPClient) StepInRequest ¶
StepInRequest sends a 'stepIn' request.
func (*DAPClient) StepOutRequest ¶
StepOutRequest sends a 'stepOut' request.
func (*DAPClient) TerminateRequest ¶
TerminateRequest sends a 'terminate' request.
func (*DAPClient) ThreadsRequest ¶
ThreadsRequest sends a 'threads' request.
func (*DAPClient) VariablesRequest ¶
VariablesRequest sends a 'variables' request.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon holds the stateful debug session.
type DebugArgs ¶
type DebugArgs struct {
Script string `json:"script"`
Backend string `json:"backend,omitempty"`
Breaks []Breakpoint `json:"breaks,omitempty"`
StopOnEntry bool `json:"stop_on_entry,omitempty"`
Attach string `json:"attach,omitempty"` // "host:port" for remote
PID int `json:"pid,omitempty"` // PID for local attach
ProgramArgs []string `json:"program_args,omitempty"`
ExceptionFilters []string `json:"exception_filters,omitempty"` // backend-specific filter IDs
ContextLines int `json:"context_lines,omitempty"`
}
DebugArgs are arguments for the "debug" command.
type EvalArgs ¶
type EvalArgs struct {
Expression string `json:"expression"`
Frame int `json:"frame,omitempty"`
BreakpointUpdates
}
EvalArgs are arguments for the "eval" command.
type EvalResult ¶
EvalResult holds the result of an eval command.
type ExceptionInfo ¶ added in v0.3.0
type ExceptionInfo struct {
ExceptionID string `json:"exception_id"`
Description string `json:"description,omitempty"`
Details string `json:"details,omitempty"`
}
ExceptionInfo holds details about an exception that caused a stop.
type InspectArgs ¶ added in v0.3.0
type InspectArgs struct {
Variable string `json:"variable"`
Depth int `json:"depth,omitempty"` // default 1, max 5
Frame int `json:"frame,omitempty"`
}
InspectArgs are arguments for the "inspect" command.
type InspectResult ¶ added in v0.3.0
type InspectResult struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Value string `json:"value"`
Children []InspectResult `json:"children,omitempty"`
}
InspectResult holds the result of an inspect command.
type Location ¶
type Location struct {
File string `json:"file"`
Line int `json:"line"`
Function string `json:"function"`
}
Location identifies a position in source code.
type OutputArgs ¶ added in v0.2.0
type OutputArgs struct {
BreakpointUpdates
}
OutputArgs are arguments for the "output" command.
type PauseArgs ¶ added in v0.3.0
type PauseArgs struct {
BreakpointUpdates
}
PauseArgs are arguments for the "pause" command.
type Request ¶
type Request struct {
Command string `json:"command"`
Args json.RawMessage `json:"args,omitempty"`
}
Request is sent from CLI to daemon over Unix socket.
type Response ¶
type Response struct {
Status string `json:"status"` // "stopped", "terminated", "error", "ok"
Error string `json:"error,omitempty"`
Data *ContextResult `json:"data,omitempty"`
}
Response is sent from daemon to CLI over Unix socket.
type SourceLine ¶
type SourceLine struct {
Line int `json:"line"`
Text string `json:"text"`
Current bool `json:"current,omitempty"`
}
SourceLine is a single line of source code.
type StackFrame ¶
type StackFrame struct {
Frame int `json:"frame"`
Function string `json:"function"`
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
}
StackFrame represents a frame in the call stack.
type StepArgs ¶
type StepArgs struct {
Mode string `json:"mode"` // "over", "in", "out"
ContextLines int `json:"context_lines,omitempty"`
BreakpointUpdates
}
StepArgs are arguments for the "step" command.
type ThreadArgs ¶ added in v0.3.0
type ThreadArgs struct {
ThreadID int `json:"thread_id"`
ContextLines int `json:"context_lines,omitempty"`
}
ThreadArgs are arguments for the "thread" command.
type ThreadInfo ¶ added in v0.3.0
type ThreadInfo struct {
ID int `json:"id"`
Name string `json:"name"`
Current bool `json:"current,omitempty"`
}
ThreadInfo represents a thread in the debugged program.
