• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2014 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
6
7function f0() {
8  var v00 = 0;              // Break 1
9  var v01 = 1;
10  // Normal function call in a catch scope.
11  try {
12    throw 1;
13  } catch (e) {
14    try {
15      f1();
16    } catch (e) {
17      var v02 = 2;          // Break 13
18    }
19  }
20  var v03 = 3;
21  var v04 = 4;
22  eval('var v05 = 5;        // Break 14');
23  var v06 = 6;              // Break 15
24}
25
26function f1() {
27  var v10 = 0;              // Break 2
28  var v11 = 1;
29  // Getter call.
30  var v12 = o.get;
31  var v13 = 3               // Break 4
32  // Setter call.
33  o.set = 2;
34  var v14 = 4;              // Break 6
35  // Function.prototype.call.
36  f2.call();
37  var v15 = 5;              // Break 12
38  var v16 = 6;
39  // Exit function by throw.
40  throw 1;
41  var v17 = 7;
42}
43
44function get() {
45  var g0 = 0;               // Break 3
46  var g1 = 1;
47  return 3;
48}
49
50function set() {
51  var s0 = 0;               // Break 5
52  return 3;
53}
54
55function f2() {
56  var v20 = 0;              // Break 7
57  // Construct call.
58  var v21 = new c0();
59  var v22 = 2;              // Break 9
60  // Bound function.
61  b0();
62  return 2;                 // Break 11
63}
64
65function c0() {
66  this.v0 = 0;              // Break 8
67  this.v1 = 1;
68}
69
70function f3() {
71  var v30 = 0;              // Break 10
72  var v31 = 1;
73  return 3;
74}
75
76var b0 = f3.bind(o);
77
78var o = {};
79Object.defineProperty(o, "get", { get : get });
80Object.defineProperty(o, "set", { set : set });
81
82Debug = debug.Debug;
83var break_count = 0
84var exception = null;
85
86function listener(event, exec_state, event_data, data) {
87  if (event != Debug.DebugEvent.Break) return;
88  try {
89    var line = exec_state.frame(0).sourceLineText();
90    print(line);
91    var match = line.match(/\/\/ Break (\d+)$/);
92    assertEquals(2, match.length);
93    assertEquals(break_count, parseInt(match[1]));
94    break_count ++;
95    exec_state.prepareStep(Debug.StepAction.StepFrame);
96  } catch (e) {
97    print(e + e.stack);
98    exception = e;
99  }
100}
101
102
103break_count = 0;
104Debug.setListener(listener);
105debugger;                 // Break 0
106f0();
107Debug.setListener(null);  // Break 16
108assertTrue(break_count > 14);
109
110assertNull(exception);
111