We have used pdb.set_trace() to set a breakpoint before we run the program.
Often we want to add break points at specific points in the program after our debugging session has begun.
The option b is our friend here.
Lets start executing our program again.
['debugger.py', '1', '2']
> /Users/someuser/debugger.py(15)main()
-> addition = add(sys.argv[1], sys.argv[2])
(Pdb)
Now let me set a breakpoint on line 18.
-> addition = add(sys.argv[1], sys.argv[2])
(Pdb) b 18
Breakpoint 1 at /Users/someuser/debugger.py:18
(Pdb) c
We are in add--
3
> /Users/someuser/debugger.py(18)main()
-> print subtraction
(Pdb) p subtraction
-1
(Pdb)
As we see above pdb jumped right to line 18 and is waiting for the next action.
Also pdb assigned a number to to the break point (in this case 1). We can user enable/disable breakpoint number to enable/disable the break point for future executions.