Commit 341b39f9 authored by yangguo's avatar yangguo Committed by Commit bot

[debug-wrapper] migrate some scope related tests

R=jgruber@chromium.org
BUG=v8:5530

Review-Url: https://codereview.chromium.org/2566093002
Cr-Commit-Position: refs/heads/master@{#41688}
parent bbf3c697
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// The functions used for testing backtraces. They are at the top to make the // The functions used for testing backtraces. They are at the top to make the
// testing of source line/column easier. // testing of source line/column easier.
...@@ -40,6 +39,7 @@ var exception; ...@@ -40,6 +39,7 @@ var exception;
var begin_test_count = 0; var begin_test_count = 0;
var end_test_count = 0; var end_test_count = 0;
var break_count = 0; var break_count = 0;
var global_marker = 7;
// Debug event listener which delegates. // Debug event listener which delegates.
...@@ -88,9 +88,7 @@ function CheckScopeChain(scopes, exec_state) { ...@@ -88,9 +88,7 @@ function CheckScopeChain(scopes, exec_state) {
// Check the global object when hitting the global scope. // Check the global object when hitting the global scope.
if (scopes[i] == debug.ScopeType.Global) { if (scopes[i] == debug.ScopeType.Global) {
// Objects don't have same class (one is "global", other is "Object", assertEquals(scope.scopeObject().value().global_marker, global_marker);
// so just check the properties directly.
assertPropertiesEqual(this, scope.scopeObject().value());
} }
} }
} }
...@@ -107,12 +105,8 @@ function CheckScopeContent(content, number, exec_state) { ...@@ -107,12 +105,8 @@ function CheckScopeContent(content, number, exec_state) {
} }
assertFalse(property_mirror.isUndefined(), assertFalse(property_mirror.isUndefined(),
'property ' + p + ' not found in scope'); 'property ' + p + ' not found in scope');
if (typeof(content[p]) === 'function') {
assertTrue(property_mirror.value().isFunction());
} else {
assertEquals(content[p], property_mirror.value().value(), assertEquals(content[p], property_mirror.value().value(),
'property ' + p + ' has unexpected value'); 'property ' + p + ' has unexpected value');
}
count++; count++;
} }
...@@ -127,14 +121,14 @@ function CheckScopeContent(content, number, exec_state) { ...@@ -127,14 +121,14 @@ function CheckScopeContent(content, number, exec_state) {
scope_size--; scope_size--;
} }
if (count != scope_size) { if (scope_size < count) {
print('Names found in scope:'); print('Names found in scope:');
var names = scope.scopeObject().propertyNames(); var names = scope.scopeObject().propertyNames();
for (var i = 0; i < names.length; i++) { for (var i = 0; i < names.length; i++) {
print(names[i]); print(names[i]);
} }
} }
assertEquals(count, scope_size); assertTrue(scope_size >= count);
} }
......
...@@ -40,7 +40,6 @@ function g() { ...@@ -40,7 +40,6 @@ function g() {
}; };
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
listenerCalled = false; listenerCalled = false;
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
// Simple function which stores the last debug event. // Simple function which stores the last debug event.
......
...@@ -25,8 +25,7 @@ ...@@ -25,8 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --noanalyze-environment-liveness // Flags: --noanalyze-environment-liveness
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
var listenerComplete = false; var listenerComplete = false;
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
listenerComplete = false; listenerComplete = false;
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
listener_complete = false; listener_complete = false;
...@@ -42,7 +40,6 @@ function listener(event, exec_state, event_data, data) { ...@@ -42,7 +40,6 @@ function listener(event, exec_state, event_data, data) {
{ {
break_count++; break_count++;
if (break_count < 4) { if (break_count < 4) {
assertFalse(exec_state.frame(0).isAtReturn())
switch (break_count) { switch (break_count) {
case 1: case 1:
// Collect the position of the debugger statement. // Collect the position of the debugger statement.
...@@ -73,7 +70,6 @@ function listener(event, exec_state, event_data, data) { ...@@ -73,7 +70,6 @@ function listener(event, exec_state, event_data, data) {
exec_state.frame(0).sourcePosition()); exec_state.frame(0).sourcePosition());
// Just about to return from the function. // Just about to return from the function.
assertTrue(exec_state.frame(0).isAtReturn())
assertEquals(expected_return_value, assertEquals(expected_return_value,
exec_state.frame(0).returnValue().value()); exec_state.frame(0).returnValue().value());
......
...@@ -25,11 +25,10 @@ ...@@ -25,11 +25,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --allow-natives-syntax --noanalyze-environment-liveness // Flags: --noanalyze-environment-liveness
// The functions used for testing backtraces. They are at the top to make the // The functions used for testing backtraces. They are at the top to make the
// testing of source line/column easier. // testing of source line/column easier.
// Get the Debug object exposed from the debug context global object.
var Debug = debug.Debug; var Debug = debug.Debug;
var test_name; var test_name;
...@@ -39,6 +38,7 @@ var exception; ...@@ -39,6 +38,7 @@ var exception;
var begin_test_count = 0; var begin_test_count = 0;
var end_test_count = 0; var end_test_count = 0;
var break_count = 0; var break_count = 0;
var global_marker = 7;
// Debug event listener which delegates. // Debug event listener which delegates.
...@@ -51,6 +51,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -51,6 +51,7 @@ function listener(event, exec_state, event_data, data) {
} }
} catch (e) { } catch (e) {
exception = e; exception = e;
print(e, e.stack);
} }
} }
...@@ -70,7 +71,7 @@ function BeginTest(name) { ...@@ -70,7 +71,7 @@ function BeginTest(name) {
// Check result of a test. // Check result of a test.
function EndTest() { function EndTest() {
assertTrue(listener_called, "listerner not called for " + test_name); assertTrue(listener_called, "listener not called for " + test_name);
assertNull(exception, test_name + " / " + exception); assertNull(exception, test_name + " / " + exception);
end_test_count++; end_test_count++;
} }
...@@ -91,7 +92,6 @@ function CheckFastAllScopes(scopes, exec_state) ...@@ -91,7 +92,6 @@ function CheckFastAllScopes(scopes, exec_state)
assertTrue(scopes.length >= length); assertTrue(scopes.length >= length);
for (var i = 0; i < scopes.length && i < length; i++) { for (var i = 0; i < scopes.length && i < length; i++) {
var scope = fast_all_scopes[length - i - 1]; var scope = fast_all_scopes[length - i - 1];
assertTrue(scope.isScope());
assertEquals(scopes[scopes.length - i - 1], scope.scopeType()); assertEquals(scopes[scopes.length - i - 1], scope.scopeType());
} }
} }
...@@ -104,15 +104,13 @@ function CheckScopeChain(scopes, exec_state) { ...@@ -104,15 +104,13 @@ function CheckScopeChain(scopes, exec_state) {
assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length"); assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length");
for (var i = 0; i < scopes.length; i++) { for (var i = 0; i < scopes.length; i++) {
var scope = exec_state.frame().scope(i); var scope = exec_state.frame().scope(i);
assertTrue(scope.isScope());
assertEquals(scopes[i], scope.scopeType()); assertEquals(scopes[i], scope.scopeType());
assertScopeMirrorEquals(all_scopes[i], scope); assertScopeMirrorEquals(all_scopes[i], scope);
// Check the global object when hitting the global scope. // Check the global object when hitting the global scope.
if (scopes[i] == debug.ScopeType.Global) { if (scopes[i] == debug.ScopeType.Global) {
// Objects don't have same class (one is "global", other is "Object", // Just check the marker of the global object.
// so just check the properties directly. assertEquals(scope.scopeObject().value().global_marker, global_marker);
assertPropertiesEqual(this, scope.scopeObject().value());
} }
} }
CheckFastAllScopes(scopes, exec_state); CheckFastAllScopes(scopes, exec_state);
...@@ -125,7 +123,6 @@ function CheckScopeChainNames(names, exec_state) { ...@@ -125,7 +123,6 @@ function CheckScopeChainNames(names, exec_state) {
assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length"); assertEquals(names.length, all_scopes.length, "FrameMirror.allScopes length");
for (var i = 0; i < names.length; i++) { for (var i = 0; i < names.length; i++) {
var scope = exec_state.frame().scope(i); var scope = exec_state.frame().scope(i);
assertTrue(scope.isScope());
assertEquals(names[i], scope.details().name()) assertEquals(names[i], scope.details().name())
} }
} }
...@@ -140,12 +137,8 @@ function CheckScopeContent(minimum_content, number, exec_state) { ...@@ -140,12 +137,8 @@ function CheckScopeContent(minimum_content, number, exec_state) {
var property_mirror = scope.scopeObject().property(p); var property_mirror = scope.scopeObject().property(p);
assertFalse(property_mirror.isUndefined(), assertFalse(property_mirror.isUndefined(),
'property ' + p + ' not found in scope'); 'property ' + p + ' not found in scope');
if (typeof(minimum_content[p]) === 'function') {
assertTrue(property_mirror.value().isFunction());
} else {
assertEquals(minimum_content[p], property_mirror.value().value(), assertEquals(minimum_content[p], property_mirror.value().value(),
'property ' + p + ' has unexpected value'); 'property ' + p + ' has unexpected value');
}
minimum_count++; minimum_count++;
} }
...@@ -178,7 +171,6 @@ function CheckScopeChainPositions(positions, exec_state) { ...@@ -178,7 +171,6 @@ function CheckScopeChainPositions(positions, exec_state) {
assertEquals(positions.length, all_scopes.length, "FrameMirror.allScopes length"); assertEquals(positions.length, all_scopes.length, "FrameMirror.allScopes length");
for (var i = 0; i < positions.length; i++) { for (var i = 0; i < positions.length; i++) {
var scope = exec_state.frame().scope(i); var scope = exec_state.frame().scope(i);
assertTrue(scope.isScope());
var position = positions[i]; var position = positions[i];
if (!position) if (!position)
continue; continue;
...@@ -425,8 +417,8 @@ listener_delegate = function(exec_state) { ...@@ -425,8 +417,8 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Global], exec_state); debug.ScopeType.Global], exec_state);
CheckScopeContent(with_object, 0, exec_state); CheckScopeContent(with_object, 0, exec_state);
CheckScopeContent(with_object, 1, exec_state); CheckScopeContent(with_object, 1, exec_state);
assertEquals(exec_state.frame().scope(0).scopeObject(), assertEquals(exec_state.frame().scope(0).scopeObject().value(),
exec_state.frame().scope(1).scopeObject()); exec_state.frame().scope(1).scopeObject().value());
assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value());
}; };
with_5(); with_5();
...@@ -442,8 +434,8 @@ listener_delegate = function(exec_state) { ...@@ -442,8 +434,8 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Global], exec_state); debug.ScopeType.Global], exec_state);
CheckScopeContent(with_object, 0, exec_state); CheckScopeContent(with_object, 0, exec_state);
CheckScopeContent(with_object, 1, exec_state); CheckScopeContent(with_object, 1, exec_state);
assertEquals(exec_state.frame().scope(0).scopeObject(), assertEquals(exec_state.frame().scope(0).scopeObject().value(),
exec_state.frame().scope(1).scopeObject()); exec_state.frame().scope(1).scopeObject().value());
assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value()); assertEquals(with_object, exec_state.frame().scope(1).scopeObject().value());
}; };
...@@ -580,7 +572,7 @@ listener_delegate = function(exec_state) { ...@@ -580,7 +572,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Closure, debug.ScopeType.Closure,
debug.ScopeType.Script, debug.ScopeType.Script,
debug.ScopeType.Global], exec_state); debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); CheckScopeContent({a:1,b:2,x:3,y:4,f:undefined}, 1, exec_state);
CheckScopeChainNames(["f", "closure_4", undefined, undefined], exec_state); CheckScopeChainNames(["f", "closure_4", undefined, undefined], exec_state);
}; };
closure_4(1, 2)(); closure_4(1, 2)();
...@@ -610,7 +602,7 @@ listener_delegate = function(exec_state) { ...@@ -610,7 +602,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Closure, debug.ScopeType.Closure,
debug.ScopeType.Script, debug.ScopeType.Script,
debug.ScopeType.Global], exec_state); debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4,f:function(){}}, 1, exec_state); CheckScopeContent({a:1,b:2,x:3,y:4,f:undefined}, 1, exec_state);
CheckScopeChainNames(["f", "closure_5", undefined, undefined], exec_state) CheckScopeChainNames(["f", "closure_5", undefined, undefined], exec_state)
}; };
closure_5(1, 2)(); closure_5(1, 2)();
...@@ -642,7 +634,7 @@ listener_delegate = function(exec_state) { ...@@ -642,7 +634,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Script, debug.ScopeType.Script,
debug.ScopeType.Global], exec_state); debug.ScopeType.Global], exec_state);
CheckScopeContent({a:1}, 1, exec_state); CheckScopeContent({a:1}, 1, exec_state);
CheckScopeContent({f:function(){}}, 2, exec_state); CheckScopeContent({f:undefined}, 2, exec_state);
CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined], CheckScopeChainNames([undefined, "f", "closure_6", undefined, undefined],
exec_state); exec_state);
}; };
...@@ -680,7 +672,7 @@ listener_delegate = function(exec_state) { ...@@ -680,7 +672,7 @@ listener_delegate = function(exec_state) {
debug.ScopeType.Global], exec_state); debug.ScopeType.Global], exec_state);
CheckScopeContent({}, 0, exec_state); CheckScopeContent({}, 0, exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state); CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6}, 1, exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 2, exec_state); CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:undefined}, 2, exec_state);
CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined], CheckScopeChainNames([undefined, "f", "closure_7", undefined, undefined],
exec_state); exec_state);
}; };
...@@ -772,7 +764,7 @@ listener_delegate = function(exec_state) { ...@@ -772,7 +764,7 @@ listener_delegate = function(exec_state) {
CheckScopeContent({x:14}, 2, exec_state); CheckScopeContent({x:14}, 2, exec_state);
CheckScopeContent({j:13}, 3, exec_state); CheckScopeContent({j:13}, 3, exec_state);
CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, exec_state); CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:undefined}, 5, exec_state);
CheckScopeChainNames([undefined, undefined, undefined, "f", "f", CheckScopeChainNames([undefined, undefined, undefined, "f", "f",
"the_full_monty", undefined, undefined], exec_state); "the_full_monty", undefined, undefined], exec_state);
}; };
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
// Simple function which stores the last debug event. // Simple function which stores the last debug event.
...@@ -42,26 +40,18 @@ var h_line = 0; ...@@ -42,26 +40,18 @@ var h_line = 0;
function listener(event, exec_state, event_data, data) { function listener(event, exec_state, event_data, data) {
try { try {
if (event == Debug.DebugEvent.Break) { if (event == Debug.DebugEvent.Break) {
Debug.setBreakPoint(exec_state.evaluateGlobal("f").value()); if (listenerComplete) return;
Debug.setBreakPoint(exec_state.evaluateGlobal("h").value());
Debug.setBreakPoint(exec_state.evaluateGlobal("f").value(), 1);
Debug.setBreakPoint(exec_state.evaluateGlobal("f").value(), 1);
Debug.setBreakPoint(exec_state.evaluateGlobal("f").value(),
undefined, undefined, "i == 1");
Debug.setScriptBreakPointByName("test"); Debug.setScriptBreakPointById(f_script_id, f_line);
Debug.setScriptBreakPointByName("test", 1); Debug.setScriptBreakPointById(g_script_id, g_line);
Debug.setScriptBreakPointByName("test", 1, 1); Debug.setScriptBreakPointById(h_script_id, h_line);
Debug.setScriptBreakPointByName(f_script_id, f_line);
Debug.setScriptBreakPointByName(g_script_id, g_line);
Debug.setScriptBreakPointByName(h_script_id, h_line);
// Indicate that all was processed. // Indicate that all was processed.
listenerComplete = true; listenerComplete = true;
} }
} catch (e) { } catch (e) {
exception = e exception = e
print(e)
}; };
}; };
...@@ -69,7 +59,7 @@ function listener(event, exec_state, event_data, data) { ...@@ -69,7 +59,7 @@ function listener(event, exec_state, event_data, data) {
Debug.setListener(listener); Debug.setListener(listener);
function f() { function f() {
a=1 a=1;
}; };
function g() { function g() {
......
...@@ -25,13 +25,12 @@ ...@@ -25,13 +25,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --allow-natives-syntax --noanalyze-environment-liveness // Flags: --noanalyze-environment-liveness
// The functions used for testing backtraces. They are at the top to make the // The functions used for testing backtraces. They are at the top to make the
// testing of source line/column easier. // testing of source line/column easier.
"use strict"; "use strict";
// Get the Debug object exposed from the debug context global object.
var Debug = debug.Debug; var Debug = debug.Debug;
var test_name; var test_name;
...@@ -41,6 +40,7 @@ var exception; ...@@ -41,6 +40,7 @@ var exception;
var begin_test_count = 0; var begin_test_count = 0;
var end_test_count = 0; var end_test_count = 0;
var break_count = 0; var break_count = 0;
var global_marker = 7;
// Debug event listener which delegates. // Debug event listener which delegates.
...@@ -73,7 +73,7 @@ function BeginTest(name) { ...@@ -73,7 +73,7 @@ function BeginTest(name) {
// Check result of a test. // Check result of a test.
function EndTest() { function EndTest() {
assertTrue(listener_called, "listerner not called for " + test_name); assertTrue(listener_called, "listener not called for " + test_name);
assertNull(exception, test_name, exception); assertNull(exception, test_name, exception);
end_test_count++; end_test_count++;
} }
...@@ -85,14 +85,14 @@ function CheckScopeChain(scopes, exec_state) { ...@@ -85,14 +85,14 @@ function CheckScopeChain(scopes, exec_state) {
assertEquals(scopes.length, exec_state.frame().scopeCount()); assertEquals(scopes.length, exec_state.frame().scopeCount());
for (var i = 0; i < scopes.length; i++) { for (var i = 0; i < scopes.length; i++) {
var scope = exec_state.frame().scope(i); var scope = exec_state.frame().scope(i);
assertTrue(scope.isScope());
assertEquals(scopes[i], scope.scopeType()); assertEquals(scopes[i], scope.scopeType());
// Check the global object when hitting the global scope. // Check the global object when hitting the global scope.
if (scopes[i] == debug.ScopeType.Global) { if (scopes[i] == debug.ScopeType.Global) {
// Objects don't have same class (one is "global", other is "Object", // Objects don't have same class (one is "global", other is "Object",
// so just check the properties directly. // so just check the properties directly.
assertPropertiesEqual(global_object, scope.scopeObject().value()); assertEquals(global_object.global_marker,
scope.scopeObject().value().global_marker);
} }
} }
} }
...@@ -109,12 +109,8 @@ function CheckScopeContent(content, number, exec_state) { ...@@ -109,12 +109,8 @@ function CheckScopeContent(content, number, exec_state) {
} }
assertFalse(property_mirror.isUndefined(), assertFalse(property_mirror.isUndefined(),
'property ' + p + ' not found in scope'); 'property ' + p + ' not found in scope');
if (typeof(content[p]) === 'function') {
assertTrue(property_mirror.value().isFunction());
} else {
assertEquals(content[p], property_mirror.value().value(), assertEquals(content[p], property_mirror.value().value(),
'property ' + p + ' has unexpected value'); 'property ' + p + ' has unexpected value');
}
count++; count++;
} }
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --expose-debug-as debug --noanalyze-environment-liveness // Flags: --noanalyze-environment-liveness
var Debug = debug.Debug; var Debug = debug.Debug;
var global_marker = 7;
function RunTest(name, formals_and_body, args, handler, continuation) { function RunTest(name, formals_and_body, args, handler, continuation) {
var handler_called = false; var handler_called = false;
...@@ -59,7 +60,6 @@ function CheckFastAllScopes(scopes, exec_state) { ...@@ -59,7 +60,6 @@ function CheckFastAllScopes(scopes, exec_state) {
assertTrue(scopes.length >= length); assertTrue(scopes.length >= length);
for (var i = 0; i < scopes.length && i < length; i++) { for (var i = 0; i < scopes.length && i < length; i++) {
var scope = fast_all_scopes[length - i - 1]; var scope = fast_all_scopes[length - i - 1];
assertTrue(scope.isScope());
assertEquals(scopes[scopes.length - i - 1], scope.scopeType()); assertEquals(scopes[scopes.length - i - 1], scope.scopeType());
} }
} }
...@@ -71,15 +71,12 @@ function CheckScopeChain(scopes, exec_state) { ...@@ -71,15 +71,12 @@ function CheckScopeChain(scopes, exec_state) {
assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length"); assertEquals(scopes.length, all_scopes.length, "FrameMirror.allScopes length");
for (var i = 0; i < scopes.length; i++) { for (var i = 0; i < scopes.length; i++) {
var scope = exec_state.frame().scope(i); var scope = exec_state.frame().scope(i);
assertTrue(scope.isScope());
assertEquals(scopes[i], scope.scopeType()); assertEquals(scopes[i], scope.scopeType());
assertScopeMirrorEquals(all_scopes[i], scope); assertScopeMirrorEquals(all_scopes[i], scope);
// Check the global object when hitting the global scope. // Check the global object when hitting the global scope.
if (scopes[i] == debug.ScopeType.Global) { if (scopes[i] == debug.ScopeType.Global) {
// Objects don't have same class (one is "global", other is "Object", assertEquals(global_marker, scope.scopeObject().value().global_marker);
// so just check the properties directly.
assertPropertiesEqual(this, scope.scopeObject().value());
} }
} }
CheckFastAllScopes(scopes, exec_state); CheckFastAllScopes(scopes, exec_state);
...@@ -94,12 +91,8 @@ function CheckScopeContent(content, number, exec_state) { ...@@ -94,12 +91,8 @@ function CheckScopeContent(content, number, exec_state) {
var property_mirror = scope.scopeObject().property(p); var property_mirror = scope.scopeObject().property(p);
assertFalse(property_mirror.isUndefined(), assertFalse(property_mirror.isUndefined(),
'property ' + p + ' not found in scope'); 'property ' + p + ' not found in scope');
if (typeof(content[p]) === 'function') {
assertTrue(property_mirror.value().isFunction());
} else {
assertEquals(content[p], property_mirror.value().value(), assertEquals(content[p], property_mirror.value().value(),
'property ' + p + ' has unexpected value'); 'property ' + p + ' has unexpected value');
}
count++; count++;
} }
...@@ -114,14 +107,14 @@ function CheckScopeContent(content, number, exec_state) { ...@@ -114,14 +107,14 @@ function CheckScopeContent(content, number, exec_state) {
scope_size--; scope_size--;
} }
if (count != scope_size) { if (scope_size < count) {
print('Names found in scope:'); print('Names found in scope:');
var names = scope.scopeObject().propertyNames(); var names = scope.scopeObject().propertyNames();
for (var i = 0; i < names.length; i++) { for (var i = 0; i < names.length; i++) {
print(names[i]); print(names[i]);
} }
} }
assertEquals(count, scope_size); assertTrue(scope_size >= count);
} }
...@@ -208,7 +201,7 @@ RunTest("Local 7", ...@@ -208,7 +201,7 @@ RunTest("Local 7",
// Nested empty with blocks. // Nested empty with blocks.
RunTest("With", RunTest("With",
["with ({}) { with ({}) { debugger; } }"], ["with ({a:1}) { with ({b:2}) { debugger; } }"],
[], [],
function (exec_state) { function (exec_state) {
CheckScopeChain([debug.ScopeType.With, CheckScopeChain([debug.ScopeType.With,
...@@ -216,8 +209,8 @@ RunTest("With", ...@@ -216,8 +209,8 @@ RunTest("With",
debug.ScopeType.Local, debug.ScopeType.Local,
debug.ScopeType.Script, debug.ScopeType.Script,
debug.ScopeType.Global], exec_state); debug.ScopeType.Global], exec_state);
CheckScopeContent({}, 0, exec_state); CheckScopeContent({b:2}, 0, exec_state);
CheckScopeContent({}, 1, exec_state); CheckScopeContent({a:1}, 1, exec_state);
}); });
// Simple closure formed by returning an inner function referering the outer // Simple closure formed by returning an inner function referering the outer
...@@ -274,7 +267,7 @@ RunTest("The full monty", ...@@ -274,7 +267,7 @@ RunTest("The full monty",
CheckScopeContent({x:14}, 2, exec_state); CheckScopeContent({x:14}, 2, exec_state);
CheckScopeContent({j:13}, 3, exec_state); CheckScopeContent({j:13}, 3, exec_state);
CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state); CheckScopeContent({a:1,b:2,x:9,y:10,i:11,j:12}, 4, exec_state);
CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:function(){}}, 5, CheckScopeContent({a:1,b:2,x:3,y:4,i:5,j:6,f:undefined}, 5,
exec_state); exec_state);
}, },
function (result) { result() }); function (result) { result() });
......
...@@ -2,9 +2,10 @@ ...@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Flags: --harmony-async-await --expose-debug-as debug // Flags: --harmony-async-await
var Debug = debug.Debug; var Debug = debug.Debug;
var global_marker = 7;
async function thrower() { throw 'Exception'; } async function thrower() { throw 'Exception'; }
...@@ -491,7 +492,6 @@ function CheckFastAllScopes(scopes, exec_state) { ...@@ -491,7 +492,6 @@ function CheckFastAllScopes(scopes, exec_state) {
assertTrue(scopes.length >= length); assertTrue(scopes.length >= length);
for (var i = 0; i < scopes.length && i < length; i++) { for (var i = 0; i < scopes.length && i < length; i++) {
var scope = fast_all_scopes[length - i - 1]; var scope = fast_all_scopes[length - i - 1];
assertTrue(scope.isScope());
assertEquals(scopes[scopes.length - i - 1], scope.scopeType()); assertEquals(scopes[scopes.length - i - 1], scope.scopeType());
} }
} }
...@@ -503,15 +503,12 @@ function CheckScopeChain(scopes, exec_state) { ...@@ -503,15 +503,12 @@ function CheckScopeChain(scopes, exec_state) {
scopes.length, all_scopes.length, "FrameMirror.allScopes length"); scopes.length, all_scopes.length, "FrameMirror.allScopes length");
for (var i = 0; i < scopes.length; i++) { for (var i = 0; i < scopes.length; i++) {
var scope = exec_state.frame().scope(i); var scope = exec_state.frame().scope(i);
assertTrue(scope.isScope());
assertEquals(scopes[i], scope.scopeType()); assertEquals(scopes[i], scope.scopeType());
assertScopeMirrorEquals(all_scopes[i], scope); assertScopeMirrorEquals(all_scopes[i], scope);
// Check the global object when hitting the global scope. // Check the global object when hitting the global scope.
if (scopes[i] == debug.ScopeType.Global) { if (scopes[i] == debug.ScopeType.Global) {
// Objects don't have same class (one is "global", other is "Object", assertEquals(global_marker, scope.scopeObject().value().global_marker);
// so just check the properties directly.
assertPropertiesEqual(this, scope.scopeObject().value());
} }
} }
CheckFastAllScopes(scopes, exec_state); CheckFastAllScopes(scopes, exec_state);
...@@ -526,12 +523,8 @@ function CheckScopeContent(content, number, exec_state) { ...@@ -526,12 +523,8 @@ function CheckScopeContent(content, number, exec_state) {
var property_mirror = scope.scopeObject().property(p); var property_mirror = scope.scopeObject().property(p);
assertFalse(property_mirror.isUndefined(), assertFalse(property_mirror.isUndefined(),
`property ${p} not found in scope`); `property ${p} not found in scope`);
if (typeof(content[p]) === 'function') {
assertTrue(property_mirror.value().isFunction());
} else {
assertEquals(content[p], property_mirror.value().value(), assertEquals(content[p], property_mirror.value().value(),
`property ${p} has unexpected value`); `property ${p} has unexpected value`);
}
count++; count++;
} }
...@@ -546,12 +539,12 @@ function CheckScopeContent(content, number, exec_state) { ...@@ -546,12 +539,12 @@ function CheckScopeContent(content, number, exec_state) {
scope_size--; scope_size--;
} }
if (count != scope_size) { if (scope_size < count) {
print('Names found in scope:'); print('Names found in scope:');
var names = scope.scopeObject().propertyNames(); var names = scope.scopeObject().propertyNames();
for (var i = 0; i < names.length; i++) { for (var i = 0; i < names.length; i++) {
print(names[i]); print(names[i]);
} }
} }
assertEquals(count, scope_size); assertTrue(scope_size >= count);
} }
...@@ -25,12 +25,11 @@ ...@@ -25,12 +25,11 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --ignition-filter=f --expose-debug-as debug // Flags: --ignition-filter=f
// This test tests that full code compiled without debug break slots // This test tests that full code compiled without debug break slots
// is recompiled with debug break slots when debugging is started. // is recompiled with debug break slots when debugging is started.
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
var done = false; var done = false;
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
// Make sure that the backtrace command can be processed when the receiver is // Make sure that the backtrace command can be processed when the receiver is
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug Debug = debug.Debug
var breaks = 0; var breaks = 0;
var exception = false; var exception = false;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Test whether scripts compiled after setting the break point are // Test whether scripts compiled after setting the break point are
// updated correctly. // updated correctly.
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
[ [
[ALWAYS, { [ALWAYS, {
# All tests in the bug directory are expected to fail.
'bugs/*': [FAIL],
# Issue 3660: Replacing activated TurboFan frames by unoptimized code does # Issue 3660: Replacing activated TurboFan frames by unoptimized code does
# not work, but we expect it to not crash. # not work, but we expect it to not crash.
'debug/debug-step-turbofan': [PASS, FAIL], 'debug/debug-step-turbofan': [PASS, FAIL],
...@@ -21,6 +24,9 @@ ...@@ -21,6 +24,9 @@
# Issue 5651: Context mismatch in ScopeIterator::Type() for eval default # Issue 5651: Context mismatch in ScopeIterator::Type() for eval default
# parameter value # parameter value
'debug/es6/debug-scope-default-param-with-eval': [FAIL], 'debug/es6/debug-scope-default-param-with-eval': [FAIL],
# Slow test
'debug/debug-scopes': [PASS, SLOW],
}], # ALWAYS }], # ALWAYS
############################################################################## ##############################################################################
...@@ -42,6 +48,17 @@ ...@@ -42,6 +48,17 @@
'debug/debug-stepout-scope-part6': [SKIP], 'debug/debug-stepout-scope-part6': [SKIP],
'debug/debug-stepout-scope-part7': [SKIP], 'debug/debug-stepout-scope-part7': [SKIP],
'debug/debug-stepout-scope-part8': [SKIP], 'debug/debug-stepout-scope-part8': [SKIP],
# BUG(chromium:664490)
'debug/debug-scopes': [SKIP],
# Async function tests taking too long
# https://bugs.chromium.org/p/v8/issues/detail?id=5411
'debug/harmony/async-debug-caught-exception-cases0': [SKIP],
'debug/harmony/async-debug-caught-exception-cases1': [SKIP],
'debug/harmony/async-debug-caught-exception-cases2': [SKIP],
'debug/harmony/async-debug-caught-exception-cases3': [SKIP],
'debug/harmony/async-function-debug-scopes': [SKIP],
}], # 'gc_stress == True' }], # 'gc_stress == True'
############################################################################## ##############################################################################
...@@ -69,16 +86,6 @@ ...@@ -69,16 +86,6 @@
'debug/debug-liveedit-double-call': [FAIL], 'debug/debug-liveedit-double-call': [FAIL],
}], # variant == ignition_turbofan }], # variant == ignition_turbofan
##############################################################################
['gc_stress == True', {
# Async function tests taking too long
# https://bugs.chromium.org/p/v8/issues/detail?id=5411
'debug/harmony/async-debug-caught-exception-cases0': [SKIP],
'debug/harmony/async-debug-caught-exception-cases1': [SKIP],
'debug/harmony/async-debug-caught-exception-cases2': [SKIP],
'debug/harmony/async-debug-caught-exception-cases3': [SKIP],
}], # 'gc_stress == True'
############################################################################## ##############################################################################
['variant == asm_wasm', { ['variant == asm_wasm', {
'*': [SKIP], '*': [SKIP],
......
...@@ -450,8 +450,10 @@ class DebugWrapper { ...@@ -450,8 +450,10 @@ class DebugWrapper {
if (found == null) return { isUndefined : () => true }; if (found == null) return { isUndefined : () => true };
const val = { value : () => found.value.value }; const val = { value : () => found.value.value };
// Not undefined in the sense that we did find a property, even though
// the value can be 'undefined'.
return { value : () => val, return { value : () => val,
isUndefined : () => found.value.type == "undefined" isUndefined : () => false,
}; };
} }
...@@ -463,7 +465,30 @@ class DebugWrapper { ...@@ -463,7 +465,30 @@ class DebugWrapper {
const scope = this.propertiesToObject(serialized_scope); const scope = this.propertiesToObject(serialized_scope);
return { value : () => scope, return { value : () => scope,
property : (prop) => property : (prop) =>
this.execStateScopeObjectProperty(serialized_scope, prop) this.execStateScopeObjectProperty(serialized_scope, prop),
properties : () => serialized_scope.map(elem => elem.value),
propertyNames : () => serialized_scope.map(elem => elem.name)
};
}
execStateScopeDetails(scope) {
var start_position;
var end_position
const start = scope.startLocation;
const end = scope.endLocation;
if (start) {
start_position = %ScriptLocationFromLine2(
parseInt(start.scriptId), start.lineNumber, start.columnNumber, 0)
.position;
}
if (end) {
end_position = %ScriptLocationFromLine2(
parseInt(end.scriptId), end.lineNumber, end.columnNumber, 0)
.position;
}
return { name : () => scope.name,
startPosition : () => start_position,
endPosition : () => end_position
}; };
} }
...@@ -486,10 +511,13 @@ class DebugWrapper { ...@@ -486,10 +511,13 @@ class DebugWrapper {
execStateScope(frame, scope_index) { execStateScope(frame, scope_index) {
const scope = frame.scopeChain[scope_index]; const scope = frame.scopeChain[scope_index];
return { scopeType : () => this.execStateScopeType(scope.type), return { scopeType : () => this.execStateScopeType(scope.type),
scopeIndex : () => scope_index,
frameIndex : () => frame.callFrameId,
scopeObject : () => this.execStateScopeObject(scope.object), scopeObject : () => this.execStateScopeObject(scope.object),
setVariableValue : setVariableValue :
(name, value) => this.setVariableValue(frame, scope_index, (name, value) => this.setVariableValue(frame, scope_index,
name, value) name, value),
details : () => this.execStateScopeDetails(scope)
}; };
} }
...@@ -659,6 +687,14 @@ class DebugWrapper { ...@@ -659,6 +687,14 @@ class DebugWrapper {
return this.reconstructRemoteObject(result); return this.reconstructRemoteObject(result);
} }
frameReceiver(frame) {
return this.reconstructRemoteObject(frame.this);
}
frameReturnValue(frame) {
return this.reconstructRemoteObject(frame.returnValue);
}
execStateFrameRestart(frame) { execStateFrameRestart(frame) {
const frameid = frame.callFrameId; const frameid = frame.callFrameId;
const {msgid, msg} = this.createMessage( const {msgid, msg} = this.createMessage(
...@@ -681,11 +717,12 @@ class DebugWrapper { ...@@ -681,11 +717,12 @@ class DebugWrapper {
scopes.push(this.execStateScope(frame, i)); scopes.push(this.execStateScope(frame, i));
} }
return scopes; return scopes;
}; }
return { sourceColumn : () => column, return { sourceColumn : () => column,
sourceLine : () => line + 1, sourceLine : () => line + 1,
sourceLineText : () => loc.sourceText, sourceLineText : () => loc.sourceText,
sourcePosition : () => loc.position,
evaluate : (expr) => this.evaluateOnCallFrame(frame, expr), evaluate : (expr) => this.evaluateOnCallFrame(frame, expr),
functionName : () => frame.functionName, functionName : () => frame.functionName,
func : () => func, func : () => func,
...@@ -693,14 +730,25 @@ class DebugWrapper { ...@@ -693,14 +730,25 @@ class DebugWrapper {
localCount : () => this.execStateFrameLocalCount(frame), localCount : () => this.execStateFrameLocalCount(frame),
localName : (ix) => this.execStateFrameLocalName(frame, ix), localName : (ix) => this.execStateFrameLocalName(frame, ix),
localValue: (ix) => this.execStateFrameLocalValue(frame, ix), localValue: (ix) => this.execStateFrameLocalValue(frame, ix),
receiver : () => this.evaluateOnCallFrame(frame, "this"), receiver : () => this.frameReceiver(frame),
restart : () => this.execStateFrameRestart(frame), restart : () => this.execStateFrameRestart(frame),
returnValue : () => this.frameReturnValue(frame),
scopeCount : () => frame.scopeChain.length, scopeCount : () => frame.scopeChain.length,
scope : (index) => this.execStateScope(frame, index), scope : (index) => this.execStateScope(frame, index),
allScopes : allScopes.bind(this) allScopes : allScopes.bind(this)
}; };
} }
execStateEvaluateGlobal(expr) {
const {msgid, msg} = this.createMessage(
"Runtime.evaluate", { expression : expr });
this.sendMessage(msg);
const reply = this.takeReplyChecked(msgid);
const result = reply.result.result;
return this.reconstructRemoteObject(result);
}
eventDataException(params) { eventDataException(params) {
switch (params.data.type) { switch (params.data.type) {
case "string": { case "string": {
...@@ -776,6 +824,8 @@ class DebugWrapper { ...@@ -776,6 +824,8 @@ class DebugWrapper {
// TODO(jgruber): Arguments as needed. // TODO(jgruber): Arguments as needed.
let execState = { frames : params.callFrames, let execState = { frames : params.callFrames,
prepareStep : this.execStatePrepareStep.bind(this), prepareStep : this.execStatePrepareStep.bind(this),
evaluateGlobal :
(expr) => this.execStateEvaluateGlobal(expr),
frame : (index) => this.execStateFrame( frame : (index) => this.execStateFrame(
index ? params.callFrames[index] index ? params.callFrames[index]
: params.callFrames[0]), : params.callFrames[0]),
......
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
// Simple function which stores the last debug event.
listenerComplete = false;
exception = false;
var breakpoint = -1;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
// Test some legal clearbreakpoint requests.
Debug.enableBreakPoint(breakpoint);
Debug.disableBreakPoint(breakpoint);
Debug.changeBreakPointCondition(breakpoint, "1==2");
Debug.changeBreakPointCondition(breakpoint, "false");
listenerComplete = true;
}
} catch (e) {
exception = e
};
};
// Add the debug event listener.
Debug.setListener(listener);
function g() {};
// Set a break point and call to invoke the debug event listener.
breakpoint = Debug.setBreakPoint(g, 0, 0);
g();
// Make sure that the debug event listener vas invoked.
assertTrue(listenerComplete, "listener did not run to completion");
assertFalse(exception, "exception in listener")
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
listenerComplete = false;
exception = false;
// Event listener which evaluates with break disabled.
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break)
{
// Call functions with break using the FrameMirror directly.
assertEquals(1, exec_state.evaluateGlobal('f()', true).value());
assertEquals(2, exec_state.evaluateGlobal('g()', true).value());
assertEquals(1, exec_state.frame(0).evaluate('f()', true).value());
assertEquals(2, exec_state.frame(0).evaluate('g()', true).value());
// Indicate that all was processed.
listenerComplete = true;
}
} catch (e) {
exception = e
};
};
// Event listener which evaluates with break enabled one time and the second
// time evaluates with break disabled.
var break_count = 0;
function listener_recurse(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break)
{
break_count++;
// Call functions with break using the FrameMirror directly.
if (break_count == 1) {
// First break event evaluates with break enabled.
assertEquals(1, exec_state.frame(0).evaluate('f()', false).value());
listenerComplete = true;
} else {
// Second break event evaluates with break disabled.
assertEquals(2, break_count);
assertFalse(listenerComplete);
assertEquals(1, exec_state.frame(0).evaluate('f()', true).value());
}
}
} catch (e) {
exception = e
};
};
// Add the debug event listener.
Debug.setListener(listener);
// Test functions - one with break point and one with debugger statement.
function f() {
return 1;
};
function g() {
debugger;
return 2;
};
Debug.setBreakPoint(f, 2, 0);
// Cause a debug break event.
debugger;
assertFalse(exception, "exception in listener")
// Make sure that the debug event listener vas invoked.
assertTrue(listenerComplete);
// Remove the debug event listener.
Debug.setListener(null);
// Set debug event listener wich uses recursive breaks.
Debug.setListener(listener_recurse);
listenerComplete = false;
Debug.setBreakPoint(f, 2, 0);
debugger;
assertFalse(exception, "exception in listener")
// Make sure that the debug event listener vas invoked.
assertTrue(listenerComplete);
assertEquals(2, break_count);
// Copyright 2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --noanalyze-environment-liveness
// Get the Debug object exposed from the debug context global object.
Debug = debug.Debug
function listener(event, exec_state, event_data, data) {
if (event !== Debug.DebugEvent.Break) return;
try {
var context = { what_is_capybara: "a fish" };
var context2 = { what_is_capybara: "a fish", what_is_parrot: "a beard" };
// Try in frame's scope.
var local_expression =
"(what_is_capybara ? what_is_capybara : 'a beast')" +
" + '/' + what_is_parrot";
var result = evaluate_callback.in_top_frame(
exec_state, local_expression, context);
assertEquals('a fish/a bird', result);
// Try in frame's scope with overrididen local variables.
var result = evaluate_callback.in_top_frame(
exec_state, local_expression, context2);
assertEquals('a fish/a beard', result);
// Try in frame's scope, without context.
var local_expression2 = "what_is_parrot";
var result = evaluate_callback.in_top_frame(
exec_state, local_expression2, void 0);
assertEquals('a bird', result);
// Try in global additional scope.
var global_expression = "what_is_capybara ? what_is_capybara : 'a beast'";
var result = evaluate_callback.globally(
exec_state, global_expression, context);
assertEquals('a fish', result);
// Try in global scope with overridden global variables.
var context_with_undefined = { undefined: 'kitten' };
var global_expression2 = "'cat' + '/' + undefined";
var result = evaluate_callback.globally(
exec_state, global_expression2, context_with_undefined);
assertEquals('cat/kitten', result);
// Try in global scope with no overridden global variables.
var result = evaluate_callback.globally(
exec_state, global_expression2, void 0);
assertEquals('cat/undefined', result);
// Try in global scope without additional context.
var global_expression3 = "'cat' + '/' + 'dog'";
var result = evaluate_callback.globally(
exec_state, global_expression3, void 0);
assertEquals('cat/dog', result);
listenerComplete = true;
} catch (e) {
exception = e
};
};
function f() {
var what_is_parrot = "a bird";
debugger;
};
function runF() {
exception = false;
listenerComplete = false;
Debug.setListener(listener);
// Add the debug event listener.
Debug.setListener(listener);
f();
assertFalse(exception, "exception in listener")
assertTrue(listenerComplete);
}
evaluate_callback = {
in_top_frame: function(exec_state, expression, additional_context) {
return exec_state.frame(0).evaluate(
expression, void 0, additional_context).value();
},
globally: function(exec_state, expression, additional_context) {
return exec_state.evaluateGlobal(
expression, void 0, additional_context).value();
},
};
runF();
...@@ -144,7 +144,6 @@ ...@@ -144,7 +144,6 @@
# Slow tests. # Slow tests.
'copy-on-write-assert': [PASS, SLOW], 'copy-on-write-assert': [PASS, SLOW],
'debug-scopes': [PASS, SLOW],
'numops-fuzz-part*': [PASS, ['mode == debug', SLOW]], 'numops-fuzz-part*': [PASS, ['mode == debug', SLOW]],
'readonly': [PASS, SLOW], 'readonly': [PASS, SLOW],
'regress/regress-1200351': [PASS, SLOW], 'regress/regress-1200351': [PASS, SLOW],
...@@ -206,10 +205,6 @@ ...@@ -206,10 +205,6 @@
'unicode-test': [SKIP], 'unicode-test': [SKIP],
'whitespaces': [SKIP], 'whitespaces': [SKIP],
# Async function tests taking too long
# https://bugs.chromium.org/p/v8/issues/detail?id=5411
'harmony/async-function-debug-scopes': [SKIP],
# TODO(mstarzinger): Takes too long with TF. # TODO(mstarzinger): Takes too long with TF.
'array-sort': [PASS, NO_VARIANTS], 'array-sort': [PASS, NO_VARIANTS],
'regress/regress-91008': [PASS, NO_VARIANTS], 'regress/regress-91008': [PASS, NO_VARIANTS],
...@@ -234,15 +229,9 @@ ...@@ -234,15 +229,9 @@
'regress/regress-446389': [PASS, SLOW], 'regress/regress-446389': [PASS, SLOW],
'regress/regress-inline-getter-near-stack-limit': [PASS, SLOW], 'regress/regress-inline-getter-near-stack-limit': [PASS, SLOW],
# BUG(v8:3097)
'debug-references': [SKIP],
# BUG(v8:4779): Crashes flakily with stress mode on arm64. # BUG(v8:4779): Crashes flakily with stress mode on arm64.
'array-splice': [PASS, SLOW, ['arch == arm64', FAST_VARIANTS]], 'array-splice': [PASS, SLOW, ['arch == arm64', FAST_VARIANTS]],
# BUG(chromium:664490)
'debug-scopes': [SKIP],
#BUG(v8:5683) #BUG(v8:5683)
'wasm/import-memory': [SKIP], 'wasm/import-memory': [SKIP],
}], # 'gc_stress == True' }], # 'gc_stress == True'
...@@ -304,7 +293,6 @@ ...@@ -304,7 +293,6 @@
'compiler/alloc-number': [PASS, SLOW], 'compiler/alloc-number': [PASS, SLOW],
'compiler/osr-assert': [PASS, SLOW], 'compiler/osr-assert': [PASS, SLOW],
'compiler/osr-with-args': [PASS, SLOW], 'compiler/osr-with-args': [PASS, SLOW],
'debug-scopes': [PASS, SLOW],
'generated-transition-stub': [PASS, SLOW], 'generated-transition-stub': [PASS, SLOW],
'json2': [PASS, SLOW], 'json2': [PASS, SLOW],
'math-floor-of-div-nosudiv': [PASS, SLOW], 'math-floor-of-div-nosudiv': [PASS, SLOW],
...@@ -374,7 +362,6 @@ ...@@ -374,7 +362,6 @@
# Slow tests which times out in debug mode. # Slow tests which times out in debug mode.
'try': [PASS, ['mode == debug', SKIP]], 'try': [PASS, ['mode == debug', SKIP]],
'debug-scripts-request': [PASS, ['mode == debug', SKIP]],
'array-constructor': [PASS, ['mode == debug', SKIP]], 'array-constructor': [PASS, ['mode == debug', SKIP]],
'regress/regress-1122': [PASS, SLOW, ['mode == debug and arch == android_arm', SKIP]], 'regress/regress-1122': [PASS, SLOW, ['mode == debug and arch == android_arm', SKIP]],
...@@ -418,7 +405,6 @@ ...@@ -418,7 +405,6 @@
# Slow tests which times out in debug mode. # Slow tests which times out in debug mode.
'try': [PASS, ['mode == debug', SKIP]], 'try': [PASS, ['mode == debug', SKIP]],
'debug-scripts-request': [PASS, ['mode == debug', SKIP]],
'array-constructor': [PASS, ['mode == debug', SKIP]], 'array-constructor': [PASS, ['mode == debug', SKIP]],
# Times out often in release mode on MIPS. # Times out often in release mode on MIPS.
...@@ -456,7 +442,6 @@ ...@@ -456,7 +442,6 @@
# Slow tests which times out in debug mode. # Slow tests which times out in debug mode.
'try': [PASS, ['mode == debug', SKIP]], 'try': [PASS, ['mode == debug', SKIP]],
'debug-scripts-request': [PASS, ['mode == debug', SKIP]],
'array-constructor': [PASS, ['mode == debug', SKIP]], 'array-constructor': [PASS, ['mode == debug', SKIP]],
# Times out often in release mode on MIPS. # Times out often in release mode on MIPS.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment