github.com/phuslu/log@v1.0.100/runtime.go (about) 1 package log 2 3 import ( 4 "unsafe" 5 ) 6 7 type funcInfo struct { 8 _func unsafe.Pointer 9 datap unsafe.Pointer //nolint:unused 10 } 11 12 //go:linkname findfunc runtime.findfunc 13 func findfunc(pc uintptr) funcInfo 14 15 //go:linkname funcInfoEntry runtime.funcInfo.entry 16 func funcInfoEntry(f funcInfo) uintptr 17 18 //go:linkname funcline1 runtime.funcline1 19 func funcline1(f funcInfo, targetpc uintptr, strict bool) (file string, line int32) 20 21 func pcFileLine(pc uintptr) (file string, line int32) { 22 funcInfo := findfunc(pc) 23 if funcInfo._func == nil { 24 return 25 } 26 27 entry := funcInfoEntry(funcInfo) 28 29 if pc > entry { 30 // We store the pc of the start of the instruction following 31 // the instruction in question (the call or the inline mark). 32 // This is done for historical reasons, and to make FuncForPC 33 // work correctly for entries in the result of runtime.Callers. 34 pc-- 35 } 36 37 return funcline1(funcInfo, pc, false) 38 }