native

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: MIT Imports: 20 Imported by: 3

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 linutil.AMD64Xstate, 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, debugInfoDirs []string) (*Process, error)

Attach to an existing process with the given PID. Once attached, if the DWARF information cannot be found in the binary, Delve will look for external debug files in the directories passed in.

func Launch

func Launch(cmd []string, wd string, foreground bool, debugInfoDirs []string) (*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. If the DWARF information cannot be found in the binary, Delve will look for external debug files in the directories passed in.

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

BinInfo will return the binary info struct associated with this process.

func (*Process) Breakpoints

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

Breakpoints returns a list of breakpoints currently set.

func (*Process) CheckAndClearManualStopRequest

func (dbp *Process) CheckAndClearManualStopRequest() bool

CheckAndClearManualStopRequest checks if a manual stop has been requested, and then clears that state.

func (*Process) Checkpoint

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

Checkpoint will always return an error on the native proc backend, only supported for recorded traces.

func (*Process) Checkpoints

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

Checkpoints will always return an error on the native proc backend, only supported for recorded traces.

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

ClearCheckpoint will always return an error on the native proc backend, only supported in recorded traces.

func (*Process) ClearInternalBreakpoints

func (dbp *Process) ClearInternalBreakpoints() error

ClearInternalBreakpoints will clear all non-user set breakpoints. These breakpoints are set for internal operations such as 'next'.

func (*Process) Common added in v1.1.0

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

Common returns common information across Process implementations

func (*Process) ContinueOnce

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

ContinueOnce will continue the target until it stops. This could be the result of a breakpoint or signal.

func (*Process) CurrentThread

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

CurrentThread returns the current selected, active 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

Direction will always return an error in the native proc backend, only for recorded traces.

func (*Process) EntryPoint added in v1.2.0

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

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

func (*Process) FindBreakpoint

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

FindBreakpoint finds the breakpoint for the given pc.

func (*Process) FindThread

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

FindThread attempts to find the thread with the specified ID.

func (*Process) Pid

func (dbp *Process) Pid() int

Pid returns the process ID.

func (*Process) Recorded

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

Recorded always returns false for the native proc backend.

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

Restart will always return an error in the native proc backend, only for recorded traces.

func (*Process) ResumeNotify

func (dbp *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 (dbp *Process) SelectedGoroutine() *proc.G

SelectedGoroutine returns the current selected, active goroutine.

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) SetSelectedGoroutine added in v1.2.0

func (dbp *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) 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

ThreadList returns a list of threads in the process.

func (*Process) Valid added in v1.1.0

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

Valid returns whether the process is still attached to and has not exited.

func (*Process) When

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

When will always return an empty string and nil, not supported on native proc backend.

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 (t *Thread) Arch() proc.Arch

Arch returns the architecture the binary is compiled for and executing on.

func (*Thread) BinInfo

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

BinInfo returns information on the binary.

func (*Thread) Blocked

func (t *Thread) Blocked() bool

func (*Thread) Breakpoint

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

Breakpoint returns the current breakpoint that is active on this thread.

func (*Thread) ClearBreakpoint

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

ClearBreakpoint clears the specified breakpoint.

func (*Thread) Common added in v1.1.0

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

Common returns information common across Process implementations.

func (*Thread) Continue

func (t *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 (t *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)

PC returns the current program counter value for this thread.

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.Registers) error

RestoreRegisters will set the value of the CPU registers to those passed in via 'savedRegs'.

func (*Thread) SetCurrentBreakpoint

func (t *Thread) SetCurrentBreakpoint(adjustPC bool) 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 (t *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 (t *Thread) ThreadID() int

ThreadID returns the ID of this thread.

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