Run cargo fmt on everything.

This commit is contained in:
losfair
2019-10-13 20:02:47 +08:00
parent c18bdd52cc
commit 5499a69ddc
7 changed files with 170 additions and 143 deletions

View File

@ -94,11 +94,15 @@ pub fn get_inline_breakpoint_size(arch: Architecture, backend: Backend) -> Optio
match (arch, backend) {
(Architecture::X64, Backend::Singlepass) => Some(7),
(Architecture::Aarch64, Backend::Singlepass) => Some(12),
_ => None
_ => None,
}
}
pub fn read_inline_breakpoint(arch: Architecture, backend: Backend, code: &[u8]) -> Option<InlineBreakpoint> {
pub fn read_inline_breakpoint(
arch: Architecture,
backend: Backend,
code: &[u8],
) -> Option<InlineBreakpoint> {
match arch {
Architecture::X64 => match backend {
Backend::Singlepass => {
@ -118,7 +122,7 @@ pub fn read_inline_breakpoint(arch: Architecture, backend: Backend, code: &[u8])
None
}
}
_ => None
_ => None,
},
Architecture::Aarch64 => match backend {
Backend::Singlepass => {
@ -131,14 +135,14 @@ pub fn read_inline_breakpoint(arch: Architecture, backend: Backend, code: &[u8])
0 => InlineBreakpointType::Trace,
1 => InlineBreakpointType::Middleware,
_ => InlineBreakpointType::Unknown,
}
},
})
} else {
None
}
},
}
_ => None,
}
},
}
}

View File

@ -244,7 +244,9 @@ extern "C" fn signal_trap_handler(
siginfo: *mut siginfo_t,
ucontext: *mut c_void,
) {
use crate::backend::{Architecture, InlineBreakpointType, get_inline_breakpoint_size, read_inline_breakpoint};
use crate::backend::{
get_inline_breakpoint_size, read_inline_breakpoint, Architecture, InlineBreakpointType,
};
#[cfg(target_arch = "x86_64")]
static ARCH: Architecture = Architecture::X64;
@ -260,30 +262,35 @@ extern "C" fn signal_trap_handler(
let magic_size = if let Some(x) = get_inline_breakpoint_size(ARCH, v.backend) {
x
} else {
continue
continue;
};
let ip = fault.ip.get();
let end = v.base + v.msm.total_size;
if ip >= v.base && ip < end && ip + magic_size <= end {
if let Some(ib) = read_inline_breakpoint(ARCH, v.backend, std::slice::from_raw_parts(ip as *const u8, magic_size)) {
if let Some(ib) = read_inline_breakpoint(
ARCH,
v.backend,
std::slice::from_raw_parts(ip as *const u8, magic_size),
) {
fault.ip.set(ip + magic_size);
match ib.ty {
InlineBreakpointType::Trace => {},
InlineBreakpointType::Trace => {}
InlineBreakpointType::Middleware => {
let out: Option<Result<(), Box<dyn Any>>> = with_breakpoint_map(|bkpt_map| {
bkpt_map.and_then(|x| x.get(&ip)).map(|x| {
x(BreakpointInfo {
fault: Some(&fault),
let out: Option<Result<(), Box<dyn Any>>> =
with_breakpoint_map(|bkpt_map| {
bkpt_map.and_then(|x| x.get(&ip)).map(|x| {
x(BreakpointInfo {
fault: Some(&fault),
})
})
})
});
});
if let Some(Ok(())) = out {
} else {
println!("Failed calling middleware: {:?}", out);
}
}
_ => println!("Unknown breakpoint type: {:?}", ib.ty)
_ => println!("Unknown breakpoint type: {:?}", ib.ty),
}
return true;
}

View File

@ -1,6 +1,6 @@
use crate::backend::Backend;
use std::collections::BTreeMap;
use std::ops::Bound::{Included, Unbounded};
use crate::backend::Backend;
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub struct RegisterIndex(pub usize);