Partially fix set_trace_func line numbers #4052
Merged
+14
−1
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.
After reporting issue #4051 I decided to look at the generated IR and noticed that trace instructions were being added without line numbers. This led to the observed issue where stack traces generated inside
set_trace_func
did not have the correct line numbers.For the
LINE
andCALL
events the fix is straightforward: just add a line number instruction before the trace instruction, as the line number was already known statically by theIRBuilder
.Unfortunately, for the
RETURN
andEND
events the parser does not include this information and thus there's no simple way of adding line number instructions before those. I think that particular fix is a bit beyond my capabilities so I added someFIXME
s so at least this doesn't get forgotten.Nevertheless, and happily, the partial fix seems to be enough to get
pry-nav
to work!On a side note, I must admit that

but nevertheless for a first time diving inside JRuby's codebase, this went better than expected 😄
Please let me know if there's some way I can help fix this further!
Issue #4051