dap

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnsupportedCommand int = 9999
	InternalError      int = 8888
	NotYetImplemented  int = 7777

	FailedToLaunch             = 3000
	FailedToAttach             = 3001
	FailedToInitialize         = 3002
	UnableToSetBreakpoints     = 2002
	UnableToDisplayThreads     = 2003
	UnableToProduceStackTrace  = 2004
	UnableToListLocals         = 2005
	UnableToListArgs           = 2006
	UnableToListGlobals        = 2007
	UnableToLookupVariable     = 2008
	UnableToEvaluateExpression = 2009
	UnableToHalt               = 2010
	UnableToGetExceptionInfo   = 2011
	UnableToSetVariable        = 2012
	UnableToDisassemble        = 2013
	UnableToListRegisters      = 2014
	UnableToRunDlvCommand      = 2015

	NoDebugIsRunning  = 3000
	DebuggeeIsRunning = 4000
	DisconnectError   = 5000
)

Unique identifiers for messages returned for errors from requests. These values are not mandated by DAP (other than the uniqueness requirement), so each implementation is free to choose their own.

Variables

This section is empty.

Functions

func DAPLogger

func DAPLogger() *logrus.Entry

DAPLogger returns a logger for dap package.

func StartServer

func StartServer(port int)

Types

type AttachConfig

type AttachConfig struct {
	// Acceptable values are:
	//   "local": attaches to the local process with the given ProcessID.
	//   "remote": expects the debugger to already be running to "attach" to an in-progress debug session.
	//
	// Default is "local".
	Mode string `json:"mode"`

	// The numeric ID of the process to be debugged. Required and must not be 0.
	ProcessID int `json:"processId,omitempty"`

	LaunchAttachCommonConfig
}

AttachConfig is the collection of attach request attributes recognized by DAP implementation.

type Client added in v1.2.0

type Client struct {
	MsgChan chan string
	// contains filtered or unexported fields
}

func NewClient added in v1.2.0

func NewClient(address string) (*Client, error)

func (*Client) Close added in v1.2.0

func (c *Client) Close() error

func (*Client) Evaluate added in v1.2.0

func (c *Client) Evaluate(req *dap.EvaluateRequest) (*dap.EvaluateResponse, error)

func (*Client) Initialize added in v1.2.0

func (c *Client) Initialize(req *dap.InitializeRequest) (*dap.InitializeResponse, error)

func (*Client) Launch added in v1.2.0

func (c *Client) Launch(req *dap.LaunchRequest) (*dap.LaunchResponse, error)

func (*Client) OnContinue added in v1.2.0

func (c *Client) OnContinue(req *dap.ContinueRequest) (*dap.ContinueResponse, error)

func (*Client) OnDisconnectRequest added in v1.2.0

func (c *Client) OnDisconnectRequest(req *dap.DisconnectRequest) (*dap.DisconnectResponse, error)

func (*Client) OnNext added in v1.2.0

func (c *Client) OnNext(req *dap.NextRequest) (*dap.NextResponse, error)

func (*Client) OnVariables added in v1.2.0

func (c *Client) OnVariables(req *dap.VariablesRequest) (*dap.VariablesResponse, error)

func (*Client) Read added in v1.2.0

func (c *Client) Read()

func (*Client) SetBreakpoints added in v1.2.0

func (c *Client) SetBreakpoints(req *dap.SetBreakpointsRequest) (*dap.SetBreakpointsResponse, error)

type Config

type Config struct {
	StopTriggered chan struct{}

	DisconnectChan chan<- struct{}
	Listener       net.Listener
	// contains filtered or unexported fields
}

type LaunchAttachCommonConfig

type LaunchAttachCommonConfig struct {
	// Automatically stop program after launch or attach.
	StopOnEntry bool `json:"stopOnEntry,omitempty"`

	// Backend used for debugging. See `dlv backend` for allowed values.
	// Default is "default".
	Backend string `json:"backend,omitempty"`

	// Maximum depth of stack trace to return.
	// Default is 50.
	StackTraceDepth int `json:"stackTraceDepth,omitempty"`

	// Boolean value to indicate whether global package variables
	// should be shown in the variables pane or not.
	ShowGlobalVariables bool `json:"showGlobalVariables,omitempty"`

	// Boolean value to indicate whether registers should be shown
	// in the variables pane or not.
	ShowRegisters bool `json:"showRegisters,omitempty"`

	// Boolean value to indicate whether system goroutines
	// should be hidden from the call stack view.
	HideSystemGoroutines bool `json:"hideSystemGoroutines,omitempty"`

	// String value to indicate which system goroutines should be
	// shown in the call stack view. See filtering documentation:
	// https://github.com/go-delve/delve/blob/master/Documentation/cli/README.md#goroutines
	GoroutineFilters string `json:"goroutineFilters,omitempty"`

	// An array of mappings from a local path (client) to the remote path (debugger).
	// This setting is useful when working in a file system with symbolic links,
	// running remote debugging, or debugging an executable compiled externally.
	// The debug adapter will replace the local path with the remote path in all of the calls.
	SubstitutePath []SubstitutePath `json:"substitutePath,omitempty"`
}

