Breaking at a member function in the Python debugger

匿名 (未验证) 提交于 2019-12-03 01:48:02

问题:

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?

回答1:

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

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


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!