The ZeroBugs debugger allows you to automate debugging tasks using the Python programming language.
If you have a build of ZeroBugs that includes the zpython.so plug-in (the Python Gate) then you may specify a script with
the command line option --py-run=path to your script.
The python plugin is unloaded if no script is specified in the command line.
As of September 2nd all builds on the download page include the Python Gate.
The debugger engine broadcasts notifications to the plug-ins. The Python Gate plug-in receives these like any other plug-in, and exposes them to user-written Python scripts. It looks up the user script for a number of functions with predefined names. If found, these functions are invoked when the events they correspond to occur. See example.
These functions are:
debugger.set_option(zero.Debugger.Option.TraceSysCalls) is called.
See example
thread.step(zero.Step.Return)
The debugger instance can be accessed from either the Process and Thread objects like so:
process.debugger()
thread.debugger()
The reason I have not exposed it as a global variable (say, zero.debugger) is that at some point in the future I might have several instances of the debugger engine running in parallel. Thus it makes more sense to think in terms of "the debugger that is attached to this thread", or "the debugger instance that is attached to this process" rather than "the debugger". I simply do not want to introduce a singleton architectural limitation at this point.
I hope to put some more format documentation together soon, meanwhile please refer to these examples.
You need to get the glade file and glade project in order to run the Gtk example.
The source code for a more sophisticated Gtk project that wants to replace the current GUI with a lightweight Python implementation can be browsed here and downloaded from here.
This example illustrates how to augment the command line interface. This script attempts to implement the Debugger Machine Interface (work in progress).
I have generated the documentation for the ZeroBUGS classes and functions that can be used from Python scripts, with the following script:
import zero
import pydoc
import sys
def on_init(debugger):
f = open("zero.html", "w")
f.write("Zero Python Documentation ")
doc = pydoc.HTMLDoc()
f.write(doc.docmodule(zero))
f.write("")
f.close()
sys.exit(0)
I ran the debugger invoking the script, like this:
zero --py-run=gendoc.py
Happy hacking!