]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-91048: Refactor and optimize remote debugging module (#134652) (#134673)
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Sun, 25 May 2025 22:10:20 +0000 (23:10 +0100)
committerGitHub <noreply@github.com>
Sun, 25 May 2025 22:10:20 +0000 (22:10 +0000)
commit1822f33b1af989ebb9e7a5b58bd40721fca9a218
tree196253d1c3d71489cadb6e16beec3530eb66df17
parentf68f05cbe3bdac0c668303ae55c6943b824d0c3f
[3.14] gh-91048: Refactor and optimize remote debugging module (#134652) (#134673)

gh-91048: Refactor and optimize remote debugging module (#134652)

Completely refactor Modules/_remote_debugging_module.c with improved
code organization, replacing scattered reference counting and error
handling with centralized goto error paths. This cleanup improves
maintainability and reduces code duplication throughout the module while
preserving the same external API.

Implement memory page caching optimization in Python/remote_debug.h to
avoid repeated reads of the same memory regions during debugging
operations. The cache stores previously read memory pages and reuses
them for subsequent reads, significantly reducing system calls and
improving performance.

Add code object caching mechanism with a new code_object_generation
field in the interpreter state that tracks when code object caches need
invalidation. This allows efficient reuse of parsed code object metadata
and eliminates redundant processing of the same code objects across
debugging sessions.

Optimize memory operations by replacing multiple individual structure
copies with single bulk reads for the same data structures. This reduces
the number of memory operations and system calls required to gather
debugging information from the target process.

Update Makefile.pre.in to include Python/remote_debug.h in the headers
list, ensuring that changes to the remote debugging header force proper
recompilation of dependent modules and maintain build consistency across
the codebase.

Also, make the module compatible with the free threading build as an extra :)

Co-authored-by: Ɓukasz Langa <lukasz@langa.pl>
(cherry picked from commit 42b25ad4d3d6bcdc28ddfe07d2bf8831378bb0d1)
17 files changed:
Doc/data/python3.14.abi
Include/cpython/pystate.h
Include/internal/pycore_debug_offsets.h
Include/internal/pycore_global_objects_fini_generated.h
Include/internal/pycore_global_strings.h
Include/internal/pycore_interp_structs.h
Include/internal/pycore_runtime_init_generated.h
Include/internal/pycore_unicodeobject_generated.h
Lib/asyncio/tools.py
Lib/test/test_external_inspection.py
Makefile.pre.in
Modules/_remote_debugging_module.c
Modules/clinic/_remote_debugging_module.c.h [new file with mode: 0644]
Objects/codeobject.c
Python/index_pool.c
Python/pystate.c
Python/remote_debug.h