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

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

Generated by: LCOV version 2.1-1