Move copying of the thread name to the client side.
This commit is contained in:
parent
feb188360e
commit
04abf066f1
@ -119,7 +119,7 @@ fn prctl(
|
||||
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.");
|
||||
|
@ -254,11 +254,16 @@ fn enable_thread(&mut self, thread_id: ThreadId) {
|
||||
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> {
|
||||
@ -304,9 +309,9 @@ fn set_thread_name(&mut self, new_thread_name: Vec<u8>) {
|
||||
}
|
||||
|
||||
/// 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)
|
||||
}
|
||||
@ -557,8 +562,11 @@ fn set_active_thread_name(&mut self, new_thread_name: Vec<u8>) -> InterpResult<'
|
||||
}
|
||||
|
||||
#[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()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user