Skip to content

Commit

Permalink
Merge pull request #3683 from bytecodealliance/demangle-names-in-prof…
Browse files Browse the repository at this point in the history
…iling

Try demangling names before forwarding them to the profiler
  • Loading branch information
fitzgen authored Jan 12, 2022
2 parents 7454f1f + e53f213 commit eeca41d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/jit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
5 changes: 4 additions & 1 deletion crates/jit/src/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
}

0 comments on commit eeca41d

Please sign in to comment.