Version 11 of Debugging via introspection

Updated 2008-07-30 16:08:50 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, use 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 :) and use a second browser to reset you semaphore and go on with 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