Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,55 @@
// Copyright 2013 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-gc
Debug = debug.Debug
function breakListener(event, exec_state, event_data, data) {
exec_state.prepareStep(Debug.StepAction.StepInto);
}
Debug.setListener(breakListener);
var o = {x:function() { return 10; }};
function f(o) {
var m = "x";
o[m]();
}
Debug.setBreakPoint(f, 2, 0);
f(o);
%NotifyContextDisposed();
function g() {
gc();
}
g();
Debug.setListener(null);

View File

@ -0,0 +1,56 @@
// Copyright 2012 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.
// Test that the break point is set before initializing the loop variable
// so that we break before any iteration has been run.
Debug = debug.Debug;
var break_hit = false;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
break_hit = true;
}
}
Debug.setListener(listener);
function test() {
for (var i = 0; i < 3; i++) { // Break here.
if (i == 0) break;
}
}
Debug.setBreakPoint(test, 1, 0);
assertTrue(Debug.showBreakPoints(test).indexOf("// Break here.") >= 0);
test();
assertTrue(break_hit);

View File

@ -0,0 +1,45 @@
// Copyright 2020 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.
var Debug = debug.Debug;
var frame;
Debug.setListener(function (event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
frame = exec_state.frame(0);
// Try changing the value, which hasn't yet been initialized.
assertEquals(3, frame.evaluate("result = 3").value());
assertEquals(3, frame.evaluate("result").value());
}
});
function makeCounter() {
// The debug-evaluate should be able to set this to 3. This was fixed with
// https://crbug.com/1246907 which delays debug breaks triggered by stack
// checks until the function context is properly set up.
assertEquals(3, result);
var result = 0;
// Regardless of how `result` is allocated, it should now be initialized.
assertEquals(0, result);
// Close over `result` to cause it to be heap-allocated.
return () => ++result;
}
// Break on entry to a function which includes heap-allocated variables.
%ScheduleBreak();
makeCounter();
// Check the frame state which was collected during the breakpoint.
assertEquals(1, frame.localCount());
assertEquals('result', frame.localName(0));
assertEquals(undefined, frame.localValue(0).value());
assertEquals(3, frame.scopeCount());
assertEquals(debug.ScopeType.Local, frame.scope(0).scopeType());
assertEquals(debug.ScopeType.Script, frame.scope(1).scopeType());
assertEquals(debug.ScopeType.Global, frame.scope(2).scopeType());

View File

@ -0,0 +1,72 @@
// 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.
Debug = debug.Debug
// Make sure that the backtrace command can be processed when the receiver is
// undefined.
let listenerCalled = false;
let exceptionThrown = false;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Exception) {
// The expected backtrace is
// 1: g
// 0: [anonymous]
assertEquals(2, exec_state.frameCount());
assertEquals("g", exec_state.frame(0).func().name());
assertEquals("", exec_state.frame(1).func().name());
listenerCalled = true;
}
} catch (e) {
print(e);
exceptionThrown = true;
};
};
// Add the debug event listener.
Debug.setListener(listener);
// Call method on undefined.
function g() {
(void 0).f();
};
// Break on the exception to do a backtrace with undefined as receiver.
Debug.setBreakOnException(true);
try {
g();
} catch(e) {
// Ignore the exception "Cannot call method 'x' of undefined"
}
assertFalse(exceptionThrown, "exception in listener");
// Make sure that the debug event listener vas invoked.
assertTrue(listenerCalled, "listener not called");

View File

@ -0,0 +1,65 @@
// Copyright 2012 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.
var Debug = debug.Debug;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
for (var i = 0, n = exec_state.frameCount(); i < n; i++) {
exec_state.frame().scopeCount(i);
}
exec_state.prepareStep(Debug.StepAction.StepOver);
}
Debug.setListener(listener);
var F = function () {
1, function () {
var d = 0;
(function () { d; });
debugger;
}();
};
var src = "(" + F.toString() + ")()";
eval(src);
Function.prototype.__defineGetter__("f", function () {
debugger;
return 0;
});
var G = function () {
1, function () {
var d = 0;
(function () { d; });
debugger;
}['f'];
};
var src = "(" + G.toString() + ")()";
eval(src);

View File

@ -0,0 +1,86 @@
// 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.
// Make sure that the retreival of local variables are performed correctly even
// when an adapter frame is present.
Debug = debug.Debug
let listenerCalled = false;
let exceptionThrown = false;
function checkName(name) {
const validNames = new Set([ 'a', 'b', 'c', 'x', 'y' ]);
assertTrue(validNames.has(name));
}
function checkValue(value) {
assertEquals(void 0, value);
}
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
var local0Name = exec_state.frame(0).localName(0);
var local1Name = exec_state.frame(0).localName(1);
var local2Name = exec_state.frame(0).localName(2);
checkName(local0Name);
checkName(local1Name);
checkName(local2Name);
var local0Value = exec_state.frame(0).localValue(0).value();
var local1Value = exec_state.frame(0).localValue(1).value();
var local2Value = exec_state.frame(0).localValue(2).value();
checkValue(local0Value);
checkValue(local1Value);
checkValue(local2Value);
listenerCalled = true;
}
} catch (e) {
exceptionThrown = true;
};
};
// Add the debug event listener.
Debug.setListener(listener);
// Call a function with local variables passing a different number parameters
// that the number of arguments.
(function(x,y){
var a,b,c;
// Make sure a, b, and c are used.
a,b,c;
debugger;
return 3
})()
// Make sure that the debug event listener vas invoked (again).
assertTrue(listenerCalled);
assertFalse(exceptionThrown, "exception in listener")