LaunchAttachCommonConfig is the attributes common in both launch/attach requests.

type LaunchConfig

type LaunchConfig struct {
	// Acceptable values are:
	//   "debug": compiles your program with optimizations disabled, starts and attaches to it.
	//   "test": compiles your unit test program with optimizations disabled, starts and attaches to it.
	//   "exec": executes a precompiled binary and begins a debug session.
	//   "replay": replays an rr trace.
	//   "core": examines a core dump.
	//
	// Default is "debug".
	Mode string `json:"mode,omitempty"`

	// Path to the program folder (or any go file within that folder)
	// when in `debug` or `test` mode, and to the pre-built binary file
	// to debug in `exec` mode.
	// If it is not an absolute path, it will be interpreted as a path
	// relative to Delve's working directory.
	// Required when mode is `debug`, `test`, `exec`, and `core`.
	Program string `json:"program,omitempty"`

	// Command line arguments passed to the debugged program.
	// Relative paths used in Args will be interpreted as paths relative
	// to `cwd`.
	Args []string `json:"args,omitempty"`

	// Working directory of the program being debugged.
	// If a relative path is provided, it will be interpreted as
	// a relative path to Delve's working directory. This is
	// similar to `dlv --wd` flag.
	//
	// If not specified or empty, Delve's working directory is
	// used by default. But for `test` mode, Delve tries to find
	// the test's package source directory and run tests from there.
	// This matches the behavior of `dlv test` and `go test`.
	Cwd string `json:"cwd,omitempty"`

	// Build flags, to be passed to the Go compiler.
	// Relative paths used in BuildFlags will be interpreted as paths
	// relative to Delve's current working directory.
	//
	// It is like `dlv --build-flags`. For example,
	//    "buildFlags": "-tags=integration -mod=vendor -cover -v"
	BuildFlags string `json:"buildFlags,omitempty"`

	// Output path for the binary of the debugee.
	// Relative path is interpreted as the path relative to
	// the Delve's current working directory.
	// This is deleted after the debug session ends.
	Output string `json:"output,omitempty"`

	// NoDebug is used to run the program without debugging.
	NoDebug bool `json:"noDebug,omitempty"`

	// TraceDirPath is the trace directory path for replay mode.
	// Relative path is interpreted as a path relative to Delve's
	// current working directory.
	// This is required for "replay" mode but unused in other modes.
	TraceDirPath string `json:"traceDirPath,omitempty"`

	// CoreFilePath is the core file path for core mode.
	//
	// This is required for "core" mode but unused in other modes.
	CoreFilePath string `json:"coreFilePath,omitempty"`

	// DlvCwd is the new working directory for Delve server.
	// If specified, the server will change its working
	// directory to the specified directory using os.Chdir.
	// Any other launch attributes with relative paths interpreted
	// using Delve's working directory will use this new directory.
	// When Delve needs to build the program (in debug/test modes),
	// it will run the go command from this directory as well.
	//
	// If a relative path is provided as DlvCwd, it will be
	// interpreted as a path relative to Delve's current working
	// directory.
	DlvCwd string `json:"dlvCwd,omitempty"`

	// Env specifies optional environment variables for Delve server
	// in addition to the environment variables Delve initially
	// started with.
	// Variables with 'nil' values can be used to unset the named
	// environment variables.
	// Values are interpreted verbatim. Variable substitution or
	// reference to other environment variables is not supported.
	Env map[string]*string `json:"env,omitempty"`

	Script   string `json:"script,omitempty"`
	FilePath string `json:"filePath,omitempty"`

	LaunchAttachCommonConfig
}

LaunchConfig is the collection of launch request attributes recognized by DAP implementation.

type ReadBody added in v1.2.0

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

type Server

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

func NewServer

func NewServer(config *Config) *Server

func StartInstance added in v1.2.0

func StartInstance(port int) *Server

func (*Server) Run

func (s *Server) Run()

func (*Server) Stop

func (s *Server) Stop()

type Session

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

func NewSession

func NewSession(conn io.ReadWriteCloser, config *Config) *Session

func (*Session) Close

func (s *Session) Close()

func (*Session) ServeDAPCodec

func (s *Session) ServeDAPCodec()

ServeDAPCodec reads and decodes requests from the client until it encounters an error or EOF, when it sends a disconnect signal and returns.

type SubstitutePath

type SubstitutePath struct {
	// The local path to be replaced when passing paths to the debugger.
	From string `json:"from,omitempty"`
	// The remote path to be replaced when passing paths back to the client.
	To string `json:"to,omitempty"`
}

SubstitutePath defines a mapping from a local path to the remote path. Both 'from' and 'to' must be specified and non-null. Empty values can be used to add or remove absolute path prefixes when mapping. For example, mapping with empy 'to' can be used to work with binaries with trimmed paths.

func (*SubstitutePath) UnmarshalJSON

func (m *SubstitutePath) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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