Documentation ¶
Index ¶
- func NewStack(skipFrames int) (stack parl.Stack)
- func ParseCreatedLine(createdLine []byte) (funcName string, IsMainThread bool)
- func ParseFileLine(fileLine []byte) (file string, line int)
- func ParseFirstLine(debugStack []byte) (ID parl.ThreadID, status parl.ThreadStatus, err error)
- func ParseFuncLine(funcLine []byte) (funcName string, args string)
- type Frame
- type Stack
- func (s *Stack) Creator() (creator *pruntime.CodeLocation)
- func (s *Stack) Frames() (frames []parl.Frame)
- func (s *Stack) GoFunction() (goFunction *pruntime.CodeLocation)
- func (s *Stack) ID() (threadID parl.ThreadID)
- func (s *Stack) IsMain() (isMainThread bool)
- func (s *Stack) MostRecentFrame() (frame parl.Frame)
- func (s *Stack) SetCreator(creator *pruntime.CodeLocation, isMainThread bool)
- func (s *Stack) SetFrames(frames []parl.Frame)
- func (s *Stack) SetID(threadID parl.ThreadID, status parl.ThreadStatus)
- func (s *Stack) Shorts(prepend string) (shorts string)
- func (s *Stack) Status() (status parl.ThreadStatus)
- func (s *Stack) String() (str string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStack ¶
NewStack populates a Stack object with the current thread and its stack using debug.Stack
func ParseCreatedLine ¶
ParseCreatedLine parses the second-to-last line of the stack trace. samples:
- “created by main.main”
- “created by main.(*MyType).goroutine1”
- “main.main()”
func ParseFileLine ¶
ParseFileLine parses a line of a tab character then absolue file path, followed by a colon and line number, then a space character and a byte offset.
"\t/gp-debug-stack/debug-stack.go:29 +0x44" "\t/opt/sw/parl/g0/waiterr.go:49"
func ParseFirstLine ¶
getID obtains gorutine ID, as of go1.18 a numeric string "1"…
func ParseFuncLine ¶
ParseFuncLine parses a line of a package name, optionally fully qualified, and a possible receiver type name and a function name, followed by a parenthesised argument list. samples:
main.main() main.(*MyType).goroutine1(0x0?, 0x140000120d0, 0x2) codeberg.org/haraldrudell/goprogramming/std/runtime-debug/gp-debug-stack/mypackage.Fn(...)
Types ¶
type Frame ¶
type Frame struct { pruntime.CodeLocation // contains filtered or unexported fields }
Frame represents an executing code location, ie. a code line in source code
- parl.Frame is similar to runtime.Frame returned by runtime.CallersFrames but has only basic types, ie. can be stored or transferred
- pdebug.Frame implements parl.Frame
- Frame is a value container only created by pdebug.NewStack. Frame extends pruntime.CodeLocation with argument values
func (*Frame) Args ¶
function argument values like "(1, 0x14000113040)"
- values of basic types like int are displayed
- most types appear as a pointer value “0x…”
func (*Frame) Loc ¶
func (f *Frame) Loc() (location *pruntime.CodeLocation)
the code location for this frame, never nil
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
- Go stack traces are created by runtime.Stack and is a byte slice
- [debug.Stack] repeatedly calls runtime.Stack with an increased buffer size that is eventually returned
- [debug.PrintStack] writes the byte stream to os.Stderr
- interning large strings is a temporary memory leak. Converting the entire byte-slice stack-trace to string retains the memory for as long as there is a reference to any one character. This leads to megabytes of memory leaks
func (*Stack) Creator ¶
func (s *Stack) Creator() (creator *pruntime.CodeLocation)
func (*Stack) GoFunction ¶ added in v0.4.92
func (s *Stack) GoFunction() (goFunction *pruntime.CodeLocation)
func (*Stack) MostRecentFrame ¶ added in v0.4.92
func (*Stack) SetCreator ¶
func (s *Stack) SetCreator(creator *pruntime.CodeLocation, isMainThread bool)
SetCreator is used if Stack is for a goroutine
- describing whether it is the main thread
- if a gouroutine, where the launching go statement was located
func (*Stack) SetID ¶
func (s *Stack) SetID(threadID parl.ThreadID, status parl.ThreadStatus)
SetID updates goroutine ID and thread status from the stack trace status line
func (*Stack) Status ¶
func (s *Stack) Status() (status parl.ThreadStatus)