LCOV - code coverage report
Current view: top level - src/pdb - debug_info.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 0.0 % 36 0
Test Date: 2025-08-10:00:00:00 Functions: 0.0 % 11 0

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : use std::path::Path;
       4              : use std::marker::PhantomData;
       5              : use crate::common::{FromFFI, into_optional};
       6              : use crate::generic;
       7              : 
       8              : use super::compilation_unit::CompilationUnits;
       9              : use super::public_symbol::PublicSymbols;
      10              : use super::types::{Types, Type};
      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(path.as_ref().to_str().unwrap()))
      35            0 :     }
      36              : 
      37              :     /// The number of times the PDB file has been written.
      38            0 :     pub fn age(&self) -> u32 {
      39            0 :         self.ptr.age()
      40            0 :     }
      41              : 
      42              :     /// Unique identifier of the PDB file
      43            0 :     pub fn guid(&self) -> String {
      44            0 :         self.ptr.guid().to_string()
      45            0 :     }
      46              : 
      47              :     /// Iterator over the CompilationUnit from the PDB's DBI stream.
      48              :     /// [`crate::pdb::CompilationUnit`] are also named "Module" in the PDB's official documentation
      49            0 :     pub fn compilation_units(&self) -> CompilationUnits {
      50            0 :         CompilationUnits::new(self.ptr.compilation_units())
      51            0 :     }
      52              : 
      53              :     /// Return an iterator over the public symbol stream ([`PublicSymbol`])
      54            0 :     pub fn public_symbols(&self) -> PublicSymbols {
      55            0 :         PublicSymbols::new(self.ptr.public_symbols())
      56            0 :     }
      57              : 
      58              :     /// Try to find the [`PublicSymbol`] from the given name (based on the public symbol stream)
      59              :     ///
      60              :     ///
      61              :     /// ```
      62              :     /// if let Some(symbol) = info.public_symbol_by_name("MiSyncSystemPdes") {
      63              :     ///   // FOUND!
      64              :     /// }
      65              :     /// ```
      66            0 :     pub fn public_symbol_by_name(&self, name: &str) -> Option<PublicSymbol> {
      67            0 :         into_optional(self.ptr.public_symbol_by_name(name))
      68            0 :     }
      69              : 
      70              :     /// Return an iterator over the different [`crate::pdb::Type`] registered for this PDB file
      71            0 :     pub fn types(&self) -> Types {
      72            0 :         Types::new(self.ptr.types())
      73            0 :     }
      74              : 
      75              :     /// Try to find the type with the given name
      76            0 :     pub fn type_by_name(&self, name: &str) -> Option<Type> {
      77            0 :         into_optional(self.ptr.find_type(name))
      78            0 :     }
      79              : }
      80              : 
      81              : impl generic::DebugInfo for DebugInfo<'_> {
      82            0 :     fn as_generic(&self) -> &ffi::AbstracDebugInfo {
      83            0 :         self.ptr.as_ref().unwrap().as_ref()
      84            0 :     }
      85              : }
      86              : 
      87              : 
      88              : impl std::fmt::Display for DebugInfo<'_> {
      89            0 :     fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
      90            0 :         write!(f, "{}", self.ptr.to_string())
      91            0 :     }
      92              : }
        

Generated by: LCOV version 2.1-1