From 67eb2bcdfbb7c73ae4e5dee6c0e61add28bcd5cd Mon Sep 17 00:00:00 2001 From: ridethepig Date: Tue, 7 Mar 2023 14:39:02 +0000 Subject: [PATCH] update dependency --- proj-1/deet/Cargo.toml | 13 +++++++------ proj-1/deet/src/debugger.rs | 7 ++++--- proj-1/deet/src/dwarf_data.rs | 2 +- proj-1/deet/src/gimli_wrapper.rs | 23 +++++++++++++---------- proj-1/deet/src/inferior.rs | 16 +++++++++------- 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/proj-1/deet/Cargo.toml b/proj-1/deet/Cargo.toml index d1e8652..ae4d7d0 100644 --- a/proj-1/deet/Cargo.toml +++ b/proj-1/deet/Cargo.toml @@ -7,11 +7,12 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -nix = "0.17.0" -libc = "0.2.68" -rustyline = "6.1.2" +nix = "0.26.2" +libc = "0.2.139" +rustyline = "11.0.0" # gimli = { git = "https://github.com/gimli-rs/gimli", rev = "ad23cdb2", default-features = false, features = ["read"] } gimli = "0.27.2" -object = { version = "0.17", default-features = false, features = ["read"] } -memmap = "0.7" -addr2line = "0.11.0" +# object = { version = "0.17", default-features = false, features = ["read"] } +object = "0.30.3" +memmap2 = "0.5.10" +addr2line = "0.19.0" diff --git a/proj-1/deet/src/debugger.rs b/proj-1/deet/src/debugger.rs index 4e979c3..fa1bc3c 100644 --- a/proj-1/deet/src/debugger.rs +++ b/proj-1/deet/src/debugger.rs @@ -6,11 +6,12 @@ use crate::inferior::{Inferior, Status}; use nix::sys::signal::Signal::SIGTRAP; use rustyline::error::ReadlineError; use rustyline::Editor; +use rustyline::history::FileHistory; pub struct Debugger { target: String, history_path: String, - readline: Editor<()>, + readline: Editor<(), FileHistory>, inferior: Option, debug_data: DwarfData, breakpoint_vec: Vec, @@ -55,7 +56,7 @@ impl Debugger { // debug_data.print(); let history_path = format!("{}/.deet_history", std::env::var("HOME").unwrap()); - let mut readline = Editor::<()>::new(); + let mut readline = Editor::<(), FileHistory>::new().unwrap(); // Attempt to load history from ~/.deet_history if it exists let _ = readline.load_history(&history_path); @@ -296,7 +297,7 @@ impl Debugger { if line.trim().len() == 0 { continue; } - self.readline.add_history_entry(line.as_str()); + self.readline.add_history_entry(line.as_str()).unwrap(); if let Err(err) = self.readline.save_history(&self.history_path) { println!( "Warning: failed to save history file at {}: {}", diff --git a/proj-1/deet/src/dwarf_data.rs b/proj-1/deet/src/dwarf_data.rs index 954d4f3..4b9bf65 100644 --- a/proj-1/deet/src/dwarf_data.rs +++ b/proj-1/deet/src/dwarf_data.rs @@ -30,7 +30,7 @@ impl From for Error { impl DwarfData { pub fn from_file(path: &str) -> Result { let file = fs::File::open(path).or(Err(Error::ErrorOpeningFile))?; - let mmap = unsafe { memmap::Mmap::map(&file).or(Err(Error::ErrorOpeningFile))? }; + let mmap = unsafe { memmap2::Mmap::map(&file).or(Err(Error::ErrorOpeningFile))? }; let object = object::File::parse(&*mmap) .or_else(|e| Err(gimli_wrapper::Error::ObjectError(e.to_string())))?; let endian = if object.is_little_endian() { diff --git a/proj-1/deet/src/gimli_wrapper.rs b/proj-1/deet/src/gimli_wrapper.rs index 11d4879..1e88d9f 100644 --- a/proj-1/deet/src/gimli_wrapper.rs +++ b/proj-1/deet/src/gimli_wrapper.rs @@ -7,7 +7,7 @@ use gimli; use gimli::{UnitOffset, UnitSectionOffset}; -use object::Object; +use object::{Object, ObjectSection}; use std::borrow; //use std::io::{BufWriter, Write}; use crate::dwarf_data::{File, Function, Line, Location, Type, Variable}; @@ -19,9 +19,12 @@ use std::{io, path}; pub fn load_file(object: &object::File, endian: gimli::RunTimeEndian) -> Result, Error> { // Load a section and return as `Cow<[u8]>`. let load_section = |id: gimli::SectionId| -> Result, gimli::Error> { - Ok(object - .section_data_by_name(id.name()) - .unwrap_or(borrow::Cow::Borrowed(&[][..]))) + match object.section_by_name(id.name()) { + Some(ref section) => Ok(section + .uncompressed_data() + .unwrap_or(borrow::Cow::Borrowed(&[][..]))), + None => Ok(borrow::Cow::Borrowed(&[][..])), + } }; // Load a supplementary section. We don't have a supplementary object file, // so always return an empty slice. @@ -259,7 +262,7 @@ pub enum DebugValue { #[derive(Debug, Clone, PartialEq, Eq)] pub enum Error { GimliError(gimli::Error), - Addr2lineError(addr2line::gimli::Error), + // Addr2lineError(addr2line::gimli::Error), ObjectError(String), IoError, } @@ -270,11 +273,11 @@ impl From for Error { } } -impl From for Error { - fn from(err: addr2line::gimli::Error) -> Self { - Error::Addr2lineError(err) - } -} +// impl From for Error { +// fn from(err: addr2line::gimli::Error) -> Self { +// Error::Addr2lineError(err) +// } +// } impl From for Error { fn from(_: io::Error) -> Self { diff --git a/proj-1/deet/src/inferior.rs b/proj-1/deet/src/inferior.rs index ab8c6a5..2667a95 100644 --- a/proj-1/deet/src/inferior.rs +++ b/proj-1/deet/src/inferior.rs @@ -3,10 +3,10 @@ use nix::sys::signal; use nix::sys::signal::Signal; use nix::sys::wait::{waitpid, WaitPidFlag, WaitStatus}; use nix::unistd::Pid; +use std::mem::size_of; use std::os::unix::process::CommandExt; use std::process::Child; use std::process::Command; -use std::mem::size_of; use crate::dwarf_data::DwarfData; #[derive(Debug)] @@ -134,11 +134,13 @@ impl Inferior { let orig_byte = (word >> 8 * byte_offset) & 0xff; let masked_word = word & !(0xff << 8 * byte_offset); let updated_word = masked_word | ((val as u64) << 8 * byte_offset); - ptrace::write( - self.pid(), - aligned_addr as ptrace::AddressType, - updated_word as *mut std::ffi::c_void, - )?; + unsafe { + ptrace::write( + self.pid(), + aligned_addr as ptrace::AddressType, + updated_word as *mut std::ffi::c_void, + )?; + } Ok(orig_byte as u8) } @@ -147,7 +149,7 @@ impl Inferior { self.wait(None) } - pub fn restore_rip(&mut self, rip: u64) -> Result<(), nix::Error>{ + pub fn restore_rip(&mut self, rip: u64) -> Result<(), nix::Error> { let mut regs = ptrace::getregs(self.pid()).unwrap(); regs.rip = rip; ptrace::setregs(self.pid(), regs)