views:

24

answers:

1

Hi all,

I'd like to save the commands for a breakpoint in a .pdbrc, something like:

b 81 
commands 1 
pp foo.attr1 
pp foo.attr2 
end 
b 108 
commands 2 
pp bar.attr1 
pp bar.attr2 
end 

This would automate setting the environment for the debugging session. However, this does not work with 'python -m pdb script.py', because at the line 'commands 1', the pdb prompt starts and asks me for the commands for the first breakpoint, ignoring what I wrote in .pdbrc; further, it raises a NameError after I type 'end' at the pdb prompt, because of 'foo.attr1', 'foo.attr2' and even 'end'. The same happens for the rest of the breakpoints, so I end up with them set but not their commands.

What would be the correct way to do this? Is it even possible?

Thanks a lot,

Pablo Torres N.

A: 

My first thought was that the command must be defined on one line:

commands 1;; pp foo.attr1;; pp foo.attr2;; end;;

However, it appears that this will only work at the prompt, and you will incorrectly get:

Usage : commands [bnum]
        ...
        end

if you place the line above in a .pdbrc

Looking at pdb.py it appears that the author does not properly handle defining commands in a pdbrc. I personally would just temporarily place the print lines in the code I was debugging while using pdbrc to save the breakpoints of interest to get around this.

manifest