use std::ptr;
use foreign_types::ForeignTypeRef;
use foreign_types::Opaque;
use super::Error;
use super::ThreadRef;
pub struct FrameRef(Opaque);
unsafe impl ForeignTypeRef for FrameRef {
type CType = crate::dw_sys::Dwfl_Frame;
}
impl FrameRef {
pub fn thread(&self) -> &ThreadRef {
unsafe {
let ptr = crate::dw_sys::dwfl_frame_thread(self.as_ptr());
ThreadRef::from_ptr(ptr)
}
}
pub fn pc(&self, is_activation: Option<&mut bool>) -> Result<u64, Error> {
unsafe {
let mut pc = 0;
let isactivation = is_activation.map_or(ptr::null_mut(), |b| b as *mut bool);
if crate::dw_sys::dwfl_frame_pc(self.as_ptr(), &mut pc, isactivation) {
Ok(pc)
} else {
Err(Error::new())
}
}
}
}