https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112013-07-23T04:59:12ZRuby Issue Tracking SystemRuby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=406082013-07-23T04:59:12Zjballanc (Joshua Ballanco)jballanc@gmail.com
<ul></ul><p>You can already accomplish something like this yourself:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">begin</span>
<span class="k">raise</span> <span class="s2">"Hello!"</span>
<span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
<span class="nb">puts</span> <span class="n">e</span><span class="p">.</span><span class="nf">backtrace</span><span class="p">.</span><span class="nf">reverse</span><span class="p">.</span><span class="nf">join</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>
<span class="nb">puts</span> <span class="n">e</span><span class="p">.</span><span class="nf">message</span>
<span class="k">end</span>
</code></pre>
<p>Simple!</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=406182013-07-23T11:23:13Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul></ul><p>(13/07/23 4:56), Joshua Ballanco wrote:</p>
<blockquote>
<p>You can already accomplish something like this yourself:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">begin</span>
<span class="k">raise</span> <span class="s2">"Hello!"</span>
<span class="k">rescue</span> <span class="no">Exception</span> <span class="o">=></span> <span class="n">e</span>
<span class="nb">puts</span> <span class="n">e</span><span class="p">.</span><span class="nf">backtrace</span><span class="p">.</span><span class="nf">reverse</span><span class="p">.</span><span class="nf">join</span><span class="p">(</span><span class="s2">"</span><span class="se">\n</span><span class="s2">"</span><span class="p">)</span>
</code></pre>
</blockquote>
<p>You don't need to join.</p>
<blockquote>
<pre><code class="ruby syntaxhl" data-language="ruby"> <span class="nb">puts</span> <span class="n">e</span><span class="p">.</span><span class="nf">message</span>
<span class="k">end</span>
</code></pre>
<p>Simple!</p>
</blockquote> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=622152016-12-22T22:50:17Znofxx (Marcos Piccinini)
<ul></ul><p>Already doing the rescue & reverse, but need to do it on every project...</p>
<p>Another use case is when using some monitor (e.g. guard) to run tests as you code:<br>
When there's a fail one needs to switch to terminal and scroll up to see the lines that matter.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=630882017-02-22T08:49:00Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Description</strong> updated (<a title="View differences" href="/journals/63088/diff?detail_id=44017">diff</a>)</li></ul> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=630892017-02-22T08:50:31Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset ruby-trunk:r57685.</p>
<hr>
<p>eval_error.c: backstrace in reverse order</p>
<ul>
<li>eval_error.c (rb_threadptr_error_print): print backtrace and<br>
error message in reverse order if STDERR is unchanged and a tty.<br>
[Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Add option to print backtrace in reverse order (stack frames first and error last) (Closed)" href="https://redmine.ruby-lang.org/issues/8661">#8661</a>]</li>
</ul> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=647372017-05-10T10:00:25ZEregon (Benoit Daloze)
<ul></ul><p>Should matz give an opinion on this feature?</p>
<p>It's a pretty big change for the user, I got confused a couple times by it when running trunk.<br>
Particularly, if a test framework prints a backtrace in the old order, but then some exception kills the test framework then there is a mix of backtrace in old and new order.</p>
<p>I see from the commit this is limited to top-level backtraces printed to stderr.<br>
This is good to limit breaking compatibility but also inconsistent with the Exception#backtrace order for instance.<br>
Even then, it might already break compatibility significantly if anyone depends on the output of the top-level exception handler.</p>
<p>Also, I am not sure this addresses the OP concern, since the display of the backtrace in Rails is rarely an exception going to the top-level (which would be affected by this change) but managed by some handler printing the exception in the log (managed by Rails and can only be changed there).</p>
<p>In any case, if this remains for 2.5 it should be mentioned in the NEWS file.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=647382017-05-10T10:01:28ZEregon (Benoit Daloze)
<ul><li><strong>Assignee</strong> set to <i>matz (Yukihiro Matsumoto)</i></li></ul> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=647522017-05-11T06:11:43Zko1 (Koichi Sasada)
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li></ul><p>Agreed. I got confusing too. (not sure it is a matter of experience or not...)</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=649032017-05-19T06:09:12Znaruse (Yui NARUSE)naruse@airemix.jp
<ul></ul><p>We expect some people may object this.<br>
Therefore we're gathering feedback now (so thank you for your feedback).</p>
<p>To gather feedback wider, we'll give final decision after preview 1, including rspec and Rails will follow this change or not.</p>
<blockquote>
<p>In any case, if this remains for 2.5 it should be mentioned in the NEWS file.</p>
</blockquote>
<p>Yeah, NEWS should include this and note as EXPERIMENTAL.<br>
I add it.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=649042017-05-19T06:14:50Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Applied in changeset ruby-trunk:trunk|r58785.</p>
<hr>
<p>Add NEWS about [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Add option to print backtrace in reverse order (stack frames first and error last) (Closed)" href="https://redmine.ruby-lang.org/issues/8661">#8661</a>]</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=649052017-05-19T06:15:05Znaruse (Yui NARUSE)naruse@airemix.jp
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li></ul> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=649172017-05-19T07:12:51Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Applied in changeset ruby-trunk:trunk|r58786.</p>
<hr>
<p>eval_error.c: enrich backtrace</p>
<ul>
<li>eval_error.c (print_backtrace): add frame number when printing<br>
in reverse order. [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Add option to print backtrace in reverse order (stack frames first and error last) (Closed)" href="https://redmine.ruby-lang.org/issues/8661">#8661</a>]</li>
</ul> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=649722017-05-20T02:14:10Zshyouhei (Shyouhei Urabe)shyouhei@ruby-lang.org
<ul></ul><p>FYI it is intentional for this feature being automatically enabled right now, instead of some configuration like the OP requests.</p>
<p>The reason behind this is that stderr is expected to be passed to other processes (like some logging infrastructure for instance). If the order of backtraces is configurable, it becoms impossible for such outer-process things to detect which. So configuration is a bad idea in this area. Either the backtrace is ascending or descending, that order should be static and should never be configurable.</p>
<p>P.S. I get confused too so I personally don't like the way it is.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=670382017-10-03T13:06:22Zsonots (Naotoshi Seo)sonots@gmail.com
<ul></ul><p>I object the current behavior which prints backtrace in reverse order for STDERR. It is confusing.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=680182017-11-29T07:46:43Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>My enthusiastic -1.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=682672017-12-11T15:47:39Zkou (Kouhei Sutou)kou@cozmixng.org
<ul></ul><p>I like this change. It's unbelievable.</p>
<p>I thought that I don't like this feature because I was confused Python's backtrace behavior (most recent call last).</p>
<p>I used trunk in a few weeks but I was not confused the current behavior. Instead it was convenient.</p>
<p>I noticed that I confirm error message and then backtrace on error. It was convenient that error message is shown at the last. I could confirm backtrace from the bottom to the top naturally.</p>
<p>Python's backtrace behavior doesn't show index:</p>
<pre><code class="python syntaxhl" data-language="python"><span class="k">def</span> <span class="nf">a</span><span class="p">():</span>
<span class="nf">x</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">b</span><span class="p">():</span>
<span class="nf">a</span><span class="p">()</span>
<span class="nf">b</span><span class="p">()</span>
</code></pre>
<pre><code class="console syntaxhl" data-language="console"><span class="go">% python /tmp/a.py
Traceback (most recent call last):
</span><span class="gp"> File "/tmp/a.py", line 7, in <module></span><span class="w">
</span><span class="go"> b()
File "/tmp/a.py", line 5, in b
a()
File "/tmp/a.py", line 2, in a
x()
NameError: global name 'x' is not defined
</span></code></pre>
<p>Ruby 2.5's one shows index:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">a</span>
<span class="n">x</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">b</span>
<span class="n">a</span>
<span class="k">end</span>
<span class="n">b</span>
</code></pre>
<pre><code class="console syntaxhl" data-language="console"><span class="go">% ruby /tmp/a.rb
Traceback (most recent call last):
</span><span class="gp"> 2: from /tmp/a.rb:9:in `<main></span><span class="s1">'
</span><span class="go"> 1: from /tmp/a.rb:6:in `b'
/tmp/a.rb:2:in `a': undefined local variable or method `x' for main:Object (NameError)
</span></code></pre>
<p>It may be helpful to recognize backtrace order.</p>
<p>I've added the same behavior to test-unit and released a new version.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=686242017-12-24T15:09:48Zaeroastro (Takumasa Ochi)
<ul></ul><p>Although I am not a Ruby committer, IMHO, I do not think the current implementation<br>
is the best way to fully address the reporter's concern.</p>
<p>As written in this issue's description section, reversing the backtrace is a<br>
solution which only works in the environments where you read the log from bottom<br>
to top like terminals.</p>
<p>Nowadays, it is becoming more and more common to read the log from top to bottom<br>
in other environments like CI report (e.g. Jenkins, Travis, and so on),<br>
web-based error dashboard (e.g. Stack Driver), interactive applications<br>
(e.g. Jupyter). Current Ruby 2.5's behavior is to reverse backtrace when STDERR<br>
is unchanged and a tty. Therefore we can still read the backtrace from top to<br>
bottom in those situations. However, this conditional reversing lacks consistency<br>
and is confusing. For example, just a redirection can change the behavior of output.</p>
<p>At the same time, I think we need to clarify what the problem actually is.<br>
If a lot of people using Rails are suffering from huge backtraces, which can be assumed from<br>
the word "every project" and "tailing the production logs", ActiveSupport::BacktraceCleaner<br>
can solve the problem in a more sophisticated way. It convert the huge backtrace to<br>
a very compact one by filtering out irrelevant lines which belong to Rails framework.<br>
This solution works well regardless of the way how we read the log because the backtrace<br>
is short and simple.</p>
<p>If people developing Rails itself are suffering from huge backtraces, although conditional<br>
reversing could work to some extent, IMHO, we need to consider a solution with fewer<br>
and minor side effects.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=726692018-06-27T03:24:27Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>This is possibly one of the most irritating changes to Ruby recently. Now, every time I read back trace, I have to check it carefully.</p>
<p>Is it top to bottom or bottom to top?</p>
<p>How is this confusion made worse?</p>
<ul>
<li>Using multiple versions of Ruby, or different interpreters that retain the old behaviour.</li>
<li>Using testing frameworks and logging frameworks that retain the old behaviour.</li>
</ul>
<p>This is a case where I think the benefit was significantly overshadowed by the cost to end users. It's now very, very confusing.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=735732018-08-17T14:41:13Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>Over one year has passed since the backtrace order was reversed. But I'm not still used to the new order.</p>
<p>I agree with Samuel's points. In addition, the old order was more useful because it shows the last debug output and the exception message in one place.</p>
<pre><code>$ ruby24 test.rb
...
...
"debug print"
"debug print"
"the last debug print"
test.rb:X:in 'buggy_func': exception message
from test.rb:X:in `foo'
from test.rb:X:in `bar'
...
...
</code></pre>
<p>In the above output, <code>"the last debug output"</code> and <code>test.rb:X:in 'buggy_func': exception message</code> are placed in one place. It is easy to understand the situation and to start debugging.</p>
<p>However, the current behavior separates the two. This is very frastrating.</p>
<pre><code>$ ruby25 test.rb
...
...
"debug print"
"debug print"
"the last debug print"
...
...
from test.rb:X:in `bar'
from test.rb:X:in `foo'
test.rb:X:in 'buggy_func': exception message
</code></pre>
<p>Is there any chance to revert the change?</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=736062018-08-18T17:45:57Zshevegen (Robert A. Heiler)shevegen@gmail.com
<ul></ul><p>I think I agree with mame - perhaps it should be reverted for now.</p>
<p>There was another ruby hacker from japan who wrote, some time ago<br>
(a year or two?), that he was confused about it too; I don't remember<br>
where it was but I think it was in a standalone proposal some time<br>
ago.</p>
<p>In my opinion, the best would be to find a way to be able to<br>
fully customize the behaviour/display that ruby uses for reporting<br>
warnings/errors, with a default chosen that may be most appropriate<br>
for the most common ways to display the issues at hand (I have no<br>
preference to the default chosen here, but perhaps we should<br>
revert to the behaviour ruby used to use; and then allow full<br>
customization for people to adapt it to their own personal needs).</p>
<p>I assume that matz may not have a huge preference either, so<br>
perhaps we should (lateron?) focus on some way to be able to<br>
customize how ruby treats warnings/errors or rather, display<br>
them. An obvious way may be to allow for environment variables.</p>
<p>An additional way may be to pick something at compile time (so<br>
that people can customize it for their own host system, as a<br>
default), and perhaps also a --user flag directive of some<br>
sorts; and perhaps additionally something like $VERBOSE, but<br>
through some core method call or something instead.</p>
<p>I should, however had, also note that while I think I prefer<br>
the old behaviour, to me personally it is not a huge deal either<br>
way - I just can understand everyone who may not like the<br>
chosen default as-is. The only thing that I personally found hard<br>
was when the filenames are very long and the error is somewhere<br>
deep down in code that gets called by lots of other methods in<br>
different files - then the error messages are "overflowing" to<br>
the right of my screen display, so in this case, I would prefer<br>
a shorter message, or perhaps split up onto several lines; I kind<br>
of focus on the left hand side of my screen normally. But again,<br>
it's not really something I personally am deeply invested - I am<br>
personally am more looking as to how mjit is progressing. :)</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=825582019-11-07T04:45:40Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>For the record: I am even surprised with myself, but I am not really used to the new order of the backtrace. I may be too old, but I wish the original backtrace order is back.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=841392020-02-03T07:15:29Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>I still hate the "reversed" order of backtraces. I often use <code>p *caller</code> and <code>p *$!.backtrace</code> for debugging, whose order is "normal" (non-reversed). Please revert the change at Ruby 3.0.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=845822020-03-10T23:33:35Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-1 priority-4 priority-default" href="/issues/16684">Feature #16684</a>: Use the word "to" instead of "from" in backtrace</i> added</li></ul> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=851932020-04-19T10:46:52Zioquatix (Samuel Williams)samuel@oriontransfer.net
<ul></ul><p>I have not changed my opinion, but I gave up and now wrap every command with my own gem which puts it back in the top to bottom order.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=851942020-04-19T10:52:12Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<ul></ul><p>Yes, this is still the most annoying change in Ruby. Once the backtrace is displayed in reverse order, the other time in normal order, depending if I am seeing log in TTY or in file. Terrible.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=851952020-04-19T11:03:09Zretro (Josef Šimánek)
<ul></ul><p>I agree on this is really unfortunate and annoying change. I need to go thru backtrace visually first to decide which order is used and then do second visual parsing to actually use it. The new order usually means I need to scroll up in console history to find out related info. With old ordering I was able to get the info I usually need from the bottom of stacktrace info without any scrolling.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852212020-04-21T07:53:29Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>OK, let's revert it. Instead, I want to something to suppress backtrace lines (e.g. <code>--suppress-backtrace=5</code> command-line option to <code>ruby</code> or something similar in <code>RUBYOPT</code> environment variable).</p>
<p>Matz.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852232020-04-21T08:13:25Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>Thank you very much, <a class="user active user-mention" href="https://redmine.ruby-lang.org/users/13">@matz (Yukihiro Matsumoto)</a>!!!</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852242020-04-21T08:13:59Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li></ul> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852252020-04-21T08:17:16Zretro (Josef Šimánek)
<ul></ul><p>Thank you <a class="user active user-mention" href="https://redmine.ruby-lang.org/users/13">@matz (Yukihiro Matsumoto)</a>!</p>
<p>I can try to prepare patch including both options:</p>
<ol>
<li>specify order</li>
<li>limit amount of lines printed</li>
</ol> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852262020-04-21T08:44:12Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" title="eval_error.c: revert the "reversed" backtrace [Feature #8661] Now, the order is good, old-fashio..." href="https://redmine.ruby-lang.org/projects/ruby-master/repository/git/revisions/487d0c99d53208594702bb3ce1c657130fb8d65f">ruby-master:git|487d0c99d53208594702bb3ce1c657130fb8d65f</a>.</p>
<hr>
<p>eval_error.c: revert the "reversed" backtrace [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Add option to print backtrace in reverse order (stack frames first and error last) (Closed)" href="https://redmine.ruby-lang.org/issues/8661">#8661</a>]</p>
<p>Now, the order is good, old-fashioned style:</p>
<pre><code>$ ./local/bin/ruby -e 'def foo; raise; end
def bar; foo; end
def baz; bar; end
def qux; baz; end
qux
'
-e:1:in `foo': unhandled exception
from -e:2:in `bar'
from -e:3:in `baz'
from -e:4:in `qux'
from -e:5:in `<main>'
</code></pre> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852272020-04-21T08:45:29Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li></ul><p>Reopen because we need to support <code>--suppress-backtrace=5</code>.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852292020-04-21T09:36:03Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>I've created a PR for <code>--suppress-backtrace=num</code> option.</p>
<p><a href="https://github.com/ruby/ruby/pull/3047" class="external">https://github.com/ruby/ruby/pull/3047</a></p>
<p><a class="user active user-mention" href="https://redmine.ruby-lang.org/users/13">@matz (Yukihiro Matsumoto)</a> Could you confirm if the behavior is right as you think?</p>
<p>t.rb</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">def</span> <span class="nf">f1</span> <span class="o">=</span> <span class="k">raise</span>
<span class="k">def</span> <span class="nf">f2</span> <span class="o">=</span> <span class="n">f1</span>
<span class="k">def</span> <span class="nf">f3</span> <span class="o">=</span> <span class="n">f2</span>
<span class="k">def</span> <span class="nf">f4</span> <span class="o">=</span> <span class="n">f3</span>
<span class="k">def</span> <span class="nf">f5</span> <span class="o">=</span> <span class="n">f4</span>
<span class="k">def</span> <span class="nf">f6</span> <span class="o">=</span> <span class="n">f5</span>
<span class="k">def</span> <span class="nf">f7</span> <span class="o">=</span> <span class="n">f6</span>
<span class="k">def</span> <span class="nf">f8</span> <span class="o">=</span> <span class="n">f7</span>
<span class="k">def</span> <span class="nf">f9</span> <span class="o">=</span> <span class="n">f8</span>
<span class="n">f9</span>
</code></pre>
<p><code>--suppress-backtrace=3</code> limits the backtrace up to three lines, so the rest seven lines are omitted.</p>
<pre><code>$ ./miniruby --suppress-backtrace=3 t.rb
t.rb:1:in `f1': unhandled exception
from t.rb:2:in `f2'
from t.rb:3:in `f3'
from t.rb:4:in `f4'
... 7 levels...
</code></pre>
<p><code>--suppress-backtrace=8</code> limits it up to eight, even if the lines being omitted are only two lines.</p>
<pre><code>$ ./miniruby --suppress-backtrace=8 t.rb
t.rb:1:in `f1': unhandled exception
from t.rb:2:in `f2'
from t.rb:3:in `f3'
from t.rb:4:in `f4'
from t.rb:5:in `f5'
from t.rb:6:in `f6'
from t.rb:7:in `f7'
from t.rb:8:in `f8'
from t.rb:9:in `f9'
... 2 levels...
</code></pre>
<p>If the line being omitted is only one, no lines are omitted.</p>
<pre><code>$ ./miniruby --suppress-backtrace=9 t.rb
t.rb:1:in `f1': unhandled exception
from t.rb:2:in `f2'
from t.rb:3:in `f3'
from t.rb:4:in `f4'
from t.rb:5:in `f5'
from t.rb:6:in `f6'
from t.rb:7:in `f7'
from t.rb:8:in `f8'
from t.rb:9:in `f9'
from t.rb:10:in `<main>'
</code></pre>
<p><code>--suppress-backtrace=1</code> shows only the first level (except the message line).</p>
<pre><code>$ ./miniruby --suppress-backtrace=1 t.rb
t.rb:1:in `f1': unhandled exception
from t.rb:2:in `f2'
... 9 levels...
</code></pre>
<p><code>--suppress-backtrace=0</code> omits all backtrace except the message line.</p>
<pre><code>$ ./miniruby --suppress-backtrace=0 t.rb
t.rb:1:in `f1': unhandled exception
... 10 levels...
</code></pre> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852302020-04-21T10:29:49Znobu (Nobuyoshi Nakada)nobu@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>Applied in changeset <a class="changeset" title="NEWS.md: the order of backtrace [Feature #8661] [ci skip]" href="https://redmine.ruby-lang.org/projects/ruby-master/repository/git/revisions/bf11bf31e2e795bb22c939a5b5cd412c98208982">ruby-master:git|bf11bf31e2e795bb22c939a5b5cd412c98208982</a>.</p>
<hr>
<p>NEWS.md: the order of backtrace [Feature <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Add option to print backtrace in reverse order (stack frames first and error last) (Closed)" href="https://redmine.ruby-lang.org/issues/8661">#8661</a>] [ci skip]</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852352020-04-21T16:51:54Zsawa (Tsuyoshi Sawada)
<ul><li><strong>Subject</strong> changed from <i>Add option to print backstrace in reverse order(stack frames first & error last)</i> to <i>Add option to print backtrace in reverse order (stack frames first and error last)</i></li><li><strong>Description</strong> updated (<a title="View differences" href="/journals/85235/diff?detail_id=56913">diff</a>)</li></ul> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852392020-04-21T23:35:50Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul></ul><p>I think the option's name (<code>--suppress-backtrace</code>) is wrong. If I write <code>--suppress-backtrace=10</code>, it reads like "suppress 10 entries of backtrace". That would mean if the whole backtrace is 50 entries, it would print 40 entries. The name of the option should be changed to something positive, such as <code>--show-backtrace</code> or <code>--print-backtrace</code> or so, to match its meaning.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852412020-04-21T23:49:02Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul></ul><p>duerst (Martin Dürst) wrote in <a href="#note-36">#note-36</a>:</p>
<blockquote>
<p>I think the option's name (<code>--suppress-backtrace</code>) is wrong. If I write <code>--suppress-backtrace=10</code>, it reads like "suppress 10 entries of backtrace". That would mean if the whole backtrace is 50 entries, it would print 40 entries. The name of the option should be changed to something positive, such as <code>--show-backtrace</code> or <code>--print-backtrace</code> or so, to match its meaning.</p>
</blockquote>
<p>I agree the option could have a better name. I recommend <code>--backtrace-limit</code>, as that indicates a numerical setting, as opposed to <code>--show-backtrace</code> or <code>--print-backtrace</code>, both of which indicate a boolean setting.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852422020-04-22T00:34:10Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Assigned</i></li></ul><p>jeremyevans0 (Jeremy Evans) wrote in <a href="#note-37">#note-37</a>:</p>
<blockquote>
<p>I agree the option could have a better name. I recommend <code>--backtrace-limit</code>, as that indicates a numerical setting, as opposed to <code>--show-backtrace</code> or <code>--print-backtrace</code>, both of which indicate a boolean setting.</p>
</blockquote>
<p>I agree that <code>--backtrace-limit</code> is much better than my earlier proposals. I have reopened this feature. Please tell me in case I should open a separate issue.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=852442020-04-22T01:19:59Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>I agree with <code>--backtrace-limit</code>, and actually I use <code>rb_backtrace_length_limit</code> in my patch :-)<br>
I'll update my patch if I get a reply from matz.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=856122020-05-14T08:41:23Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>LGTM (including <code>--backtrace-limit</code>).</p>
<p>Matz.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=857952020-05-26T04:28:21Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Status</strong> changed from <i>Assigned</i> to <i>Closed</i></li></ul><p>Committed at 39365b46e250162f278cb36aa148bc2a92b1b84a. Thanks!</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=857992020-05-26T07:08:39Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<ul></ul><p>Have the commit changed the order or introduced just the option? It seems to that just the later, which is not what was agreed in <a href="#note-27">#note-27</a></p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=858042020-05-26T10:57:10Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>The order had been already reverted in <a href="#note-31">#note-31</a>.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=858052020-05-26T11:29:37Zvo.x (Vit Ondruch)v.ondruch@tiscali.cz
<ul></ul><p>mame (Yusuke Endoh) wrote in <a href="#note-43">#note-43</a>:</p>
<blockquote>
<p>The order had been already reverted in <a href="#note-31">#note-31</a>.</p>
</blockquote>
<p>Ah, thx and sorry to miss that :blush:</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=858172020-05-26T14:23:00Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul></ul><p>Don't mind, I was not clear.</p> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=893502020-12-21T02:05:00Zmame (Yusuke Endoh)mame@ruby-lang.org
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/17413">Bug #17413</a>: --backtrace-limit: wrong level counter</i> added</li></ul> Ruby master - Feature #8661: Add option to print backtrace in reverse order (stack frames first and error last)https://redmine.ruby-lang.org/issues/8661?journal_id=955422021-12-23T23:41:08Zhsbt (Hiroshi SHIBATA)hsbt@ruby-lang.org
<ul><li><strong>Project</strong> changed from <i>14</i> to <i>Ruby master</i></li></ul>