Documentation ¶
Index ¶
- Constants
- func PtraceAttach(pid int) error
- func PtraceCont(tid, sig int) error
- func PtraceDetach(tid, sig int) error
- func PtracePeekUser(tid int, off uintptr) (uintptr, error)
- func PtracePokeUser(tid int, off, addr uintptr) error
- func PtraceSingleStep(tid int) error
- type OSProcessDetails
- type OSSpecificDetails
- type Process
- func (dbp *Process) AllGCache() *[]*proc.G
- func (dbp *Process) BinInfo() *proc.BinaryInfo
- func (dbp *Process) Breakpoints() map[uint64]*proc.Breakpoint
- func (dbp *Process) Checkpoint(string) (int, error)
- func (dbp *Process) Checkpoints() ([]proc.Checkpoint, error)
- func (dbp *Process) ClearBreakpoint(addr uint64) (*proc.Breakpoint, error)
- func (dbp *Process) ClearCheckpoint(int) error
- func (dbp *Process) ClearInternalBreakpoints() error
- func (dbp *Process) ContinueOnce() (proc.Thread, error)
- func (dbp *Process) CurrentThread() proc.Thread
- func (dbp *Process) Detach(kill bool) (err error)
- func (dbp *Process) Direction(proc.Direction) error
- func (dbp *Process) Exited() bool
- func (dbp *Process) FindBreakpoint(pc uint64) (*proc.Breakpoint, bool)
- func (dbp *Process) FindThread(threadID int) (proc.Thread, bool)
- func (dbp *Process) Halt() (err error)
- func (dbp *Process) Kill() (err error)
- func (dbp *Process) LoadInformation(path string) error
- func (dbp *Process) Pid() int
- func (dbp *Process) Recorded() (bool, string)
- func (dbp *Process) RequestManualStop() error
- func (dbp *Process) Restart(string) error
- func (dbp *Process) Running() bool
- func (dbp *Process) SelectedGoroutine() *proc.G
- func (dbp *Process) SetBreakpoint(addr uint64, kind proc.BreakpointKind, cond ast.Expr) (*proc.Breakpoint, error)
- func (dbp *Process) StepInstruction() (err error)
- func (dbp *Process) SwitchGoroutine(gid int) error
- func (dbp *Process) SwitchThread(tid int) error
- func (dbp *Process) ThreadList() []proc.Thread
- func (dbp *Process) When() (string, error)
- type PtraceFpRegs
- type PtraceXsave
- type Regs
- func (r *Regs) BP() uint64
- func (r *Regs) CX() uint64
- func (r *Regs) GAddr() (uint64, bool)
- func (r *Regs) Get(n int) (uint64, error)
- func (r *Regs) PC() uint64
- func (r *Regs) SP() uint64
- func (r *Regs) SetPC(t proc.Thread, pc uint64) (err error)
- func (r *Regs) Slice() []proc.Register
- func (r *Regs) TLS() uint64
- type Thread
- func (thread *Thread) Arch() proc.Arch
- func (thread *Thread) BinInfo() *proc.BinaryInfo
- func (t *Thread) Blocked() bool
- func (th *Thread) Breakpoint() (*proc.Breakpoint, bool, error)
- func (thread *Thread) ClearBreakpoint(bp *proc.Breakpoint) (*proc.Breakpoint, error)
- func (thread *Thread) Continue() error
- func (thread *Thread) Halt() (err error)
- func (thread *Thread) Location() (*proc.Location, error)
- func (t *Thread) PC() (uint64, error)
- func (t *Thread) ReadMemory(data []byte, addr uintptr) (n int, err error)
- func (t *Thread) Registers(floatingPoint bool) (proc.Registers, error)
- func (thread *Thread) SetCurrentBreakpoint() error
- func (thread *Thread) SetPC(pc uint64) error
- func (thread *Thread) StepInstruction() (err error)
- func (thread *Thread) Stopped() bool
- func (th *Thread) ThreadID() int
- func (t *Thread) WriteMemory(addr uintptr, data []byte) (written int, err error)
- type WaitStatus
Constants ¶
const ( StatusSleeping = 'S' StatusRunning = 'R' StatusTraceStop = 't' StatusZombie = 'Z' // Kernel 2.6 has TraceStop as T // TODO(derekparker) Since this means something different based on the // version of the kernel ('T' is job control stop on modern 3.x+ kernels) we // may want to differentiate at some point. StatusTraceStopT = 'T' )
Process statuses
Variables ¶
This section is empty.
Functions ¶
func PtraceAttach ¶
PtraceAttach executes the sys.PtraceAttach call.
func PtracePeekUser ¶
PtracePeekUser execute ptrace PTRACE_PEEK_USER.
func PtracePokeUser ¶
PtracePokeUser execute ptrace PTRACE_POKE_USER.
func PtraceSingleStep ¶
PtraceSingleStep executes ptrace PTRACE_SINGLE_STEP.
Types ¶
type OSProcessDetails ¶
type OSProcessDetails struct {
// contains filtered or unexported fields
}
OSProcessDetails contains Linux specific process details.
type OSSpecificDetails ¶
type OSSpecificDetails struct {
// contains filtered or unexported fields
}
OSSpecificDetails hold Linux specific process details.
type Process ¶
type Process struct { Process *os.Process // Pointer to process struct for the actual process we are debugging // contains filtered or unexported fields }
Process represents all of the information the debugger is holding onto regarding the process we are debugging.
func Launch ¶
Launch creates and begins debugging a new process. First entry in `cmd` is the program to run, and then rest are the arguments to be supplied to that process. `wd` is working directory of the program.
func New ¶
New returns an initialized Process struct. Before returning, it will also launch a goroutine in order to handle ptrace(2) functions. For more information, see the documentation on `handlePtraceFuncs`.
func (*Process) BinInfo ¶
func (dbp *Process) BinInfo() *proc.BinaryInfo
func (*Process) Breakpoints ¶
func (dbp *Process) Breakpoints() map[uint64]*proc.Breakpoint
func (*Process) Checkpoints ¶
func (dbp *Process) Checkpoints() ([]proc.Checkpoint, error)
func (*Process) ClearBreakpoint ¶
func (dbp *Process) ClearBreakpoint(addr uint64) (*proc.Breakpoint, error)
ClearBreakpoint clears the breakpoint at addr.
func (*Process) ClearCheckpoint ¶
func (*Process) ClearInternalBreakpoints ¶
func (*Process) CurrentThread ¶
func (*Process) FindBreakpoint ¶
func (dbp *Process) FindBreakpoint(pc uint64) (*proc.Breakpoint, bool)
FindBreakpoint finds the breakpoint for the given pc.
func (*Process) LoadInformation ¶
LoadInformation finds the executable and then uses it to parse the following information: * Dwarf .debug_frame section * Dwarf .debug_line section * Go symbol table.
func (*Process) RequestManualStop ¶
RequestManualStop sets the `halt` flag and sends SIGSTOP to all threads.
func (*Process) SelectedGoroutine ¶
func (*Process) SetBreakpoint ¶
func (dbp *Process) SetBreakpoint(addr uint64, kind proc.BreakpointKind, cond ast.Expr) (*proc.Breakpoint, error)
SetBreakpoint sets a 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.
func (*Process) StepInstruction ¶
StepInstruction will continue the current thread for exactly one instruction. This method affects only the thread asssociated with the selected goroutine. All other threads will remain stopped.
func (*Process) SwitchGoroutine ¶
SwitchGoroutine changes from current thread to the thread running the specified goroutine.
func (*Process) SwitchThread ¶
SwitchThread changes from current thread to the thread specified by `tid`.
func (*Process) ThreadList ¶
type PtraceFpRegs ¶
type PtraceFpRegs struct { Cwd uint16 Swd uint16 Ftw uint16 Fop uint16 Rip uint64 Rdp uint64 Mxcsr uint32 MxcrMask uint32 StSpace [32]uint32 XmmSpace [256]byte // contains filtered or unexported fields }
tracks user_fpregs_struct in /usr/include/x86_64-linux-gnu/sys/user.h
type PtraceXsave ¶
type PtraceXsave struct { PtraceFpRegs AvxState bool // contains AVX state YmmSpace [256]byte }
func PtraceGetRegset ¶
func PtraceGetRegset(tid int) (regset PtraceXsave, err error)
PtraceGetRegset returns floating point registers of the specified thread using PTRACE. See amd64_linux_fetch_inferior_registers in gdb/amd64-linux-nat.c.html and amd64_supply_xsave in gdb/amd64-tdep.c.html and Section 13.1 (and following) of Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 1: Basic Architecture
type Regs ¶
type Regs struct {
// contains filtered or unexported fields
}
Regs is a wrapper for sys.PtraceRegs.
type Thread ¶
type Thread struct { ID int // Thread ID or mach port Status *WaitStatus // Status returned from last wait call CurrentBreakpoint *proc.Breakpoint // Breakpoint thread is currently stopped at BreakpointConditionMet bool // Output of evaluating the breakpoint's condition BreakpointConditionError error // Error evaluating the breakpoint's condition // contains filtered or unexported fields }
Thread represents a single thread in the traced process ID represents the thread id or port, Process holds a reference to the Process struct that contains info on the process as a whole, and Status represents the last result of a `wait` call on this thread.
func (*Thread) BinInfo ¶
func (thread *Thread) BinInfo() *proc.BinaryInfo
func (*Thread) Breakpoint ¶
func (th *Thread) Breakpoint() (*proc.Breakpoint, bool, error)
func (*Thread) ClearBreakpoint ¶
func (thread *Thread) ClearBreakpoint(bp *proc.Breakpoint) (*proc.Breakpoint, error)
ClearBreakpoint clears the specified breakpoint.
func (*Thread) Continue ¶
Continue the execution of this thread.
If we are currently at a breakpoint, we'll clear it first and then resume execution. Thread will continue until it hits a breakpoint or is signaled.
func (*Thread) Halt ¶
Halt stops this thread from executing. Actual implementation is OS dependant. Look in OS thread file.
func (*Thread) Location ¶
Location returns the threads location, including the file:line of the corresponding source code, the function we're in and the current instruction address.
func (*Thread) ReadMemory ¶
func (*Thread) SetCurrentBreakpoint ¶
SetCurrentBreakpoint sets the current breakpoint that this thread is stopped at as CurrentBreakpoint on the thread struct.
func (*Thread) StepInstruction ¶
StepInstruction steps a single instruction.
Executes exactly one instruction and then returns. If the thread is at a breakpoint, we first clear it, execute the instruction, and then replace the breakpoint. Otherwise we simply execute the next instruction.
type WaitStatus ¶
type WaitStatus sys.WaitStatus