Commit 96062c04 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Use spec'ed location format

This CL changes the printed wasm locations to use the spec'ed format
(see https://github.com/WebAssembly/design/blob/master/Web.md#developer-facing-display-conventions).

Before: <WASM[<id>]+<offset>
After:  wasm-function[<id>]:<offset>

R=ahaas@chromium.org

Change-Id: If8018012b518143d6353f5a1f5319764ee46f148
Reviewed-on: https://chromium-review.googlesource.com/529104Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45820}
parent 2b9e36e9
......@@ -1422,10 +1422,11 @@ void Shell::ReportException(Isolate* isolate, v8::TryCatch* try_catch) {
// print the exception.
printf("%s\n", exception_string);
} else if (message->GetScriptOrigin().Options().IsWasm()) {
// Print <WASM>[(function index)]((function name))+(offset): (message).
// Print wasm-function[(function index)]:(offset): (message).
int function_index = message->GetLineNumber(context).FromJust() - 1;
int offset = message->GetStartColumn(context).FromJust();
printf("<WASM>[%d]+%d: %s\n", function_index, offset, exception_string);
printf("wasm-function[%d]:%d: %s\n", function_index, offset,
exception_string);
} else {
// Print (filename):(line number): (message).
v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName());
......
......@@ -675,24 +675,21 @@ MaybeHandle<String> WasmStackFrame::ToString() {
IncrementalStringBuilder builder(isolate_);
Handle<Object> name = GetFunctionName();
if (name->IsNull(isolate_)) {
builder.AppendCString("<WASM UNNAMED>");
} else {
DCHECK(name->IsString());
if (!name->IsNull(isolate_)) {
builder.AppendString(Handle<String>::cast(name));
builder.AppendCString(" (");
}
builder.AppendCString(" (<WASM>[");
builder.AppendCString("wasm-function[");
char buffer[16];
SNPrintF(ArrayVector(buffer), "%u", wasm_func_index_);
SNPrintF(ArrayVector(buffer), "%u]", wasm_func_index_);
builder.AppendCString(buffer);
builder.AppendCString("]+");
SNPrintF(ArrayVector(buffer), "%d", GetPosition());
SNPrintF(ArrayVector(buffer), ":%d", GetPosition());
builder.AppendCString(buffer);
builder.AppendCString(")");
if (!name->IsNull(isolate_)) builder.AppendCString(")");
return builder.Finish();
}
......
......@@ -18,8 +18,8 @@ end
Getting current stack trace via "new Error().stack".
Error
at v8://test/getStack:1:1
at func (<WASM>[0]+1)
at main (<WASM>[1]+1)
at func (wasm-function[0]:1)
at main (wasm-function[1]:1)
at v8://test/runWasm:1:22
exports.main returned.
Finished.
......@@ -12,8 +12,8 @@ Result of evaluate (string):
Error: this is your stack trace:
-- skipped --
at call_debugger (<anonymous>:3:5)
at call_func (<WASM>[1]+1)
at main (<WASM>[2]+3)
at call_func (wasm-function[1]:1)
at main (wasm-function[2]:3)
at testFunction (<anonymous>:15:20)
at <anonymous>:1:1
Finished!
<WASM>[0]+5: RuntimeError: divide by zero
wasm-function[0]:5: RuntimeError: divide by zero
RuntimeError: divide by zero
at main (<WASM>[0]+5)
at main (wasm-function[0]:5)
at *%(basename)s:15:16
......@@ -39,7 +39,7 @@ function checkStack(stack, expected_lines) {
checkStack(stripPath(stack), [
'Error: test imported stack', // -
/^ at func \(interpreter.js:\d+:28\)$/, // -
' at main (<WASM>[1]+1)', // -
' at main (wasm-function[1]:1)', // -
/^ at testCallImported \(interpreter.js:\d+:22\)$/, // -
/^ at interpreter.js:\d+:3$/
]);
......@@ -101,8 +101,8 @@ function checkStack(stack, expected_lines) {
assertEquals(interpreted_before + 2, %WasmNumInterpretedCalls(instance));
checkStack(stripPath(stack), [
'RuntimeError: unreachable', // -
' at foo (<WASM>[0]+3)', // -
' at main (<WASM>[1]+2)', // -
' at foo (wasm-function[0]:3)', // -
' at main (wasm-function[1]:2)', // -
/^ at testTrap \(interpreter.js:\d+:24\)$/, // -
/^ at interpreter.js:\d+:3$/
]);
......@@ -133,7 +133,7 @@ function checkStack(stack, expected_lines) {
checkStack(stripPath(stack), [
'Error: thrown from imported function', // -
/^ at func \(interpreter.js:\d+:11\)$/, // -
' at main (<WASM>[1]+1)', // -
' at main (wasm-function[1]:1)', // -
/^ at testThrowFromImport \(interpreter.js:\d+:24\)$/, // -
/^ at interpreter.js:\d+:3$/
]);
......@@ -213,10 +213,10 @@ function checkStack(stack, expected_lines) {
for (var e = 0; e < stacks.length; ++e) {
expected = ['Error: reentrant interpreter test #' + e];
expected.push(/^ at func \(interpreter.js:\d+:17\)$/);
expected.push(' at main (<WASM>[1]+3)');
expected.push(' at main (wasm-function[1]:3)');
for (var k = e; k > 0; --k) {
expected.push(/^ at func \(interpreter.js:\d+:33\)$/);
expected.push(' at main (<WASM>[1]+3)');
expected.push(' at main (wasm-function[1]:3)');
}
expected.push(
/^ at testReentrantInterpreter \(interpreter.js:\d+:22\)$/);
......@@ -289,8 +289,8 @@ function checkStack(stack, expected_lines) {
if (!(e instanceof TypeError)) throw e;
checkStack(stripPath(e.stack), [
'TypeError: invalid type', // -
' at direct (<WASM>[1]+1)', // -
' at main (<WASM>[3]+3)', // -
' at direct (wasm-function[1]:1)', // -
' at main (wasm-function[3]:3)', // -
/^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // -
/^ at interpreter.js:\d+:3$/
]);
......@@ -302,8 +302,8 @@ function checkStack(stack, expected_lines) {
if (!(e instanceof TypeError)) throw e;
checkStack(stripPath(e.stack), [
'TypeError: invalid type', // -
' at indirect (<WASM>[2]+1)', // -
' at main (<WASM>[3]+3)', // -
' at indirect (wasm-function[2]:1)', // -
' at main (wasm-function[3]:3)', // -
/^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // -
/^ at interpreter.js:\d+:3$/
]);
......@@ -325,8 +325,8 @@ function checkStack(stack, expected_lines) {
if (!(e instanceof RangeError)) throw e;
checkStack(stripPath(e.stack), [
'RangeError: Maximum call stack size exceeded',
' at main (<WASM>[0]+0)'
].concat(Array(9).fill(' at main (<WASM>[0]+2)')));
' at main (wasm-function[0]:0)'
].concat(Array(9).fill(' at main (wasm-function[0]:2)')));
}
})();
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// clang-format off
// Flags: --expose-wasm
load("test/mjsunit/wasm/wasm-constants.js");
......@@ -25,8 +24,8 @@ function verifyStack(frames, expected) {
assertContains(exp[4], frames[i].getFileName(), "["+i+"].getFileName()");
var toString;
if (exp[0]) {
var fun_str = exp[1] !== null ? exp[1] : "<WASM UNNAMED>";
toString = fun_str + " (<WASM>[" + exp[2] + "]+" + exp[3] + ")";
toString = "wasm-function[" + exp[2] + "]:" + exp[3];
if (exp[1] !== null) toString = exp[1] + " (" + toString + ")";
} else {
toString = exp[4] + ":" + exp[2] + ":";
}
......@@ -69,12 +68,12 @@ builder.addFunction("call_mem_out_of_bounds", kSig_i_v)
var module = builder.instantiate({mod: {func: STACK}});
(function testSimpleStack() {
var expected_string = "Error\n" +
var expected_string = 'Error\n' +
// The line numbers below will change as this test gains / loses lines..
" at STACK (stack.js:40:11)\n" + // --
" at main (<WASM>[1]+1)\n" + // --
" at testSimpleStack (stack.js:79:18)\n" + // --
" at stack.js:81:3"; // --
' at STACK (stack.js:39:11)\n' + // --
' at main (wasm-function[1]:1)\n' + // --
' at testSimpleStack (stack.js:78:18)\n' + // --
' at stack.js:80:3'; // --
module.exports.main();
assertEquals(expected_string, stripPath(stack));
......@@ -91,10 +90,10 @@ Error.prepareStackTrace = function(error, frames) {
verifyStack(stack, [
// isWasm function line pos file
[ false, "STACK", 40, 0, "stack.js"],
[ false, "STACK", 39, 0, "stack.js"],
[ true, "main", 1, 1, null],
[ false, "testStackFrames", 90, 0, "stack.js"],
[ false, null, 99, 0, "stack.js"]
[ false, "testStackFrames", 89, 0, "stack.js"],
[ false, null, 98, 0, "stack.js"]
]);
})();
......@@ -107,8 +106,8 @@ Error.prepareStackTrace = function(error, frames) {
verifyStack(e.stack, [
// isWasm function line pos file
[ true, "exec_unreachable", 2, 1, null],
[ false, "testWasmUnreachable", 103, 0, "stack.js"],
[ false, null, 114, 0, "stack.js"]
[ false, "testWasmUnreachable", 102, 0, "stack.js"],
[ false, null, 113, 0, "stack.js"]
]);
}
})();
......@@ -123,8 +122,8 @@ Error.prepareStackTrace = function(error, frames) {
// isWasm function line pos file
[ true, null, 3, 3, null],
[ true, "call_mem_out_of_bounds", 4, 1, null],
[ false, "testWasmMemOutOfBounds", 118, 0, "stack.js"],
[ false, null, 130, 0, "stack.js"]
[ false, "testWasmMemOutOfBounds", 117, 0, "stack.js"],
[ false, null, 129, 0, "stack.js"]
]);
}
})();
......
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