debug-evaluate-modify-catch-block-scope.js 1010 Bytes
Newer Older
1 2 3 4
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
// Flags: --no-always-opt --no-stress-opt
6 7 8 9 10 11 12

Debug = debug.Debug

var exception = null;
function listener(event, exec_state, event_data, data) {
  if (event != Debug.DebugEvent.Break) return;
  try {
13 14
    exec_state.frame(0).evaluate("a = 2");
    exec_state.frame(0).evaluate("e = 3");
15
    exec_state.frame(0).evaluate("bar()");
16 17
    exec_state.frame(0).evaluate("a++");
    exec_state.frame(0).evaluate("e++");
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
  } catch (e) {
    exception = e;
    print(e + e.stack);
  }
}

Debug.setListener(listener);

(function() {
  "use strict";
  try {
    throw 1;
  } catch (e) {
    let a = 1;
    function bar() {
33 34
      a *= 2;
      e *= 2;
35
    }
36 37
    // Make sure bar is 'used' so that it is visible to the debugger.
    bar;
38
    debugger;
39 40
    assertEquals(5, a);
    assertEquals(7, e);
41 42 43 44 45
  }
})();

Debug.setListener(null);
assertNull(exception);