Skip to content

runtime: use AST-derivable names for Frame.Function names #77392

Description

@dsnet

Go version

go1.25.6

Output of go env in your module/workspace:

n/a

What did you do?

I want to reverse lookup a runtime.Function name back to the original Go source declaration.

What did you see happen?

Today, the exact runtime.Function name too closely matches what the backend compiler chose to do rather than being more closely associated with what the Go AST declares.

For example, if you have a qualified function symbol named path/to/package.FooFunc and it inlines another function named InlinedFunc, the symbol chosen might be something like path/to/package.FooFunc.InlinedFunc. This does produce a unique symbol name, but it is somewhat deceptive since it makes it look like InlinedFunc is declared within FooFunc (which it isn't, it just happens to be inlined). Also the numbering of anonymous functions is not simply numeration based on declaration order in a function, but also affected by how inlining occurred.

What did you expect to see?

My desire is that the function names can be primarily derived purely from the AST of the Go package, rather than depending on artifacts of the backend compiler such as inlining. Thus, looking up a function name would be possible purely by analyzing the Go source code without needing to build the Go binary and use go tool objdump to extract the exact symbol names. This perhaps implies that there is a helper function in the Go AST to derive a stable base name for a declaration that would be used both by the compiler backend and also be Go tools that want to reverse lookup a function by name.

Understandably, the backend compiler may need to emit unique instantiations of a function (e.g., for inlining or type parameterization), which then requires unique symbol names. I suspect that unique names can be derived by amending the base name in such a way that syntactic parsing can remove those alterations. For example, type instantiation always occurs in [...], which can be syntactically parsed and removed.

I don't have a concrete proposal for the exact naming convention, but just wanted to state the desired outcome.

\cc @adonovan @prattmic @aclements

Metadata

Metadata

Assignees

No one assigned

    Labels

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions