@@ -242,6 +242,7 @@ typedef struct {
242242typedef struct {
243243 uintptr_t interpreter_addr ;
244244 uintptr_t thread_state_addr ;
245+ uint64_t code_object_generation ;
245246} InterpreterThreadCacheEntry ;
246247
247248// Carries already-read thread state and/or frame buffers across helpers so the
@@ -288,7 +289,8 @@ typedef struct {
288289#define STATS_ADD (unwinder , field , val ) \
289290 do { if (REMOTE_DEBUG_UNLIKELY((unwinder)->collect_stats)) (unwinder)->stats.field += (val); } while(0)
290291
291- #define STATS_BATCHED_READ (unwinder , requested , completed ) \
292+ #if HAVE_PROCESS_VM_READV
293+ # define STATS_BATCHED_READ (unwinder , requested , completed ) \
292294 do { \
293295 if (REMOTE_DEBUG_UNLIKELY((unwinder)->collect_stats)) { \
294296 (unwinder)->stats.batched_read_attempts++; \
@@ -302,6 +304,9 @@ typedef struct {
302304 } \
303305 } \
304306 } while(0)
307+ #else
308+ # define STATS_BATCHED_READ (unwinder , requested , completed ) ((void)0)
309+ #endif
305310
306311typedef struct {
307312 PyTypeObject * RemoteDebugging_Type ;
@@ -342,7 +347,6 @@ typedef struct {
342347 struct _Py_AsyncioModuleDebugOffsets async_debug_offsets ;
343348 uintptr_t interpreter_addr ;
344349 uintptr_t tstate_addr ;
345- uint64_t code_object_generation ;
346350 _Py_hashtable_t * code_object_cache ;
347351 int debug ;
348352 int only_active_thread ;
@@ -355,9 +359,11 @@ typedef struct {
355359 int collect_stats ; // whether to collect statistics
356360 uint32_t stale_invalidation_counter ; // counter for throttling frame_cache_invalidate_stale
357361 // L1 single-entry shortcut over cached_tstates[]: most workloads sample one
358- // interpreter, so check this pair before hashing into the table below.
362+ // interpreter, so check these pairs before hashing into the table below.
359363 uintptr_t cached_tstate_interpreter_addr ;
360364 uintptr_t cached_tstate_addr ;
365+ uintptr_t cached_generation_interpreter_addr ;
366+ uint64_t cached_code_object_generation ;
361367 RemoteDebuggingState * cached_state ;
362368 FrameCacheEntry * frame_cache ; // preallocated array of FRAME_CACHE_MAX_THREADS entries
363369 UnwinderStats stats ; // statistics for performance analysis
0 commit comments