Merge pull request #3683 from bytecodealliance/demangle-names-in-profiling

Try demangling names before forwarding them to the profiler
This commit is contained in:
Nick Fitzgerald
2022-01-12 10:31:56 -08:00
committed by GitHub
3 changed files with 8 additions and 1 deletions

2
Cargo.lock generated
View File

@@ -3560,10 +3560,12 @@ dependencies = [
"anyhow",
"bincode",
"cfg-if 1.0.0",
"cpp_demangle",
"gimli",
"ittapi-rs",
"object",
"region",
"rustc-demangle",
"rustix",
"serde",
"target-lexicon",

View File

@@ -24,6 +24,8 @@ serde = { version = "1.0.94", features = ["derive"] }
addr2line = { version = "0.17.0", default-features = false }
ittapi-rs = { version = "0.1.6", optional = true }
bincode = "1.2.1"
rustc-demangle = "0.1.16"
cpp_demangle = "0.3.2"
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.8", features = ["winnt", "impl-default"] }

View File

@@ -65,7 +65,10 @@ impl ProfilingAgent for NullProfilerAgent {
fn debug_name(module: &Module, index: DefinedFuncIndex) -> String {
let index = module.func_index(index);
match module.func_names.get(&index) {
Some(s) => s.clone(),
Some(s) => rustc_demangle::try_demangle(s)
.map(|demangle| demangle.to_string())
.or_else(|_| cpp_demangle::Symbol::new(s).map(|sym| sym.to_string()))
.unwrap_or_else(|_| s.clone()),
None => format!("wasm::wasm-function[{}]", index.index()),
}
}