Line data Source code
1 : //! Module for processing PDB file
2 : //!
3 : //! This module exposes an API similar to the [`crate::dwarf`] module to process PDB
4 : //! files.
5 : //!
6 : //! One can instantiate a [`crate::pdb::DebugInfo`] using either [`crate::generic::Binary::debug_info`] or
7 : //! [`crate::pdb::load`].
8 : //!
9 : //! ```
10 : //! fn read_pdb(file: &str) {
11 : //! let pdb = lief::pdb::load(file).unwrap();
12 : //! for symbol in pdb.public_symbols() {
13 : //! println!("name: {}", symbol.name());
14 : //! }
15 : //! }
16 : //! ```
17 :
18 : use std::path::Path;
19 :
20 : use lief_ffi as ffi;
21 :
22 : use crate::common::into_optional;
23 :
24 : pub mod debug_info;
25 : pub mod compilation_unit;
26 : pub mod public_symbol;
27 : pub mod function;
28 : pub mod types;
29 : pub mod build_metadata;
30 :
31 : #[doc(inline)]
32 : pub use debug_info::DebugInfo;
33 :
34 : #[doc(inline)]
35 : pub use compilation_unit::CompilationUnit;
36 :
37 : #[doc(inline)]
38 : pub use public_symbol::PublicSymbol;
39 :
40 : #[doc(inline)]
41 : pub use function::Function;
42 :
43 : #[doc(inline)]
44 : pub use types::Type;
45 :
46 : #[doc(inline)]
47 : pub use build_metadata::BuildMetadata;
48 :
49 : /// Load a PDB from its filepath
50 0 : pub fn load<P: AsRef<Path>>(path: P) -> Option<DebugInfo<'static>> {
51 0 : into_optional(ffi::PDB_DebugInfo::from_file(path.as_ref().to_str().unwrap()))
52 0 : }
53 :
54 : /// Check if the given file is a `PDB`
55 0 : pub fn is_pdb<P: AsRef<Path>>(path: P) -> bool {
56 0 : ffi::PDB_Utils::is_pdb(path.as_ref().to_str().unwrap())
57 0 : }
|