Hi everyone,

I know by reading the docs (and lists, and every resource out there) that 
the output of runtime.Callers is meant to be used with 
runtime.CallersFrames, but I'm curious to learn in which cases using 
FuncForPC with the PCs returned by Callers (minus 1) would produce 
different results if all I care for is filename, line number and function, 
in a non-CGO environment (I'm not sure if this would make any change).

By the docs I read, it would be possible that using FuncForPC on the 
results of Callers may not appropriately account for inlined functions. By 
reading the latest code of runtime, I found that it would appear to account 
for inlined functions with the inline unwinder, although the treatment is 
different as that which is made in (*Frames).Next(), I presume since it 
creates a "fake" *Func.

My curiosity comes from reading the code of https://github.com/pkg/errors, 
which even being archived appears to still be extensively used, and it uses 
Callers and FuncForPC (with PC-1) and appears to work just fine. I also 
made a small test myself and found that both methods would report the same 
stack trace: https://go.dev/play/p/zGzOV6CdAx4

So I'm not interested in doing the opposite as what the documentation says, 
but rather learn about whether it would still be safe to use packages that 
still import https://github.com/pkg/errors and rely on its Stack tracing 
feature.

Thanks everyone for your time, kind regards

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/25bf3417-1092-4962-851a-278263e1f6d1n%40googlegroups.com.

Reply via email to