-
Notifications
You must be signed in to change notification settings - Fork 18k
reflect: add method to obtain function name #3901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
gccgo has runtime.FuncForPC. The results may not be what people expect, as for various reasons there can be 1, 2, or even 3 variants of a function in gccgo, and they all get different names. The program above prints this with gccgo: main f2$descriptorfn returned G main f5$descriptorfn returned O main f3$descriptorfn returned L main f1$descriptorfn returned A main f4$descriptorfn returned N main f2$descriptorfn returned G main $nested0$descriptorfn returned ! I could probably rationalize the names in some way, perhaps even in FuncForPC. |
I am not sure I want to add this to reflect. In general it may not be possible to give the correct name, if two functions with identical bodies are merged into one symbol. I think runtime.FuncForPC possibly giving back weird information in the face of optimizations is much more defensible than reflect doing it. runtime is what it is, but reflect should be 100% accurate. If we do put this into reflect I think we'd be compelled to disable that kind of optimization. Labels changed: added go1.3maybe, removed go1.2maybe. Status changed to Thinking. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: