native

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
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

func PtraceAttach(pid int) error

PtraceAttach executes the sys.PtraceAttach call.

func PtraceCont

func PtraceCont(tid, sig int) error

PtraceCont executes ptrace PTRACE_CONT

func PtraceDetach

func PtraceDetach(tid, sig int) error

PtraceDetach calls ptrace(PTRACE_DETACH).

func PtraceGetRegset

func PtraceGetRegset(tid int) (regset proc.LinuxX86Xstate, 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

func PtracePeekUser

func PtracePeekUser(tid int, off uintptr) (uintptr, error)

PtracePeekUser execute ptrace PTRACE_PEEK_USER.

func PtracePokeUser

func PtracePokeUser(tid int, off, addr uintptr) error

PtracePokeUser execute ptrace PTRACE_POKE_USER.

func PtraceSingleStep

func PtraceSingleStep(tid int) error

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

Process represents all of the information the debugger is holding onto regarding the process we are debugging.

func Attach

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

Attach to an existing process with the given PID.

func Launch

func Launch(cmd []string, wd string, foreground bool) (*Process, error)

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

func New(pid int) *Process

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() *proc.BreakpointMap

func (*Process) CheckAndClearManualStopRequest

func (dbp *Process) CheckAndClearManualStopRequest() bool

func (*Process) Checkpoint

func (dbp *Process) Checkpoint(string) (int, error)

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 (dbp *Process) ClearCheckpoint(int) error

func (*Process) ClearInternalBreakpoints

func (dbp *Process) ClearInternalBreakpoints() error

func (*Process) Common added in v1.1.0

func (dbp *Process) Common() *proc.CommonProcess

func (*Process) ContinueOnce

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

func (*Process) CurrentThread

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

func (*Process) Detach

func (dbp *Process) Detach(kill bool) (err error)

Detach from the process being debugged, optionally killing it.

func (*Process) Direction

func (dbp *Process) Direction(proc.Direction) error

func (*Process) FindBreakpoint

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

FindBreakpoint finds the breakpoint for the given pc.

func (*Process) FindThread

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

func (*Process) LoadInformation

func (dbp *Process) LoadInformation(path string) error

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

func (dbp *Process) Pid() int

func (*Process) Recorded

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

func (*Process) RequestManualStop

func (dbp *Process) RequestManualStop() error

RequestManualStop sets the `halt` flag and sends SIGSTOP to all threads.

func (*Process) Restart

func (dbp *Process) Restart(string) error

func (*Process) ResumeNotify

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

func (*Process) SelectedGoroutine

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

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.

func (*Process) StepInstruction

func (dbp *Process) StepInstruction() (err error)

StepInstruction will continue the current thread for exactly one instruction. This method affects only the thread associated with the selected goroutine. All other threads will remain stopped.

func (*Process) SwitchGoroutine

func (dbp *Process) SwitchGoroutine(gid int) error

SwitchGoroutine changes from current thread to the thread running the specified goroutine.

func (*Process) SwitchThread

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

SwitchThread changes from current thread to the thread specified by `tid`.

func (*Process) ThreadList

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

func (*Process) Valid added in v1.1.0

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

func (*Process) When

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

type Regs

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

Regs is a wrapper for sys.PtraceRegs.

func (*Regs) BP

func (r *Regs) BP() uint64

func (*Regs) CX

func (r *Regs) CX() uint64

CX returns the value of RCX register.

func (*Regs) GAddr

func (r *Regs) GAddr() (uint64, bool)

func (*Regs) Get

func (r *Regs) Get(n int) (uint64, error)

func (*Regs) PC

func (r *Regs) PC() uint64

PC returns the value of RIP register.

func (*Regs) SP

func (r *Regs) SP() uint64

SP returns the value of RSP register.

func (*Regs) Save added in v1.1.0

func (r *Regs) Save() proc.SavedRegisters

func (*Regs) Slice

func (r *Regs) Slice() []proc.Register

func (*Regs) TLS

func (r *Regs) TLS() uint64

TLS returns the address of the thread local storage memory segment.

type Thread

type Thread struct {
	ID                int                  // Thread ID or mach port
	Status            *WaitStatus          // Status returned from last wait call
	CurrentBreakpoint proc.BreakpointState // Breakpoint thread is currently stopped at
	// 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) Arch

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

func (*Thread) BinInfo

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

func (*Thread) Blocked

func (t *Thread) Blocked() bool

func (*Thread) Breakpoint

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

func (*Thread) ClearBreakpoint

func (thread *Thread) ClearBreakpoint(bp *proc.Breakpoint) error

ClearBreakpoint clears the specified breakpoint.

func (*Thread) Common added in v1.1.0

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

func (*Thread) Continue

func (thread *Thread) Continue() error

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

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

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

func (t *Thread) PC() (uint64, error)

func (*Thread) ReadMemory

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

func (*Thread) Registers

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

Registers obtains register values from the debugged process.

func (*Thread) RestoreRegisters added in v1.1.0

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

func (*Thread) SetCurrentBreakpoint

func (thread *Thread) SetCurrentBreakpoint() error

SetCurrentBreakpoint sets the current breakpoint that this thread is stopped at as CurrentBreakpoint on the thread struct.

func (*Thread) SetDX added in v1.1.0

func (thread *Thread) SetDX(dx uint64) (err error)

func (*Thread) SetPC

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

SetPC sets RIP to the value specified by 'pc'.

func (*Thread) SetSP added in v1.1.0

func (thread *Thread) SetSP(sp uint64) (err error)

SetSP sets RSP to the value specified by 'sp'

func (*Thread) StepInstruction

func (thread *Thread) StepInstruction() (err error)

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.

func (*Thread) Stopped

func (t *Thread) Stopped() bool

Stopped returns whether the thread is stopped at the operating system level.

func (*Thread) ThreadID

func (th *Thread) ThreadID() int

func (*Thread) WriteMemory

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

type WaitStatus

type WaitStatus sys.WaitStatus

Jump to

Keyboard shortcuts

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