Ignore:
Timestamp:
Aug 24, 2020, 10:34:12 AM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: allow event breakpoints to be configured
https://bugs.webkit.org/show_bug.cgi?id=215362
<rdar://problem/66932921>

Reviewed by Brian Burg.

Source/JavaScriptCore:

This allows developers to do things like:

  • only pause when window.event.type is a certain value
  • ignore the first N pauses
  • evaluate JavaScript whenever an event listener is invoked without pausing
  • inspector/protocol/DOM.json:

Add an options paramater to DOM.setBreakpointForEventListener to allow configuration.

  • inspector/protocol/DOMDebugger.json:

Add an options paramater to DOMDebugger.setEventBreakpoint to allow configuration.

  • debugger/Breakpoint.h:

(JSC::Breakpoint::id const): Added.
(JSC::Breakpoint::sourceID const): Added.
(JSC::Breakpoint::lineNumber const): Added.
(JSC::Breakpoint::columnNumber const): Added.
(JSC::Breakpoint::condition const): Added.
(JSC::Breakpoint::actions const): Added.
(JSC::Breakpoint::isAutoContinue const): Added.
(JSC::Breakpoint::resetHitCount): Added.
(JSC::Breakpoint::isLinked const): Added.
(JSC::Breakpoint::isResolved const): Added.
(JSC::BreakpointsList::~BreakpointsList): Deleted.

  • debugger/Breakpoint.cpp: Added.

(JSC::Breakpoint::Action::Action): Added.
(JSC::Breakpoint::create): Added.
(JSC::Breakpoint::Breakpoint): Added.
(JSC::Breakpoint::link): Added.
(JSC::Breakpoint::resolve): Added.
(JSC::Breakpoint::shouldPause): Added.
Unify JSC::Breakpoint and Inspector::ScriptBreakpoint.

  • debugger/DebuggerPrimitives.h:
  • debugger/Debugger.h:
  • debugger/Debugger.cpp:

(JSC::Debugger::Debugger):
(JSC::Debugger::addObserver): Added.
(JSC::Debugger::removeObserver): Added.
(JSC::Debugger::canDispatchFunctionToObservers const): Added.
(JSC::Debugger::dispatchFunctionToObservers): Added.
(JSC::Debugger::sourceParsed): Added.
(JSC::Debugger::toggleBreakpoint):
(JSC::Debugger::applyBreakpoints):
(JSC::Debugger::resolveBreakpoint):
(JSC::Debugger::setBreakpoint):
(JSC::Debugger::removeBreakpoint):
(JSC::Debugger::didHitBreakpoint): Added.
(JSC::Debugger::clearBreakpoints):
(JSC::Debugger::evaluateBreakpointCondition): Added.
(JSC::Debugger::evaluateBreakpointActions): Added.
(JSC::Debugger::schedulePauseAtNextOpportunity): Added.
(JSC::Debugger::cancelPauseAtNextOpportunity): Added.
(JSC::Debugger::schedulePauseForSpecialBreakpoint): Added.
(JSC::Debugger::cancelPauseForSpecialBreakpoint): Added.
(JSC::Debugger::continueProgram):
(JSC::Debugger::stepNextExpression):
(JSC::Debugger::stepIntoStatement):
(JSC::Debugger::stepOverStatement):
(JSC::Debugger::stepOutOfFunction):
(JSC::Debugger::pauseIfNeeded):
(JSC::Debugger::handlePause): Added.
(JSC::Debugger::exceptionOrCaughtValue): Added.
(JSC::Debugger::atExpression):
(JSC::Debugger::clearNextPauseState):
(JSC::Debugger::willRunMicrotask): Added.
(JSC::Debugger::didRunMicrotask): Added.
(JSC::Debugger::hasBreakpoint): Deleted.
(JSC::Debugger::setPauseOnNextStatement): Deleted.
Unify JSC::Debugger and Inspector::ScriptDebugServer to simplify breakpoint logic.
Introduce the concept of a "special breakpoint", which is essentially a JSC::Breakpoint
that is expected to pause at the next opportunity but isn't tied to a particular location.
As an example, whenever an event breakpoint is hit, instead of just pausing at the next
opportunity, the newly managed JSC::Breakpoint is used as a "special breakpoint", allowing
for it's configuration (ie.g. condition, ignore count, actions, auto-continue) to be used.

  • inspector/agents/InspectorDebuggerAgent.h:
  • inspector/agents/InspectorDebuggerAgent.cpp:

(Inspector::objectGroupForBreakpointAction):
(Inspector::breakpointActionTypeForString): Added.
(Inspector::parseBreakpointOptions): Added.
(Inspector::InspectorDebuggerAgent::ProtocolBreakpoint::fromPayload): Added.
(Inspector::InspectorDebuggerAgent::ProtocolBreakpoint::ProtocolBreakpoint): Added.
(Inspector::InspectorDebuggerAgent::ProtocolBreakpoint::createDebuggerBreakpoint const): Added.
(Inspector::InspectorDebuggerAgent::ProtocolBreakpoint::matchesScriptURL const): Added.
(Inspector::InspectorDebuggerAgent::debuggerBreakpointFromPayload): Added.
(Inspector::InspectorDebuggerAgent::enable):
(Inspector::InspectorDebuggerAgent::disable):
(Inspector::InspectorDebuggerAgent::buildBreakpointPauseReason):
(Inspector::InspectorDebuggerAgent::handleConsoleAssert):
(Inspector::InspectorDebuggerAgent::didScheduleAsyncCall):
(Inspector::buildDebuggerLocation):
(Inspector::InspectorDebuggerAgent::setBreakpointByUrl):
(Inspector::InspectorDebuggerAgent::setBreakpoint):
(Inspector::InspectorDebuggerAgent::didSetBreakpoint):
(Inspector::InspectorDebuggerAgent::resolveBreakpoint):
(Inspector::InspectorDebuggerAgent::removeBreakpoint):
(Inspector::InspectorDebuggerAgent::continueToLocation):
(Inspector::InspectorDebuggerAgent::schedulePauseAtNextOpportunity): Added.
(Inspector::InspectorDebuggerAgent::cancelPauseAtNextOpportunity): Added.
(Inspector::InspectorDebuggerAgent::schedulePauseForSpecialBreakpoint): Added.
(Inspector::InspectorDebuggerAgent::cancelPauseForSpecialBreakpoint): Added.
(Inspector::InspectorDebuggerAgent::pause):
(Inspector::InspectorDebuggerAgent::resume):
(Inspector::InspectorDebuggerAgent::didBecomeIdle):
(Inspector::InspectorDebuggerAgent::sourceMapURLForScript):
(Inspector::InspectorDebuggerAgent::didParseSource):
(Inspector::InspectorDebuggerAgent::willRunMicrotask):
(Inspector::InspectorDebuggerAgent::didRunMicrotask):
(Inspector::InspectorDebuggerAgent::didPause):
(Inspector::InspectorDebuggerAgent::breakpointActionSound):
(Inspector::InspectorDebuggerAgent::breakpointActionProbe):
(Inspector::InspectorDebuggerAgent::clearInspectorBreakpointState):
(Inspector::InspectorDebuggerAgent::clearDebuggerBreakpointState):
(Inspector::matches): Deleted.
(Inspector::buildObjectForBreakpointCookie): Deleted.
(Inspector::InspectorDebuggerAgent::breakpointActionsFromProtocol): Deleted.
(Inspector::InspectorDebuggerAgent::schedulePauseOnNextStatement): Deleted.
(Inspector::InspectorDebuggerAgent::cancelPauseOnNextStatement): Deleted.
Create a private ProtocolBreakpoint class that holds the data sent by the frontend. This
is necessary because breakpoints in the frontend have a potentially one-to-many relationship
with breakpoints in the backend, as the same script can be loaded many times on a page. Each
of those scripts is independent, however, and can execute differently, meaning that the same
breakpoint for each script also needs a different state (e.g. ignore count). As such, the
ProtocolBreakpoint is effectively a template that is actualized whenever a new script is
parsed that matches the URL of the ProtocolBreakpoint to create a JSC::Breakpoint that
is used by the JSC::Debugger. ProtocolBreakpoint also parses breakpoint configurations.

  • inspector/InspectorEnvironment.h:
  • inspector/JSGlobalObjectScriptDebugServer.h:
  • inspector/JSGlobalObjectScriptDebugServer.cpp:

