From 3041c78c9c055988de5d1138a14cc61fb9ea94fd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 3 Mar 2024 12:53:32 +0100 Subject: [PATCH] log when we change the active thread --- src/tools/miri/src/concurrency/thread.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/tools/miri/src/concurrency/thread.rs b/src/tools/miri/src/concurrency/thread.rs index 83ca27a467c8..8341fd7648b2 100644 --- a/src/tools/miri/src/concurrency/thread.rs +++ b/src/tools/miri/src/concurrency/thread.rs @@ -445,10 +445,13 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> { /// Set an active thread and return the id of the thread that was active before. fn set_active_thread_id(&mut self, id: ThreadId) -> ThreadId { - let active_thread_id = self.active_thread; - self.active_thread = id; - assert!(self.active_thread.index() < self.threads.len()); - active_thread_id + assert!(id.index() < self.threads.len()); + info!( + "---------- Now executing on thread `{}` (previous: `{}`) ----------------------------------------", + self.get_thread_display_name(id), + self.get_thread_display_name(self.active_thread) + ); + std::mem::replace(&mut self.active_thread, id) } /// Get the id of the currently active thread. @@ -735,6 +738,11 @@ impl<'mir, 'tcx: 'mir> ThreadManager<'mir, 'tcx> { for (id, thread) in threads { debug_assert_ne!(self.active_thread, id); if thread.state == ThreadState::Enabled { + info!( + "---------- Now executing on thread `{}` (previous: `{}`) ----------------------------------------", + self.get_thread_display_name(id), + self.get_thread_display_name(self.active_thread) + ); self.active_thread = id; break; }