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-debug-as debug --allow-natives-syntax | |
jgruber
2016/08/12 12:51:34
Would it be possible to add --ignition-staging her
Yang
2016/08/12 13:27:23
We have test variants that explicitly include --ig
| |
6 | |
7 Debug = debug.Debug | |
8 | |
9 var exception = null; | |
10 var frame_depth = 11; | |
11 var break_point; | |
jgruber
2016/08/12 12:51:34
This appears to be unused.
Yang
2016/08/12 13:27:23
Removed.
| |
12 | |
13 function listener(event, exec_state, event_data, data) { | |
14 if (event != Debug.DebugEvent.Break) return; | |
15 try { | |
16 assertEquals(frame_depth, exec_state.frameCount()); | |
17 assertTrue(/\/\/ Break$/.test(exec_state.frame(0).sourceLineText())); | |
18 assertEquals(12 - frame_depth, exec_state.frame(0).evaluate("x").value()); | |
19 if (frame_depth > 2) exec_state.prepareStep(Debug.StepAction.StepOut); | |
20 frame_depth--; | |
21 } catch (e) { | |
22 exception = e; | |
23 print(e + e.stack); | |
24 } | |
25 } | |
26 | |
27 function ChooseCode(f, x) { | |
28 switch (x % 2) { | |
29 case 0: | |
30 %BaselineFunctionOnNextCall(f); | |
31 break; | |
32 case 1: | |
33 %InterpretFunctionOnNextCall(f); | |
34 break; | |
35 } | |
36 } | |
37 | |
38 function factorial(x) { | |
39 ChooseCode(factorial, x); | |
40 if (x == 1) { | |
41 debugger; // Break | |
42 return 1; | |
43 } | |
44 var factor = factorial(x - 1); | |
45 return x * factor; // Break | |
46 } | |
47 | |
48 Debug.setListener(listener); | |
49 | |
50 assertEquals(3628800, factorial(10)); | |
51 | |
52 Debug.setListener(null); | |
53 assertNull(exception); | |
54 assertEquals(1, frame_depth); | |
OLD | NEW |