1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
pub mod gdb_remote;
pub enum RunResult {
Ok,
HitBreakCondition,
ExecutionError(String)
}
pub trait Peek {
fn read_bytes<A: yaxpeax_arch::Address, W: std::io::Write>(&self, addr: A, len: u64, buf: &mut W) -> Option<()>;
fn read<A: yaxpeax_arch::Address>(&self, addr: A) -> Option<u8> {
let mut buf = [0u8; 1];
if self.read_bytes(addr, buf.len() as u64, &mut &mut buf[..]).is_none() {
return None;
} else {
return Some(buf[0]);
}
}
fn read16<A: yaxpeax_arch::Address>(&self, addr: A) -> Option<[u8; 2]> {
let mut buf = [0u8; 2];
if self.read_bytes(addr, buf.len() as u64, &mut &mut buf[..]).is_none() {
return None;
} else {
return Some(buf);
}
}
fn read32<A: yaxpeax_arch::Address>(&self, addr: A) -> Option<[u8; 4]> {
let mut buf = [0u8; 4];
if self.read_bytes(addr, buf.len() as u64, &mut &mut buf[..]).is_none() {
return None;
} else {
return Some(buf);
}
}
fn read64<A: yaxpeax_arch::Address>(&self, addr: A) -> Option<[u8; 8]> {
let mut buf = [0u8; 8];
if self.read_bytes(addr, buf.len() as u64, &mut &mut buf[..]).is_none() {
return None;
} else {
return Some(buf);
}
}
}
pub trait DebugTarget<'a, Target> {
type WatchTarget;
type BreakCondition;
fn attach(_: &'a mut Target) -> Self;
fn single_step(&mut self) -> Result<(), String>;
fn run(&mut self) -> RunResult;
fn add_watch(&mut self, _: Self::WatchTarget) -> Result<(), String>;
fn add_break_condition(&mut self, _: Self::BreakCondition) -> Result<(), String>;
}
pub trait DBTarget2<Target> {
type WatchTarget;
type BreakCondition;
fn attach(_: Target) -> Self;
fn detach(self) -> Target;
fn single_step(&mut self) -> Result<(), String>;
fn run(&mut self) -> RunResult;
fn add_watch(&mut self, _: Self::WatchTarget) -> Result<(), String>;
fn add_break_condition(&mut self, _: Self::BreakCondition) -> Result<(), String>;
}