MCPcopy Create free account
hub / github.com/chain/Core / getStack

Function getStack

errors/stack.go:33–51  ·  view source on GitHub ↗

getStack is a formatting wrapper around runtime.Callers. It returns a stack trace in the form of a StackFrame slice.

(skip int, size int)

Source from the content-addressed store, hash-verified

31// getStack is a formatting wrapper around runtime.Callers. It returns a stack
32// trace in the form of a StackFrame slice.
33func getStack(skip int, size int) []StackFrame {
34 var (
35 pc = make([]uintptr, size)
36 calls = runtime.Callers(skip+1, pc)
37 trace []StackFrame
38 )
39
40 for i := 0; i < calls; i++ {
41 f := runtime.FuncForPC(pc[i])
42 file, line := f.FileLine(pc[i] - 1)
43 trace = append(trace, StackFrame{
44 Func: f.Name(),
45 File: file,
46 Line: line,
47 })
48 }
49
50 return trace
51}

Callers 1

wrapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected