Re: debugging proposal

Thanks! Somehow I did not spot this…

I’ll give it another go then.

Cheers,
Max

On Thu, Jul 06, 2006 at 04:24:41PM +0900, Max M. wrote:

Thanks! Somehow I did not spot this…

I’ll give it another go then.

I went ahead and simplified the code + made an extension (you can find
it
attached).
[Florian, are you reading this?]

BTW, it now works with ruby 1.8 too (just remove the File.expand_path
calls in
dbg.rb).

$ ruby19 -rrdebug dbg.rb
[["/home/batsman/mess/2006/27/rdebug/debugee.rb", 7],
["/home/batsman/mess/2006/27/rdebug/debugee.rb", 3]]
Dbg.rb
Breakpoint /home/batsman/mess/2006/27/rdebug/debugee.rb:3
(Debugee#hello)
(Dbg):caller
["(eval):1:in `Debugee#hello’", “dbg.rb:36”]
(Dbg):c
Dbg.rb
Breakpoint /home/batsman/mess/2006/27/rdebug/debugee.rb:7 (Debugee#say)
Local variables:
what: “World”
(Dbg):what = “foooo”
“foooo”
(Dbg):c
“Hello foooo”

$ cat debugee.rb
class Debugee
def hello
say “World”
end

    def say( what )
            p "Hello #{what}"
    end

end
$ cat dbg.rb
require “debugee”

set_breakpoint_func proc { |event, file, line, id, binding, klass,
*rest|
puts “Dbg.rb”
prompt = true
puts “Breakpoint #{file}:#{line} (#{klass}##{id})”
lvars = eval(“local_variables”, binding)
unless lvars.empty?
puts “Local variables:”
lvars.each{|x| val = eval(x, binding); puts “#{x}: #{val.inspect}” }
end
print “(Dbg):”
while prompt and input = readline.chomp
next if input == “”
case input
when “c”
prompt = false
else
begin
res =eval(input,binding)
p res
rescue Exception, StandardError, ScriptError => e
p e
nil
end
end
print “(Dbg):” if prompt
end
}

add_breakpoint File.expand_path("./debugee.rb"), 3
add_breakpoint File.expand_path("./debugee.rb"), 7
p breakpoints

c = Debugee.new
c.hello

Mauricio F. wrote:

I went ahead and simplified the code + made an extension (you can find it
attached).
[Florian, are you reading this?]

Yup, and I’m wondering if I could use this for implementing fast
stepping support in ruby-breakpoint.

Anything else I’m missing that this might buy me? It would be nice if I
could get away from the Ruby implementation of Binding.of_caller() soon.

Thank you!

My ruby-debug extension is doing precisely that. It keeps track of
bindings
along the program execution and allows fast stepping. Basically it’s a
standard debug.rb library with a small native extension which uses new
Ruby C API calls rb_add_event_hook/rb_remove_event_hook to keep track
of
method execution and to check for breakpoints.

http://www.datanoise.com/articles/2006/07/07/faster-debugger-for-ruby
Kent