gdbserial

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: MIT Imports: 29 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDirChange = errors.New("direction change with internal breakpoints")

ErrDirChange is returned when trying to change execution direction while there are still internal breakpoints set.

View Source
var ErrTooManyAttempts = errors.New("too many transmit attempts")
View Source
var ErrUnsupportedOS = errors.New("lldb backend not supported on Windows")

ErrUnsupportedOS is returned when trying to use the lldb backend on Windows.

Functions

func LLDBAttach

func LLDBAttach(pid int, path string, debugInfoDirs []string) (*proc.Target, error)

LLDBAttach starts an instance of lldb-server and connects to it, asking it to attach to the specified pid. Path is path to the target's executable, path only needs to be specified for some stubs that do not provide an automated way of determining it (for example debugserver).

func LLDBLaunch

func LLDBLaunch(cmd []string, wd string, foreground bool, debugInfoDirs []string) (*proc.Target, error)

LLDBLaunch starts an instance of lldb-server and connects to it, asking it to launch the specified target program with the specified arguments (cmd) on the specified directory wd.

func Record

func Record(cmd []string, wd string, quiet bool) (tracedir string, err error)

Record uses rr to record the execution of the specified program and returns the trace directory's path.

func RecordAndReplay

func RecordAndReplay(cmd []string, wd string, quiet bool, debugInfoDirs []string) (*proc.Target, string, error)

RecordAndReplay acts like calling Record and then Replay.

func Replay

func Replay(tracedir string, quiet, deleteOnDetach bool, debugInfoDirs []string) (*proc.Target, error)

Replay starts an instance of rr in replay mode, with the specified trace directory, and connects to it.

Types

type ErrBackendUnavailable added in v1.1.0

type ErrBackendUnavailable struct{}

ErrBackendUnavailable is returned when the stub program can not be found.

func (*ErrBackendUnavailable) Error added in v1.1.0

func (err *ErrBackendUnavailable) Error() string

type ErrMalformedRRGdbCommand

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

func (*ErrMalformedRRGdbCommand) Error

func (err *ErrMalformedRRGdbCommand) Error() string

type ErrPerfEventParanoid added in v1.1.0

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

ErrPerfEventParanoid is the error returned by Reply and Record if /proc/sys/kernel/perf_event_paranoid is greater than 1.

func (ErrPerfEventParanoid) Error added in v1.1.0

func (err ErrPerfEventParanoid) Error() string

type GdbMalformedThreadIDError

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

GdbMalformedThreadIDError is returned when a the stub responds with a thread ID that does not conform with the Gdb Remote Serial Protocol specification.

func (*GdbMalformedThreadIDError) Error

func (err *GdbMalformedThreadIDError) Error() string

type GdbProtocolError

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

GdbProtocolError is an error response (Exx) of Gdb Remote Serial Protocol or an "unsupported command" response (empty packet).

func (*GdbProtocolError) Error

func (err *GdbProtocolError) Error() string

type Process

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

Process implements proc.Process using a connection to a debugger stub that understands Gdb Remote Serial Protocol.

func New

func New(process *os.Process) *Process

New creates a new Process instance. If process is not nil it is the stub's process and will be killed after Detach. Use Listen, Dial or Connect to complete connection.

func (*Process) BinInfo

func (p *Process) BinInfo() *proc.BinaryInfo

BinInfo returns information on the binary.

func (*Process) Breakpoints

func (p *Process) Breakpoints() *proc.BreakpointMap

Breakpoints returns the list of breakpoints currently set.

func (*Process) CheckAndClearManualStopRequest

func (p *Process) CheckAndClearManualStopRequest() bool

CheckAndClearManualStopRequest will check for a manual stop and then clear that state.

func (*Process) Checkpoint

func (p *Process) Checkpoint(where string) (int, error)

Checkpoint creates a checkpoint from which you can restart the program.

func (*Process) Checkpoints

func (p *Process) Checkpoints() ([]proc.Checkpoint, error)

Checkpoints returns a list of all checkpoints set.

func (*Process) ClearBreakpoint

func (p *Process) ClearBreakpoint(addr uint64) (*proc.Breakpoint, error)

ClearBreakpoint clears a breakpoint at the given address.

func (*Process) ClearCheckpoint

func (p *Process) ClearCheckpoint(id int) error

ClearCheckpoint clears the checkpoint for the given ID.

func (*Process) ClearInternalBreakpoints

func (p *Process) ClearInternalBreakpoints() error

ClearInternalBreakpoints clear all internal use breakpoints like those set by 'next'.

func (*Process) Connect

func (p *Process) Connect(conn net.Conn, path string, pid int, debugInfoDirs []string) error

Connect connects to a stub and performs a handshake.

Path and pid are, respectively, the path to the executable of the target program and the PID of the target process, both are optional, however some stubs do not provide ways to determine path and pid automatically and Connect will be unable to function without knowing them.

func (*Process) ContinueOnce

func (p *Process) ContinueOnce() (proc.Thread, error)

ContinueOnce will continue execution of the process until a breakpoint is hit or signal is received.

func (*Process) CurrentThread

func (p *Process) CurrentThread() proc.Thread

CurrentThread returns the current active selected thread.

func (*Process) Detach

func (p *Process) Detach(kill bool) error

Detach will detach from the target process, if 'kill' is true it will also kill the process.

func (*Process) Dial

func (p *Process) Dial(addr string, path string, pid int, debugInfoDirs []string) error