View File

@ -0,0 +1,66 @@
// Copyright 2012 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.
Debug = debug.Debug;
var exceptionThrown = false;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
function lookup(name) {
return exec_state.frame(0).evaluate(name).value();
}
assertEquals(3, lookup("e"));
assertEquals(4, lookup("f"));
assertEquals(1, lookup("a"));
assertThrows(() => lookup("b"), ReferenceError);
}
} catch (e) {
exceptionThrown = true;
}
}
Debug.setListener(listener);
function f(a, b) {
var c = 3;
function d(e, f) {
var g = a;
var h = c;
debugger;
}
return d;
}
f(1, 2)(3, 4);
assertFalse(exceptionThrown);

View File

@ -0,0 +1,70 @@
// Copyright 2012 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: --noanalyze-environment-liveness
// Test that a variable in the local scope that shadows a context-allocated
// variable is correctly resolved when being evaluated in the debugger.
Debug = debug.Debug;
var exceptionThrown = false;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
var breakpoint = exec_state.frame(0);
try {
// Assert correct break point.
assertTrue(breakpoint.sourceLineText().indexOf("// Break") > -1);
// Assert correct value.
assertEquals(3, breakpoint.evaluate('x').value());
} catch (e) {
exceptionThrown = true;
}
}
Debug.setListener(listener);
function h() {
var x; // Context-allocated due to g().
var g = function g() {
x = -7;
};
var f = function f() {
var x = 3; // Allocated in the local scope.
debugger; // Break.
};
f();
}
h();
assertFalse(exceptionThrown);

View File

@ -0,0 +1,44 @@
// Copyright 2013 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.
Debug = debug.Debug;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
exec_state.prepareStep(Debug.StepAction.StepOver);
}
};
Debug.setListener(listener);
var statement = "";
for (var i = 0; i < 1024; i++) statement += "z";
statement = 'with(0)' + statement + '=function foo(){}';
debugger;
eval(statement);

View File

@ -0,0 +1,67 @@
// Copyright 2011 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.
// See: http://code.google.com/p/v8/issues/detail?id=1523
Debug = debug.Debug
var listenerCalled = false;
var result = -1;
function listener(event, exec_state, event_data, data) {
listenerCalled = true;
};
// Add the debug event listener.
Debug.setListener(listener);
function test_and(x) {
if (x && (bar === this.baz))
return 0;
return 1;
}
function test_or(x) {
if (x || (bar === this.baz))
return 0;
return 1;
}
// Set a break points and call each function to invoke the debug event listener.
Debug.setBreakPoint(test_and, 0, 0);
Debug.setBreakPoint(test_or, 0, 0);
listenerCalled = false;
result = test_and(false);
assertEquals(1, result);
assertTrue(listenerCalled);
listenerCalled = false;
result = test_or(true);
assertEquals(0, result);
assertTrue(listenerCalled);

View File

@ -0,0 +1,64 @@
// Copyright 2011 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.
// Test debug evaluation for functions without local context, but with
// nested catch contexts.
function f() {
var i = 1; // Line 1.
{ // Line 2.
try { // Line 3.
throw 'stuff'; // Line 4.
} catch (e) { // Line 5.
x = 2; // Line 6.
}
}
};
Debug = debug.Debug
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
result = exec_state.frame().evaluate("i").value();
}
};
// Add the debug event listener.
Debug.setListener(listener);
//Set breakpoint on line 6.
var bp = Debug.setBreakPoint(f, 6);
result = -1;
f();
assertEquals(1, result);
// Clear breakpoint.
Debug.clearBreakPoint(bp);
// Get rid of the debug event listener.
Debug.setListener(null);

View File

@ -0,0 +1,75 @@
// Copyright 2012 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.
Debug = debug.Debug
var breaks = 0;
var exceptionThrown = false;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
var line = event_data.sourceLineText();
print('break: ' + line);
assertEquals(-1, line.indexOf('NOBREAK'),
"should not break on unexpected lines")
assertEquals('BREAK ' + breaks, line.substr(-7));
breaks++;
if (breaks < 4) exec_state.prepareStep(Debug.StepAction.StepOver);
}
} catch (e) {
print(e);
exceptionThrown = true;
}
}
// Add the debug event listener.
Debug.setListener(listener);
function a(f) {
if (f) { // NOBREAK: should not break here!
try {
f();
} catch(e) {
}
}
} // BREAK 2
function b() {
c(); // BREAK 0
} // BREAK 1
function c() {
a();
}
// Set a break point and call to invoke the debug event listener.
Debug.setBreakPoint(b, 0, 0);
a(b);
a(); // BREAK 3
assertFalse(exceptionThrown);

View File

@ -0,0 +1,43 @@
// Copyright 2012 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.
Debug = debug.Debug
function listener(event, exec_state, event_data, data) {
try {
event_data.script().setSource(1);
} catch (e) {
assertTrue(String(e).indexOf("Source is not a string") > 0);
}
};
Debug.setListener(listener);
eval('0');
Debug.setListener(null);

View File

@ -0,0 +1,47 @@
// 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.
Debug = debug.Debug
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
exec_state.prepareStep(Debug.StepAction.StepInto);
}
};
// Add the debug event listener.
Debug.setListener(listener);
function g() {
}
function f() {
debugger;
g.apply(null, ['']);
}
f()

View File

@ -0,0 +1,39 @@
// 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.
// Do not edit this file with an editor that replaces \r with \r\n.
// Variable definitions for i0 through i3 are each terminated with \r.
function f() {
var i0 = 0;
var i1 = 1;
var i2 = 2;
var i3 = 3;
var j0 = 0;
var j1 = 1;
var j2 = 2;
var j3 = 3;
}
Debug = debug.Debug;
var exception = null;
var break_point_hit = false;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
break_point_hit = true;
assertEquals(" var i2 = 2;", exec_state.frame(0).sourceLineText());
} catch (e) {
print(e + e.stack);
exception = e;
}
}
Debug.setListener(listener);
Debug.setBreakPoint(f, 3, 0);
f();

View File

@ -0,0 +1,68 @@
// Copyright 2013 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.
// If a function parameter is forced to be context allocated,
// debug evaluate need to resolve it to a context slot instead of
// parameter slot on the stack.
var Debug = debug.Debug;
var expected;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals(expected, exec_state.frame(0).evaluate('arg').value());
exec_state.frame(0).evaluate('arg = "evaluated";'); // no effect
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
function f(arg) {
expected = arg;
debugger;
assertEquals("evaluated", arg);
arg = "value";
expected = arg;
debugger;
assertEquals("evaluated", arg);
// Forces arg to be context allocated even though a parameter.
function g() { arg; }
}
f();
f(1);
f(1, 2);
assertNull(exception);

View File

@ -0,0 +1,33 @@
// Copyright 2014 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.
// Flags: --no-lazy
Debug = debug.Debug;
var exception = null;
var break_count = 0;
function f() {
function g(p) {
return 1;
}
g(1);
};
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) break_count++;
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
var bp = Debug.setBreakPoint(f, 2);
f();
Debug.clearBreakPoint(bp);
Debug.setListener(null);
assertEquals(1, break_count);
assertNull(exception);

View File

@ -0,0 +1,66 @@
// Copyright 2014 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.
Debug = debug.Debug;
function dummy(x) {
return x + 100;
}
function create_closure() {
var f = function(arg) {
if (arg) { %DeoptimizeFunction(f); }
var a = Array(10);
for (var i = 0; i < a.length; i++) {
a[i] = i;
}
}
return f;
}
var c = create_closure();
c();
// c CallIC state now has custom Array handler installed.
// Turn on the debugger.
Debug.setListener(function () {});
var d = create_closure();
%PrepareFunctionForOptimization(d);
%OptimizeFunctionOnNextCall(d);
// Thanks to the debugger, we recreate the full code too. We deopt and run
// it, stomping on the unexpected AllocationSite in the type vector slot.
d(true);
// CallIC in c misinterprets type vector slot contents as an AllocationSite,
// corrupting the heap.
c();
// CallIC MISS - crash due to corruption.
dummy();

View File

@ -0,0 +1,38 @@
// 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.
var Debug = debug.Debug;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var scopes = exec_state.frame().allScopes();
assertEquals(3, scopes.length);
assertEquals(debug.ScopeType.Local, scopes[0].scopeType());
assertEquals(debug.ScopeType.Script, scopes[1].scopeType());
assertEquals(debug.ScopeType.Global, scopes[2].scopeType());
} catch (e) {
exception = e;
}
}
function f() {
eval('');
debugger;
}
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
Debug.setListener(listener);
f();
assertNull(exception);

View File

@ -0,0 +1,35 @@
// 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.
var Debug = debug.Debug;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var scope = exec_state.frame().scope(0);
assertEquals(5, scope.scopeObject().property("i").value().value());
} catch (e) {
exception = e;
}
}
function f() {
eval('var i = 5');
debugger;
}
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
Debug.setListener(listener);
f();
assertNull(exception);

View File

@ -0,0 +1,40 @@
// 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.
var Debug = debug.Debug;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var scopes = exec_state.frame().allScopes();
assertEquals(4, scopes.length);
assertEquals(debug.ScopeType.With, scopes[0].scopeType());
assertEquals(debug.ScopeType.Local, scopes[1].scopeType());
assertEquals(debug.ScopeType.Script, scopes[2].scopeType());
assertEquals(debug.ScopeType.Global, scopes[3].scopeType());
} catch (e) {
exception = e;
}
}
function f() {
with({}) {
debugger;
}
}
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
Debug.setListener(listener);
f();
assertNull(exception);

View File

@ -0,0 +1,21 @@
// 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.
var Debug = debug.Debug;
function f() { g(); }
function g() { }
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
f();
Debug.setListener(function() {});
Debug.setBreakPoint(g, 0);
f();

View File

@ -0,0 +1,35 @@
// 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.
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != debug.Debug.DebugEvent.Break) return;
try {
var all_scopes = exec_state.frame().allScopes();
assertEquals([ debug.ScopeType.Block,
debug.ScopeType.Local,
debug.ScopeType.Script,
debug.ScopeType.Global ],
all_scopes.map(scope => scope.scopeType()));
} catch (e) {
exception = e;
print(e);
}
}
debug.Debug.setListener(listener);
(function(arg, ...rest) {
var one = 1;
function inner() {
one;
arg;
}
debugger;
})();
debug.Debug.setListener(null);
assertNull(exception);

View File

@ -0,0 +1,9 @@
// 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.
if (this["debug"]) debug.Debug.setListener(function() {});
var source = "var outer = 0; function test() {'use strict'; outer = 1; } test(); print('ok');";
function test_function() { eval(source); }
assertDoesNotThrow(test_function);

View File

