api

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: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// VariableEscaped is set for local variables that escaped to the heap
	//
	// The compiler performs escape analysis on local variables, the variables
	// that may outlive the stack frame are allocated on the heap instead and
	// only the address is recorded on the stack. These variables will be
	// marked with this flag.
	VariableEscaped = VariableFlags(proc.VariableEscaped)

	// VariableShadowed is set for local variables that are shadowed by a
	// variable with the same name in another scope
	VariableShadowed = VariableFlags(proc.VariableShadowed)

	// VariableConstant means this variable is a constant value
	VariableConstant

	// VariableArgument means this variable is a function argument
	VariableArgument

	// VariableReturnArgument means this variable is a function return value
	VariableReturnArgument
)
View Source
const (
	// Continue resumes process execution.
	Continue = "continue"
	// Rewind resumes process execution backwards (target must be a recording).
	Rewind = "rewind"
	// Step continues to next source line, entering function calls.
	Step = "step"
	// StepOut continues to the return address of the current function
	StepOut = "stepOut"
	// SingleStep continues for exactly 1 cpu instruction.
	StepInstruction = "stepInstruction"
	// Next continues to the next source line, not entering function calls.
	Next = "next"
	// SwitchThread switches the debugger's current thread context.
	SwitchThread = "switchThread"
	// SwitchGoroutine switches the debugger's current thread context to the thread running the specified goroutine
	SwitchGoroutine = "switchGoroutine"
	// Halt suspends the process.
	Halt = "halt"
	// Call resumes process execution injecting a function call.
	Call = "call"
)
View Source
const (
	GNUFlavour   = AssemblyFlavour(proc.GNUFlavour)
	IntelFlavour = AssemblyFlavour(proc.IntelFlavour)
)

Variables

View Source
var NotExecutableErr = proc.NotExecutableErr

Functions

func LoadConfigToProc

func LoadConfigToProc(cfg *LoadConfig) *proc.LoadConfig

func ValidBreakpointName

func ValidBreakpointName(name string) error

Types

type AsmInstruction

type AsmInstruction struct {
	// Loc is the location of this instruction
	Loc Location
	// Destination of CALL instructions
	DestLoc *Location
	// Text is the formatted representation of the instruction
	Text string
	// Bytes is the instruction as read from memory
	Bytes []byte
	// If Breakpoint is true a breakpoint is set at this instruction
	Breakpoint bool
	// In AtPC is true this is the instruction the current thread is stopped at
	AtPC bool
}

AsmInstruction represents one assembly instruction at some address

func ConvertAsmInstruction

func ConvertAsmInstruction(inst proc.AsmInstruction, text string) AsmInstruction

type AsmInstructions

type AsmInstructions []AsmInstruction

type AssemblyFlavour

type AssemblyFlavour int

type Breakpoint

type Breakpoint struct {
	// ID is a unique identifier for the breakpoint.
	ID int `json:"id"`
	// User defined name of the breakpoint
	Name string `json:"name"`
	// Addr is the address of the breakpoint.
	Addr uint64 `json:"addr"`
	// File is the source file for the breakpoint.
	File string `json:"file"`
	// Line is a line in File for the breakpoint.
	Line int `json:"line"`
	// FunctionName is the name of the function at the current breakpoint, and
	// may not always be available.
	FunctionName string `json:"functionName,omitempty"`

	// Breakpoint condition
	Cond string

	// tracepoint flag
	Tracepoint bool `json:"continue"`
	// retrieve goroutine information
	Goroutine bool `json:"goroutine"`
	// number of stack frames to retrieve
	Stacktrace int `json:"stacktrace"`
	// expressions to evaluate
	Variables []string `json:"variables,omitempty"`
	// LoadArgs requests loading function arguments when the breakpoint is hit
	LoadArgs *LoadConfig
	// LoadLocals requests loading function locals when the breakpoint is hit
	LoadLocals *LoadConfig
	// number of times a breakpoint has been reached in a certain goroutine
	HitCount map[string]uint64 `json:"hitCount"`
	// number of times a breakpoint has been reached
	TotalHitCount uint64 `json:"totalHitCount"`
}

Breakpoint addresses a location at which process execution may be suspended.

func ConvertBreakpoint

func ConvertBreakpoint(bp *proc.Breakpoint) *Breakpoint

ConvertBreakpoint converts from a proc.Breakpoint to an api.Breakpoint.

type BreakpointInfo

