debug

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("This call has not been implemented")

ErrNotImplemented is returned by a handler if the called method is not implemented

Functions

func JoinPath

func JoinPath(base string, other string) string

JoinPath wraps filepath.Join, but returns only the second part if the second part is an absolute path

func StartSession

func StartSession(conn io.ReadWriteCloser, handler Handler, debuglog bool)

StartSession handles a session with a single client. It reads and decodes the incoming data and dispatches it to per-request processing goroutines. It also launches the sender goroutine to send resulting messages over the connection back to the client. If debuglog is true, all incoming and outgoing messages are logged

Types

type Handler

type Handler interface {
	SetSession(s *Session)
	OnInitializeRequest(arguments *dap.InitializeRequestArguments) (*dap.Capabilities, error)
	OnLaunchRequest(arguments map[string]interface{}) error
	OnAttachRequest(arguments *dap.AttachRequestArguments) error
	OnDisconnectRequest(arguments *dap.DisconnectArguments) error
	OnTerminateRequest(arguments *dap.TerminateArguments) error
	OnRestartRequest(arguments *dap.RestartArguments) error
	OnSetBreakpointsRequest(arguments *dap.SetBreakpointsArguments) (*dap.SetBreakpointsResponseBody, error)
	OnSetFunctionBreakpointsRequest(arguments *dap.SetFunctionBreakpointsArguments) (*dap.SetFunctionBreakpointsResponseBody, error)
	OnSetExceptionBreakpointsRequest(arguments *dap.SetExceptionBreakpointsArguments) error
	OnConfigurationDoneRequest(arguments *dap.ConfigurationDoneArguments) error
	OnContinueRequest(arguments *dap.ContinueArguments) (*dap.ContinueResponseBody, error)
	OnNextRequest(arguments *dap.NextArguments) error
	OnStepInRequest(arguments *dap.StepInArguments) error
	OnStepOutRequest(arguments *dap.StepOutArguments) error
	OnStepBackRequest(arguments *dap.StepBackArguments) error
	OnReverseContinueRequest(arguments *dap.ReverseContinueArguments) error
	OnRestartFrameRequest(arguments *dap.RestartFrameArguments) error
	OnGotoRequest(arguments *dap.GotoArguments) error
	OnPauseRequest(arguments *dap.PauseArguments) error
	OnStackTraceRequest(arguments *dap.StackTraceArguments) (*dap.StackTraceResponseBody, error)
	OnScopesRequest(arguments *dap.ScopesArguments) (*dap.ScopesResponseBody, error)
	OnVariablesRequest(arguments *dap.VariablesArguments) (*dap.VariablesResponseBody, error)
	OnSetVariableRequest(arguments *dap.SetVariableArguments) (*dap.SetVariableResponseBody, error)
	OnSetExpressionRequest(arguments *dap.SetExpressionArguments) (*dap.SetExpressionResponseBody, error)
	OnSourceRequest(arguments *dap.SourceArguments) (*dap.SourceResponseBody, error)
	OnThreadsRequest() (*dap.ThreadsResponseBody, error)
	OnTerminateThreadsRequest(arguments *dap.TerminateThreadsArguments) error
	OnEvaluateRequest(arguments *dap.EvaluateArguments) (*dap.EvaluateResponseBody, error)
	OnStepInTargetsRequest(arguments *dap.StepInTargetsArguments) (*dap.StepInTargetsResponseBody, error)
	OnGotoTargetsRequest(arguments *dap.GotoTargetsArguments) (*dap.GotoTargetsResponseBody, error)
	OnCompletionsRequest(arguments *dap.CompletionsArguments) (*dap.CompletionsResponseBody, error)
	OnExceptionInfoRequest(arguments *dap.ExceptionInfoArguments) (*dap.ExceptionInfoResponseBody, error)
	OnLoadedSourcesRequest(arguments *dap.LoadedSourcesArguments) (*dap.LoadedSourcesResponseBody, error)
	OnDataBreakpointInfoRequest(arguments *dap.DataBreakpointInfoArguments) (*dap.DataBreakpointInfoResponseBody, error)
	OnSetDataBreakpointsRequest(arguments *dap.SetDataBreakpointsArguments) (*dap.SetDataBreakpointsResponseBody, error)
	OnReadMemoryRequest(arguments *dap.ReadMemoryArguments) (*dap.ReadMemoryResponseBody, error)
	OnDisassembleRequest(arguments *dap.DisassembleArguments) (*dap.DisassembleResponseBody, error)
	OnCancelRequest(arguments *dap.CancelArguments) error
	OnBreakpointLocationsRequest(arguments *dap.BreakpointLocationsArguments) (*dap.BreakpointLocationsResponseBody, error)
}

