File tree Expand file tree Collapse file tree
Modules/_remote_debugging Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -450,12 +450,14 @@ unwind_stack_for_thread(
450450 set_exception_cause (unwinder , PyExc_RuntimeError , "Failed to collect frames" );
451451 goto error ;
452452 }
453- // Update last_profiled_frame for next sample
454- uintptr_t lpf_addr =
455- * current_tstate + (uintptr_t )unwinder -> debug_offsets .thread_state .last_profiled_frame ;
456- if (_Py_RemoteDebug_WriteRemoteMemory (& unwinder -> handle , lpf_addr ,
457- sizeof (uintptr_t ), & frame_addr ) < 0 ) {
458- PyErr_Clear (); // Non-fatal
453+ // Update last_profiled_frame for next sample if it changed
454+ if (frame_addr != ctx .last_profiled_frame ) {
455+ uintptr_t lpf_addr =
456+ * current_tstate + (uintptr_t )unwinder -> debug_offsets .thread_state .last_profiled_frame ;
457+ if (_Py_RemoteDebug_WriteRemoteMemory (& unwinder -> handle , lpf_addr ,
458+ sizeof (uintptr_t ), & frame_addr ) < 0 ) {
459+ PyErr_Clear (); // Non-fatal
460+ }
459461 }
460462 } else {
461463 // No caching - process entire frame chain with base_frame validation
You can’t perform that action at this time.
0 commit comments