Tutorial
Komodo can debug Ruby programs locally or remotely. The instructions below describe how to configure Komodo and Ruby for debugging. For general information about using the Komodo debugger, see Komodo Debugger Functions.
Debugger commands can be accessed from the Debug menu, by shortcut keys, or from the Debug Toolbar. For a summary of debugger commands, see the Debugger Command List.
To specify which Ruby interpreter Komodo uses for debuging:
To start a local Ruby debugging session:
On the Debug menu or Debug Toolbar, click Go/Continue or Step In to invoke the debugging session. See Komodo Debugger Functions for full instructions on using Komodo's debugging functionality.
Note: Mac OS X users may have to install a more recent
version of Ruby (1.8.4 or greater). Linux users on x86_64 systems will need to
install a 64 bit version of the ruby-debug
library (see the Komodo FAQ entry for more
information).
When debugging a Ruby program remotely, the program is executed on the remote system and the debug output is sent to Komodo. Komodo controls the debugging session (e.g. stepping and breakpoints) once the session starts on the remote system.
dbgdir
variable
to specify the location of the remote mahcine directory where
you copied rdbgp.rb and its associated files.
Windows
set dbgdir=<Path_To_rbdbgp.rb>
Linux/Mac OS X
dbgdir=<Path_To_rbdbgp.rb>
RUBYDB_OPTS
variable his supplies the Ruby interpreter with the information
that is necessary to connect to the Komodo application running
on the local machine.
Windows
set RUBYDB_OPTS=remoteport=<ServerName>:<Port> set RUBYOPT=
Linux/Mac OS X
export RUBYDB_OPTS=remoteport=<Server_Name>:<Port> unset RUBYOPT
Windows
ruby -I%dbgdir% -r %dbgdir%\rdbgp.rb <Program_To_Debug.rb>
Linux/Mac OS X
ruby -I"$dbgdir" -r "$dbgdir"/rdbgp.rb <Program_To_Debug.rb>The remote file will open in Komodo with the debugger stopped at the first line of executable code. A yellow arrow indicates the current position. You can now set breakpoints in this file, step through, and use other Komodo debugging features as if it were a local file. However, you cannot modify the file.
To break into a remote debugging session directly from within your Ruby code, insert the following:
ENV['RUBYDB_OPTS'] = 'remoteport=<Server_Name>:<Port>' $:.push('<Path_To_rdbgp.rb>') require 'rdbgp'
The first two lines set up the environment for remote debugging (similar to steps three and four above). The third line loads the debugger which breaks immediately by default.
Once the debugger has been loaded, subsequent breaks can be
specified in the program with the
Debugger.current_context.stop_next
function. It's a
good idea to wrap this function in a begin ... end
block in case the module wasn't loaded:
begin; Debugger.current_context.stop_next = 1; rescue Exception; end
These in-code breakpoints can be easily toggled by changing the boolean value (i.e. 1 = enabled, 0 = disabled).
Rubygems is the most commonly used framework for managing third-party Ruby modules.
Rubygems is included with the One-Click Installer (available
at http://rubyforge.org/projects/rubyinstaller/).
This installer adds the environment variable
RUBYOPT=rubygems
to the list of system variables.
This is usually correct behavior, as it automatically enables all
your Ruby scripts to use rubygems to find modules. However, it
will cause the Ruby debugger to always step into a file called
ubygems.rb
(a simple wrapper around
rubygems.rb
) when debugging.
There are three ways to avoid this:
RUBYOPT
environment variable
an empty string.RUBYOPT
in the
User Environment Variables box, and leave its
value empty.Ruby on Rails applications can be debugged locally or remotely just like any other ruby application. However, since much of the Rails framework has to run within the debugger, the process is normally slower than with a standalone ruby program.
dbgdir
and RUBYDB_OPTS
.Windows
ruby -I%dbgdir% -r %dbgdir%\rdbgp.rb script/server
Linux/Mac OS X
ruby -I"$dbgdir" -r "$dbgdir"/rdbgp.rb script/server
The remote files will open in Komodo with the debugger stopped at the first line of executable code. A yellow arrow indicates the current position. You can now set breakpoints in this file, step through, and use other Komodo debugging features as if it were a local file. However, you cannot modify the file.