From: gsamokovarov@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92338] [Ruby trunk Feature#15778] Expose an API to pry-open the stack frames in Ruby
Date: Sat, 20 Apr 2019 02:27:49 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-15778.20190420022749.0c155f1534e4ca63@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15778.20190420022749@ruby-lang.org
Issue #15778 has been reported by gsamokovarov (Genadi Samokovarov).
----------------------------------------
Feature #15778: Expose an API to pry-open the stack frames in Ruby
https://bugs.ruby-lang.org/issues/15778
* Author: gsamokovarov (Genadi Samokovarov)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Hello,
I'm the maintainer of the web-console (https://github.com/rails/web-console/) gem, where one of our features is to jump between the frames in which an error occurred. To accomplish this, I currently use the Debug Inspector CRuby API. I think we expose this functionality in Rubyland, so tools like web-console don't need to resort to C code for this. This also makes it quite harder for me to support different implementations like JRuby or TruffleRuby as everyone is having a different way to create Ruby Binding objects that represent the frames.
Here the API ideas:
Add `Thread::Backtrace::Location#binding` method that can create a binding for a specific caller of the current frame. We can reuse the existing `Kernel.caller_locations` method to generate the array of `Thread::Backtrace::Location` objects. We can optionally have the `Kernel.caller_locations(debug: true)` argument if we cannot generate the bindings lazily on the VM that can instruct the VM to do the slower operation.
- `Thread::Backtrace::Location#binding` returns `Binding|nil`. Nil result may mean that the current location is a C frame or a JITted/optimized frame and we cannot debug it.
We can also expose the DebugInspector API directly, as done in the https://github.com/banister/debug_inspector gem, but for tools like web-console, we'd need to map the bindings with the backtrace, as we cannot generate Bindings for every frame (C frames) and this needs to be done in application code, so I think the `Thread::Backtrace::Location#binding` is the better API for Ruby-land.
Such API can help us eventually write most of our debuggers in Ruby as right now we don't have a way to do Post-Mortem debugging without native code or even start our debuggers without monkey-patching `Binding`.
I have presented this idea in a RubyKaigi's 2019 talk called "Writing Debuggers in Plain Ruby", you can check-out the slides for more context: http://kaigi-debuggers-in-ruby.herokuapp.com.
--
https://bugs.ruby-lang.org/
next parent reply other threads:[~2019-04-20 2:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15778.20190420022749@ruby-lang.org>
2019-04-20 2:27 ` gsamokovarov [this message]
2019-04-20 10:21 ` [ruby-core:92340] [Ruby trunk Feature#15778] Expose an API to pry-open the stack frames in Ruby chris
2019-04-20 14:36 ` [ruby-core:92345] " eregontp
2019-04-20 14:43 ` [ruby-core:92346] " eregontp
2019-04-20 15:12 ` [ruby-core:92347] " chris
2019-04-20 15:49 ` [ruby-core:92348] " gsamokovarov
2019-04-24 7:46 ` [ruby-core:92397] " ko1
2019-04-26 13:55 ` [ruby-core:92420] " eregontp
2019-04-29 16:22 ` [ruby-core:92480] " gsamokovarov
2019-05-15 9:10 ` [ruby-core:92654] " eregontp
2019-07-14 6:05 ` [ruby-core:93746] [Ruby master " ko1
2019-07-31 9:37 ` [ruby-core:94069] " eregontp
2019-08-29 6:24 ` [ruby-core:94647] " duerst
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-15778.20190420022749.0c155f1534e4ca63@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).