2 * Copyright (C) 2010 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * @extends {WebInspector.SDKModel}
34 * @param {!WebInspector.Target} target
36 WebInspector.DebuggerModel = function(target)
38 WebInspector.SDKModel.call(this, WebInspector.DebuggerModel, target);
40 target.registerDebuggerDispatcher(new WebInspector.DebuggerDispatcher(this));
41 this._agent = target.debuggerAgent();
43 /** @type {?WebInspector.DebuggerPausedDetails} */
44 this._debuggerPausedDetails = null;
45 /** @type {!Object.<string, !WebInspector.Script>} */
47 /** @type {!StringMap.<!Array.<!WebInspector.Script>>} */
48 this._scriptsBySourceURL = new StringMap();
50 /** @type {!WebInspector.Object} */
51 this._breakpointResolvedEventTarget = new WebInspector.Object();
53 this._isPausing = false;
54 WebInspector.settings.pauseOnExceptionEnabled.addChangeListener(this._pauseOnExceptionStateChanged, this);
55 WebInspector.settings.pauseOnCaughtException.addChangeListener(this._pauseOnExceptionStateChanged, this);
57 WebInspector.settings.enableAsyncStackTraces.addChangeListener(this._asyncStackTracesStateChanged, this);
58 WebInspector.profilingLock().addEventListener(WebInspector.Lock.Events.StateChanged, this._profilingStateChanged, this);
60 this.enableDebugger();
62 WebInspector.settings.skipStackFramesPattern.addChangeListener(this._applySkipStackFrameSettings, this);
63 this._applySkipStackFrameSettings();
66 /** @typedef {{location: ?WebInspector.DebuggerModel.Location, sourceURL: ?string, functionName: string, scopeChain: (Array.<!DebuggerAgent.Scope>|null)}} */
67 WebInspector.DebuggerModel.FunctionDetails;
70 * Keep these in sync with WebCore::ScriptDebugServer
74 WebInspector.DebuggerModel.PauseOnExceptionsState = {
75 DontPauseOnExceptions : "none",
76 PauseOnAllExceptions : "all",
77 PauseOnUncaughtExceptions: "uncaught"
80 WebInspector.DebuggerModel.Events = {
81 DebuggerWasEnabled: "DebuggerWasEnabled",
82 DebuggerWasDisabled: "DebuggerWasDisabled",
83 DebuggerPaused: "DebuggerPaused",
84 DebuggerResumed: "DebuggerResumed",
85 ParsedScriptSource: "ParsedScriptSource",
86 FailedToParseScriptSource: "FailedToParseScriptSource",
87 GlobalObjectCleared: "GlobalObjectCleared",
88 CallFrameSelected: "CallFrameSelected",
89 ConsoleCommandEvaluatedInSelectedCallFrame: "ConsoleCommandEvaluatedInSelectedCallFrame",
92 WebInspector.DebuggerModel.BreakReason = {
94 EventListener: "EventListener",
96 Exception: "exception",
98 CSPViolation: "CSPViolation",
99 DebugCommand: "debugCommand"
102 WebInspector.DebuggerModel.prototype = {
106 debuggerEnabled: function()
108 return !!this._debuggerEnabled;
111 enableDebugger: function()
113 if (this._debuggerEnabled)
115 this._agent.enable();
116 this._debuggerEnabled = true;
117 this._pauseOnExceptionStateChanged();
118 this._asyncStackTracesStateChanged();
119 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerWasEnabled);
122 disableDebugger: function()
124 if (!this._debuggerEnabled)
127 this._agent.disable();
128 this._debuggerEnabled = false;
129 this._isPausing = false;
130 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerWasDisabled);
134 * @param {boolean} skip
135 * @param {boolean=} untilReload
137 skipAllPauses: function(skip, untilReload)
139 if (this._skipAllPausesTimeout) {
140 clearTimeout(this._skipAllPausesTimeout);
141 delete this._skipAllPausesTimeout;
143 this._agent.setSkipAllPauses(skip, untilReload);
147 * @param {number} timeout
149 skipAllPausesUntilReloadOrTimeout: function(timeout)
151 if (this._skipAllPausesTimeout)
152 clearTimeout(this._skipAllPausesTimeout);
153 this._agent.setSkipAllPauses(true, true);
154 // If reload happens before the timeout, the flag will be already unset and the timeout callback won't change anything.
155 this._skipAllPausesTimeout = setTimeout(this.skipAllPauses.bind(this, false), timeout);
158 _pauseOnExceptionStateChanged: function()
161 if (!WebInspector.settings.pauseOnExceptionEnabled.get()) {
162 state = WebInspector.DebuggerModel.PauseOnExceptionsState.DontPauseOnExceptions;
163 } else if (WebInspector.settings.pauseOnCaughtException.get()) {
164 state = WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnAllExceptions;
166 state = WebInspector.DebuggerModel.PauseOnExceptionsState.PauseOnUncaughtExceptions;
168 this._agent.setPauseOnExceptions(state);
171 _profilingStateChanged: function()
173 if (WebInspector.experimentsSettings.disableAgentsWhenProfile.isEnabled()) {
174 if (WebInspector.profilingLock().isAcquired())
175 this.disableDebugger();
177 this.enableDebugger();
179 this._asyncStackTracesStateChanged();
182 _asyncStackTracesStateChanged: function()
184 const maxAsyncStackChainDepth = 4;
185 var enabled = WebInspector.settings.enableAsyncStackTraces.get() && !WebInspector.profilingLock().isAcquired();
186 this._agent.setAsyncCallStackDepth(enabled ? maxAsyncStackChainDepth : 0);
192 * @this {WebInspector.DebuggerModel}
196 this._agent.stepInto();
198 this._agent.setOverlayMessage(undefined, callback.bind(this));
204 * @this {WebInspector.DebuggerModel}
208 this._agent.stepOver();
210 this._agent.setOverlayMessage(undefined, callback.bind(this));
216 * @this {WebInspector.DebuggerModel}
220 this._agent.stepOut();
222 this._agent.setOverlayMessage(undefined, callback.bind(this));
228 * @this {WebInspector.DebuggerModel}
232 this._agent.resume();
234 this._agent.setOverlayMessage(undefined, callback.bind(this));
235 this._isPausing = false;
240 this._isPausing = true;
241 this.skipAllPauses(false);
246 * @param {string} url
247 * @param {number} lineNumber
248 * @param {number=} columnNumber
249 * @param {string=} condition
250 * @param {function(?DebuggerAgent.BreakpointId, !Array.<!WebInspector.DebuggerModel.Location>)=} callback
252 setBreakpointByURL: function(url, lineNumber, columnNumber, condition, callback)
254 // Adjust column if needed.
255 var minColumnNumber = 0;
256 var scripts = this._scriptsBySourceURL.get(url) || [];
257 for (var i = 0, l = scripts.length; i < l; ++i) {
258 var script = scripts[i];
259 if (lineNumber === script.lineOffset)
260 minColumnNumber = minColumnNumber ? Math.min(minColumnNumber, script.columnOffset) : script.columnOffset;
262 columnNumber = Math.max(columnNumber, minColumnNumber);
264 var target = this.target();
266 * @param {?Protocol.Error} error
267 * @param {!DebuggerAgent.BreakpointId} breakpointId
268 * @param {!Array.<!DebuggerAgent.Location>} locations
270 function didSetBreakpoint(error, breakpointId, locations)
273 var rawLocations = locations ? locations.map(WebInspector.DebuggerModel.Location.fromPayload.bind(WebInspector.DebuggerModel.Location, target)) : [];
274 callback(error ? null : breakpointId, rawLocations);
277 this._agent.setBreakpointByUrl(lineNumber, url, undefined, columnNumber, condition, undefined, didSetBreakpoint);
278 WebInspector.userMetrics.ScriptsBreakpointSet.record();
282 * @param {!WebInspector.DebuggerModel.Location} rawLocation
283 * @param {string} condition
284 * @param {function(?DebuggerAgent.BreakpointId, !Array.<!WebInspector.DebuggerModel.Location>)=} callback
286 setBreakpointBySourceId: function(rawLocation, condition, callback)
288 var target = this.target();
291 * @param {?Protocol.Error} error
292 * @param {!DebuggerAgent.BreakpointId} breakpointId
293 * @param {!DebuggerAgent.Location} actualLocation
295 function didSetBreakpoint(error, breakpointId, actualLocation)
298 var location = WebInspector.DebuggerModel.Location.fromPayload(target, actualLocation);
299 callback(error ? null : breakpointId, [location]);
302 this._agent.setBreakpoint(rawLocation.payload(), condition, didSetBreakpoint);
303 WebInspector.userMetrics.ScriptsBreakpointSet.record();
307 * @param {!DebuggerAgent.BreakpointId} breakpointId
308 * @param {function()=} callback
310 removeBreakpoint: function(breakpointId, callback)
312 this._agent.removeBreakpoint(breakpointId, innerCallback);
315 * @param {?Protocol.Error} error
317 function innerCallback(error)
320 console.error("Failed to remove breakpoint: " + error);
327 * @param {!DebuggerAgent.BreakpointId} breakpointId
328 * @param {!DebuggerAgent.Location} location
330 _breakpointResolved: function(breakpointId, location)
332 this._breakpointResolvedEventTarget.dispatchEventToListeners(breakpointId, WebInspector.DebuggerModel.Location.fromPayload(this.target(), location));
335 _globalObjectCleared: function()
337 this._setDebuggerPausedDetails(null);
339 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.GlobalObjectCleared);
345 this._scriptsBySourceURL.clear();
349 * @return {!Object.<string, !WebInspector.Script>}
353 return this._scripts;
357 * @param {!DebuggerAgent.ScriptId} scriptId
358 * @return {!WebInspector.Script}
360 scriptForId: function(scriptId)
362 return this._scripts[scriptId] || null;
366 * @return {!Array.<!WebInspector.Script>}
368 scriptsForSourceURL: function(sourceURL)
372 return this._scriptsBySourceURL.get(sourceURL) || [];
376 * @param {!DebuggerAgent.ScriptId} scriptId
377 * @param {string} newSource
378 * @param {function(?Protocol.Error, !DebuggerAgent.SetScriptSourceError=)} callback
380 setScriptSource: function(scriptId, newSource, callback)
382 this._scripts[scriptId].editSource(newSource, this._didEditScriptSource.bind(this, scriptId, newSource, callback));
386 * @param {!DebuggerAgent.ScriptId} scriptId
387 * @param {string} newSource
388 * @param {function(?Protocol.Error, !DebuggerAgent.SetScriptSourceError=)} callback
389 * @param {?Protocol.Error} error
390 * @param {!DebuggerAgent.SetScriptSourceError=} errorData
391 * @param {!Array.<!DebuggerAgent.CallFrame>=} callFrames
392 * @param {!DebuggerAgent.StackTrace=} asyncStackTrace
393 * @param {boolean=} needsStepIn
395 _didEditScriptSource: function(scriptId, newSource, callback, error, errorData, callFrames, asyncStackTrace, needsStepIn)
399 this._pendingLiveEditCallback = callback.bind(this, error, errorData);
403 if (!error && callFrames && callFrames.length)
404 this._pausedScript(callFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDetails.auxData, this._debuggerPausedDetails.breakpointIds, asyncStackTrace);
405 callback(error, errorData);
409 * @return {?Array.<!WebInspector.DebuggerModel.CallFrame>}
413 return this._debuggerPausedDetails ? this._debuggerPausedDetails.callFrames : null;
417 * @return {?WebInspector.DebuggerPausedDetails}
419 debuggerPausedDetails: function()
421 return this._debuggerPausedDetails;
425 * @param {?WebInspector.DebuggerPausedDetails} debuggerPausedDetails
427 _setDebuggerPausedDetails: function(debuggerPausedDetails)
429 this._isPausing = false;
430 this._debuggerPausedDetails = debuggerPausedDetails;
431 if (this._debuggerPausedDetails)
432 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerPaused, this._debuggerPausedDetails);
433 if (debuggerPausedDetails) {
434 this.setSelectedCallFrame(debuggerPausedDetails.callFrames[0]);
435 this._agent.setOverlayMessage(WebInspector.UIString("Paused in debugger"));
437 this.setSelectedCallFrame(null);
438 this._agent.setOverlayMessage();
443 * @param {!Array.<!DebuggerAgent.CallFrame>} callFrames
444 * @param {string} reason
445 * @param {!Object|undefined} auxData
446 * @param {!Array.<string>} breakpointIds
447 * @param {!DebuggerAgent.StackTrace=} asyncStackTrace
449 _pausedScript: function(callFrames, reason, auxData, breakpointIds, asyncStackTrace)
451 this._setDebuggerPausedDetails(new WebInspector.DebuggerPausedDetails(this.target(), callFrames, reason, auxData, breakpointIds, asyncStackTrace));
452 if (this._pendingLiveEditCallback) {
453 var callback = this._pendingLiveEditCallback;
454 delete this._pendingLiveEditCallback;
459 _resumedScript: function()
461 this._setDebuggerPausedDetails(null);
462 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.DebuggerResumed);
466 * @param {!DebuggerAgent.ScriptId} scriptId
467 * @param {string} sourceURL
468 * @param {number} startLine
469 * @param {number} startColumn
470 * @param {number} endLine
471 * @param {number} endColumn
472 * @param {boolean} isContentScript
473 * @param {string=} sourceMapURL
474 * @param {boolean=} hasSourceURL
475 * @param {boolean=} hasSyntaxError
477 _parsedScriptSource: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL, hasSyntaxError)
479 var script = new WebInspector.Script(this.target(), scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL);
480 this._registerScript(script);
482 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, script);
484 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, script);
488 * @param {!WebInspector.Script} script
490 _registerScript: function(script)
492 this._scripts[script.scriptId] = script;
493 if (script.isAnonymousScript())
496 var scripts = this._scriptsBySourceURL.get(script.sourceURL);
499 this._scriptsBySourceURL.put(script.sourceURL, scripts);
501 scripts.push(script);
505 * @param {!WebInspector.Script} script
506 * @param {number} lineNumber
507 * @param {number} columnNumber
508 * @return {?WebInspector.DebuggerModel.Location}
510 createRawLocation: function(script, lineNumber, columnNumber)
512 if (script.sourceURL)
513 return this.createRawLocationByURL(script.sourceURL, lineNumber, columnNumber);
514 return new WebInspector.DebuggerModel.Location(this.target(), script.scriptId, lineNumber, columnNumber);
518 * @param {string} sourceURL
519 * @param {number} lineNumber
520 * @param {number} columnNumber
521 * @return {?WebInspector.DebuggerModel.Location}
523 createRawLocationByURL: function(sourceURL, lineNumber, columnNumber)
525 var closestScript = null;
526 var scripts = this._scriptsBySourceURL.get(sourceURL) || [];
527 for (var i = 0, l = scripts.length; i < l; ++i) {
528 var script = scripts[i];
530 closestScript = script;
531 if (script.lineOffset > lineNumber || (script.lineOffset === lineNumber && script.columnOffset > columnNumber))
533 if (script.endLine < lineNumber || (script.endLine === lineNumber && script.endColumn <= columnNumber))
535 closestScript = script;
538 return closestScript ? new WebInspector.DebuggerModel.Location(this.target(), closestScript.scriptId, lineNumber, columnNumber) : null;
542 * @param {?DebuggerAgent.ScriptId} scriptId
543 * @param {string} sourceUrl
544 * @param {number} lineNumber
545 * @param {number} columnNumber
546 * @return {?WebInspector.DebuggerModel.Location}
548 createRawLocationByScriptId: function(scriptId, sourceUrl, lineNumber, columnNumber)
550 var script = scriptId ? this.scriptForId(scriptId) : null;
551 return script ? this.createRawLocation(script, lineNumber, columnNumber) : this.createRawLocationByURL(sourceUrl, lineNumber, columnNumber);
559 return !!this.debuggerPausedDetails();
565 isPausing: function()
567 return this._isPausing;
571 * @param {?WebInspector.DebuggerModel.CallFrame} callFrame
573 setSelectedCallFrame: function(callFrame)
575 this._selectedCallFrame = callFrame;
576 if (!this._selectedCallFrame)
579 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.CallFrameSelected, callFrame);
583 * @return {?WebInspector.DebuggerModel.CallFrame}
585 selectedCallFrame: function()
587 return this._selectedCallFrame;
591 * @param {string} code
592 * @param {string} objectGroup
593 * @param {boolean} includeCommandLineAPI
594 * @param {boolean} doNotPauseOnExceptionsAndMuteConsole
595 * @param {boolean} returnByValue
596 * @param {boolean} generatePreview
597 * @param {function(?WebInspector.RemoteObject, boolean, ?RuntimeAgent.RemoteObject=, ?DebuggerAgent.ExceptionDetails=)} callback
599 evaluateOnSelectedCallFrame: function(code, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, callback)
602 * @param {?RuntimeAgent.RemoteObject} result
603 * @param {boolean=} wasThrown
604 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
605 * @this {WebInspector.DebuggerModel}
607 function didEvaluate(result, wasThrown, exceptionDetails)
610 callback(null, false);
611 else if (returnByValue)
612 callback(null, !!wasThrown, wasThrown ? null : result, exceptionDetails);
614 callback(this.target().runtimeModel.createRemoteObject(result), !!wasThrown, undefined, exceptionDetails);
616 if (objectGroup === "console")
617 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ConsoleCommandEvaluatedInSelectedCallFrame);
620 this.selectedCallFrame().evaluate(code, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, didEvaluate.bind(this));
624 * @param {function(!Object)} callback
626 getSelectedCallFrameVariables: function(callback)
628 var result = { this: true };
630 var selectedCallFrame = this._selectedCallFrame;
631 if (!selectedCallFrame)
634 var pendingRequests = 0;
636 function propertiesCollected(properties)
638 for (var i = 0; properties && i < properties.length; ++i)
639 result[properties[i].name] = true;
640 if (--pendingRequests == 0)
644 for (var i = 0; i < selectedCallFrame.scopeChain.length; ++i) {
645 var scope = selectedCallFrame.scopeChain[i];
646 var object = this.target().runtimeModel.createRemoteObject(scope.object);
648 object.getAllProperties(false, propertiesCollected);
653 * Handles notification from JavaScript VM about updated stack (liveedit or frame restart action).
654 * @param {!Array.<!DebuggerAgent.CallFrame>=} newCallFrames
655 * @param {!Object=} details
656 * @param {!DebuggerAgent.StackTrace=} asyncStackTrace
658 callStackModified: function(newCallFrames, details, asyncStackTrace)
660 // FIXME: declare this property in protocol and in JavaScript.
661 if (details && details["stack_update_needs_step_in"])
663 else if (newCallFrames && newCallFrames.length)
664 this._pausedScript(newCallFrames, this._debuggerPausedDetails.reason, this._debuggerPausedDetails.auxData, this._debuggerPausedDetails.breakpointIds, asyncStackTrace);
667 _applySkipStackFrameSettings: function()
669 this._agent.skipStackFrames(WebInspector.settings.skipStackFramesPattern.get());
673 * @param {!WebInspector.RemoteObject} remoteObject
674 * @param {function(?WebInspector.DebuggerModel.FunctionDetails)} callback
676 functionDetails: function(remoteObject, callback)
678 this._agent.getFunctionDetails(remoteObject.objectId, didGetDetails.bind(this));
681 * @param {?Protocol.Error} error
682 * @param {!DebuggerAgent.FunctionDetails} response
683 * @this {WebInspector.DebuggerModel}
685 function didGetDetails(error, response)
688 console.error(error);
692 var location = response.location;
693 var script = this.scriptForId(location.scriptId);
694 var rawLocation = script ? this.createRawLocation(script, location.lineNumber + 1, location.columnNumber + 1) : null;
695 var sourceURL = script ? script.contentURL() : null;
696 callback({location: rawLocation, sourceURL: sourceURL, functionName: response.functionName, scopeChain: response.scopeChain || null});
701 * @param {!DebuggerAgent.BreakpointId} breakpointId
702 * @param {function(!WebInspector.Event)} listener
703 * @param {!Object=} thisObject
705 addBreakpointListener: function(breakpointId, listener, thisObject)
707 this._breakpointResolvedEventTarget.addEventListener(breakpointId, listener, thisObject)
711 * @param {!DebuggerAgent.BreakpointId} breakpointId
712 * @param {function(!WebInspector.Event)} listener
713 * @param {!Object=} thisObject
715 removeBreakpointListener: function(breakpointId, listener, thisObject)
717 this._breakpointResolvedEventTarget.removeEventListener(breakpointId, listener, thisObject);
722 WebInspector.settings.pauseOnExceptionEnabled.removeChangeListener(this._pauseOnExceptionStateChanged, this);
723 WebInspector.settings.pauseOnCaughtException.removeChangeListener(this._pauseOnExceptionStateChanged, this);
724 WebInspector.settings.skipStackFramesPattern.removeChangeListener(this._applySkipStackFrameSettings, this);
725 WebInspector.settings.enableAsyncStackTraces.removeChangeListener(this._asyncStackTracesStateChanged, this);
728 __proto__: WebInspector.SDKModel.prototype
731 WebInspector.DebuggerEventTypes = {
733 JavaScriptBreakpoint: 1,
739 * @implements {DebuggerAgent.Dispatcher}
740 * @param {!WebInspector.DebuggerModel} debuggerModel
742 WebInspector.DebuggerDispatcher = function(debuggerModel)
744 this._debuggerModel = debuggerModel;
747 WebInspector.DebuggerDispatcher.prototype = {
749 * @param {!Array.<!DebuggerAgent.CallFrame>} callFrames
750 * @param {string} reason
751 * @param {!Object=} auxData
752 * @param {!Array.<string>=} breakpointIds
753 * @param {!DebuggerAgent.StackTrace=} asyncStackTrace
755 paused: function(callFrames, reason, auxData, breakpointIds, asyncStackTrace)
757 this._debuggerModel._pausedScript(callFrames, reason, auxData, breakpointIds || [], asyncStackTrace);
765 this._debuggerModel._resumedScript();
771 globalObjectCleared: function()
773 this._debuggerModel._globalObjectCleared();
777 * @param {!DebuggerAgent.ScriptId} scriptId
778 * @param {string} sourceURL
779 * @param {number} startLine
780 * @param {number} startColumn
781 * @param {number} endLine
782 * @param {number} endColumn
783 * @param {boolean=} isContentScript
784 * @param {string=} sourceMapURL
785 * @param {boolean=} hasSourceURL
787 scriptParsed: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
789 this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, !!isContentScript, sourceMapURL, hasSourceURL, false);
793 * @param {!DebuggerAgent.ScriptId} scriptId
794 * @param {string} sourceURL
795 * @param {number} startLine
796 * @param {number} startColumn
797 * @param {number} endLine
798 * @param {number} endColumn
799 * @param {boolean=} isContentScript
800 * @param {string=} sourceMapURL
801 * @param {boolean=} hasSourceURL
803 scriptFailedToParse: function(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
805 this._debuggerModel._parsedScriptSource(scriptId, sourceURL, startLine, startColumn, endLine, endColumn, !!isContentScript, sourceMapURL, hasSourceURL, true);
809 * @param {!DebuggerAgent.BreakpointId} breakpointId
810 * @param {!DebuggerAgent.Location} location
812 breakpointResolved: function(breakpointId, location)
814 this._debuggerModel._breakpointResolved(breakpointId, location);
820 * @extends {WebInspector.SDKObject}
821 * @param {!WebInspector.Target} target
822 * @param {string} scriptId
823 * @param {number} lineNumber
824 * @param {number=} columnNumber
826 WebInspector.DebuggerModel.Location = function(target, scriptId, lineNumber, columnNumber)
828 WebInspector.SDKObject.call(this, target);
829 this._debuggerModel = target.debuggerModel;
830 this.scriptId = scriptId;
831 this.lineNumber = lineNumber;
832 this.columnNumber = columnNumber || 0;
836 * @param {!WebInspector.Target} target
837 * @param {!DebuggerAgent.Location} payload
838 * @return {!WebInspector.DebuggerModel.Location}
840 WebInspector.DebuggerModel.Location.fromPayload = function(target, payload)
842 return new WebInspector.DebuggerModel.Location(target, payload.scriptId, payload.lineNumber, payload.columnNumber);
845 WebInspector.DebuggerModel.Location.prototype = {
847 * @return {!DebuggerAgent.Location}
851 return { scriptId: this.scriptId, lineNumber: this.lineNumber, columnNumber: this.columnNumber };
855 * @return {!WebInspector.Script}
859 return this._debuggerModel.scriptForId(this.scriptId);
862 continueToLocation: function()
864 this._debuggerModel._agent.continueToLocation(this.payload());
872 return this.target().id() + ":" + this.scriptId + ":" + this.lineNumber + ":" + this.columnNumber
875 __proto__: WebInspector.SDKObject.prototype
880 * @extends {WebInspector.SDKObject}
881 * @param {!WebInspector.Target} target
882 * @param {!WebInspector.Script} script
883 * @param {!DebuggerAgent.CallFrame} payload
884 * @param {boolean=} isAsync
886 WebInspector.DebuggerModel.CallFrame = function(target, script, payload, isAsync)
888 WebInspector.SDKObject.call(this, target);
889 this._debuggerAgent = target.debuggerModel._agent;
890 this._script = script;
891 this._payload = payload;
892 this._isAsync = isAsync;
893 this._location = WebInspector.DebuggerModel.Location.fromPayload(target, payload.location);
897 * @param {!WebInspector.Target} target
898 * @param {!Array.<!DebuggerAgent.CallFrame>} callFrames
899 * @param {boolean=} isAsync
900 * @return {!Array.<!WebInspector.DebuggerModel.CallFrame>}
902 WebInspector.DebuggerModel.CallFrame.fromPayloadArray = function(target, callFrames, isAsync)
905 for (var i = 0; i < callFrames.length; ++i) {
906 var callFrame = callFrames[i];
907 var script = target.debuggerModel.scriptForId(callFrame.location.scriptId);
909 result.push(new WebInspector.DebuggerModel.CallFrame(target, script, callFrame, isAsync));
914 WebInspector.DebuggerModel.CallFrame.prototype = {
917 * @return {!WebInspector.Script}
929 return this._payload.type;
937 return this._payload.callFrameId;
941 * @return {!Array.<!DebuggerAgent.Scope>}
945 return this._payload.scopeChain;
949 * @return {?WebInspector.RemoteObject}
951 thisObject: function()
953 return this._payload.this ? this.target().runtimeModel.createRemoteObject(this._payload.this) : null;
957 * @return {?WebInspector.RemoteObject}
959 returnValue: function()
961 return this._payload.returnValue ? this.target().runtimeModel.createRemoteObject(this._payload.returnValue) : null
969 return this._payload.functionName;
973 * @return {!WebInspector.DebuggerModel.Location}
977 return this._location;
985 return !!this._isAsync;
989 * @param {string} code
990 * @param {string} objectGroup
991 * @param {boolean} includeCommandLineAPI
992 * @param {boolean} doNotPauseOnExceptionsAndMuteConsole
993 * @param {boolean} returnByValue
994 * @param {boolean} generatePreview
995 * @param {function(?RuntimeAgent.RemoteObject, boolean=, ?DebuggerAgent.ExceptionDetails=)} callback
997 evaluate: function(code, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, callback)
1000 * @param {?Protocol.Error} error
1001 * @param {!RuntimeAgent.RemoteObject} result
1002 * @param {boolean=} wasThrown
1003 * @param {?DebuggerAgent.ExceptionDetails=} exceptionDetails
1005 function didEvaluateOnCallFrame(error, result, wasThrown, exceptionDetails)
1008 console.error(error);
1009 callback(null, false);
1012 callback(result, wasThrown, exceptionDetails);
1014 this._debuggerAgent.evaluateOnCallFrame(this._payload.callFrameId, code, objectGroup, includeCommandLineAPI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, didEvaluateOnCallFrame);
1018 * @param {function(?Protocol.Error=)=} callback
1020 restart: function(callback)
1023 * @param {?Protocol.Error} error
1024 * @param {!Array.<!DebuggerAgent.CallFrame>=} callFrames
1025 * @param {!Object=} details
1026 * @param {!DebuggerAgent.StackTrace=} asyncStackTrace
1027 * @this {WebInspector.DebuggerModel.CallFrame}
1029 function protocolCallback(error, callFrames, details, asyncStackTrace)
1032 this.target().debuggerModel.callStackModified(callFrames, details, asyncStackTrace);
1036 this._debuggerAgent.restartFrame(this._payload.callFrameId, protocolCallback.bind(this));
1039 __proto__: WebInspector.SDKObject.prototype
1044 * @param {!Array.<!WebInspector.DebuggerModel.CallFrame>} callFrames
1045 * @param {?WebInspector.DebuggerModel.StackTrace} asyncStackTrace
1046 * @param {string=} description
1048 WebInspector.DebuggerModel.StackTrace = function(callFrames, asyncStackTrace, description)
1050 this.callFrames = callFrames;
1051 this.asyncStackTrace = asyncStackTrace;
1052 this.description = description;
1056 * @param {!WebInspector.Target} target
1057 * @param {!DebuggerAgent.StackTrace=} payload
1058 * @param {boolean=} isAsync
1059 * @return {?WebInspector.DebuggerModel.StackTrace}
1061 WebInspector.DebuggerModel.StackTrace.fromPayload = function(target, payload, isAsync)
1065 var callFrames = WebInspector.DebuggerModel.CallFrame.fromPayloadArray(target, payload.callFrames, isAsync);
1066 if (!callFrames.length)
1068 var asyncStackTrace = WebInspector.DebuggerModel.StackTrace.fromPayload(target, payload.asyncStackTrace, true);
1069 return new WebInspector.DebuggerModel.StackTrace(callFrames, asyncStackTrace, payload.description);
1074 * @extends {WebInspector.SDKObject}
1075 * @param {!WebInspector.Target} target
1076 * @param {!Array.<!DebuggerAgent.CallFrame>} callFrames
1077 * @param {string} reason
1078 * @param {!Object|undefined} auxData
1079 * @param {!Array.<string>} breakpointIds
1080 * @param {!DebuggerAgent.StackTrace=} asyncStackTrace
1082 WebInspector.DebuggerPausedDetails = function(target, callFrames, reason, auxData, breakpointIds, asyncStackTrace)
1084 WebInspector.SDKObject.call(this, target);
1085 this.callFrames = WebInspector.DebuggerModel.CallFrame.fromPayloadArray(target, callFrames);
1086 this.reason = reason;
1087 this.auxData = auxData;
1088 this.breakpointIds = breakpointIds;
1089 this.asyncStackTrace = WebInspector.DebuggerModel.StackTrace.fromPayload(target, asyncStackTrace, true);
1092 WebInspector.DebuggerPausedDetails.prototype = {
1094 * @return {?WebInspector.RemoteObject}
1096 exception: function()
1098 if (this.reason !== WebInspector.DebuggerModel.BreakReason.Exception)
1100 return this.target().runtimeModel.createRemoteObject(/** @type {!RuntimeAgent.RemoteObject} */(this.auxData));
1103 __proto__: WebInspector.SDKObject.prototype
1107 * @type {!WebInspector.DebuggerModel}
1109 WebInspector.debuggerModel;