LCOV - code coverage report
Current view: top level - src/pdb - debug_info.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 0.0 % 41 0
Test Date: 2026-04-12:00:00:00 Functions: 0.0 % 12 0

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : use crate::common::{into_optional, FromFFI};
       4              : use crate::generic;
       5              : use std::marker::PhantomData;
       6              : use std::path::Path;
       7              : 
       8              : use super::compilation_unit::CompilationUnits;
       9              : use super::public_symbol::PublicSymbols;
      10              : use super::types::{Type, Types};
      11              : use super::PublicSymbol;
      12              : 
      13              : /// Main interface over a PDB.
      14              : ///
      15              : /// One can instantiate this structure with [`crate::pdb::load`],
      16              : /// [`DebugInfo::from`] or using [`crate::generic::Binary::debug_info`].
      17              : pub struct DebugInfo<'a> {
      18              :     ptr: cxx::UniquePtr<ffi::PDB_DebugInfo>,
      19              :     _owner: PhantomData<&'a ()>,
      20              : }
      21              : 
      22              : impl FromFFI<ffi::PDB_DebugInfo> for DebugInfo<'_> {
      23            0 :     fn from_ffi(info: cxx::UniquePtr<ffi::PDB_DebugInfo>) -> Self {
      24            0 :         Self {
      25            0 :             ptr: info,
      26            0 :             _owner: PhantomData,
      27            0 :         }
      28            0 :     }
      29              : }
      30              : 
      31              : impl DebugInfo<'_> {
      32              :     /// Create a DebugInfo from a PDB file path
      33            0 :     pub fn from<P: AsRef<Path>>(path: P) -> Option<DebugInfo<'static>> {
      34            0 :         into_optional(ffi::PDB_DebugInfo::from_file(
      35            0 :             path.as_ref().to_str().unwrap(),
      36            0 :         ))
      37            0 :     }
      38              : 
      39              :     /// The number of times the PDB file has been written.
      40            0 :     pub fn age(&self) -> u32 {
      41            0 :         self.ptr.age()
      42            0 :     }
      43              : 
      44              :     /// Unique identifier of the PDB file
      45            0 :     pub fn guid(&self) -> String {
      46            0 :         self.ptr.guid().to_string()
      47            0 :     }
      48              : 
      49              :     /// Iterator over the CompilationUnit from the PDB's DBI stream.
      50              :     /// [`crate::pdb::CompilationUnit`] are also named "Module" in the PDB's official documentation
      51            0 :     pub fn compilation_units(&self) -> CompilationUnits<'_> {
      52            0 :         CompilationUnits::new(self.ptr.compilation_units())
      53            0 :     }
      54              : 
      55              :     /// Return an iterator over the public symbol stream ([`PublicSymbol`])
      56            0 :     pub fn public_symbols(&self) -> PublicSymbols<'_> {
      57            0 :         PublicSymbols::new(self.ptr.public_symbols())
      58            0 :     }
      59              : 
      60              :     /// Try to find the [`PublicSymbol`] from the given name (based on the public symbol stream)
      61              :     ///
      62              :     ///
      63              :     /// ```
      64              :     /// if let Some(symbol) = info.public_symbol_by_name("MiSyncSystemPdes") {
      65              :     ///   // FOUND!
      66              :     /// }
      67              :     /// ```
      68            0 :     pub fn public_symbol_by_name(&self, name: &str) -> Option<PublicSymbol<'_>> {
      69            0 :         into_optional(self.ptr.public_symbol_by_name(name))
      70            0 :     }
      71              : 
      72              :     /// Return an iterator over the different [`crate::pdb::Type`] registered for this PDB file
      73            0 :     pub fn types(&self) -> Types<'_> {
      74            0 :         Types::new(self.ptr.types())
      75            0 :     }
      76              : 
      77              :     /// Try to find the type with the given name
      78            0 :     pub fn type_by_name(&self, name: &str) -> Option<Type<'_>> {
      79            0 :         into_optional(self.ptr.find_type(name))
      80            0 :     }
      81              : 
      82              :     /// Try to find the type at the given index
      83            0 :     pub fn type_by_index(&self, index: u32) -> Option<Type<'_>> {
      84            0 :         into_optional(self.ptr.find_type_by_index(index))
      85            0 :     }
      86              : }
      87              : 
      88              : impl generic::DebugInfo for DebugInfo<'_> {
      89            0 :     fn as_generic(&self) -> &ffi::AbstracDebugInfo {
      90            0 :         self.ptr.as_ref().unwrap().as_ref()
      91            0 :     }
      92              : }
      93              : 
      94              : impl std::fmt::Display for DebugInfo<'_> {
      95            0 :     fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
      96            0 :         write!(f, "{}", self.ptr.to_string())
      97            0 :     }
      98              : }
        

Generated by: LCOV version 2.1-1