Skip to content

Support instruction-level debugging in pdb #103049

@gaogaotiantian

Description

@gaogaotiantian

Feature or enhancement

Support instruction-level debugging in pdb

  • li and lli to display instructions with source code
  • current instruction display before interaction
  • si and ni 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.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy