https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112009-07-13T21:19:44ZRuby Issue Tracking SystemRuby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=46012009-07-13T21:19:44Zyugui (Yuki Sonoda)yugui@yugui.jp
<ul><li><strong>Category</strong> set to <i>YARV</i></li><li><strong>Assignee</strong> set to <i>ko1 (Koichi Sasada)</i></li><li><strong>Priority</strong> changed from <i>3</i> to <i>5</i></li><li><strong>Target version</strong> set to <i>1.9.2</i></li></ul><p>=begin</p>
<p>=end</p> Ruby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=51682009-08-09T01:29:46Zmark-moseley (Mark Moseley)mark@fast-software.com
<ul></ul><p>=begin<br>
Patch to fix this:</p>
<p>--- compile.c (revision 24476)<br>
+++ compile.c (working copy)<br>
@@ -2959,6 +2959,8 @@<br>
COMPILE_(ret, "BLOCK body", node->nd_head,<br>
(node->nd_next == 0 && poped == 0) ? 0 : 1);<br>
node = node->nd_next;</p>
<ul>
<li>
<pre><code> if (node)
</code></pre>
</li>
<li>
<pre><code> iseq->compile_data->last_line = nd_line(node);
</code></pre>
}<br>
if (node) {<br>
COMPILE_(ret, "BLOCK next", node->nd_next, poped);</li>
</ul>
<p>This is probably not the best solution, though. It appears to me that there might be other problems lurking in iseq_compile_each() after any "node = node->nd_next" statement. I think that probably a macro that both goes to the next node, and resets the line number, (and maybe also resets type) is appropriate, but I haven't investigated this in depth.<br>
=end</p> Ruby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=52892009-08-18T05:19:10Zrogerdpack (Roger Pack)rogerpack2005@gmail.com
<ul></ul><p>=begin<br>
As a note, this is fixed by a patch discussed here<br>
<a href="http://github.com/mark-moseley/ruby-debug/issues/#issue/1/comment/36731" class="external">http://github.com/mark-moseley/ruby-debug/issues/#issue/1/comment/36731</a><br>
If that's any help.<br>
=end</p> Ruby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=53012009-08-19T01:07:45Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>=begin<br>
Hi,</p>
<p>2009/08/09 1:29 に Mark Moseley<a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> さんは書きました:</p>
<blockquote>
<p>Patch to fix this:</p>
<p>--- compile.c (revision 24476)<br>
+++ compile.c (working copy)<br>
@@ -2959,6 +2959,8 @@<br>
COMPILE_(ret, "BLOCK body", node->nd_head,<br>
(node->nd_next == 0 && poped == 0) ? 0 : 1);<br>
node = node->nd_next;</p>
<ul>
<li>
<pre><code> if (node)
</code></pre>
</li>
<li>
<pre><code> iseq->compile_data->last_line = nd_line(node);
</code></pre>
}<br>
if (node) {<br>
COMPILE_(ret, "BLOCK next", node->nd_next, poped);</li>
</ul>
</blockquote>
<p>wanabe reports an unexpected behavior in which return event should be<br>
fired but not when foo(true) is called. This will be fixed by the<br>
following patch:</p>
<a name="Index-compilec"></a>
<h1 >Index: compile.c<a href="#Index-compilec" class="wiki-anchor">¶</a></h1>
<p>--- compile.c (revision 24578)<br>
+++ compile.c (working copy)<br>
@@ -4205,6 +4205,7 @@</p>
<pre><code> if (is->type == ISEQ_TYPE_METHOD) {
add_ensure_iseq(ret, iseq, 1);
</code></pre>
<ul>
<li>
<pre><code> ADD_TRACE(ret, nd_line(node), RUBY_EVENT_RETURN);
ADD_INSN(ret, nd_line(node), leave);
ADD_ADJUST_RESTORE(ret, splabel);
</code></pre>
</li>
</ul>
<p>Your patch fixes line number of return event. Indeed, the line number<br>
is wrong, which is another problem.<br>
In place of ko1, I'll checking both the problem and <a href="/issues/1797">[ruby-core:24463]</a><br>
with your whole patch (<a href="http://gist.github.com/166330" class="external">http://gist.github.com/166330</a>) later.</p>
<p>Anyway, thank you for your patch.</p>
<p>--<br>
Yusuke ENDOH <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a></p>
<p>=end</p> Ruby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=53032009-08-19T01:17:05Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>=begin<br>
Applied in changeset r24579.<br>
=end</p> Ruby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=53052009-08-19T01:27:55Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li><li><strong>Priority</strong> changed from <i>5</i> to <i>3</i></li></ul><p>=begin<br>
直した直後に気がつきましたが、eval("return") の場合に問題が残ります。</p>
<p>$ ./ruby -e '<br>
set_trace_func(proc{|*a| p a if a[0] == "call" || a[0] == "return"})<br>
def foo<br>
eval("return")<br>
end<br>
foo<br>
'<br>
["call", "-e", 3, :foo, #<a href="Binding:0x8224b44" class="external">Binding:0x8224b44</a>, Object]</p>
<p>直すのが面倒そうなのと、あまり問題にならなさそうなので<br>
報告だけして後回しにします。</p>
<p>--<br>
Yusuke ENDOH <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a><br>
=end</p> Ruby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=53082009-08-19T02:57:09Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>=begin<br>
Applied in changeset r24581.<br>
=end</p> Ruby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=53092009-08-19T03:06:38Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li></ul><p>=begin<br>
テストを追加した際、間違って close してしまいました。<br>
eval("return") はまだ修正していません。<br>
何度もすみません。<br>
=end</p> Ruby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=53122009-08-19T06:23:50Zwanabe (_ wanabe)s.wanabe@gmail.com
<ul></ul><p>=begin<br>
遠藤さん、ありがとうございます。Mark さんへの説明も重ね重ねありがとうございます。<br>
自明のことかもしれませんが、自分で困ったので念のため<br>
proc {return}.call のようなときにも問題があることを報告させていただきます。<br>
=end</p> Ruby master - Bug #1676: only last "return" is traced by set_trace_funchttps://bugs.ruby-lang.org/issues/1676?journal_id=101892010-04-14T21:44:55Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>=begin<br>
遠藤です。</p>
<p>残っていた課題も、ささださんが知らぬ間に直してくれていた<br>
(r26395) ので close します。</p>
<p>$ ./ruby -e '<br>
set_trace_func(proc{|*a| p a if a[0] == "call" || a[0] == "return"})<br>
def foo<br>
eval("return")<br>
end<br>
foo<br>
'<br>
["call", "-e", 3, :foo, #<a href="Binding:0x822a8f0" class="external">Binding:0x822a8f0</a>, Object]<br>
["return", "-e", 4, :foo, #<a href="Binding:0x822a4cc" class="external">Binding:0x822a4cc</a>, Object]</p>
<p>$ ./ruby -e '<br>
set_trace_func(proc{|*a| p a if a[0] == "call" || a[0] == "return"})<br>
def foo<br>
proc {return}.call<br>
end<br>
foo<br>
'<br>
["call", "-e", 3, :foo, #<a href="Binding:0x822a83c" class="external">Binding:0x822a83c</a>, Object]<br>
["return", "-e", 4, :foo, #<a href="Binding:0x822a3dc" class="external">Binding:0x822a3dc</a>, Object]</p>
<p>--<br>
Yusuke Endoh <a href="mailto:mame@tsg.ne.jp" class="email">mame@tsg.ne.jp</a><br>
=end</p>