dap

package
v1.4.1-0...-9011182 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package dap implements VSCode's Debug Adaptor Protocol (DAP). This allows delve to communicate with frontends using DAP without a separate adaptor. The frontend will run the debugger (which now doubles as an adaptor) in server mode listening on a port and communicating over TCP. This is work in progress, so for now Delve in dap mode only supports synchronous request-response communication, blocking while processing each request. For DAP details see https://microsoft.github.io/debug-adapter-protocol.

Index

Constants

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

	// The values below come from the vscode-go debug adaptor.
	// Although the spec says they should be unique, the adaptor
	// reuses 3000 for launch, attach and program exit failures.
	// TODO(polina): confirm if the extension expects specific ids
	// for specific cases, and we must match the existing adaptor
	// or if these codes can evolve.
	FailedToContinue       = 3000
	UnableToDisplayThreads = 2003
)

Unique identifiers for messages returned for errors from requests.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server implements a DAP server that can accept a single client for a single debug session. It does not support restarting. The server operates via two goroutines: (1) Main goroutine where the server is created via NewServer(), started via Run() and stopped via Stop(). (2) Run goroutine started from Run() that accepts a client connection, reads, decodes and processes each request, issuing commands to the underlying debugger and sending back events and responses. TODO(polina): make it asynchronous (i.e. launch goroutine per request)

func NewServer

func NewServer(config *service.Config) *Server

NewServer creates a new DAP Server. It takes an opened Listener via config and assumes its ownership. config.disconnectChan has to be set; it will be closed by the server when the client disconnects or requests shutdown. Once disconnectChan is closed, Server.Stop() must be called.

func (*Server) Run

func (s *Server) Run()

Run launches a new goroutine where it accepts a client connection and starts processing requests from it. Use Stop() to close connection. The server does not support multiple clients, serially or in parallel. The server should be restarted for every new debug session. The debugger won't be started until launch/attach request is received. TODO(polina): allow new client connections for new debug sessions, so the editor needs to launch delve only once?

func (*Server) Stop

func (s *Server) Stop()

Stop stops the DAP debugger service, closes the listener and the client connection. It shuts down the underlying debugger and kills the target process if it was launched by it. This method mustn't be called more than once.

Directories

Path Synopsis
Package daptest provides a sample client with utilities for DAP mode testing.
Package daptest provides a sample client with utilities for DAP mode testing.

Jump to

Keyboard shortcuts

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