Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
The beginnings of aux value parsing
  • Loading branch information
Sam Rose committed May 15, 2020
1 parent e7890da commit f612aea
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/debugger/subordinate.rs
Expand Up @@ -38,6 +38,7 @@ impl Subordinate {
debug_info,
};

subordinate.fetch_aux_vector()?;
subordinate.fetch_state()?;
Ok(subordinate)
}
Expand Down Expand Up @@ -119,6 +120,48 @@ impl Subordinate {
&self.debug_info
}

fn fetch_aux_vector(&mut self) -> Result<()> {
let regs: Registers = ptrace::getregs(self.pid)?.into();

let mut addr = (regs.rsp + 8) as usize;

for _ in 0..2 {
loop {
let mut buf = [0 as u8; 8];
let bytes = self.read_bytes(addr, 8)?;
buf.clone_from_slice(&bytes[0..8]);
let val = usize::from_le_bytes(buf);
addr += 8;
if val == 0 {
break;
}
}
}

loop {
let mut type_buf = [0 as u8; 8];
let mut val_buf = [0 as u8; 8];

let type_bytes = self.read_bytes(addr, 8)?;
type_buf.clone_from_slice(&type_bytes[0..8]);
let aux_type = u64::from_le_bytes(type_buf);

let val_bytes = self.read_bytes(addr + 8, 8)?;
val_buf.clone_from_slice(&val_bytes[0..8]);

let aux_val = u64::from_le_bytes(val_buf);

println!("aux type: {}, aux val: {:x}", aux_type, aux_val);

addr += 16;
if aux_type == 0 {
break;
}
}

Ok(())
}

fn fetch_state(&mut self) -> Result<()> {
self.wait_status = wait()?;
if let Stopped(_, _) = self.wait_status {
Expand Down

0 comments on commit f612aea

Please sign in to comment.