proctl

package
v0.0.0-...-a838feb Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package proctl provides functions for attaching to and manipulating a process during the debug session.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BreakPoint

type BreakPoint struct {
	FunctionName string
	File         string
	Line         int
	Addr         uint64
	OriginalData []byte
}

Represents a single breakpoint. Stores information on the break point including the byte of data that originally was stored at that address.

type BreakPointExistsError

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

func (BreakPointExistsError) Error

func (bpe BreakPointExistsError) Error() string

type DebuggedProcess

type DebuggedProcess struct {
	Pid             int
	Regs            *syscall.PtraceRegs
	Process         *os.Process
	ProcessState    *syscall.WaitStatus
	Executable      *elf.File
	Symbols         []elf.Symbol
	GoSymTable      *gosym.Table
	FrameEntries    *frame.FrameDescriptionEntries
	DebugLine       *line.DebugLineInfo
	BreakPoints     map[string]*BreakPoint
	TempBreakPoints map[uint64]*BreakPoint
}

Struct representing a debugged process. Holds onto pid, register values, process struct and process state.

func NewDebugProcess

func NewDebugProcess(pid int) (*DebuggedProcess, error)

Returns a new DebuggedProcess struct with sensible defaults.

func (*DebuggedProcess) Break

func (dbp *DebuggedProcess) Break(addr uintptr) (*BreakPoint, error)

Sets a breakpoint in the running process.

func (*DebuggedProcess) CheckAndClearBP

func (dbp *DebuggedProcess) CheckAndClearBP() (func(), error)

func (*DebuggedProcess) Clear

func (dbp *DebuggedProcess) Clear(pc uint64) (*BreakPoint, error)

Clears a breakpoint.

func (*DebuggedProcess) Continue

func (dbp *DebuggedProcess) Continue() error

Continue process until next breakpoint.

func (*DebuggedProcess) CurrentPC

func (dbp *DebuggedProcess) CurrentPC() (uint64, error)

returns current rip, whose content is virtual address (linear address)

func (*DebuggedProcess) EvalSymbol

func (dbp *DebuggedProcess) EvalSymbol(name string) (*Variable, error)

Returns the value of the named symbol.

func (*DebuggedProcess) LoadInformation

func (dbp *DebuggedProcess) LoadInformation() error

Finds the executable from /proc/<pid>/exe and then uses that to parse the following information: * Dwarf .debug_frame section * Dwarf .debug_line section * Go symbol table.

func (*DebuggedProcess) Next

func (dbp *DebuggedProcess) Next() error

Step over function calls.

func (*DebuggedProcess) PCtoBP

func (dbp *DebuggedProcess) PCtoBP(pc uint64) (*BreakPoint, bool)

Converts a program counter value into a breakpoint, if one was set for the function containing pc.

func (*DebuggedProcess) Registers

func (dbp *DebuggedProcess) Registers() (*syscall.PtraceRegs, error)

Obtains register values from the debugged process.

func (*DebuggedProcess) ReturnAddressFromOffset

func (dbp *DebuggedProcess) ReturnAddressFromOffset(offset int64) uint64

Takes an offset from RSP and returns the address of the instruction the currect function is going to return to.

func (*DebuggedProcess) Step

func (dbp *DebuggedProcess) Step() (err error)

Steps through process.

type Variable

type Variable struct {
	Name  string
	Value string
	Type  string
}

Variable has type, name and value

Jump to

Keyboard shortcuts

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