| 1 |
// |jit-test| test-also=--wasm-compiler=optimizing; skip-if: !wasmDebuggingEnabled() |
| 2 |
|
| 3 |
// Tests that wasm module scripts raises onEnterFrame and onLeaveFrame events in |
| 4 |
// wasm return calls. |
| 5 |
|
| 6 |
load(libdir + "wasm.js"); |
| 7 |
|
| 8 |
// Checking if enter/leave frame at return_call. |
| 9 |
var onEnterFrameCalled, onLeaveFrameCalled, onStepCalled; |
| 10 |
wasmRunWithDebugger( |
| 11 |
'(module (func) (func (return_call 0)) (func (call 1)) (export "test" (func 2)))', |
| 12 |
undefined, |
| 13 |
function ({dbg}) { |
| 14 |
onEnterFrameCalled = 0; |
| 15 |
onLeaveFrameCalled = 0; |
| 16 |
onStepCalled = []; |
| 17 |
dbg.onEnterFrame = function (frame) { |
| 18 |
if (frame.type != 'wasmcall') return; |
| 19 |
onEnterFrameCalled++; |
| 20 |
frame.onStep = function () { |
| 21 |
onStepCalled.push(frame.offset); |
| 22 |
}; |
| 23 |
frame.onPop = function () { |
| 24 |
onLeaveFrameCalled++; |
| 25 |
}; |
| 26 |
}; |
| 27 |
}, |
| 28 |
function ({error}) { |
| 29 |
assertEq(error, undefined); |
| 30 |
assertEq(onEnterFrameCalled, 3); |
| 31 |
assertEq(onLeaveFrameCalled, 3); |
| 32 |
assertEq(onStepCalled.length, 4); |
| 33 |
assertEq(onStepCalled[0] > 0, true); |
| 34 |
} |
| 35 |
); |
| 36 |
|
| 37 |
// Checking if enter/leave frame at return_call_indirect. |
| 38 |
wasmRunWithDebugger( |
| 39 |
'(module (func) (func (return_call_indirect (i32.const 0))) (func (call 1)) (table 1 1 funcref) (elem (i32.const 0) 0) (export "test" (func 2)))', |
| 40 |
undefined, |
| 41 |
function ({dbg}) { |
| 42 |
onEnterFrameCalled = 0; |
| 43 |
onLeaveFrameCalled = 0; |
| 44 |
onStepCalled = []; |
| 45 |
dbg.onEnterFrame = function (frame) { |
| 46 |
if (frame.type != 'wasmcall') return; |
| 47 |
onEnterFrameCalled++; |
| 48 |
frame.onStep = function () { |
| 49 |
onStepCalled.push(frame.offset); |
| 50 |
}; |
| 51 |
frame.onPop = function () { |
| 52 |
onLeaveFrameCalled++; |
| 53 |
}; |
| 54 |
}; |
| 55 |
}, |
| 56 |
function ({error}) { |
| 57 |
assertEq(error, undefined); |
| 58 |
assertEq(onEnterFrameCalled, 3); |
| 59 |
assertEq(onLeaveFrameCalled, 3); |
| 60 |
assertEq(onStepCalled.length, 4); |
| 61 |
assertEq(onStepCalled[0] > 0, true); |
| 62 |
} |
| 63 |
); |
| 64 |
|
| 65 |
// Checking if enter/leave frame at return_call_ref. |
| 66 |
wasmRunWithDebugger( |
| 67 |
'(module (type $t (func)) (elem declare func 0) (func) (func (return_call_ref $t (ref.func 0))) (func (call 1)) (export "test" (func 2)))', |
| 68 |
undefined, |
| 69 |
function ({dbg}) { |
| 70 |
onEnterFrameCalled = 0; |
| 71 |
onLeaveFrameCalled = 0; |
| 72 |
onStepCalled = []; |
| 73 |
dbg.onEnterFrame = function (frame) { |
| 74 |
if (frame.type != 'wasmcall') return; |
| 75 |
onEnterFrameCalled++; |
| 76 |
frame.onStep = function () { |
| 77 |
onStepCalled.push(frame.offset); |
| 78 |
}; |
| 79 |
frame.onPop = function () { |
| 80 |
onLeaveFrameCalled++; |
| 81 |
}; |
| 82 |
}; |
| 83 |
}, |
| 84 |
function ({error}) { |
| 85 |
assertEq(error, undefined); |
| 86 |
assertEq(onEnterFrameCalled, 3); |
| 87 |
assertEq(onLeaveFrameCalled, 3); |
| 88 |
assertEq(onStepCalled.length, 5); |
| 89 |
assertEq(onStepCalled[0] > 0, true); |
| 90 |
} |
| 91 |
); |