@ -0,0 +1,34 @@
// 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.
//
// Flags: --noanalyze-environment-liveness
var Debug = debug.Debug;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals(2, exec_state.frameCount());
assertEquals("a", exec_state.frame(0).localName(0));
assertEquals(1, exec_state.frame(0).localValue(0).value());
assertEquals(1, exec_state.frame(0).localCount());
} catch (e) {
exception = e;
}
}
function f() {
var a = 1;
{
let b = 2;
debugger;
}
}
Debug.setListener(listener);
f();
Debug.setListener(null);
assertNull(exception);

View File

@ -0,0 +1,21 @@
// 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.
function bar(x) { debugger; }
function foo() { bar(arguments[0]); }
function wrap() { return foo(1); }
%PrepareFunctionForOptimization(wrap);
wrap();
wrap();
%OptimizeFunctionOnNextCall(wrap);
var Debug = debug.Debug;
Debug.setListener(function(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
for (var i = 0; i < exec_state.frameCount(); i++) exec_state.frame(i);
});
wrap();

View File

@ -0,0 +1,43 @@
// 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.
//
var failure = null;
var args;
function listener(event, exec_state, event_data, data) {
if (event != debug.Debug.DebugEvent.Break) return;
try {
args = exec_state.frame(0).evaluate('arguments').value();
} catch (e) {
failure = e;
}
}
debug.Debug.setListener(listener);
function* gen(a, b) {
debugger;
yield a;
yield b;
}
var foo = gen(1, 2);
foo.next()
assertEquals(2, args.length);
assertEquals(1, args[0]);
assertEquals(2, args[1]);
foo.next()
assertEquals(2, args.length);
assertEquals(1, args[0]);
assertEquals(2, args[1]);
foo.next()
assertEquals(2, args.length);
assertEquals(1, args[0]);
assertEquals(2, args[1]);
assertNull(failure);

View File

@ -0,0 +1,20 @@
// 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.
var Debug = debug.Debug;
Debug.setListener(() => undefined);
function f() {
const myObj = {};
for (let i = 0; i < 10; i++) {
%OptimizeOsr();
%ScheduleBreak();
%PrepareFunctionForOptimization(f);
}
}
%PrepareFunctionForOptimization(f);
f()

View File

@ -0,0 +1,37 @@
// 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 = debug.Debug
var exception = null;
var break_count = 0;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
print(event_data.sourceLineText());
assertTrue(
event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0);
exec_state.prepareStep(Debug.StepAction.StepOut);
} catch (e) {
exception = e;
}
};
function thrower() {
try {
debugger; // Break 0.
throw 'error';
} catch (err) {
}
}
Debug.setListener(listener);
thrower();
Debug.setListener(null); // Break 1.
assertNull(exception);
assertEquals(2, break_count);

View File

@ -0,0 +1,29 @@
// 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.
// Flags: --invoke-weak-callbacks --omit-quit --gc-interval=355
var __v_33 = {};
__v_4 = 70000;
function __f_18() {
if ((__v_7 % 50) != 0) {
} else {
return __v_33 + 0.5;
}
}
function __f_17(a) {
for (var __v_7= 0; __v_7 < __v_4; ++__v_7 ) {
a[__v_7] = __f_18();
}
}
for (var __v_7= 0; __v_7 < __v_4; __v_7 += 500 ) {
}
__v_9 = new Array();
__f_17(__v_9);
__v_9.length = 100;
Debug = debug.Debug
function __f_26() {
}
__v_29 = "(function() {\
})()";

View File

@ -0,0 +1,14 @@
// 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.
// Flags: --stack-size=100
Debug = debug.Debug
function overflow() {
return overflow();
}
Debug.setBreakOnException();
assertThrows(overflow, RangeError);

View File

@ -0,0 +1,16 @@
// 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.
// Flags: --ignore-unhandled-promises
Debug = debug.Debug
function overflow() {
return new Promise(function foo() { foo() });
}
function listener(event, exec_state, event_data, data) { }
Debug.setListener(listener);
assertEquals(Promise, overflow().constructor);

View File

@ -0,0 +1,22 @@
// Copyright 2019 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.
// Flags: --expose-gc --stress-flush-code --flush-bytecode
var Debug = debug.Debug
var bp;
Debug.setListener(function (event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
Debug.clearBreakPoint(bp);
gc();
}
});
function f() {
(function () {})();
}
bp = Debug.setBreakPoint(f, 0, 0);
f();

View File

@ -0,0 +1,68 @@
// Copyright 2012 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.
Debug = debug.Debug;
Debug.setListener(listener);
var exception = null;
var fourteen;
var four_in_debugger = [];
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
try {
for (var i = 0; i < exec_state.frameCount() - 1; i++) {
var frame = exec_state.frame(i);
four_in_debugger[i] = frame.evaluate("four", false).value();
}
} catch (e) {
exception = e;
}
}
}
function f1() {
var three = 3;
var four = 4;
(function f2() {
var seven = 7;
(function f3() {
debugger;
fourteen = three + four + seven;
})();
})();
}
f1();
assertEquals(14, fourteen);
assertEquals(4, four_in_debugger[0]);
assertEquals(4, four_in_debugger[1]);
assertEquals(4, four_in_debugger[2]);
Debug.setListener(null);
assertNull(exception);

View File

@ -0,0 +1,37 @@
// 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.
function f() {
print(1);
print(2);
print(3);
}
var Debug = debug.Debug;
var exception = null;
var breaks = [];
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
Debug.debuggerFlags().breakPointsActive.setValue(false);
breaks.push(exec_state.frame().sourceLineText().trimLeft());
exec_state.prepareStep(Debug.StepAction.StepInto);
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
Debug.setBreakPoint(f, 0, 0);
f();
Debug.setListener(null);
Debug.debuggerFlags().breakPointsActive.setValue(true);
assertNull(exception);
assertEquals(breaks, ["print(1);", "print(2);", "print(3);", "}",
"Debug.setListener(null);"]);