Handler defines an interface that debug adapter protocol handlers must implement

func NewYODKHandler

func NewYODKHandler() Handler

NewYODKHandler returns a new handler connected to the given session

type Helper

type Helper struct {
	// index of the current script (the script targeted by commands)
	// used to index into vms, inputScripts and scriptFileNames
	CurrentScript int
	// the coordinater to coordinate the running vms
	Coordinator *vm.Coordinator
	// source code of the running Scripts
	Scripts []string
	// names of the running scripts
	ScriptNames []string
	// list of Vms for the running scripts
	Vms []*vm.VM
	// list of variable translations for the VMs
	// used to undo variable shortening performed by nolol using compilation
	VariableTranslations []map[string]string
	// number of the case in the given test to execute
	CaseNumber int
	// a folder all script paths are relative to
	Worspace string
	// a set of vms that have finished execution. This list is NOT managed by the Helper-class
	FinishedVMs map[int]bool
	// ValidBreakpoints contains a set of valid-breakpoint-locations for each script.
	// If no value is returned for a script, all breakpoints are valid.
	// This is needed because in a nolol-script not every line is valid for a breakpoint
	ValidBreakpoints map[int]map[int]bool
	// CompiledCode contains the generated yolol-code for for VMs that are running NOLOL
	CompiledCode map[int]string
	// If set to true, runtime-errors should not interrupt script execution
	IgnoreErrs bool
	// Contains a local variables used in a specific script
	LocalVars [][]string
	// Contains all global variables used in a specific script
	GlobalVars []string
}

Helper bundles a lot of stuff you need to debuy yolol/nolol-code

func FromScripts

func FromScripts(workspace string, scripts []string, prepareVM VMPrepareFunc) (*Helper, error)

FromScripts receives a list of yolol/nolol filenames and creates a Helper from them

func FromTest

func FromTest(workspace string, testfile string, casenr int, prepareVM VMPrepareFunc) (*Helper, error)

FromTest creates a Helper from the given test-file

func (Helper) CurrentVM

func (h Helper) CurrentVM() *vm.VM

CurrentVM returns the currently selected VM (only used in cli-debugger)

func (Helper) ReverseVarnameTranslation added in v0.0.17

func (h Helper) ReverseVarnameTranslation(vmidx int, search string) string

ReverseVarnameTranslation returns the compiled name of a variable, given the original (source) name

func (Helper) ScriptIndexByName

func (h Helper) ScriptIndexByName(name string) int

ScriptIndexByName returns the index of the script with the given name

func (Helper) ScriptIndexByPath

func (h Helper) ScriptIndexByPath(path string) int

ScriptIndexByPath returns the index of the script with the given path

type Session

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

Session handles a single debugging-session.

func (*Session) SendEvent

func (ds *Session) SendEvent(event dap.EventMessage)

SendEvent sends the gitven event

type StdioReadWriteCloser

type StdioReadWriteCloser struct {
}

StdioReadWriteCloser is a ReadWriteCloser for reading from stdin and writing to stdout If Log is true, all incoming and outgoing data is logged

func (StdioReadWriteCloser) Close

func (s StdioReadWriteCloser) Close() error

Close closes stdin and stdout

func (StdioReadWriteCloser) Read

func (s StdioReadWriteCloser) Read(p []byte) (n int, err error)

func (StdioReadWriteCloser) Write

func (s StdioReadWriteCloser) Write(p []byte) (n int, err error)

type VMPrepareFunc

type VMPrepareFunc func(yvm *vm.VM, filename string)

VMPrepareFunc receives a VM and prepares it for debugging (set error handlers etc.)

type YODKHandler

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

YODKHandler implements the handler-functions for a debug-session

func (*YODKHandler) OnAttachRequest

func (h *YODKHandler) OnAttachRequest(arguments *dap.AttachRequestArguments) error

OnAttachRequest implements the Handler interface

func (*YODKHandler) OnBreakpointLocationsRequest

func (h *YODKHandler) OnBreakpointLocationsRequest(arguments *dap.BreakpointLocationsArguments) (*dap.BreakpointLocationsResponseBody, error)

