在Python调试器中打破成员函数 [英] Breaking at a member function in the Python debugger

查看:89
本文介绍了在Python调试器中打破成员函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该是一个微不足道的问题,但是到目前为止,我的搜索是无效的:



我第一次使用Python调试器(pdb),很高兴找到使用gdb熟悉的大部分命令。



但是,当我在 parse ()中设置断点时,

 (Pdb)b JamParser.parse 
***指定的对象'JamParser.parse'不是一个函数
或者没有在sys.path中找到。

我尝试了几种变体,包括:

 (Pdb)b jam2dot.py:JamParser.parse 

我假设,因为我从命令行调用调试器,它知道文件中的实体。这是假的假设吗?



文档表示break可以作为一个参数,但不提供任何语法帮助。那么如何按名称设置成员函数的断点?

解决方案

您需要导入名称才能引用它们在调试器中。

 (Pdb)from jam2dot import JamParser 
(Pdb)b JamParser.parse


This should be a trivial question, but my search so far has been fruitless:

I'm using the Python debugger (pdb) for the first time, and was quite pleased to find most of the commands familiar from using gdb.

However, when I went to set a breakpoint in the parse() member of class JamParser with the statement:

(Pdb) b JamParser.parse
*** The specified object 'JamParser.parse' is not a function
or was not found along sys.path.

I tried several several variants, including:

(Pdb) b jam2dot.py:JamParser.parse

I assume that since I invoked the debugger from the command line that it knows the entities in the file. Is that a false assumption?

The documentation says that break can take a function as an argument, but doesn't offer any syntax help. So how do I set a breakpoint for a member function by name?

解决方案

You need to import names before you can refer to them in the debugger.

(Pdb) from jam2dot import JamParser
(Pdb) b JamParser.parse

这篇关于在Python调试器中打破成员函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