[inspector] fixed all deprecated calls
BUG=chromium:635948 R=dgozman@chromium.org,alph@chromium.org Review-Url: https://codereview.chromium.org/2332243002 Cr-Commit-Position: refs/heads/master@{#39506}
This commit is contained in:
parent
04c8a36849
commit
072c694336
@ -26,8 +26,7 @@ void InjectedScriptNative::setOnInjectedScriptHost(
|
|||||||
}
|
}
|
||||||
|
|
||||||
InjectedScriptNative* InjectedScriptNative::fromInjectedScriptHost(
|
InjectedScriptNative* InjectedScriptNative::fromInjectedScriptHost(
|
||||||
v8::Local<v8::Object> injectedScriptObject) {
|
v8::Isolate* isolate, v8::Local<v8::Object> injectedScriptObject) {
|
||||||
v8::Isolate* isolate = injectedScriptObject->GetIsolate();
|
|
||||||
v8::HandleScope handleScope(isolate);
|
v8::HandleScope handleScope(isolate);
|
||||||
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
v8::Local<v8::Context> context = isolate->GetCurrentContext();
|
||||||
v8::Local<v8::Private> privateKey = v8::Private::ForApi(
|
v8::Local<v8::Private> privateKey = v8::Private::ForApi(
|
||||||
|
@ -19,7 +19,8 @@ class InjectedScriptNative final {
|
|||||||
~InjectedScriptNative();
|
~InjectedScriptNative();
|
||||||
|
|
||||||
void setOnInjectedScriptHost(v8::Local<v8::Object>);
|
void setOnInjectedScriptHost(v8::Local<v8::Object>);
|
||||||
static InjectedScriptNative* fromInjectedScriptHost(v8::Local<v8::Object>);
|
static InjectedScriptNative* fromInjectedScriptHost(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Object>);
|
||||||
|
|
||||||
int bind(v8::Local<v8::Value>, const String16& groupName);
|
int bind(v8::Local<v8::Value>, const String16& groupName);
|
||||||
void unbind(int id);
|
void unbind(int id);
|
||||||
|
@ -53,7 +53,8 @@ int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const {
|
|||||||
v8::Local<v8::Object> callFrame =
|
v8::Local<v8::Object> callFrame =
|
||||||
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
||||||
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(
|
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(
|
||||||
callFrame->Get(toV8StringInternalized(m_isolate, name)));
|
callFrame->Get(context, toV8StringInternalized(m_isolate, name))
|
||||||
|
.ToLocalChecked());
|
||||||
v8::Local<v8::Value> result;
|
v8::Local<v8::Value> result;
|
||||||
if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result) ||
|
if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result) ||
|
||||||
!result->IsInt32())
|
!result->IsInt32())
|
||||||
@ -79,44 +80,56 @@ int JavaScriptCallFrame::contextId() const {
|
|||||||
|
|
||||||
bool JavaScriptCallFrame::isAtReturn() const {
|
bool JavaScriptCallFrame::isAtReturn() const {
|
||||||
v8::HandleScope handleScope(m_isolate);
|
v8::HandleScope handleScope(m_isolate);
|
||||||
v8::Local<v8::Value> result =
|
v8::Local<v8::Context> context =
|
||||||
v8::Local<v8::Object>::New(m_isolate, m_callFrame)
|
v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
|
||||||
->Get(toV8StringInternalized(m_isolate, "isAtReturn"));
|
v8::Local<v8::Object> callFrame =
|
||||||
if (result.IsEmpty() || !result->IsBoolean()) return false;
|
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
||||||
return result->BooleanValue();
|
v8::Local<v8::Value> result;
|
||||||
|
if (!callFrame->Get(context, toV8StringInternalized(m_isolate, "isAtReturn"))
|
||||||
|
.ToLocal(&result) ||
|
||||||
|
!result->IsBoolean())
|
||||||
|
return false;
|
||||||
|
return result.As<v8::Boolean>()->BooleanValue(context).FromMaybe(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Object> JavaScriptCallFrame::details() const {
|
v8::Local<v8::Object> JavaScriptCallFrame::details() const {
|
||||||
v8::MicrotasksScope microtasks(m_isolate,
|
v8::MicrotasksScope microtasks(m_isolate,
|
||||||
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
||||||
|
v8::Local<v8::Context> context =
|
||||||
|
v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
|
||||||
v8::Local<v8::Object> callFrame =
|
v8::Local<v8::Object> callFrame =
|
||||||
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
||||||
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(
|
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(
|
||||||
callFrame->Get(toV8StringInternalized(m_isolate, "details")));
|
callFrame->Get(context, toV8StringInternalized(m_isolate, "details"))
|
||||||
return v8::Local<v8::Object>::Cast(
|
|
||||||
func->Call(m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr)
|
|
||||||
.ToLocalChecked());
|
.ToLocalChecked());
|
||||||
|
return v8::Local<v8::Object>::Cast(
|
||||||
|
func->Call(context, callFrame, 0, nullptr).ToLocalChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate(
|
v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate(
|
||||||
v8::Local<v8::Value> expression) {
|
v8::Local<v8::Value> expression) {
|
||||||
v8::MicrotasksScope microtasks(m_isolate,
|
v8::MicrotasksScope microtasks(m_isolate,
|
||||||
v8::MicrotasksScope::kRunMicrotasks);
|
v8::MicrotasksScope::kRunMicrotasks);
|
||||||
|
v8::Local<v8::Context> context =
|
||||||
|
v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
|
||||||
v8::Local<v8::Object> callFrame =
|
v8::Local<v8::Object> callFrame =
|
||||||
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
||||||
v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(
|
v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(
|
||||||
callFrame->Get(toV8StringInternalized(m_isolate, "evaluate")));
|
callFrame->Get(context, toV8StringInternalized(m_isolate, "evaluate"))
|
||||||
return evalFunction->Call(m_debuggerContext.Get(m_isolate), callFrame, 1,
|
.ToLocalChecked());
|
||||||
&expression);
|
return evalFunction->Call(context, callFrame, 1, &expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() {
|
v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() {
|
||||||
v8::MicrotasksScope microtasks(m_isolate,
|
v8::MicrotasksScope microtasks(m_isolate,
|
||||||
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
||||||
|
v8::Local<v8::Context> context =
|
||||||
|
v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
|
||||||
v8::Local<v8::Object> callFrame =
|
v8::Local<v8::Object> callFrame =
|
||||||
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
||||||
v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(
|
v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(
|
||||||
callFrame->Get(toV8StringInternalized(m_isolate, "restart")));
|
callFrame->Get(context, toV8StringInternalized(m_isolate, "restart"))
|
||||||
|
.ToLocalChecked());
|
||||||
v8::Debug::SetLiveEditEnabled(m_isolate, true);
|
v8::Debug::SetLiveEditEnabled(m_isolate, true);
|
||||||
v8::MaybeLocal<v8::Value> result = restartFunction->Call(
|
v8::MaybeLocal<v8::Value> result = restartFunction->Call(
|
||||||
m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr);
|
m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr);
|
||||||
@ -129,16 +142,20 @@ v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue(
|
|||||||
v8::Local<v8::Value> newValue) {
|
v8::Local<v8::Value> newValue) {
|
||||||
v8::MicrotasksScope microtasks(m_isolate,
|
v8::MicrotasksScope microtasks(m_isolate,
|
||||||
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
||||||
|
v8::Local<v8::Context> context =
|
||||||
|
v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
|
||||||
v8::Local<v8::Object> callFrame =
|
v8::Local<v8::Object> callFrame =
|
||||||
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
v8::Local<v8::Object>::New(m_isolate, m_callFrame);
|
||||||
v8::Local<v8::Function> setVariableValueFunction =
|
v8::Local<v8::Function> setVariableValueFunction =
|
||||||
v8::Local<v8::Function>::Cast(callFrame->Get(
|
v8::Local<v8::Function>::Cast(
|
||||||
toV8StringInternalized(m_isolate, "setVariableValue")));
|
callFrame
|
||||||
|
->Get(context,
|
||||||
|
toV8StringInternalized(m_isolate, "setVariableValue"))
|
||||||
|
.ToLocalChecked());
|
||||||
v8::Local<v8::Value> argv[] = {
|
v8::Local<v8::Value> argv[] = {
|
||||||
v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)),
|
v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)),
|
||||||
variableName, newValue};
|
variableName, newValue};
|
||||||
return setVariableValueFunction->Call(m_debuggerContext.Get(m_isolate),
|
return setVariableValueFunction->Call(context, callFrame,
|
||||||
callFrame,
|
|
||||||
V8_INSPECTOR_ARRAY_LENGTH(argv), argv);
|
V8_INSPECTOR_ARRAY_LENGTH(argv), argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +63,9 @@ const unsigned maxStackDepthLimit = 32;
|
|||||||
|
|
||||||
class V8ValueStringBuilder {
|
class V8ValueStringBuilder {
|
||||||
public:
|
public:
|
||||||
static String16 toString(v8::Local<v8::Value> value, v8::Isolate* isolate) {
|
static String16 toString(v8::Local<v8::Value> value,
|
||||||
V8ValueStringBuilder builder(isolate);
|
v8::Local<v8::Context> context) {
|
||||||
|
V8ValueStringBuilder builder(context);
|
||||||
if (!builder.append(value)) return String16();
|
if (!builder.append(value)) return String16();
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
@ -75,10 +76,11 @@ class V8ValueStringBuilder {
|
|||||||
IgnoreUndefined = 1 << 1,
|
IgnoreUndefined = 1 << 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
V8ValueStringBuilder(v8::Isolate* isolate)
|
V8ValueStringBuilder(v8::Local<v8::Context> context)
|
||||||
: m_arrayLimit(maxArrayItemsLimit),
|
: m_arrayLimit(maxArrayItemsLimit),
|
||||||
m_isolate(isolate),
|
m_isolate(context->GetIsolate()),
|
||||||
m_tryCatch(isolate) {}
|
m_tryCatch(context->GetIsolate()),
|
||||||
|
m_context(context) {}
|
||||||
|
|
||||||
bool append(v8::Local<v8::Value> value, unsigned ignoreOptions = 0) {
|
bool append(v8::Local<v8::Value> value, unsigned ignoreOptions = 0) {
|
||||||
if (value.IsEmpty()) return true;
|
if (value.IsEmpty()) return true;
|
||||||
@ -133,7 +135,9 @@ class V8ValueStringBuilder {
|
|||||||
m_visitedArrays.push_back(array);
|
m_visitedArrays.push_back(array);
|
||||||
for (uint32_t i = 0; i < length; ++i) {
|
for (uint32_t i = 0; i < length; ++i) {
|
||||||
if (i) m_builder.append(',');
|
if (i) m_builder.append(',');
|
||||||
if (!append(array->Get(i), IgnoreNull | IgnoreUndefined)) {
|
v8::Local<v8::Value> value;
|
||||||
|
if (!array->Get(m_context, i).ToLocal(&value)) continue;
|
||||||
|
if (!append(value, IgnoreNull | IgnoreUndefined)) {
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -165,6 +169,7 @@ class V8ValueStringBuilder {
|
|||||||
String16Builder m_builder;
|
String16Builder m_builder;
|
||||||
std::vector<v8::Local<v8::Array>> m_visitedArrays;
|
std::vector<v8::Local<v8::Array>> m_visitedArrays;
|
||||||
v8::TryCatch m_tryCatch;
|
v8::TryCatch m_tryCatch;
|
||||||
|
v8::Local<v8::Context> m_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -336,11 +341,13 @@ ConsoleAPIType V8ConsoleMessage::type() const { return m_type; }
|
|||||||
std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
|
std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
|
||||||
double timestamp, ConsoleAPIType type,
|
double timestamp, ConsoleAPIType type,
|
||||||
const std::vector<v8::Local<v8::Value>>& arguments,
|
const std::vector<v8::Local<v8::Value>>& arguments,
|
||||||
std::unique_ptr<V8StackTraceImpl> stackTrace, InspectedContext* context) {
|
std::unique_ptr<V8StackTraceImpl> stackTrace,
|
||||||
v8::Isolate* isolate = context->isolate();
|
InspectedContext* inspectedContext) {
|
||||||
int contextId = context->contextId();
|
v8::Isolate* isolate = inspectedContext->isolate();
|
||||||
int contextGroupId = context->contextGroupId();
|
int contextId = inspectedContext->contextId();
|
||||||
V8InspectorImpl* inspector = context->inspector();
|
int contextGroupId = inspectedContext->contextGroupId();
|
||||||
|
V8InspectorImpl* inspector = inspectedContext->inspector();
|
||||||
|
v8::Local<v8::Context> context = inspectedContext->context();
|
||||||
|
|
||||||
std::unique_ptr<V8ConsoleMessage> message = wrapUnique(
|
std::unique_ptr<V8ConsoleMessage> message = wrapUnique(
|
||||||
new V8ConsoleMessage(V8MessageOrigin::kConsole, timestamp, String16()));
|
new V8ConsoleMessage(V8MessageOrigin::kConsole, timestamp, String16()));
|
||||||
@ -356,7 +363,7 @@ std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
|
|||||||
message->m_arguments.push_back(
|
message->m_arguments.push_back(
|
||||||
wrapUnique(new v8::Global<v8::Value>(isolate, arguments.at(i))));
|
wrapUnique(new v8::Global<v8::Value>(isolate, arguments.at(i))));
|
||||||
if (arguments.size())
|
if (arguments.size())
|
||||||
message->m_message = V8ValueStringBuilder::toString(arguments[0], isolate);
|
message->m_message = V8ValueStringBuilder::toString(arguments[0], context);
|
||||||
|
|
||||||
V8ConsoleAPIType clientType = V8ConsoleAPIType::kLog;
|
V8ConsoleAPIType clientType = V8ConsoleAPIType::kLog;
|
||||||
if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount ||
|
if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount ||
|
||||||
|
@ -35,12 +35,14 @@ v8::MaybeLocal<v8::Value> V8Debugger::callDebuggerMethod(
|
|||||||
const char* functionName, int argc, v8::Local<v8::Value> argv[]) {
|
const char* functionName, int argc, v8::Local<v8::Value> argv[]) {
|
||||||
v8::MicrotasksScope microtasks(m_isolate,
|
v8::MicrotasksScope microtasks(m_isolate,
|
||||||
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
||||||
|
DCHECK(m_isolate->InContext());
|
||||||
|
v8::Local<v8::Context> context = m_isolate->GetCurrentContext();
|
||||||
v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
|
v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
|
||||||
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
|
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
|
||||||
debuggerScript->Get(toV8StringInternalized(m_isolate, functionName)));
|
debuggerScript
|
||||||
DCHECK(m_isolate->InContext());
|
->Get(context, toV8StringInternalized(m_isolate, functionName))
|
||||||
return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc,
|
.ToLocalChecked());
|
||||||
argv);
|
return function->Call(context, debuggerScript, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector)
|
V8Debugger::V8Debugger(v8::Isolate* isolate, V8InspectorImpl* inspector)
|
||||||
@ -110,15 +112,18 @@ void V8Debugger::getCompiledScripts(
|
|||||||
v8::HandleScope scope(m_isolate);
|
v8::HandleScope scope(m_isolate);
|
||||||
v8::MicrotasksScope microtasks(m_isolate,
|
v8::MicrotasksScope microtasks(m_isolate,
|
||||||
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
||||||
|
v8::Local<v8::Context> context = debuggerContext();
|
||||||
v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
|
v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate);
|
||||||
DCHECK(!debuggerScript->IsUndefined());
|
DCHECK(!debuggerScript->IsUndefined());
|
||||||
v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(
|
v8::Local<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(
|
||||||
debuggerScript->Get(toV8StringInternalized(m_isolate, "getScripts")));
|
debuggerScript
|
||||||
|
->Get(context, toV8StringInternalized(m_isolate, "getScripts"))
|
||||||
|
.ToLocalChecked());
|
||||||
v8::Local<v8::Value> argv[] = {v8::Integer::New(m_isolate, contextGroupId)};
|
v8::Local<v8::Value> argv[] = {v8::Integer::New(m_isolate, contextGroupId)};
|
||||||
v8::Local<v8::Value> value;
|
v8::Local<v8::Value> value;
|
||||||
if (!getScriptsFunction
|
if (!getScriptsFunction
|
||||||
->Call(debuggerContext(), debuggerScript,
|
->Call(context, debuggerScript, V8_INSPECTOR_ARRAY_LENGTH(argv),
|
||||||
V8_INSPECTOR_ARRAY_LENGTH(argv), argv)
|
argv)
|
||||||
.ToLocal(&value))
|
.ToLocal(&value))
|
||||||
return;
|
return;
|
||||||
DCHECK(value->IsArray());
|
DCHECK(value->IsArray());
|
||||||
@ -126,9 +131,10 @@ void V8Debugger::getCompiledScripts(
|
|||||||
result.reserve(scriptsArray->Length());
|
result.reserve(scriptsArray->Length());
|
||||||
for (unsigned i = 0; i < scriptsArray->Length(); ++i) {
|
for (unsigned i = 0; i < scriptsArray->Length(); ++i) {
|
||||||
v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(
|
v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(
|
||||||
scriptsArray->Get(v8::Integer::New(m_isolate, i)));
|
scriptsArray->Get(context, v8::Integer::New(m_isolate, i))
|
||||||
|
.ToLocalChecked());
|
||||||
result.push_back(wrapUnique(
|
result.push_back(wrapUnique(
|
||||||
new V8DebuggerScript(m_isolate, scriptObject, inLiveEditScope)));
|
new V8DebuggerScript(context, scriptObject, inLiveEditScope)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,55 +143,82 @@ String16 V8Debugger::setBreakpoint(const String16& sourceID,
|
|||||||
int* actualLineNumber,
|
int* actualLineNumber,
|
||||||
int* actualColumnNumber) {
|
int* actualColumnNumber) {
|
||||||
v8::HandleScope scope(m_isolate);
|
v8::HandleScope scope(m_isolate);
|
||||||
v8::Context::Scope contextScope(debuggerContext());
|
v8::Local<v8::Context> context = debuggerContext();
|
||||||
|
v8::Context::Scope contextScope(context);
|
||||||
|
|
||||||
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
|
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
|
||||||
info->Set(toV8StringInternalized(m_isolate, "sourceID"),
|
bool success = false;
|
||||||
toV8String(m_isolate, sourceID));
|
success = info->Set(context, toV8StringInternalized(m_isolate, "sourceID"),
|
||||||
info->Set(toV8StringInternalized(m_isolate, "lineNumber"),
|
toV8String(m_isolate, sourceID))
|
||||||
v8::Integer::New(m_isolate, scriptBreakpoint.lineNumber));
|
.FromMaybe(false);
|
||||||
info->Set(toV8StringInternalized(m_isolate, "columnNumber"),
|
DCHECK(success);
|
||||||
v8::Integer::New(m_isolate, scriptBreakpoint.columnNumber));
|
success = info->Set(context, toV8StringInternalized(m_isolate, "lineNumber"),
|
||||||
info->Set(toV8StringInternalized(m_isolate, "condition"),
|
v8::Integer::New(m_isolate, scriptBreakpoint.lineNumber))
|
||||||
toV8String(m_isolate, scriptBreakpoint.condition));
|
.FromMaybe(false);
|
||||||
|
DCHECK(success);
|
||||||
|
success =
|
||||||
|
info->Set(context, toV8StringInternalized(m_isolate, "columnNumber"),
|
||||||
|
v8::Integer::New(m_isolate, scriptBreakpoint.columnNumber))
|
||||||
|
.FromMaybe(false);
|
||||||
|
DCHECK(success);
|
||||||
|
success = info->Set(context, toV8StringInternalized(m_isolate, "condition"),
|
||||||
|
toV8String(m_isolate, scriptBreakpoint.condition))
|
||||||
|
.FromMaybe(false);
|
||||||
|
DCHECK(success);
|
||||||
|
|
||||||
v8::Local<v8::Function> setBreakpointFunction =
|
v8::Local<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Cast(
|
||||||
v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(
|
m_debuggerScript.Get(m_isolate)
|
||||||
toV8StringInternalized(m_isolate, "setBreakpoint")));
|
->Get(context, toV8StringInternalized(m_isolate, "setBreakpoint"))
|
||||||
|
.ToLocalChecked());
|
||||||
v8::Local<v8::Value> breakpointId =
|
v8::Local<v8::Value> breakpointId =
|
||||||
v8::Debug::Call(debuggerContext(), setBreakpointFunction, info)
|
v8::Debug::Call(debuggerContext(), setBreakpointFunction, info)
|
||||||
.ToLocalChecked();
|
.ToLocalChecked();
|
||||||
if (!breakpointId->IsString()) return "";
|
if (!breakpointId->IsString()) return "";
|
||||||
*actualLineNumber =
|
*actualLineNumber =
|
||||||
info->Get(toV8StringInternalized(m_isolate, "lineNumber"))->Int32Value();
|
info->Get(context, toV8StringInternalized(m_isolate, "lineNumber"))
|
||||||
|
.ToLocalChecked()
|
||||||
|
->Int32Value(context)
|
||||||
|
.FromJust();
|
||||||
*actualColumnNumber =
|
*actualColumnNumber =
|
||||||
info->Get(toV8StringInternalized(m_isolate, "columnNumber"))
|
info->Get(context, toV8StringInternalized(m_isolate, "columnNumber"))
|
||||||
->Int32Value();
|
.ToLocalChecked()
|
||||||
|
->Int32Value(context)
|
||||||
|
.FromJust();
|
||||||
return toProtocolString(breakpointId.As<v8::String>());
|
return toProtocolString(breakpointId.As<v8::String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8Debugger::removeBreakpoint(const String16& breakpointId) {
|
void V8Debugger::removeBreakpoint(const String16& breakpointId) {
|
||||||
v8::HandleScope scope(m_isolate);
|
v8::HandleScope scope(m_isolate);
|
||||||
v8::Context::Scope contextScope(debuggerContext());
|
v8::Local<v8::Context> context = debuggerContext();
|
||||||
|
v8::Context::Scope contextScope(context);
|
||||||
|
|
||||||
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
|
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
|
||||||
info->Set(toV8StringInternalized(m_isolate, "breakpointId"),
|
bool success = false;
|
||||||
toV8String(m_isolate, breakpointId));
|
success =
|
||||||
|
info->Set(context, toV8StringInternalized(m_isolate, "breakpointId"),
|
||||||
|
toV8String(m_isolate, breakpointId))
|
||||||
|
.FromMaybe(false);
|
||||||
|
DCHECK(success);
|
||||||
|
|
||||||
v8::Local<v8::Function> removeBreakpointFunction =
|
v8::Local<v8::Function> removeBreakpointFunction =
|
||||||
v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(
|
v8::Local<v8::Function>::Cast(
|
||||||
toV8StringInternalized(m_isolate, "removeBreakpoint")));
|
m_debuggerScript.Get(m_isolate)
|
||||||
|
->Get(context,
|
||||||
|
toV8StringInternalized(m_isolate, "removeBreakpoint"))
|
||||||
|
.ToLocalChecked());
|
||||||
v8::Debug::Call(debuggerContext(), removeBreakpointFunction, info)
|
v8::Debug::Call(debuggerContext(), removeBreakpointFunction, info)
|
||||||
.ToLocalChecked();
|
.ToLocalChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8Debugger::clearBreakpoints() {
|
void V8Debugger::clearBreakpoints() {
|
||||||
v8::HandleScope scope(m_isolate);
|
v8::HandleScope scope(m_isolate);
|
||||||
v8::Context::Scope contextScope(debuggerContext());
|
v8::Local<v8::Context> context = debuggerContext();
|
||||||
|
v8::Context::Scope contextScope(context);
|
||||||
|
|
||||||
v8::Local<v8::Function> clearBreakpoints =
|
v8::Local<v8::Function> clearBreakpoints = v8::Local<v8::Function>::Cast(
|
||||||
v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(
|
m_debuggerScript.Get(m_isolate)
|
||||||
toV8StringInternalized(m_isolate, "clearBreakpoints")));
|
->Get(context, toV8StringInternalized(m_isolate, "clearBreakpoints"))
|
||||||
|
.ToLocalChecked());
|
||||||
v8::Debug::Call(debuggerContext(), clearBreakpoints).ToLocalChecked();
|
v8::Debug::Call(debuggerContext(), clearBreakpoints).ToLocalChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,14 +228,21 @@ void V8Debugger::setBreakpointsActivated(bool activated) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
v8::HandleScope scope(m_isolate);
|
v8::HandleScope scope(m_isolate);
|
||||||
v8::Context::Scope contextScope(debuggerContext());
|
v8::Local<v8::Context> context = debuggerContext();
|
||||||
|
v8::Context::Scope contextScope(context);
|
||||||
|
|
||||||
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
|
v8::Local<v8::Object> info = v8::Object::New(m_isolate);
|
||||||
info->Set(toV8StringInternalized(m_isolate, "enabled"),
|
bool success = false;
|
||||||
v8::Boolean::New(m_isolate, activated));
|
success = info->Set(context, toV8StringInternalized(m_isolate, "enabled"),
|
||||||
|
v8::Boolean::New(m_isolate, activated))
|
||||||
|
.FromMaybe(false);
|
||||||
|
DCHECK(success);
|
||||||
v8::Local<v8::Function> setBreakpointsActivated =
|
v8::Local<v8::Function> setBreakpointsActivated =
|
||||||
v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(
|
v8::Local<v8::Function>::Cast(
|
||||||
toV8StringInternalized(m_isolate, "setBreakpointsActivated")));
|
m_debuggerScript.Get(m_isolate)
|
||||||
|
->Get(context, toV8StringInternalized(m_isolate,
|
||||||
|
"setBreakpointsActivated"))
|
||||||
|
.ToLocalChecked());
|
||||||
v8::Debug::Call(debuggerContext(), setBreakpointsActivated, info)
|
v8::Debug::Call(debuggerContext(), setBreakpointsActivated, info)
|
||||||
.ToLocalChecked();
|
.ToLocalChecked();
|
||||||
|
|
||||||
@ -212,12 +252,14 @@ void V8Debugger::setBreakpointsActivated(bool activated) {
|
|||||||
V8Debugger::PauseOnExceptionsState V8Debugger::getPauseOnExceptionsState() {
|
V8Debugger::PauseOnExceptionsState V8Debugger::getPauseOnExceptionsState() {
|
||||||
DCHECK(enabled());
|
DCHECK(enabled());
|
||||||
v8::HandleScope scope(m_isolate);
|
v8::HandleScope scope(m_isolate);
|
||||||
v8::Context::Scope contextScope(debuggerContext());
|
v8::Local<v8::Context> context = debuggerContext();
|
||||||
|
v8::Context::Scope contextScope(context);
|
||||||
|
|
||||||
v8::Local<v8::Value> argv[] = {v8::Undefined(m_isolate)};
|
v8::Local<v8::Value> argv[] = {v8::Undefined(m_isolate)};
|
||||||
v8::Local<v8::Value> result =
|
v8::Local<v8::Value> result =
|
||||||
callDebuggerMethod("pauseOnExceptionsState", 0, argv).ToLocalChecked();
|
callDebuggerMethod("pauseOnExceptionsState", 0, argv).ToLocalChecked();
|
||||||
return static_cast<V8Debugger::PauseOnExceptionsState>(result->Int32Value());
|
return static_cast<V8Debugger::PauseOnExceptionsState>(
|
||||||
|
result->Int32Value(context).FromJust());
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8Debugger::setPauseOnExceptionsState(
|
void V8Debugger::setPauseOnExceptionsState(
|
||||||
@ -357,12 +399,20 @@ bool V8Debugger::setScriptSource(
|
|||||||
v8result = maybeResult.ToLocalChecked();
|
v8result = maybeResult.ToLocalChecked();
|
||||||
}
|
}
|
||||||
DCHECK(!v8result.IsEmpty());
|
DCHECK(!v8result.IsEmpty());
|
||||||
v8::Local<v8::Object> resultTuple = v8result->ToObject(m_isolate);
|
v8::Local<v8::Context> context = m_isolate->GetCurrentContext();
|
||||||
int code =
|
v8::Local<v8::Object> resultTuple =
|
||||||
static_cast<int>(resultTuple->Get(0)->ToInteger(m_isolate)->Value());
|
v8result->ToObject(context).ToLocalChecked();
|
||||||
|
int code = static_cast<int>(resultTuple->Get(context, 0)
|
||||||
|
.ToLocalChecked()
|
||||||
|
->ToInteger(context)
|
||||||
|
.ToLocalChecked()
|
||||||
|
->Value());
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 0: {
|
case 0: {
|
||||||
*stackChanged = resultTuple->Get(1)->BooleanValue();
|
*stackChanged = resultTuple->Get(context, 1)
|
||||||
|
.ToLocalChecked()
|
||||||
|
->BooleanValue(context)
|
||||||
|
.FromJust();
|
||||||
// Call stack may have changed after if the edited function was on the
|
// Call stack may have changed after if the edited function was on the
|
||||||
// stack.
|
// stack.
|
||||||
if (!dryRun && isPaused()) {
|
if (!dryRun && isPaused()) {
|
||||||
@ -376,11 +426,20 @@ bool V8Debugger::setScriptSource(
|
|||||||
*exceptionDetails =
|
*exceptionDetails =
|
||||||
protocol::Runtime::ExceptionDetails::create()
|
protocol::Runtime::ExceptionDetails::create()
|
||||||
.setExceptionId(m_inspector->nextExceptionId())
|
.setExceptionId(m_inspector->nextExceptionId())
|
||||||
.setText(toProtocolStringWithTypeCheck(resultTuple->Get(2)))
|
.setText(toProtocolStringWithTypeCheck(
|
||||||
.setLineNumber(
|
resultTuple->Get(context, 2).ToLocalChecked()))
|
||||||
resultTuple->Get(3)->ToInteger(m_isolate)->Value() - 1)
|
.setLineNumber(resultTuple->Get(context, 3)
|
||||||
.setColumnNumber(
|
.ToLocalChecked()
|
||||||
resultTuple->Get(4)->ToInteger(m_isolate)->Value() - 1)
|
->ToInteger(context)
|
||||||
|
.ToLocalChecked()
|
||||||
|
->Value() -
|
||||||
|
1)
|
||||||
|
.setColumnNumber(resultTuple->Get(context, 4)
|
||||||
|
.ToLocalChecked()
|
||||||
|
->ToInteger(context)
|
||||||
|
.ToLocalChecked()
|
||||||
|
->Value() -
|
||||||
|
1)
|
||||||
.build();
|
.build();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -394,8 +453,11 @@ JavaScriptCallFrames V8Debugger::currentCallFrames(int limit) {
|
|||||||
v8::Local<v8::Value> currentCallFramesV8;
|
v8::Local<v8::Value> currentCallFramesV8;
|
||||||
if (m_executionState.IsEmpty()) {
|
if (m_executionState.IsEmpty()) {
|
||||||
v8::Local<v8::Function> currentCallFramesFunction =
|
v8::Local<v8::Function> currentCallFramesFunction =
|
||||||
v8::Local<v8::Function>::Cast(m_debuggerScript.Get(m_isolate)->Get(
|
v8::Local<v8::Function>::Cast(
|
||||||
toV8StringInternalized(m_isolate, "currentCallFrames")));
|
m_debuggerScript.Get(m_isolate)
|
||||||
|
->Get(debuggerContext(),
|
||||||
|
toV8StringInternalized(m_isolate, "currentCallFrames"))
|
||||||
|
.ToLocalChecked());
|
||||||
currentCallFramesV8 =
|
currentCallFramesV8 =
|
||||||
v8::Debug::Call(debuggerContext(), currentCallFramesFunction,
|
v8::Debug::Call(debuggerContext(), currentCallFramesFunction,
|
||||||
v8::Integer::New(m_isolate, limit))
|
v8::Integer::New(m_isolate, limit))
|
||||||
@ -459,10 +521,11 @@ void V8Debugger::handleProgramBreak(v8::Local<v8::Context> pausedContext,
|
|||||||
if (!hitBreakpointNumbers.IsEmpty()) {
|
if (!hitBreakpointNumbers.IsEmpty()) {
|
||||||
breakpointIds.reserve(hitBreakpointNumbers->Length());
|
breakpointIds.reserve(hitBreakpointNumbers->Length());
|
||||||
for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
|
for (size_t i = 0; i < hitBreakpointNumbers->Length(); i++) {
|
||||||
v8::Local<v8::Value> hitBreakpointNumber = hitBreakpointNumbers->Get(i);
|
v8::Local<v8::Value> hitBreakpointNumber =
|
||||||
DCHECK(!hitBreakpointNumber.IsEmpty() && hitBreakpointNumber->IsInt32());
|
hitBreakpointNumbers->Get(debuggerContext(), i).ToLocalChecked();
|
||||||
breakpointIds.push_back(
|
DCHECK(hitBreakpointNumber->IsInt32());
|
||||||
String16::fromInteger(hitBreakpointNumber->Int32Value()));
|
breakpointIds.push_back(String16::fromInteger(
|
||||||
|
hitBreakpointNumber->Int32Value(debuggerContext()).FromJust()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +570,10 @@ v8::Local<v8::Value> V8Debugger::callInternalGetterFunction(
|
|||||||
v8::MicrotasksScope microtasks(m_isolate,
|
v8::MicrotasksScope microtasks(m_isolate,
|
||||||
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
v8::MicrotasksScope::kDoNotRunMicrotasks);
|
||||||
v8::Local<v8::Value> getterValue =
|
v8::Local<v8::Value> getterValue =
|
||||||
object->Get(toV8StringInternalized(m_isolate, functionName));
|
object
|
||||||
|
->Get(m_isolate->GetCurrentContext(),
|
||||||
|
toV8StringInternalized(m_isolate, functionName))
|
||||||
|
.ToLocalChecked();
|
||||||
DCHECK(!getterValue.IsEmpty() && getterValue->IsFunction());
|
DCHECK(!getterValue.IsEmpty() && getterValue->IsFunction());
|
||||||
return v8::Local<v8::Function>::Cast(getterValue)
|
return v8::Local<v8::Function>::Cast(getterValue)
|
||||||
->Call(m_isolate->GetCurrentContext(), object, 0, 0)
|
->Call(m_isolate->GetCurrentContext(), object, 0, 0)
|
||||||
@ -546,9 +612,10 @@ void V8Debugger::handleV8DebugEvent(
|
|||||||
if (value->IsNull()) return;
|
if (value->IsNull()) return;
|
||||||
DCHECK(value->IsObject());
|
DCHECK(value->IsObject());
|
||||||
v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(value);
|
v8::Local<v8::Object> scriptObject = v8::Local<v8::Object>::Cast(value);
|
||||||
agent->didParseSource(wrapUnique(new V8DebuggerScript(
|
agent->didParseSource(
|
||||||
m_isolate, scriptObject, inLiveEditScope)),
|
wrapUnique(new V8DebuggerScript(debuggerContext(), scriptObject,
|
||||||
event == v8::AfterCompile);
|
inLiveEditScope)),
|
||||||
|
event == v8::AfterCompile);
|
||||||
} else if (event == v8::Exception) {
|
} else if (event == v8::Exception) {
|
||||||
v8::Local<v8::Object> eventData = eventDetails.GetEventData();
|
v8::Local<v8::Object> eventData = eventDetails.GetEventData();
|
||||||
v8::Local<v8::Value> exception =
|
v8::Local<v8::Value> exception =
|
||||||
@ -580,7 +647,8 @@ void V8Debugger::handleV8AsyncTaskEvent(v8::Local<v8::Context> context,
|
|||||||
String16 name = toProtocolStringWithTypeCheck(
|
String16 name = toProtocolStringWithTypeCheck(
|
||||||
callInternalGetterFunction(eventData, "name"));
|
callInternalGetterFunction(eventData, "name"));
|
||||||
int id = callInternalGetterFunction(eventData, "id")
|
int id = callInternalGetterFunction(eventData, "id")
|
||||||
->ToInteger(m_isolate)
|
->ToInteger(context)
|
||||||
|
.ToLocalChecked()
|
||||||
->Value();
|
->Value();
|
||||||
// The scopes for the ids are defined by the eventData.name namespaces. There
|
// The scopes for the ids are defined by the eventData.name namespaces. There
|
||||||
// are currently two namespaces: "Object." and "Promise.".
|
// are currently two namespaces: "Object." and "Promise.".
|
||||||
|
@ -100,6 +100,8 @@ class V8Debugger {
|
|||||||
void muteScriptParsedEvents();
|
void muteScriptParsedEvents();
|
||||||
void unmuteScriptParsedEvents();
|
void unmuteScriptParsedEvents();
|
||||||
|
|
||||||
|
V8InspectorImpl* inspector() { return m_inspector; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void compileDebuggerScript();
|
void compileDebuggerScript();
|
||||||
v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName,
|
v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName,
|
||||||
|
@ -67,44 +67,50 @@ static String16 calculateHash(const String16& str) {
|
|||||||
return hash.toString();
|
return hash.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate,
|
static v8::Local<v8::Value> GetChecked(v8::Local<v8::Context> context,
|
||||||
|
v8::Local<v8::Object> object,
|
||||||
|
const char* name) {
|
||||||
|
return object
|
||||||
|
->Get(context, toV8StringInternalized(context->GetIsolate(), name))
|
||||||
|
.ToLocalChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
static int64_t GetCheckedInt(v8::Local<v8::Context> context,
|
||||||
|
v8::Local<v8::Object> object, const char* name) {
|
||||||
|
return GetChecked(context, object, name)
|
||||||
|
->ToInteger(context)
|
||||||
|
.ToLocalChecked()
|
||||||
|
->Value();
|
||||||
|
}
|
||||||
|
|
||||||
|
V8DebuggerScript::V8DebuggerScript(v8::Local<v8::Context> context,
|
||||||
v8::Local<v8::Object> object,
|
v8::Local<v8::Object> object,
|
||||||
bool isLiveEdit) {
|
bool isLiveEdit) {
|
||||||
v8::Local<v8::Value> idValue =
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
object->Get(toV8StringInternalized(isolate, "id"));
|
v8::Local<v8::Value> idValue = GetChecked(context, object, "id");
|
||||||
DCHECK(!idValue.IsEmpty() && idValue->IsInt32());
|
DCHECK(!idValue.IsEmpty() && idValue->IsInt32());
|
||||||
m_id = String16::fromInteger(idValue->Int32Value());
|
m_id = String16::fromInteger(idValue->Int32Value(context).FromJust());
|
||||||
|
|
||||||
m_url = toProtocolStringWithTypeCheck(
|
m_url = toProtocolStringWithTypeCheck(GetChecked(context, object, "name"));
|
||||||
object->Get(toV8StringInternalized(isolate, "name")));
|
m_sourceURL =
|
||||||
m_sourceURL = toProtocolStringWithTypeCheck(
|
toProtocolStringWithTypeCheck(GetChecked(context, object, "sourceURL"));
|
||||||
object->Get(toV8StringInternalized(isolate, "sourceURL")));
|
|
||||||
m_sourceMappingURL = toProtocolStringWithTypeCheck(
|
m_sourceMappingURL = toProtocolStringWithTypeCheck(
|
||||||
object->Get(toV8StringInternalized(isolate, "sourceMappingURL")));
|
GetChecked(context, object, "sourceMappingURL"));
|
||||||
m_startLine = object->Get(toV8StringInternalized(isolate, "startLine"))
|
m_startLine = GetCheckedInt(context, object, "startLine");
|
||||||
->ToInteger(isolate)
|
m_startColumn = GetCheckedInt(context, object, "startColumn");
|
||||||
->Value();
|
m_endLine = GetCheckedInt(context, object, "endLine");
|
||||||
m_startColumn = object->Get(toV8StringInternalized(isolate, "startColumn"))
|
m_endColumn = GetCheckedInt(context, object, "endColumn");
|
||||||
->ToInteger(isolate)
|
|
||||||
->Value();
|
|
||||||
m_endLine = object->Get(toV8StringInternalized(isolate, "endLine"))
|
|
||||||
->ToInteger(isolate)
|
|
||||||
->Value();
|
|
||||||
m_endColumn = object->Get(toV8StringInternalized(isolate, "endColumn"))
|
|
||||||
->ToInteger(isolate)
|
|
||||||
->Value();
|
|
||||||
m_executionContextAuxData = toProtocolStringWithTypeCheck(
|
m_executionContextAuxData = toProtocolStringWithTypeCheck(
|
||||||
object->Get(toV8StringInternalized(isolate, "executionContextAuxData")));
|
GetChecked(context, object, "executionContextAuxData"));
|
||||||
m_executionContextId =
|
m_executionContextId = GetCheckedInt(context, object, "executionContextId");
|
||||||
object->Get(toV8StringInternalized(isolate, "executionContextId"))
|
|
||||||
->ToInteger(isolate)
|
|
||||||
->Value();
|
|
||||||
m_isLiveEdit = isLiveEdit;
|
m_isLiveEdit = isLiveEdit;
|
||||||
|
|
||||||
v8::Local<v8::Value> sourceValue =
|
v8::Local<v8::Value> sourceValue;
|
||||||
object->Get(toV8StringInternalized(isolate, "source"));
|
if (!object->Get(context, toV8StringInternalized(isolate, "source"))
|
||||||
if (!sourceValue.IsEmpty() && sourceValue->IsString())
|
.ToLocal(&sourceValue) ||
|
||||||
setSource(isolate, sourceValue.As<v8::String>());
|
!sourceValue->IsString())
|
||||||
|
return;
|
||||||
|
setSource(isolate, sourceValue.As<v8::String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
V8DebuggerScript::~V8DebuggerScript() {}
|
V8DebuggerScript::~V8DebuggerScript() {}
|
||||||
|
@ -41,7 +41,8 @@ class V8DebuggerScript {
|
|||||||
V8_INSPECTOR_DISALLOW_COPY(V8DebuggerScript);
|
V8_INSPECTOR_DISALLOW_COPY(V8DebuggerScript);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
V8DebuggerScript(v8::Isolate*, v8::Local<v8::Object>, bool isLiveEdit);
|
V8DebuggerScript(v8::Local<v8::Context>, v8::Local<v8::Object>,
|
||||||
|
bool isLiveEdit);
|
||||||
~V8DebuggerScript();
|
~V8DebuggerScript();
|
||||||
|
|
||||||
const String16& scriptId() const { return m_id; }
|
const String16& scriptId() const { return m_id; }
|
||||||
|
@ -189,10 +189,13 @@ void V8InjectedScriptHost::bindCallback(
|
|||||||
const v8::FunctionCallbackInfo<v8::Value>& info) {
|
const v8::FunctionCallbackInfo<v8::Value>& info) {
|
||||||
if (info.Length() < 2 || !info[1]->IsString()) return;
|
if (info.Length() < 2 || !info[1]->IsString()) return;
|
||||||
InjectedScriptNative* injectedScriptNative =
|
InjectedScriptNative* injectedScriptNative =
|
||||||
InjectedScriptNative::fromInjectedScriptHost(info.Holder());
|
InjectedScriptNative::fromInjectedScriptHost(info.GetIsolate(),
|
||||||
|
info.Holder());
|
||||||
if (!injectedScriptNative) return;
|
if (!injectedScriptNative) return;
|
||||||
|
|
||||||
v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate());
|
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
|
||||||
|
v8::Local<v8::String> v8groupName =
|
||||||
|
info[1]->ToString(context).ToLocalChecked();
|
||||||
String16 groupName = toProtocolStringWithTypeCheck(v8groupName);
|
String16 groupName = toProtocolStringWithTypeCheck(v8groupName);
|
||||||
int id = injectedScriptNative->bind(info[0], groupName);
|
int id = injectedScriptNative->bind(info[0], groupName);
|
||||||
info.GetReturnValue().Set(id);
|
info.GetReturnValue().Set(id);
|
||||||
|
@ -37,12 +37,11 @@
|
|||||||
#include "src/inspector/V8Debugger.h"
|
#include "src/inspector/V8Debugger.h"
|
||||||
#include "src/inspector/V8DebuggerAgentImpl.h"
|
#include "src/inspector/V8DebuggerAgentImpl.h"
|
||||||
#include "src/inspector/V8InspectorSessionImpl.h"
|
#include "src/inspector/V8InspectorSessionImpl.h"
|
||||||
|
#include "src/inspector/V8ProfilerAgentImpl.h"
|
||||||
#include "src/inspector/V8RuntimeAgentImpl.h"
|
#include "src/inspector/V8RuntimeAgentImpl.h"
|
||||||
#include "src/inspector/V8StackTraceImpl.h"
|
#include "src/inspector/V8StackTraceImpl.h"
|
||||||
#include "src/inspector/protocol/Protocol.h"
|
#include "src/inspector/protocol/Protocol.h"
|
||||||
|
|
||||||
#include "include/v8-profiler.h"
|
|
||||||
|
|
||||||
namespace v8_inspector {
|
namespace v8_inspector {
|
||||||
|
|
||||||
std::unique_ptr<V8Inspector> V8Inspector::create(v8::Isolate* isolate,
|
std::unique_ptr<V8Inspector> V8Inspector::create(v8::Isolate* isolate,
|
||||||
@ -74,6 +73,13 @@ V8RuntimeAgentImpl* V8InspectorImpl::enabledRuntimeAgentForGroup(
|
|||||||
return agent && agent->enabled() ? agent : nullptr;
|
return agent && agent->enabled() ? agent : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
V8ProfilerAgentImpl* V8InspectorImpl::enabledProfilerAgentForGroup(
|
||||||
|
int contextGroupId) {
|
||||||
|
V8InspectorSessionImpl* session = sessionForContextGroup(contextGroupId);
|
||||||
|
V8ProfilerAgentImpl* agent = session ? session->profilerAgent() : nullptr;
|
||||||
|
return agent && agent->enabled() ? agent : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
v8::MaybeLocal<v8::Value> V8InspectorImpl::runCompiledScript(
|
v8::MaybeLocal<v8::Value> V8InspectorImpl::runCompiledScript(
|
||||||
v8::Local<v8::Context> context, v8::Local<v8::Script> script) {
|
v8::Local<v8::Context> context, v8::Local<v8::Script> script) {
|
||||||
v8::MicrotasksScope microtasksScope(m_isolate,
|
v8::MicrotasksScope microtasksScope(m_isolate,
|
||||||
@ -271,11 +277,15 @@ void V8InspectorImpl::didExecuteScript(v8::Local<v8::Context> context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void V8InspectorImpl::idleStarted() {
|
void V8InspectorImpl::idleStarted() {
|
||||||
m_isolate->GetCpuProfiler()->SetIdle(true);
|
for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) {
|
||||||
|
if (it->second->profilerAgent()->idleStarted()) return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void V8InspectorImpl::idleFinished() {
|
void V8InspectorImpl::idleFinished() {
|
||||||
m_isolate->GetCpuProfiler()->SetIdle(false);
|
for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) {
|
||||||
|
if (it->second->profilerAgent()->idleFinished()) return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned V8InspectorImpl::exceptionThrown(
|
unsigned V8InspectorImpl::exceptionThrown(
|
||||||
|
@ -46,6 +46,7 @@ class V8ConsoleMessageStorage;
|
|||||||
class V8Debugger;
|
class V8Debugger;
|
||||||
class V8DebuggerAgentImpl;
|
class V8DebuggerAgentImpl;
|
||||||
class V8InspectorSessionImpl;
|
class V8InspectorSessionImpl;
|
||||||
|
class V8ProfilerAgentImpl;
|
||||||
class V8RuntimeAgentImpl;
|
class V8RuntimeAgentImpl;
|
||||||
class V8StackTraceImpl;
|
class V8StackTraceImpl;
|
||||||
|
|
||||||
@ -119,6 +120,7 @@ class V8InspectorImpl : public V8Inspector {
|
|||||||
InspectedContext* getContext(int groupId, int contextId) const;
|
InspectedContext* getContext(int groupId, int contextId) const;
|
||||||
V8DebuggerAgentImpl* enabledDebuggerAgentForGroup(int contextGroupId);
|
V8DebuggerAgentImpl* enabledDebuggerAgentForGroup(int contextGroupId);
|
||||||
V8RuntimeAgentImpl* enabledRuntimeAgentForGroup(int contextGroupId);
|
V8RuntimeAgentImpl* enabledRuntimeAgentForGroup(int contextGroupId);
|
||||||
|
V8ProfilerAgentImpl* enabledProfilerAgentForGroup(int contextGroupId);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
v8::Isolate* m_isolate;
|
v8::Isolate* m_isolate;
|
||||||
|
@ -304,4 +304,18 @@ bool V8ProfilerAgentImpl::isRecording() const {
|
|||||||
return m_recordingCPUProfile || !m_startedProfiles.empty();
|
return m_recordingCPUProfile || !m_startedProfiles.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool V8ProfilerAgentImpl::idleStarted() {
|
||||||
|
if (m_profiler) m_profiler->SetIdle(true);
|
||||||
|
return m_profiler;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool V8ProfilerAgentImpl::idleFinished() {
|
||||||
|
if (m_profiler) m_profiler->SetIdle(false);
|
||||||
|
return m_profiler;
|
||||||
|
}
|
||||||
|
|
||||||
|
void V8ProfilerAgentImpl::collectSample() {
|
||||||
|
if (m_profiler) m_profiler->CollectSample();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace v8_inspector
|
} // namespace v8_inspector
|
||||||
|
@ -43,6 +43,11 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
|
|||||||
void consoleProfile(const String16& title);
|
void consoleProfile(const String16& title);
|
||||||
void consoleProfileEnd(const String16& title);
|
void consoleProfileEnd(const String16& title);
|
||||||
|
|
||||||
|
bool idleStarted();
|
||||||
|
bool idleFinished();
|
||||||
|
|
||||||
|
void collectSample();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String16 nextProfileId();
|
String16 nextProfileId();
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include "src/inspector/StringUtil.h"
|
#include "src/inspector/StringUtil.h"
|
||||||
#include "src/inspector/V8Debugger.h"
|
#include "src/inspector/V8Debugger.h"
|
||||||
|
#include "src/inspector/V8InspectorImpl.h"
|
||||||
|
#include "src/inspector/V8ProfilerAgentImpl.h"
|
||||||
#include "src/inspector/protocol/Protocol.h"
|
#include "src/inspector/protocol/Protocol.h"
|
||||||
|
|
||||||
#include "include/v8-debug.h"
|
#include "include/v8-debug.h"
|
||||||
@ -158,7 +160,12 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
|
|||||||
v8::HandleScope handleScope(isolate);
|
v8::HandleScope handleScope(isolate);
|
||||||
v8::Local<v8::StackTrace> stackTrace;
|
v8::Local<v8::StackTrace> stackTrace;
|
||||||
if (isolate->InContext()) {
|
if (isolate->InContext()) {
|
||||||
isolate->GetCpuProfiler()->CollectSample();
|
if (debugger) {
|
||||||
|
V8InspectorImpl* inspector = debugger->inspector();
|
||||||
|
V8ProfilerAgentImpl* profilerAgent =
|
||||||
|
inspector->enabledProfilerAgentForGroup(contextGroupId);
|
||||||
|
if (profilerAgent) profilerAgent->collectSample();
|
||||||
|
}
|
||||||
stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize,
|
stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize,
|
||||||
stackTraceOptions);
|
stackTraceOptions);
|
||||||
}
|
}
|
||||||
|
@ -1753,11 +1753,9 @@
|
|||||||
4324, # Struct padded due to declspec(align).
|
4324, # Struct padded due to declspec(align).
|
||||||
4714, # Function marked forceinline not inlined.
|
4714, # Function marked forceinline not inlined.
|
||||||
4800, # Value forced to bool.
|
4800, # Value forced to bool.
|
||||||
4996, # Deprecated function call.
|
|
||||||
],
|
],
|
||||||
'cflags': [
|
'cflags': [
|
||||||
'-Wno-shorten-64-to-32',
|
'-Wno-shorten-64-to-32',
|
||||||
'-Wno-deprecated-declarations',
|
|
||||||
],
|
],
|
||||||
}],
|
}],
|
||||||
['OS=="win" and v8_enable_i18n_support==1', {
|
['OS=="win" and v8_enable_i18n_support==1', {
|
||||||
|
Loading…
Reference in New Issue
Block a user