What is Mr. Guid?
Mr. Guid has all the features that Ruby's bundled debugger has, but also remote debugging.
- Ruby 1.8.2 or higher.
and libglade2) 0.13 or higher.
- Windows users can view the install guide here.
- Mac users (thanks to Rob Pitt) must download DarwinPorts and
run the command
sudo port install libgnomecanvas libgnomeui libgnome libglade2. You should now be able to compile Ruby-GTK2
- Download Mr. Guid
(If you'd like the latest version, possibly unstable, you can get it from the SVN Repository.)
- Untar/unzip the files to any directory
- cd into the directory created (mr_guid_x.x)
- [Windows only] Skip the following step. You're done, but can create shortcuts as you wish. Mr. Guid must still be run from the command line/prompt though.
- One of the following:
- (As root)
./install.rbto install the mr_guid executable in /usr/local/bin
./install.rb --prefix=[other_dir]to install the mr_guid executable in a desired directory
- Nothing! You can just call mr_guid by its absolute or relative path
- (As root)
The Windows version of Mr. Guid can be unstable and appear to freeze. This is a combination of threading issues and TCP issues with relation to Windows only. The Unix/Linux version of Mr. Guid functions as it should. I don't have the time or patience to work out a perfectly functioning Windows version, but would welcome any help.
Starting Out (Local Debugging)
To start debugging filename normally, type in the console:
mr_guid [filename] [args](Windows users will use the appropriate shortcut or file name for mr_guid.)
Starting Out (Remote Debugging)
To start debugging filename remotely, run the command:
ruby -r gdebug.rb [filename] [args] -r[=[host:]port]and then (separately):
Source files will be transferred over the connection as they are needed, so local copies are not needed.
-rmay be substituted with
--remoteand can appear anywhere after file in either gdebug or mr_guid. Order does not matter.
Command Line Options
mr_guid [options] [filename] [args]
Starts debugging script on [[host:]port] (use this if you want to debug script on non-default port or host)
Debugs remote script running on [[host:]port] or default localhost:3001
ruby mr_guid.rb my_script.rb
starts debugging my_script normally (localhost:3001)
ruby mr_guid.rb -l=5000 my_script.rb
starts debugging my_script on localhost:5000
ruby -r gdebug.rb my_script.rb -r
[elsewhere on same host]
ruby mr_guid.rb -r
starts debugging my_script remotely over default localhost:3001
- [on 192.168.0.10]
ruby -r gdebug.rb my_script.rb -r=5000
ruby mr_guid.rb -r=192.168.0.10:5000
starts debugging my_script remotely on 192.168.0.10:5000
Manual File Loading
Source files can be manually loaded by selecting 'load source file' from the 'debug' menu and typing in the absolute or relative path to the source file. You can then add breakpoints if desired.
Breakpoints can be placed by:
- Double-clicking (or activating) a source line.
- Selecting 'toggle breakpoint on line...' from the 'breakpoints' menu and entering the line number.
Double-clicking (or activating) local or global variables brings up the Object View. This view lists the object's instance variables (if any) and the object's available methods. In order to edit a variable, enter in the new value or expression at the bottom of the window.
Variables that are objects can have instance variables. They can be viewed by double-clicking (or activating) the object which in turn brings up a window showing all instance variables. If an instance happens to be an object containing more instance variables, they can be accessed, provided that the parent object says it is readable (attr_reader for example).
Threads can be stopped or resumed by selecting the desired thread in the view and selecting the appropriate option from the menu, selecting an action and entering the thread number, or right-clicking the thread and selecting an option.
You can move around stacks by:
- Double-clicking (or activating) a stack in the view.
- Select an action from the 'stack' menu.
- Select 'move to stack #...' from the 'stack' menu and enter in the desired stack's number.
You can enter in any command Ruby's bundled debugger understands in the text field to execute it.
- Alt+N = View next source file
- Alt+P = View previous source file
- Ctrl+S = Focus to source view
- Ctrl+L = Focus to Local Vars view
- Ctrl+G = Focus to Global Vars view
- Ctrl+T = Focus to Threads view
- Ctrl+A = Focus to Stack view
- Ctrl+E = Focus to command text field
- Ctrl+N = Next line (in any view)
- Ctrl+P = Previous line (in any view)
- Enter or Space activates the current line in any view
- Typing into the source view goes to that line number
- Typing into variable views searches for variables by name
- Typing into the methods view searches for the method by name
- Typing into threads view searches for threads by number
- Typing into the stack view searches for the stack by name
- Ctrl+I (instance vars window) = Focus to Instance Vars view
- Ctrl+E (instance vars window) = Focus to object value entry
I would like to thank Matthias Georgi for all of his help in helping me improve Mr. Guid.