OnBreakpointLocationsRequest implements the Handler interface

func (*YODKHandler) OnCancelRequest

func (h *YODKHandler) OnCancelRequest(arguments *dap.CancelArguments) error

OnCancelRequest implements the Handler interface

func (*YODKHandler) OnCompletionsRequest

func (h *YODKHandler) OnCompletionsRequest(arguments *dap.CompletionsArguments) (*dap.CompletionsResponseBody, error)

OnCompletionsRequest implements the Handler interface

func (*YODKHandler) OnConfigurationDoneRequest

func (h *YODKHandler) OnConfigurationDoneRequest(arguments *dap.ConfigurationDoneArguments) error

OnConfigurationDoneRequest implements the Handler interface

func (*YODKHandler) OnContinueRequest

func (h *YODKHandler) OnContinueRequest(arguments *dap.ContinueArguments) (*dap.ContinueResponseBody, error)

OnContinueRequest implements the Handler interface

func (*YODKHandler) OnDataBreakpointInfoRequest

func (h *YODKHandler) OnDataBreakpointInfoRequest(arguments *dap.DataBreakpointInfoArguments) (*dap.DataBreakpointInfoResponseBody, error)

OnDataBreakpointInfoRequest implements the Handler interface

func (*YODKHandler) OnDisassembleRequest

func (h *YODKHandler) OnDisassembleRequest(arguments *dap.DisassembleArguments) (*dap.DisassembleResponseBody, error)

OnDisassembleRequest implements the Handler interface

func (*YODKHandler) OnDisconnectRequest

func (h *YODKHandler) OnDisconnectRequest(arguments *dap.DisconnectArguments) error

OnDisconnectRequest implements the Handler interface

func (*YODKHandler) OnEvaluateRequest

func (h *YODKHandler) OnEvaluateRequest(arguments *dap.EvaluateArguments) (*dap.EvaluateResponseBody, error)

OnEvaluateRequest implements the Handler interface

func (*YODKHandler) OnExceptionInfoRequest

func (h *YODKHandler) OnExceptionInfoRequest(arguments *dap.ExceptionInfoArguments) (*dap.ExceptionInfoResponseBody, error)

OnExceptionInfoRequest implements the Handler interface

func (*YODKHandler) OnGotoRequest

func (h *YODKHandler) OnGotoRequest(arguments *dap.GotoArguments) error

OnGotoRequest implements the Handler interface

func (*YODKHandler) OnGotoTargetsRequest

func (h *YODKHandler) OnGotoTargetsRequest(arguments *dap.GotoTargetsArguments) (*dap.GotoTargetsResponseBody, error)

OnGotoTargetsRequest implements the Handler interface

func (*YODKHandler) OnInitializeRequest

func (h *YODKHandler) OnInitializeRequest(arguments *dap.InitializeRequestArguments) (*dap.Capabilities, error)

OnInitializeRequest implements the Handler interface

func (*YODKHandler) OnLaunchRequest

func (h *YODKHandler) OnLaunchRequest(arguments map[string]interface{}) error

OnLaunchRequest implements the Handler interface

func (*YODKHandler) OnLoadedSourcesRequest

func (h *YODKHandler) OnLoadedSourcesRequest(arguments *dap.LoadedSourcesArguments) (*dap.LoadedSourcesResponseBody, error)

OnLoadedSourcesRequest implements the Handler interface

func (*YODKHandler) OnNextRequest

func (h *YODKHandler) OnNextRequest(arguments *dap.NextArguments) error

OnNextRequest implements the Handler interface

func (*YODKHandler) OnPauseRequest

func (h *YODKHandler) OnPauseRequest(arguments *dap.PauseArguments) error

OnPauseRequest implements the Handler interface

func (*YODKHandler) OnReadMemoryRequest

func (h *YODKHandler) OnReadMemoryRequest(arguments *dap.ReadMemoryArguments) (*dap.ReadMemoryResponseBody, error)

OnReadMemoryRequest implements the Handler interface

func (*YODKHandler) OnRestartFrameRequest

func (h *YODKHandler) OnRestartFrameRequest(arguments *dap.RestartFrameArguments) error

OnRestartFrameRequest implements the Handler interface

func (*YODKHandler) OnRestartRequest

func (h *YODKHandler) OnRestartRequest(arguments *dap.RestartArguments) error

OnRestartRequest implements the Handler interface

func (*YODKHandler) OnReverseContinueRequest

