Support vtune profiling of trampolines too (#3687)
* Provide helpers for demangling function names * Profile trampolines in vtune too * get rid of mapping * avoid code duplication with jitdump_linux * maintain previous default display name for wasm functions * no dash, grrr * Remove unused profiling error type
This commit is contained in:
27
crates/jit/src/demangling.rs
Normal file
27
crates/jit/src/demangling.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
//! Helpers for demangling function names.
|
||||
|
||||
/// Demangles a single function name into a user-readable form.
|
||||
///
|
||||
/// Currently supported: Rust/C/C++ function names.
|
||||
pub fn demangle_function_name(writer: &mut impl std::fmt::Write, name: &str) -> std::fmt::Result {
|
||||
if let Ok(demangled) = rustc_demangle::try_demangle(name) {
|
||||
write!(writer, "{}", demangled)
|
||||
} else if let Ok(demangled) = cpp_demangle::Symbol::new(name) {
|
||||
write!(writer, "{}", demangled)
|
||||
} else {
|
||||
write!(writer, "{}", name)
|
||||
}
|
||||
}
|
||||
|
||||
/// Demangles a function name if it's provided, or returns a unified representation based on the
|
||||
/// function index otherwise.
|
||||
pub fn demangle_function_name_or_index(
|
||||
writer: &mut impl std::fmt::Write,
|
||||
name: Option<&str>,
|
||||
func_id: usize,
|
||||
) -> std::fmt::Result {
|
||||
match name {
|
||||
Some(name) => demangle_function_name(writer, name),
|
||||
None => write!(writer, "<wasm function {}>", func_id),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user