(fd: i32, vm: &VirtualMachine)
| 402 | /// Dump tracebacks of all threads. |
| 403 | #[cfg(any(unix, windows))] |
| 404 | fn dump_all_threads(fd: i32, vm: &VirtualMachine) { |
| 405 | // Get all threads' frame stacks from the shared registry |
| 406 | #[cfg(feature = "threading")] |
| 407 | { |
| 408 | let current_tid = rustpython_vm::stdlib::_thread::get_ident(); |
| 409 | let registry = vm.state.thread_frames.lock(); |
| 410 | |
| 411 | // First dump non-current threads, then current thread last |
| 412 | for (&tid, slot) in registry.iter() { |
| 413 | if tid == current_tid { |
| 414 | continue; |
| 415 | } |
| 416 | let frames_guard = slot.frames.lock(); |
| 417 | dump_traceback_thread_frames(fd, tid, false, &frames_guard); |
| 418 | puts(fd, "\n"); |
| 419 | } |
| 420 | |
| 421 | // Now dump current thread (use vm.frames for most up-to-date data) |
| 422 | write_thread_id(fd, current_tid, true); |
| 423 | let frames = vm.frames.borrow(); |
| 424 | if frames.is_empty() { |
| 425 | puts(fd, " <no Python frame>\n"); |
| 426 | } else { |
| 427 | for fp in frames.iter().rev() { |
| 428 | dump_frame_from_ref(fd, unsafe { fp.as_ref() }); |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | #[cfg(not(feature = "threading"))] |
| 434 | { |
| 435 | write_thread_id(fd, current_thread_id(), true); |
| 436 | let frames = vm.frames.borrow(); |
| 437 | for fp in frames.iter().rev() { |
| 438 | dump_frame_from_ref(fd, unsafe { fp.as_ref() }); |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | #[derive(FromArgs)] |
| 444 | #[allow(unused)] |
no test coverage detected