From a1d9a685191cd57b0e7fdaee408c9c17232326cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maurycy=20Paw=C5=82owski-Wiero=C5=84ski?= Date: Mon, 16 Nov 2026 09:56:17 +0100 Subject: [PATCH 1/2] Simplify remote debugging page cache state --- Python/remote_debug.h | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Python/remote_debug.h b/Python/remote_debug.h index a68e4c6102e5a7d..0c55fd3a0354e3a 100644 --- a/Python/remote_debug.h +++ b/Python/remote_debug.h @@ -155,8 +155,6 @@ get_page_size(void) { typedef struct page_cache_entry { uintptr_t page_addr; // page-aligned base address char *data; - int valid; - struct page_cache_entry *next; } page_cache_entry_t; #define MAX_PAGES 1024 @@ -211,7 +209,6 @@ _Py_RemoteDebug_FreePageCache(proc_handle_t *handle) PyMem_RawFree(handle->pages[i].data); } handle->pages[i].data = NULL; - handle->pages[i].valid = 0; } handle->page_cache_count = 0; } @@ -219,9 +216,6 @@ _Py_RemoteDebug_FreePageCache(proc_handle_t *handle) UNUSED static void _Py_RemoteDebug_ClearCache(proc_handle_t *handle) { - for (int i = 0; i < handle->page_cache_count; i++) { - handle->pages[i].valid = 0; - } handle->page_cache_count = 0; } @@ -244,7 +238,6 @@ _Py_RemoteDebug_InitProcHandle(proc_handle_t *handle, pid_t pid) { handle->page_cache_count = 0; for (int i = 0; i < MAX_PAGES; i++) { handle->pages[i].data = NULL; - handle->pages[i].valid = 0; } handle->pid = pid; @@ -1539,7 +1532,7 @@ _Py_RemoteDebug_PagedReadRemoteMemory(proc_handle_t *handle, // between profiler samples, so entries are packed at the front. for (int i = 0; i < handle->page_cache_count; i++) { page_cache_entry_t *entry = &handle->pages[i]; - if (entry->valid && entry->page_addr == page_base) { + if (entry->page_addr == page_base) { memcpy(out, entry->data + offset_in_page, size); return 0; } @@ -1566,7 +1559,6 @@ _Py_RemoteDebug_PagedReadRemoteMemory(proc_handle_t *handle, } entry->page_addr = page_base; - entry->valid = 1; handle->page_cache_count++; memcpy(out, entry->data + offset_in_page, size); return 0; From 27ed797221e89ef4f629e3d3013d44b24451c525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maurycy=20Paw=C5=82owski-Wiero=C5=84ski?= Date: Mon, 16 Nov 2026 10:04:28 +0100 Subject: [PATCH 2/2] redundant makro --- Modules/_remote_debugging/_remote_debugging.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Modules/_remote_debugging/_remote_debugging.h b/Modules/_remote_debugging/_remote_debugging.h index 6080dc4e3815067..7bbcd8942de61f6 100644 --- a/Modules/_remote_debugging/_remote_debugging.h +++ b/Modules/_remote_debugging/_remote_debugging.h @@ -121,7 +121,6 @@ typedef struct { #define SIZEOF_GEN_OBJ sizeof(PyGenObject) #define SIZEOF_INTERP_FRAME sizeof(_PyInterpreterFrame) #define SIZEOF_LLIST_NODE sizeof(struct llist_node) -#define SIZEOF_PAGE_CACHE_ENTRY sizeof(page_cache_entry_t) #define SIZEOF_PYOBJECT sizeof(PyObject) #define SIZEOF_SET_OBJ sizeof(PySetObject) #define SIZEOF_TASK_OBJ 4096