Python (pdb) - 排队要执行的命令
我正在实现一个用于 Python 开发的“断点”系统,该系统允许我调用一个函数,该函数本质上调用 pdb.set_trace();
我想要实现的一些功能要求我在 set_trace 上下文中时通过代码控制 pdb。
示例:
disableList = []
def breakpoint(name=None):
def d():
disableList.append(name)
#****
#issue 'run' command to pdb so user
#does not have to type 'c'
#****
if name in disableList:
return
print "Use d() to disable breakpoint, 'c' to continue"
pdb.set_trace();
在上面的示例中,如何实现 #****
标记的注释?
在该系统的其他部分,我想发出一个“up”命令,或两个连续的“up”命令,而不离开 pdb 会话(因此用户最终会出现 pdb 提示符,但在调用堆栈上上升两级)。
I am implementing a "breakpoint" system for use in my Python development that will allow me to call a function that, in essence, calls pdb.set_trace();
Some of the functionality that I would like to implement requires me to control pdb from code while I am within a set_trace context.
Example:
disableList = []
def breakpoint(name=None):
def d():
disableList.append(name)
#****
#issue 'run' command to pdb so user
#does not have to type 'c'
#****
if name in disableList:
return
print "Use d() to disable breakpoint, 'c' to continue"
pdb.set_trace();
In the above example, how do I implement the comments demarked by the #****
?
In other parts of this system, I would like to issue an 'up' command, or two sequential 'up' commands without leaving the pdb session (so the user ends up at a pdb prompt but up two levels on the call stack).
您可以调用较低级别的方法来更好地控制调试器:
您可以在此处找到
pdb
模块的文档:http://docs.python.org/library/pdb 以及bdb
较低级别的调试接口:http://docs.python.org/library/bdb。您可能还想查看他们的源代码。You could invoke lower-level methods to get more control over the debugger:
You can find documentation for the
pdb
module here: http://docs.python.org/library/pdb and for thebdb
lower-level debugging interface here: http://docs.python.org/library/bdb. You may also want to look at their source code.