/ Hathaway Weblog / How Boa Constructor's ZPT debugger works

Shane :: Python :: November 11, 2004 # How Boa Constructor's ZPT debugger works

Stephan Richter asked me how Boa Constructor is able to debug Zope page templates. The answer is surprisingly simple, so I thought I'd share my answer with everyone.

The trick is to provide a "view" of the Python stack and make the debugger use that view instead of inspecting the Python stack directly. ZopeScriptDebugServer (in Boa's Debugger package) is a view of the program stack. It implements a notional "program stack" interface. Each time the debugger hits a frame, the debugger asks the debug server whether it should stop at that point. The debug server has a policy that tells the debugger to stop only in a PythonScript or when the TAL interpreter is executing a setPosition byte code.

To gather stack information, the debugger uses the debug server to inspect the stack rather than accessing the stack directly. The debug server digs deep into the Python stack and generates a stack that contains ZPT filenames and line numbers rather than Python code references. This trick seems to be sufficient to turn a Python debugger into a good ZPT debugger.

ZopeScriptDebugServer uses brittle introspection methods, since TALInterpreter provides no explicit debugging hooks, but the concept is sound. It would be cool to integrate the concept of a replaceable stack view into a debugger that's smaller than Boa.

No further comments may be added.

3 Nephi 11:29 (Click below to fill in the blanks.)
Your browser is not able to display the scripture fill-in program. To see it, enable Javascript or use Mozilla 1.0 or better.

Church: lds scriptures provident games pearls kzion shiblon film chancellor gateway cumorah byutv happiness nephi
Zope: freezope org com zen labs newbies zettai warnes
Python: home pyzine daily icanprogram
Genealogy: cyndi
Weblogs: jeffrey paul jon joel another-shane guido barry jeremy windley chrism zac
News: quakes lwn dc weather deseret zeitgeist softwarelivre
Zaurus: software developer
Tech: tango spintronics thin
Semantic: aaron sean
Reference: css rdf html4 javascript geckodom iecss emacs phrases acronyms
Reverse: advogato slashdot
Misc: gimp-savvy directory soda jokes shouldexist pdphoto