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

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : use crate::common::{into_ranges, FromFFI};
       4              : use crate::{declare_fwd_iterator, to_opt, Range};
       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!(&lief_ffi::DWARF_LexicalBlock::addr, &self);
      41            0 :     }
      42              : 
      43              :     /// Return the lowest virtual address owned by this block.
      44            0 :     pub fn low_pc(&self) -> Option<u64> {
      45            0 :         to_opt!(&lief_ffi::DWARF_LexicalBlock::low_pc, &self);
      46            0 :     }
      47              : 
      48              :     /// Return the highest virtual address owned by this block.
      49            0 :     pub fn high_pc(&self) -> Option<u64> {
      50            0 :         to_opt!(&lief_ffi::DWARF_LexicalBlock::high_pc, &self);
      51            0 :     }
      52              : 
      53              :     /// Return the size of this block as the difference of the highest address and the lowest
      54              :     /// address.
      55            0 :     pub fn size(&self) -> u64 {
      56            0 :         self.ptr.size()
      57            0 :     }
      58              : 
      59              :     /// Return a list of address ranges owned by this block.
      60              :     ///
      61              :     /// If the lexical block owns a contiguous range, it should return
      62              :     /// **a single** range.
      63            0 :     pub fn ranges(&self) -> Vec<Range> {
      64            0 :         into_ranges(self.ptr.ranges())
      65            0 :     }
      66              : }
      67              : 
      68            0 : declare_fwd_iterator!(
      69            0 :     LexicalBlocks,
      70            0 :     LexicalBlock<'a>,
      71            0 :     ffi::DWARF_LexicalBlock,
      72            0 :     ffi::DWARF_LexicalBlock,
      73            0 :     ffi::DWARF_LexicalBlock_it_sub_blocks
      74            0 : );
        

Generated by: LCOV version 2.1-1