Eigen Class
Posts: 358
Nickname: eigenclass
Registered: Oct, 2005
|
Eigenclass is a hardcore Ruby blog.
|
|
|
|
Binding.of_caller and breakpoint breaking in 4 days (Ruby 1.8.5)
|
Posted: Aug 22, 2006 11:48 AM
|
|
You might have heard of Florian Gro��' Binding.of_caller before. More
probably, you might have used his breakpoint library (yes, the one included
in Rails, which can be used with script/breakpointer). If you read ruby-core
a few months ago, you'll know that it only worked thanks to a bug which is
being fixed in Ruby 1.8.5. Which means that breakpoint will be breaking in
under a week time, since
matz is releasing 1.8.5 next Friday or Saturday at the latest.
Fortunately, I'd kept an unreleased rcov branch with some 500 lines of C to
implement a better Kernel#caller method, which I
had discarded at first because there was a much easier way to proceed when bindings
were not needed.
So, I have the functionality that will keep breakpoint alive after the arrival of
1.8.5, but I need some help to refine the interface before it can be released; better get the naming right the first time, and this is something several
brains tend to do better than one.
This is what it looks like currently:
require 'binding_n'
def a; _a = 1; b end
def b; _b = 2; c end
def c; _c = 3; d end
def d; _d = 4; send(:e) end
def e
levels = binding_n(10)
levels.each do |klass, id, file, line, binding, lang|
puts "=" * 80
p [klass, id, file, line, lang]
next unless binding
p eval("local_variables", binding).map{|x| [x, eval(x, binding)]}
end
end
def x
Kernel.install_binding_n_hook
a
Kernel.remove_binding_n_hook
end
x
Read more...
Read: Binding.of_caller and breakpoint breaking in 4 days (Ruby 1.8.5)
|
|