Created
July 6, 2012 15:56
-
-
Save oscardelben/3061040 to your computer and use it in GitHub Desktop.
Minimal debugger written in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def speak | |
'hello' | |
end | |
end | |
my_proc = Proc.new do |event, file, line, id, binding, classname| | |
printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname | |
while cmd = gets.chomp do | |
if cmd == 'n' | |
break | |
elsif cmd == 'c' | |
set_trace_func(nil) | |
else | |
begin | |
p eval(cmd, binding) | |
rescue Exception => e | |
puts e.message | |
end | |
end | |
end | |
end | |
def debugger | |
set_trace_func(my_proc) | |
end | |
debugger | |
Foo.new.speak |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment