Line data Source code
1 : //! Module for processing DWARF debug info
2 : //!
3 : //! This module exposes an API similar to the [`crate::pdb`] module to process DWARF
4 : //! debug info (embedded or not).
5 : //!
6 : //! One can instantiate a [`crate::dwarf::DebugInfo`] using either [`crate::generic::Binary::debug_info`] or
7 : //! [`crate::dwarf::load`] for external DWARF files.
8 : //!
9 : //! ```
10 : //! fn from_binary(elf: &lief::elf::Binary) {
11 : //! if let Some(lief::DebugInfo::Dwarf(dwarf)) = elf.debug_info() {
12 : //! for complilation_unit in dwarf.compilation_units() {
13 : //! println!("{}", complilation_unit.name());
14 : //! }
15 : //! }
16 : //! }
17 : //!
18 : //! fn from_external(dwarf_file: &str) {
19 : //! let debug_info = lief::dwarf::load(dwarf_file).unwrap();
20 : //! for complilation_unit in debug_info.compilation_units() {
21 : //! println!("{}", complilation_unit.name());
22 : //! }
23 : //! }
24 : //! ```
25 :
26 : use lief_ffi as ffi;
27 :
28 : pub mod debug_info;
29 : pub mod compilation_unit;
30 : pub mod function;
31 : pub mod variable;
32 : pub mod types;
33 : pub mod scope;
34 : pub mod parameters;
35 : pub mod editor;
36 :
37 : use crate::common::into_optional;
38 :
39 : #[doc(inline)]
40 : pub use debug_info::DebugInfo;
41 :
42 : #[doc(inline)]
43 : pub use compilation_unit::CompilationUnit;
44 :
45 : #[doc(inline)]
46 : pub use function::Function;
47 :
48 : #[doc(inline)]
49 : pub use variable::Variable;
50 :
51 : #[doc(inline)]
52 : pub use scope::Scope;
53 :
54 : #[doc(inline)]
55 : pub use types::Type;
56 :
57 : #[doc(inline)]
58 : pub use editor::Editor;
59 :
60 : #[doc(inline)]
61 : pub use parameters::{Parameter, Parameters};
62 :
63 : /// Load a DWARF from its file path
64 0 : pub fn load(path: &str) -> Option<DebugInfo> {
65 0 : into_optional(ffi::DWARF_DebugInfo::from_file(path))
66 0 : }
|