OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --expose-wasm | |
6 | |
7 load('test/mjsunit/wasm/wasm-constants.js'); | |
8 load('test/mjsunit/wasm/wasm-module-builder.js'); | |
9 | |
10 var builder = new WasmModuleBuilder(); | |
11 | |
12 var imported_idx = builder.addImport("func", kSig_v_v); | |
13 | |
14 var call_imported_idx = builder.addFunction("call_func", kSig_v_v) | |
15 .addBody([kExprCallFunction, imported_idx]) | |
16 .index; | |
17 | |
18 var sig_index = builder.addType(kSig_v_v); | |
19 | |
20 builder.addFunction('main', kSig_v_v) | |
21 .addBody([ | |
22 kExprBlock, kAstStmt, kExprI32Const, 0, kExprCallIndirect, sig_index, | |
23 kTableZero, kExprEnd | |
24 ]) | |
25 .exportAs('main'); | |
26 | |
27 builder.appendToTable([call_imported_idx]); | |
28 | |
29 var module_bytes = builder.toArray(); | |
30 | |
31 function testFunction(bytes) { | |
32 function call_debugger() { | |
33 debugger; | |
34 } | |
35 | |
36 var buffer = new ArrayBuffer(bytes.length); | |
37 var view = new Uint8Array(buffer); | |
38 for (var i = 0; i < bytes.length; i++) { | |
39 view[i] = bytes[i] | 0; | |
40 } | |
41 | |
42 var module = new WebAssembly.Module(buffer); | |
43 var instance = new WebAssembly.Instance(module, {func: call_debugger}); | |
44 | |
45 instance.exports.main(); | |
46 } | |
47 | |
48 InspectorTest.addScript(testFunction.toString()); | |
49 InspectorTest.addScript('var module_bytes = ' + JSON.stringify(module_bytes)); | |
50 | |
51 Protocol.Debugger.enable(); | |
52 Protocol.Debugger.onPaused(handleDebuggerPaused); | |
53 InspectorTest.log('Check that inspector gets disassembled wasm code'); | |
54 Protocol.Runtime.evaluate({'expression': 'testFunction(module_bytes)'}); | |
55 | |
56 function handleDebuggerPaused(messageObject) | |
57 { | |
58 InspectorTest.log('Paused on debugger!'); | |
59 var frames = messageObject.params.callFrames; | |
60 InspectorTest.log('Number of frames: ' + frames.length); | |
61 function next(frame_id) { | |
62 if (frame_id == frames.length) { | |
63 InspectorTest.log('Finished.'); | |
64 InspectorTest.completeTest(); | |
65 } | |
66 Protocol.Debugger | |
67 .getScriptSource({scriptId: frames[frame_id].location.scriptId}) | |
68 .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
| |
69 if (sourceMessage.error) | |
70 InspectorTest.logObject(sourceMessage); | |
71 var text = sourceMessage.result.scriptSource; | |
72 var line_nr = frames[frame_id].location.lineNumber; | |
73 var line = text.split('\n')[line_nr]; | |
74 InspectorTest.log('[' + frame_id + '] ' + line); | |
75 next(frame_id + 1); | |
76 }); | |
77 } | |
78 next(0); | |
79 } | |
OLD | NEW |