Index: test/inspector/debugger/wasm-stack.js |
diff --git a/test/inspector/debugger/asm-js-stack.js b/test/inspector/debugger/wasm-stack.js |
similarity index 57% |
copy from test/inspector/debugger/asm-js-stack.js |
copy to test/inspector/debugger/wasm-stack.js |
index 37db088ba19a710ee9fcb9652923b138ab7239bd..b443a283f324c5bb02107c89ca41df52425faf4b 100644 |
--- a/test/inspector/debugger/asm-js-stack.js |
+++ b/test/inspector/debugger/wasm-stack.js |
@@ -2,34 +2,49 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-// Flags: --validate-asm |
- |
-function testFunction() { |
- function generateAsmJs(stdlib, foreign, heap) { |
- 'use asm'; |
- var debugger_fun = foreign.call_debugger; |
- function callDebugger() { |
- debugger_fun(); |
- } |
- function redirectFun() { |
- callDebugger(); |
- } |
- return redirectFun; |
- } |
+// 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("main", kSig_v_v) |
+ .addBody([kExprCallFunction, imported_idx]) |
+ .index; |
+builder.addFunction("main", kSig_v_v) |
+ .addBody([kExprCallFunction, call_imported_idx]) |
+ .exportAs("main"); |
+ |
+var module_bytes = builder.toArray(); |
+ |
+function testFunction(bytes) { |
function call_debugger() { |
debugger; |
} |
- var fun = generateAsmJs(this, {'call_debugger': call_debugger}, undefined); |
- fun(); |
+ 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()); |
Protocol.Debugger.enable(); |
-Protocol.Debugger.oncePaused().then(handleDebuggerPaused); |
-Protocol.Runtime.evaluate({'expression': 'testFunction()'}); |
+Protocol.Debugger.onPaused(handleDebuggerPaused); |
+InspectorTest.log('Running testFunction with generated WASM bytes...'); |
+Protocol.Runtime.evaluate( |
+ {'expression': 'testFunction(' + JSON.stringify(module_bytes) + ')'}); |
function locationToString(callFrame) { |
var res = {functionName: callFrame.functionName}; |
@@ -61,7 +76,7 @@ function handleDebuggerPaused(messageObject) |
Protocol.Debugger |
.evaluateOnCallFrame({ |
callFrameId: topFrameId, |
- expression: '(new Error("getting stack trace")).stack' |
+ expression: '(new Error("this is your stack trace:")).stack' |
}) |
.then(callbackEvaluate); |
} |
@@ -70,9 +85,9 @@ function callbackEvaluate(response) |
{ |
InspectorTest.log( |
'Result of evaluate (' + response.result.result.type + '):'); |
- var result_lines = response.result.result.value.split("\n"); |
+ var result_lines = response.result.result.value.split('\n'); |
// Skip the second line, containing the 'evaluate' position. |
- result_lines[1] = " -- skipped --"; |
+ result_lines[1] = ' -- skipped --'; |
InspectorTest.log(result_lines.join('\n')); |
InspectorTest.log('Finished!'); |
InspectorTest.completeTest(); |