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