# Re: debugging proposal

**URL:** <https://www.ruby-forum.com/t/re-debugging-proposal/97306>\
**Category:** Ruby\
**Created:** [July 6, 2006, 9:26am UTC](https://www.ruby-forum.com/t/re-debugging-proposal/97306 "2006-07-06T09:26:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fangheuschrecke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/58956e/32.png) [@fangheuschrecke](https://www.ruby-forum.com/u/fangheuschrecke)\
**Post date:** [July 6, 2006, 9:26am UTC](https://www.ruby-forum.com/t/re-debugging-proposal/97306/1 "2006-07-06T09:26:31Z")

</div>

Thanks! Somehow I did not spot this…

I’ll give it another go then.

Cheers,  
Max

---

<div class="post-metadata">

**Author:** ![fangheuschrecke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/58956e/32.png) [@fangheuschrecke](https://www.ruby-forum.com/u/fangheuschrecke)\
**Post date:** [July 6, 2006, 12:34pm UTC](https://www.ruby-forum.com/t/re-debugging-proposal/97306/2 "2006-07-06T12:34:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fangheuschrecke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/58956e/32.png) [@fangheuschrecke](https://www.ruby-forum.com/u/fangheuschrecke)\
**Post date:** [July 8, 2006, 8:24pm UTC](https://www.ruby-forum.com/t/re-debugging-proposal/97306/3 "2006-07-08T20:24:34Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![fangheuschrecke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/58956e/32.png) [@fangheuschrecke](https://www.ruby-forum.com/u/fangheuschrecke)\
**Post date:** [July 8, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/re-debugging-proposal/97306/4 "2006-07-08T21:02:01Z")

</div>

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](http://www.datanoise.com/articles/2006/07/07/faster-debugger-for-ruby)  
Kent
