Commit dc3a90be authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

[debug] Revert to old line number behavior for new Function()

Reverting https://chromium-review.googlesource.com/c/v8/v8/+/1741660

This fixed one bug but caused a lot of others and on balance I think
reverting it is the lesser evil.

This also fixed generator-relocation.js because
(function*(){}).constructor is the function constructor and we try to
set a breakpoint on line 3.

Bug: chromium:109362, chromium:1028689
Fixes: v8:9721
Change-Id: I1bfe6ec57ce77ea7292df91266311f5c0194947e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1940259
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65232}
parent c8704891
......@@ -93,17 +93,6 @@ MaybeHandle<Object> CreateDynamicFunction(Isolate* isolate,
function->shared().set_name_should_print_as_anonymous(true);
}
// The spec says that we have to wrap code created via the function
// constructor in e.g. 'function anonymous(' as above, including with extra
// line breaks. Ths is confusing when reporting stack traces from the eval'd
// code as the line number of the error is always reported with 2 extra line
// breaks e.g. line 1 is reported as line 3. We fix this up here by setting
// line_offset which is read by stack trace code.
Handle<Script> script(Script::cast(function->shared().script()), isolate);
if (script->line_offset() == 0) {
script->set_line_offset(-2);
}
// If new.target is equal to target then the function created
// is already correctly setup and nothing else should be done
// here. But if new.target is not equal to target then we are
......
......@@ -250,31 +250,31 @@ static void AnalyzeStackInNativeCode(
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(nullptr, "function.name", 1, 1, true, false,
checkStackFrame(nullptr, "function.name", 3, 1, true, false,
stackTrace->GetFrame(isolate, 0));
} else if (testGroup == kDisplayName) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(nullptr, "function.displayName", 1, 1, true, false,
checkStackFrame(nullptr, "function.displayName", 3, 1, true, false,
stackTrace->GetFrame(isolate, 0));
} else if (testGroup == kFunctionNameAndDisplayName) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(nullptr, "function.displayName", 1, 1, true, false,
checkStackFrame(nullptr, "function.displayName", 3, 1, true, false,
stackTrace->GetFrame(isolate, 0));
} else if (testGroup == kDisplayNameIsNotString) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(nullptr, "function.name", 1, 1, true, false,
checkStackFrame(nullptr, "function.name", 3, 1, true, false,
stackTrace->GetFrame(isolate, 0));
} else if (testGroup == kFunctionNameIsNotString) {
v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
args.GetIsolate(), 5, v8::StackTrace::kOverview);
CHECK_EQ(3, stackTrace->GetFrameCount());
checkStackFrame(nullptr, "", 1, 1, true, false,
checkStackFrame(nullptr, "", 3, 1, true, false,
stackTrace->GetFrame(isolate, 0));
}
}
......
......@@ -11,9 +11,6 @@
# not work, but we expect it to not crash.
'debug/debug-step-turbofan': [PASS, FAIL],
# BUG (v8:9721)
'debug/es6/generators-relocation': [FAIL],
# Issue 3641: The new 'then' semantics suppress some exceptions.
# These tests may be changed or removed when 'chain' is deprecated.
'debug/es6/debug-promises/reject-with-throw-in-reject': [FAIL],
......
......@@ -6,19 +6,19 @@ Tests that Runtime.evaluate has the correct error line number for 'new Function(
columnNumber : 3
exception : {
className : TypeError
description : TypeError: 0 is not a function at eval (eval at <anonymous> (:1:1), <anonymous>:1:4) at <anonymous>:1:22
description : TypeError: 0 is not a function at eval (eval at <anonymous> (:1:1), <anonymous>:3:4) at <anonymous>:1:22
objectId : <objectId>
subtype : error
type : object
}
exceptionId : <exceptionId>
lineNumber : 0
lineNumber : 2
scriptId : <scriptId>
text : Uncaught
}
result : {
className : TypeError
description : TypeError: 0 is not a function at eval (eval at <anonymous> (:1:1), <anonymous>:1:4) at <anonymous>:1:22
description : TypeError: 0 is not a function at eval (eval at <anonymous> (:1:1), <anonymous>:3:4) at <anonymous>:1:22
objectId : <objectId>
subtype : error
type : object
......
......@@ -19,7 +19,7 @@ function test(expectation, f) {
1 + reference_error //@ sourceURL=evaltest
})
*/
test("1:5", new Function(
test("3:5", new Function(
'1 + reference_error //@ sourceURL=evaltest'));
/*
(function(x
......@@ -28,7 +28,7 @@ test("1:5", new Function(
1 + reference_error //@ sourceURL=evaltest
})
*/
test("2:6", new Function(
test("4:6", new Function(
'x', '\n 1 + reference_error //@ sourceURL=evaltest'));
/*
(function(x
......@@ -40,7 +40,7 @@ test("2:6", new Function(
1 + reference_error //@ sourceURL=evaltest
})
*/
test("5:6", new Function(
test("7:6", new Function(
'x\n\n', "z//\n", "y", '\n 1 + reference_error //@ sourceURL=evaltest'));
/*
(function(x/\*,z//
......@@ -49,7 +49,7 @@ test("5:6", new Function(
1 + reference_error //@ sourceURL=evaltest
})
*/
test("2:5", new Function(
test("4:5", new Function(
'x/*', "z//\n", "y*/", '1 + reference_error //@ sourceURL=evaltest'));
/*
(function () {
......
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