LCOV - code coverage report
Current view: top level - src/dwarf - lexical_block.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 0.0 % 46 0
Test Date: 2025-10-05:00:00:00 Functions: 0.0 % 10 0

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : use crate::common::{FromFFI, into_ranges};
       4              : use crate::{Range, declare_fwd_iterator, to_opt};
       5              : use std::marker::PhantomData;
       6              : 
       7              : /// This structure represents a DWARF lexical block (`DW_TAG_lexical_block`)
       8              : pub struct LexicalBlock<'a> {
       9              :     ptr: cxx::UniquePtr<ffi::DWARF_LexicalBlock>,
      10              :     _owner: PhantomData<&'a ()>,
      11              : }
      12              : 
      13              : impl FromFFI<ffi::DWARF_LexicalBlock> for LexicalBlock<'_> {
      14            0 :     fn from_ffi(ptr: cxx::UniquePtr<ffi::DWARF_LexicalBlock>) -> Self {
      15            0 :         Self {
      16            0 :             ptr,
      17            0 :             _owner: PhantomData,
      18            0 :         }
      19            0 :     }
      20              : }
      21              : 
      22              : impl LexicalBlock<'_> {
      23              :     /// Return the *name* associated with this lexical block or an empty string
      24            0 :     pub fn name(&self) -> String {
      25            0 :         self.ptr.name().to_string()
      26            0 :     }
      27              : 
      28              :     /// Return the description associated with this lexical block or an empty string
      29            0 :     pub fn description(&self) -> String {
      30            0 :         self.ptr.description().to_string()
      31            0 :     }
      32              : 
      33              :     /// Return an iterator over the sub-LexicalBlock owned by this block.
      34            0 :     pub fn sub_blocks(&self) -> LexicalBlocks {
      35            0 :         LexicalBlocks::new(self.ptr.sub_blocks())
      36            0 :     }
      37              : 
      38              :     /// Return the start address of this block
      39            0 :     pub fn addr(&self) -> Option<u64> {
      40            0 :         to_opt!(
      41            0 :             &lief_ffi::DWARF_LexicalBlock::addr,
      42            0 :             &self
      43            0 :         );
      44            0 :     }
      45              : 
      46              :     /// Return the lowest virtual address owned by this block.
      47            0 :     pub fn low_pc(&self) -> Option<u64> {
      48            0 :         to_opt!(
      49            0 :             &lief_ffi::DWARF_LexicalBlock::low_pc,
      50            0 :             &self
      51            0 :         );
      52            0 :     }
      53              : 
      54              :     /// Return the highest virtual address owned by this block.
      55            0 :     pub fn high_pc(&self) -> Option<u64> {
      56            0 :         to_opt!(
      57            0 :             &lief_ffi::DWARF_LexicalBlock::high_pc,
      58            0 :             &self
      59            0 :         );
      60            0 :     }
      61              : 
      62              : 
      63              :     /// Return the size of this block as the difference of the highest address and the lowest
      64              :     /// address.
      65            0 :     pub fn size(&self) -> u64 {
      66            0 :         self.ptr.size()
      67            0 :     }
      68              : 
      69              :     /// Return a list of address ranges owned by this block.
      70              :     ///
      71              :     /// If the lexical block owns a contiguous range, it should return
      72              :     /// **a single** range.
      73            0 :     pub fn ranges(&self) -> Vec<Range> {
      74            0 :         into_ranges(self.ptr.ranges())
      75            0 :     }
      76              : }
      77              : 
      78            0 : declare_fwd_iterator!(
      79            0 :     LexicalBlocks,
      80            0 :     LexicalBlock<'a>,
      81            0 :     ffi::DWARF_LexicalBlock,
      82            0 :     ffi::DWARF_LexicalBlock,
      83            0 :     ffi::DWARF_LexicalBlock_it_sub_blocks
      84            0 : );
        

Generated by: LCOV version 2.1-1