View File

@ -0,0 +1,20 @@
// Copyright 2022 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.
// Flags: --always-sparkplug
var Debug = debug.Debug;
Debug.setListener(function (event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
Debug.setListener(null);
Debug.stepInto();
}
});
%ScheduleBreak();
(function foo() {
const x = 5;
() => x; // context-allocate x.
})();

View File

@ -0,0 +1,87 @@
// Copyright 2013 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: --no-always-turbofan
Debug = debug.Debug
var error = null;
var test = 0;
function check_v(expected, exec_state, frame_id) {
assertEquals(expected, exec_state.frame(frame_id).evaluate('v').value());
}
function listener(event, exec_state, event_data, data) {
try {
if (event != Debug.DebugEvent.Break) return;
test++;
if (test == 1) {
check_v('inner0', exec_state, 0);
check_v('inner0', exec_state, 1);
check_v('outer', exec_state, 2);
assertArrayEquals(["a", "b", "c"],
exec_state.frame(0).evaluate('arguments').value());
} else if (test == 2) {
check_v('inner1', exec_state, 0);
check_v('inner1', exec_state, 1);
check_v('outer', exec_state, 2);
assertArrayEquals(["a", "b", "c"],
exec_state.frame(0).evaluate('arguments').value());
} else {
assertEquals(3, test);
check_v('inner2', exec_state, 0);
check_v('inner1', exec_state, 1);
check_v('inner1', exec_state, 2);
check_v('outer', exec_state, 3);
assertArrayEquals(["x", "y", "z"],
exec_state.frame(0).evaluate('arguments').value());
assertArrayEquals(["a", "b", "c"],
exec_state.frame(1).evaluate('arguments').value());
}
} catch (e) {
error = e;
}
};
Debug.setListener(listener);
var v = 'outer';
(function() { // Test 1 and 2
var v = 'inner0';
eval("debugger; var v = 'inner1'; debugger;");
assertEquals('inner1', v); // Overwritten by local eval.
})("a", "b", "c");
assertNull(error);
(function() { // Test 3
var v = 'inner0'; // Local eval overwrites this value.
eval("var v = 'inner1'; " +
"(function() { var v = 'inner2'; debugger; })('x', 'y', 'z');");
assertEquals('inner1', v); // Overwritten by local eval.
})("a", "b", "c");
assertNull(error);

View File

@ -0,0 +1,85 @@
// Copyright 2013 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: --noanalyze-environment-liveness
Debug = debug.Debug
var error = null;
var array = ["a", "b", "c"];
var result = null;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
result = exec_state.frame(0).evaluate('arguments').value();
}
} catch (e) {
error = e;
}
};
Debug.setListener(listener);
function f(a, b) {
arguments;
debugger; // Arguments object is already materialized.
}
result = null;
f.apply(this, array);
assertArrayEquals(array, result);
result = null;
f("a", "b", "c");
assertArrayEquals(array, result);
assertNull(error);
function g(a, b) {
debugger; // Arguments object is not yet materialized.
}
result = null;
g.apply(this, array);
assertArrayEquals(array, result);
result = null;
g("a", "b", "c");
assertArrayEquals(array, result);
assertNull(error);
function h(a, b) {
var arguments = undefined;
debugger; // Arguments already used as local variable.
}
result = null;
h.apply(this, array);
assertEquals(undefined, result);
result = null;
h("a", "b", "c");
assertEquals(undefined, result);
assertNull(error);

View File

@ -0,0 +1,57 @@
// Copyright 2014 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.
// Flags: --no-always-turbofan
Debug = debug.Debug;
var step = 0;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
if (step == 0) {
assertEquals("error", exec_state.frame(0).evaluate("e").value());
exec_state.frame(0).evaluate("write_0('foo')");
exec_state.frame(0).evaluate("write_1('modified')");
} else {
assertEquals("argument", exec_state.frame(0).evaluate("e").value());
exec_state.frame(0).evaluate("write_2('bar')");
}
step++;
} catch (e) {
print(e + e.stack);
exception = e;
}
}
Debug.setListener(listener);
function f(e, x) {
try {
throw "error";
} catch(e) {
// In ES2015 hoisting semantics, 'x' binds to the argument
// and 'e' binds to the exception.
function write_0(v) { e = v }
function write_1(v) { x = v }
// Make sure write_0 and write_1 are 'used' so that they are visible to the
// debugger.
write_0, write_1;
debugger;
assertEquals("foo", e); // overwritten by the debugger
}
assertEquals("argument", e); // debugger did not overwrite
function write_2(v) { e = v }
// Make sure write_2 is 'used' so that it is visible to the debugger.
write_2;
debugger;
assertEquals("bar", e);
assertEquals("modified", x);
}
f("argument")
assertNull(exception);
assertEquals(2, step);

View File

@ -0,0 +1,21 @@
// Copyright 2014 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 = debug.Debug;
Debug.setListener(function() {});
function f() {
for (var i = 0; i < 100; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f);
}
}
%PrepareFunctionForOptimization(f);
Debug.setBreakPoint(f, 0, 0);
f();
%PrepareFunctionForOptimization(f);
f();
Debug.setListener(null);

View File

@ -0,0 +1,29 @@
// Copyright 2014 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 = debug.Debug
var exception = null;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
exec_state.prepareStep(Debug.StepAction.StepInto);
}
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
function f(x) {
if (x > 0) %Call(f, null, x-1);
}
debugger;
f(2);
Debug.setListener(null);
assertNull(exception);

