dwat/
lib.rs

1//! `dwat` is a library for accessing [DWARF](https://dwarfstd.org/)
2//! (v4/v5) debuging information.
3//!
4//! The library is primarily focused on making type information from DWARF more
5//! accessible, enabling quick lookups and enumeration of type related DWARF
6//! information.
7//!
8//! `dwat` also implements formatting methods for pretty pretting structs/unions
9//! similar to the [pahole](https://github.com/acmel/dwarves) utility and the
10//! gdb `ptype` command.
11
12pub mod format;
13pub mod types;
14pub mod dwarf;
15
16pub use dwarf::Dwarf;
17pub use types::*;
18
19#[cfg(feature = "python")]
20pub mod python;
21
22pub mod prelude {
23    //! Re-exports commonly needed traits
24    pub use crate::types::NamedType;
25    pub use crate::types::InnerType;
26    pub use crate::types::HasMembers;
27    pub use crate::dwarf::DwarfContext;
28    pub use crate::dwarf::DwarfLookups;
29}
30
31/// Error type for parsing/loading DWARF information
32#[derive(thiserror::Error, Debug)]
33pub enum Error {
34    // Fatal
35    #[error("failed to load dwarf info from file")]
36    DwarfLoadError(String),
37
38    #[error("object failed to parse file")]
39    ObjectError(#[from] object::Error),
40
41    #[error("failed when attempting to get offset of a UnitHeader")]
42    HeaderOffsetError,
43
44    #[error("failed when attempting to get some CU")]
45    CUError(String),
46
47    #[error("failed when attempting to get some DIE")]
48    DIEError(String),
49
50    #[error("failed due to unimplemented functionality")]
51    UnimplementedError(String),
52
53    #[error("failed due to an invalid attribute")]
54    InvalidAttributeError,
55
56    // Non-Fatal
57    #[error("failure when attempting to find a Name Attribute")]
58    NameAttributeNotFound,
59
60    #[error("failure when attempting to find a Type Attribute")]
61    TypeAttributeNotFound,
62
63    #[error("failure when attempting to find a ByteSize Attribute")]
64    ByteSizeAttributeNotFound,
65
66    #[error("failure when attempting to find a BitSize Attribute")]
67    BitSizeAttributeNotFound,
68
69    #[error("failure when attempting to find a MemberLocation Attribute")]
70    MemberLocationAttributeNotFound,
71
72    #[error("failure when attempting to find an Alignment Attribute")]
73    AlignmentAttributeNotFound,
74
75    #[error("failure when attempting to find a Producer Attribute")]
76    ProducerAttributeNotFound,
77
78    #[error("failure when attempting to find a Language Attribute")]
79    LanguageAttributeNotFound,
80}