There are several ways to debug a program.
To debug a TCL file locally, apply the following steps:
Files->Open file
. To make a test, use the example located in <RamDebugger directory>/Examples/example1.tcl
Debug->Set breakpoint
or press F9
after having the cursor in the desired line. Debug->Go
or press F5
. A grey arrow at the left of the text indicates that the program has stopped in that line. Debug->Next
or press F10
. Edit->Goto line->27
and press Debug->Continue to
set cc $bb--qq
to:
set cc $bb--qq2
Debug->Step
or press F11
. Debug->Expressions
and write: [string length $i]+3
Return
. To debug a TCL file remotely, apply the following steps:
wish example2.tcl
Files->Open file
. In this case, use the example located in <RamDebugger directory>/Examples/example2.tcl
Debug->Set breakpoint
or press F9
after having the cursor in the desired line. File->Debug on->Update remotes
before finding the remote program in the menu list. Depending on the computer (in Windows), it can be necessary to wait for several seconds for RamDebugger to find the remote program. To debug remotely, in Windows it is necessary to load the package comm
in the remote program. To do so use add something similar to the code below in you program, in any place that gets executed before beginning the debug session (typically at the beginning of your program):
lappend ::auto_path <RamDebugger path>/addons
package require commR
comm::register application_name 1
Note:
The package commR
included in RamDebugger is based on the package comm
in tcllib with some modifications. Use always commR
instead of comm
. This package uses sockets for communication. If you have a firewall in your computer, maybe it will not work. In Linux/Unix, the communication is made with the command send
, So, it is only necessary to have this command enabled in the program, which is true by default. Note:
It can be necessary to check the security of the server in Unix before being able to use send
. As a fast workaround, write command xhost -
in the UNIX command line.
Note: Package commR can also be used in Unix and MacOSX .
Check example4.tcl
to see how Ramdebugger
can be used as a package.
It is possible to add a command in the debugged program that stops execution and waits for RamDebugger to be connected to it remotely. Command is:
commR::wait_for_debugger
Check example "example2b.tcl"for details.
GiD is a pre/postprocessing program for Finite Element Analysis that uses TCL/TK as its extension language http://www.gidhome.com .
To debug GiD in Windows, it is necessary to load the comm
package. Do it in file: <GiD installation dir>/scripts/tclfile-opengl
around line 420 before section Debug funcs
.
In UNIX, it should work directly.
Check section Debugging remotely
for the rest of the steps to follow. Check section Debugging as package
for an alternative way of debugging GiD. Specifically, the package require RamDebugger should be added near the end of file <GiD installation dir>/scripts/tclfile-opengl
.
As a good debugger must do, RamDebugger permmits to debugger itself. As it is not a simple code, this is a good testing of the program capabilities. It can be debugged either locally or remotely. To debug itself locally, open TCL source file RamDebugger.tcl
and choose File->Debug on->Currentfile
. See Debugging locally
for details. To debug itself remotely, open two RamDebuggers. From one of them, connect to the other with File->Debug on->RamDebugger
. In Windows
, if option Automatically check remote files
is unset (the default), it can be necessary to use Debug on-> Update remotes
on both RamDebuggers.