[AFLplusplus/LibAFL] dump registers on OpenBSD amd64 (PR #787)
* dump registers on openbsd * write_crash implementations
This commit is contained in:
parent
60a6c3f68b
commit
577f0be832
@ -216,13 +216,42 @@ pub fn dump_registers<W: Write>(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Write the content of all important registers
|
||||||
|
#[cfg(all(target_os = "openbsd", target_arch = "x86_64"))]
|
||||||
|
#[allow(clippy::similar_names)]
|
||||||
|
pub fn dump_registers<W: Write>(
|
||||||
|
writer: &mut BufWriter<W>,
|
||||||
|
ucontext: &ucontext_t,
|
||||||
|
) -> Result<(), std::io::Error> {
|
||||||
|
write!(writer, "r8 : {:#016x}, ", ucontext.sc_r8)?;
|
||||||
|
write!(writer, "r9 : {:#016x}, ", ucontext.sc_r9)?;
|
||||||
|
write!(writer, "r10 : {:#016x}, ", ucontext.sc_r10)?;
|
||||||
|
write!(writer, "r11 : {:#016x}, ", ucontext.sc_r11)?;
|
||||||
|
write!(writer, "r12 : {:#016x}, ", ucontext.sc_r12)?;
|
||||||
|
write!(writer, "r13 : {:#016x}, ", ucontext.sc_r13)?;
|
||||||
|
write!(writer, "r14 : {:#016x}, ", ucontext.sc_r14)?;
|
||||||
|
write!(writer, "r15 : {:#016x}, ", ucontext.sc_r15)?;
|
||||||
|
write!(writer, "rdi : {:#016x}, ", ucontext.sc_rdi)?;
|
||||||
|
write!(writer, "rsi : {:#016x}, ", ucontext.sc_rsi)?;
|
||||||
|
write!(writer, "rbp : {:#016x}, ", ucontext.sc_rbp)?;
|
||||||
|
write!(writer, "rbx : {:#016x}, ", ucontext.sc_rbx)?;
|
||||||
|
write!(writer, "rdx : {:#016x}, ", ucontext.sc_rdx)?;
|
||||||
|
write!(writer, "rax : {:#016x}, ", ucontext.sc_rax)?;
|
||||||
|
write!(writer, "rcx : {:#016x}, ", ucontext.sc_rcx)?;
|
||||||
|
write!(writer, "rsp : {:#016x}, ", ucontext.sc_rsp)?;
|
||||||
|
write!(writer, "rflags : {:#016x}, ", ucontext.sc_rflags)?;
|
||||||
|
write!(writer, "cs : {:#016x}, ", ucontext.sc_cs)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::unnecessary_wraps)]
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
target_vendor = "apple",
|
target_vendor = "apple",
|
||||||
target_os = "linux",
|
target_os = "linux",
|
||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "freebsd",
|
target_os = "freebsd",
|
||||||
target_os = "netbsd"
|
target_os = "netbsd",
|
||||||
|
target_os = "openbsd"
|
||||||
)))]
|
)))]
|
||||||
fn dump_registers<W: Write>(
|
fn dump_registers<W: Write>(
|
||||||
writer: &mut BufWriter<W>,
|
writer: &mut BufWriter<W>,
|
||||||
@ -326,7 +355,45 @@ fn write_crash<W: Write>(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(target_vendor = "apple", target_os = "linux", target_os = "android")))]
|
#[cfg(target_os = "freebsd")]
|
||||||
|
#[allow(clippy::similar_names)]
|
||||||
|
fn write_crash<W: Write>(
|
||||||
|
writer: &mut BufWriter<W>,
|
||||||
|
signal: Signal,
|
||||||
|
ucontext: &ucontext_t,
|
||||||
|
) -> Result<(), std::io::Error> {
|
||||||
|
writeln!(
|
||||||
|
writer,
|
||||||
|
"Received signal {} at{:016x}, fault address: 0x{:016x}",
|
||||||
|
signal, ucontext.uc_mcontext.mc_rip, ucontext.uc_mcontext.mc_fs
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "openbsd")]
|
||||||
|
#[allow(clippy::similar_names)]
|
||||||
|
fn write_crash<W: Write>(
|
||||||
|
writer: &mut BufWriter<W>,
|
||||||
|
signal: Signal,
|
||||||
|
ucontext: &ucontext_t,
|
||||||
|
) -> Result<(), std::io::Error> {
|
||||||
|
writeln!(
|
||||||
|
writer,
|
||||||
|
"Received signal {} at{:016x}, fault address: 0x{:016x}",
|
||||||
|
signal, ucontext.sc_rip, ucontext.sc_fs
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(any(
|
||||||
|
target_vendor = "apple",
|
||||||
|
target_os = "linux",
|
||||||
|
target_os = "android",
|
||||||
|
target_os = "freebsd",
|
||||||
|
target_os = "openbsd"
|
||||||
|
)))]
|
||||||
fn write_crash<W: Write>(
|
fn write_crash<W: Write>(
|
||||||
writer: &mut BufWriter<W>,
|
writer: &mut BufWriter<W>,
|
||||||
signal: Signal,
|
signal: Signal,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user