LCOV - code coverage report
Current view: top level - src/elf/note/core - siginfo.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 100.0 % 27 27
Test Date: 2026-04-12:00:00:00 Functions: 100.0 % 9 9

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : use std::marker::PhantomData;
       3              : 
       4              : use crate::common::FromFFI;
       5              : use crate::elf::note::NoteBase;
       6              : use crate::{to_result, Error};
       7              : 
       8              : /// Note representing core signal information (`NT_SIGINFO`)
       9              : pub struct SigInfo<'a> {
      10              :     ptr: cxx::UniquePtr<ffi::ELF_CoreSigInfo>,
      11              :     _owner: PhantomData<&'a ffi::ELF_Binary>,
      12              : }
      13              : 
      14              : impl SigInfo<'_> {
      15              :     /// Signal number
      16           26 :     pub fn signo(&self) -> Result<i32, Error> {
      17           26 :         to_result!(ffi::ELF_CoreSigInfo::signo, &self);
      18           26 :     }
      19              : 
      20              :     /// Signal code
      21           26 :     pub fn sigcode(&self) -> Result<i32, Error> {
      22           26 :         to_result!(ffi::ELF_CoreSigInfo::sigcode, &self);
      23           26 :     }
      24              : 
      25              :     /// Signal error number
      26           26 :     pub fn sigerrno(&self) -> Result<i32, Error> {
      27           26 :         to_result!(ffi::ELF_CoreSigInfo::sigerrno, &self);
      28           26 :     }
      29              : }
      30              : 
      31              : impl NoteBase for SigInfo<'_> {
      32          286 :     fn get_base(&self) -> &ffi::ELF_Note {
      33          286 :         self.ptr.as_ref().unwrap().as_ref()
      34          286 :     }
      35              : }
      36              : 
      37              : impl FromFFI<ffi::ELF_CoreSigInfo> for SigInfo<'_> {
      38          104 :     fn from_ffi(ptr: cxx::UniquePtr<ffi::ELF_CoreSigInfo>) -> Self {
      39          104 :         Self {
      40          104 :             ptr,
      41          104 :             _owner: PhantomData,
      42          104 :         }
      43          104 :     }
      44              : }
      45              : 
      46              : impl std::fmt::Debug for SigInfo<'_> {
      47           78 :     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
      48           78 :         let base = self as &dyn NoteBase;
      49           78 :         f.debug_struct("CoreSigInfo")
      50           78 :             .field("base", &base)
      51           78 :             //.field("signo", &self.signo())
      52           78 :             //.field("sigcode", &self.sigcode())
      53           78 :             //.field("sigerrno", &self.sigerrno())
      54           78 :             .finish()
      55           78 :     }
      56              : }
        

Generated by: LCOV version 2.1-1