Commit 8de427fa authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

[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/+/1667408Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62385}
parent 7d0b1210
......@@ -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;
......
// 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;
}
......
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