delve/pkg/proc/interface.go

89 lines
2.6 KiB
Go
Raw Normal View History

package proc
2017-02-08 00:23:47 +00:00
import (
"debug/gosym"
"go/ast"
)
// Process represents the target of the debugger. This
2017-02-08 00:23:47 +00:00
// target could be a system process, core file, etc.
type Process interface {
2017-02-08 00:23:47 +00:00
Info
ProcessManipulation
BreakpointManipulation
}
// Info is an interface that provides general information on the target.
type Info interface {
Pid() int
Exited() bool
Running() bool
BinInfo() *BinaryInfo
2017-02-08 00:23:47 +00:00
ThreadInfo
GoroutineInfo
// FindFileLocation returns the address of the first instruction belonging
// to line lineNumber in file fileName.
2017-02-08 00:23:47 +00:00
FindFileLocation(fileName string, lineNumber int) (uint64, error)
// FirstPCAfterPrologue returns the first instruction address after fn's
// prologue.
// If sameline is true and the first instruction after the prologue belongs
// to a different source line the entry point will be returned instead.
2017-02-08 00:23:47 +00:00
FirstPCAfterPrologue(fn *gosym.Func, sameline bool) (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
FindFunctionLocation(funcName string, firstLine bool, lineOffset int) (uint64, error)
2017-02-08 00:23:47 +00:00
}
// ThreadInfo is an interface for getting information on active threads
// in the process.
type ThreadInfo interface {
FindThread(threadID int) (Thread, bool)
ThreadList() []Thread
CurrentThread() Thread
2017-02-08 00:23:47 +00:00
}
// GoroutineInfo is an interface for getting information on running goroutines.
type GoroutineInfo interface {
SelectedGoroutine() *G
2017-02-08 00:23:47 +00:00
}
// ProcessManipulation is an interface for changing the execution state of a process.
type ProcessManipulation interface {
ContinueOnce() (trapthread Thread, err error)
2017-02-08 00:23:47 +00:00
StepInstruction() error
SwitchThread(int) error
SwitchGoroutine(int) error
RequestManualStop() error
Halt() error
Kill() error
Detach(bool) error
}
// BreakpointManipulation is an interface for managing breakpoints.
type BreakpointManipulation interface {
Breakpoints() map[uint64]*Breakpoint
SetBreakpoint(addr uint64, kind BreakpointKind, cond ast.Expr) (*Breakpoint, error)
ClearBreakpoint(addr uint64) (*Breakpoint, error)
2017-02-08 00:23:47 +00:00
ClearInternalBreakpoints() error
}
// VariableEval is an interface for dealing with eval scopes.
type VariableEval interface {
FrameToScope(Stackframe) *EvalScope
ConvertEvalScope(gid, frame int) (*EvalScope, error)
2017-02-08 00:23:47 +00:00
}