-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Labels
Description
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:
debug_inspector/test/basic_test.rb
Lines 5 to 7 in 582251c
| @offset = DebugInspector.open do |dc| | |
| dc.backtrace_locations.index { |loc| loc.path == __FILE__ and loc.label == "setup" } | |
| end |