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

            Line data    Source code
       1              : //! This module wraps a PDB public symbol (stream number `n+5`)
       2              : 
       3              : use lief_ffi as ffi;
       4              : 
       5              : use std::marker::PhantomData;
       6              : 
       7              : use crate::common::FromFFI;
       8              : use crate::declare_fwd_iterator;
       9              : 
      10              : /// This class provides general information (RVA, name) about a symbol
      11              : /// from the PDB's public symbol stream (or Public symbol hash stream)
      12              : pub struct PublicSymbol<'a> {
      13              :     ptr: cxx::UniquePtr<ffi::PDB_PublicSymbol>,
      14              :     _owner: PhantomData<&'a ()>,
      15              : }
      16              : 
      17              : impl FromFFI<ffi::PDB_PublicSymbol> for PublicSymbol<'_> {
      18            0 :     fn from_ffi(ptr: cxx::UniquePtr<ffi::PDB_PublicSymbol>) -> Self {
      19            0 :         Self {
      20            0 :             ptr,
      21            0 :             _owner: PhantomData,
      22            0 :         }
      23            0 :     }
      24              : }
      25              : 
      26              : impl PublicSymbol<'_> {
      27              :     /// Name of the symbol
      28            0 :     pub fn name(&self) -> String {
      29            0 :         self.ptr.name().to_string()
      30            0 :     }
      31              : 
      32              :     /// Demangled representation of the symbol
      33            0 :     pub fn demangled_name(&self) -> String {
      34            0 :         self.ptr.name().to_string()
      35            0 :     }
      36              : 
      37              :     /// Name of the section in which this symbol is defined (e.g. `.text`).
      38            0 :     pub fn section_name(&self) -> Option<String> {
      39            0 :         let name = self.ptr.section_name().to_string();
      40            0 :         if !name.is_empty() {
      41            0 :             Some(name)
      42              :         } else {
      43            0 :             None
      44              :         }
      45            0 :     }
      46              : 
      47              :     /// **Relative** Virtual Address of this symbol.
      48              :     ///
      49              :     /// This function returns 0 if the RVA can't be computed.
      50            0 :     pub fn rva(&self) -> u32 {
      51            0 :         self.ptr.RVA()
      52            0 :     }
      53              : }
      54              : 
      55              : impl std::fmt::Display for PublicSymbol<'_> {
      56            0 :     fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
      57            0 :         write!(f, "{}", self.ptr.to_string())
      58            0 :     }
      59              : }
      60              : 
      61            0 : declare_fwd_iterator!(
      62            0 :     PublicSymbols,
      63            0 :     PublicSymbol<'a>,
      64            0 :     ffi::PDB_PublicSymbol,
      65            0 :     ffi::PDB_DebugInfo,
      66            0 :     ffi::PDB_DebugInfo_it_public_symbols
      67            0 : );
        

Generated by: LCOV version 2.1-1