Implement From LibAFL Error for Qemu Error (#2641)
* impl from qemu error for libafl error * new error for frontends like qemu or frida * exhaustive match * frontend -> runtime
This commit is contained in:
parent
d4fbe1754f
commit
99a156f783
@ -300,6 +300,8 @@ pub enum Error {
|
||||
Unknown(String, ErrorBacktrace),
|
||||
/// Error with the corpora
|
||||
InvalidCorpus(String, ErrorBacktrace),
|
||||
/// Error specific to a runtime like QEMU or Frida
|
||||
Runtime(String, ErrorBacktrace),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
@ -438,6 +440,15 @@ impl Error {
|
||||
{
|
||||
Error::InvalidCorpus(arg.into(), ErrorBacktrace::new())
|
||||
}
|
||||
|
||||
/// Error specific to some runtime, like QEMU or Frida
|
||||
#[must_use]
|
||||
pub fn runtime<S>(arg: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
Error::Runtime(arg.into(), ErrorBacktrace::new())
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
@ -502,6 +513,10 @@ impl Display for Error {
|
||||
write!(f, "Invalid corpus: {0}", &s)?;
|
||||
display_error_backtrace(f, b)
|
||||
}
|
||||
Self::Runtime(s, b) => {
|
||||
write!(f, "Runtime error: {0}", &s)?;
|
||||
display_error_backtrace(f, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,6 +57,18 @@ pub enum QemuError {
|
||||
RW(QemuRWError),
|
||||
}
|
||||
|
||||
impl From<QemuError> for libafl::Error {
|
||||
fn from(qemu_error: QemuError) -> Self {
|
||||
libafl::Error::runtime(qemu_error)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<QemuError> for String {
|
||||
fn from(qemu_error: QemuError) -> Self {
|
||||
format!("LibAFL QEMU Error: {qemu_error:?}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum QemuInitError {
|
||||
MultipleInstances,
|
||||
|
Loading…
x
Reference in New Issue
Block a user