I know that pdb is an interactive system and it is very helpful. My ultimate goal is to gather all memory states after executing each command in certain function, command by command. For example, with a code snippet
0: def foo() : 1: if True: 2: x=1 3: else: 4: x=2 5: x then the memory state of each command is
0: empty 1: empty 2: x = 1 3: x = 1 4: (not taken) 5: x = 1 To do this, what I'd like to do with pdb is to write a script that interact with pdb class. I know that s is a function to step forward in statements and print var(in the above case, var is x) is a function to print the value of certain variable. I can gather variables at each command. Then, I want to run a script like below:
import pdb pdb.run('foo()') while(not pdb.end()): pdb.s() pdb.print('x') But I cannot find any way how to implement this functionality. Can anybody help me??