update dependency

This commit is contained in:
ridethepig 2023-03-07 14:39:02 +00:00
parent 1adfb67cff
commit 67eb2bcdfb
5 changed files with 34 additions and 27 deletions

View File

@ -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"

View File

@ -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<Inferior>,
debug_data: DwarfData,
breakpoint_vec: Vec<usize>,
@ -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 {}: {}",

View File

@ -30,7 +30,7 @@ impl From<gimli_wrapper::Error> for Error {
impl DwarfData {
pub fn from_file(path: &str) -> Result<DwarfData, Error> {
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() {

View File

@ -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<Vec<File>, Error> {
// Load a section and return as `Cow<[u8]>`.
let load_section = |id: gimli::SectionId| -> Result<borrow::Cow<[u8]>, 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<gimli::Error> for Error {
}
}
impl From<addr2line::gimli::Error> for Error {
fn from(err: addr2line::gimli::Error) -> Self {
Error::Addr2lineError(err)
}
}
// impl From<addr2line::gimli::Error> for Error {
// fn from(err: addr2line::gimli::Error) -> Self {
// Error::Addr2lineError(err)
// }
// }
impl From<io::Error> for Error {
fn from(_: io::Error) -> Self {

View File

@ -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);
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)