-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[WIP] Add file:line information to backtraces #3170
[WIP] Add file:line information to backtraces #3170
Conversation
8254de3
to
3742178
Compare
Now with better commits that should be easier to read :) |
This requires the executable to be built with `--debug` to include the necessary information. Also requires the `addr2line` executable to be installed on the machine running the binary, otherwise the unhelpful `?:?` will be printed instead. Somewhat demangles symbols to remove the pointers (`*` and `~`) as well as the return type so it's easier to read. Doesn't touch the `print_backtrace` methods that will continue to report the raw backtrace. closes crystal-lang#1270
Skips any call in the callstack originating from the src/exception.cr and src/callstack.cr files that are implementation details. closes crystal-lang#3161
3742178
to
0325453
Compare
And now with support for I can't figure why CI fails so badly. I can't reproduce any of the errors 😢 |
It seems a bug in libevent (searched from Google) |
@ysbaddaden this is great! Is there any use case for keeping the hexadecimal (address?) at the beginning of the line? |
I don't know why it fails, but if I run this snippet of code: # foo.cr
raise "OH NO!"
So that probably means there's something missing in the implementation.,, |
I guess the "open the file then pass addresses as stdin" is quirky, or it should catch some errno. I'll revert to a basic "pass addresses as CLI args". @mverzilli thats the raw symbols address. It's nit useful to most people, but maybe some would like it, so they hexdump the binary and follow what ASM is doing? I'm not sure. |
The problem is actually within |
@asterite it doesn't hang on Linux, but crashes in SignalHandler while receiving the |
I found the issue and it lies in Dropping the I wonder, thought, why the |
Closed in favor of #3303. |
This is an example of using
addr2line
/atos
for exception backtraces (and caller). This is only tested on Linux (whereaddr2line
is provided bybinutils). It doesn't fail when
addr2lineis unavailable but prints
??:?`. Untested on OSX but should work too.This requires the debug mode because debug location tables must be added to the executable. It could be nice to always add the file:line information, whatever the debug mode. This is easy to enable and doesn't increases the executable much (roughly 5%) but the compiler specs fail badly.
I added skips for whatever relates to some files (exceptions) to filter the backtrace from internal implementation details.
We should eventually have an executable parser (eg. ELF parser) capable to extract this information itself. But this
is HARD work andwill have to be duplicated for each platform (edit: actually it's not hard).