Chromium Code Reviews| Index: test/inspector/debugger/wasm-source.js |
| diff --git a/test/inspector/debugger/wasm-source.js b/test/inspector/debugger/wasm-source.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bc5a9648146e8ac41b94cd467ad769e92dde7059 |
| --- /dev/null |
| +++ b/test/inspector/debugger/wasm-source.js |
| @@ -0,0 +1,79 @@ |
| +// Copyright 2016 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 |
| + |
| +load('test/mjsunit/wasm/wasm-constants.js'); |
| +load('test/mjsunit/wasm/wasm-module-builder.js'); |
| + |
| +var builder = new WasmModuleBuilder(); |
| + |
| +var imported_idx = builder.addImport("func", kSig_v_v); |
| + |
| +var call_imported_idx = builder.addFunction("call_func", kSig_v_v) |
| + .addBody([kExprCallFunction, imported_idx]) |
| + .index; |
| + |
| +var sig_index = builder.addType(kSig_v_v); |
| + |
| +builder.addFunction('main', kSig_v_v) |
| + .addBody([ |
| + kExprBlock, kAstStmt, kExprI32Const, 0, kExprCallIndirect, sig_index, |
| + kTableZero, kExprEnd |
| + ]) |
| + .exportAs('main'); |
| + |
| +builder.appendToTable([call_imported_idx]); |
| + |
| +var module_bytes = builder.toArray(); |
| + |
| +function testFunction(bytes) { |
| + function call_debugger() { |
| + debugger; |
| + } |
| + |
| + var buffer = new ArrayBuffer(bytes.length); |
| + var view = new Uint8Array(buffer); |
| + for (var i = 0; i < bytes.length; i++) { |
| + view[i] = bytes[i] | 0; |
| + } |
| + |
| + var module = new WebAssembly.Module(buffer); |
| + var instance = new WebAssembly.Instance(module, {func: call_debugger}); |
| + |
| + instance.exports.main(); |
| +} |
| + |
| +InspectorTest.addScript(testFunction.toString()); |
| +InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); |
| + |
| +Protocol.Debugger.enable(); |
| +Protocol.Debugger.onPaused(handleDebuggerPaused); |
| +InspectorTest.log('Check that inspector gets disassembled wasm code'); |
| +Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'}); |
| + |
| +function handleDebuggerPaused(messageObject) |
| +{ |
| + InspectorTest.log('Paused on debugger!'); |
| + var frames = messageObject.params.callFrames; |
| + InspectorTest.log('Number of frames: ' + frames.length); |
| + function next(frame_id) { |
| + if (frame_id == frames.length) { |
| + InspectorTest.log('Finished.'); |
| + InspectorTest.completeTest(); |
| + } |
| + Protocol.Debugger |
| + .getScriptSource({scriptId: frames[frame_id].location.scriptId}) |
| + .then((sourceMessage) => { |
|
kozy
2016/11/15 23:10:53
Please extract this arrow function to real one, we
Clemens Hammacher
2016/11/16 11:58:01
Thanks, that looks much nicer indeed. I have to wo
|
| + if (sourceMessage.error) |
| + InspectorTest.logObject(sourceMessage); |
| + var text = sourceMessage.result.scriptSource; |
| + var line_nr = frames[frame_id].location.lineNumber; |
| + var line = text.split('\n')[line_nr]; |
| + InspectorTest.log('[' + frame_id + '] ' + line); |
| + next(frame_id + 1); |
| + }); |
| + } |
| + next(0); |
| +} |