Commit 90eb06b3 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[inspector] prepare debug::ScopeIterator for function without context

Some API functions have no context and debug::ScopeIterator::
CreateForFunction is crashing on attempt to get context.

R=jgruber@chromium.org

Bug: chromium:759913
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I0a9861ea2d19bceff97c4394b34a8dda45222b78
Reviewed-on: https://chromium-review.googlesource.com/661789
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47981}
parent c9efff3f
......@@ -15,10 +15,13 @@ namespace v8 {
std::unique_ptr<debug::ScopeIterator> debug::ScopeIterator::CreateForFunction(
v8::Isolate* v8_isolate, v8::Local<v8::Function> v8_func) {
internal::Handle<internal::JSFunction> func =
internal::Handle<internal::JSFunction>::cast(Utils::OpenHandle(*v8_func));
// Blink has function objects with callable map, JS_SPECIAL_API_OBJECT_TYPE
// but without context on heap.
if (!func->has_context()) return nullptr;
return std::unique_ptr<debug::ScopeIterator>(new internal::DebugScopeIterator(
reinterpret_cast<internal::Isolate*>(v8_isolate),
internal::Handle<internal::JSFunction>::cast(
Utils::OpenHandle(*v8_func))));
reinterpret_cast<internal::Isolate*>(v8_isolate), func));
}
std::unique_ptr<debug::ScopeIterator>
......@@ -27,7 +30,6 @@ debug::ScopeIterator::CreateForGeneratorObject(
internal::Handle<internal::Object> generator =
Utils::OpenHandle(*v8_generator);
DCHECK(generator->IsJSGeneratorObject());
return std::unique_ptr<debug::ScopeIterator>(new internal::DebugScopeIterator(
reinterpret_cast<internal::Isolate*>(v8_isolate),
internal::Handle<internal::JSGeneratorObject>::cast(generator)));
......
......@@ -582,7 +582,7 @@ v8::MaybeLocal<v8::Value> V8Debugger::getTargetScopes(
m_isolate, v8::Local<v8::Object>::Cast(value));
break;
}
if (!iterator) return v8::MaybeLocal<v8::Value>();
v8::Local<v8::Array> result = v8::Array::New(m_isolate);
if (!result->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) {
return v8::MaybeLocal<v8::Value>();
......
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