(Inspector::JSGlobalObjectScriptDebugServer::JSGlobalObjectScriptDebugServer):
(Inspector::JSGlobalObjectScriptDebugServer::attachDebugger):
(Inspector::JSGlobalObjectScriptDebugServer::detachDebugger):
(Inspector::JSGlobalObjectScriptDebugServer::runEventLoopWhilePaused):

  • inspector/agents/InspectorAuditAgent.h:
  • inspector/agents/InspectorAuditAgent.cpp:

(Inspector::InspectorAuditAgent::run):

  • inspector/agents/InspectorRuntimeAgent.h:
  • inspector/agents/InspectorRuntimeAgent.cpp:

(Inspector::setPauseOnExceptionsState):
(Inspector::InspectorRuntimeAgent::evaluate):
(Inspector::InspectorRuntimeAgent::callFunctionOn):
(Inspector::InspectorRuntimeAgent::getPreview):
(Inspector::InspectorRuntimeAgent::getProperties):
(Inspector::InspectorRuntimeAgent::getDisplayableProperties):

  • inspector/agents/InspectorScriptProfilerAgent.cpp:
  • inspector/agents/JSGlobalObjectDebuggerAgent.h:

Replace Inspector::ScriptDebugServer with JSC::Debugger.

  • runtime/JSMicrotask.cpp:

(JSC::JSMicrotask::run):
Drive-by: r248894 mistakenly omitted the call to notify the debugger that the microtask ran.

  • inspector/ScriptBreakpoint.h: Removed.
  • inspector/ScriptDebugListener.h: Removed.
  • inspector/ScriptDebugServer.h: Removed.
  • inspector/ScriptDebugServer.cpp: Removed.
  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:

Source/WebCore:

This allows developers to do things like:

  • only pause when window.event.type is a certain value
  • ignore the first N pauses
  • evaluate JavaScript whenever an event listener is invoked without pausing

Tests: inspector/dom/breakpoint-for-event-listener.html

inspector/dom-debugger/event-animation-frame-breakpoints.html
inspector/dom-debugger/event-interval-breakpoints.html
inspector/dom-debugger/event-listener-breakpoints.html
inspector/dom-debugger/event-timeout-breakpoints.html

  • inspector/agents/InspectorDOMAgent.h:
  • inspector/agents/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::getEventListenersForNode):
(WebCore::InspectorDOMAgent::setBreakpointForEventListener):
(WebCore::InspectorDOMAgent::removeBreakpointForEventListener):
(WebCore::InspectorDOMAgent::buildObjectForEventListener):
(WebCore::InspectorDOMAgent::breakpointForEventListener):
(WebCore::InspectorDOMAgent::hasBreakpointForEventListener): Deleted.

  • inspector/agents/InspectorDOMDebuggerAgent.h:
  • inspector/agents/InspectorDOMDebuggerAgent.cpp:

(WebCore::InspectorDOMDebuggerAgent::disable):
(WebCore::InspectorDOMDebuggerAgent::mainFrameNavigated):
(WebCore::InspectorDOMDebuggerAgent::setEventBreakpoint):
(WebCore::InspectorDOMDebuggerAgent::removeEventBreakpoint):
(WebCore::InspectorDOMDebuggerAgent::willHandleEvent):
(WebCore::InspectorDOMDebuggerAgent::didHandleEvent):
(WebCore::InspectorDOMDebuggerAgent::willFireTimer):
(WebCore::InspectorDOMDebuggerAgent::didFireTimer):

  • inspector/agents/page/PageDOMDebuggerAgent.h:
  • inspector/agents/page/PageDOMDebuggerAgent.cpp:

(WebCore::PageDOMDebuggerAgent::disable):
(WebCore::PageDOMDebuggerAgent::mainFrameNavigated):
(WebCore::PageDOMDebuggerAgent::willFireAnimationFrame):
(WebCore::PageDOMDebuggerAgent::didFireAnimationFrame):
(WebCore::PageDOMDebuggerAgent::setAnimationFrameBreakpoint):

  • inspector/agents/worker/WorkerDOMDebuggerAgent.h:
  • inspector/agents/worker/WorkerDOMDebuggerAgent.cpp:

(WebCore::WorkerDOMDebuggerAgent::setAnimationFrameBreakpoint):
Keep a JSC::Breakpoint for each event breakpoint instead of a simple bool, allowing for
configuration when the breakpoint is first set. When any of these breakpoints are hit, pass
it to the JSC::Debugger as a "special breakpoint", which behaves the same as "pause ASAP"
but also supports a condition, an ignore count, actions, and auto-continue. Reset the hit
count for any of these "special breakpoints" that persist across Web Inspector sessions
when the main frame navigates.

  • inspector/PageScriptDebugServer.h:
  • inspector/PageScriptDebugServer.cpp:

(WebCore::PageScriptDebugServer::PageScriptDebugServer):
(WebCore::PageScriptDebugServer::attachDebugger):
(WebCore::PageScriptDebugServer::detachDebugger):
(WebCore::PageScriptDebugServer::didPause):
(WebCore::PageScriptDebugServer::didContinue):
(WebCore::PageScriptDebugServer::runEventLoopWhilePaused):
(WebCore::PageScriptDebugServer::runEventLoopWhilePausedInternal):
(WebCore::PageScriptDebugServer::isContentScript const):
(WebCore::PageScriptDebugServer::reportException const):

  • inspector/WorkerScriptDebugServer.h:
  • inspector/WorkerScriptDebugServer.cpp:

