Update the global monitoring_events atomic mask from current state.
(vm: &VirtualMachine, state: &MonitoringState)
| 511 | |
| 512 | /// Update the global monitoring_events atomic mask from current state. |
| 513 | fn 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 | |
| 540 | fn use_tool_id(tool_id: i32, name: &str, vm: &VirtualMachine) -> PyResult<()> { |
| 541 | let tool = check_valid_tool(tool_id, vm)?; |
no test coverage detected