Skip to content

Commit 812bd87

Browse files
authored
gh-149584: _remote_debugging: Simplify page cache state (GH-162094)
Use page_cache_count to identify active page cache entries. Remove the redundant validity flag, unused next pointer, and unused size macro.
1 parent 6f049d3 commit 812bd87

2 files changed

Lines changed: 1 addition & 10 deletions

File tree

‎Modules/_remote_debugging/_remote_debugging.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ typedef struct {
121121
#define SIZEOF_GEN_OBJ sizeof(PyGenObject)
122122
#define SIZEOF_INTERP_FRAME sizeof(_PyInterpreterFrame)
123123
#define SIZEOF_LLIST_NODE sizeof(struct llist_node)
124-
#define SIZEOF_PAGE_CACHE_ENTRY sizeof(page_cache_entry_t)
125124
#define SIZEOF_PYOBJECT sizeof(PyObject)
126125
#define SIZEOF_SET_OBJ sizeof(PySetObject)
127126
#define SIZEOF_TASK_OBJ 4096

‎Python/remote_debug.h‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ get_page_size(void) {
155155
typedef struct page_cache_entry {
156156
uintptr_t page_addr; // page-aligned base address
157157
char *data;
158-
int valid;
159-
struct page_cache_entry *next;
160158
} page_cache_entry_t;
161159

162160
#define MAX_PAGES 1024
@@ -211,17 +209,13 @@ _Py_RemoteDebug_FreePageCache(proc_handle_t *handle)
211209
PyMem_RawFree(handle->pages[i].data);
212210
}
213211
handle->pages[i].data = NULL;
214-
handle->pages[i].valid = 0;
215212
}
216213
handle->page_cache_count = 0;
217214
}
218215

219216
UNUSED static void
220217
_Py_RemoteDebug_ClearCache(proc_handle_t *handle)
221218
{
222-
for (int i = 0; i < handle->page_cache_count; i++) {
223-
handle->pages[i].valid = 0;
224-
}
225219
handle->page_cache_count = 0;
226220
}
227221

@@ -244,7 +238,6 @@ _Py_RemoteDebug_InitProcHandle(proc_handle_t *handle, pid_t pid) {
244238
handle->page_cache_count = 0;
245239
for (int i = 0; i < MAX_PAGES; i++) {
246240
handle->pages[i].data = NULL;
247-
handle->pages[i].valid = 0;
248241
}
249242

250243
handle->pid = pid;
@@ -1539,7 +1532,7 @@ _Py_RemoteDebug_PagedReadRemoteMemory(proc_handle_t *handle,
15391532
// between profiler samples, so entries are packed at the front.
15401533
for (int i = 0; i < handle->page_cache_count; i++) {
15411534
page_cache_entry_t *entry = &handle->pages[i];
1542-
if (entry->valid && entry->page_addr == page_base) {
1535+
if (entry->page_addr == page_base) {
15431536
memcpy(out, entry->data + offset_in_page, size);
15441537
return 0;
15451538
}
@@ -1566,7 +1559,6 @@ _Py_RemoteDebug_PagedReadRemoteMemory(proc_handle_t *handle,
15661559
}
15671560

15681561
entry->page_addr = page_base;
1569-
entry->valid = 1;
15701562
handle->page_cache_count++;
15711563
memcpy(out, entry->data + offset_in_page, size);
15721564
return 0;

0 commit comments

Comments
 (0)