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),
|
Unknown(String, ErrorBacktrace),
|
||||||
/// Error with the corpora
|
/// Error with the corpora
|
||||||
InvalidCorpus(String, ErrorBacktrace),
|
InvalidCorpus(String, ErrorBacktrace),
|
||||||
|
/// Error specific to a runtime like QEMU or Frida
|
||||||
|
Runtime(String, ErrorBacktrace),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
@ -438,6 +440,15 @@ impl Error {
|
|||||||
{
|
{
|
||||||
Error::InvalidCorpus(arg.into(), ErrorBacktrace::new())
|
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 {
|
impl Display for Error {
|
||||||
@ -502,6 +513,10 @@ impl Display for Error {
|
|||||||
write!(f, "Invalid corpus: {0}", &s)?;
|
write!(f, "Invalid corpus: {0}", &s)?;
|
||||||
display_error_backtrace(f, b)
|
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),
|
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)]
|
#[derive(Debug)]
|
||||||
pub enum QemuInitError {
|
pub enum QemuInitError {
|
||||||
MultipleInstances,
|
MultipleInstances,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user