From: "Dan0042 (Daniel DeLorme)" <noreply@ruby-lang.org>
To: ruby-core@neon.ruby-lang.org
Subject: [ruby-core:110784] [Ruby master Feature#19117] Include the method owner in backtraces, not just the method name
Date: Wed, 16 Nov 2022 18:32:58 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-100130.20221116183257.7941@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19117.20221110121311.7941@ruby-lang.org
Issue #19117 has been updated by Dan0042 (Daniel DeLorme).
> Not all code follow a convention where classes map to files 1 to 1.
And that's why I wrote "usually/often", not "always".
> That's not the case for methods defined in C (either core or C extensions) as mentioned above, so it's a significant help to read and understand the backtrace to have the owner there.
Ok thank you, I missed that above.
But I want to point out that since **usually** ruby code is written with the convention that classes map to files 1 to 1, and since the owner is right there in the filepath for the methods that are **defined in ruby**, for the majority of the stack trace you're going to see a lot of redundancy. ex:
```
/home/me/test/superspeed/server/events/socket/base.rb:7:in `Superspeed::Server::Events::Socket::Base#test': todo (RuntimeError)
from /home/me/test/superspeed/server/events/socket/comm.rb:9:in `Superspeed::Server::Events::Socket::Comm#test1'
from /home/me/test/superspeed/server/events/socket/comm.rb:18:in `<main>'
```
----------------------------------------
Feature #19117: Include the method owner in backtraces, not just the method name
https://bugs.ruby-lang.org/issues/19117#change-100130
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
```
module Foo
class Bar
def inspect
1 + '1'
end
end
end
p Foo::Bar.new
```
This code produce the following backtrace:
```
/tmp/foo.rb:4:in `+': String can't be coerced into Integer (TypeError)
from /tmp/foo.rb:4:in `inspect'
from /tmp/foo.rb:9:in `p'
from /tmp/foo.rb:9:in `<main>'
```
This works, but on large codebases and large backtraces the method name isn't always all that revealing, most of the time you need to open many of the locations listed in the backtrace to really understand what is going on.
I propose that we also include the owner name:
```
/tmp/foo.rb:4:in `Integer#+': String can't be coerced into Integer (TypeError)
from /tmp/foo.rb:4:in `Foo::Bar#inspect'
from /tmp/foo.rb:9:in `Kernel#p'
from /tmp/foo.rb:9:in `<main>'
```
I believe that in many case it would allow to much better understand the backtrace without having to jump back and forth between it and the source code.
This is inspired by @ivoanjo 's `backtracie` gem: https://github.com/ivoanjo/backtracie
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2022-11-16 18:33 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 12:13 [ruby-core:110683] [Ruby master Feature#19117] Include the method owner in backtraces, not just the method name byroot (Jean Boussier)
2022-11-10 12:28 ` [ruby-core:110685] " zverok (Victor Shepelev)
2022-11-10 13:08 ` [ruby-core:110686] " Eregon (Benoit Daloze)
2022-11-10 13:11 ` [ruby-core:110687] " Eregon (Benoit Daloze)
2022-11-10 13:29 ` [ruby-core:110688] " byroot (Jean Boussier)
2022-11-10 13:50 ` [ruby-core:110691] " kjtsanaktsidis (KJ Tsanaktsidis)
2022-11-10 16:41 ` [ruby-core:110696] " Eregon (Benoit Daloze)
2022-11-11 0:23 ` [ruby-core:110701] " byroot (Jean Boussier)
2022-11-11 10:01 ` [ruby-core:110702] " Eregon (Benoit Daloze)
2022-11-11 23:37 ` [ruby-core:110712] " byroot (Jean Boussier)
2022-11-12 2:08 ` [ruby-core:110717] " kjtsanaktsidis (KJ Tsanaktsidis)
2022-11-12 2:24 ` [ruby-core:110719] " kjtsanaktsidis (KJ Tsanaktsidis)
2022-11-12 3:30 ` [ruby-core:110720] " byroot (Jean Boussier)
2022-11-12 12:24 ` [ruby-core:110724] " Eregon (Benoit Daloze)
2022-11-14 8:03 ` [ruby-core:110745] " mame (Yusuke Endoh)
2022-11-16 16:20 ` [ruby-core:110778] " ivoanjo (Ivo Anjo)
2022-11-16 16:25 ` [ruby-core:110779] " Dan0042 (Daniel DeLorme)
2022-11-16 16:40 ` [ruby-core:110780] " byroot (Jean Boussier)
2022-11-16 16:57 ` [ruby-core:110782] " Eregon (Benoit Daloze)
2022-11-16 17:01 ` [ruby-core:110783] " Eregon (Benoit Daloze)
2022-11-16 18:32 ` Dan0042 (Daniel DeLorme) [this message]
2022-12-02 2:33 ` [ruby-core:111140] " mame (Yusuke Endoh)
2023-11-30 7:01 ` [ruby-core:115539] " mame (Yusuke Endoh) via ruby-core
2023-11-30 7:27 ` [ruby-core:115541] " byroot (Jean Boussier) via ruby-core
2023-11-30 12:32 ` [ruby-core:115546] " Eregon (Benoit Daloze) via ruby-core
2024-01-19 5:39 ` [ruby-core:116312] " mame (Yusuke Endoh) via ruby-core
2024-01-19 9:11 ` [ruby-core:116320] " byroot (Jean Boussier) via ruby-core
2024-01-19 9:37 ` [ruby-core:116321] " byroot (Jean Boussier) via ruby-core
2024-01-19 15:02 ` [ruby-core:116334] " Dan0042 (Daniel DeLorme) via ruby-core
2024-01-19 15:25 ` [ruby-core:116335] " byroot (Jean Boussier) via ruby-core
2024-01-19 15:36 ` [ruby-core:116337] " Dan0042 (Daniel DeLorme) via ruby-core
2024-01-19 15:42 ` [ruby-core:116338] " byroot (Jean Boussier) via ruby-core
2024-01-19 19:38 ` [ruby-core:116339] " Dan0042 (Daniel DeLorme) via ruby-core
2024-01-19 19:48 ` [ruby-core:116340] " byroot (Jean Boussier) via ruby-core
2024-01-20 0:58 ` [ruby-core:116343] " mame (Yusuke Endoh) via ruby-core
2024-01-20 11:04 ` [ruby-core:116346] " byroot (Jean Boussier) via ruby-core
2024-01-20 16:50 ` [ruby-core:116348] " Dan0042 (Daniel DeLorme) via ruby-core
2024-02-13 9:42 ` [ruby-core:116693] " ko1 (Koichi Sasada) via ruby-core
2024-02-13 10:28 ` [ruby-core:116694] " byroot (Jean Boussier) via ruby-core
2024-02-13 10:58 ` [ruby-core:116695] " Eregon (Benoit Daloze) via ruby-core
2024-02-13 18:02 ` [ruby-core:116705] " ko1 (Koichi Sasada) via ruby-core
2024-02-13 18:14 ` [ruby-core:116706] " Eregon (Benoit Daloze) via ruby-core
2024-02-14 5:10 ` [ruby-core:116729] " matz (Yukihiro Matsumoto) via ruby-core
2024-02-16 8:39 ` [ruby-core:116793] " byroot (Jean Boussier) via ruby-core
2024-02-16 11:34 ` [ruby-core:116796] " mame (Yusuke Endoh) via ruby-core
2024-02-16 11:38 ` [ruby-core:116797] " byroot (Jean Boussier) via ruby-core
2024-02-16 20:31 ` [ruby-core:116807] " Eregon (Benoit Daloze) via ruby-core
2024-02-16 21:45 ` [ruby-core:116809] " Dan0042 (Daniel DeLorme) via ruby-core
2024-02-17 3:50 ` [ruby-core:116812] " mame (Yusuke Endoh) via ruby-core
2024-02-17 10:33 ` [ruby-core:116818] " Eregon (Benoit Daloze) via ruby-core
2024-02-17 10:48 ` [ruby-core:116821] " Eregon (Benoit Daloze) via ruby-core
2024-03-21 20:08 ` [ruby-core:117285] " Eregon (Benoit Daloze) via ruby-core
2024-03-21 20:08 ` [ruby-core:117286] " Eregon (Benoit Daloze) via ruby-core
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.journal-100130.20221116183257.7941@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
--cc=ruby-core@neon.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).