I am writing a web debugger for Ruby, but for this I need to be able to call the Ruby debugger from a server-side Ruby program. Has this ever been done? Is it possible?
The final product being designed will allow you to edit, execute, and edit Ruby code using only a web browser. The ruby code that needs to be debugged will be "eval" ed on the server side.
Since then, I pointed in the right direction to one of the users of stackoverflow, who suggested using popen or waiting. I tried both of them now, but ran into the following problems:
popen: When waiting for the console, you need to use the timeout block to signal that the debug console output is complete (the command line terminal can detect this, so why not chop).
Expect: in the program below, the debugger inputs go out of sync with the debugger. Why is this?
require 'pty'
require 'expect'
$ expect_verbose = true
PTY.spawn ("rdebug deb.rb") do | from_debugger, to_debugger, pid |
a = nil
while (a! = "end") do
from_debugger.expect (/ \ (rdb: 1 \) /) do | input |
a = gets
to_debugger.puts (a + "\ n")
end
from_debugger.flush
end
end
source
share