1use gimli::{DwAte, DwTag, SectionId};
2
3mod dwarf;
4
5pub mod metadata;
6pub mod parser;
7pub mod r#type;
8
9pub use parser::Parser;
10
11#[derive(Debug, thiserror::Error)]
12pub enum Error {
13 #[error("Gimli error: {0}")]
14 Gimli(#[from] gimli::Error),
15 #[error("Json error: {0}")]
16 Json(#[from] serde_json::Error),
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 SchemaVersion(u32),
47 #[error("{0}")]
48 Custom(&'static str),
49}
50
51pub type Result<T> = std::result::Result<T, Error>;