NewStackFrame popoulates a stack frame object from the program counter.
(pc uintptr)
| 26 | |
| 27 | // NewStackFrame popoulates a stack frame object from the program counter. |
| 28 | func NewStackFrame(pc uintptr) (frame StackFrame) { |
| 29 | |
| 30 | frame = StackFrame{ProgramCounter: pc} |
| 31 | if frame.Func() == nil { |
| 32 | return |
| 33 | } |
| 34 | frame.Package, frame.Name = packageAndName(frame.Func()) |
| 35 | |
| 36 | // pc -1 because the program counters we use are usually return addresses, |
| 37 | // and we want to show the line that corresponds to the function call |
| 38 | frame.File, frame.LineNumber = frame.Func().FileLine(pc - 1) |
| 39 | return |
| 40 | |
| 41 | } |
| 42 | |
| 43 | // Func returns the function that contained this frame. |
| 44 | func (frame *StackFrame) Func() *runtime.Func { |
no test coverage detected
searching dependent graphs…