Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breaking at a member function in the Python debugger

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?

like image 907
Codie CodeMonkey Avatar asked Jun 30 '11 16:06

Codie CodeMonkey


1 Answers

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

(Pdb) from jam2dot import JamParser
(Pdb) b JamParser.parse
like image 108
Gareth Rees Avatar answered Sep 30 '22 03:09

Gareth Rees