type BreakpointInfo struct {
	Stacktrace []Stackframe `json:"stacktrace,omitempty"`
	Goroutine  *Goroutine   `json:"goroutine,omitempty"`
	Variables  []Variable   `json:"variables,omitempty"`
	Arguments  []Variable   `json:"arguments,omitempty"`
	Locals     []Variable   `json:"locals,omitempty"`
}

Informations about the current breakpoint

type Checkpoint added in v1.0.0

type Checkpoint struct {
	ID    int
	When  string
	Where string
}

func ConvertCheckpoint added in v1.0.0

func ConvertCheckpoint(in proc.Checkpoint) (out Checkpoint)

type DebuggerCommand

type DebuggerCommand struct {
	// Name is the command to run.
	Name string `json:"name"`
	// ThreadID is used to specify which thread to use with the SwitchThread
	// command.
	ThreadID int `json:"threadID,omitempty"`
	// GoroutineID is used to specify which thread to use with the SwitchGoroutine
	// command.
	GoroutineID int `json:"goroutineID,omitempty"`
	// When ReturnInfoLoadConfig is not nil it will be used to load the value
	// of any return variables.
	ReturnInfoLoadConfig *LoadConfig
	// Expr is the expression argument for a Call command
	Expr string `json:"expr,omitempty"`
}

DebuggerCommand is a command which changes the debugger's execution state.

type DebuggerState

type DebuggerState struct {
	// Running is true if the process is running and no other information can be collected.
	Running bool
	// CurrentThread is the currently selected debugger thread.
	CurrentThread *Thread `json:"currentThread,omitempty"`
	// SelectedGoroutine is the currently selected goroutine
	SelectedGoroutine *Goroutine `json:"currentGoroutine,omitempty"`
	// List of all the process threads
	Threads []*Thread
	// NextInProgress indicates that a next or step operation was interrupted by another breakpoint
	// or a manual stop and is waiting to complete.
	// While NextInProgress is set further requests for next or step may be rejected.
	// Either execute continue until NextInProgress is false or call CancelNext
	NextInProgress bool
	// Exited indicates whether the debugged process has exited.
	Exited     bool `json:"exited"`
	ExitStatus int  `json:"exitStatus"`
	// When contains a description of the current position in a recording
	When string
	// Filled by RPCClient.Continue, indicates an error
	Err error `json:"-"`
}

DebuggerState represents the current context of the debugger.

type Defer added in v1.1.0

type Defer struct {
	DeferredLoc Location // deferred function
	DeferLoc    Location // location of the defer statement
	SP          uint64   // value of SP when the function was deferred
	Unreadable  string
}

type DiscardedBreakpoint

type DiscardedBreakpoint struct {
	Breakpoint *Breakpoint
	Reason     string
}

type EvalScope

type EvalScope struct {
	GoroutineID int
	Frame       int
}

type Function

type Function struct {
	// Name is the function name.
	Name_  string `json:"name"`
	Value  uint64 `json:"value"`
	Type   byte   `json:"type"`
	GoType uint64 `json:"goType"`
	// Optimized is true if the function was optimized
	Optimized bool `json:"optimized"`
}

Function represents thread-scoped function information.

func ConvertFunction

func ConvertFunction(fn *proc.Function) *Function

ConvertFunction converts from gosym.Func to api.Function.

func (*Function) Name

func (fn *Function) Name() string

type GetVersionIn

type GetVersionIn struct {
}

type GetVersionOut

type GetVersionOut struct {
	DelveVersion string
	APIVersion   int
}

type Goroutine

type Goroutine struct {
	// ID is a unique identifier for the goroutine.
	ID int `json:"id"`
	// Current location of the goroutine
	CurrentLoc Location `json:"currentLoc"`
	// Current location of the goroutine, excluding calls inside runtime
	UserCurrentLoc Location `json:"userCurrentLoc"`
	// Location of the go instruction that started this goroutine
	GoStatementLoc Location `json:"goStatementLoc"`
	// Location of the starting function
	StartLoc Location `json:"startLoc"`
	// ID of the associated thread for running goroutines
	ThreadID int `json:"threadID"`
}

Goroutine represents the information relevant to Delve from the runtime's internal G structure.

func ConvertGoroutine

func ConvertGoroutine(g *proc.G) *Goroutine

ConvertGoroutine converts from proc.G to api.Goroutine.

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
}

LoadConfig describes how to load values from target's memory

func LoadConfigFromProc

func LoadConfigFromProc(cfg *proc.LoadConfig) *LoadConfig

type Location

