use crate::ffi::asan::*;
use std::ffi::CStr;
use std::os::raw::c_void;
pub fn poison_memory_region(addr: *const c_void, size: usize) {
unsafe {
__asan_poison_memory_region(addr, size);
}
}
pub fn unpoison_memory_region(addr: *const c_void, size: usize) {
unsafe {
__asan_unpoison_memory_region(addr, size);
}
}
pub fn is_address_poisoned(addr: *const c_void) -> bool {
unsafe { __asan_address_is_poisoned(addr) != 0 }
}
pub fn region_is_poisoned(beg: *mut c_void, size: usize) -> Option<*mut c_void> {
let addr = unsafe { __asan_region_is_poisoned(beg, size) };
if addr.is_null() {
None
} else {
Some(addr)
}
}
pub fn describe_address(addr: *mut c_void) {
unsafe {
__asan_describe_address(addr);
}
}
pub fn report_present() -> bool {
unsafe { __asan_report_present() != 0 }
}
pub fn get_report_pc() -> *mut c_void {
unsafe { __asan_get_report_pc() }
}
pub fn get_report_bp() -> *mut c_void {
unsafe { __asan_get_report_bp() }
}
pub fn get_report_sp() -> *mut c_void {
unsafe { __asan_get_report_sp() }
}
pub fn get_report_address() -> *mut c_void {
unsafe { __asan_get_report_address() }
}
pub fn get_report_access_type() -> i32 {
unsafe { __asan_get_report_access_type() }
}
pub fn get_report_access_size() -> usize {
unsafe { __asan_get_report_access_size() }
}
pub fn get_report_description() -> String {
unsafe {
let desc_ptr = __asan_get_report_description();
if desc_ptr.is_null() {
String::new()
} else {
CStr::from_ptr(desc_ptr).to_string_lossy().into_owned()
}
}
}
pub fn set_error_report_callback(callback: Option<unsafe extern "C" fn(arg1: *const i8)>) {
unsafe {
__asan_set_error_report_callback(callback);
}
}
pub fn print_accumulated_stats() {
unsafe {
__asan_print_accumulated_stats();
}
}
pub fn default_options() -> String {
unsafe {
let options_ptr = __asan_default_options();
if options_ptr.is_null() {
String::new()
} else {
CStr::from_ptr(options_ptr).to_string_lossy().into_owned()
}
}
}