Tcl Tutorial

 

Table of Contents

Debugging the Program

In this step you'll add breakpoints to the program and "debug" it. Adding breakpoints lets you to run the program in chunks, making it possible to watch variables and view output as it is generated. Before you begin, ensure that line numbers are enabled (View|View Line Numbers). Open "dlg_tcl_check.tcl" in the Komodo editor (if it is not already open).

  1. Set a breakpoint Click in the grey margin immediately to the left of the code on line 113 of the program. This will set a breakpoint, indicated by a green circle.
  2. Run the debugger Select Debug|Start (or <F5>, or use the Debug Toolbar). In the Debugging Options dialog box, click OK to accept the defaults. The debugger will process the program until it encounters the first breakpoint.

Komodo Tip Debugger commands can be accessed from the Debug menu, by shortcut keys, or from the Debug Toolbar. For a summary of debugger commands, see Debugger Command List.

  1. Watch the debug process Notice that the breakpoint turns red, which indicates that the debugger is running. A yellow arrow on the breakpoint indicates the position at which the debugger has halted.
  2. Line 113: Step Into Select Debug|Step Into. "Step Into" is a debugger command that causes the debugger to execute the current line and then stop at the next processing line. In this case, the debugger will open the GUI definition file (dlg_tcl_check_ui.tcl). This file initializes the graphical elements in the applications.
  3. Line 23: Step Out Select Debug|Step Out to run the rest of the code in dlg_tcl_check_ui.tcl. The debugger will stop on line 118 in dlg_tcl_check.tcl.
  4. View variables pane In the Output Pane, click the Debug Variables tab. Click the Globals tab, and drag the $example_radiobutton variable to the Watched Variables pane.
  5. Line 118: Step Into Line 118 will launch the application. Note that the debugger appears to be inactive (for example, no yellow arrow indicates the current debugger position). The debugger is waiting for action from the application.
  6. Click "Check it out" When you click the "Check it out" checkbox in the application, the debugger will move to line 35.
  7. Set a breakpoint Click the breakpoint margin on line 39 to set a breakpoint.
  8. Line 35: Run Select Debug|Continue. The debugger will stop on line 39.
  9. Line 39: Step Into Select Debug|Step Into. Focus returns to the application. Click the "Radio Liberty" radio button. The debugger will move to line 62. Notice that the $example_radiobutton variable in the Watched Variables pane now has the value "liberty". This association is defined in the dlg_tcl_check_ui.tcl file.
  10. Line 62: Step Into Select Debug|Step Into until line 63 is executed. This will return focus to the application, and write "The Liberty Sessions" text to the label.
  11. Click the OK button This will stop the debugger.

Komodo Tip What do the debugger commands do?

  • Step In executes the current line of code and pauses at the following line.
  • Step Over executes the current line of code. If the line of code calls a function or method, the function or method is executed in the background and the debugger pauses at the line that follows the original line.
  • Step Out when the debugger is within a function or method, Step Out will execute the code without stepping through the code line by line. The debugger will stop on the line of code following the function or method call in the calling program.

Top Previous Next