truffleruby
truffleruby copied to clipboard
TracePoint#new(:call) and TracePoint#new(:c_call): ArgumentError: unknown event
To reproduce:
TracePoint.new(:call)
# or
TracePoint.new(:c_call)
Error:
ArgumentError:
unknown event: call/c_call
This uses Sorbet when srb init is run.
We should map c_call to calls to our builtins and primitives, even though they're written in Java. We probably can't tractably map to what would be a c_call in MRI. I don't know if that's an issue.
I'm not sure if any tool differentiates between :c_call and :call events, I would guess not.
So we could just do nothing on :c_call but trigger :call on any method call.
:call is not yet implemented, though.
In addition, to reproduce:
# ruby -v
truffleruby 20.1.0, like ruby 2.6.5, GraalVM CE Native [x86_64-linux]
TracePoint.new(:end){}
Error:
ArgumentError (unknown event: end)
https://ruby-doc.org/core-2.6.5/TracePoint.html
The TracePoint :call event is also used by byebug:
$ ruby -Iext -Ilib exe/byebug ~/test.rb
<internal:core> core/tracepoint.rb:24:in `block in initialize': unknown event: call (ArgumentError)
from <internal:core> core/tracepoint.rb:19:in `each'
from <internal:core> core/tracepoint.rb:19:in `initialize'
from lib/truffle/truffle/cext.rb:618:in `new'
from lib/truffle/truffle/cext.rb:618:in `rb_tracepoint_new'
from tracepoint.c:8:in `rb_tracepoint_new'
from /home/eregon/code/byebug/ext/byebug/byebug.c:497:in `register_tracepoints'
from /home/eregon/code/byebug/ext/byebug/byebug.c:706:in `Start'
from /home/eregon/code/byebug/ext/byebug/byebug.c:731:in `Debug_load'
from lib/truffle/truffle/cext_ruby.rb:39:in `debug_load'
from /home/eregon/code/byebug/lib/byebug/runner.rb:186:in `debug_program'
from /home/eregon/code/byebug/lib/byebug/runner.rb:103:in `block in run'
from <internal:core> core/kernel.rb:439:in `loop'
from /home/eregon/code/byebug/lib/byebug/runner.rb:102:in `run'
from exe/byebug:6:in `<main>'
This also breaks pry-byebug, and thus pry: running pry with pry-byebug installed makes it die immediately:
ivo.anjo@macieira:~/datadog/dd-trace-rb$ bundle exec pry
bundler: failed to load command: pry (/Users/ivo.anjo/.rvm/gems/truffleruby-head/bin/pry)
<internal:core> core/tracepoint.rb:24:in `block in initialize': unknown event: call (ArgumentError)
Is there maybe a way to "disable plugins" for pry as a workaround?
We seem to have some logic for calls for set_trace_func but not for TracePoint.
We should add support for the TracePoint :call event, it's probably quite some work though (it was for the :class event at least).
Is there maybe a way to "disable plugins" for pry as a workaround?
Yeap, good point. bundle exec pry --no-plugins does the trick indeed :)
For now I've just disabled installing pry-byebug when running in TruffleRuby in https://github.com/DataDog/dd-trace-rb/pull/1406 .
As a note, TruffleRuby already supports a couple debuggers:
- VSCode: https://www.graalvm.org/tools/vscode/graalvm-extension/#ruby-debugging
- Chrome: https://www.graalvm.org/tools/chrome-debugger/
I checked out this issue #1450 and I got error when running the following code. I guess the error is related to this one.
require 'byebug'
byebug
puts 'Hello byebug'
<internal:core> core/tracepoint.rb:24:in `block in initialize': unknown event: call (ArgumentError)
from <internal:core> core/tracepoint.rb:19:in `each'
from <internal:core> core/tracepoint.rb:19:in `initialize'
from /usr/local/lib/truffle/truffle/cext.rb:647:in `rb_tracepoint_new'
from tracepoint.c:17:in `rb_tracepoint_new'
from /usr/local/bundle/gems/byebug-11.1.3/ext/byebug/byebug.c:497:in `register_tracepoints'
from /usr/local/bundle/gems/byebug-11.1.3/ext/byebug/byebug.c:706:in `Start'
from /usr/local/lib/truffle/truffle/cext_ruby.rb:41:in `start'
from /usr/local/bundle/gems/byebug-11.1.3/lib/byebug/attacher.rb:14:in `attach'
from /usr/local/bundle/gems/byebug-11.1.3/lib/byebug/attacher.rb:38:in `byebug'
from a.rb:3:in `<main>'
docker run --rm -it ghcr.io/flavorjones/truffleruby:nightly-slim bash
Ruby version: truffleruby 22.1.0-dev-8d985822, like ruby 3.0.2, GraalVM CE Native [x86_64-linux] using Docker image
byebug (11.1.3)
Yes, byebug doesn't work currently on TruffleRuby, and that error is due to the call/c_call TracePoint not being implemented yet. There are already GUI debuggers for TruffleRuby however: https://github.com/oracle/truffleruby/issues/1672#issuecomment-882436749