Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
Signed-off-by: CalvinNeo <calvinneo1995@gmail.com>
  • Loading branch information
CalvinNeo committed Jul 22, 2024
1 parent 66d6a9c commit b439abc
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,27 @@ pub fn adhoc_dump(path: &str) -> tikv_alloc::error::ProfResult<()> {
let mut bytes = std::ffi::CString::new(path)?.into_bytes_with_nul();
let mut ptr = bytes.as_mut_ptr() as *mut ::std::os::raw::c_char;
let len = std::mem::size_of_val(&ptr) as u64;
issue_mallctl_args(
let r = issue_mallctl_args(
"prof.dump",
std::ptr::null_mut(),
std::ptr::null_mut(),
&mut ptr as *mut _ as *mut _,
len,
);
if r != 0 {
unsafe {
let err = *libc::__errno_location();
let err_msg = libc::strerror(err);
let c_str = std::ffi::CStr::from_ptr(err_msg);
let str_slice = c_str.to_str().unwrap_or("Unknown error");
tikv_util::warn!(
"adhoc_dump returns non-zero {} error_code: {} error_message: {}",
r,
err,
str_slice
);
}
}
}
Ok(())
}

0 comments on commit b439abc

Please sign in to comment.