[go-nuts] Re: runtime CallerFrames and FuncForPC miss some infomation

2019-02-24 Thread qiaojiawei-star
thanks for replay, you said right, i have changed the code, its works fine, thank you, here is code: package main import ( "fmt" "runtime" ) func test() { var zero = 0 _ = 1 / zero } func Stack() { var pc [16]uintptr n := runtime.Callers(0, pc[:]) fmt.Println(n, pc) callers := pc[:n] frames :

[go-nuts] Re: runtime CallerFrames and FuncForPC miss some infomation

2019-02-18 Thread 'Keith Randall' via golang-nuts
FuncForPC misses the test function because it is inlined. Using FuncForPC on the results of Callers does not work correctly in the presence of inlining. That is essentially why CallersFrames was introduced. The function name is missing because you're using the wrong expression for it. You shoul