Chromium Code Reviews| 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 --expose-debug-as debug | |
| 6 | |
| 7 load("test/mjsunit/wasm/wasm-constants.js"); | |
| 8 load("test/mjsunit/wasm/wasm-module-builder.js"); | |
| 9 | |
| 10 Debug = debug.Debug | |
| 11 | |
| 12 var exception = null; | |
| 13 var break_count = 0; | |
| 14 | |
| 15 const expected_num_frames = 5; | |
| 16 const expected_wasm_frames = [false, true, true, false, false]; | |
| 17 const expected_wasm_positions = [0, 1, 2, 0, 0]; | |
| 18 const expected_function_names = ["call_debugger", "wasm_2", "wasm_1", "testFrame Inspection", ""]; | |
| 19 | |
| 20 function listener(event, exec_state, event_data, data) { | |
| 21 if (event != Debug.DebugEvent.Break) return; | |
| 22 ++break_count; | |
| 23 try { | |
| 24 var break_id = exec_state.break_id; | |
| 25 var frame_count = exec_state.frameCount(); | |
| 26 assertEquals(expected_num_frames, frame_count); | |
| 27 | |
| 28 for (var i = 0; i < frame_count; ++i) { | |
| 29 var frame = exec_state.frame(i); | |
| 30 assertEquals(expected_wasm_frames[i], !frame.func().resolved()); | |
| 31 var wasm_script = null; | |
| 32 if (expected_wasm_frames[i]) { | |
| 33 var script = frame.details().script(); | |
| 34 assertNotNull(script); | |
| 35 if (wasm_script === null) wasm_script = script; | |
|
ahaas
2016/06/17 07:25:44
what's the purpose of this if?
Clemens Hammacher
2016/06/17 14:01:46
You are right, it's pointless :)
I removed it.
| |
| 36 assertEquals(wasm_script, script); | |
| 37 assertEquals(expected_wasm_positions[i], frame.details().sourcePosition( )); | |
| 38 var loc = script.locationFromPosition(frame.details().sourcePosition()); | |
| 39 assertEquals(expected_wasm_positions[i], loc.column); | |
| 40 assertEquals(expected_wasm_positions[i], loc.position); | |
| 41 } | |
| 42 assertEquals(expected_function_names[i], frame.func().name()); | |
| 43 } | |
| 44 } catch (e) { | |
| 45 exception = e; | |
| 46 } | |
| 47 }; | |
| 48 | |
| 49 var builder = new WasmModuleBuilder(); | |
| 50 | |
| 51 // wasm_1 calls wasm_2 on offset 2. | |
| 52 // wasm_2 calls call_debugger on offset 1. | |
| 53 | |
| 54 builder.addImport("func", kSig_v_v); | |
| 55 | |
| 56 builder.addFunction("wasm_1", kSig_v_v) | |
| 57 .addBody([kExprNop, kExprCallFunction, kArity0, 1]) | |
| 58 .exportAs("main"); | |
| 59 | |
| 60 builder.addFunction("wasm_2", kSig_v_v) | |
| 61 .addBody([kExprCallImport, kArity0, 0]); | |
| 62 | |
| 63 function call_debugger() { | |
| 64 debugger; | |
| 65 } | |
| 66 | |
| 67 var module = builder.instantiate({func: call_debugger}); | |
| 68 | |
| 69 (function testFrameInspection() { | |
| 70 Debug.setListener(listener); | |
| 71 module.exports.main(); | |
| 72 Debug.setListener(null); | |
| 73 | |
| 74 assertEquals(1, break_count); | |
| 75 if (exception) throw exception; | |
| 76 })(); | |
| OLD | NEW |