Commit c68e075e authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[debug] Introduce GetCreationContext to debug API

This new function forwards to v8::Object::CreationContext but has
special handling for JSGlobalProxy objects to prevent the former from
crashing.

R=yangguo@chromium.org

Bug: chromium:952057
Change-Id: I5ade682976efd1724c13f52b468e4fb30bb9ade7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1569425
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61197}
parent 6d0078e4
......@@ -9100,6 +9100,14 @@ MaybeLocal<Array> debug::GetPrivateFields(Local<Context> context,
RETURN_ESCAPED(Utils::ToLocal(result));
}
Local<Context> debug::GetCreationContext(Local<Object> value) {
i::Handle<i::Object> val = Utils::OpenHandle(*value);
if (val->IsJSGlobalProxy()) {
return Local<Context>();
}
return value->CreationContext();
}
void debug::ChangeBreakOnException(Isolate* isolate, ExceptionBreakState type) {
i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
internal_isolate->debug()->ChangeBreakOnException(
......
......@@ -57,6 +57,12 @@ MaybeLocal<Array> GetInternalProperties(Isolate* isolate, Local<Value> value);
V8_EXPORT_PRIVATE MaybeLocal<Array> GetPrivateFields(Local<Context> context,
Local<Object> value);
/**
* Forwards to v8::Object::CreationContext, but with special handling for
* JSGlobalProxy objects.
*/
Local<Context> GetCreationContext(Local<Object> value);
enum ExceptionBreakState {
NoBreakOnException = 0,
BreakOnUncaughtException = 1,
......
......@@ -42,7 +42,8 @@ class MatchPrototypePredicate : public v8::debug::QueryObjectPredicate {
: m_inspector(inspector), m_context(context), m_prototype(prototype) {}
bool Filter(v8::Local<v8::Object> object) override {
v8::Local<v8::Context> objectContext = object->CreationContext();
v8::Local<v8::Context> objectContext =
v8::debug::GetCreationContext(object);
if (objectContext != m_context) return false;
if (!m_inspector->client()->isInspectableHeapObject(object)) return false;
// Get prototype chain for current object until first visited prototype.
......
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