Temp debug info for loading lib symbols
This commit is contained in:
parent
b680b0e61c
commit
da8e7c7258
1 changed files with 18 additions and 0 deletions
|
@ -14,12 +14,30 @@ macro_rules! load_function_ptrs {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl $struct_name {
|
impl $struct_name {
|
||||||
|
fn log(msg: impl ToString) {
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
|
let home = std::env::var("HOME").unwrap();
|
||||||
|
|
||||||
|
let log_file = format!("{}/rf2_vk_hud.log", home);
|
||||||
|
|
||||||
|
if let Ok(mut file) = std::fs::OpenOptions::new()
|
||||||
|
.append(true)
|
||||||
|
.create(true)
|
||||||
|
.open(&log_file)
|
||||||
|
{
|
||||||
|
if let Err(_) = file.write_all(format!("{}\n", msg.to_string()).as_bytes()) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn load<F>(mut f: F) -> $struct_name
|
pub fn load<F>(mut f: F) -> $struct_name
|
||||||
where F: FnMut(&std::ffi::CStr) -> *const std::os::raw::c_void
|
where F: FnMut(&std::ffi::CStr) -> *const std::os::raw::c_void
|
||||||
{
|
{
|
||||||
$struct_name {
|
$struct_name {
|
||||||
$(
|
$(
|
||||||
$name: unsafe {
|
$name: unsafe {
|
||||||
|
Self::log(format!("load: {}", stringify!($name)));
|
||||||
|
|
||||||
let dummy: *const std::ffi::c_void = std::ptr::null();
|
let dummy: *const std::ffi::c_void = std::ptr::null();
|
||||||
|
|
||||||
let name = std::ffi::CStr::from_bytes_with_nul_unchecked(concat!(stringify!($name), "\0").as_bytes());
|
let name = std::ffi::CStr::from_bytes_with_nul_unchecked(concat!(stringify!($name), "\0").as_bytes());
|
||||||
|
|
Loading…
Reference in a new issue