ea48d0942a
This CL adds further support to the test wrapper. We are now able to run almost all mjsunit/debug-step-* tests using the inspector backend. debug-stepframe-* tests are not yet supported since inspector does not know a 'frame' step type. The interface has also been improved to be able to move these tests to inspector mostly without modification. BUG=v8:5330 Review-Url: https://codereview.chromium.org/2466273005 Cr-Commit-Position: refs/heads/master@{#40800}
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
// Copyright 2016 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.
|
|
|
|
Debug = new DebugWrapper();
|
|
Debug.enable();
|
|
|
|
// Simple debug event handler which performs 100 steps and then retrieves
|
|
// the resulting value of "i" in f().
|
|
|
|
function listener(event, exec_state, event_data, data) {
|
|
if (event == Debug.DebugEvent.Break) {
|
|
if (step_count > 0) {
|
|
Debug.stepInto();
|
|
step_count--;
|
|
} else {
|
|
const frameid = exec_state.frames[0].callFrameId;
|
|
result = Debug.evaluate(frameid, "i").value;
|
|
}
|
|
}
|
|
};
|
|
|
|
// Add the debug event listener.
|
|
Debug.setListener(listener);
|
|
|
|
// Test debug event for break point.
|
|
function f() {
|
|
var i; // Line 1.
|
|
for (i = 0; i < 100; i++) { // Line 2.
|
|
x = 1; // Line 3.
|
|
}
|
|
};
|
|
|
|
// Set a breakpoint on the for statement (line 1).
|
|
Debug.setBreakPoint(f, 1);
|
|
|
|
// Check that performing 100 steps will make i 33.
|
|
let step_count = 100;
|
|
let result = -1;
|
|
|
|
f();
|
|
|
|
assertEquals(33, result);
|