Decode "Line" chunk and expand line instructions#51
Merged
Conversation
Pull Request Test Coverage Report for Build 359
💛 - Coveralls |
Line information comes from the "Line" chunk in the beam module. This
is not decoded by `beam_disasm` and the `line` instructions it produces
only have the index inside that "Line" beam chunk.
So far, we needed to get rid of all those `line` instructions because
they were invalid for the compiler. It meant that frames in stacktraces
pointing to an extracted function had no location. This made any sort of
debugging quite difficult.
Here is an example without this patch:
%% Based on the following function:
%% crashing_fun() ->
%% throw("Expected crash").
1> Fun = khepri_fun:to_standalone_fun(fun mod:crashing_fun/0, #{}).
2> khepri_fun:exec(Fun, []).
** exception throw: "Expected crash"
in function kfun__mod__crashing_fun__33048370:run/0
Now, we decode the "Line" beam chunk for each module we need to
disassemble. We then use this decoded table to replace the incomplete
`line` instructions by valid ones.
Thanks to that, we get stacktrace frames with correct locations, making
debugging far easier. Here is the same example as above, but with this
change in place:
1> Fun = khepri_fun:to_standalone_fun(fun mod:crashing_fun/0, #{}).
2> khepri_fun:exec(Fun, []).
** exception throw: "Expected crash"
in function kfun__mod__crashing_fun__33048370:run/0 (.../mod.erl, line 30)
Fixes #50.
dumbbell
force-pushed
the
decode-line-chunk-for-meaningful-staktraces
branch
from
February 15, 2022 13:38
a1d0527 to
4582437
Compare
dumbbell
marked this pull request as ready for review
February 15, 2022 13:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Line information comes from the "Line" chunk in the beam module. This is not decoded by
beam_disasmand thelineinstructions it produces only have the index inside that "Line" beam chunk.So far, we needed to get rid of all those
lineinstructions because they were invalid for the compiler. It meant that frames in stacktraces pointing to an extracted function had no location. This made any sort of debugging quite difficult.Here is an example without this patch:
Now, we decode the "Line" beam chunk for each module we need to disassemble. We then use this decoded table to replace the incomplete
lineinstructions by valid ones.Thanks to that, we get stacktrace frames with correct locations, making debugging far easier. Here is the same example as above, but with this change in place:
Fixes #50.