Feature #8960

Add Exception#backtrace_locations

Added by Charles Nutter 7 months ago. Updated 4 months ago.

[ruby-core:57430]
Status:Feedback
Priority:Normal
Assignee:Koichi Sasada
Category:core
Target version:next minor

Description

All parties agreed this would be useful to add in https://bugs.ruby-lang.org/issues/7895 and ko1 suggested I file a feature against ruby-trunk. So here it is.

I might be able to come up with a patch, but I'm not sure when. Help wanted.

Can we agree this will go into 2.1?


Related issues

Related to CommonRuby - Feature #7895: Exception#backtrace_locations to go with Thread#backtrace... Open 02/21/2013

Associated revisions

Revision 44170
Added by Koichi Sasada 4 months ago

  • error.c: add Exception#backtrace_locations. Now, there are no setter and independent from Exception#backtrace. [Feature #8960]
  • eval.c (setupexception): set backtrace locations for `btlocation' special attribute.
  • vmbacktrace.c (rbbacktracetolocation_ary): added.
  • internal.h: ditto.
  • test/ruby/testbacktrace.rb: add a test for Exception#backtracelocations.

History

#1 Updated by Koichi Sasada 7 months ago

  • Category set to core
  • Assignee set to Koichi Sasada
  • Target version set to 2.1.0

I'll try before preview-2.

JRuby already has a implementation and tests?

#2 Updated by Charles Nutter 7 months ago

JRuby has implementation but no tests. The test should look pretty much like Thread#backtrace_locations tests, though.

I can work on some tests if you work on impl for MRI.

#3 Updated by Nobuyoshi Nakada 4 months ago

What will be returned from an exception set by Exception#set_backtrace in JRuby?

#4 Updated by Koichi Sasada 4 months ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r44170.
Charles, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • error.c: add Exception#backtrace_locations. Now, there are no setter and independent from Exception#backtrace. [Feature #8960]
  • eval.c (setupexception): set backtrace locations for `btlocation' special attribute.
  • vmbacktrace.c (rbbacktracetolocation_ary): added.
  • internal.h: ditto.
  • test/ruby/testbacktrace.rb: add a test for Exception#backtracelocations.

#5 Updated by Koichi Sasada 4 months ago

  • Status changed from Closed to Feedback
  • Target version changed from 2.1.0 to next minor
  • % Done changed from 100 to 0

Now, I implemented half-baked feature (read-only backtrace locations).

How about to continue how to change it?

#6 Updated by Charles Nutter 4 months ago

ko1: I have no problem whatsoever with backtrace_locations being read-only now and forever. I'm glad to see this made it into 2.1 as at least a basic feature.

Also available in: Atom PDF