Skip to content
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

Use an offset to hide extra frames on TruffleRuby? #40

Open
eregon opened this issue Dec 12, 2023 · 0 comments
Open

Use an offset to hide extra frames on TruffleRuby? #40

eregon opened this issue Dec 12, 2023 · 0 comments

Comments

@eregon
Copy link
Collaborator

eregon commented Dec 12, 2023

Currently:

$ ruby -v -rdebug_inspector -e 'tap { 1.times { DebugInspector.open { |dc| pp dc.backtrace_locations; p dc.frame_binding(1) } } }'
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
["-e:1:in `open'",
 "-e:1:in `block (2 levels) in <main>'",
 "-e:1:in `times'",
 "-e:1:in `block in <main>'",
 "<internal:kernel>:90:in `tap'",
 "-e:1:in `<main>'"]
#<Binding:0x00007fa9fa275dc0>
$ ruby -v -rdebug_inspector -e 'tap { 1.times { DebugInspector.open { |dc| pp dc.backtrace_locations; p dc.frame_binding(3) } } }'
truffleruby 24.0.0-dev-4cd14c48, like ruby 3.2.2, GraalVM CE Native [x86_64-linux]
["/home/eregon/.rubies/truffleruby-dev/lib/truffle/truffle/cext.rb:1750:in `rb_ensure'",
 "exception.c:107:in `rb_ensure'",
 "/home/eregon/.rubies/truffleruby-dev/lib/truffle/truffle/cext_ruby.rb:40:in `open'",
 "-e:1:in `block (2 levels) in <main>'",
 "<internal:core> core/integer.rb:148:in `times'",
 "-e:1:in `block in <main>'",
 "<internal:core> core/kernel.rb:517:in `tap'",
 "-e:1:in `<main>'"]
#<Binding:0xbf8>

So there are 2 more frames on TruffleRuby due to the call to rb_ensure() which is actually part of the stacktrace, unlike on CRuby.

We could potentially try to apply an offset in this C extension to hide this.
OTOH, people might want to filter the open call and maybe even some callers, in which case such filtering code would work for both without any changes.
Example of such filtering:

@offset = DebugInspector.open do |dc|
dc.backtrace_locations.index { |loc| loc.path == __FILE__ and loc.label == "setup" }
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant