Skip to content

Commit 0cc0b5a

Browse files
committed
More tests
1 parent 84c47e4 commit 0cc0b5a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Modules/_remote_debugging_module.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,18 @@ get_thread_status(RemoteUnwinderObject *unwinder, uint64_t tid, uint64_t pthread
26172617
#endif
26182618
}
26192619

2620+
typedef struct {
2621+
unsigned int initialized:1;
2622+
unsigned int bound:1;
2623+
unsigned int unbound:1;
2624+
unsigned int bound_gilstate:1;
2625+
unsigned int active:1;
2626+
unsigned int finalizing:1;
2627+
unsigned int cleared:1;
2628+
unsigned int finalized:1;
2629+
unsigned int :24;
2630+
} _thread_status;
2631+
26202632
static PyObject*
26212633
unwind_stack_for_thread(
26222634
RemoteUnwinderObject *unwinder,
@@ -2649,15 +2661,21 @@ unwind_stack_for_thread(
26492661
goto error;
26502662
}
26512663
} else if (unwinder->mode == PROFILING_MODE_GIL) {
2664+
#ifdef Py_GIL_DISABLED
2665+
// All threads are considered running in free threading builds if they have a thread state attached
2666+
int active = GET_MEMBER(_thread_status, ts, unwinder->debug_offsets.thread_state.status).active;
2667+
status = active ? THREAD_STATE_RUNNING : THREAD_STATE_GIL_WAIT;
2668+
#else
26522669
status = (*current_tstate == gil_holder_tstate) ? THREAD_STATE_RUNNING : THREAD_STATE_GIL_WAIT;
2670+
#endif
26532671
} else {
26542672
// PROFILING_MODE_WALL - all threads are considered running
26552673
status = THREAD_STATE_RUNNING;
26562674
}
26572675

26582676
// Check if we should skip this thread based on mode
26592677
int should_skip = 0;
2660-
if ((unwinder->skip_non_matching_threads && status != THREAD_STATE_RUNNING) &&
2678+
if (unwinder->skip_non_matching_threads && status != THREAD_STATE_RUNNING &&
26612679
(unwinder->mode == PROFILING_MODE_CPU || unwinder->mode == PROFILING_MODE_GIL)) {
26622680
should_skip = 1;
26632681
}

0 commit comments

Comments
 (0)