View File

@ -0,0 +1,36 @@
// Copyright 2014 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 = debug.Debug;
var exception = null;
var error_count = 0;
function f() {
return 0; // Break
} // Break
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
if (exec_state.frame(0).sourceLineText().indexOf("Break") <0) {
error_count++;
}
exec_state.prepareStep(Debug.StepAction.StepInto);
f(); // We should not break in this call of f().
} catch (e) {
print(e + e.stack);
exception = e;
}
}
Debug.setListener(listener);
debugger; // Break
f(); // Break
Debug.setListener(null); // Break
assertNull(exception);
assertEquals(0, error_count);

View File

@ -0,0 +1,56 @@
// Copyright 2014 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.
function f() {
var a = 1;
var b = 2;
return a + b;
}
var exception = null;
var break_count = 0;
var throw_count = 0;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
break_count++;
// Disable all breakpoints from within the debug event callback.
Debug.debuggerFlags().breakPointsActive.setValue(false);
} else if (event = Debug.DebugEvent.Exception) {
throw_count++;
// Enable all breakpoints from within the debug event callback.
Debug.debuggerFlags().breakPointsActive.setValue(true);
}
} catch (e) {
exception = e;
}
}
Debug = debug.Debug;
Debug.setListener(listener);
Debug.setBreakOnException();
Debug.setBreakPoint(f, 2);
f();
f();
assertEquals(1, break_count);
assertEquals(0, throw_count);
// Trigger exception event.
try { throw 1; } catch (e) {}
f();
f();
Debug.setListener(null);
Debug.clearBreakOnException();
Debug.debuggerFlags().breakPointsActive.setValue(true);
assertEquals(2, break_count);
assertEquals(1, throw_count);
assertNull(exception);

View File

@ -0,0 +1,54 @@
// 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.
// Flags: --noturbo-inlining
var stdlib = this;
var buffer = new ArrayBuffer(64 * 1024);
var foreign = { thrower: thrower, debugme: debugme }
Debug = debug.Debug;
var listenerCalled = false;
function listener(event, exec_state, event_data, data) {
try {
if (event == Debug.DebugEvent.Break) {
var frame = exec_state.frame(1);
assertEquals("foo", frame.func().name());
listenerCalled = true;
}
} catch (e) {
print("Caught: " + e + " " + e.stack);
};
}
function thrower() { throw "boom"; }
function debugme() { Debug.setListener(listener); debugger; }
function Module(stdlib, foreign, heap) {
"use asm";
var thrower = foreign.thrower;
var debugme = foreign.debugme;
function foo(i) {
i = i|0;
var a = 101; // Local variables exist ...
var b = 102; // ... to make the debugger ...
var c = 103; // ... inspect them during break.
if (i > 0) {
debugme();
i = 23;
} else {
thrower();
i = 42;
}
return i|0;
}
return { foo: foo };
}
var m = Module(stdlib, foreign, buffer);
assertThrows("m.foo(0)");
assertEquals(23, m.foo(1));
assertTrue(listenerCalled);

View File

@ -0,0 +1,40 @@
// 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.
function f() {
for (var i = 10; i < 14; i++) { // 1
i *= 1; // 2
}
} // 3
var state = "conditional";
var log = [];
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var label = +exec_state.frame(0).sourceLineText().substr(-1);
log.push(label);
if (label == 2) log.push(exec_state.frame(0).evaluate("i").value());
exec_state.prepareStep(Debug.StepAction.StepOver);
} catch (e) {
exception = e;
print("Caught something. " + e + " " + e.stack);
};
};
var Debug = debug.Debug;
Debug.setListener(listener);
Debug.setBreakPoint(f, 2, 0, "i == 12");
f();
Debug.setListener(null); // 4
assertEquals([2,12,1,1,2,13,1,1,3,4], log);
assertNull(exception);

View File

@ -0,0 +1,19 @@
// 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.
var Debug = debug.Debug;
var receiver = null;
Debug.setListener(function(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
receiver = exec_state.frame(0).evaluate('this').value();
});
function f() { debugger; }
var expected = {};
f.call(expected);
assertEquals(expected, receiver);

View File

@ -0,0 +1,24 @@
// 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.
var Debug = debug.Debug;
var receiver = null;
Debug.setListener(function(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
receiver = exec_state.frame(0).evaluate('this').value();
});
function f() {
var context_local = 1;
(function() { return context_local; })();
debugger;
}
var expected = {};
f.call(expected);
assertEquals(expected, receiver);

View File

@ -0,0 +1,56 @@
// 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.
// Flags: --ignore-unhandled-promises
var Debug = debug.Debug;
var expected = ["debugger;", "var x = y;", "debugger;", "var x = y;"];
var log = [];
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var line = exec_state.frame(0).sourceLineText().trimLeft();
log.push(line);
if (line == "debugger;") exec_state.prepareStep(Debug.StepAction.StepOver);
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
}
Debug.setListener(listener);
function f() {
var a = 1;
debugger;
var x = y;
print(x);
}
function call_f_with_deeper_stack() {
(() => () => () => f())()()();
}
Promise.resolve().then(f).catch(call_f_with_deeper_stack);
// Schedule microtask to check against expectation at the end.
function testDone(iteration) {
function checkResult() {
try {
assertTrue(iteration < 10);
if (expected.length == log.length) {
assertEquals(expected, log);
} else {
testDone(iteration + 1);
}
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
}
%EnqueueMicrotask(checkResult);
}
testDone(0);

View File

@ -0,0 +1,38 @@
// 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.
// Flags: --ignore-unhandled-promises
var Debug = debug.Debug;
var expected = ["debugger;",
"var x = y;",
"debugger;",
"var x = y;"];
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var line = exec_state.frame(0).sourceLineText().trimLeft();
assertEquals(expected.shift(), line);
if (line == "debugger;") exec_state.prepareStep(Debug.StepAction.StepOver);
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
}
Debug.setListener(listener);
function f() {
var a = 1;
debugger;
var x = y;
print(x);
}
function call_f_with_deeper_stack() {
(() => () => () => f())()()();
}
new Promise(f).catch(call_f_with_deeper_stack);
var a = 1;

