MCPcopy Index your code
hub / github.com/RustPython/RustPython / update_events_mask

Function update_events_mask

crates/vm/src/stdlib/sys/monitoring.rs:513–538  ·  view source on GitHub ↗

Update the global monitoring_events atomic mask from current state.

(vm: &VirtualMachine, state: &MonitoringState)

Source from the content-addressed store, hash-verified

511
512/// Update the global monitoring_events atomic mask from current state.
513fn update_events_mask(vm: &VirtualMachine, state: &MonitoringState) {
514 let events = state.combined_events();
515 vm.state.monitoring_events.store(events);
516 let new_ver = vm
517 .state
518 .instrumentation_version
519 .fetch_add(1, Ordering::Release)
520 + 1;
521 // Eagerly re-instrument all frames on the current thread's stack so that
522 // code objects already past their RESUME pick up the new event set.
523 // Each code object gets only the events that apply to it (global + its
524 // own local events), preventing e.g. INSTRUCTION from being applied to
525 // unrelated code objects.
526 for fp in vm.frames.borrow().iter() {
527 // SAFETY: frames in the Vec are alive while their FrameRef is on the call stack.
528 let frame = unsafe { fp.as_ref() };
529 let code = &frame.code;
530 let code_ver = code.instrumentation_version.load(Ordering::Acquire);
531 if code_ver != new_ver {
532 let code_events = state.events_for_code(code.get_id());
533 instrument_code(code, code_events);
534 code.instrumentation_version
535 .store(new_ver, Ordering::Release);
536 }
537 }
538}
539
540fn use_tool_id(tool_id: i32, name: &str, vm: &VirtualMachine) -> PyResult<()> {
541 let tool = check_valid_tool(tool_id, vm)?;

Callers 4

clear_tool_idFunction · 0.85
free_tool_idFunction · 0.85
set_eventsFunction · 0.85
set_local_eventsFunction · 0.85

Calls 9

instrument_codeFunction · 0.85
combined_eventsMethod · 0.80
events_for_codeMethod · 0.80
storeMethod · 0.45
iterMethod · 0.45
borrowMethod · 0.45
as_refMethod · 0.45
loadMethod · 0.45
get_idMethod · 0.45

Tested by

no test coverage detected