Commit b50dea24 authored by Z Nguyen-Huu's avatar Z Nguyen-Huu Committed by Commit Bot

[wasm] Report module name if available

Currently, when debugging wasm, the internal script URL is shown, which
has the form wasm://wasm/wasm-<hex-script-id>. With this change, if the
module specifies a module name, it would report the URL as
wasm://wasm/<module-name>-<hex-script-id>, as this will help the user
identify what they are debugging.

Bug: chromium:1017678
Change-Id: I26ff6249bd1e832d62402619a68b61c115c24640
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1888810
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64703}
parent d71c1ddc
......@@ -1509,8 +1509,8 @@ void AsyncCompileJob::PrepareRuntimeObjects() {
// Create heap objects for script and module bytes to be stored in the
// module object. Asm.js is not compiled asynchronously.
const WasmModule* module = native_module_->module();
Handle<Script> script =
CreateWasmScript(isolate_, wire_bytes_, module->source_map_url);
Handle<Script> script = CreateWasmScript(
isolate_, wire_bytes_, module->source_map_url, module->name);
Handle<WasmModuleObject> module_object =
WasmModuleObject::New(isolate_, native_module_, script);
......@@ -2673,7 +2673,8 @@ WasmCode* CompileImportWrapper(
Handle<Script> CreateWasmScript(Isolate* isolate,
const ModuleWireBytes& wire_bytes,
const std::string& source_map_url) {
const std::string& source_map_url,
WireBytesRef name) {
Handle<Script> script =
isolate->factory()->NewScript(isolate->factory()->empty_string());
script->set_context_data(isolate->native_context()->debug_context_id());
......@@ -2689,14 +2690,34 @@ Handle<Script> CreateWasmScript(Isolate* isolate,
Handle<String> url_prefix =
isolate->factory()->InternalizeString(StaticCharVector("wasm://wasm/"));
int name_chars = SNPrintF(ArrayVector(buffer), "wasm-%08x", hash);
DCHECK(name_chars >= 0 && name_chars < kBufferSize);
Handle<String> name_str =
isolate->factory()
->NewStringFromOneByte(
VectorOf(reinterpret_cast<uint8_t*>(buffer), name_chars),
AllocationType::kOld)
.ToHandleChecked();
// Script name is "<module_name>-hash" if name is available and "hash"
// otherwise.
Handle<String> name_str;
if (name.is_set()) {
int name_chars = SNPrintF(ArrayVector(buffer), "-%08x", hash);
DCHECK(name_chars >= 0 && name_chars < kBufferSize);
Handle<String> name_hash =
isolate->factory()
->NewStringFromOneByte(
VectorOf(reinterpret_cast<uint8_t*>(buffer), name_chars),
AllocationType::kOld)
.ToHandleChecked();
Handle<String> module_name =
WasmModuleObject::ExtractUtf8StringFromModuleBytes(
isolate, wire_bytes.module_bytes(), name)
.ToHandleChecked();
name_str = isolate->factory()
->NewConsString(module_name, name_hash)
.ToHandleChecked();
} else {
int name_chars = SNPrintF(ArrayVector(buffer), "%08x", hash);
DCHECK(name_chars >= 0 && name_chars < kBufferSize);
name_str = isolate->factory()
->NewStringFromOneByte(
VectorOf(reinterpret_cast<uint8_t*>(buffer), name_chars),
AllocationType::kOld)
.ToHandleChecked();
}
script->set_name(*name_str);
MaybeHandle<String> url_str =
isolate->factory()->NewConsString(url_prefix, name_str);
......
......@@ -59,7 +59,7 @@ WasmCode* CompileImportWrapper(
V8_EXPORT_PRIVATE Handle<Script> CreateWasmScript(
Isolate* isolate, const ModuleWireBytes& wire_bytes,
const std::string& source_map_url);
const std::string& source_map_url, WireBytesRef name);
// Triggered by the WasmCompileLazy builtin. The return value indicates whether
// compilation was successful. Lazy compilation can fail only if validation is
......
......@@ -966,7 +966,9 @@ class ModuleDecoderImpl : public Decoder {
// Function and local names will be decoded when needed.
if (name_type == NameSectionKindCode::kModule) {
WireBytesRef name = consume_string(&inner, false, "module name");
if (inner.ok() && validate_utf8(&inner, name)) module_->name = name;
if (inner.ok() && validate_utf8(&inner, name)) {
module_->name = name;
}
} else {
inner.consume_bytes(name_payload_len, "name subsection payload");
}
......
......@@ -303,7 +303,8 @@ MaybeHandle<WasmModuleObject> WasmEngine::SyncCompile(
if (!native_module) return {};
Handle<Script> script =
CreateWasmScript(isolate, bytes, native_module->module()->source_map_url);
CreateWasmScript(isolate, bytes, native_module->module()->source_map_url,
native_module->module()->name);
// Create the module object.
// TODO(clemensb): For the same module (same bytes / same hash), we should
......@@ -442,7 +443,8 @@ Handle<WasmModuleObject> WasmEngine::ImportNativeModule(
NativeModule* native_module = shared_native_module.get();
ModuleWireBytes wire_bytes(native_module->wire_bytes());
Handle<Script> script = CreateWasmScript(
isolate, wire_bytes, native_module->module()->source_map_url);
isolate, wire_bytes, native_module->module()->source_map_url,
native_module->module()->name);
Handle<FixedArray> export_wrappers;
CompileJsToWasmWrappers(isolate, native_module->module(), &export_wrappers);
Handle<WasmModuleObject> module_object = WasmModuleObject::New(
......
......@@ -616,8 +616,8 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule(
if (decode_result.failed()) return {};
CHECK_NOT_NULL(decode_result.value());
WasmModule* module = decode_result.value().get();
Handle<Script> script =
CreateWasmScript(isolate, wire_bytes, module->source_map_url);
Handle<Script> script = CreateWasmScript(
isolate, wire_bytes, module->source_map_url, module->name);
auto shared_native_module = isolate->wasm_engine()->NewNativeModule(
isolate, enabled_features, std::move(decode_result.value()));
......
Tests that cloning a module notifies the debugger
Got URL: wasm://wasm/wasm-95d1e44e/wasm-95d1e44e-0
Got URL: wasm://wasm/wasm-95d1e44e/wasm-95d1e44e-0
Got URL: wasm://wasm/wasm-95d1e44e/wasm-95d1e44e-0
Got URL: wasm://wasm/95d1e44e/95d1e44e-0
Got URL: wasm://wasm/95d1e44e/95d1e44e-0
Got URL: wasm://wasm/95d1e44e/95d1e44e-0
Done!
......@@ -2,9 +2,9 @@ Tests breakable locations in wasm
Running testFunction...
Script nr 0 parsed. URL: v8://test/setup
Script nr 1 parsed. URL: v8://test/runTestFunction
Script nr 2 parsed. URL: wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-0
Script nr 2 parsed. URL: wasm://wasm/6a95b41e/6a95b41e-0
This is a wasm script (nr 0).
Script nr 3 parsed. URL: wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1
Script nr 3 parsed. URL: wasm://wasm/6a95b41e/6a95b41e-1
This is a wasm script (nr 1).
Querying breakable locations for all wasm scripts now...
Requesting all breakable locations in wasm script 0
......@@ -38,51 +38,51 @@ Requesting breakable locations in lines [4,6)
[0] 4:6 || >call 0
[1] 5:4 || >end
Setting a breakpoint on each breakable location...
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-0:2:2
Setting at wasm://wasm/6a95b41e/6a95b41e-0:2:2
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-0:3:2
Setting at wasm://wasm/6a95b41e/6a95b41e-0:3:2
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-0:4:2
Setting at wasm://wasm/6a95b41e/6a95b41e-0:4:2
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-0:5:0
Setting at wasm://wasm/6a95b41e/6a95b41e-0:5:0
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:1:2
Setting at wasm://wasm/6a95b41e/6a95b41e-1:1:2
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:2:2
Setting at wasm://wasm/6a95b41e/6a95b41e-1:2:2
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:3:4
Setting at wasm://wasm/6a95b41e/6a95b41e-1:3:4
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:4:6
Setting at wasm://wasm/6a95b41e/6a95b41e-1:4:6
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:5:4
Setting at wasm://wasm/6a95b41e/6a95b41e-1:5:4
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:6:2
Setting at wasm://wasm/6a95b41e/6a95b41e-1:6:2
Success!
Setting at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:7:0
Setting at wasm://wasm/6a95b41e/6a95b41e-1:7:0
Success!
Running wasm code...
Missing breakpoints: 11
Script nr 4 parsed. URL: v8://test/runWasm
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:1:2
Stopped at wasm://wasm/6a95b41e/6a95b41e-1:1:2
Missing breakpoints: 10
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:2:2
Stopped at wasm://wasm/6a95b41e/6a95b41e-1:2:2
Missing breakpoints: 9
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:3:4
Stopped at wasm://wasm/6a95b41e/6a95b41e-1:3:4
Missing breakpoints: 8
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:4:6
Stopped at wasm://wasm/6a95b41e/6a95b41e-1:4:6
Missing breakpoints: 7
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-0:2:2
Stopped at wasm://wasm/6a95b41e/6a95b41e-0:2:2
Missing breakpoints: 6
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-0:3:2
Stopped at wasm://wasm/6a95b41e/6a95b41e-0:3:2
Missing breakpoints: 5
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-0:4:2
Stopped at wasm://wasm/6a95b41e/6a95b41e-0:4:2
Missing breakpoints: 4
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-0:5:0
Stopped at wasm://wasm/6a95b41e/6a95b41e-0:5:0
Missing breakpoints: 3
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:5:4
Stopped at wasm://wasm/6a95b41e/6a95b41e-1:5:4
Missing breakpoints: 2
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:6:2
Stopped at wasm://wasm/6a95b41e/6a95b41e-1:6:2
Missing breakpoints: 1
Stopped at wasm://wasm/wasm-6a95b41e/wasm-6a95b41e-1:7:0
Stopped at wasm://wasm/6a95b41e/6a95b41e-1:7:0
Missing breakpoints: 0
Finished!
Tests how wasm scripts are reported
Check that each inspector gets two wasm scripts at module creation time.
Session #1: Script #0 parsed. URL: wasm://wasm/wasm-f608ae1e/wasm-f608ae1e-0. Source map URL:
Session #1: Script #1 parsed. URL: wasm://wasm/wasm-f608ae1e/wasm-f608ae1e-1. Source map URL:
Session #2: Script #0 parsed. URL: wasm://wasm/wasm-f608ae1e/wasm-f608ae1e-0. Source map URL:
Session #2: Script #1 parsed. URL: wasm://wasm/wasm-f608ae1e/wasm-f608ae1e-1. Source map URL:
Session #1: Script #2 parsed. URL: wasm://wasm/wasm-74f86b7e. Source map URL: wasm://dwarf
Session #2: Script #2 parsed. URL: wasm://wasm/wasm-74f86b7e. Source map URL: wasm://dwarf
Session #1: Script #3 parsed. URL: wasm://wasm/wasm-3754e3fe. Source map URL: abc
Session #2: Script #3 parsed. URL: wasm://wasm/wasm-3754e3fe. Source map URL: abc
Session #1: Script #4 parsed. URL: wasm://wasm/wasm-2bd2e40e. Source map URL: abc
Session #2: Script #4 parsed. URL: wasm://wasm/wasm-2bd2e40e. Source map URL: abc
Session #1: Script #5 parsed. URL: wasm://wasm/wasm-f568e726. Source map URL: abc
Session #2: Script #5 parsed. URL: wasm://wasm/wasm-f568e726. Source map URL: abc
Session #1: Source for wasm://wasm/wasm-f608ae1e/wasm-f608ae1e-0:
Session #1: Script #0 parsed. URL: wasm://wasm/f608ae1e/f608ae1e-0. Source map URL:
Session #1: Script #1 parsed. URL: wasm://wasm/f608ae1e/f608ae1e-1. Source map URL:
Session #2: Script #0 parsed. URL: wasm://wasm/f608ae1e/f608ae1e-0. Source map URL:
Session #2: Script #1 parsed. URL: wasm://wasm/f608ae1e/f608ae1e-1. Source map URL:
Session #1: Script #2 parsed. URL: wasm://wasm/74f86b7e. Source map URL: wasm://dwarf
Session #2: Script #2 parsed. URL: wasm://wasm/74f86b7e. Source map URL: wasm://dwarf
Session #1: Script #3 parsed. URL: wasm://wasm/3754e3fe. Source map URL: abc
Session #2: Script #3 parsed. URL: wasm://wasm/3754e3fe. Source map URL: abc
Session #1: Script #4 parsed. URL: wasm://wasm/2bd2e40e. Source map URL: abc
Session #2: Script #4 parsed. URL: wasm://wasm/2bd2e40e. Source map URL: abc
Session #1: Script #5 parsed. URL: wasm://wasm/f568e726. Source map URL: abc
Session #2: Script #5 parsed. URL: wasm://wasm/f568e726. Source map URL: abc
Session #1: Source for wasm://wasm/f608ae1e/f608ae1e-0:
func $nopFunction
nop
end
Session #1: Source for wasm://wasm/wasm-f608ae1e/wasm-f608ae1e-1:
Session #1: Source for wasm://wasm/f608ae1e/f608ae1e-1:
func $main
block
i32.const 2
......@@ -25,12 +25,12 @@ func $main
end
end
Session #2: Source for wasm://wasm/wasm-f608ae1e/wasm-f608ae1e-0:
Session #2: Source for wasm://wasm/f608ae1e/f608ae1e-0:
func $nopFunction
nop
end
Session #2: Source for wasm://wasm/wasm-f608ae1e/wasm-f608ae1e-1:
Session #2: Source for wasm://wasm/f608ae1e/f608ae1e-1:
func $main
block
i32.const 2
......@@ -38,35 +38,35 @@ func $main
end
end
Session #1: Source for wasm://wasm/wasm-74f86b7e:
Session #1: Source for wasm://wasm/74f86b7e:
Raw: 00 61 73 6d 01 00 00 00 01 07 02 60 00 00 60 00 00 03 03 02 00 01 07 08 01 04 6d 61 69 6e 00 01 0a 0e 02 03 00 01 0b 08 00 02 40 41 02 1a 0b 0b 00 11 0b 2e 64 65 62 75 67 5f 69 6e 66 6f 01 02 03 04 05 00 1b 04 6e 61 6d 65 01 14 02 00 0b 6e 6f 70 46 75 6e 63 74 69 6f 6e 01 04 6d 61 69 6e
Imports: []
Exports: [main: function]
Session #2: Source for wasm://wasm/wasm-74f86b7e:
Session #2: Source for wasm://wasm/74f86b7e:
Raw: 00 61 73 6d 01 00 00 00 01 07 02 60 00 00 60 00 00 03 03 02 00 01 07 08 01 04 6d 61 69 6e 00 01 0a 0e 02 03 00 01 0b 08 00 02 40 41 02 1a 0b 0b 00 11 0b 2e 64 65 62 75 67 5f 69 6e 66 6f 01 02 03 04 05 00 1b 04 6e 61 6d 65 01 14 02 00 0b 6e 6f 70 46 75 6e 63 74 69 6f 6e 01 04 6d 61 69 6e
Imports: []
Exports: [main: function]
Session #1: Source for wasm://wasm/wasm-3754e3fe:
Session #1: Source for wasm://wasm/3754e3fe:
Raw: 00 61 73 6d 01 00 00 00 01 07 02 60 00 00 60 00 00 03 03 02 00 01 07 08 01 04 6d 61 69 6e 00 01 0a 0e 02 03 00 01 0b 08 00 02 40 41 02 1a 0b 0b 00 15 10 73 6f 75 72 63 65 4d 61 70 70 69 6e 67 55 52 4c 03 61 62 63 00 1b 04 6e 61 6d 65 01 14 02 00 0b 6e 6f 70 46 75 6e 63 74 69 6f 6e 01 04 6d 61 69 6e
Imports: []
Exports: [main: function]
Session #2: Source for wasm://wasm/wasm-3754e3fe:
Session #2: Source for wasm://wasm/3754e3fe:
Raw: 00 61 73 6d 01 00 00 00 01 07 02 60 00 00 60 00 00 03 03 02 00 01 07 08 01 04 6d 61 69 6e 00 01 0a 0e 02 03 00 01 0b 08 00 02 40 41 02 1a 0b 0b 00 15 10 73 6f 75 72 63 65 4d 61 70 70 69 6e 67 55 52 4c 03 61 62 63 00 1b 04 6e 61 6d 65 01 14 02 00 0b 6e 6f 70 46 75 6e 63 74 69 6f 6e 01 04 6d 61 69 6e
Imports: []
Exports: [main: function]
Session #1: Source for wasm://wasm/wasm-2bd2e40e:
Session #1: Source for wasm://wasm/2bd2e40e:
Raw: 00 61 73 6d 01 00 00 00 01 07 02 60 00 00 60 00 00 03 03 02 00 01 07 08 01 04 6d 61 69 6e 00 01 0a 0e 02 03 00 01 0b 08 00 02 40 41 02 1a 0b 0b 00 11 0b 2e 64 65 62 75 67 5f 69 6e 66 6f 01 02 03 04 05 00 15 10 73 6f 75 72 63 65 4d 61 70 70 69 6e 67 55 52 4c 03 61 62 63 00 1b 04 6e 61 6d 65 01 14 02 00 0b 6e 6f 70 46 75 6e 63 74 69 6f 6e 01 04 6d 61 69 6e
Imports: []
Exports: [main: function]
Session #2: Source for wasm://wasm/wasm-2bd2e40e:
Session #2: Source for wasm://wasm/2bd2e40e:
Raw: 00 61 73 6d 01 00 00 00 01 07 02 60 00 00 60 00 00 03 03 02 00 01 07 08 01 04 6d 61 69 6e 00 01 0a 0e 02 03 00 01 0b 08 00 02 40 41 02 1a 0b 0b 00 11 0b 2e 64 65 62 75 67 5f 69 6e 66 6f 01 02 03 04 05 00 15 10 73 6f 75 72 63 65 4d 61 70 70 69 6e 67 55 52 4c 03 61 62 63 00 1b 04 6e 61 6d 65 01 14 02 00 0b 6e 6f 70 46 75 6e 63 74 69 6f 6e 01 04 6d 61 69 6e
Imports: []
Exports: [main: function]
Session #1: Source for wasm://wasm/wasm-f568e726:
Session #1: Source for wasm://wasm/f568e726:
Raw: 00 61 73 6d 01 00 00 00 01 07 02 60 00 00 60 00 00 03 03 02 00 01 07 08 01 04 6d 61 69 6e 00 01 0a 0e 02 03 00 01 0b 08 00 02 40 41 02 1a 0b 0b 00 15 10 73 6f 75 72 63 65 4d 61 70 70 69 6e 67 55 52 4c 03 61 62 63 00 11 0b 2e 64 65 62 75 67 5f 69 6e 66 6f 01 02 03 04 05 00 1b 04 6e 61 6d 65 01 14 02 00 0b 6e 6f 70 46 75 6e 63 74 69 6f 6e 01 04 6d 61 69 6e
Imports: []
Exports: [main: function]
Session #2: Source for wasm://wasm/wasm-f568e726:
Session #2: Source for wasm://wasm/f568e726:
Raw: 00 61 73 6d 01 00 00 00 01 07 02 60 00 00 60 00 00 03 03 02 00 01 07 08 01 04 6d 61 69 6e 00 01 0a 0e 02 03 00 01 0b 08 00 02 40 41 02 1a 0b 0b 00 15 10 73 6f 75 72 63 65 4d 61 70 70 69 6e 67 55 52 4c 03 61 62 63 00 11 0b 2e 64 65 62 75 67 5f 69 6e 66 6f 01 02 03 04 05 00 1b 04 6e 61 6d 65 01 14 02 00 0b 6e 6f 70 46 75 6e 63 74 69 6f 6e 01 04 6d 61 69 6e
Imports: []
Exports: [main: function]
Tests how wasm scripts are reported with name
Check that each inspector gets two wasm scripts at module creation time.
Session #1: Script #0 parsed. URL: wasm://wasm/49a8663e/49a8663e-0.
Session #1: Script #1 parsed. URL: wasm://wasm/moduleName-aea4a206/moduleName-aea4a206-0.
Session #1: Source for wasm://wasm/49a8663e/49a8663e-0:
func $nopFunction
nop
end
Session #1: Source for wasm://wasm/moduleName-aea4a206/moduleName-aea4a206-0:
func $nopFunction
nop
end
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-wasm
InspectorTest.log("Tests how wasm scripts are reported with name");
let contextGroup = new InspectorTest.ContextGroup();
let sessions = [
// Main session.
trackScripts(),
];
utils.load('test/mjsunit/wasm/wasm-module-builder.js');
var builder = new WasmModuleBuilder();
builder.addFunction('nopFunction', kSig_v_v).addBody([kExprNop]);
var module_bytes = builder.toArray();
builder.setName('moduleName');
var module_bytes_with_name = builder.toArray();
function testFunction(bytes) {
// Compilation triggers registration of wasm scripts.
new WebAssembly.Module(new Uint8Array(bytes));
}
contextGroup.addScript(testFunction.toString(), 0, 0, 'v8://test/testFunction');
contextGroup.addScript('var module_bytes = ' + JSON.stringify(module_bytes));
contextGroup.addScript('var module_bytes_with_name = ' + JSON.stringify(module_bytes_with_name));
InspectorTest.log(
'Check that each inspector gets two wasm scripts at module creation time.');
sessions[0].Protocol.Runtime
.evaluate({
'expression': '//# sourceURL=v8://test/runTestRunction\n' +
'testFunction(module_bytes); testFunction(module_bytes_with_name);'
})
.then(() => (
// At this point all scripts were parsed.
// Stop tracking and wait for script sources in each session.
Promise.all(sessions.map(session => session.getScripts()))
))
.catch(err => {
InspectorTest.log(err.stack);
})
.then(() => InspectorTest.completeTest());
function trackScripts(debuggerParams) {
let {id: sessionId, Protocol} = contextGroup.connect();
let scripts = [];
Protocol.Debugger.enable(debuggerParams);
Protocol.Debugger.onScriptParsed(handleScriptParsed);
async function loadScript({url, scriptId}) {
InspectorTest.log(`Session #${sessionId}: Script #${scripts.length} parsed. URL: ${url}.`);
let scriptSource;
({result: {scriptSource}} = await Protocol.Debugger.getScriptSource({scriptId}));
InspectorTest.log(`Session #${sessionId}: Source for ${url}:`);
InspectorTest.log(scriptSource);
}
function handleScriptParsed({params}) {
if (params.url.startsWith("wasm://")) {
scripts.push(loadScript(params));
}
}
return {
Protocol,
getScripts: () => Promise.all(scripts),
};
}
Tests stepping through wasm scripts.
Instantiating.
Waiting for two wasm scripts (ignoring first non-wasm script).
Source of script wasm://wasm/wasm-18214bfe/wasm-18214bfe-0:
Source of script wasm://wasm/18214bfe/18214bfe-0:
1: func $wasm_A
2: nop
3: nop
4: end
Source of script wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:
Source of script wasm://wasm/18214bfe/18214bfe-1:
1: func $wasm_B (param i32)
2: loop
3: local.get 0
......@@ -22,12 +22,12 @@ Source of script wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:
12: end
13: end
Setting breakpoint on line 8 on script wasm://wasm/wasm-18214bfe/wasm-18214bfe-1
Setting breakpoint on line 7 on script wasm://wasm/wasm-18214bfe/wasm-18214bfe-1
Setting breakpoint on line 6 on script wasm://wasm/wasm-18214bfe/wasm-18214bfe-1
Setting breakpoint on line 5 on script wasm://wasm/wasm-18214bfe/wasm-18214bfe-1
Setting breakpoint on line 3 on script wasm://wasm/wasm-18214bfe/wasm-18214bfe-1
Setting breakpoint on line 4 on script wasm://wasm/wasm-18214bfe/wasm-18214bfe-1
Setting breakpoint on line 8 on script wasm://wasm/18214bfe/18214bfe-1
Setting breakpoint on line 7 on script wasm://wasm/18214bfe/18214bfe-1
Setting breakpoint on line 6 on script wasm://wasm/18214bfe/18214bfe-1
Setting breakpoint on line 5 on script wasm://wasm/18214bfe/18214bfe-1
Setting breakpoint on line 3 on script wasm://wasm/18214bfe/18214bfe-1
Setting breakpoint on line 4 on script wasm://wasm/18214bfe/18214bfe-1
Calling main(4)
Breaking on line 3
Breaking on line 4
......
......@@ -3,10 +3,10 @@ Installing code an global variable.
Calling instantiate function.
Waiting for two wasm scripts to be parsed.
Ignoring script with url v8://test/callInstantiate
Got wasm script: wasm://wasm/wasm-18214bfe/wasm-18214bfe-0
Requesting source for wasm://wasm/wasm-18214bfe/wasm-18214bfe-0...
Got wasm script: wasm://wasm/wasm-18214bfe/wasm-18214bfe-1
Requesting source for wasm://wasm/wasm-18214bfe/wasm-18214bfe-1...
Got wasm script: wasm://wasm/18214bfe/18214bfe-0
Requesting source for wasm://wasm/18214bfe/18214bfe-0...
Got wasm script: wasm://wasm/18214bfe/18214bfe-1
Requesting source for wasm://wasm/18214bfe/18214bfe-1...
func $wasm_A
nop
nop
......@@ -26,13 +26,13 @@ func $wasm_B (param i32)
end
end
Setting breakpoint on line 7 (on the setlocal before the call), url wasm://wasm/wasm-18214bfe/wasm-18214bfe-1
Setting breakpoint on line 7 (on the setlocal before the call), url wasm://wasm/18214bfe/18214bfe-1
{
columnNumber : 6
lineNumber : 7
scriptId : <scriptId>
}
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:7:6: >local.set 0
Paused at wasm://wasm/18214bfe/18214bfe-1:7:6: >local.set 0
at wasm_B (7:6):
- scope (global):
-- skipped
......@@ -43,7 +43,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:8:6: >call 0
Paused at wasm://wasm/18214bfe/18214bfe-1:8:6: >call 0
at wasm_B (8:6):
- scope (global):
-- skipped
......@@ -54,7 +54,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-0:1:2: >nop
Paused at wasm://wasm/18214bfe/18214bfe-0:1:2: >nop
at wasm_A (1:2):
- scope (global):
-- skipped
......@@ -70,7 +70,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-0:2:2: >nop
Paused at wasm://wasm/18214bfe/18214bfe-0:2:2: >nop
at wasm_A (2:2):
- scope (global):
-- skipped
......@@ -86,7 +86,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:9:6: >br 1
Paused at wasm://wasm/18214bfe/18214bfe-1:9:6: >br 1
at wasm_B (9:6):
- scope (global):
-- skipped
......@@ -97,7 +97,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:7:6: >local.set 0
Paused at wasm://wasm/18214bfe/18214bfe-1:7:6: >local.set 0
at wasm_B (7:6):
- scope (global):
-- skipped
......@@ -108,7 +108,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:8:6: >call 0
Paused at wasm://wasm/18214bfe/18214bfe-1:8:6: >call 0
at wasm_B (8:6):
- scope (global):
-- skipped
......@@ -119,7 +119,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:9:6: >br 1
Paused at wasm://wasm/18214bfe/18214bfe-1:9:6: >br 1
at wasm_B (9:6):
- scope (global):
-- skipped
......@@ -130,7 +130,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.resume called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:7:6: >local.set 0
Paused at wasm://wasm/18214bfe/18214bfe-1:7:6: >local.set 0
at wasm_B (7:6):
- scope (global):
-- skipped
......@@ -141,7 +141,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:8:6: >call 0
Paused at wasm://wasm/18214bfe/18214bfe-1:8:6: >call 0
at wasm_B (8:6):
- scope (global):
-- skipped
......@@ -152,7 +152,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-0:1:2: >nop
Paused at wasm://wasm/18214bfe/18214bfe-0:1:2: >nop
at wasm_A (1:2):
- scope (global):
-- skipped
......@@ -168,7 +168,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:9:6: >br 1
Paused at wasm://wasm/18214bfe/18214bfe-1:9:6: >br 1
at wasm_B (9:6):
- scope (global):
-- skipped
......@@ -179,7 +179,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:1:2: >loop
Paused at wasm://wasm/18214bfe/18214bfe-1:1:2: >loop
at wasm_B (1:2):
- scope (global):
-- skipped
......@@ -190,7 +190,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:2:4: >local.get 0
Paused at wasm://wasm/18214bfe/18214bfe-1:2:4: >local.get 0
at wasm_B (2:4):
- scope (global):
-- skipped
......@@ -201,7 +201,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:3:4: >if
Paused at wasm://wasm/18214bfe/18214bfe-1:3:4: >if
at wasm_B (3:4):
- scope (global):
-- skipped
......@@ -212,7 +212,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:4:6: >local.get 0
Paused at wasm://wasm/18214bfe/18214bfe-1:4:6: >local.get 0
at wasm_B (4:6):
- scope (global):
-- skipped
......@@ -223,7 +223,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:5:6: >i32.const 1
Paused at wasm://wasm/18214bfe/18214bfe-1:5:6: >i32.const 1
at wasm_B (5:6):
- scope (global):
-- skipped
......@@ -234,7 +234,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:6:6: >i32.sub
Paused at wasm://wasm/18214bfe/18214bfe-1:6:6: >i32.sub
at wasm_B (6:6):
- scope (global):
-- skipped
......@@ -245,7 +245,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:7:6: >local.set 0
Paused at wasm://wasm/18214bfe/18214bfe-1:7:6: >local.set 0
at wasm_B (7:6):
- scope (global):
-- skipped
......@@ -256,7 +256,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:8:6: >call 0
Paused at wasm://wasm/18214bfe/18214bfe-1:8:6: >call 0
at wasm_B (8:6):
- scope (global):
-- skipped
......@@ -267,7 +267,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-0:1:2: >nop
Paused at wasm://wasm/18214bfe/18214bfe-0:1:2: >nop
at wasm_A (1:2):
- scope (global):
-- skipped
......@@ -283,7 +283,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-0:2:2: >nop
Paused at wasm://wasm/18214bfe/18214bfe-0:2:2: >nop
at wasm_A (2:2):
- scope (global):
-- skipped
......@@ -299,7 +299,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-0:3:0: >end
Paused at wasm://wasm/18214bfe/18214bfe-0:3:0: >end
at wasm_A (3:0):
- scope (global):
-- skipped
......@@ -315,7 +315,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-18214bfe/wasm-18214bfe-1:9:6: >br 1
Paused at wasm://wasm/18214bfe/18214bfe-1:9:6: >br 1
at wasm_B (9:6):
- scope (global):
-- skipped
......
Tests stepping through wasm scripts with source maps
Installing code an global variable and instantiate.
Got wasm script: wasm://wasm/wasm-3697f0fe
Got wasm script: wasm://wasm/3697f0fe
Script sourceMapURL: abc
Requesting source for wasm://wasm/wasm-3697f0fe...
Requesting source for wasm://wasm/3697f0fe...
Source retrieved without error: true
Setting breakpoint on offset 54 (on the setlocal before the call), url wasm://wasm/wasm-3697f0fe
Setting breakpoint on offset 54 (on the setlocal before the call), url wasm://wasm/3697f0fe
{
columnNumber : 54
lineNumber : 0
scriptId : <scriptId>
}
Paused at wasm://wasm/wasm-3697f0fe:0:54
Paused at wasm://wasm/3697f0fe:0:54
at wasm_B (0:54):
- scope (global):
-- skipped
......@@ -21,7 +21,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:56
Paused at wasm://wasm/3697f0fe:0:56
at wasm_B (0:56):
- scope (global):
-- skipped
......@@ -32,7 +32,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:38
Paused at wasm://wasm/3697f0fe:0:38
at wasm_A (0:38):
- scope (global):
-- skipped
......@@ -48,7 +48,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Paused at wasm://wasm/wasm-3697f0fe:0:39
Paused at wasm://wasm/3697f0fe:0:39
at wasm_A (0:39):
- scope (global):
-- skipped
......@@ -64,7 +64,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Paused at wasm://wasm/wasm-3697f0fe:0:58
Paused at wasm://wasm/3697f0fe:0:58
at wasm_B (0:58):
- scope (global):
-- skipped
......@@ -75,7 +75,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Paused at wasm://wasm/wasm-3697f0fe:0:54
Paused at wasm://wasm/3697f0fe:0:54
at wasm_B (0:54):
- scope (global):
-- skipped
......@@ -86,7 +86,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Paused at wasm://wasm/wasm-3697f0fe:0:56
Paused at wasm://wasm/3697f0fe:0:56
at wasm_B (0:56):
- scope (global):
-- skipped
......@@ -97,7 +97,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOver called
Paused at wasm://wasm/wasm-3697f0fe:0:58
Paused at wasm://wasm/3697f0fe:0:58
at wasm_B (0:58):
- scope (global):
-- skipped
......@@ -108,7 +108,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.resume called
Paused at wasm://wasm/wasm-3697f0fe:0:54
Paused at wasm://wasm/3697f0fe:0:54
at wasm_B (0:54):
- scope (global):
-- skipped
......@@ -119,7 +119,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:56
Paused at wasm://wasm/3697f0fe:0:56
at wasm_B (0:56):
- scope (global):
-- skipped
......@@ -130,7 +130,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:38
Paused at wasm://wasm/3697f0fe:0:38
at wasm_A (0:38):
- scope (global):
-- skipped
......@@ -146,7 +146,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepOut called
Paused at wasm://wasm/wasm-3697f0fe:0:58
Paused at wasm://wasm/3697f0fe:0:58
at wasm_B (0:58):
- scope (global):
-- skipped
......@@ -157,7 +157,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:43
Paused at wasm://wasm/3697f0fe:0:43
at wasm_B (0:43):
- scope (global):
-- skipped
......@@ -168,7 +168,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:45
Paused at wasm://wasm/3697f0fe:0:45
at wasm_B (0:45):
- scope (global):
-- skipped
......@@ -179,7 +179,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:47
Paused at wasm://wasm/3697f0fe:0:47
at wasm_B (0:47):
- scope (global):
-- skipped
......@@ -190,7 +190,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:49
Paused at wasm://wasm/3697f0fe:0:49
at wasm_B (0:49):
- scope (global):
-- skipped
......@@ -201,7 +201,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:51
Paused at wasm://wasm/3697f0fe:0:51
at wasm_B (0:51):
- scope (global):
-- skipped
......@@ -212,7 +212,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:53
Paused at wasm://wasm/3697f0fe:0:53
at wasm_B (0:53):
- scope (global):
-- skipped
......@@ -223,7 +223,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:54
Paused at wasm://wasm/3697f0fe:0:54
at wasm_B (0:54):
- scope (global):
-- skipped
......@@ -234,7 +234,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:56
Paused at wasm://wasm/3697f0fe:0:56
at wasm_B (0:56):
- scope (global):
-- skipped
......@@ -245,7 +245,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:38
Paused at wasm://wasm/3697f0fe:0:38
at wasm_A (0:38):
- scope (global):
-- skipped
......@@ -261,7 +261,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:39
Paused at wasm://wasm/3697f0fe:0:39
at wasm_A (0:39):
- scope (global):
-- skipped
......@@ -277,7 +277,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:40
Paused at wasm://wasm/3697f0fe:0:40
at wasm_A (0:40):
- scope (global):
-- skipped
......@@ -293,7 +293,7 @@ at (anonymous) (0:17):
- scope (global):
-- skipped
Debugger.stepInto called
Paused at wasm://wasm/wasm-3697f0fe:0:58
Paused at wasm://wasm/3697f0fe:0:58
at wasm_B (0:58):
- scope (global):
-- skipped
......
......@@ -2356,6 +2356,14 @@ TEST_F(WasmModuleVerifyTest, MultipleNameSections) {
EXPECT_EQ(3u, result.value()->name.length());
}
TEST_F(WasmModuleVerifyTest, BadNameSection) {
static const byte data[] = {SECTION_NAMES(
0, ADD_COUNT(ADD_COUNT('s', 'r', 'c', '/', 'x', 0xff, 'z', '.', 'c')))};
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_TRUE(result.ok());
EXPECT_EQ(0u, result.value()->name.length());
}
TEST_F(WasmModuleVerifyTest, PassiveDataSegment) {
static const byte data[] = {
// memory declaration ----------------------------------------------------
......
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