cpython/Include/cpython
Pablo Galindo Salgado 1822f33b1a
[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 42b25ad4d3)
2025-05-25 22:10:20 +00:00
..
abstract.h gh-130947: Add again PySequence_Fast() to the limited C API (#130948) 2025-03-13 13:00:57 +01:00
audit.h gh-125604: Move _Py_AuditHookEntry, etc. Out of pycore_runtime.h (gh-125605) 2024-10-18 09:26:08 -06:00
bytearrayobject.h gh-129107: make bytearray thread safe (#129108) 2025-02-15 07:19:42 +00:00
bytesobject.h gh-128863: Deprecate private C API functions (#128864) 2025-01-22 11:04:19 +00:00
cellobject.h gh-127271: Replace use of PyCell_GET/SET (gh-127272) 2024-12-03 10:33:06 -08:00
ceval.h gh-125604: Move _Py_AuditHookEntry, etc. Out of pycore_runtime.h (gh-125605) 2024-10-18 09:26:08 -06:00
classobject.h gh-89653: PEP 670: Convert macros to functions (#99843) 2022-11-28 16:40:08 +01:00
code.h GH-131238: Core header refactor (GH-131250) 2025-03-17 09:19:04 +00:00
compile.h gh-117411: move PyFutureFeatures to pycore_symtable.h and make it private (#117412) 2024-04-02 10:34:49 +00:00
complexobject.h gh-128813: hide mixed-mode functions for complex arithmetic from C-API (#131703) 2025-04-22 14:18:18 +02:00
context.h gh-124872: Replace enter/exit events with "switched" (#125532) 2024-10-16 13:53:21 +02:00
critical_section.h gh-119344: Make critical section API public (#119353) 2024-06-21 15:50:18 -04:00
descrobject.h gh-106320: Move _PyMethodWrapper_Type to internal C API (#107064) 2023-07-22 20:57:59 +00:00
dictobject.h gh-128863: Deprecate private C API functions (#128864) 2025-01-22 11:04:19 +00:00
fileobject.h gh-106320: Remove private _Py_UniversalNewlineFgetsWithSize() (#108602) 2023-08-29 02:36:50 +00:00
fileutils.h gh-128863: Deprecate private C API functions (#128864) 2025-01-22 11:04:19 +00:00
floatobject.h gh-89653: PEP 670: Convert macros to functions (#99843) 2022-11-28 16:40:08 +01:00
frameobject.h gh-74929: Implement PEP 667 (GH-115153) 2024-05-04 12:12:10 +01:00
funcobject.h gh-132775: Unrevert "Add _PyCode_GetVarCounts()" (gh-133265) 2025-05-05 13:24:29 -06:00
genobject.h gh-120834: fix type of *_iframe field in _PyGenObject_HEAD declaration (#120835) 2024-06-24 10:23:38 +01:00
import.h gh-128911: Add PyImport_ImportModuleAttr() function (#128912) 2025-01-30 11:17:29 +00:00
initconfig.h gh-128384: Use a context variable for warnings.catch_warnings (gh-130010) 2025-04-09 16:18:54 -07:00
listobject.h gh-112087: Make list_repr and list_length to be thread-safe (gh-114582) 2024-01-27 01:20:21 +09:00
lock.h gh-117511: Make PyMutex public in the non-limited API (#117731) 2024-06-20 11:29:08 -04:00
longintrepr.h gh-127119: Faster check for small ints in long_dealloc (GH-127620) 2025-01-29 15:22:18 +00:00
longobject.h gh-132639: Adds PyLong_AsNativeBytes, PyLong_FromNativeBytes and PyLong_FromUnsignedNativeBytes to the limited API (GH-132640) 2025-04-21 15:59:03 +01:00
memoryobject.h gh-106320: Remove private _PyManagedBuffer_Type (#108431) 2023-08-24 19:07:54 +02:00
methodobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
modsupport.h gh-112136: Restore removed _PyArg_Parser (#121262) 2024-07-03 18:36:57 +02:00
monitoring.h GH-122548: Implement branch taken and not taken events for sys.monitoring (GH-122564) 2024-12-19 16:59:51 +00:00
object.h Revert "gh-133395: add option for extension modules to specialize BINARY_OP/SUBSCR, apply to arrays (#133396)" (#133498) 2025-05-06 13:12:26 +03:00
objimpl.h gh-102013: Move PyUnstable_GC_VisitObjects() to Include/cpython/objimpl.h (#115560) 2024-02-16 15:49:13 +01:00
odictobject.h gh-87347: Add parenthesis around macro arguments (#93915) 2022-06-20 16:04:52 +02:00
picklebufobject.h gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815) 2022-06-16 13:49:43 +02:00
pthread_stubs.h GH-110829: Ensure Thread.join() joins the OS thread (#110848) 2023-11-04 13:59:24 +00:00
pyatomic.h gh-129296: Fix pyatomic.h include paths (#129320) 2025-01-29 15:06:19 +00:00
pyatomic_gcc.h gh-131121: Fix _Py_atomic_store_char_relaxed memory order (gh-131122) 2025-03-12 09:03:04 -04:00
pyatomic_msc.h gh-117657: TSAN Fix races in PyMember_Get and PyMember_Set for C extensions (GH-123211) 2024-12-03 09:41:53 -05:00
pyatomic_std.h gh-117657: TSAN Fix races in PyMember_Get and PyMember_Set for C extensions (GH-123211) 2024-12-03 09:41:53 -05:00
pyctype.h bpo-43816: Add extern "C" to Include/cpython/pyctype.h (GH-25365) 2021-04-13 13:27:21 +02:00
pydebug.h gh-77782: Deprecate global configuration variable (#93943) 2022-06-17 16:12:00 +02:00
pyerrors.h gh-132449: Improve syntax error messages for keywords with typos (#132450) 2025-04-22 11:01:55 +02:00
pyfpe.h bpo-35134: Move non-limited C API files to Include/cpython/ (GH-24561) 2021-02-19 15:55:46 +01:00
pyframe.h Fix typos in comments (#120188) 2024-06-07 10:19:41 +02:00
pyhash.h gh-128863: Deprecate private C API functions (#128864) 2025-01-22 11:04:19 +00:00
pylifecycle.h gh-129033: Remove _Py_InitializeMain() function (#129034) 2025-01-20 10:03:22 +00:00
pymem.h gh-90815: Add mimalloc memory allocator (#109914) 2023-10-30 15:43:11 +00:00
pystate.h [3.14] gh-91048: Refactor and optimize remote debugging module (#134652) (#134673) 2025-05-25 22:10:20 +00:00
pystats.h gh-100239: specialize BINARY_OP/SUBSCR for list-slice (#132626) 2025-05-01 10:28:52 +00:00
pythonrun.h gh-106320: Remove private pythonrun API (#108599) 2023-08-29 04:18:52 +02:00
pythread.h gh-129296: Fix pyatomic.h include paths (#129320) 2025-01-29 15:06:19 +00:00
pytime.h gh-110850: Add PyTime_TimeRaw() function (#118394) 2024-05-01 18:05:01 +00:00
setobject.h gh-112069: Make PySet_GET_SIZE to be atomic safe. (gh-118053) 2024-04-19 06:40:28 +09:00
traceback.h gh-106320: Remove private _PyTraceback functions (#108453) 2023-08-24 23:35:47 +00:00
tracemalloc.h Add extern "C" around PyTraceMalloc_ functions. (#127772) 2024-12-11 10:27:07 +01:00
tupleobject.h gh-131525: Cache the result of tuple_hash (#131529) 2025-03-27 09:57:06 -04:00
unicodeobject.h gh-128972: Add _Py_ALIGN_AS and revert PyASCIIObject memory layout. (GH-133085) 2025-05-02 18:30:40 +02:00
warnings.h gh-131927: Prevent emitting optimizer warnings twice in the REPL (#131993) 2025-04-12 11:34:36 +01:00
weakrefobject.h gh-128008: Add PyWeakref_IsDead() (GH-128009) 2024-12-19 16:17:15 +01:00