0

When I run the following code to debug f:

import pdb
f = lambda x: x**2
pdb.runcall(f, 11) # type step, to step through code.

I get a prompt:

enter image description here

In this prompt I can enter commands, such as step to step through the function of interest (e.g. f).

Is there a way to automatically give the step or other commands so I can automatically walk through the code, and do some automated (crude) line by line analysis?

applecider
  • 2,311
  • 4
  • 19
  • 35

1 Answers1

1

In gdb there is and option -s to read commands from source file. I don't know such option in pdb, but there are some things, that you can do to automate debugging. First option - .pdbrc files. Pdb reads ~/.pdbrc and ./.pdbrc(if exists) on start up, so you can put there any settings, you want (commands, that you type in pdb shell, except execution manage commands, like jump, continue, etc.). Second - aliaces. Aliace body can contain pdb commands and python expressions, and they can also be recursive. Maybe it is also possible to redirect input stream from file and stay in shell after that.

VadimK
  • 535
  • 3
  • 8