13518219792

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

创新互联Python教程:bdb—-调试器框架

bdb —- 调试器框架

源代码: Lib/bdb.py

创新互联建站专注为客户提供全方位的互联网综合服务,包含不限于网站制作、成都做网站、莱山网络推广、小程序开发、莱山网络营销、莱山企业策划、莱山品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联建站为所有大学生创业者提供莱山建站搭建服务,24小时服务热线:18982081108,官方网址:www.cdcxhl.com


bdb 模块处理基本的调试器函数,例如设置中断点或通过调试器来管理执行。

定义了以下异常:

exception bdb.BdbQuit

由 Bdb 类引发用于退出调试器的异常。

bdb 模块还定义了两个类:

class bdb.Breakpoint(self, file, line, temporary=False, cond=None, funcname=None)

这个类实现了临时性中断点、忽略计数、禁用与(重新)启用,以及条件设置等。

中断点通过一个名为 bpbynumber 的列表基于数字并通过 bplist 基于 (file, line) 对进行索引。 前者指向一个 Breakpoint 类的单独实例。 后者指向一个由这种实例组成的列表,因为在每一行中可能存在多个中断点。

When creating a breakpoint, its associated file name should be in canonical form. If a funcname is defined, a breakpoint hit will be counted when the first line of that function is executed. A conditional breakpoint always counts a hit.

Breakpoint 的实例具有下列方法:

Breakpoint instances have the following attributes:

class bdb.Bdb(skip=None)

Bdb 类是作为通用的 python 调试器基类。

这个类负责追踪工具的细节;所派生的类应当实现用户交互。 标准调试器类 (pdb.Pdb) 就是一个例子。

如果给出了 skip 参数,它必须是一个包含 glob 风格的模块名称模式的可迭代对象。 调试器将不会步进到来自与这些模式相匹配的模块的帧。 一个帧是否会被视为来自特定的模块是由帧的 __name__ 全局变量来确定的。

3.1 新版功能: skip 参数。

Bdb 的以下方法通常不需要被重载。

通常情况下派生的类不会重载下列方法,但是如果想要重新定义停止和中断点的定义则可能会重载它们。

派生的类应当重载这些方法以获取调试器操作的控制权。

派生类与客户端可以调用以下方法来影响步进状态。

派生的类和客户端可以调用下列方法来操纵中断点。 如果出现错误则这些方法将返回一个包含错误消息的字符串,或者如果一切正常则返回 None

派生类与客户端可以调用以下方法来获取一个代表栈回溯信息的数组结构。

以下两个方法可由客户端调用以使用一个调试器来调试一条以字符串形式给出的 statement。

最后,这个模块定义了以下函数:

bdb.checkfuncname(b, frame)

Return True if we should break here, depending on the way the Breakpoint b was set.

If it was set via line number, it checks if b.line is the same as the one in frame. If the breakpoint was set via function name, we have to check we are in the right frame (the right function) and if we are on its first executable line.

bdb.effective(file, line, frame)

Return (active breakpoint, delete temporary flag) or (None, None) as the breakpoint to act upon.

The active breakpoint is the first entry in bplist for the (file, line) (which must exist) that is enabled, for which checkfuncname() is True, and that has neither a False condition nor positive ignore count. The flag, meaning that a temporary breakpoint should be deleted, is False only when the cond cannot be evaluated (in which case, ignore count is ignored).

If no such entry exists, then (None, None) is returned.

bdb.set_trace()

使用一个来自调用方的帧的 Bdb 实例开始调试。


本文题目:创新互联Python教程:bdb—-调试器框架
标题链接:http://cdbrznjsb.com/article/dpoispo.html

其他资讯

让你的专属顾问为你服务