Open
Description
Feature or enhancement
Support instruction-level debugging in pdb
-
li
andlli
to display instructions with source code - current instruction display before interaction
-
si
andni
command - test
- documentation
Pitch
pdb
could provide a better debugging experience by supporting instruction level debugging. We already have most of the utilities but we need to put them together.
The new commands will be introduced: li(listinst)
, lli(longlistinst)
, si(stepinst)
and ni(nextinst)
(Another candidate would be dis
, which is short for import dis; dis.dis()
).
li
and lli
will list source file with the instructions.
(Pdb) lli
4 def f():
0 RESUME 0
5 a = [1, 2, 3]
2 BUILD_LIST 0
4 LOAD_CONST 1 ((1, 2, 3))
6 LIST_EXTEND 1
8 STORE_FAST 0 (a)
6 breakpoint()
10 LOAD_GLOBAL 1 (NULL + breakpoint)
20 CALL 0
30 POP_TOP
7 -> g(a)
32 LOAD_GLOBAL 3 (NULL + g)
42 LOAD_FAST 0 (a)
44 CALL 1
--> 54 POP_TOP
56 RETURN_CONST 0 (None)
si
will step one instruction ahead and ni
will stay in this frame. We have opcode
event to support this.
> /home/gaogaotiantian/programs/mycpython/example.py(7)f()
-> g(a)
(Pdb) ni
> /home/gaogaotiantian/programs/mycpython/example.py(7)f()
-> g(a)
--> 42 LOAD_FAST 0 (a)
(Pdb) ni
> /home/gaogaotiantian/programs/mycpython/example.py(7)f()
-> g(a)
--> 44 CALL 1
(Pdb) si
--Call--
> /home/gaogaotiantian/programs/mycpython/example.py(1)g()
-> def g(x):
--> 0 RESUME 0
Previous discussion
Did not find any.