diff --git a/src/debugger.rs b/src/debugger.rs index af7e39a9ae..787a97161f 100644 --- a/src/debugger.rs +++ b/src/debugger.rs @@ -21,11 +21,13 @@ pub unsafe fn debugger(target_id: Option<*const ContextLock>, token: &mut CleanL let old_table = unsafe { RmmA::table(TableKind::User) }; - for context_lock in crate::context::contexts(token.token()).iter() { + let mut contexts_guard = crate::context::contexts(token.token()); + let (contexts, mut context_token) = contexts_guard.token_split(); + for context_lock in contexts.iter() { if target_id.map_or(false, |target_id| Arc::as_ptr(&context_lock.0) != target_id) { continue; } - let context = context_lock.0.read(); + let context = context_lock.0.read(context_token.token()); println!("{:p}: {}", Arc::as_ptr(&context_lock.0), context.name); if let Some(ref head) = context.syscall_head { @@ -129,8 +131,9 @@ pub unsafe fn debugger(target_id: Option<*const ContextLock>, token: &mut CleanL println!(); } + drop(contexts_guard); #[cfg(any(target_arch = "aarch64", target_arch = "x86_64"))] - crate::scheme::proc::foreach_addrsp(|addrsp| { + crate::scheme::proc::foreach_addrsp(token, |addrsp| { let was_new = spaces.insert(addrsp.acquire_read().table.utable.table().phys().data()); unsafe { check_page_table_consistency(&mut *addrsp.acquire_write(), was_new, &mut tree) }; }); diff --git a/src/scheme/sys/mod.rs b/src/scheme/sys/mod.rs index c0451c7daf..8619739736 100644 --- a/src/scheme/sys/mod.rs +++ b/src/scheme/sys/mod.rs @@ -89,8 +89,8 @@ const FILES: &[(&'static str, Kind)] = &[ ("stat", Rd(stat::resource)), // Disabled because the debugger is inherently unsafe and probably will break the system. /* - ("trigger_debugger", Rd(|| unsafe { - crate::debugger::debugger(None); + ("trigger_debugger", Rd(|token| unsafe { + crate::debugger::debugger(None, token); Ok(Vec::new()) })), */