v8/test/debugger/regress/regress-crbug-840288.js
Eric Leese 6ec6ed9cbe Report real module in addition to fake scripts
Currently the inspector reports Wasm in one of two ways:
 - If there is a source map, report one script per Wasm script, with
   bytecode but no source.
 - If there is no source map, report one script per Wasm function, with
   source (Wasm disassembly) but no bytecode.

With this change, behavior with source map is same, but without source
map it will report both ways. This will allow us to change the frontend
to do its own disassembly, allowing us to remove the per-function scripts
in a future change.

Bug: chromium:1013527
Change-Id: I0c559ad08896e8d0da419e3c6ad8d1edff3976fc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1899782
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Eric Leese <leese@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64980}
2019-11-15 09:59:58 +00:00

28 lines
1005 B
JavaScript

// Copyright 2018 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.
load("test/mjsunit/wasm/wasm-module-builder.js");
Debug = debug.Debug
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.AfterCompile) {
// The actual source doesn't matter, just don't crash.
var source = event_data.script().source();
// Source will be empty for the script representing the entire module,
// disassembly for the script representing just the function.
assertTrue(source == "func $main\nend\n" || source == "");
}
};
// Add the debug event listener.
Debug.setListener(listener);
var builder = new WasmModuleBuilder();
builder.addFunction('main', kSig_v_v).addBody([]).exportFunc();
var promise = WebAssembly.compile(builder.toBuffer());
// Clear the debug listener only after the event fired.
promise.then(() => Debug.setListener(null), assertUnreachable);