A graphical debugger would work as for other languages, you would be able to set breakpoints (positional or conditional), step over and into commands (commands being everything in the source including letters of course), view the stack (if such a thing exists in TeX..) examine variables, etc.
IMO it would make sense, and you are not the first to think about it. Unfortunately, it seems that previous projects to bring a such tool to TeX have been discontinued:
- Lutz Birkhahn. Tdb: An X11 TEX Debugger. Proceedings of the Eight European TEX Conference, September 26-30, 1994, Gdansk, Poland, pp 91-95.
A small report can be found here, p27:
Lutz Birkhahn discussed his work on developing debugging tools for TEX and presented Tdb, an extension to TEX that provides an interface to the Tk/Tcl X11 toolkit. This allowed him to set up a graphical user interface to allow one to set breakpoints, have stepwise execution, and to look at macro definitions and the value of variables.
However, it seems that ConTeXt does have a kind of visual debugging commands:
You can check ConTeXt's \showmakeup command from ConTeXt documentation:
We can visualize boxes by using \ruledhbox, \ruledvbox and \ruledvtop instead of \hbox,
\vbox and \vtop. With \showmakeup we can visualise everything automatically and we can
get some insight on the features of ConTEXt and TEX.
also featured in ConTeXt wiki: http://wiki.contextgarden.net/Visual_Debugging
At every point on the way you should be able to view the output, and this might be the most difficult part: can one view the partial dvi or pdf that is generated?
What about synctex? http://www.river-valley.tv/direct-and-reverse-synchronization-with-synctex/