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
runtime.Func.FileLine() returns the wrong line number #754
Labels
Comments
The functions symtab.c:/^funcline and extern.go:/FileLine appear to have comments, that if you edit one of them, you should edit also the other. The code looks too cryptic for me to tell whether the two functions do the same thing or not. Somebody should add an automated test which makes sure that both of the functions do the same thing, to avoid the implementations from drifting apart. Even better would be to implement one of them by calling the other - that would remove the duplicated code. |
It seems, that the bug is around here: runtime/extern.go: func (f *Func) FileLine(pc uintptr) const PcQuant = 1 because in symtab.c:/^funcline there is: int32 pcquant; switch(thechar) { case '5': pcquant = 4; break; default: // 6, 8 pcquant = 1; break; } i found, that 'thechar' is information about compiler: $GO/src/pkg/runtime% grep -r thechar . ./amd64/arch.h: thechar = '6' ./386/arch.h: thechar = '8' ./arm/arch.h: thechar = '5' but i don't know how to get the same info in go |
I found an off-by-one in the line numbers reported by FuncLine(). I've reported it as a separate issue: https://golang.org/issue/1100 I still think that the best solution would be to refactor the code to remove the code duplication between extern.go and symtab.c. That would eliminate one "bug breeding ground" as mentioned in http://jamesshore.com/Agile-Book/no_bugs.html Now that same copy-pasted function has resulted already in two bugs. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by esko.luontola:
The text was updated successfully, but these errors were encountered: