debugger

package module
v0.0.0-...-35ae82e Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2020 License: MIT Imports: 8 Imported by: 0

README

Debugger

Test Lint Go Report Card

Debugger helps build debug servers that standard debuggers can connect to.

An implementation of a new language or interpreter or even a DSL can benefit from debugger support. This pacakge provides an interface that new languages can implement to get debugging support via standard debugger clients (such as Chrome Dev Tools or VS Code).

This is a work in progress:

Chrome Dev Tools

The fake server illustrates an example debug server:

$> go run ./cmd/fake

Once that is started, open chrome://inspect/#devices, click on "Open dedicated DevTools for Node" and then type in "localhost:8222".

Now Chrome should be connected to the fake debug server.

Documentation

Overview

Package debugger implements a general purpose debugger server.

The current implementation supports the ability to build a Chrome DevTools compatible server.

There are plans to support VSCode at some point.

Usage:

See cmd/fake/fake.go for a fake debugger server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(d Driver) http.Handler

Handler implements a HTTP handler that implements the standard debugger protocol.

Types

type Dispatcher

type Dispatcher interface {
	Dispatch(d Driver, msg *cdp.Message)
}

Dispatcher dispatches a message to the driver. The response is also just filled in directly.

type Driver

type Driver interface {
	Name() string
	List() ([]*Target, error)
	Network() Network
	Dispatcher
}

Driver is the actual implementation that drivers need to implement.

type FakeNetwork

type FakeNetwork struct{}

func (FakeNetwork) ClearBrowserCache

func (FakeNetwork) ClearBrowserCache() error

func (FakeNetwork) ClearBrowserCookies

func (FakeNetwork) ClearBrowserCookies() error

func (FakeNetwork) DeleteCookies

func (FakeNetwork) DeleteCookies(req *nw.DeleteCookiesParams) error

func (FakeNetwork) Disable

func (FakeNetwork) Disable() error

func (FakeNetwork) EmulateNetworkConditions

func (FakeNetwork) EmulateNetworkConditions(req *nw.EmulateNetworkConditionsParams) error

func (FakeNetwork) Enable

func (FakeNetwork) Enable() (*nw.EnableParams, error)

func (FakeNetwork) GetAllCookies

func (FakeNetwork) GetAllCookies() (*nw.GetAllCookiesReturns, error)

func (FakeNetwork) GetCertificate

func (FakeNetwork) GetCookies

func (FakeNetwork) GetRequestPostData

func (FakeNetwork) GetResponseBody

func (FakeNetwork) ReplayXHR

func (FakeNetwork) ReplayXHR(req *nw.ReplayXHRParams) error

func (FakeNetwork) SearchInResponseBody

func (FakeNetwork) SetBlockedURLs

func (FakeNetwork) SetBlockedURLs(req *nw.SetBlockedURLSParams) error

func (FakeNetwork) SetBypassServiceWorker

func (FakeNetwork) SetBypassServiceWorker(req *nw.SetBypassServiceWorkerParams) error

func (FakeNetwork) SetCacheDisabled

func (FakeNetwork) SetCacheDisabled(req *nw.SetCacheDisabledParams) error

func (FakeNetwork) SetCookie

func (FakeNetwork) SetCookie(req *nw.SetCookieParams) (*nw.SetCookieReturns, error)

func (FakeNetwork) SetCookies

func (FakeNetwork) SetCookies(req *nw.SetCookiesParams) error

func (FakeNetwork) SetDataSizeLimitsForTest

func (FakeNetwork) SetDataSizeLimitsForTest(req *nw.SetDataSizeLimitsForTestParams) error

func (FakeNetwork) SetExtraHTTPHeaders

func (FakeNetwork) SetExtraHTTPHeaders(req *nw.SetExtraHTTPHeadersParams) error

type Network

type Network interface {
	ClearBrowserCache() error
	ClearBrowserCookies() error
	DeleteCookies(req *nw.DeleteCookiesParams) error
	Disable() error
	EmulateNetworkConditions(req *nw.EmulateNetworkConditionsParams) error
	Enable() (*nw.EnableParams, error)
	GetAllCookies() (*nw.GetAllCookiesReturns, error)
	GetCertificate(req *nw.GetCertificateParams) (*nw.GetCertificateReturns, error)
	GetCookies(req *nw.GetCookiesParams) (*nw.GetCookiesReturns, error)
	GetResponseBody(req *nw.GetResponseBodyParams) (*nw.GetResponseBodyReturns, error)
	GetRequestPostData(req *nw.GetRequestPostDataParams) (*nw.GetRequestPostDataReturns, error)

	ReplayXHR(req *nw.ReplayXHRParams) error
	SearchInResponseBody(req *nw.SearchInResponseBodyParams) (*nw.SearchInResponseBodyReturns, error)
	SetBlockedURLs(req *nw.SetBlockedURLSParams) error
	SetBypassServiceWorker(req *nw.SetBypassServiceWorkerParams) error
	SetCacheDisabled(req *nw.SetCacheDisabledParams) error
	SetCookie(req *nw.SetCookieParams) (*nw.SetCookieReturns, error)
	SetCookies(req *nw.SetCookiesParams) error
	SetDataSizeLimitsForTest(req *nw.SetDataSizeLimitsForTestParams) error
	SetExtraHTTPHeaders(req *nw.SetExtraHTTPHeadersParams) error
}

See https://github.com/chromedp/cdproto/blob/master/network/network.go

type Target

type Target struct {
	// these fields are filled in by calling Init(prefix, ID)
	ID                string `json:"id"`
	FrontEndURL       string `json:"devtoolsFrontendUrl"`
	FrontEndURLCompat string `json:"devtoolsFrontendUrlCompat"`
	DebuggerURL       string `json:"webSocketDebuggerUrl"`

	// Optional fields
	Description string `json:"description"`
	FaviconURL  string `json:"faviconUrl"`
	Title       string `json:"title"`
	Type        string `json:"type"`
	URL         string `json:"url"`
}

Target is a debugger target. Use Init() to fill in the required fields.

func (*Target) Init

func (t *Target) Init(httpPrefix, id string)

Init must be called with a prefix like "http://localhost:9222/"

Directories

Path Synopsis
cmd
fake command
Package main illustrates how to run a debugger server that chrome dev tools can connect to.
Package main illustrates how to run a debugger server that chrome dev tools can connect to.
proxy command
nolint: gochecknoglobals chromedp-proxy provides a cli utility that will proxy requests from a Chrome DevTools Protocol client to a browser instance.
nolint: gochecknoglobals chromedp-proxy provides a cli utility that will proxy requests from a Chrome DevTools Protocol client to a browser instance.

Jump to

Keyboard shortcuts

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