https://redmine.ruby-lang.org/
https://redmine.ruby-lang.org/favicon.ico?1711330511
2012-10-25T20:29:33Z
Ruby Issue Tracking System
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=31551
2012-10-25T20:29:33Z
ko1 (Koichi Sasada)
<ul></ul><p>Thank you for your comment.</p>
<p>I want to support debugging feature, but my hands doesn't work on it yet.</p>
<p>Does "debugging feature" guru attend RubyConf2012 next week?<br>
I will attend it.<br>
If there is (are), I want to finish a design (and an implementation I<br>
hope) about it for 2.0.</p>
<p>Thanks,<br>
Koichi</p>
<p>(2012/10/25 19:46), banister (john mair) wrote:</p>
<blockquote>
<p>Issue <a class="issue tracker-1 status-8 priority-4 priority-default closed" title="Bug: Ruby 2.0 breaks support for some debugging tools (Third Party's Issue)" href="https://redmine.ruby-lang.org/issues/7214">#7214</a> has been reported by banister (john mair).</p>
<hr>
<p>Bug <a class="issue tracker-1 status-8 priority-4 priority-default closed" title="Bug: Ruby 2.0 breaks support for some debugging tools (Third Party's Issue)" href="https://redmine.ruby-lang.org/issues/7214">#7214</a>: Ruby 2.0 breaks support for some debugging tools<br>
<a href="https://bugs.ruby-lang.org/issues/7214" class="external">https://bugs.ruby-lang.org/issues/7214</a></p>
<p>Author: banister (john mair)<br>
Status: Open<br>
Priority: Normal<br>
Assignee:<br>
Category:<br>
Target version:<br>
ruby -v: ruby 2.0.0dev (2012-10-18 trunk 37260) [x86_64-linux]</p>
<p>Notably the "Pry" debugger breaks, and (though i haven't checked) I'm assuming the 'debugger' project as well. The reason for the breakages (as far as i can see) is that the <code>rb_vm_make_env_object</code> function is now hidden. In the comments for 1.9.3's vm.c it was stated an alternative API for <code>rb_vm_make_env_object</code> (see <a href="https://github.com/ruby/ruby/blob/ruby_1_9_3/vm.c#L53-60" class="external">https://github.com/ruby/ruby/blob/ruby_1_9_3/vm.c#L53-60</a>) would be provided, but I have been unable to find one.</p>
<p>Can you please inform me of where I can find the new API (if it exists), or alternatively, provide a work-around so we can get the debuggers working on Ruby 2.0</p>
<p>Thanks</p>
</blockquote>
<p>--<br>
// SASADA Koichi at atdot dot net</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=31731
2012-10-27T09:30:46Z
ko1 (Koichi Sasada)
<ul><li><strong>Category</strong> set to <i>core</i></li><li><strong>Assignee</strong> set to <i>ko1 (Koichi Sasada)</i></li><li><strong>Target version</strong> set to <i>2.0.0</i></li></ul>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=31827
2012-10-28T05:14:41Z
banister (john mair)
jrmair@gmail.com
<ul></ul><p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/17">@ko1 (Koichi Sasada)</a></p>
<p>Unfortunately I can't make it to rubconf2012.</p>
<p>What we need for Ruby 2.0 is the <code>binding_of_caller</code> gem working (<a href="https://github.com/banister/binding_of_caller/blob/ruby-2.0/ext/binding_of_caller/binding_of_caller.c" class="external">https://github.com/banister/binding_of_caller/blob/ruby-2.0/ext/binding_of_caller/binding_of_caller.c</a> ). We need to generate Binding objects from parent frames further up the call-stack, and it looks like the thing stopping us in Ruby 2.0 is the visibility of the <code>rb_vm_make_env_object</code> function.</p>
<p>We are using this <code>binding_of_caller</code> functionality to great effect in the pry-rescue (<a href="https://github.com/conradirwin/pry-rescue" class="external">https://github.com/conradirwin/pry-rescue</a> ) and pry-stack_explorer (<a href="https://github.com/pry/pry-stack_explorer" class="external">https://github.com/pry/pry-stack_explorer</a> ) projects, they allow some very powerful smalltalk-style workflows, and it would be a great shame if they can't work in 2.0 as they work brilliantly in Ruby 1.9.2-1.9.3 currently.</p>
<p>I am willing to help in any way possible to make this a reality for Ruby 2.0, just let me know what you need.</p>
<p>Thanks!</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=31828
2012-10-28T05:29:11Z
ko1 (Koichi Sasada)
<ul></ul><p>(2012/10/28 5:14), banister (john mair) wrote:</p>
<blockquote>
<p>Unfortunately I can't make it to rubconf2012.</p>
<p>What we need for Ruby 2.0 is the <code>binding_of_caller</code> gem working (<a href="https://github.com/banister/binding_of_caller/blob/ruby-2.0/ext/binding_of_caller/binding_of_caller.c" class="external">https://github.com/banister/binding_of_caller/blob/ruby-2.0/ext/binding_of_caller/binding_of_caller.c</a>). We need the ability to grab bindings from parent frames up the call-stack.</p>
<p>We are using this <code>binding_of_caller</code> functionality to great effect in the pry-rescue (<a href="https://github.com/conradirwin/pry-capture" class="external">https://github.com/conradirwin/pry-capture</a>) and pry-stack_explorer (<a href="https://github.com/pry/pry-stack_explorer" class="external">https://github.com/pry/pry-stack_explorer</a>) projects, they allow some very powerful workflows, and it would be a real shame if they can't work in 2.0 as they work brilliantly in Ruby 1.9.2-1.9.3 currently.</p>
<p>I am willing to help in any way possible to make this a reality for Ruby 2.0, just let me know what you need.</p>
</blockquote>
<p>Thank you. It is great information for me.<br>
Can I find API description?</p>
<p>--<br>
// SASADA Koichi at atdot dot net</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=31864
2012-10-28T21:08:54Z
banister (john mair)
jrmair@gmail.com
<ul></ul><p>The API is this:</p>
<a name="class-methods"></a>
<h2 >class methods<a href="#class-methods" class="wiki-anchor">¶</a></h2>
<a name="return-the-binding-for-the-nth-caller-where-Bindingof_caller0-binding"></a>
<h1 >return the binding for the nth caller, where Binding.of_caller(0) == binding<a href="#return-the-binding-for-the-nth-caller-where-Bindingof_caller0-binding" class="wiki-anchor">¶</a></h1>
<p>Binding.of_caller(n)</p>
<a name="return-an-array-of-all-the-caller-bindings-this-is-useful-when-you-want-to-take-a-snap-shot-of-the-entire-call-stack-for-later-inspection-as-in-pry-rescue"></a>
<h1 >return an array of all the caller bindings (this is useful when you want to take a snap-shot of the entire call stack for later inspection, as in pry-rescue)<a href="#return-an-array-of-all-the-caller-bindings-this-is-useful-when-you-want-to-take-a-snap-shot-of-the-entire-call-stack-for-later-inspection-as-in-pry-rescue" class="wiki-anchor">¶</a></h1>
<p>Binding.callers</p>
<a name="The-number-of-frames-currently-on-the-stack"></a>
<h1 >The number of frames currently on the stack<a href="#The-number-of-frames-currently-on-the-stack" class="wiki-anchor">¶</a></h1>
<p>Binding.frame_count</p>
<a name="instance-methods"></a>
<h2 >instance methods<a href="#instance-methods" class="wiki-anchor">¶</a></h2>
<a name="the-frame-type-eg-block-class-top-lambda-method-ie-VM_FRAME_MAGIC_METHOD"></a>
<h1 >the frame type, e.g :block, :class, :top, :lambda, :method i.e VM_FRAME_MAGIC_METHOD<a href="#the-frame-type-eg-block-class-top-lambda-method-ie-VM_FRAME_MAGIC_METHOD" class="wiki-anchor">¶</a></h1>
<p>Binding#frame_type</p>
<a name="The-frame-description-ie-cfp-gtiseq-gtname-on-193-returns-stuff-like-block-in-my_method"></a>
<h1 >The frame description, i.e cfp->iseq->name on 1.9.3, returns stuff like "block in my_method"<a href="#The-frame-description-ie-cfp-gtiseq-gtname-on-193-returns-stuff-like-block-in-my_method" class="wiki-anchor">¶</a></h1>
<p>Binding#frame_description</p>
<p>Note that we skip some frames (such as VM_FRAME_MAGIC_IFUNC) as introspecting on them appears to return junk data.</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=31865
2012-10-28T21:23:33Z
ko1 (Koichi Sasada)
<ul></ul><p>Thank you for your explanation.</p>
<p>(2012/10/28 21:08), banister (john mair) wrote:</p>
<blockquote>
<a name="return-the-binding-for-the-nth-caller-where-Bindingof_caller0-binding"></a>
<h1 >return the binding for the nth caller, where Binding.of_caller(0) == binding<a href="#return-the-binding-for-the-nth-caller-where-Bindingof_caller0-binding" class="wiki-anchor">¶</a></h1>
<p>Binding.of_caller(n)</p>
</blockquote>
<p>`Kernel.binding' can't return binding of CFUNC.<br>
Is it enough?</p>
<p>--<br>
// SASADA Koichi at atdot dot net</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=31882
2012-10-28T22:59:06Z
banister (john mair)
jrmair@gmail.com
<ul></ul><p>No problem, our current code skips CFUNC frames too :)</p>
<p>Are you thinking of exposing this API to Ruby (in core or stdlib) or just as a C API ?</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=31892
2012-10-29T00:23:10Z
ko1 (Koichi Sasada)
<ul></ul><p>(2012/10/28 22:59), banister (john mair) wrote:</p>
<blockquote>
<p>No problem, our current code skips CFUNC frames too :)</p>
</blockquote>
<p>Okay.</p>
<blockquote>
<p>Are you thinking of exposing this API to Ruby (in core or stdlib) or just as a C API ?</p>
</blockquote>
<p>I think it should be C API at Ruby 2.0.</p>
<p>or exposed on RubyVM::... (MRI, ruby 2.0 specific)?</p>
<p>--<br>
// SASADA Koichi at atdot dot net</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=32925
2012-11-15T21:31:03Z
ko1 (Koichi Sasada)
<ul></ul><p>=begin<br>
[PLEASE REVIEW!!]</p>
<p>= Abstract</p>
<p>I made debugger support interface.<br>
<a href="https://github.com/ko1/ruby/compare/debugger_api" class="external">https://github.com/ko1/ruby/compare/debugger_api</a></p>
<p>Currently, no docs, no tests.</p>
<p>Sorry for my laziness.</p>
<p>Please review it.</p>
<p>= Background</p>
<p>Generally, debugger needs two features.</p>
<p>(1) Flow (execution) control API<br>
(2) Inpsection API</p>
<p>For (1), inserting breakpoints, watch points and so on.<br>
However, I don't touch these features because of no time to discuss.<br>
(set_trace_func and TracePoint will help it)</p>
<p>For (2), (2-1) inspecting current thread's frames, (2-2) thread frames and (2-3) global environment.<br>
We can access (2-3) using Ruby's powerful reflecting features (such as global_variables and so on).<br>
We lacks (2-1) and (2-2). Currently, we don't have flow control features ((1)'s feature) to stop other threads.<br>
So I decide to support only (2-1) "inspecting current thread's frames".</p>
<p>To make (2-1), <code>Binding.of_caller' (which is supported by 'binding_of_caller') gem is almost enough for debugger. However, </code>Binding.of_caller' is too powerful and it can break Ruby's semantics.<br>
I feel that we need to restrict for debugging purpose.</p>
<p>= API</p>
<p>With above consideration, I made a new C/Ruby API.</p>
<p><a href="https://github.com/ko1/ruby/compare/debugger_api" class="external">https://github.com/ko1/ruby/compare/debugger_api</a></p>
<p>== C-Level APIs</p>
<p>Types:</p>
<ul>
<li>typedef struct rb_debug_inspector_struct rb_debug_inspector_t;</li>
<li>typedef VALUE (*rb_debug_inspector_func_t)(const rb_debug_inspector_t *, void *);</li>
</ul>
<p>Functions:</p>
<ul>
<li>VALUE rb_debug_inspector_open(rb_debug_inspector_func_t func, void *data);</li>
<li>VALUE rb_debug_inspector_frame_binding_get(const rb_debug_inspector_t *dc, int index);</li>
<li>VALUE rb_debug_inspector_frame_class_get(const rb_debug_inspector_t *dc, int index);</li>
<li>VALUE rb_debug_inspector_backtrace_locations(const rb_debug_inspector_t *dc);</li>
</ul>
<p>== Ruby-level APIs (RubVM::DebugInspector)</p>
<p>You can use the following APIs after "require 'rubyvm/debug_inspector'".</p>
<ul>
<li>RubVM::DebugInspector.open{|inspector| ...}</li>
<li>RubVM::DebugInspector#backtrace_locations #=> locations array</li>
<li>RubVM::DebugInspector#frame_binding(i) #=> i-th binding.<br>
Generated bindings can be <code>broken' outside of </code>RubVM::DebugInspector.open' block<br>
to avoid abusing this powerful feature (now, they are not broken)</li>
<li>RubVM::DebugInspector#frame_class(i) #=> i-th method class</li>
</ul>
<p>Ruby level API is sample code of C-level APIs.</p>
<p>== Sample code</p>
<p>The following sample code is very simple debugger (breakpoint).</p>
<p>require 'rubyvm/debug_inspector'</p>
<p>def breakpoint<br>
RubyVM::DebugInspector.open{|inspector|<br>
$inspector = inspector<br>
inspector.backtrace_locations.each_with_index{|location, i|<br>
b = inspector.frame_binding(i) # binding is nil if it is for when C's context<br>
vars = b ? b.eval('local_variables') : []<br>
puts [i, location.to_s, vars, b, inspector.frame_class(i)].inspect<br>
}<br>
}<br>
end</p>
<p>def foo<br>
foo_a = foo_b = nil<br>
breakpoint<br>
end</p>
<p>hello = 1<br>
foo</p>
<p>begin<br>
# DebugInspector object is not active outside block of<br>
# RubyVM::DebugInspector.open<br>
p $inspector.backtrace_locations<br>
rescue ArgumentError => e<br>
p [:ok, e]<br>
end</p>
<p>= Consideration</p>
<p>== Satisfaction</p>
<p>I'm sorry I don't make surveys about debugger APIs for current CRuby's debugger<br>
and debuggers for alternative Ruby implementations.<br>
Please point out that it is enough or not enough, misunderstood and so on.</p>
<p>== Toward Ruby 2.0.0</p>
<p>Ruby 2.0.0 spec was already frozen :(<br>
Make debug_inspector gem for 2.0.0?</p>
<p>=end</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=32927
2012-11-15T22:35:36Z
ko1 (Koichi Sasada)
<ul></ul><p>I asked Matz about this feature.</p>
<p>His comments were:</p>
<p>(1) Do not need to break bindings at end of block. This is programmer's risk.<br>
(2) Ruby-level API is also okay to contains Ruby 2.0.0.</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=32933
2012-11-16T00:30:40Z
ko1 (Koichi Sasada)
<ul></ul><p>I asked mame-san (2.0.0 release manager) about this feature.</p>
<p>His comments is:<br>
DO IT ON A GEM SUCH A BIG FEATURE.</p>
<hr>
<p>His comment is: it should be experimental just now. We need to make examination with real debugger.</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=33011
2012-11-17T18:35:44Z
Conrad.Irwin (Conrad Irwin)
conrad.irwin@gmail.com
<ul></ul><p>Hey ko1,</p>
<p>Your debugging API looks good :).</p>
<p>It would be great to do this in a gem, but we can't create binding objects anymore due to changes in symbol visibility. (for 1.9 we used rb_vm_make_env_object, but it's now not exported, see [1])</p>
<p>This patch "fixes" it, but there should be a better way: <a href="https://gist.github.com/2f19a3cffb1a7bdfaf22" class="external">https://gist.github.com/2f19a3cffb1a7bdfaf22</a></p>
<p>Is there any chance you can make this function callable from C extensions?</p>
<p>Thanks!<br>
Conrad</p>
<p>[1] <a href="https://github.com/banister/binding_of_caller/blob/ruby-2.0/ext/binding_of_caller/binding_of_caller.c#L156" class="external">https://github.com/banister/binding_of_caller/blob/ruby-2.0/ext/binding_of_caller/binding_of_caller.c#L156</a> (edit, updated link)</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=33018
2012-11-17T19:53:15Z
ko1 (Koichi Sasada)
<ul></ul><p>(2012/11/17 18:35), Conrad.Irwin (Conrad Irwin) wrote:</p>
<blockquote>
<p>It would be great to do this in a gem, but we can't create binding objects anymore due to changes in symbol visibility. (for 1.9 we used rb_vm_make_env_object, but it's now not exported, see [1])</p>
</blockquote>
<p>Why do you need `rb_vm_make_env_object'? New API is not enough?</p>
<p>--<br>
// SASADA Koichi at atdot dot net</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=33099
2012-11-19T23:43:26Z
denofevil (Dennis Ushakov)
dennis.ushakov@jetbrains.com
<ul></ul><p>I will try to rewrite ruby-debug-base for 2.0 using your fork during this week and will post about results</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=33135
2012-11-20T07:53:11Z
ko1 (Koichi Sasada)
<ul></ul><p>(2012/11/19 23:43), denofevil (Dennis Ushakov) wrote:</p>
<blockquote>
<p>I will try to rewrite ruby-debug-base for 2.0 using your fork during this week and will post about results</p>
</blockquote>
<p>Can I see ruby-debug-base source code?<br>
I will try it and find out lacked feature.</p>
<p>--<br>
// SASADA Koichi at atdot dot net</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=33175
2012-11-20T17:46:25Z
denofevil (Dennis Ushakov)
dennis.ushakov@jetbrains.com
<ul></ul><p>Yes, sure: <a href="https://github.com/ruby-debug/ruby-debug-base19" class="external">https://github.com/ruby-debug/ruby-debug-base19</a></p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=33183
2012-11-20T20:23:33Z
ko1 (Koichi Sasada)
<ul></ul><p>(2012/11/20 17:46), denofevil (Dennis Ushakov) wrote:</p>
<blockquote>
<p>Yes, sure: <a href="https://github.com/ruby-debug/ruby-debug-base19" class="external">https://github.com/ruby-debug/ruby-debug-base19</a></p>
</blockquote>
<p>Thanks! I'll try it.</p>
<p>BTW, I can't understand relationship between <code>debugger' and </code>ruby-debug'.</p>
<p>--<br>
// SASADA Koichi at atdot dot net</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=33196
2012-11-20T20:53:36Z
luislavena (Luis Lavena)
luislavena@gmail.com
<ul></ul><p>On Tue, Nov 20, 2012 at 8:08 AM, SASADA Koichi <a href="mailto:ko1@atdot.net" class="email">ko1@atdot.net</a> wrote:</p>
<blockquote>
<p>Thanks! I'll try it.</p>
<p>BTW, I can't understand relationship between <code>debugger' and </code>ruby-debug'.</p>
</blockquote>
<p>AFAIK: debugger gem was a response to many of the installation issues<br>
ruby-debug-base19 had, specially due the need to download Ruby source<br>
and extract the internal headers during installation.</p>
<p>Reason of fork:</p>
<p><a href="https://github.com/cldwalker/debugger#reason-for-fork" class="external">https://github.com/cldwalker/debugger#reason-for-fork</a></p>
<p>And main differences:</p>
<p><a href="https://github.com/cldwalker/debugger#whats-different-from-ruby-debug19" class="external">https://github.com/cldwalker/debugger#whats-different-from-ruby-debug19</a></p>
<h2>--<br>
Luis Lavena<br>
AREA 17</h2>
<p>Perfection in design is achieved not when there is nothing more to add,<br>
but rather when there is nothing more to take away.<br>
Antoine de Saint-Exupéry</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=33204
2012-11-20T21:04:24Z
denofevil (Dennis Ushakov)
dennis.ushakov@jetbrains.com
<ul></ul><p>luislavena (Luis Lavena) wrote:</p>
<blockquote>
<p>AFAIK: debugger gem was a response to many of the installation issues<br>
ruby-debug-base19 had, specially due the need to download Ruby source<br>
and extract the internal headers during installation.<br>
Actually link that I gave is sources of ruby-debug-base19x. These are both forks for the same reasons =)<br>
ruby-debug-base19x was started earlier and intended to keep native frontend(base gem) and IDE/CLI backends separate.<br>
Sources of the ruby-debug-base19x and debugger native part share lots of code</p>
</blockquote>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=33814
2012-11-24T20:57:41Z
spastorino (Santiago Pastorino)
santiago@wyeworks.com
<ul></ul><p>Hope this <a href="https://bugs.ruby-lang.org/issues/6586" class="external">https://bugs.ruby-lang.org/issues/6586</a> could be done any time soon :)</p>
Ruby master - Bug #7214: Ruby 2.0 breaks support for some debugging tools
https://redmine.ruby-lang.org/issues/7214?journal_id=34664
2012-12-12T23:42:17Z
nobu (Nobuyoshi Nakada)
nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Third Party's Issue</i></li></ul><p>Debuggers should use new TracePoint feature now.</p>