Documentation ¶
Overview ¶
Package locspec implements code to parse a string into a specific location specification.
Location spec examples:
locStr ::= <filename>:<line> | <function>[:<line>] | /<regex>/ | (+|-)<offset> | <line> | *<address> * <filename> can be the full path of a file or just a suffix * <function> ::= <package>.<receiver type>.<name> | <package>.(*<receiver type>).<name> | <receiver type>.<name> | <package>.<name> | (*<receiver type>).<name> | <name> * <function> must be unambiguous * /<regex>/ will return a location for each function matched by regex * +<offset> returns a location for the line that is <offset> lines after the current line * -<offset> returns a location for the line that is <offset> lines before the current line * <line> returns a location for a line in the current file * *<address> returns the location corresponding to the specified address
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddrLocationSpec ¶
type AddrLocationSpec struct {
AddrExpr string
}
AddrLocationSpec represents an address when used as a location spec.
type AmbiguousLocationError ¶
type AmbiguousLocationError struct { Location string CandidatesString []string CandidatesLocation []api.Location }
AmbiguousLocationError is returned when the location spec should only return one location but returns multiple instead.
func (AmbiguousLocationError) Error ¶
func (ale AmbiguousLocationError) Error() string
type FuncLocationSpec ¶
type FuncLocationSpec struct { PackageName string AbsolutePackage bool ReceiverName string PackageOrReceiverName string BaseName string }
FuncLocationSpec represents a function in the target program.
type LineLocationSpec ¶
type LineLocationSpec struct {
Line int
}
LineLocationSpec represents a line number in the current file.
type LocationSpec ¶
type LocationSpec interface { // Find returns all locations that match the location spec. Find(t *proc.Target, processArgs []string, scope *proc.EvalScope, locStr string, includeNonExecutableLines bool) ([]api.Location, error) }
LocationSpec is an interface that represents a parsed location spec string.
func Parse ¶
func Parse(locStr string) (LocationSpec, error)
Parse will turn locStr into a parsed LocationSpec.
type NormalLocationSpec ¶
type NormalLocationSpec struct { Base string FuncBase *FuncLocationSpec LineOffset int }
NormalLocationSpec represents a basic location spec. This can be a file:line or func:line.
func (*NormalLocationSpec) FileMatch ¶
func (loc *NormalLocationSpec) FileMatch(path string) bool
FileMatch is true if the path matches the location spec.
func (*NormalLocationSpec) Find ¶
func (loc *NormalLocationSpec) Find(t *proc.Target, processArgs []string, scope *proc.EvalScope, locStr string, includeNonExecutableLines bool) ([]api.Location, error)
Find will return a list of locations that match the given location spec. This matches each other location spec that does not already have its own spec implemented (such as regex, or addr).
type OffsetLocationSpec ¶
type OffsetLocationSpec struct {
Offset int
}
OffsetLocationSpec represents a location spec that is an offset of the current location (file:line).
type RegexLocationSpec ¶
type RegexLocationSpec struct {
FuncRegex string
}
RegexLocationSpec represents a regular expression location expression such as /^myfunc$/.
func (*RegexLocationSpec) Find ¶
func (loc *RegexLocationSpec) Find(t *proc.Target, _ []string, scope *proc.EvalScope, locStr string, includeNonExecutableLines bool) ([]api.Location, error)
Find will search all functions in the target program and filter them via the regex location spec. Only functions matching the regex will be returned.