Index: test/inspector/debugger/wasm-get-breakable-locations.js |
diff --git a/test/inspector/debugger/wasm-get-breakable-locations.js b/test/inspector/debugger/wasm-get-breakable-locations.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9f11c2995473449de37fb8cea78ed1bbda49429c |
--- /dev/null |
+++ b/test/inspector/debugger/wasm-get-breakable-locations.js |
@@ -0,0 +1,76 @@ |
+// 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 func_idx = builder.addFunction('helper', kSig_v_v) |
+ .addLocals({i32_count: 1}) |
+ .addBody([ |
+ kExprNop, |
+ kExprI32Const, 12, |
+ kExprSetLocal, 0, |
+ kExprCallFunction, imported_idx, |
+ ]).index; |
+ |
+builder.addFunction('main', kSig_v_i) |
+ .addBody([ |
+ kExprGetLocal, 0, |
+ kExprIf, kAstStmt, |
+ kExprBlock, kAstStmt, |
+ kExprCallFunction, func_idx, |
+ kExprEnd, |
+ kExprEnd |
+ ]).exportAs('main'); |
+ |
+var module_bytes = builder.toArray(); |
+ |
+function testFunction(bytes) { |
+ function call_debugger() { |
+ // Call to the debugger to trigger wasm translations for all functions on |
+ // the stack. |
+ 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(1); |
+} |
+ |
+InspectorTest.addScript(testFunction.toString()); |
+InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); |
+ |
+Protocol.Debugger.enable(); |
+Protocol.Debugger.onScriptParsed(handleScriptParsed); |
+InspectorTest.log('Running testFunction...'); |
+Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'}); |
+ |
+var numScripts = 0; |
+function handleScriptParsed(messageObject) { |
kozy
2016/11/30 18:34:37
Can we just dump this message object and do nothin
Clemens Hammacher
2016/12/02 17:44:13
Done.
|
+ var scriptId = messageObject.params.scriptId; |
+ var url = messageObject.params.url; |
+ InspectorTest.log('Script nr ' + numScripts + ' parsed. URL: ' + url); |
+ ++numScripts; |
+ |
+ if (url.startsWith('wasm://')) { |
+ InspectorTest.log('This is a wasm script. Requesting breakable locations.'); |
+ Protocol.Debugger |
+ .getPossibleBreakpoints( |
+ {start: {lineNumber: 0, columnNumber: 0, scriptId: scriptId}}) |
+ .then(InspectorTest.logMessage) |
+ .then(InspectorTest.completeTest); |
+ } |
+} |