View File

@ -0,0 +1,57 @@
// 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.
// Flags: --ignore-unhandled-promises
var Debug = debug.Debug;
var expected = ["debugger;", "var x = y;", "debugger;", "var x = y;"];
var log = [];
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var line = exec_state.frame(0).sourceLineText().trimLeft();
log.push(line);
if (line == "debugger;") exec_state.prepareStep(Debug.StepAction.StepOver);
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
}
Debug.setListener(listener);
function f() {
var a = 1;
debugger;
var x = y;
print(x);
}
function call_f_with_deeper_stack() {
(() => () => () => f())()()();
}
var p = Promise.resolve();
p.then(f);
p.then(call_f_with_deeper_stack);
// Schedule microtask to check against expectation at the end.
function testDone(iteration) {
function checkResult() {
try {
assertTrue(iteration < 10);
if (expected.length == log.length) {
assertEquals(expected, log);
} else {
testDone(iteration + 1);
}
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
}
%EnqueueMicrotask(checkResult);
}
testDone(0);

View File

@ -0,0 +1,38 @@
// 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.
var Debug = debug.Debug;
var expected = ["debugger;", "var x = y;"];
var log = [];
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var line = exec_state.frame(0).sourceLineText().trimLeft();
log.push(line);
if (line == "debugger;") exec_state.prepareStep(Debug.StepAction.StepOver);
} catch (e) {
%AbortJS(e + "\n" + e.stack);
}
}
Debug.setListener(listener);
function f() {
var a = 1;
debugger;
var x = y;
print(x);
}
try {
%Call(f, {});
} catch (e) {
var b = 2;
}
Debug.setListener(null);
assertEquals(expected, log);

View File

@ -0,0 +1,30 @@
// 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.
var Debug = debug.Debug;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
var frame_count = exec_state.frameCount();
for (var i = 0; i < frame_count; i++) {
var frame = exec_state.frame(i);
var scope_count = frame.scopeCount();
for (var j = 0; j < scope_count; j++) {
var scope = frame.scope(j);
assertTrue(scope.scopeObject().property('').isUndefined());
}
}
} catch (e) {
print(e, e.stack);
exception = e;
}
}
Debug.setListener(listener);
(function(a = 1) { debugger; })();
Debug.setListener(null);

View File

@ -0,0 +1,43 @@
// 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.
var test_y = false;
function foo(a = 1) {
var x = 2;
debugger;
eval("var y = 3");
test_y = true;
debugger;
}
var exception = null;
var break_count = 0;
var Debug = debug.Debug;
var ScopeType = debug.ScopeType;
function listener(event, exec_state) {
if (event != Debug.DebugEvent.Break) return;
try {
var scopes = exec_state.frame(0).allScopes();
var expectation = [ ScopeType.Block,
ScopeType.Local,
ScopeType.Script,
ScopeType.Global ];
assertEquals(expectation, scopes.map(x => x.scopeType()));
assertEquals(2, scopes[0].scopeObject().value().x);
if (test_y) assertEquals(3, scopes[0].scopeObject().value().y);
assertEquals(1, scopes[1].scopeObject().value().a);
break_count++;
} catch (e) {
print(e);
exception = e;
}
}
Debug.setListener(listener);
foo();
assertNull(exception);
assertEquals(2, break_count);

View File

@ -0,0 +1,27 @@
// 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.
var Debug = debug.Debug;
var exception = null;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertThrows(() => exec_state.frame(0).evaluate("bar.baz"), ReferenceError);
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
(function() {
debugger; // bar is still in TDZ at this point.
let bar = 1;
(x => bar); // force bar to be context-allocated.
})();
Debug.setListener(null);
assertNull(exception);

View File

@ -0,0 +1,35 @@
// 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.
// Test that hidden scopes are correctly walked in the scope chain.
var Debug = debug.Debug;
var exception = null;
var delegate = null;
var done = false;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals([ debug.ScopeType.Block,
debug.ScopeType.Script,
debug.ScopeType.Global ],
exec_state.frame(0).allScopes().map(s => s.scopeType()));
done = true;
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
for(let a = 0; a < 3; a++) {
debugger;
eval(); // Force context-allocation of everything.
}
Debug.setListener(null);
assertNull(exception);
assertTrue(done);

View File

@ -0,0 +1,39 @@
// 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.
var Debug = debug.Debug;
var steps = 0;
var exception = null;
function listener(event, execState, eventData, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals([ debug.ScopeType.Local,
debug.ScopeType.Script,
debug.ScopeType.Global],
execState.frame().allScopes().map(s => s.scopeType()));
var x_value = execState.frame().evaluate("String(x)").value();
if (steps < 2) {
assertEquals("undefined", x_value);
execState.prepareStep(Debug.StepAction.StepInto);
} else {
assertEquals("l => l", x_value);
}
steps++;
} catch (e) {
exception = e;
}
}
Debug.setListener(listener);
(function() {
debugger;
var x = l => l;
})();
Debug.setListener(null);
assertNull(exception);
assertEquals(3, steps);