Dial attempts to connect to the stub.

func (*Process) Direction

func (p *Process) Direction(dir proc.Direction) error

Direction sets whether to run the program forwards or in reverse execution.

func (*Process) EntryPoint added in v1.2.0

func (p *Process) EntryPoint() (uint64, error)

EntryPoint will return the process entry point address, useful for debugging PIEs.

func (*Process) FindBreakpoint

func (p *Process) FindBreakpoint(pc uint64) (*proc.Breakpoint, bool)

FindBreakpoint returns the breakpoint at the given address.

func (*Process) FindThread

func (p *Process) FindThread(threadID int) (proc.Thread, bool)

FindThread returns the thread with the given ID.

func (*Process) Listen

func (p *Process) Listen(listener net.Listener, path string, pid int, debugInfoDirs []string) error

Listen waits for a connection from the stub.

func (*Process) Pid

func (p *Process) Pid() int

Pid returns the process ID.

func (*Process) Recorded

func (p *Process) Recorded() (bool, string)

Recorded returns whether or not we are debugging a recorded "traced" program.

func (*Process) RequestManualStop

func (p *Process) RequestManualStop() error

RequestManualStop will attempt to stop the process without a breakpoint or signal having been recieved.

func (*Process) Restart

func (p *Process) Restart(pos string) error

Restart will restart the process from the given position.

func (*Process) ResumeNotify

func (p *Process) ResumeNotify(ch chan<- struct{})

ResumeNotify specifies a channel that will be closed the next time ContinueOnce finishes resuming the target.

func (*Process) SelectedGoroutine

func (p *Process) SelectedGoroutine() *proc.G

SelectedGoroutine returns the current actuve selected goroutine.

func (*Process) SetBreakpoint

func (p *Process) SetBreakpoint(addr uint64, kind proc.BreakpointKind, cond ast.Expr) (*proc.Breakpoint, error)

SetBreakpoint creates a new breakpoint.

func (*Process) SetSelectedGoroutine added in v1.2.0

func (p *Process) SetSelectedGoroutine(g *proc.G)

SetSelectedGoroutine will set internally the goroutine that should be the default for any command executed, the goroutine being actively followed.

func (*Process) SwitchGoroutine

func (p *Process) SwitchGoroutine(g *proc.G) error

SwitchGoroutine will change the internal selected goroutine.

func (*Process) SwitchThread

func (p *Process) SwitchThread(tid int) error

SwitchThread will change the internal selected thread.

func (*Process) ThreadList

func (p *Process) ThreadList() []proc.Thread

ThreadList returns all threads in the process.

func (*Process) Valid added in v1.1.0

func (p *Process) Valid() (bool, error)

Valid returns true if we are not detached and the process has not exited.

func (*Process) When

func (p *Process) When() (string, error)

When executes the 'when' command for the Mozilla RR backend. This command will return rr's internal event number.

type Thread

type Thread struct {
	ID int

	CurrentBreakpoint proc.BreakpointState
	// contains filtered or unexported fields
}

Thread represents an operating system thread.

func (*Thread) Arch

func (t *Thread) Arch() proc.Arch

Arch will return the CPU architecture for the target.

func (*Thread) BinInfo

func (t *Thread) BinInfo() *proc.BinaryInfo

BinInfo will return information on the binary being debugged.

func (*Thread) Blocked

func (t *Thread) Blocked() bool

Blocked returns true if the thread is blocked in runtime or kernel code.

func (*Thread) Breakpoint

func (t *Thread) Breakpoint() *proc.BreakpointState

Breakpoint returns the current active breakpoint for this thread.

func (*Thread) Common added in v1.1.0

func (t *Thread) Common() *proc.CommonThread

Common returns common information across Process implementations.

func (*Thread) Location

func (t *Thread) Location() (*proc.Location, error)

Location returns the current location of this thread.

func (*Thread) ReadMemory

func (t *Thread) ReadMemory(data []byte, addr uintptr) (n int, err error)

ReadMemory will read into 'data' memory at the address provided.

func (*Thread) Registers

func (t *Thread) Registers(floatingPoint bool) (proc.Registers, error)

Registers returns the CPU registers for this thread.

func (*Thread) RestoreRegisters added in v1.1.0

func (t *Thread) RestoreRegisters(savedRegs proc.Registers) error

RestoreRegisters will set the CPU registers the value of those provided.

func (*Thread) SetCurrentBreakpoint

func (t *Thread) SetCurrentBreakpoint(adjustPC bool) error

SetCurrentBreakpoint will find and set the threads current breakpoint.

func (*Thread) SetDX added in v1.1.0

func (t *Thread) SetDX(dx uint64) error

SetDX will set the value of the DX register to the given value.

func (*Thread) SetPC added in v1.1.0

func (t *Thread) SetPC(pc uint64) error

SetPC will set the value of the PC register to the given value.

func (*Thread) SetSP added in v1.1.0

func (t *Thread) SetSP(sp uint64) error

SetSP will set the value of the SP register to the given value.

func (*Thread) StepInstruction

func (t *Thread) StepInstruction() error

StepInstruction will step exactly 1 CPU instruction.

func (*Thread) ThreadID

func (t *Thread) ThreadID() int

ThreadID returns this threads ID.

func (*Thread) WriteMemory

func (t *Thread) WriteMemory(addr uintptr, data []byte) (written int, err error)

WriteMemory will write into the memory at 'addr' the data provided.

Jump to

Keyboard shortcuts

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