Reland "[debugger] Expose reference to the function in debug-evaluate"
This is a reland of 8de427fae8
Original change's description:
> [debugger] Expose reference to the function in debug-evaluate
>
> R=verwaest@chromium.org
>
> Bug: chromium:878723
> Change-Id: Ic07f75f15230018b6d19cd1ee21f4be6dcad6360
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1667408
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#62385}
TBR=jgruber@chromium.org
Bug: chromium:878723
Change-Id: I0386655a9b2632d2d9438e674d4205ce5e5365f5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1679490
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62401}
This commit is contained in:
parent
84b07695c0
commit
9f8561be3d
@ -624,6 +624,16 @@ bool ScopeIterator::VisitLocals(const Visitor& visitor, Mode mode) const {
|
||||
if (visitor(isolate_->factory()->this_string(), receiver)) return true;
|
||||
}
|
||||
|
||||
if (current_scope_->is_function_scope()) {
|
||||
Variable* function_var =
|
||||
current_scope_->AsDeclarationScope()->function_var();
|
||||
if (function_var != nullptr) {
|
||||
Handle<JSFunction> function = frame_inspector_->GetFunction();
|
||||
Handle<String> name = function_var->name();
|
||||
if (visitor(name, function)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (Variable* var : *current_scope_->locals()) {
|
||||
DCHECK(!var->is_this());
|
||||
if (ScopeInfo::VariableIsSynthetic(*var->name())) continue;
|
||||
|
42
test/debugger/debug/debug-evaluate-function-var.js
Normal file
42
test/debugger/debug/debug-evaluate-function-var.js
Normal file
@ -0,0 +1,42 @@
|
||||
// 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.
|
||||
|
||||
Debug = debug.Debug
|
||||
var exception = null;
|
||||
|
||||
function listener(event, exec_state, event_data, data) {
|
||||
try {
|
||||
if (event == Debug.DebugEvent.Break) {
|
||||
var frame = exec_state.frame(0);
|
||||
try {
|
||||
assertTrue(frame.evaluate("f").value().startsWith("function f()"));
|
||||
} catch {
|
||||
assertTrue(frame.sourceLineText().endsWith("throws"));
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
print(e, e.stack);
|
||||
}
|
||||
};
|
||||
|
||||
Debug.setListener(listener);
|
||||
|
||||
(function f() {
|
||||
f;
|
||||
debugger; // works
|
||||
})();
|
||||
|
||||
(function f() {
|
||||
() => f;
|
||||
debugger; // works
|
||||
})();
|
||||
|
||||
(function f() {
|
||||
debugger; // throws
|
||||
})();
|
||||
|
||||
assertNull(exception);
|
||||
|
||||
Debug.setListener(null);
|
@ -541,6 +541,9 @@ class DebugWrapper {
|
||||
case "boolean": {
|
||||
break;
|
||||
}
|
||||
case "function": {
|
||||
value = obj.description;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user