1use gimli::{DwAte, DwTag, SectionId};
2
3pub mod decoder;
4pub mod log;
5pub mod var;
6
7pub use decoder::Decoder;
8
9#[derive(Debug, thiserror::Error)]
10pub enum Error {
11 #[error("Gimli error: {0}")]
12 Gimli(#[from] gimli::Error),
13 #[error("{0}")]
14 Parser(#[from] cdefmt_parser::Error),
15 #[error("rformat error: {0}")]
16 RFormat(#[from] rformat::error::FormatError),
17 #[error("The provided elf is missing the '.cdefmt' section.")]
18 MissingSection,
19 #[error("DIE is missing attribute {0}")]
20 NoAttribute(gimli::DwAt),
21 #[error("Unable to find requested compilation unit ({0}).")]
22 NoCompilationUnit(String),
23 #[error("Nullterminator is missing from log string")]
24 NoNullTerm,
25 #[error("The elf is missing the following section: {0:?}")]
26 NoSection(SectionId),
27 #[error("Unable to find requested type ({0}).")]
28 NoType(String),
29 #[error("Provided log id [{0}] is larger than the '.cdefmt' section [{1}]")]
30 OutOfBounds(usize, usize),
31 #[error("Failed extract data from the '.cdefmt' section, error: {0}")]
32 SectionData(#[from] object::Error),
33 #[error("The log at id [{0}] is malformed, error: {1}")]
34 Utf8(usize, std::str::Utf8Error),
35 #[error("Encountered an unsupported base type, encoding: {0}, size: {1}")]
36 UnsupportedBaseType(DwAte, u64),
37 #[error("Encountered an unsupported pointer size: {0}")]
38 UnsupportedPointerSize(u64),
39 #[error("Encountered an unexpected tag: {0}")]
40 UnexpectedTag(DwTag),
41 #[error("Encountered an attribute with bad type")]
42 BadAttribute,
43 #[error("There is no DIE at the given offset: {0}")]
44 NoDIE(u64),
45 #[error("Unsupported schema version: {0}")]
46 Schema(u32),
47 #[error("{0}")]
48 Custom(&'static str),
49}
50
51pub type Result<T> = std::result::Result<T, Error>;