Updated 2008-07-31 08:24:33 by tb

Purpose: to discuss the tools and techniques for debugging Tcl/Tk/etc. applications making use of Tcl's introspection capabilities.

  • Tools to leverage Tcl's native introspection
  1. TkInspect (the Tcl Dev Kit has an enhanced version)
  2. TkCon
  3. XotclIDE
  4. TclTalk uses introspection to present all namespaces, variables and procedures of the running interperter.
  • Techniques
  1. info is your friend. escargo is fond of using a proc containing puts [lindex [info level -1] 0 ]

[I'd love to see pointers to tutorials, white papers, etc. on how to make use of tkinspect, tkcon, etc. for debugging Tcl/Tk applications].

So would I :-)

[PT] 21-Jun-03: I've added a tkinspect tutorial to the Tkinspect page.

[tb] 2008-07-30: Debugging with TclTalk

Allthough there is no real debugger in TclTalk, its browser always allows a live view into variables. To halt a script at a certain line, insert the line vwait ::MySemaphore, or what you like to name the variable. Also you could output a string to the transcript saying, that your program is halted. Then you may inspect your variables of interest (or even change them :) using one browser and another one to toggle your semaphore and continue your script.

When debugging a Tk app, then it might be usefull to do a wm withdraw .mywindow, to hide your app and not change the state of it by GUI events, which might occur accidently. Use wm deiconify .mywindow afterwards, to make your application visible again.

Category Debugging