this.set_active_thread_name(name)?;
} else if option == this.eval_libc_i32("PR_GET_NAME")? {
let address = this.read_scalar(arg2)?.not_undef()?;
- let name = this.get_active_thread_name()?;
+ let name = this.get_active_thread_name()?.to_vec();
this.memory.write_bytes(address, name)?;
} else {
throw_unsup_format!("Unsupported prctl option.");
self.threads[thread_id].state = ThreadState::Enabled;
}
- /// Get the borrow of the currently active thread.
+ /// Get a mutable borrow of the currently active thread.
fn active_thread_mut(&mut self) -> &mut Thread<'mir, 'tcx> {
&mut self.threads[self.active_thread]
}
+ /// Get a shared borrow of the currently active thread.
+ fn active_thread_ref(&self) -> &Thread<'mir, 'tcx> {
+ &self.threads[self.active_thread]
+ }
+
/// Mark the thread as detached, which means that no other thread will try
/// to join it and the thread is responsible for cleaning up.
fn detach_thread(&mut self, id: ThreadId) -> InterpResult<'tcx> {
}
/// Get the name of the active thread.
- fn get_thread_name(&mut self) -> InterpResult<'tcx, Vec<u8>> {
- if let Some(ref thread_name) = self.active_thread_mut().thread_name {
- Ok(thread_name.clone())
+ fn get_thread_name(&self) -> InterpResult<'tcx, &[u8]> {
+ if let Some(ref thread_name) = self.active_thread_ref().thread_name {
+ Ok(thread_name)
} else {
throw_ub_format!("thread {:?} has no name set", self.active_thread)
}
}
#[inline]
- fn get_active_thread_name(&mut self) -> InterpResult<'tcx, Vec<u8>> {
- let this = self.eval_context_mut();
+ fn get_active_thread_name<'c>(&'c self) -> InterpResult<'tcx, &'c [u8]>
+ where
+ 'mir: 'c,
+ {
+ let this = self.eval_context_ref();
this.machine.threads.get_thread_name()
}