Commit 77582a4b authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

[debug] scope iterator should not crash on API functions

Bug: v8:8333
Change-Id: I04bb28f909a1c144f513964115b4f2dfaced3146
Reviewed-on: https://chromium-review.googlesource.com/c/1291372
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56846}
parent 581192aa
......@@ -54,13 +54,12 @@ Handle<Object> ScopeIterator::GetFunctionDebugName() const {
}
ScopeIterator::ScopeIterator(Isolate* isolate, Handle<JSFunction> function)
: isolate_(isolate),
context_(function->context(), isolate),
script_(Script::cast(function->shared()->script()), isolate) {
: isolate_(isolate), context_(function->context(), isolate) {
if (!function->shared()->IsSubjectToDebugging()) {
context_ = Handle<Context>();
return;
}
script_ = handle(Script::cast(function->shared()->script()), isolate);
UnwrapEvaluationContext();
}
......@@ -71,10 +70,7 @@ ScopeIterator::ScopeIterator(Isolate* isolate,
function_(generator->function(), isolate),
context_(generator->context(), isolate),
script_(Script::cast(function_->shared()->script()), isolate) {
if (!function_->shared()->IsSubjectToDebugging()) {
context_ = Handle<Context>();
return;
}
CHECK(function_->shared()->IsSubjectToDebugging());
TryParseAndRetrieveScopes(DEFAULT);
}
......
......@@ -2818,6 +2818,21 @@ TEST(DebugBreakInWrappedScript) {
CheckDebuggerUnloaded();
}
static void EmptyHandler(const v8::FunctionCallbackInfo<v8::Value>& args) {}
TEST(DebugScopeIteratorWithFunctionTemplate) {
LocalContext env;
v8::HandleScope handle_scope(env->GetIsolate());
v8::Isolate* isolate = env->GetIsolate();
EnableDebugger(isolate);
v8::Local<v8::Function> func =
v8::Function::New(env.local(), EmptyHandler).ToLocalChecked();
std::unique_ptr<v8::debug::ScopeIterator> iterator =
v8::debug::ScopeIterator::CreateForFunction(isolate, func);
CHECK(iterator->Done());
DisableDebugger(isolate);
}
TEST(DebugBreakWithoutJS) {
i::FLAG_stress_compaction = false;
#ifdef VERIFY_HEAP
......
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