This post originated from an RSS feed registered with Ruby Buzz
by Eric Hodel.
Original Post: Inliners are Hard to Debug
Feed Title: Segment7
Feed URL: http://blog.segment7.net/articles.rss
Feed Description: Posts about and around Ruby, MetaRuby, ruby2c, ZenTest and work at The Robot Co-op.
require 'rubygems'
require 'super_caller'
require 'super_caller/exception'
class X
def y; z; end
def z; raise; end
end
begin
X.new.y
rescue => e
e.backtrace .each do |frame|
puts frame
puts frame.source || frame.sexp.inspect
puts "---"
end
end
Gives:
/usr/local/lib/ruby/gems/1.8/gems/SuperCaller-1.0.0/lib/super_caller/exception.rb:12:in `initialize'
def initialize(message)
old_initialize(message)
@backtrace = super_caller
end
---
test.rb:7:in `new'
[[:vcall, :raise]]
---
test.rb:7:in `z'
[[:vcall, :raise]]
---
test.rb:6:in `y'
def y
z
end
---
test.rb:11
[[:call, [:call, [:const, :X], :new], :y]]
---