This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Dump CodeObject API for debugging
Type: enhancement Stage: patch review
Components: Interpreter Core Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Mark.Shannon, gvanrossum, penguin_wwy
Priority: normal Keywords: patch

Created on 2021-10-27 15:47 by penguin_wwy, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 29243 open penguin_wwy, 2021-10-27 16:05
Messages (6)
msg405106 - (view) Author: penguin_wwy (penguin_wwy) * Date: 2021-10-27 15:47
What the title says.
msg405184 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-10-28 13:21
What is the motivation for this?

I see it could be useful when modifying the compiler, but there is already code for dumping the CFG in the compiler.
https://github.com/python/cpython/blob/main/Python/compile.c#L7565
msg405200 - (view) Author: penguin_wwy (penguin_wwy) * Date: 2021-10-28 17:09
This interface can dump code at any time, not just at compile time.

Can observe the comparison before and after dynamic optimization(eg. specialize and super instr), and can also observe the instructions actually executed.

Another situation is to execute the dump by command line in gdb/lldb(eg. `expression _PyCode_DebugDump(co, "test")`), when debugging.
msg405801 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2021-11-05 14:51
Why not propose a slight extension to the dis module?
msg405815 - (view) Author: penguin_wwy (penguin_wwy) * Date: 2021-11-05 18:32
I hope that this function can be used in the _PyEval_EvalFrameDefault(or other customized eval_frame), for example, after calling the _Py_Quicken to confirm whether the instruction is modified correctly 
https://github.com/python/cpython/pull/29243/files#diff-c22186367cbe20233e843261998dc027ae5f1f8c0d2e778abfa454ae74cc59de
msg408176 - (view) Author: penguin_wwy (penguin_wwy) * Date: 2021-12-10 07:29
Recently, we have used this function to troubleshoot problems with online applications.
We have implemented the PEP659(Specializing) to the 3.6 version which is used by online services, and this function allows us to dump the current function's code in the case of an unhandled exception to determine if the problem was caused by an optimization.
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89793
2021-12-10 07:29:40penguin_wwysetmessages: + msg408176
2021-11-05 18:32:00penguin_wwysetmessages: + msg405815
2021-11-05 14:51:17gvanrossumsetmessages: + msg405801
2021-11-05 09:34:24penguin_wwysetnosy: + gvanrossum
2021-10-28 17:09:04penguin_wwysetmessages: + msg405200
2021-10-28 13:21:21Mark.Shannonsetnosy: + Mark.Shannon
messages: + msg405184
2021-10-27 16:05:17penguin_wwysetkeywords: + patch
stage: patch review
pull_requests: + pull_request27507
2021-10-27 15:47:45penguin_wwycreate