View File

@ -0,0 +1,41 @@
// 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.
// Flags: --turbofan --no-turbo
var Debug = debug.Debug
var exception = null;
var step = 0;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Exception) return;
try {
step++;
} catch (e) {
exception = e;
}
}
Debug.setBreakOnException();
Debug.setListener(listener);
(function () {
"use asm";
function f() {
try {
throw 666;
} catch (e) {
}
}
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
f();
assertOptimized(f);
})();
Debug.setListener(null);
assertNull(exception);
assertEquals(3, step);

View File

@ -0,0 +1,50 @@
// Copyright 2012 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.
Debug = debug.Debug
Debug.setListener(function(){});
function f() {a=1;b=2};
function g() {
a=1;
b=2;
}
%PrepareFunctionForOptimization(Debug.setBreakPoint);
bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp);
%OptimizeFunctionOnNextCall(Debug.setBreakPoint);
bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp);
bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp);
%PrepareFunctionForOptimization(Debug.setBreakPoint);
%OptimizeFunctionOnNextCall(Debug.setBreakPoint);
bp = Debug.setBreakPoint(f, 0, 0);
Debug.clearBreakPoint(bp);
Debug.setListener(null);

View File

@ -0,0 +1,7 @@
// Copyright 2014 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 = debug.Debug;
Debug.setListener(null);

View File

@ -0,0 +1,86 @@
// Copyright 2013 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.
Debug = debug.Debug;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals("foo", exec_state.frame(0).evaluate("bar").value());
} catch (e) {
exception = e;
};
listened++;
};
var exception = null;
var listened = 0;
var f = function() {
var bar = "foo";
var baz = bar; // Break point should be here.
return bar;
};
var g = function() {
var bar = "foo";
var baz = bar; // Break point should be here.
return bar;
};
%PrepareFunctionForOptimization(f);
%PrepareFunctionForOptimization(g);
f();
f();
g();
g();
// Mark with builtin.
%OptimizeFunctionOnNextCall(f);
if (%IsConcurrentRecompilationSupported()) {
%OptimizeFunctionOnNextCall(g, "concurrent");
}
// Activate debugger.
Debug.setListener(listener);
// Set break point.
Debug.setBreakPoint(f, 2, 0);
Debug.setBreakPoint(g, 2, 0);
// Trigger break point.
f();
g();
// Assert that break point is set at expected location.
assertTrue(Debug.showBreakPoints(f).indexOf("var baz = [B0]bar;") > 0);
assertTrue(Debug.showBreakPoints(g).indexOf("var baz = [B0]bar;") > 0);
assertEquals(2, listened);
assertNull(exception);

View File

@ -0,0 +1,50 @@
// Copyright 2013 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.
Debug = debug.Debug;
var listened = false;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Exception) {
for (var i = 0; i < exec_state.frameCount(); i++) {
print(exec_state.frame(i).receiver());
print(exec_state.frame(i).func().name());
}
}
listened = true;
}
Debug.setListener(listener);
Debug.setBreakOnException();
assertThrows(function() { delete null['foo']; });
Debug.clearBreakOnException();
Debug.setListener(null);
assertTrue(listened);

View File

@ -0,0 +1,72 @@
// Copyright 2013 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: --concurrent-recompilation
// Flags: --no-always-turbofan
Debug = debug.Debug;
function listener(event, exec_state, event_data, data) {
if (event != Debug.DebugEvent.Break) return;
try {
assertEquals("foo", exec_state.frame(0).evaluate("a").value());
} catch (e) {
exception = e;
};
listened++;
};
var exception = null;
var listened = 0;
var f = function() {
var a = "foo";
var b = a.substring("1");
[a, b].sort();
return a;
};
%PrepareFunctionForOptimization(f);
f();
f();
%DisableOptimizationFinalization();
%OptimizeFunctionOnNextCall(f, "concurrent");
f(); // Kick off concurrent recompilation.
%WaitForBackgroundOptimization();
// After compile graph has been created...
Debug.setListener(listener); // Activate debugger.
Debug.setBreakPoint(f, 2, 0); // Force deopt.
assertUnoptimized(f);
%FinalizeOptimization();
// No optimized code was installed.
assertUnoptimized(f);
f(); // Trigger break point.
assertEquals(1, listened);
assertNull(exception);

View File

@ -0,0 +1,65 @@
// Copyright 2013 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: --concurrent-recompilation
// Flags: --no-always-turbofan
Debug = debug.Debug
function foo() {
var x = 1;
return x;
}
function bar() {
var x = 2;
return x;
}
%PrepareFunctionForOptimization(foo);
foo();
foo();
// Mark and kick off recompilation.
%DisableOptimizationFinalization();
%OptimizeFunctionOnNextCall(foo, "concurrent");
foo();
// Set break points on an unrelated function. This clears both optimized
// and (shared) unoptimized code on foo, and sets both to lazy-compile builtin.
// Clear the break point immediately after to deactivate the debugger.
// Do all of this after compile graph has been created.
%WaitForBackgroundOptimization();
Debug.setListener(function(){});
Debug.setBreakPoint(bar, 0, 0);
Debug.clearAllBreakPoints();
Debug.setListener(null);
assertUnoptimized(foo);
// Install optimized code when concurrent optimization finishes.
// This needs to be able to deal with shared code being a builtin.
%FinalizeOptimization();
assertUnoptimized(foo);