(WebCore::WorkerScriptDebugServer::WorkerScriptDebugServer):
(WebCore::WorkerScriptDebugServer::attachDebugger):
(WebCore::WorkerScriptDebugServer::detachDebugger):
(WebCore::WorkerScriptDebugServer::runEventLoopWhilePaused):
(WebCore::WorkerScriptDebugServer::reportException const):

  • inspector/agents/page/PageDebuggerAgent.h:
  • inspector/agents/page/PageDebuggerAgent.cpp:

(WebCore::PageDebuggerAgent::sourceMapURLForScript):
Replace Inspector::ScriptDebugServer with JSC::Debugger.

  • inspector/TimelineRecordFactory.h:
  • inspector/TimelineRecordFactory.cpp:

(WebCore::TimelineRecordFactory::createProbeSampleData):

  • inspector/agents/InspectorTimelineAgent.h:
  • inspector/agents/InspectorTimelineAgent.cpp:

(WebCore::InspectorTimelineAgent::internalStart):
(WebCore::InspectorTimelineAgent::internalStop):
(WebCore::InspectorTimelineAgent::breakpointActionProbe):
Replace Inspector::ScriptBreakpoint with JSC::Breakpoint.

  • inspector/InspectorInstrumentation.h:

(WebCore::InspectorInstrumentation::didHandleEvent):
(WebCore::InspectorInstrumentation::didFireTimer):

  • inspector/InspectorInstrumentation.cpp:

(WebCore::InspectorInstrumentation::didHandleEventImpl):
(WebCore::InspectorInstrumentation::didFireTimerImpl):
(WebCore::InspectorInstrumentation::didCommitLoadImpl):
(WebCore::InspectorInstrumentation::didFireAnimationFrameImpl):

  • dom/EventTarget.cpp:

(WebCore::EventTarget::innerInvokeEventListeners):

  • page/DOMTimer.cpp:

(WebCore::DOMTimer::fired):
When notifying Web Inspector that activity did occur, include all information previously
included when notifying Web Inspector that that activity was about to occur so that Web
Inspector can know whether a pause for the "special breakpoint" for that activity is still
scheduled and if so cancel it.

Source/WebInspectorUI:

This allows developers to do things like:

  • only pause when window.event.type is a certain value
  • ignore the first N pauses
  • evaluate JavaScript whenever an event listener is invoked without pausing
  • UserInterface/Models/Breakpoint.js:

(WI.Breakpoint):
(WI.Breakpoint.prototype.toJSON):
(WI.Breakpoint.prototype.get special): Added.
(WI.Breakpoint.prototype.get removable): Added.
(WI.Breakpoint.prototype.get editable): Added.
(WI.Breakpoint.prototype.set condition):
(WI.Breakpoint.prototype.get ignoreCount):
(WI.Breakpoint.prototype.set ignoreCount):
(WI.Breakpoint.prototype.get autoContinue):
(WI.Breakpoint.prototype.set autoContinue):
(WI.Breakpoint.prototype.get actions):
(WI.Breakpoint.prototype.get probeActions):
(WI.Breakpoint.prototype.cycleToNextMode):
(WI.Breakpoint.prototype.createAction):
(WI.Breakpoint.prototype.recreateAction):
(WI.Breakpoint.prototype.removeAction):
(WI.Breakpoint.prototype.clearActions):
(WI.Breakpoint.prototype.remove): Added.
(WI.Breakpoint.prototype.optionsToProtocol): Added.
(WI.Breakpoint.prototype.breakpointActionDidChange):
(WI.Breakpoint.fromJSON): Deleted.
(WI.Breakpoint.prototype.get sourceCodeLocation): Deleted.
(WI.Breakpoint.prototype.get contentIdentifier): Deleted.
(WI.Breakpoint.prototype.get scriptIdentifier): Deleted.
(WI.Breakpoint.prototype.get target): Deleted.
(WI.Breakpoint.prototype.get identifier): Deleted.
(WI.Breakpoint.prototype.set identifier): Deleted.
(WI.Breakpoint.prototype.get resolved): Deleted.
(WI.Breakpoint.prototype.set resolved): Deleted.
(WI.Breakpoint.prototype.saveIdentityToCookie): Deleted.
(WI.Breakpoint.prototype._isSpecial): Deleted.
(WI.Breakpoint.prototype._sourceCodeLocationLocationChanged): Deleted.
(WI.Breakpoint.prototype._sourceCodeLocationDisplayLocationChanged): Deleted.

  • UserInterface/Models/DOMBreakpoint.js:

(WI.DOMBreakpoint):
(WI.DOMBreakpoint.fromJSON): Added.
(WI.DOMBreakpoint.prototype.remove): Added.
(WI.DOMBreakpoint.prototype.toJSON):
(WI.DOMBreakpoint.deserialize): Deleted.
(WI.DOMBreakpoint.prototype.get disabled): Deleted.
(WI.DOMBreakpoint.prototype.set disabled): Deleted.

  • UserInterface/Models/EventBreakpoint.js:

(WI.EventBreakpoint):
(WI.EventBreakpoint.fromJSON): Added.
(WI.EventBreakpoint.prototype.get special): Added.
(WI.EventBreakpoint.prototype.get editable): Added.
(WI.EventBreakpoint.prototype.remove): Added.
(WI.EventBreakpoint.prototype.saveIdentityToCookie):
(WI.EventBreakpoint.prototype.toJSON):
(WI.EventBreakpoint.deserialize): Deleted.
(WI.EventBreakpoint.prototype.get disabled): Deleted.
(WI.EventBreakpoint.prototype.set disabled): Deleted.

  • UserInterface/Models/JavaScriptBreakpoint.js: Copied from UserInterface/Models/Breakpoint.js.

(WI.JavaScriptBreakpoint):
(WI.JavaScriptBreakpoint.fromJSON):
(WI.JavaScriptBreakpoint.prototype.toJSON):
(WI.JavaScriptBreakpoint.prototype.get sourceCodeLocation):
(WI.JavaScriptBreakpoint.prototype.get contentIdentifier):
(WI.JavaScriptBreakpoint.prototype.get scriptIdentifier):
(WI.JavaScriptBreakpoint.prototype.get target):
(WI.JavaScriptBreakpoint.prototype.get special): Added.
(WI.JavaScriptBreakpoint.prototype.get removable): Added.
(WI.JavaScriptBreakpoint.prototype.get editable): Added.
(WI.JavaScriptBreakpoint.prototype.get identifier):
(WI.JavaScriptBreakpoint.prototype.set identifier):
(WI.JavaScriptBreakpoint.prototype.get resolved):
(WI.JavaScriptBreakpoint.prototype.set resolved):
(WI.JavaScriptBreakpoint.prototype.remove): Added.
(WI.JavaScriptBreakpoint.prototype.saveIdentityToCookie):
(WI.JavaScriptBreakpoint.prototype._isSpecial):
(WI.JavaScriptBreakpoint.prototype._sourceCodeLocationLocationChanged):
(WI.JavaScriptBreakpoint.prototype._sourceCodeLocationDisplayLocationChanged):

  • UserInterface/Models/URLBreakpoint.js:

(WI.URLBreakpoint):
(WI.URLBreakpoint.fromJSON): Added.
(WI.URLBreakpoint.prototype.get special): Added.
(WI.URLBreakpoint.prototype.remove): Added.
(WI.URLBreakpoint.prototype.toJSON):
(WI.URLBreakpoint.deserialize): Deleted.
(WI.URLBreakpoint.prototype.get disabled): Deleted.
(WI.URLBreakpoint.prototype.set disabled): Deleted.
Rename WI.Breakpoint to WI.JavaScriptBreakpoint and use WI.Breakpoint as a new common
base class for all breakpoint types, allowing more logic to be shared (e.g. disabled state).
Additionally, breakpoints are now able to

  • determine whether or not they're
    • special
    • removable
    • editable (i.e. configurable)
  • remove themselves

without the caller needing to know what manager to consult with.

  • UserInterface/Controllers/DOMManager.js:

(WI.DOMManager):
(WI.DOMManager.supportsEventListenerBreakpointConfiguration): Added.
(WI.DOMManager.prototype.setBreakpointForEventListener):
(WI.DOMManager.prototype.removeBreakpointForEventListener):
(WI.DOMManager.prototype._setEventBreakpoint): Added.
(WI.DOMManager.prototype._removeEventBreakpoint): Added.
(WI.DOMManager.prototype._handleEventBreakpointEditablePropertyChanged): Added.
(WI.DOMManager.prototype._handleEventBreakpointActionsChanged): Added.
(WI.DOMManager.prototype._updateEventBreakpoint): Deleted.
Keep track of configuration changes for specific listener breakpoints.

  • UserInterface/Controllers/DOMDebuggerManager.js:

(WI.DOMDebuggerManager):
(WI.DOMDebuggerManager.prototype.initializeTarget):
(WI.DOMDebuggerManager.prototype.addDOMBreakpoint):
(WI.DOMDebuggerManager.prototype.removeDOMBreakpoint):
(WI.DOMDebuggerManager.prototype.addEventBreakpoint):
(WI.DOMDebuggerManager.prototype.removeEventBreakpoint):
(WI.DOMDebuggerManager.prototype.addURLBreakpoint):
(WI.DOMDebuggerManager.prototype.removeURLBreakpoint):
(WI.DOMDebuggerManager.prototype._commandArgumentsForEventBreakpoint): Added.
(WI.DOMDebuggerManager.prototype._setEventBreakpoint): Added.
(WI.DOMDebuggerManager.prototype._removeEventBreakpoint): Added.
(WI.DOMDebuggerManager.prototype._handleEventBreakpointDisabledStateChanged): Added.
(WI.DOMDebuggerManager.prototype._handleEventBreakpointEditablePropertyChanged): Added.
(WI.DOMDebuggerManager.prototype._handleEventBreakpointActionsChanged): Added.
(WI.DOMDebuggerManager.prototype.isBreakpointSpecial): Deleted.
(WI.DOMDebuggerManager.prototype._updateEventBreakpoint): Deleted.
Keep track of configuration changes for special event breakpoints.
Store special event breakpoints inside WI.objectStores.eventBreakpoints.

  • UserInterface/Controllers/DebuggerManager.js:

(WI.DebuggerManager):
(WI.DebuggerManager.prototype.addBreakpoint):
(WI.DebuggerManager.prototype.removeBreakpoint):
(WI.DebuggerManager.prototype.addProbesForBreakpoint): Added.
(WI.DebuggerManager.prototype.removeProbesForBreakpoint): Added.
(WI.DebuggerManager.prototype.updateProbesForBreakpoint): Added.
(WI.DebuggerManager.prototype._setBreakpoint):
(WI.DebuggerManager.prototype._breakpointEditablePropertyDidChange):
(WI.DebuggerManager.prototype._handleBreakpointActionsDidChange):
(WI.DebuggerManager.prototype.isBreakpointRemovable): Deleted.
(WI.DebuggerManager.prototype.isBreakpointSpecial): Deleted.
(WI.DebuggerManager.prototype.isBreakpointEditable): Deleted.
(WI.DebuggerManager.prototype._debuggerBreakpointActionType): Deleted.
(WI.DebuggerManager.prototype._debuggerBreakpointOptions): Deleted.
(WI.DebuggerManager.prototype._addProbesForBreakpoint): Deleted.
(WI.DebuggerManager.prototype._removeProbesForBreakpoint): Deleted.
(WI.DebuggerManager.prototype._updateProbesForBreakpoint): Deleted.
Replace WI.Breakpoint with WI.JavaScriptBreakpoint.
Probes now support WI.EventBreakpoint in addition to WI.JavaScriptBreakpoint.

  • UserInterface/Controllers/BreakpointPopoverController.js:

(WI.BreakpointPopoverController.prototype.appendContextMenuItems):
(WI.BreakpointPopoverController.prototype._createPopoverContent):
Allow any breakpoint instead of only WI.JavaScriptBreakpoint.
Drive-by: the existing ignoreCount value wasn't being used to populate the <input>.

  • UserInterface/Views/BreakpointTreeElement.js:

(WI.BreakpointTreeElement.prototype.ondelete):
(WI.BreakpointTreeElement.prototype.get listenerSet): Added.
(WI.BreakpointTreeElement.prototype.updateStatus): Added.
(WI.BreakpointTreeElement.prototype.updateTitles): Added.
(WI.BreakpointTreeElement.prototype.get breakpoint): Deleted.
(WI.BreakpointTreeElement.prototype.get filterableData): Deleted.
(WI.BreakpointTreeElement.prototype._updateTitles): Deleted.
(WI.BreakpointTreeElement.prototype._updateStatus): Deleted.
(WI.BreakpointTreeElement.prototype._breakpointLocationDidChange): Deleted.

  • UserInterface/Views/BreakpointTreeElement.css:

(.item.breakpoint .status > .status-image):
(.item.breakpoint.paused .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.paused .icon): Added.
(.item.breakpoint .status > .status-image.resolved): Deleted.
(body:not(.window-inactive, .window-docked-inactive) .tree-outline:focus-within .item.breakpoint.selected .status > .status-image.resolved): Deleted.
(.item.breakpoint .subtitle.formatted-location): Deleted.
(.breakpoint-debugger-statement-icon .icon): Deleted.
(.breakpoint-exception-icon .icon): Deleted.
(.breakpoint-assertion-icon .icon): Deleted.
(.breakpoint-microtask-icon .icon): Deleted.
(.breakpoint-paused-icon .icon): Deleted.
(.breakpoint-generic-line-icon .icon): Deleted.
(.breakpoint-generic-line-icon .icon > span): Deleted.
(.data-updated.breakpoint-generic-line-icon .icon > span): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint-debugger-statement-icon .icon): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint-exception-icon .icon): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint-assertion-icon .icon): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint-microtask-icon .icon): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint-paused-icon .icon): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint-generic-line-icon .icon): Deleted.

  • UserInterface/Views/DOMBreakpointTreeElement.js:

(WI.DOMBreakpointTreeElement):
(WI.DOMBreakpointTreeElement.prototype.onattach): Deleted.
(WI.DOMBreakpointTreeElement.prototype.ondetach): Deleted.
(WI.DOMBreakpointTreeElement.prototype.ondelete): Deleted.
(WI.DOMBreakpointTreeElement.prototype.onenter): Deleted.
(WI.DOMBreakpointTreeElement.prototype.onspace): Deleted.
(WI.DOMBreakpointTreeElement.prototype.populateContextMenu): Deleted.
(WI.DOMBreakpointTreeElement.prototype._statusImageElementClicked): Deleted.
(WI.DOMBreakpointTreeElement.prototype._statusImageElementFocused): Deleted.
(WI.DOMBreakpointTreeElement.prototype._statusImageElementMouseDown): Deleted.
(WI.DOMBreakpointTreeElement.prototype._toggleBreakpoint): Deleted.
(WI.DOMBreakpointTreeElement.prototype._updateStatus): Deleted.

  • UserInterface/Views/DOMBreakpointTreeElement.css:

(.item.breakpoint.dom.subtree-modified:not(.paused) .icon): Added.
(.item.breakpoint.dom.attribute-modified:not(.paused) .icon): Added.
(.item.breakpoint.dom.node-removed:not(.paused) .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.dom.subtree-modified:not(.paused) .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.dom.attribute-modified:not(.paused) .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.dom.node-removed:not(.paused) .icon): Added.
(.breakpoint.dom.breakpoint-for-subtree-modified:not(.breakpoint-paused-icon) .icon): Deleted.
(.breakpoint.dom.breakpoint-for-attribute-modified:not(.breakpoint-paused-icon) .icon): Deleted.
(.breakpoint.dom.breakpoint-for-node-removed:not(.breakpoint-paused-icon) .icon): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint.dom.breakpoint-for-subtree-modified:not(.breakpoint-paused-icon) .icon): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint.dom.breakpoint-for-attribute-modified:not(.breakpoint-paused-icon) .icon): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint.dom.breakpoint-for-node-removed:not(.breakpoint-paused-icon) .icon): Deleted.

  • UserInterface/Views/EventBreakpointTreeElement.js:

(WI.EventBreakpointTreeElement):
(WI.EventBreakpointTreeElement.prototype.onattach): Deleted.
(WI.EventBreakpointTreeElement.prototype.ondetach): Deleted.
(WI.EventBreakpointTreeElement.prototype.ondelete): Deleted.
(WI.EventBreakpointTreeElement.prototype.onenter): Deleted.
(WI.EventBreakpointTreeElement.prototype.onspace): Deleted.
(WI.EventBreakpointTreeElement.prototype.populateContextMenu): Deleted.
(WI.EventBreakpointTreeElement.prototype._statusImageElementClicked): Deleted.
(WI.EventBreakpointTreeElement.prototype._statusImageElementFocused): Deleted.
(WI.EventBreakpointTreeElement.prototype._statusImageElementMouseDown): Deleted.
(WI.EventBreakpointTreeElement.prototype._toggleBreakpoint): Deleted.
(WI.EventBreakpointTreeElement.prototype._updateStatus): Deleted.

  • UserInterface/Views/EventBreakpointTreeElement.css:

(.item.breakpoint.event.animation-frame:not(.paused) .icon): Added.
(.item.breakpoint.event.interval:not(.paused) .icon): Added.
(.item.breakpoint.event.listener:not(.paused) .icon): Added.
(.item.breakpoint.event.timeout:not(.paused) .icon): Added.
(@media(prefers-color-scheme: dark) .item.breakpoint.event.animation-frame:not(.paused) .icon): Added.
(@media(prefers-color-scheme: dark) .item.breakpoint.event.interval:not(.paused) .icon): Added.
(@media(prefers-color-scheme: dark) .item.breakpoint.event.listener:not(.paused) .icon): Added.
(@media(prefers-color-scheme: dark) .item.breakpoint.event.timeout:not(.paused) .icon): Added.
(.breakpoint.event.breakpoint-for-animation-frame:not(.breakpoint-paused-icon) .icon): Deleted.
(.breakpoint.event.breakpoint-for-interval:not(.breakpoint-paused-icon) .icon): Deleted.
(.breakpoint.event.breakpoint-for-listener:not(.breakpoint-paused-icon) .icon): Deleted.
(.breakpoint.event.breakpoint-for-timeout:not(.breakpoint-paused-icon) .icon): Deleted.
(@media(prefers-color-scheme: dark) .breakpoint.event.breakpoint-for-animation-frame:not(.breakpoint-paused-icon) .icon): Deleted.
(@media(prefers-color-scheme: dark) .breakpoint.event.breakpoint-for-interval:not(.breakpoint-paused-icon) .icon): Deleted.
(@media(prefers-color-scheme: dark) .breakpoint.event.breakpoint-for-listener:not(.breakpoint-paused-icon) .icon): Deleted.
(@media(prefers-color-scheme: dark) .breakpoint.event.breakpoint-for-timeout:not(.breakpoint-paused-icon) .icon): Deleted.

  • UserInterface/Views/JavaScriptBreakpointTreeElement.js: Copied from Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.js.

(WI.JavaScriptBreakpointTreeElement):
(WI.JavaScriptBreakpointTreeElement.prototype.get filterableData):
(WI.JavaScriptBreakpointTreeElement.prototype.updateStatus): Added.
(WI.JavaScriptBreakpointTreeElement.prototype.updateTitles): Added.
(WI.JavaScriptBreakpointTreeElement.prototype._breakpointLocationDidChange):

  • UserInterface/Views/JavaScriptBreakpointTreeElement.css: Copied from Source/WebInspectorUI/UserInterface/Views/BreakpointTreeElement.css.

(.item.breakpoint.javascript .status > .status-image): Added.
(.item.breakpoint.javascript .status > .status-image.resolved): Added.
(body:not(.window-inactive, .window-docked-inactive) .tree-outline:focus-within .item.breakpoint.javascript.selected .status > .status-image.resolved): Added.
(.item.breakpoint.javascript .subtitle.formatted-location): Added.
(.item.breakpoint.javascript.line .icon): Added.
(.item.breakpoint.javascript.line .icon > span): Added.
(.data-updated.item.breakpoint.javascript.line .icon > span): Added.
(.item.breakpoint.javascript.debugger-statement .icon): Added.
(.item.breakpoint.javascript.exception .icon): Added.
(.item.breakpoint.javascript.assertion .icon): Added.
(.item.breakpoint.javascript.microtask .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.javascript.line .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.javascript.debugger-statement .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.javascript.exception .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.javascript.assertion .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.javascript.microtask .icon): Added.

  • UserInterface/Views/URLBreakpointTreeElement.js:

(WI.URLBreakpointTreeElement):
(WI.URLBreakpointTreeElement.prototype.onattach): Deleted.
(WI.URLBreakpointTreeElement.prototype.ondetach): Deleted.
(WI.URLBreakpointTreeElement.prototype.ondelete): Deleted.
(WI.URLBreakpointTreeElement.prototype.onenter): Deleted.
(WI.URLBreakpointTreeElement.prototype.onspace): Deleted.
(WI.URLBreakpointTreeElement.prototype.populateContextMenu): Deleted.
(WI.URLBreakpointTreeElement.prototype._statusImageElementClicked): Deleted.
(WI.URLBreakpointTreeElement.prototype._statusImageElementFocused): Deleted.
(WI.URLBreakpointTreeElement.prototype._statusImageElementMouseDown): Deleted.
(WI.URLBreakpointTreeElement.prototype._toggleBreakpoint): Deleted.
(WI.URLBreakpointTreeElement.prototype._updateStatus): Deleted.

  • UserInterface/Views/URLBreakpointTreeElement.css:

(.item.breakpoint.url .subtitle): Added.
(.item.breakpoint.url:not(.paused) .icon): Added.
(@media (prefers-color-scheme: dark) .item.breakpoint.url:not(.paused) .icon): Added.
(.breakpoint.url .subtitle): Deleted.
(.breakpoint.url:not(.breakpoint-paused-icon) .icon): Deleted.
(@media (prefers-color-scheme: dark) .breakpoint.url:not(.breakpoint-paused-icon) .icon): Deleted.
Rename WI.BreakpointTreeElement to WI.JavaScriptBreakpointTreeElement and use
WI.BreakpointTreeElement as a new common base class for all breakpoint tree elements,
allowing more logic and styles to be shared (e.g. disabled state).

  • UserInterface/Views/SourcesNavigationSidebarPanel.js:

(WI.SourcesNavigationSidebarPanel):
(WI.SourcesNavigationSidebarPanel.prototype.closed):
(WI.SourcesNavigationSidebarPanel.prototype._insertDebuggerTreeElement):
(WI.SourcesNavigationSidebarPanel.prototype._compareJavaScriptBreakpointTreeElements): Added.
(WI.SourcesNavigationSidebarPanel.prototype._addBreakpoint):
(WI.SourcesNavigationSidebarPanel.prototype._removeAllBreakpoints):
(WI.SourcesNavigationSidebarPanel.prototype._breakpointsBeneathTreeElement):
(WI.SourcesNavigationSidebarPanel.prototype._addIssue):
(WI.SourcesNavigationSidebarPanel.prototype._updatePauseReasonSection):
(WI.SourcesNavigationSidebarPanel.prototype._handleTreeSelectionDidChange):
(WI.SourcesNavigationSidebarPanel.prototype._handleBreakpointElementAddedOrRemoved):
(WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu.addToggleForSpecialEventBreakpoint):
(WI.SourcesNavigationSidebarPanel.prototype._populateCreateBreakpointContextMenu):
(WI.SourcesNavigationSidebarPanel.prototype._handleDebuggerObjectDisplayLocationDidChange):
(WI.SourcesNavigationSidebarPanel.prototype._compareBreakpointTreeElements): Deleted.

  • UserInterface/Models/ProbeSet.js:

(WI.ProbeSet):
(WI.ProbeSet.prototype.createProbe):
(WI.ProbeSet.prototype.willRemove):

  • UserInterface/Controllers/TimelineManager.js:

(WI.TimelineManager.prototype._processRecord):

  • UserInterface/Views/ProbeSetDetailsSection.js:

(WI.ProbeSetDetailsSection):

  • UserInterface/Views/ProbeDetailsSidebarPanel.js:

(WI.ProbeDetailsSidebarPanel.prototype.inspect):

  • UserInterface/Views/SourceCodeTextEditor.js:

(WI.SourceCodeTextEditor):
(WI.SourceCodeTextEditor.prototype.close):
(WI.SourceCodeTextEditor.prototype.textEditorBreakpointAdded):

  • UserInterface/Views/TextResourceContentView.js:

(WI.TextResourceContentView.prototype.get supplementalRepresentedObjects):
(WI.TextResourceContentView.prototype._probeSetsChanged):
Probes now support WI.EventBreakpoint in addition to WI.JavaScriptBreakpoint.

  • UserInterface/Views/ContentView.js:

(WI.ContentView.createFromRepresentedObject):
(WI.ContentView.resolvedRepresentedObjectForRepresentedObject):
(WI.ContentView.isViewable):

  • UserInterface/Views/ContextMenuUtilities.js:

(WI.appendContextMenuItemsForSourceCode):
Replace WI.Breakpoint with WI.JavaScriptBreakpoint.

  • UserInterface/Views/DOMTreeContentView.js:

(WI.DOMTreeContentView):
Replace WI.DOMBreakpoint with WI.Breakpoint.

  • UserInterface/Views/EventListenerSectionGroup.js:

(WI.EventListenerSectionGroup):

  • UserInterface/Views/EventListenerSectionGroup.css:

(.event-listener-section > .content input[type="checkbox"] + .go-to-arrow): Added.
(.event-listener-section > .content input[type="checkbox"]:not(:checked) + .go-to-arrow): Added.
Add a go-to arrow next to the Breakpoint checkbox that reveals the WI.EventBreakpoint in
the Sources Tab.

  • UserInterface/Views/BreakpointActionView.js:

(WI.BreakpointActionView.prototype._appendActionButtonClicked):
Drive-by: minor code cleanup.

  • UserInterface/Views/CallFrameTreeElement.js:

(WI.CallFrameTreeElement.prototype.populateContextMenu):
Drive-by: include source code location context menu items.

  • UserInterface/Base/Setting.js:
  • UserInterface/Main.html:
  • UserInterface/Test.html:

LayoutTests:

  • inspector/dom-debugger/resources/event-breakpoint-utilities.js:

(TestPage.registerInitializer.InspectorTest.EventBreakpoint.addBreakpointOptionsTestCases): Added.
(TestPage.registerInitializer.InspectorTest.EventBreakpoint.async teardown):
(TestPage.registerInitializer.InspectorTest.EventBreakpoint.createBreakpoint):
(TestPage.registerInitializer.InspectorTest.EventBreakpoint.removeBreakpoint):

  • inspector/dom/breakpoint-for-event-listener.html:
  • inspector/dom/breakpoint-for-event-listener-expected.txt:
  • inspector/dom-debugger/event-animation-frame-breakpoints.html:
  • inspector/dom-debugger/event-animation-frame-breakpoints-expected.txt:
  • inspector/dom-debugger/event-interval-breakpoints.html:
  • inspector/dom-debugger/event-interval-breakpoints-expected.txt:
  • inspector/dom-debugger/event-listener-breakpoints.html:
  • inspector/dom-debugger/event-listener-breakpoints-expected.txt:
  • inspector/dom-debugger/event-timeout-breakpoints.html:
  • inspector/dom-debugger/event-timeout-breakpoints-expected.txt:

Add tests for new event breakpoint configuration options.

  • http/tests/inspector/debugger/debugger-test.js:

(TestPage.registerInitializer.InspectorTest.startTracingBreakpoints):

  • http/tests/inspector/resources/probe-test.js:

(TestPage.registerInitializer.ProtocolTest.Probe.installTracingListeners):

  • inspector/debugger/breakpoint-action-eval.html:
  • inspector/debugger/breakpoint-action-log.html:
  • inspector/debugger/breakpoint-columns.html:
  • inspector/debugger/breakpoint-scope.html:
  • inspector/debugger/debugger-stack-overflow.html:
  • inspector/debugger/pause-reason.html:
  • inspector/debugger/probe-manager-add-remove-actions.html:
  • inspector/debugger/stepping/stepping-through-autoContinue-breakpoint.html:
  • inspector/debugger/tail-deleted-frames-this-value.html:
  • inspector/debugger/tail-recursion.html:
  • inspector/worker/debugger-pause.html:
  • inspector/worker/debugger-shared-breakpoint.html:

Update existing breakpoint tests to use new model objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/debugger/Debugger.h

    r260113 r266074  
    2828#include "DebuggerPrimitives.h"
    2929#include "JSCJSValue.h"
    30 #include <wtf/HashMap.h>
    31 #include <wtf/HashSet.h>
    32 #include <wtf/RefPtr.h>
    33 #include <wtf/text/TextPosition.h>
     30#include <wtf/Forward.h>
    3431
    3532namespace JSC {
     
    4239class VM;
    4340
    44 class JS_EXPORT_PRIVATE Debugger {
     41class Debugger {
    4542    WTF_MAKE_FAST_ALLOCATED;
    4643public:
    47     Debugger(VM&);
    48     virtual ~Debugger();
     44    JS_EXPORT_PRIVATE Debugger(VM&);
     45    JS_EXPORT_PRIVATE virtual ~Debugger();
    4946
    5047    VM& vm() { return m_vm; }
    51 
    52     JSC::DebuggerCallFrame& currentDebuggerCallFrame();
    53     bool hasHandlerForExceptionCallback() const
    54     {
    55         ASSERT(m_reasonForPause == PausedForException);
    56         return m_hasHandlerForExceptionCallback;
    57     }
    58     JSValue currentException()
    59     {
    60         ASSERT(m_reasonForPause == PausedForException);
    61         return m_currentException;
    62     }
    6348
    6449    bool needsExceptionCallbacks() const { return m_breakpointsActivated && m_pauseOnExceptionsState != DontPauseOnExceptions; }
     
    6954        GlobalObjectIsDestructing
    7055    };
    71     void attach(JSGlobalObject*);
    72     void detach(JSGlobalObject*, ReasonForDetach);
    73     bool isAttached(JSGlobalObject*);
    74 
    75     void resolveBreakpoint(Breakpoint&, SourceProvider*);
    76     BreakpointID setBreakpoint(Breakpoint&, bool& existing);
    77     void removeBreakpoint(BreakpointID);
     56    JS_EXPORT_PRIVATE void attach(JSGlobalObject*);
     57    JS_EXPORT_PRIVATE void detach(JSGlobalObject*, ReasonForDetach);
     58    JS_EXPORT_PRIVATE bool isAttached(JSGlobalObject*);
     59
     60    bool resolveBreakpoint(Breakpoint&, SourceProvider*);
     61    bool setBreakpoint(Breakpoint&);
     62    bool removeBreakpoint(Breakpoint&);
    7863    void clearBreakpoints();
    7964
     
    8166    void deactivateBreakpoints() { setBreakpointsActivated(false); }
    8267    bool breakpointsActive() const { return m_breakpointsActivated; }
     68
     69    // Breakpoint "delegate" functionality.
     70    bool evaluateBreakpointCondition(Breakpoint&, JSGlobalObject*);
     71    void evaluateBreakpointActions(Breakpoint&, JSGlobalObject*);
    8372
    8473    enum PauseOnExceptionsState {
     
    8877    };
    8978    PauseOnExceptionsState pauseOnExceptionsState() const { return m_pauseOnExceptionsState; }
    90     void setPauseOnExceptionsState(PauseOnExceptionsState);
     79    JS_EXPORT_PRIVATE void setPauseOnExceptionsState(PauseOnExceptionsState);
    9180
    9281    void setPauseOnDebuggerStatements(bool enabled) { m_pauseOnDebuggerStatements = enabled; }
     
    10695    BreakpointID pausingBreakpointID() const { return m_pausingBreakpointID; }
    10796
    108     void setPauseOnNextStatement(bool);
     97    void schedulePauseAtNextOpportunity();
     98    void cancelPauseAtNextOpportunity();
     99    bool schedulePauseForSpecialBreakpoint(Breakpoint&);
     100    bool cancelPauseForSpecialBreakpoint(Breakpoint&);
    109101    void breakProgram();
    110102    void continueProgram();
     
    124116    void setSuppressAllPauses(bool suppress) { m_suppressAllPauses = suppress; }
    125117
    126     virtual void sourceParsed(JSGlobalObject*, SourceProvider*, int errorLineNumber, const WTF::String& errorMessage) = 0;
    127     virtual void willRunMicrotask() { }
    128     virtual void didRunMicrotask() { }
     118    JS_EXPORT_PRIVATE virtual void sourceParsed(JSGlobalObject*, SourceProvider*, int errorLineNumber, const WTF::String& errorMessage);
    129119
    130120    void exception(JSGlobalObject*, CallFrame*, JSValue exceptionValue, bool hasCatchHandler);
     
    138128    void didReachDebuggerStatement(CallFrame*);
    139129
    140     virtual void recompileAllJSFunctions();
     130    void willRunMicrotask();
     131    void didRunMicrotask();
    141132
    142133    void registerCodeBlock(CodeBlock*);
     134
     135    // FIXME: <https://webkit.org/b/162773> Web Inspector: Simplify Debugger::Script to use SourceProvider
     136    struct Script {
     137        String url;
     138        String source;
     139        String sourceURL;
     140        String sourceMappingURL;
     141        RefPtr<SourceProvider> sourceProvider;
     142        int startLine { 0 };
     143        int startColumn { 0 };
     144        int endLine { 0 };
     145        int endColumn { 0 };
     146        bool isContentScript { false };
     147    };
     148
     149    class Observer {
     150    public:
     151        virtual ~Observer() { }
     152
     153        virtual void didParseSource(SourceID, const Debugger::Script&) { }
     154        virtual void failedToParseSource(const String& /* url */, const String& /* data */, int /* firstLine */, int /* errorLine */, const String& /* errorMessage */) { }
     155
     156        virtual void willRunMicrotask() { }
     157        virtual void didRunMicrotask() { }
     158
     159        virtual void didPause(JSGlobalObject*, DebuggerCallFrame&, JSValue /* exceptionOrCaughtValue */) { }
     160        virtual void didContinue() { }
     161
     162        virtual void breakpointActionLog(JSGlobalObject*, const String& /* data */) { }
     163        virtual void breakpointActionSound(BreakpointActionID) { }
     164        virtual void breakpointActionProbe(JSGlobalObject*, BreakpointActionID, unsigned /* batchId */, unsigned /* sampleId */, JSValue /* result */) { }
     165    };
     166
     167    JS_EXPORT_PRIVATE void addObserver(Observer&);
     168    JS_EXPORT_PRIVATE void removeObserver(Observer&, bool isBeingDestroyed);
    143169
    144170    class ProfilingClient {
     
    157183
    158184protected:
    159     virtual void handleBreakpointHit(JSGlobalObject*, const Breakpoint&) { }
    160     virtual void handleExceptionInBreakpointCondition(JSGlobalObject*, Exception*) const { }
    161     virtual void handlePause(JSGlobalObject*, ReasonForPause) { }
    162     virtual void notifyDoneProcessingDebuggerEvents() { }
     185    JS_EXPORT_PRIVATE JSC::DebuggerCallFrame& currentDebuggerCallFrame();
     186
     187    bool hasHandlerForExceptionCallback() const
     188    {
     189        ASSERT(m_reasonForPause == PausedForException);
     190        return m_hasHandlerForExceptionCallback;
     191    }
     192
     193    JSValue currentException()
     194    {
     195        ASSERT(m_reasonForPause == PausedForException);
     196        return m_currentException;
     197    }
     198
     199    virtual void attachDebugger() { }
     200    virtual void detachDebugger(bool /* isBeingDestroyed */) { }
     201    JS_EXPORT_PRIVATE virtual void recompileAllJSFunctions();
     202
     203    virtual void didPause(JSGlobalObject*) { }
     204    JS_EXPORT_PRIVATE virtual void handlePause(JSGlobalObject*, ReasonForPause);
     205    virtual void didContinue(JSGlobalObject*) { }
     206    virtual void runEventLoopWhilePaused() { }
     207
     208    virtual bool isContentScript(JSGlobalObject*) const { return false; }
     209
     210    // NOTE: Currently all exceptions are reported at the API boundary through reportAPIException.
     211    // Until a time comes where an exception can be caused outside of the API (e.g. setTimeout
     212    // or some other async operation in a pure JSContext) we can ignore exceptions reported here.
     213    virtual void reportException(JSGlobalObject*, Exception*) const { }
     214
     215    bool doneProcessingDebuggerEvents() const { return m_doneProcessingDebuggerEvents; }
    163216
    164217private:
    165     typedef HashMap<BreakpointID, Breakpoint*> BreakpointIDToBreakpointMap;
    166 
    167     typedef HashMap<unsigned, RefPtr<BreakpointsList>, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>> LineToBreakpointsMap;
    168     typedef HashMap<SourceID, LineToBreakpointsMap, WTF::IntHash<SourceID>, WTF::UnsignedWithZeroKeyHashTraits<SourceID>> SourceIDToBreakpointsMap;
     218    JSValue exceptionOrCaughtValue(JSGlobalObject*);
    169219
    170220    class ClearCodeBlockDebuggerRequestsFunctor;
     
    189239    };
    190240
    191     bool hasBreakpoint(SourceID, const TextPosition&, Breakpoint* hitBreakpoint);
     241    RefPtr<Breakpoint> didHitBreakpoint(JSGlobalObject*, SourceID, const TextPosition&);
    192242
    193243    DebuggerParseData& debuggerParseData(SourceID, SourceProvider*);
     
    216266        BreakpointEnabled
    217267    };
    218     void setBreakpointsActivated(bool);
     268    JS_EXPORT_PRIVATE void setBreakpointsActivated(bool);
    219269    void toggleBreakpoint(CodeBlock*, Breakpoint&, BreakpointState);
    220270    void applyBreakpoints(CodeBlock*);
     
    223273    void clearDebuggerRequests(JSGlobalObject*);
    224274    void clearParsedData();
     275
     276    bool canDispatchFunctionToObservers() const;
     277    void dispatchFunctionToObservers(Function<void(Observer&)>);
    225278
    226279    VM& m_vm;
     
    249302    bool m_afterBlackboxedScript { false };
    250303
    251     BreakpointID m_topBreakpointID;
     304    using LineToBreakpointsMap = HashMap<unsigned, BreakpointsVector, WTF::IntHash<int>, WTF::UnsignedWithZeroKeyHashTraits<int>>;
     305    HashMap<SourceID, LineToBreakpointsMap, WTF::IntHash<SourceID>, WTF::UnsignedWithZeroKeyHashTraits<SourceID>> m_breakpointsForSourceID;
     306    HashSet<Ref<Breakpoint>> m_breakpoints;
     307    RefPtr<Breakpoint> m_specialBreakpoint;
    252308    BreakpointID m_pausingBreakpointID;
    253     BreakpointIDToBreakpointMap m_breakpointIDToBreakpoint;
    254     SourceIDToBreakpointsMap m_sourceIDToBreakpoints;
     309
     310    unsigned m_nextProbeSampleId { 1 };
     311    unsigned m_currentProbeBatchId { 0 };
    255312
    256313    RefPtr<JSC::DebuggerCallFrame> m_currentDebuggerCallFrame;
    257314
     315    HashSet<Observer*> m_observers;
     316    bool m_dispatchingFunctionToObservers { false };
     317
    258318    ProfilingClient* m_profilingClient { nullptr };
     319
     320    bool m_doneProcessingDebuggerEvents { true };
    259321
    260322    friend class DebuggerPausedScope;
Note: See TracChangeset for help on using the changeset viewer.