type Location struct {
	PC       uint64    `json:"pc"`
	File     string    `json:"file"`
	Line     int       `json:"line"`
	Function *Function `json:"function,omitempty"`
}

func ConvertLocation

func ConvertLocation(loc proc.Location) Location

ConvertLocation converts from proc.Location to api.Location.

type Register

type Register struct {
	Name  string
	Value string
}

func ConvertRegisters

func ConvertRegisters(in []proc.Register) (out []Register)

type Registers

type Registers []Register

func (Registers) String

func (regs Registers) String() string

type SetAPIVersionIn

type SetAPIVersionIn struct {
	APIVersion int
}

type SetAPIVersionOut

type SetAPIVersionOut struct {
}

type Stackframe

type Stackframe struct {
	Location
	Locals    []Variable
	Arguments []Variable

	FrameOffset        int64
	FramePointerOffset int64

	Defers []Defer

	Err string
}

func (*Stackframe) Var

func (frame *Stackframe) Var(name string) *Variable

type Thread

type Thread struct {
	// ID is a unique identifier for the thread.
	ID int `json:"id"`
	// PC is the current program counter for the thread.
	PC uint64 `json:"pc"`
	// File is the file for the program counter.
	File string `json:"file"`
	// Line is the line number for the program counter.
	Line int `json:"line"`
	// Function is function information at the program counter. May be nil.
	Function *Function `json:"function,omitempty"`

	// ID of the goroutine running on this thread
	GoroutineID int `json:"goroutineID"`

	// Breakpoint this thread is stopped at
	Breakpoint *Breakpoint `json:"breakPoint,omitempty"`
	// Informations requested by the current breakpoint
	BreakpointInfo *BreakpointInfo `json:"breakPointInfo,omitempty"`

	// ReturnValues contains the return values of the function we just stepped out of
	ReturnValues []Variable
}

Thread is a thread within the debugged process.

func ConvertThread

func ConvertThread(th proc.Thread) *Thread

ConvertThread converts a proc.Thread into an api thread.

type Variable

type Variable struct {
	// Name of the variable or struct member
	Name string `json:"name"`
	// Address of the variable or struct member
	Addr uintptr `json:"addr"`
	// Only the address field is filled (result of evaluating expressions like &<expr>)
	OnlyAddr bool `json:"onlyAddr"`
	// Go type of the variable
	Type string `json:"type"`
	// Type of the variable after resolving any typedefs
	RealType string `json:"realType"`

	Flags VariableFlags `json:"flags"`

	Kind reflect.Kind `json:"kind"`

	//Strings have their length capped at proc.maxArrayValues, use Len for the real length of a string
	//Function variables will store the name of the function in this field
	Value string `json:"value"`

	// Number of elements in an array or a slice, number of keys for a map, number of struct members for a struct, length of strings
	Len int64 `json:"len"`
	// Cap value for slices
	Cap int64 `json:"cap"`

	// Array and slice elements, member fields of structs, key/value pairs of maps, value of complex numbers
	// The Name field in this slice will always be the empty string except for structs (when it will be the field name) and for complex numbers (when it will be "real" and "imaginary")
	// For maps each map entry will have to items in this slice, even numbered items will represent map keys and odd numbered items will represent their values
	// This field's length is capped at proc.maxArrayValues for slices and arrays and 2*proc.maxArrayValues for maps, in the circumstances where the cap takes effect len(Children) != Len
	// The other length cap applied to this field is related to maximum recursion depth, when the maximum recursion depth is reached this field is left empty, contrary to the previous one this cap also applies to structs (otherwise structs will always have all their member fields returned)
	Children []Variable `json:"children"`

	// 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 `json:"base"`

	// Unreadable addresses will have this field set
	Unreadable string `json:"unreadable"`

	// LocationExpr describes the location expression of this variable's address
	LocationExpr string
	// DeclLine is the line number of this variable's declaration
	DeclLine int64
}

Variable describes a variable.

func ConvertVar

func ConvertVar(v *proc.Variable) *Variable

ConvertVar converts from proc.Variable to api.Variable.

func (*Variable) MultilineString

func (v *Variable) MultilineString(indent string) string

MultilineString returns a representation of v on multiple lines.

func (*Variable) SinglelineString

func (v *Variable) SinglelineString() string

SinglelineString returns a representation of v on a single line.

type VariableFlags added in v1.0.0

type VariableFlags uint16

VariableFlags is the type of the Flags field of Variable.

Jump to

Keyboard shortcuts

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