Title: [244285] trunk/Source/_javascript_Core
- Revision
- 244285
- Author
- [email protected]
- Date
- 2019-04-15 13:29:30 -0700 (Mon, 15 Apr 2019)
Log Message
Web Inspector: REGRESSION(r244172): crash when trying to add extra domain while inspecting JSContext
https://bugs.webkit.org/show_bug.cgi?id=196925
<rdar://problem/49873994>
Reviewed by Joseph Pecoraro.
Move the logic for creating the `InspectorAgent` and `InspectorDebuggerAgent` into separate
functions so that callers can be guaranteed to have a valid instance of the agent.
* inspector/JSGlobalObjectInspectorController.h:
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::connectFrontend):
(Inspector::JSGlobalObjectInspectorController::frontendInitialized):
(Inspector::JSGlobalObjectInspectorController::appendExtraAgent):
(Inspector::JSGlobalObjectInspectorController::ensureInspectorAgent): Added.
(Inspector::JSGlobalObjectInspectorController::ensureDebuggerAgent): Added.
(Inspector::JSGlobalObjectInspectorController::createLazyAgents):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (244284 => 244285)
--- trunk/Source/_javascript_Core/ChangeLog 2019-04-15 20:18:48 UTC (rev 244284)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-04-15 20:29:30 UTC (rev 244285)
@@ -1,3 +1,23 @@
+2019-04-15 Devin Rousso <[email protected]>
+
+ Web Inspector: REGRESSION(r244172): crash when trying to add extra domain while inspecting JSContext
+ https://bugs.webkit.org/show_bug.cgi?id=196925
+ <rdar://problem/49873994>
+
+ Reviewed by Joseph Pecoraro.
+
+ Move the logic for creating the `InspectorAgent` and `InspectorDebuggerAgent` into separate
+ functions so that callers can be guaranteed to have a valid instance of the agent.
+
+ * inspector/JSGlobalObjectInspectorController.h:
+ * inspector/JSGlobalObjectInspectorController.cpp:
+ (Inspector::JSGlobalObjectInspectorController::connectFrontend):
+ (Inspector::JSGlobalObjectInspectorController::frontendInitialized):
+ (Inspector::JSGlobalObjectInspectorController::appendExtraAgent):
+ (Inspector::JSGlobalObjectInspectorController::ensureInspectorAgent): Added.
+ (Inspector::JSGlobalObjectInspectorController::ensureDebuggerAgent): Added.
+ (Inspector::JSGlobalObjectInspectorController::createLazyAgents):
+
2019-04-14 Don Olmstead <[email protected]>
[CMake] _javascript_Core derived sources should only be referenced inside _javascript_Core
Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp (244284 => 244285)
--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp 2019-04-15 20:18:48 UTC (rev 244284)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp 2019-04-15 20:29:30 UTC (rev 244285)
@@ -118,8 +118,7 @@
m_agents.didCreateFrontendAndBackend(nullptr, nullptr);
#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
- ASSERT(m_inspectorAgent);
- m_inspectorAgent->activateExtraDomains(m_agents.extraDomains());
+ ensureInspectorAgent().activateExtraDomains(m_agents.extraDomains());
if (m_augmentingClient)
m_augmentingClient->inspectorConnected();
@@ -237,10 +236,9 @@
if (m_pauseAfterInitialization) {
m_pauseAfterInitialization = false;
- ASSERT(m_debuggerAgent);
ErrorString ignored;
- m_debuggerAgent->enable(ignored);
- m_debuggerAgent->pause(ignored);
+ ensureDebuggerAgent().enable(ignored);
+ ensureDebuggerAgent().pause(ignored);
}
#if ENABLE(REMOTE_INSPECTOR)
@@ -274,11 +272,33 @@
m_agents.appendExtraAgent(WTFMove(agent));
- ASSERT(m_inspectorAgent);
- m_inspectorAgent->activateExtraDomain(domainName);
+ ensureInspectorAgent().activateExtraDomain(domainName);
}
#endif
+InspectorAgent& JSGlobalObjectInspectorController::ensureInspectorAgent()
+{
+ if (!m_inspectorAgent) {
+ auto context = jsAgentContext();
+ auto inspectorAgent = std::make_unique<InspectorAgent>(context);
+ m_inspectorAgent = inspectorAgent.get();
+ m_agents.append(WTFMove(inspectorAgent));
+ }
+ return *m_inspectorAgent;
+}
+
+InspectorDebuggerAgent& JSGlobalObjectInspectorController::ensureDebuggerAgent()
+{
+ if (!m_debuggerAgent) {
+ auto context = jsAgentContext();
+ auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, m_consoleAgent);
+ m_debuggerAgent = debuggerAgent.get();
+ m_consoleClient->setInspectorDebuggerAgent(m_debuggerAgent);
+ m_agents.append(WTFMove(debuggerAgent));
+ }
+ return *m_debuggerAgent;
+}
+
JSAgentContext JSGlobalObjectInspectorController::jsAgentContext()
{
AgentContext baseContext = {
@@ -305,16 +325,11 @@
auto context = jsAgentContext();
- auto inspectorAgent = std::make_unique<InspectorAgent>(context);
- m_inspectorAgent = inspectorAgent.get();
- m_agents.append(WTFMove(inspectorAgent));
+ ensureInspectorAgent();
m_agents.append(std::make_unique<JSGlobalObjectRuntimeAgent>(context));
- auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, m_consoleAgent);
- m_debuggerAgent = debuggerAgent.get();
- m_consoleClient->setInspectorDebuggerAgent(m_debuggerAgent);
- m_agents.append(WTFMove(debuggerAgent));
+ ensureDebuggerAgent();
auto scriptProfilerAgentPtr = std::make_unique<InspectorScriptProfilerAgent>(context);
m_consoleClient->setInspectorScriptProfilerAgent(scriptProfilerAgentPtr.get());
Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.h (244284 => 244285)
--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.h 2019-04-15 20:18:48 UTC (rev 244284)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.h 2019-04-15 20:29:30 UTC (rev 244285)
@@ -104,6 +104,9 @@
private:
void appendAPIBacktrace(ScriptCallStack&);
+ InspectorAgent& ensureInspectorAgent();
+ InspectorDebuggerAgent& ensureDebuggerAgent();
+
JSAgentContext jsAgentContext();
void createLazyAgents();
@@ -114,8 +117,10 @@
JSGlobalObjectScriptDebugServer m_scriptDebugServer;
AgentRegistry m_agents;
+ InspectorConsoleAgent* m_consoleAgent { nullptr };
+
+ // Lazy, but also on-demand agents.
InspectorAgent* m_inspectorAgent { nullptr };
- InspectorConsoleAgent* m_consoleAgent { nullptr };
InspectorDebuggerAgent* m_debuggerAgent { nullptr };
Ref<FrontendRouter> m_frontendRouter;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes