Commit d5998f08 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Also print relative position for compiled frames

This helps debugging wasm crashes. {WasmCompiledFrame::Print} should
also print the position inside the current function, additional to the
absolute position in the wasm module. The source positions encoded in
wasm code are also function-relative, so with the additional output
it's easier to match them.

R=ahaas@chromium.org

Change-Id: I40f99e75e3ba25fdfd24943ea96e49868b91844f
Reviewed-on: https://chromium-review.googlesource.com/1138053Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54458}
parent 423c10d5
......@@ -1772,9 +1772,14 @@ void WasmCompiledFrame::Print(StringStream* accumulator, PrintMode mode,
int func_name_len = std::min(kMaxPrintedFunctionName, raw_func_name.length());
memcpy(func_name, raw_func_name.start(), func_name_len);
func_name[func_name_len] = '\0';
accumulator->Add("], function #%u ('%s'), pc=%p (+0x%x), pos=%d\n",
function_index(), func_name, reinterpret_cast<void*>(pc()),
static_cast<int>(pc() - instruction_start), position());
int pos = position();
const wasm::WasmModule* module = wasm_instance()->module_object()->module();
int func_index = function_index();
int func_code_offset = module->functions[func_index].code.offset();
accumulator->Add("], function #%u ('%s'), pc=%p (+0x%x), pos=%d (+%d)\n",
func_index, func_name, reinterpret_cast<void*>(pc()),
static_cast<int>(pc() - instruction_start), pos,
pos - func_code_offset);
if (mode != OVERVIEW) accumulator->Add("\n");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment