debugger

package
v0.0.0-...-b5d9cbe Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package debugger provides the ability to start binaries under a debugger.

Index

Constants

This section is empty.

Variables

View Source
var DlvDUTEnv = []string{"XDG_CONFIG_HOME=/mnt/stateful_partition/xdg_config"}

DlvDUTEnv is the environment variables required to run dlv on DUTs. Setting XDG_CONFIG_HOME to the stateful partition is required to stop it writing to ~/.config/dlv, which is in a read-only partition.

View Source
var DlvHostEnv = []string{}

DlvHostEnv is the environment variables required to run dlv on a host machine.

Functions

func FindPreemptiveDebuggerErrors

func FindPreemptiveDebuggerErrors(port int, remoteCommand bool) error

FindPreemptiveDebuggerErrors pre-emptively checks potential errors, to ensure better error messages for users.

func ForwardPort

func ForwardPort(ctx context.Context, sshConn *ssh.Conn, port int) error

ForwardPort forwards a port from port to the ssh'd machine on the same port for the debugger. The existing SSHConn.ForwardLocalToRemote is unsuitable for our use case because it assumes that both channels will stop writing, and also because it attempts to accept multiple connections.

func IsRunningOnDUT

func IsRunningOnDUT() bool

IsRunningOnDUT returns whether the current process is running on the DUT.

func PrintWaitingMessage

func PrintWaitingMessage(ctx context.Context, debugPort int)

PrintWaitingMessage outputs a "Waiting for debugger" message, if required.

func RewriteDebugCommand

func RewriteDebugCommand(debugPort int, env []string, cmd string, args ...string) (newCmd string, newArgs []string)

RewriteDebugCommand takes a go binary and a set of arguments it takes, and if a debug port was provided, rewrites it as a command that instead runs a debugger and waits on that port before running the binary.

Types

type DebugTarget

type DebugTarget string

A DebugTarget represents a go binary that can be debugged.

const (
	LocalBundle      DebugTarget = "local"
	RemoteBundle     DebugTarget = "remote"
	LocalTestRunner  DebugTarget = "local-test-runner"
	RemoteTestRunner DebugTarget = "remote-test-runner"
)

Valid DebugTargets are listed below.

Jump to

Keyboard shortcuts

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