Skip to content

runtime: strongly encourage using CallersFrames over FuncForPC with Callers result #19426

@cespare

Description

@cespare

Go 1.7 introduced the CallersFrames API:

The new function CallersFrames translates a PC slice obtained from Callers into a sequence of frames corresponding to the call stack. This new API should be preferred instead of direct use of FuncForPC, because the frame sequence can more accurately describe call stacks with inlined function calls.

I understand that in Go 1.9, mid-stack inlining will make the results significantly worse for callers that are still using FuncForPC instead of CallersFrames. However, in the runtime documentation I don't see anything to steer the user towards one or the other.

Should we mark Func and FuncForPC as deprecated? Is there some situation to use them instead of CallersFrames?

@ianlancetaylor @aclements @davidlazar

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions