Remote Debugging
I've just released a new version of ruby-debug which has a new feature: remote debugging. In order to use it you have to pass -s parameter to rdebug script:
$ rdebug -s <script.rb>
This option makes the debugger start listening for an incoming TCP connection on port 8989, by default. You can change the default port and host name with -p and -h option respectively.
Now when the debugger is started this way, you can connect to it using this command:
$ rdebug -c
Also since this feature is implemented using plain sockets, you can connect to the remote debugger using a plain telnet client:
$ telnet localhost 8989
Trying ::1...
Connected to localhost.
Escape character is '^]'.
script/../config/../app/controllers/shop_controller.rb:28: product_id = params['id']
PROMPT (rdb:3)
list
[23, 32] in script/../config/../app/controllers/shop_controller.rb
23 end
24 end
25
26 def product
27 debugger
=> 28 product_id = params['id']
29 unless product_id
30 redirect_to :action => 'index'
31 return
32 end
PROMPT (rdb:3)
cont
API Changes
One more thing. There are two important changes have been made.
First off, starting from this version when you require 'ruby-debug', it doesn't activate the debugger by default. You have to explicitly activate it by calling
Debugger#startmethod. Also if you want to activate remote debugging, you should start the listener server by callingDebugger#start_server(host, port)method.require 'ruby-debug' Debugger.start_server Debugger.startSecond off, it used to be possible at the debugger prompt to type anything and the debugger evaluates the expression, now you should use eval or p command.
Win32 gem
Thanks to Max Muermann, win32 version of ruby-debug 0.1.5 is available for download. The ruby-debug 0.2 version is coming too.
Update: win32 version of ruby-debug 0.2 is now available.
Hi,
I have upgraded to this version and my problem is fixed.
10x for this great piece of software.
I’m confused about how to use the remote debugger on win32. If I go to a rails directory and type
rdebug -s script/console
I still see the normal, local debugger in operation. And if I open up a second command prompt and type
rdebug -c
(no host or port), it says “Connected”. But then I can’t type anything.
If I go down to the rdebug server window and type “c” to continue the program, console starts up and gives me its input prompt. Still nothing shown on the client window.
And if I try to telnet to port 8989 at any time, it just immediately hangs up on me.
Jay,
Yeah, it’s a little bit confusing. It works like that:
1. When you start your application with:
2. Then you connect to the debugger with
I know it’s a little bit confusing, but I open to suggestions though.