Documentation ¶
Overview ¶
Package proc is a low-level package that provides methods to manipulate the process we are debugging.
proc implements all core functionality including: * creating / attaching to a process * process manipulation (step, next, continue, halt) * methods to explore the memory of the process
Index ¶
- Constants
- Variables
- func PtraceAttach(pid int) error
- func PtraceCont(tid, sig int) error
- func PtraceDetach(tid, sig int) error
- func PtraceSingleStep(tid int) error
- type AMD64
- type Arch
- type ArchInst
- type AsmInstruction
- type AssemblyFlavour
- type BinaryInfo
- func (bi *BinaryInfo) Close() error
- func (bi *BinaryInfo) DwarfReader() *reader.Reader
- func (bi *BinaryInfo) Funcs() []gosym.Func
- func (bi *BinaryInfo) LastModified() time.Time
- func (bininfo *BinaryInfo) LoadBinaryInfo(path string, wg *sync.WaitGroup) error
- func (bi *BinaryInfo) LoadBinaryInfoElf(path string, wg *sync.WaitGroup) error
- func (bi *BinaryInfo) LoadBinaryInfoMacho(path string, wg *sync.WaitGroup) error
- func (bi *BinaryInfo) LoadBinaryInfoPE(path string, wg *sync.WaitGroup) error
- func (bi *BinaryInfo) PCToLine(pc uint64) (string, int, *gosym.Func)
- func (bi *BinaryInfo) Sources() map[string]*gosym.Obj
- func (bi *BinaryInfo) Types() ([]string, error)
- type Breakpoint
- type BreakpointExistsError
- type BreakpointKind
- type EvalScope
- func (scope *EvalScope) DwarfReader() *reader.Reader
- func (scope *EvalScope) EvalExpression(expr string, cfg LoadConfig) (*Variable, error)
- func (scope *EvalScope) EvalVariable(name string, cfg LoadConfig) (*Variable, error)
- func (scope *EvalScope) FunctionArguments(cfg LoadConfig) ([]*Variable, error)
- func (scope *EvalScope) LocalVariables(cfg LoadConfig) ([]*Variable, error)
- func (scope *EvalScope) PackageVariables(cfg LoadConfig) ([]*Variable, error)
- func (scope *EvalScope) PtrSize() int
- func (scope *EvalScope) SetVariable(name, value string) error
- func (scope *EvalScope) Type(offset dwarf.Offset) (dwarf.Type, error)
- type FloatSpecial
- type G
- type GoVersion
- type InvalidAddressError
- type IsNilErr
- type LoadConfig
- type Location
- type M
- type NoBreakpointError
- type NoGError
- type NoReturnAddr
- type NullAddrError
- type OSProcessDetails
- type OSSpecificDetails
- type Process
- func (dbp *Process) BinInfo() *BinaryInfo
- func (dbp *Process) Breakpoints() map[uint64]*Breakpoint
- func (dbp *Process) ClearBreakpoint(addr uint64) (*Breakpoint, error)
- func (dbp *Process) ClearInternalBreakpoints() error
- func (dbp *Process) Continue() error
- func (dbp *Process) ConvertEvalScope(gid, frame int) (*EvalScope, error)
- func (dbp *Process) CurrentBreakpoint() *Breakpoint
- func (dbp *Process) CurrentLocation() (*Location, error)
- func (dbp *Process) CurrentThread() *Thread
- func (dbp *Process) Detach(kill bool) (err error)
- func (dbp *Process) EvalPackageVariable(name string, cfg LoadConfig) (*Variable, error)
- func (dbp *Process) Exited() bool
- func (dbp *Process) FindBreakpoint(pc uint64) (*Breakpoint, bool)
- func (dbp *Process) FindBreakpointByID(id int) (*Breakpoint, bool)
- func (dbp *Process) FindFileLocation(fileName string, lineno int) (uint64, error)
- func (dbp *Process) FindFunctionLocation(funcName string, firstLine bool, lineOffset int) (uint64, error)
- func (dbp *Process) FindGoroutine(gid int) (*G, error)
- func (dbp *Process) FirstPCAfterPrologue(fn *gosym.Func, sameline bool) (uint64, error)
- func (dbp *Process) GoroutineLocation(g *G) *Location
- func (dbp *Process) GoroutinesInfo() ([]*G, error)
- func (dbp *Process) Halt() (err error)
- func (dbp *Process) Kill() (err error)
- func (dbp *Process) LoadInformation(path string) error
- func (dbp *Process) Next() (err error)
- func (dbp *Process) PC() (uint64, error)
- func (dbp *Process) Pid() int
- func (dbp *Process) Registers() (Registers, error)
- func (dbp *Process) RequestManualStop() error
- func (dbp *Process) Running() bool
- func (dbp *Process) SelectedGoroutine() *G
- func (dbp *Process) SetBreakpoint(addr uint64, kind BreakpointKind, cond ast.Expr) (*Breakpoint, error)
- func (dbp *Process) Status() *WaitStatus
- func (dbp *Process) Step() (err error)
- func (dbp *Process) StepInstruction() (err error)
- func (dbp *Process) StepOut() error
- func (dbp *Process) SwitchGoroutine(gid int) error
- func (dbp *Process) SwitchThread(tid int) error
- func (dbp *Process) Threads() map[int]*Thread
- type ProcessExitedError
- type Register
- type Registers
- type Regs
- type Stackframe
- type Thread
- func (thread *Thread) Continue() error
- func (thread *Thread) Disassemble(startPC, endPC uint64, currentGoroutine bool) ([]AsmInstruction, error)
- func (thread *Thread) GetG() (g *G, err error)
- func (thread *Thread) Halt() (err error)
- func (thread *Thread) Location() (*Location, error)
- func (t *Thread) PC() (uint64, error)
- func (t *Thread) Registers(floatingPoint bool) (Registers, error)
- func (t *Thread) ReturnAddress() (uint64, error)
- func (thread *Thread) Scope() (*EvalScope, error)
- func (thread *Thread) SetCurrentBreakpoint() error
- func (thread *Thread) SetPC(pc uint64) error
- func (t *Thread) Stacktrace(depth int) ([]Stackframe, error)
- func (thread *Thread) StepInstruction() (err error)
- func (thread *Thread) Stopped() bool
- type ThreadBlockedError
- type Variable
- type WaitStatus
Constants ¶
const ( GNUFlavour = AssemblyFlavour(iota) IntelFlavour )
const ( Gidle uint64 = iota // 0 Grunnable // 1 runnable and on a run queue Grunning // 2 Gsyscall // 3 Gwaiting // 4 GmoribundUnused // 5 currently unused, but hardcoded in gdb scripts Gdead // 6 Genqueue // 7 Only the Gscanenqueue is used. Gcopystack // 8 in this state when newstack is moving the stack )
G status, from: src/runtime/runtime2.go
Variables ¶
var ErrContinueThread = fmt.Errorf("could not continue thread")
ErrContinueThread is the error returned when a thread could not be continued.
var (
GoVer18Beta = GoVersion{1, 8, -1, 0, 0}
)
var NotExecutableErr = errors.New("not an executable file")
var OperationOnSpecialFloatError = errors.New("operations on non-finite floats not implemented")
var UnknownRegisterError = errors.New("unknown register")
var UnsupportedDarwinArchErr = errors.New("unsupported architecture - only darwin/amd64 is supported")
var UnsupportedLinuxArchErr = errors.New("unsupported architecture - only linux/amd64 is supported")
var UnsupportedWindowsArchErr = errors.New("unsupported architecture of windows/386 - only windows/amd64 is supported")
Functions ¶
func PtraceAttach ¶
PtraceAttach executes the sys.PtraceAttach call.
func PtraceCont ¶
PtraceCont executes the PTRACE_CONT ptrace call.
func PtraceDetach ¶
PtraceDetach executes the PT_DETACH ptrace call.
func PtraceSingleStep ¶
PtraceSingleStep returns PT_STEP ptrace call.
Types ¶
type AMD64 ¶
type AMD64 struct {
// contains filtered or unexported fields
}
AMD64 represents the AMD64 CPU architecture.
func (*AMD64) BreakpointInstruction ¶
BreakpointInstruction returns the Breakpoint instruction for this architecture.
func (*AMD64) BreakpointSize ¶
BreakpointSize returns the size of the breakpoint instruction on this architecture.
func (*AMD64) GStructOffset ¶
GStructOffset returns the offset of the G struct in thread local storage.
func (*AMD64) SetGStructOffset ¶
SetGStructOffset sets the offset of the G struct on the AMD64 arch struct. The offset is dependent on the Go compiler Version and whether or not the target program was externally linked.
type Arch ¶
type Arch interface { SetGStructOffset(ver GoVersion, iscgo bool) PtrSize() int BreakpointInstruction() []byte BreakpointSize() int GStructOffset() uint64 }
Arch defines an interface for representing a CPU architecture.
type AsmInstruction ¶
type AsmInstruction struct { Loc Location DestLoc *Location Bytes []byte Breakpoint bool AtPC bool Inst *ArchInst }
func (*AsmInstruction) IsCall ¶
func (inst *AsmInstruction) IsCall() bool
func (*AsmInstruction) Text ¶
func (inst *AsmInstruction) Text(flavour AssemblyFlavour) string
type AssemblyFlavour ¶
type AssemblyFlavour int
type BinaryInfo ¶
type BinaryInfo struct {
// contains filtered or unexported fields
}
func NewBinaryInfo ¶
func NewBinaryInfo(goos, goarch string) BinaryInfo
func (*BinaryInfo) Close ¶
func (bi *BinaryInfo) Close() error
func (*BinaryInfo) DwarfReader ¶
func (bi *BinaryInfo) DwarfReader() *reader.Reader
DwarfReader returns a reader for the dwarf data
func (*BinaryInfo) Funcs ¶
func (bi *BinaryInfo) Funcs() []gosym.Func
Funcs returns list of functions present in the debugged program.
func (*BinaryInfo) LastModified ¶
func (bi *BinaryInfo) LastModified() time.Time
func (*BinaryInfo) LoadBinaryInfo ¶
func (bininfo *BinaryInfo) LoadBinaryInfo(path string, wg *sync.WaitGroup) error
func (*BinaryInfo) LoadBinaryInfoElf ¶
func (bi *BinaryInfo) LoadBinaryInfoElf(path string, wg *sync.WaitGroup) error
func (*BinaryInfo) LoadBinaryInfoMacho ¶
func (bi *BinaryInfo) LoadBinaryInfoMacho(path string, wg *sync.WaitGroup) error
func (*BinaryInfo) LoadBinaryInfoPE ¶
func (bi *BinaryInfo) LoadBinaryInfoPE(path string, wg *sync.WaitGroup) error
func (*BinaryInfo) Sources ¶
func (bi *BinaryInfo) Sources() map[string]*gosym.Obj
Sources returns list of source files that comprise the debugged binary.
func (*BinaryInfo) Types ¶
func (bi *BinaryInfo) Types() ([]string, error)
Types returns list of types present in the debugged program.
type Breakpoint ¶
type Breakpoint struct { // File & line information for printing. FunctionName string File string Line int Addr uint64 // Address breakpoint is set for. OriginalData []byte // If software breakpoint, the data we replace with breakpoint instruction. Name string // User defined name of the breakpoint ID int // Monotonically increasing ID. Kind BreakpointKind // Whether this is an internal breakpoint (for next'ing or stepping). // Breakpoint information Tracepoint bool // Tracepoint flag Goroutine bool // Retrieve goroutine information Stacktrace int // Number of stack frames to retrieve Variables []string // Variables to evaluate LoadArgs *LoadConfig LoadLocals *LoadConfig HitCount map[int]uint64 // Number of times a breakpoint has been reached in a certain goroutine TotalHitCount uint64 // Number of times a breakpoint has been reached // DeferReturns: when kind == NextDeferBreakpoint this breakpoint // will also check if the caller is runtime.gopanic or if the return // address is in the DeferReturns array. // Next uses NextDeferBreakpoints for the breakpoint it sets on the // deferred function, DeferReturns is populated with the // addresses of calls to runtime.deferreturn in the current // function. This insures that the breakpoint on the deferred // function only triggers on panic or on the defer call to // the function, not when the function is called directly DeferReturns []uint64 // Cond: if not nil the breakpoint will be triggered only if evaluating Cond returns true Cond ast.Expr }
Breakpoint represents a breakpoint. Stores information on the break point including the byte of data that originally was stored at that address.
func (*Breakpoint) Clear ¶
func (bp *Breakpoint) Clear(thread *Thread) (*Breakpoint, error)
Clear this breakpoint appropriately depending on whether it is a hardware or software breakpoint.
func (*Breakpoint) Internal ¶
func (bp *Breakpoint) Internal() bool
Internal returns true for breakpoints not set directly by the user.
func (*Breakpoint) String ¶
func (bp *Breakpoint) String() string
type BreakpointExistsError ¶
type BreakpointExistsError struct {
// contains filtered or unexported fields
}
BreakpointExistsError is returned when trying to set a breakpoint at an address that already has a breakpoint set for it.
func (BreakpointExistsError) Error ¶
func (bpe BreakpointExistsError) Error() string
type BreakpointKind ¶
type BreakpointKind int
Breakpoint Kind determines the behavior of delve when the breakpoint is reached.
const ( // UserBreakpoint is a user set breakpoint UserBreakpoint BreakpointKind = iota // NextBreakpoint is a breakpoint set by Next, Continue // will stop on it and delete it NextBreakpoint // NextDeferBreakpoint is a breakpoint set by Next on the // first deferred function. In addition to checking their condition // breakpoints of this kind will also check that the function has been // called by runtime.gopanic or through runtime.deferreturn. NextDeferBreakpoint // StepBreakpoint is a breakpoint set by Step on a CALL instruction, // Continue will set a new breakpoint (of NextBreakpoint kind) on the // destination of CALL, delete this breakpoint and then continue again StepBreakpoint )
type EvalScope ¶
EvalScope is the scope for variable evaluation. Contains the thread, current location (PC), and canonical frame address.
func (*EvalScope) DwarfReader ¶
DwarfReader returns the DwarfReader containing the Dwarf information for the target process.
func (*EvalScope) EvalExpression ¶
func (scope *EvalScope) EvalExpression(expr string, cfg LoadConfig) (*Variable, error)
EvalExpression returns the value of the given expression.
func (*EvalScope) EvalVariable ¶
func (scope *EvalScope) EvalVariable(name string, cfg LoadConfig) (*Variable, error)
EvalVariable returns the value of the given expression (backwards compatibility).
func (*EvalScope) FunctionArguments ¶
func (scope *EvalScope) FunctionArguments(cfg LoadConfig) ([]*Variable, error)
FunctionArguments returns the name, value, and type of all current function arguments.
func (*EvalScope) LocalVariables ¶
func (scope *EvalScope) LocalVariables(cfg LoadConfig) ([]*Variable, error)
LocalVariables returns all local variables from the current function scope.
func (*EvalScope) PackageVariables ¶
func (scope *EvalScope) PackageVariables(cfg LoadConfig) ([]*Variable, error)
PackageVariables returns the name, value, and type of all package variables in the application.
func (*EvalScope) SetVariable ¶
SetVariable sets the value of the named variable
type FloatSpecial ¶
type FloatSpecial uint8
const ( FloatIsNormal FloatSpecial = iota FloatIsNaN FloatIsPosInf FloatIsNegInf )
type G ¶
type G struct { ID int // Goroutine ID PC uint64 // PC of goroutine when it was parked. SP uint64 // SP of goroutine when it was parked. GoPC uint64 // PC of 'go' statement that created this goroutine. WaitReason string // Reason for goroutine being parked. Status uint64 // Information on goroutine location CurrentLoc Location // contains filtered or unexported fields }
G represents a runtime G (goroutine) structure (at least the fields that Delve is interested in).
func (*G) ChanRecvBlocked ¶
ChanRecvBlocked returns whether the goroutine is blocked on a channel read operation.
func (*G) Stacktrace ¶
func (g *G) Stacktrace(depth int) ([]Stackframe, error)
Stacktrace returns the stack trace for a goroutine. Note the locations in the array are return addresses not call addresses.
func (*G) UserCurrent ¶
UserCurrent returns the location the users code is at, or was at before entering a runtime function.
type GoVersion ¶
GoVersion represents the Go version of the Go compiler version used to compile the target binary.
func ParseVersionString ¶
func (*GoVersion) AfterOrEqual ¶
AfterOrEqual returns whether one GoVersion is after or equal to the other.
type InvalidAddressError ¶
type InvalidAddressError struct {
// contains filtered or unexported fields
}
InvalidAddressError represents the result of attempting to set a breakpoint at an invalid address.
func (InvalidAddressError) Error ¶
func (iae InvalidAddressError) Error() string
type IsNilErr ¶
type IsNilErr struct {
// contains filtered or unexported fields
}
IsNilErr is returned when a variable is nil.
type LoadConfig ¶
type LoadConfig struct { // FollowPointers requests pointers to be automatically dereferenced. FollowPointers bool // MaxVariableRecurse is how far to recurse when evaluating nested types. MaxVariableRecurse int // MaxStringLen is the maximum number of bytes read from a string MaxStringLen int // MaxArrayValues is the maximum number of elements read from an array, a slice or a map. MaxArrayValues int // MaxStructFields is the maximum number of fields read from a struct, -1 will read all fields. MaxStructFields int }
type Location ¶
Location represents the location of a thread. Holds information on the current instruction address, the source file:line, and the function.
type M ¶
type M struct {
// contains filtered or unexported fields
}
M represents a runtime M (OS thread) structure.
type NoBreakpointError ¶
type NoBreakpointError struct {
// contains filtered or unexported fields
}
NoBreakpointError is returned when trying to clear a breakpoint that does not exist.
func (NoBreakpointError) Error ¶
func (nbp NoBreakpointError) Error() string
type NoGError ¶
type NoGError struct {
// contains filtered or unexported fields
}
NoGError returned when a G could not be found for a specific thread.
type NoReturnAddr ¶
type NoReturnAddr struct {
// contains filtered or unexported fields
}
NoReturnAddr is returned when return address could not be found during stack trace.
func (NoReturnAddr) Error ¶
func (nra NoReturnAddr) Error() string
type NullAddrError ¶
type NullAddrError struct{}
NullAddrError is an error for a null address.
func (NullAddrError) Error ¶
func (n NullAddrError) Error() string
type OSProcessDetails ¶
type OSProcessDetails struct {
// contains filtered or unexported fields
}
OSProcessDetails holds Darwin specific information.
type OSSpecificDetails ¶
type OSSpecificDetails struct {
// contains filtered or unexported fields
}
OSSpecificDetails holds information specific to the OSX/Darwin operating system / kernel.
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. Uses a custom fork/exec process in order to take advantage of PT_SIGEXC on Darwin which will turn Unix signals into Mach exceptions.
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() *BinaryInfo
func (*Process) Breakpoints ¶
func (dbp *Process) Breakpoints() map[uint64]*Breakpoint
func (*Process) ClearBreakpoint ¶
func (dbp *Process) ClearBreakpoint(addr uint64) (*Breakpoint, error)
ClearBreakpoint clears the breakpoint at addr.
func (*Process) ClearInternalBreakpoints ¶
func (*Process) Continue ¶
Continue continues execution of the debugged process. It will continue until it hits a breakpoint or is otherwise stopped.
func (*Process) ConvertEvalScope ¶
ConvertEvalScope returns a new EvalScope in the context of the specified goroutine ID and stack frame.
func (*Process) CurrentBreakpoint ¶
func (dbp *Process) CurrentBreakpoint() *Breakpoint
CurrentBreakpoint returns the breakpoint the current thread is stopped at.
func (*Process) CurrentLocation ¶
CurrentLocation returns the location of the current thread.
func (*Process) CurrentThread ¶
func (*Process) EvalPackageVariable ¶
func (dbp *Process) EvalPackageVariable(name string, cfg LoadConfig) (*Variable, error)
EvalPackageVariable will evaluate the package level variable specified by 'name'.
func (*Process) FindBreakpoint ¶
func (dbp *Process) FindBreakpoint(pc uint64) (*Breakpoint, bool)
FindBreakpoint finds the breakpoint for the given pc.
func (*Process) FindBreakpointByID ¶
func (dbp *Process) FindBreakpointByID(id int) (*Breakpoint, bool)
FindBreakpointByID finds the breakpoint for the given ID.
func (*Process) FindFileLocation ¶
FindFileLocation returns the PC for a given file:line. Assumes that `file` is normailzed to lower case and '/' on Windows.
func (*Process) FindFunctionLocation ¶
func (dbp *Process) FindFunctionLocation(funcName string, firstLine bool, lineOffset int) (uint64, error)
FindFunctionLocation finds address of a function's line If firstLine == true is passed FindFunctionLocation will attempt to find the first line of the function If lineOffset is passed FindFunctionLocation will return the address of that line Pass lineOffset == 0 and firstLine == false if you want the address for the function's entry point Note that setting breakpoints at that address will cause surprising behavior: https://github.com/derekparker/delve/issues/170
func (*Process) FindGoroutine ¶
FindGoroutine returns a G struct representing the goroutine specified by `gid`.
func (*Process) FirstPCAfterPrologue ¶
FirstPCAfterPrologue returns the address of the first instruction after the prologue for function fn If sameline is set FirstPCAfterPrologue will always return an address associated with the same line as fn.Entry
func (*Process) GoroutineLocation ¶
GoroutineLocation returns the location of the given goroutine.
func (*Process) GoroutinesInfo ¶
GoroutinesInfo returns an array of G structures representing the information Delve cares about from the internal runtime G structure.
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) Registers ¶
Registers obtains register values from the "current" thread of the traced process.
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 BreakpointKind, cond ast.Expr) (*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) Status ¶
func (dbp *Process) Status() *WaitStatus
Status returns the status of the current main thread context.
func (*Process) Step ¶
Step will continue until another source line is reached. Will step into functions.
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) StepOut ¶
StepOut will continue until the current goroutine exits the function currently being executed or a deferred function is executed
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`.
type ProcessExitedError ¶
ProcessExitedError indicates that the process has exited and contains both process id and exit status.
func (ProcessExitedError) Error ¶
func (pe ProcessExitedError) Error() string
type Registers ¶
type Registers interface { PC() uint64 SP() uint64 BP() uint64 CX() uint64 TLS() uint64 Get(int) (uint64, error) SetPC(*Thread, uint64) error Slice() []Register }
Registers is an interface for a generic register type. The interface encapsulates the generic values / actions we need independent of arch. The concrete register types will be different depending on OS/Arch.
type Regs ¶
type Regs struct {
// contains filtered or unexported fields
}
Regs represents CPU registers on an AMD64 processor.
type Stackframe ¶
type Stackframe struct { // Address the function above this one on the call stack will return to. Current Location // Address of the call instruction for the function above on the call stack. Call Location // Start address of the stack frame. CFA int64 // Description of the stack frame. FDE *frame.FrameDescriptionEntry // Return address for this stack frame (as read from the stack frame itself). Ret uint64 // contains filtered or unexported fields }
Stackframe represents a frame in a system stack.
func (*Stackframe) Scope ¶
func (frame *Stackframe) Scope(thread *Thread) *EvalScope
Scope returns a new EvalScope using this frame.
type Thread ¶
type Thread struct { ID int // Thread ID or mach port Status *WaitStatus // Status returned from last wait call CurrentBreakpoint *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) 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) Disassemble ¶
func (thread *Thread) Disassemble(startPC, endPC uint64, currentGoroutine bool) ([]AsmInstruction, error)
Disassemble disassembles target memory between startPC and endPC If currentGoroutine is set and thread is stopped at a CALL instruction Disassemble will evaluate the argument of the CALL instruction using the thread's registers Be aware that the Bytes field of each returned instruction is a slice of a larger array of size endPC - startPC
func (*Thread) GetG ¶
GetG returns information on the G (goroutine) that is executing on this thread.
The G structure for a thread is stored in thread local storage. Here we simply calculate the address and read and parse the G struct.
We cannot simply use the allg linked list in order to find the M that represents the given OS thread and follow its G pointer because on Darwin mach ports are not universal, so our port for this thread would not map to the `id` attribute of the M structure. Also, when linked against libc, Go prefers the libc version of clone as opposed to the runtime version. This has the consequence of not setting M.id for any thread, regardless of OS.
In order to get around all this craziness, we read the address of the G structure for the current thread from the thread local storage area.
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) ReturnAddress ¶
ReturnAddress returns the return address of the function this thread is executing.
func (*Thread) SetCurrentBreakpoint ¶
SetCurrentBreakpoint sets the current breakpoint that this thread is stopped at as CurrentBreakpoint on the thread struct.
func (*Thread) Stacktrace ¶
func (t *Thread) Stacktrace(depth int) ([]Stackframe, error)
Stacktrace returns the stack trace for thread. Note the locations in the array are return addresses not call addresses.
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 ThreadBlockedError ¶
type ThreadBlockedError struct{}
ThreadBlockedError is returned when the thread is blocked in the scheduler.
func (ThreadBlockedError) Error ¶
func (tbe ThreadBlockedError) Error() string
type Variable ¶
type Variable struct { Addr uintptr OnlyAddr bool Name string DwarfType dwarf.Type RealType dwarf.Type Kind reflect.Kind Value constant.Value FloatSpecial FloatSpecial Len int64 Cap int64 // Base address of arrays, Base address of the backing array for slices (0 for nil slices) // Base address of the backing byte array for strings // address of the struct backing chan and map variables // address of the function entry point for function variables (0 for nil function pointers) Base uintptr Children []Variable Unreadable error // contains filtered or unexported fields }
Variable represents a variable. It contains the address, name, type and other information parsed from both the Dwarf information and the memory of the debugged process. If OnlyAddr is true, the variables value has not been loaded.
func (*Variable) TypeString ¶
TypeString returns the string representation of the type of this variable.
type WaitStatus ¶
type WaitStatus sys.WaitStatus
WaitStatus is a synonym for the platform-specific WaitStatus