Skip to content

Commit

Permalink
feat(wasm_trace): support unknown info in wasm trace
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop authored and atenjin committed Jun 2, 2021
1 parent 7a599c2 commit 22fd27e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ impl FuncInstance {
let mut stack = interpreter
.trace()
.iter()
.map(|n| format!("{:#}[{}]", rustc_demangle::demangle(&n.1), n.0))
.map(|n| {
if let Some(info) = n {
format!("{:#}[{}]", rustc_demangle::demangle(&info.1), info.0)
} else {
"unknown".to_string()
}
})
.collect::<Vec<_>>();

// Append the panicing trap
Expand Down
6 changes: 3 additions & 3 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ impl Interpreter {
}

/// Get the stack functions
pub fn trace(&self) -> Vec<&(usize, String)> {
pub fn trace(&self) -> Vec<Option<&(usize, String)>> {
self.call_stack.trace()
}

Expand Down Expand Up @@ -1488,8 +1488,8 @@ impl CallStack {
}

/// Get the functions of current the stack
pub fn trace(&self) -> Vec<&(usize, String)> {
self.buf.iter().filter_map(|f| f.info()).collect::<Vec<_>>()
pub fn trace(&self) -> Vec<Option<&(usize, String)>> {
self.buf.iter().map(|f| f.info()).collect::<Vec<_>>()
}
}

Expand Down

0 comments on commit 22fd27e

Please sign in to comment.