Documentation ¶
Overview ¶
Package stack implements utilities to capture, manipulate, and format call stacks.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call uintptr
Call records a single function invocation from a goroutine stack. It is a wrapper for the program counter values returned by runtime.Caller and runtime.Callers and consumed by runtime.FuncForPC.
func (Call) Format ¶
Format implements fmt.Formatter with support for the following verbs.
%s source file %d line number %n function name %v equivalent to %s:%d
It accepts the '+' and '#' flags for most of the verbs as follows.
%+s path of source file relative to the compile time GOPATH %#s full path of source file %+n import path qualified function name %+v equivalent to %+s:%d %#v equivalent to %#s:%d
type Trace ¶
type Trace []Call
Trace records a sequence of function invocations from a goroutine stack.
func Callers ¶
func Callers() Trace
Callers returns a Trace for the current goroutine with element 0 identifying the calling function.
func (Trace) Format ¶
Format implements fmt.Formatter by printing the Trace as square brackes ([, ]) surrounding a space separated list of Calls each formatted with the supplied verb and options.
func (Trace) TrimAboveName ¶
TrimAboveName returns a slice of the Trace with all entries above the highest with function name name removed.
func (Trace) TrimBelowName ¶
TrimBelowName returns a slice of the Trace with all entries below the lowest with function name name removed.
Notes ¶
Bugs ¶
Subtracting one from pc is a work around for https://code.google.com/p/go/issues/detail?id=7690. The idea for this work around comes from rsc's initial patch at https://codereview.appspot.com/84100043/#ps20001, but as noted in the issue discussion, it is not a complete fix since it doesn't handle some cases involving signals. Just the same, it handles all of the other cases I have tested.