Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(917)

Unified Diff: test/inspector/debugger/wasm-get-breakable-locations.js

Issue 2532433003: [inspector] Split V8DebuggerScript implementation for wasm (Closed)
Patch Set: Refactor a bit Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..2d915864bc2240e1179d0d4b59c56f33b1fada02
--- /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);
+
+builder.addFunction("main", kSig_v_i)
+ .addBody([
+ // @1
+ kExprNop,
+ // @2
+ kExprGetLocal, 0,
+ // @4
+ kExprIf, kAstStmt,
+ // @6
+ kExprBlock, kAstStmt,
+ // @8
+ kExprCallFunction, imported_idx,
+ // @10
+ kExprEnd,
+ // @11
+ 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)
+{
+ 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);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698