func (h *YODKHandler) OnReverseContinueRequest(arguments *dap.ReverseContinueArguments) error

OnReverseContinueRequest implements the Handler interface

func (*YODKHandler) OnScopesRequest

func (h *YODKHandler) OnScopesRequest(arguments *dap.ScopesArguments) (*dap.ScopesResponseBody, error)

OnScopesRequest implements the Handler interface

func (*YODKHandler) OnSetBreakpointsRequest

func (h *YODKHandler) OnSetBreakpointsRequest(arguments *dap.SetBreakpointsArguments) (*dap.SetBreakpointsResponseBody, error)

OnSetBreakpointsRequest implements the Handler interface

func (*YODKHandler) OnSetDataBreakpointsRequest

func (h *YODKHandler) OnSetDataBreakpointsRequest(arguments *dap.SetDataBreakpointsArguments) (*dap.SetDataBreakpointsResponseBody, error)

OnSetDataBreakpointsRequest implements the Handler interface

func (*YODKHandler) OnSetExceptionBreakpointsRequest

func (h *YODKHandler) OnSetExceptionBreakpointsRequest(arguments *dap.SetExceptionBreakpointsArguments) error

OnSetExceptionBreakpointsRequest implements the Handler interface

func (*YODKHandler) OnSetExpressionRequest

func (h *YODKHandler) OnSetExpressionRequest(arguments *dap.SetExpressionArguments) (*dap.SetExpressionResponseBody, error)

OnSetExpressionRequest implements the Handler interface

func (*YODKHandler) OnSetFunctionBreakpointsRequest

func (h *YODKHandler) OnSetFunctionBreakpointsRequest(arguments *dap.SetFunctionBreakpointsArguments) (*dap.SetFunctionBreakpointsResponseBody, error)

OnSetFunctionBreakpointsRequest implements the Handler interface

func (*YODKHandler) OnSetVariableRequest

func (h *YODKHandler) OnSetVariableRequest(arguments *dap.SetVariableArguments) (*dap.SetVariableResponseBody, error)

OnSetVariableRequest implements the Handler interface

func (*YODKHandler) OnSourceRequest

func (h *YODKHandler) OnSourceRequest(arguments *dap.SourceArguments) (*dap.SourceResponseBody, error)

OnSourceRequest implements the Handler interface

func (*YODKHandler) OnStackTraceRequest

func (h *YODKHandler) OnStackTraceRequest(arguments *dap.StackTraceArguments) (*dap.StackTraceResponseBody, error)

OnStackTraceRequest implements the Handler interface

func (*YODKHandler) OnStepBackRequest

func (h *YODKHandler) OnStepBackRequest(arguments *dap.StepBackArguments) error

OnStepBackRequest implements the Handler interface

func (*YODKHandler) OnStepInRequest

func (h *YODKHandler) OnStepInRequest(arguments *dap.StepInArguments) error

OnStepInRequest implements the Handler interface

func (*YODKHandler) OnStepInTargetsRequest

func (h *YODKHandler) OnStepInTargetsRequest(arguments *dap.StepInTargetsArguments) (*dap.StepInTargetsResponseBody, error)

OnStepInTargetsRequest implements the Handler interface

func (*YODKHandler) OnStepOutRequest

func (h *YODKHandler) OnStepOutRequest(arguments *dap.StepOutArguments) error

OnStepOutRequest implements the Handler interface

func (*YODKHandler) OnTerminateRequest

func (h *YODKHandler) OnTerminateRequest(arguments *dap.TerminateArguments) error

OnTerminateRequest implements the Handler interface

func (*YODKHandler) OnTerminateThreadsRequest

func (h *YODKHandler) OnTerminateThreadsRequest(arguments *dap.TerminateThreadsArguments) error

OnTerminateThreadsRequest implements the Handler interface

func (*YODKHandler) OnThreadsRequest

func (h *YODKHandler) OnThreadsRequest() (*dap.ThreadsResponseBody, error)

OnThreadsRequest implements the Handler interface

func (*YODKHandler) OnVariablesRequest

func (h *YODKHandler) OnVariablesRequest(arguments *dap.VariablesArguments) (*dap.VariablesResponseBody, error)

OnVariablesRequest implements the Handler interface

func (*YODKHandler) SetSession

func (h *YODKHandler) SetSession(s *Session)

SetSession implements the Handler interface

Jump to

Keyboard shortcuts

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