Changeset 244285 in webkit


Ignore:
Timestamp:
Apr 15, 2019 1:29:30 PM (5 years ago)
Author:
Devin Rousso
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):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r244245 r244285  
     12019-04-15  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: REGRESSION(r244172): crash when trying to add extra domain while inspecting JSContext
     4        https://bugs.webkit.org/show_bug.cgi?id=196925
     5        <rdar://problem/49873994>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        Move the logic for creating the `InspectorAgent` and `InspectorDebuggerAgent` into separate
     10        functions so that callers can be guaranteed to have a valid instance of the agent.
     11
     12        * inspector/JSGlobalObjectInspectorController.h:
     13        * inspector/JSGlobalObjectInspectorController.cpp:
     14        (Inspector::JSGlobalObjectInspectorController::connectFrontend):
     15        (Inspector::JSGlobalObjectInspectorController::frontendInitialized):
     16        (Inspector::JSGlobalObjectInspectorController::appendExtraAgent):
     17        (Inspector::JSGlobalObjectInspectorController::ensureInspectorAgent): Added.
     18        (Inspector::JSGlobalObjectInspectorController::ensureDebuggerAgent): Added.
     19        (Inspector::JSGlobalObjectInspectorController::createLazyAgents):
     20
    1212019-04-14  Don Olmstead  <don.olmstead@sony.com>
    222
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp

    r244172 r244285  
    119119
    120120#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
    121     ASSERT(m_inspectorAgent);
    122     m_inspectorAgent->activateExtraDomains(m_agents.extraDomains());
     121    ensureInspectorAgent().activateExtraDomains(m_agents.extraDomains());
    123122
    124123    if (m_augmentingClient)
     
    238237        m_pauseAfterInitialization = false;
    239238
    240         ASSERT(m_debuggerAgent);
    241239        ErrorString ignored;
    242         m_debuggerAgent->enable(ignored);
    243         m_debuggerAgent->pause(ignored);
     240        ensureDebuggerAgent().enable(ignored);
     241        ensureDebuggerAgent().pause(ignored);
    244242    }
    245243
     
    275273    m_agents.appendExtraAgent(WTFMove(agent));
    276274
    277     ASSERT(m_inspectorAgent);
    278     m_inspectorAgent->activateExtraDomain(domainName);
    279 }
    280 #endif
     275    ensureInspectorAgent().activateExtraDomain(domainName);
     276}
     277#endif
     278
     279InspectorAgent& JSGlobalObjectInspectorController::ensureInspectorAgent()
     280{
     281    if (!m_inspectorAgent) {
     282        auto context = jsAgentContext();
     283        auto inspectorAgent = std::make_unique<InspectorAgent>(context);
     284        m_inspectorAgent = inspectorAgent.get();
     285        m_agents.append(WTFMove(inspectorAgent));
     286    }
     287    return *m_inspectorAgent;
     288}
     289
     290InspectorDebuggerAgent& JSGlobalObjectInspectorController::ensureDebuggerAgent()
     291{
     292    if (!m_debuggerAgent) {
     293        auto context = jsAgentContext();
     294        auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, m_consoleAgent);
     295        m_debuggerAgent = debuggerAgent.get();
     296        m_consoleClient->setInspectorDebuggerAgent(m_debuggerAgent);
     297        m_agents.append(WTFMove(debuggerAgent));
     298    }
     299    return *m_debuggerAgent;
     300}
    281301
    282302JSAgentContext JSGlobalObjectInspectorController::jsAgentContext()
     
    306326    auto context = jsAgentContext();
    307327
    308     auto inspectorAgent = std::make_unique<InspectorAgent>(context);
    309     m_inspectorAgent = inspectorAgent.get();
    310     m_agents.append(WTFMove(inspectorAgent));
     328    ensureInspectorAgent();
    311329
    312330    m_agents.append(std::make_unique<JSGlobalObjectRuntimeAgent>(context));
    313331
    314     auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, m_consoleAgent);
    315     m_debuggerAgent = debuggerAgent.get();
    316     m_consoleClient->setInspectorDebuggerAgent(m_debuggerAgent);
    317     m_agents.append(WTFMove(debuggerAgent));
     332    ensureDebuggerAgent();
    318333
    319334    auto scriptProfilerAgentPtr = std::make_unique<InspectorScriptProfilerAgent>(context);
  • trunk/Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h

    r239976 r244285  
    105105    void appendAPIBacktrace(ScriptCallStack&);
    106106
     107    InspectorAgent& ensureInspectorAgent();
     108    InspectorDebuggerAgent& ensureDebuggerAgent();
     109
    107110    JSAgentContext jsAgentContext();
    108111    void createLazyAgents();
     
    115118
    116119    AgentRegistry m_agents;
     120    InspectorConsoleAgent* m_consoleAgent { nullptr };
     121
     122    // Lazy, but also on-demand agents.
    117123    InspectorAgent* m_inspectorAgent { nullptr };
    118     InspectorConsoleAgent* m_consoleAgent { nullptr };
    119124    InspectorDebuggerAgent* m_debuggerAgent { nullptr };
    120125
Note: See TracChangeset for help on using the changeset viewer.