diff --git a/reverie-ptrace/src/gdbstub/mod.rs b/reverie-ptrace/src/gdbstub/mod.rs index 6922c19..b87a00f 100644 --- a/reverie-ptrace/src/gdbstub/mod.rs +++ b/reverie-ptrace/src/gdbstub/mod.rs @@ -34,8 +34,8 @@ pub use inferior::Inferior; pub use inferior::InferiorThreadId; pub use inferior::ResumeInferior; pub use inferior::StoppedInferior; -pub use regs::Amd64CoreRegs; -pub use regs::Amd64ExtraRegs; +pub use regs::CoreRegs; +pub use regs::ExtraRegs; pub use request::GdbRequest; pub use server::GdbServer; pub use session::Session; diff --git a/reverie-ptrace/src/gdbstub/regs/mod.rs b/reverie-ptrace/src/gdbstub/regs/mod.rs index cd82895..9b46b9b 100644 --- a/reverie-ptrace/src/gdbstub/regs/mod.rs +++ b/reverie-ptrace/src/gdbstub/regs/mod.rs @@ -11,6 +11,6 @@ mod x86_64; #[cfg(target_arch = "x86_64")] -pub use x86_64::Amd64CoreRegs; +pub use x86_64::CoreRegs; #[cfg(target_arch = "x86_64")] -pub use x86_64::Amd64ExtraRegs; +pub use x86_64::ExtraRegs; diff --git a/reverie-ptrace/src/gdbstub/regs/x86_64.rs b/reverie-ptrace/src/gdbstub/regs/x86_64.rs index 7bfa0c4..d290217 100644 --- a/reverie-ptrace/src/gdbstub/regs/x86_64.rs +++ b/reverie-ptrace/src/gdbstub/regs/x86_64.rs @@ -49,7 +49,7 @@ pub struct X87Regs { /// AMD64 core/sse regs, see gdb/64bit-{core,sse}-linux.xml. /// This is the same as: 64bit-core+64bit-sse+64bit-linux. #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] -pub struct Amd64CoreRegs { +pub struct CoreRegs { /// general purpose regsiters /// rax/rbx/rcx/rdx/rsi/rdi/rbp/rsp/r8..r15 pub regs: [u64; 16], @@ -74,7 +74,7 @@ pub struct Amd64CoreRegs { /// amd64 avx regs #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] -pub struct Amd64ExtraRegs { +pub struct ExtraRegs { /// avx registers pub ymm: [u128; 32], /// avx512 registers @@ -209,8 +209,8 @@ impl From for [u32; 64] { } } -impl Amd64CoreRegs { - /// create `Amd64CoreRegs` from user and fp regs. +impl CoreRegs { + /// create `CoreRegs` from user and fp regs. pub fn from_parts(regs: libc::user_regs_struct, i387: libc::user_fpregs_struct) -> Self { Self { regs: [ @@ -297,14 +297,14 @@ impl Amd64CoreRegs { } } -impl WriteResponse for ResponseAsHex { +impl WriteResponse for ResponseAsHex { fn write_response(&self, f: &mut ResponseWriter) { let encoded: Vec = bincode::serialize(&self.0).unwrap(); ResponseAsHex(encoded.as_slice()).write_response(f) } } -impl WriteResponse for ResponseAsBinary { +impl WriteResponse for ResponseAsBinary { fn write_response(&self, f: &mut ResponseWriter) { let encoded: Vec = bincode::serialize(&self.0).unwrap(); ResponseAsBinary(encoded.as_slice()).write_response(f) @@ -361,15 +361,15 @@ mod test { #[test] fn amd64_core_regs_sanity() { const EXPECTED_SIZE: usize = 16 * 8 + 8 + 4 + 4 * 6 + 10 * 8 + 8 * 4 + 16 * 16 + 4 + 8 * 3; // 560. - assert_eq!(mem::size_of::(), EXPECTED_SIZE); - let core_regs: Amd64CoreRegs = Default::default(); + assert_eq!(mem::size_of::(), EXPECTED_SIZE); + let core_regs: CoreRegs = Default::default(); let encoded: Vec = bincode::serialize(&core_regs).unwrap(); assert_eq!(encoded.len(), EXPECTED_SIZE); } #[test] fn amd64_core_regs_serde() { - let core_regs: Amd64CoreRegs = Amd64CoreRegs { + let core_regs: CoreRegs = CoreRegs { regs: [ 0x1c, 0, diff --git a/reverie-ptrace/src/gdbstub/request.rs b/reverie-ptrace/src/gdbstub/request.rs index 3b2ba3e..dca40f7 100644 --- a/reverie-ptrace/src/gdbstub/request.rs +++ b/reverie-ptrace/src/gdbstub/request.rs @@ -9,8 +9,8 @@ use safeptrace::Error as TraceError; use tokio::sync::oneshot; -use super::Amd64CoreRegs; use super::Breakpoint; +use super::CoreRegs; /// gdb request send to reverie. #[derive(Debug)] @@ -27,7 +27,7 @@ pub enum GdbRequest { /// Write inferior memory WriteInferiorMemory(u64, usize, Vec, oneshot::Sender>), /// Read registers - ReadRegisters(oneshot::Sender>), + ReadRegisters(oneshot::Sender>), /// Write registers - WriteRegisters(Amd64CoreRegs, oneshot::Sender>), + WriteRegisters(CoreRegs, oneshot::Sender>), } diff --git a/reverie-ptrace/src/gdbstub/session.rs b/reverie-ptrace/src/gdbstub/session.rs index 8fda130..1faee91 100644 --- a/reverie-ptrace/src/gdbstub/session.rs +++ b/reverie-ptrace/src/gdbstub/session.rs @@ -33,7 +33,7 @@ use tokio::sync::MutexGuard; use super::commands; use super::commands::*; -use super::regs::Amd64CoreRegs; +use super::regs::CoreRegs; use super::response::*; use super::Breakpoint; use super::BreakpointType; @@ -811,7 +811,7 @@ impl Session { .await } - async fn read_registers(&self) -> Result { + async fn read_registers(&self) -> Result { self.with_current_inferior(async move |inferior| { let request_tx = inferior .request_tx @@ -837,7 +837,7 @@ impl Session { .as_ref() .ok_or(Error::SessionNotStarted)?; let (reply_tx, reply_rx) = oneshot::channel(); - let core_regs: Amd64CoreRegs = + let core_regs: CoreRegs = bincode::deserialize(regs).map_err(|_| CommandParseError::MalformedRegisters)?; let request = GdbRequest::WriteRegisters(core_regs, reply_tx); let _ = request_tx diff --git a/reverie-ptrace/src/task.rs b/reverie-ptrace/src/task.rs index 98ef666..4da344a 100644 --- a/reverie-ptrace/src/task.rs +++ b/reverie-ptrace/src/task.rs @@ -71,8 +71,8 @@ use super::regs::RegAccess; use crate::children; use crate::cp; use crate::error::Error; -use crate::gdbstub::Amd64CoreRegs; use crate::gdbstub::BreakpointType; +use crate::gdbstub::CoreRegs; use crate::gdbstub::GdbRequest; use crate::gdbstub::GdbServer; use crate::gdbstub::ResumeAction; @@ -2019,15 +2019,15 @@ impl TracedTask { Ok(()) } - fn read_registers(&self) -> Result { + fn read_registers(&self) -> Result { let task = self.assume_stopped(); let regs = task.getregs()?; let fpregs = task.getfpregs()?; - let core_regs = Amd64CoreRegs::from_parts(regs, fpregs); + let core_regs = CoreRegs::from_parts(regs, fpregs); Ok(core_regs) } - fn write_registers(&self, core_regs: Amd64CoreRegs) -> Result<(), TraceError> { + fn write_registers(&self, core_regs: CoreRegs) -> Result<(), TraceError> { let task = self.assume_stopped(); let (regs, fpregs) = core_regs.into_parts(); task.setregs(regs)?;