Debugging Programs
Starting the DebuggerTo start the debugger, do one of the following:
By default, the Debugging Options dialog box is displayed (unless the debugger preference has been configured to start without displaying the dialog box). To override the debugger preference on Windows and Linux systems, hold down the 'Ctrl' key while invoking the key binding for starting the debug session. (Select Help|List Key Bindings to view the current key bindings; use the key bindings preference to configure custom key bindings.) Alternatively, the 'Ctrl' key can be used to suppress the display of the Debugging Options dialog box. If multiple files are open in the Editor Pane, the program that is currently displayed is debugged. If no breakpoints are set, Go/Continue causes the debugger to run to the end without stopping. Step In moves through the program one line at a time. If the Bottom Pane is hidden, Komodo automatically shows it. To run a program without debugging, do one of the following:
To run a program to the current cursor position, do one of the following:
Multi-Session DebuggingKomodo supports the concurrent debugging of multiple applications, or multi-session debugging. With multi-session debugging, Komodo debugs more than one project at a time, regardless of the supported languages used in the programs being debugged. When debugging multiple sessions, each session has a unique Debug tab (located in the Bottom Pane) for controlling the debug actions specific to that process. A Debug tab is created each time a new debugger session is started. To close a Debug tab, click the X button at the top right corner. To start multiple debugging sessions, do one of the following:
Debugging OptionsWhen the debugger is invoked, the Debugging Options dialog box is displayed. Use this to configure the system environment, command-line arguments, CGI environment, and other debugging options. Not all of the debugging options described below apply to all languages. The available tabs and fields depend on the interpreter used to debug the file. The interpreter is determined by the File Associations configured for the active file in the Editor Pane. To suppress the display of the Debugging Options dialog box on Windows and Linux systems, hold down the 'Ctrl' key while clicking the desired debugging button on the Debug Toolbar, or use the desired keyboard shortcut. Change the default display by selecting Skip debug options dialog from Edit|Preferences|Debugger.
Global OptionsThese options are displayed regardless of which configuration tabs are available.
General Tab
Environment TabThe Environment tab displays all environment variables set on the system. Use this tab to add new variables or change the values of existing variables for the duration of the debug session. The Default Environment Variables pane displays environment variables that have been declared on your system. The User Environment Variables pane displays environment variables set in the saved configuration which override the Default Environment Variables. Change variables by adding a new variable with the same name and a new value. These changes have no effect outside of the Komodo debugger and are stored in each saved configuration.
CGI Environment TabThe CGI Environment tab is only displayed if the Simulate CGI Environment check box is selected on the General tab. It displays CGI Environment Variables commonly configured on a web server. Use this tab to alter existing variables and add new variables. Variable changes have no effect outside of the Komodo debugger and are stored in each saved configuration.
CGI Input TabThe CGI Input tab is only displayed if the Simulate CGI Environment check box is selected on the Global Options tab. It is used to configure the CGI form type and variables for the purpose of simulating CGI input. Note that Komodo's CGI emulation does not generate HTTP Request Headers; rather, it executes the CGI directly by emulating a web server environment.
Use the Request Variable section of the dialog box to create variables that are processed by your CGI program. These variables are displayed in the Browser Arguments section of the dialog box.
To alter variables: Click on the desired variable in the Browser Arguments section of the dialog box, make changes in the Type, Name and Value fields, then click Update. To delete variables: click on the desired variable in the Browser Arguments section of the dialog box, and click Delete.
Storing Debug ConfigurationsDebugging options can be saved as "named configurations" in the Debug Configuration panel. To save the current configuration:
Existing saved configurations can be selected from the drop-down list. If you wish to delete a saved configuration, select it from the list and click Delete. If the file being debugged is part of a project that is currently open, these preferences are saved in that project. If not, this configuration is automatically saved as part of the file's Properties and Settings (although they cannot be altered via the file's Properties dialog box).
Breakpoints and Tcl SpawnpointsBreakpoints are set at lines in the program where you want program execution to pause. Enabled breakpoints appear as solid red circles in the left margin of the Editor pane and are also listed on the Breakpoints tab during debugging. Disabled breakpoints appear as white circles with a red outline. Double-clicking on an enabled or disabled breakpoint from the Breakpoints tab opens the associated file in the Editor Pane and shifts focus to the line number for that break location. Spawnpoints are set at points in a Tcl script where you want an external application to execute (spawn). When a spawnpoint is encountered during the debugging process, Komodo configures the spawned application to start as a new debugger session. Both the initial and spawned debugger sessions run concurrently. Enabled spawnpoints appear as solid green arrows in the left margin of the Editor pane and are also listed on the Breakpoints tab during debugging. Disabled spawnpoints appear as white arrows with a green outline. Double-clicking an enabled or disabled spawnpoint from the Breakpoints tab opens the associated file in the Editor pane and shifts focus to the line number coinciding with that spawnpoint location.
Breakpoint and Spawnpoint ManagementBreakpoints and spawnpoints can be monitored and managed on the Breakpoints tab in the Bottom pane (displayed during debugging or invoked by selecting View|Tabs|Command Output). This tab lists all breakpoints and spawnpoints set in the program. Use the Breakpoints tab to:
Toggling BreakpointsBreakpoints and Spawnpoints can be toggled between enabled, disabled and deleted. To toggle a breakpoint, do one of the following:
To create a new breakpoint in the Breakpoints tab:
To delete a breakpoint in the Breakpoints tab, do one of the following:
To clear or remove multiple breakpoints, do one of the following:
To disable or enable all breakpoints:
Toggling SpawnpointsTo add a Tcl spawnpoint, use the Breakpoints tab:
To delete a spawnpoint in the Breakpoints tab, do one of the following:
To clear or remove multiple spawnpoints, do one of the following:
To disable or enable all spawnpoints:
Note: Breakpoints and spawnpoints added or modified while a program is running are not necessarily updated in the breakpoint manager. To add breakpoints while debugging, interrupt the debugging session using the Break button to ensure that the new breakpoint is properly updated.
Go to the Source CodeTo open the source code in the Editor Pane at the line number where the breakpoint or spawnpoint is set, do one of the following:
Breakpoint PropertiesWhen adding or editing a breakpoint in the Breakpoint tab, a Breakpoint Properties dialog box appears. This dialog box contains a tab for each available breakpoint type. Change the breakpoint type by switching to a different tab. Each tab is split into two parts, separated by a horizontal line. The top section contains configuration items that are required; the bottom section contains configuration options that are optional. The last item on this tab is the Enable checkbox.
Not all breakpoint types are supported for all languages. The following table shows breakpoint support by language:
Forcing a BreakUse the Break Now function to stop debugging an application at the current execution point, and then continue debugging from that point. For example, use this control when debugging applications running long processes. To force a break while debugging an application, do one of the following:
Remote DebuggingRemote debugging is the process of debugging programs locally while they execute on remote machines. This is useful for debugging applications in the environments where they would normally be run (e.g. CGI programs in a live web server setting), and for systems built using client/server architecture. Komodo can be set to Listen for Debugger Connections continuously. Additionally, you can set remote debugger preferences and check listener status of the current listener configuration. For instructions on configuring specific languages for remote debugging, see:
Listen for Debugger ConnectionsTo toggle continuous listening for remote debugging, do one of the following:
Note: A check mark appears when Listen for Debugger Connections is enabled. Otherwise, this feature is disabled.
Check Listener StatusTo check the status and current configuration of the Komodo debugger:
Multi-User DebuggingWhen multiple users are running Komodo session, configure Komodo's Debugger Connection Options to listen for debug connections on port "0" (see Set Debugger Preferences). The system provides Komodo with a unique port each time Komodo is started, allowing multiple users on the system to debug applications simultaneously. In remote debugging, this requires the remote debugger application to be manually set to connect on the system-allocated port unless the Debugger Proxy is used.
Debugger ProxyRemote debugger processes can communicate with Komodo through the DBGP proxy (debugger protocol proxy). The proxy allows Komodo to use a system-allocated listener port for debugging without the user having to manually configure the same port number on the remote debugger. This is useful for running multiple remote debugging sessions and on networks where a remote debugging process can not connect to Komodo directly. The proxy can run on the local machine, the remote machine, or a separate machine. A typical DBGP Proxy connection is established as follows:
To start the proxy on Windows: set PYTHONPATH="<Komodo install directory>\lib\support\dbgp\pythonlib;%PYTHONPATH%" cd <Komodo install directory>\lib\support\dbgp\bin pydbgpproxy To start the proxy on Linux (requires Python 2.2 or later): export PYTHONPATH=<Komodo install directory>/lib/support/dbgp/pythonlib;$PYTHONPATH cd <Komodo install directory>/lib/support/dbgp/bin python pydbgpproxy To start the proxy on OS X: export PYTHONPATH=<Komodo install directory>/Contents/SharedSupport/dbgp/pythonlib;$PYTHONPATH cd <Komodo install directory>/Contents/SharedSupport/dbgp/bin python pydbgpproxy The following options are available:
Example If you are debugging scripts on a remote web server that cannot connect to Komodo directly because of a firewall, you can run dbgpProxy on an intermediary server (e.g. a gateway) which can connect to Komodo and the web server on specified ports. The three servers in this example are:
The debugging process on 'webserver' is launched with the following command: python dbgpClient.py -d gateway:9000 -k "jdoe" test.py The remote debugger running on 'webserver' (dbgpClient.py in this case) connects to the proxy (dbgpProxy.py) running on 'gateway'. The proxy uses the IDE Key "jdoe" to connect the debugger process to the Komodo instance listening with a Proxy Key of "jdoe". The proxy continues to communicate with the remote debugger on port 9000, but routes the debugging session to Komodo on port 37016.
Sending Input to the ProgramWhen a program prompts for input, enter the desired input in the console window or Output tab (depending on the Debugging Options configuration), and press Enter to continue.
Using Debugger Commands
Debugger Command DescriptionThis table lists common tasks and their Komodo commands.
Debugger Stepping BehaviorInstead of running to the end of a program or to the next breakpoint, the debugger can also step through code one statement at a time. The following Debug menu items and toolbar buttons control stepping behavior:
When stepping through a program which calls a function or method from an external program (e.g. a module or package) the debugger steps into the external program at the point where the function or method is called, opening it in a new tab. Stepping continues in the external program until the function call is completed. Note: Perl operators For example, if the debugger steps over a statement containing a
To skip execution of such looping constructs, set a breakpoint on the statement following the construct, and continue until Komodo reaches that breakpoint.
Viewing the Debugging SessionWhen the Komodo debugger is started, the Debug tab opens in the Bottom Pane. This tab consolidates views of the debugger output, call stack, program variables (local and global), and watch variables. The Debug tab also contains a Debug Toolbar for stepping in, out, over, and running functions while debugging. When debugging more than one session at a time (multi-session debugging), a Debug tab for each session is accessible in the Bottom Pane. The Debug tab selected is the session currently being debugged. To change to another debug session, select the Debug tab for that session (identified by the filename of the program). When a new session is started, a new Debug tab is created and Komodo automatically switches to that new session. The Debug tab is divided into two sub-panes, which have tabs of their own. The right sub-pane contains the Output, Call Stack, and HTML Preview tabs. The left sub-pane contains variable tabs.
Viewing VariablesThe variables section of the Debug tab is divided into tabs that vary according to the language of the program being debugged. (Language variations are described below.) Variables with multiple values (such as arrays) are indicated by plus and minus symbols to the left of the variable name. To Expand or Collapse Variables: Plus symbols indicate variables with multiple values that can be expanded; minus symbols indicate variables that can be collapsed. Click on the plus or minus symbol to expand or collapse the variable list. To Change Variable Values: Double-click in the variable's Value field and enter the desired value. (The value of nodes in XML documents cannot be changed.)
Python Variables and ObjectsWhile debugging Python programs, variables and objects are displayed on the Locals, Globals, and Code Objects tabs:
During Python debugging sessions, click the Show Hidden
Variables button to
display special Python variables prefixed with double underscores, such as
PHP and Tcl VariablesWhile debugging PHP and Tcl programs, variables are displayed on the Locals and Globals tabs:
Perl VariablesWhile debugging Perl programs, Argument and Special tabs are displayed in addition to the Locals and Globals tabs listed above.
XSLT VariablesWhile debugging XSLT programs, data nodes and variables are displayed on the Locals and Globals tabs:
Setting Watched VariablesThe Watch variable tab monitors selected variables and expressions. Use the Watch variable tab to watch variables, or expressions based on variables, by typing expressions, dragging and dropping expressions from an editor, or selecting variables from one of the other variable tabs. Also, use the Watch tab to change the value of a variable or remove a variable from the Watch tab. Watched variables can be added, manipulated and removed regardless of whether the debugger is currently running. To watch one or more variables during program execution:
The Watch variable tab supports viewing the results of
expressions made with watched variables. For example, in a Perl program with
scalar variables ($base / 2) * $height To enter arbitrary expressions on the Watch variable tab:
To change the values of variables:
Note: This function is not available for arbitrary expressions. To remove a variable from the Watch variable tab, select the variable and click Delete on the bottom right toolbar. Alternatively, right-click the desired variable and select Remove Watch on the context menu.
Output TabThe Output tab is used to view program output and to send input to the program being debugged. The following standard data streams are handled in the Output tab:
When debugging Tcl and Python, if
HTML Preview TabIf the program produces HTML output, select the HTML tab to preview the rendered output. Unlike the Output tab, the HTML preview is not constantly updated. Use the Reload HTML View button in the bottom-pane toolbar to update the preview.
Viewing the Call StackThe call stack is a data area or buffer used for storing requests that need to be handled by the program. Komodo's stack stores temporary data such as variables and parameters and operates as a push-down list. New data moves to the top of the stack and pushes the older data down in a "last-in, first-out" arrangement. To view the call stack in a current debugging session, select the Call Stack tab in the right pane of the Debug tab. There is one line in this tab per stack frame at any point in the execution of a program. The calling frame contains the information about a function call, including the filename, the line number, and any parameters or local variables.
Watching FilesWhen debugging a program that writes output to another file, or when watching programs execute, you can watch the output or the log file using Komodo's File Watcher. The Watch File tool shows a file as the file is being updated on disk. It has no relationship with variable viewing, except that, while debugging, it is often useful to watch variables change state and files change content. To use the File Watcher:
Detaching the DebuggerUse the Detach control to stop the debugging process but continue running the application. When application execution is detached from the debugging process, output continues to print on the Debug tab until the application finishes running. To detach application execution from the debugging process, do one of the following:
Stopping the DebuggerTo stop the Komodo debugger, do one of the following:
The debug session ends.
|