proctl

package
v0.0.0-...-c0ae1ee Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2015 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const (
	STATUS_SLEEPING   = 'S'
	STATUS_RUNNING    = 'R'
	STATUS_TRACE_STOP = 't'
)

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
	ID           int
	// contains filtered or unexported fields
}

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
	Process       *os.Process
	Dwarf         *dwarf.Data
	GoSymTable    *gosym.Table
	FrameEntries  *frame.FrameDescriptionEntries
	BreakPoints   map[uint64]*BreakPoint
	Threads       map[int]*ThreadContext
	CurrentThread *ThreadContext
	// contains filtered or unexported fields
}

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

func Attach

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

func Launch

func Launch(cmd []string) (*DebuggedProcess, error)

func (*DebuggedProcess) AttachThread

func (dbp *DebuggedProcess) AttachThread(tid int) (*ThreadContext, error)

func (*DebuggedProcess) Break

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

Sets a breakpoint in the current thread.

func (*DebuggedProcess) BreakByLocation

func (dbp *DebuggedProcess) BreakByLocation(loc string) (*BreakPoint, error)

Sets a breakpoint by location string (function, file+line, address)

func (*DebuggedProcess) Clear

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

Clears a breakpoint in the current thread.

func (*DebuggedProcess) ClearByLocation

func (dbp *DebuggedProcess) ClearByLocation(loc string) (*BreakPoint, error)

Clears a breakpoint by location (function, file+line, address, breakpoint id)

func (*DebuggedProcess) Continue

func (dbp *DebuggedProcess) Continue() error

Resume process.

func (*DebuggedProcess) CurrentPC

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

func (*DebuggedProcess) DwarfReader

func (dbp *DebuggedProcess) DwarfReader() *reader.Reader

Returns a reader for the dwarf data

func (*DebuggedProcess) EvalSymbol

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

Returns the value of the named symbol.

func (*DebuggedProcess) FindLocation

func (dbp *DebuggedProcess) FindLocation(str string) (uint64, error)

Find a location by string (file+line, function, breakpoint id, addr)

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) PrintGoroutinesInfo

func (dbp *DebuggedProcess) PrintGoroutinesInfo() error

func (*DebuggedProcess) PrintThreadInfo

func (dbp *DebuggedProcess) PrintThreadInfo() error

Loop through all threads, printing their information to the console.

func (*DebuggedProcess) Registers

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

Obtains register values from what Delve considers to be the current thread of the traced process.

func (*DebuggedProcess) RequestManualStop

func (dbp *DebuggedProcess) RequestManualStop()

func (*DebuggedProcess) Running

func (dbp *DebuggedProcess) Running() bool

func (*DebuggedProcess) Status

func (dbp *DebuggedProcess) Status() *syscall.WaitStatus

Returns the status of the current main thread context.

func (*DebuggedProcess) Step

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

Steps through process.

type InvalidAddressError

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

func (InvalidAddressError) Error

func (iae InvalidAddressError) Error() string

type M

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

type ManualStopError

type ManualStopError struct{}

func (ManualStopError) Error

func (mse ManualStopError) Error() string

type ProcessExitedError

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

func (ProcessExitedError) Error

func (pe ProcessExitedError) Error() string

type ProcessStatus

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

ProcessStatus is the result of parsing the data from the /proc/<pid>/stats psuedo file.

type Registers

type Registers interface {
	PC() uint64
	SP() uint64
	SetPC(int, uint64) error
}

type Regs

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

func (*Regs) PC

func (r *Regs) PC() uint64

func (*Regs) SP

func (r *Regs) SP() uint64

func (*Regs) SetPC

func (r *Regs) SetPC(tid int, pc uint64) error

type ThreadContext

type ThreadContext struct {
	Id      int
	Process *DebuggedProcess
	Status  *syscall.WaitStatus
}

ThreadContext represents a single thread of execution in the traced program.

func (*ThreadContext) AllM

func (thread *ThreadContext) AllM() ([]*M, error)

Parses and returns select info on the internal M data structures used by the Go scheduler.

func (*ThreadContext) Break

func (thread *ThreadContext) Break(addr uint64) (*BreakPoint, error)

Sets a software breakpoint at addr, and stores it in the process wide break point table. Setting a break point must be thread specific due to ptrace actions needing the thread to be in a signal-delivery-stop in order to initiate any ptrace command. Otherwise, it really doesn't matter as we're only dealing with threads.

func (*ThreadContext) Clear

func (thread *ThreadContext) Clear(addr uint64) (*BreakPoint, error)

Clears a software breakpoint, and removes it from the process level break point table.

func (*ThreadContext) Continue

func (thread *ThreadContext) Continue() error

func (*ThreadContext) CurrentPC

func (thread *ThreadContext) CurrentPC() (uint64, error)

Returns the current PC for this thread id.

func (*ThreadContext) EvalSymbol

func (thread *ThreadContext) EvalSymbol(name string) (*Variable, error)

Returns the value of the named symbol.

func (*ThreadContext) FunctionArguments

func (thread *ThreadContext) FunctionArguments() ([]*Variable, error)

FunctionArguments returns the name, value, and type of all current function arguments

func (*ThreadContext) LocalVariables

func (thread *ThreadContext) LocalVariables() ([]*Variable, error)

LocalVariables returns all local variables from the current function scope

func (*ThreadContext) Next

func (thread *ThreadContext) Next() (err error)

Step to next source line. Next will step over functions, and will follow through to the return address of a function. Next is implemented on the thread context, however during the course of this function running, it's very likely that the goroutine our M is executing will switch to another M, therefore this function cannot assume all execution will happen on this thread in the traced process.

func (*ThreadContext) PrintInfo

func (thread *ThreadContext) PrintInfo() error

PrintInfo prints out the thread status including: PC, tid, file, line, and function.

func (*ThreadContext) Registers

func (thread *ThreadContext) Registers() (Registers, error)

Obtains register values from the debugged process.

func (*ThreadContext) ReturnAddressFromOffset

func (thread *ThreadContext) 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 (*ThreadContext) Step

func (thread *ThreadContext) Step() (err error)

Single steps this thread a single instruction, ensuring that we correctly handle the likely case that we are at a breakpoint.

type Variable

type Variable struct {
	Name  string
	Value string
	Type  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