From 1aac7d0ad20ea1cbf629524a329465a7a5ed6efb Mon Sep 17 00:00:00 2001 From: Anastasios Andronidis Date: Wed, 11 May 2022 09:05:58 -0700 Subject: [PATCH] Get guest registers Reviewed By: jasonwhite Differential Revision: D36315857 fbshipit-source-id: bd00a87fea9b17a28d5afc438d640f2b68bd5975 --- reverie-ptrace/src/task.rs | 9 +++++++++ reverie/src/guest.rs | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/reverie-ptrace/src/task.rs b/reverie-ptrace/src/task.rs index bff7a24..0984e94 100644 --- a/reverie-ptrace/src/task.rs +++ b/reverie-ptrace/src/task.rs @@ -2005,6 +2005,15 @@ impl Guest for TracedTask { self.assume_stopped() } + async fn regs(&mut self) -> user_regs_struct { + let task = self.assume_stopped(); + + match task.getregs() { + Ok(ret) => ret, + Err(err) => self.abort(Err(err)).await, + } + } + async fn stack(&mut self) -> Self::Stack { match GuestStack::new(self.tid, self.stack_checked_out.clone()) { Ok(ret) => ret, diff --git a/reverie/src/guest.rs b/reverie/src/guest.rs index 8fc5e32..149cce0 100644 --- a/reverie/src/guest.rs +++ b/reverie/src/guest.rs @@ -78,6 +78,9 @@ pub trait Guest: Send + GlobalRPC { /// Returns an immutable reference to thread state. fn thread_state(&self) -> &T::ThreadState; + /// Returns the current register values of the guest thread. + async fn regs(&mut self) -> libc::user_regs_struct; + /// Returns the current stack pointer with this guest thread. async fn stack(&mut self) -> Self::Stack; @@ -329,6 +332,10 @@ where self.inner.thread_state().as_ref() } + async fn regs(&mut self) -> libc::user_regs_struct { + self.inner.regs().await + } + async fn stack(&mut self) -> Self::Stack { self.inner.stack().await }