Debugger Domain
Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.
Methods
- Debugger.continueToLocation
- Debugger.disable
- Debugger.enable
- Debugger.evaluateOnCallFrame
- Debugger.getScriptSource
- Debugger.pause
- Debugger.removeBreakpoint
- Debugger.restartFrame
- Debugger.resume
- Debugger.setAsyncCallStackDepth
- Debugger.setBreakpoint
- Debugger.setBreakpointByUrl
- Debugger.setBreakpointsActive
- Debugger.setPauseOnExceptions
- Debugger.setScriptSource
- Debugger.setSkipAllPauses
- Debugger.setVariableValue
- Debugger.stepInto
- Debugger.stepOut
- Debugger.stepOver
Events
- Debugger.breakpointResolved
- Debugger.paused
- Debugger.resumed
- Debugger.scriptFailedToParse
- Debugger.scriptParsed
Types
Methods
Debugger.continueToLocation #
Continues execution until specific location is reached.
Parameters
location Location to continue to.
Debugger.disable #
Disables debugger for given page.
Handles Debugger.disable request @cdp Debugger.disable If domain is already disabled, will return success.
Debugger.enable #
Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.
Handles Debugger.enable request @cdp Debugger.enable If domain is already enabled, will return success.
Debugger.evaluateOnCallFrame #
Evaluates expression on a given call frame.
In V8, @cdp Debugger.evaluateOnCallFrame populates the result
field with the exception value.
Parameters
callFrameId Call frame identifier to evaluate on.
expression stringExpression to evaluate.
objectGroupOptional
stringString object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup).
includeCommandLineAPIOptional
booleanSpecifies whether command line API should be available to the evaluated expression, defaults to false.
silentOptional
booleanIn silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
returnByValueOptional
booleanWhether the result is expected to be a JSON object that should be sent by value.
generatePreviewOptional
booleanWhether preview should be generated for the result.
Return object
result Object wrapper for the evaluation result.
exceptionDetailsOptional
Exception details.
Debugger.getScriptSource #
Returns source for the script with given id.
Parameters
scriptId Id of the script to get source for.
Return object
scriptSource stringScript source.
Debugger.restartFrame #
Restarts particular call frame from the beginning.
Parameters
callFrameId Call frame identifier to evaluate on.
Return object
callFrames array[ CallFrame ]New stack trace.
asyncStackTraceOptional
Async stack trace, if any.
Debugger.setAsyncCallStackDepth #
Enables or disables async call stacks tracking.
Parameters
maxDepth integerMaximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default).
Debugger.setBreakpoint #
Sets JavaScript breakpoint at a given location.
Parameters
location Location to set breakpoint in.
conditionOptional
stringExpression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
Return object
breakpointId Id of the created breakpoint for further reference.
actualLocation Location this breakpoint resolved into.
Debugger.setBreakpointByUrl #
Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads.
Parameters
lineNumber integerLine number to set breakpoint at.
urlOptional
stringURL of the resources to set breakpoint on.
urlRegexOptional
stringRegex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified.
columnNumberOptional
integerOffset in the line to set breakpoint at.
conditionOptional
stringExpression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
Return object
breakpointId Id of the created breakpoint for further reference.
locations array[ Location ]List of the locations this breakpoint resolved into upon addition.
Debugger.setBreakpointsActive #
Activates / deactivates all breakpoints on the page.
Handles Debugger.setBreakpointsActive @cdp Debugger.setBreakpointsActive Allowed even if domain is not enabled.
Parameters
active booleanNew value for breakpoints active state.
Debugger.setPauseOnExceptions #
Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none.
Parameters
state stringPause on exceptions mode.
Allowed values: none, uncaught, all
Debugger.setScriptSource #
Edits JavaScript source live.
Parameters
scriptId Id of the script to edit.
scriptSource stringNew content of the script.
dryRunOptional
booleanIf true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code.
Return object
callFramesOptional
array[ CallFrame ]New stack trace in case editing has happened while VM was stopped.
stackChangedOptional
booleanWhether current call stack was modified after applying the changes.
asyncStackTraceOptional
Async stack trace, if any.
exceptionDetailsOptional
Exception details if any.
Debugger.setSkipAllPauses #
Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).
Parameters
skip booleanNew value for skip pauses state.
Debugger.setVariableValue #
Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually.
Parameters
scopeNumber integer0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually.
variableName stringVariable name.
newValue New variable value.
callFrameId Id of callframe that holds variable.
Events
Debugger.breakpointResolved #
Fired when breakpoint is resolved to an actual script and location.
Parameters
breakpointId Breakpoint unique identifier.
location Actual breakpoint location.
Debugger.paused #
Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.
Although the documentation lists the "data" field as optional for the @cdp Debugger.paused event: https://chromedevtools.github.io/devtools-protocol/tot/Debugger/#event-paused it is accessed unconditionally by the front-end when the pause reason is "exception". "data" is passed in as "auxData" via: https://github.com/facebookexperimental/rn-chrome-devtools-frontend/blob/9a23d4c7c4c2d1a3d9e913af38d6965f474c4284/front_end/core/sdk/DebuggerModel.ts#L994 and "auxData" stored in a DebuggerPausedDetails instance: https://github.com/facebookexperimental/rn-chrome-devtools-frontend/blob/9a23d4c7c4c2d1a3d9e913af38d6965f474c4284/front_end/core/sdk/DebuggerModel.ts#L642 which then has its fields accessed in: https://github.com/facebookexperimental/rn-chrome-devtools-frontend/blob/main/front_end/panels/sources/DebuggerPausedMessage.ts#L225 If the "data" ("auxData") object is absent, accessing its fields will throw, breaking the display of pause information. Thus, we always populate "data" with an object. The "data" field has no schema in the protocol metadata that we use to generate message structures, so we need to manually construct a JSON object here. The structure expected by the front-end (specifically, the "description" field) can be inferred from the field access at the URL above. The front-end does gracefully handle missing fields on the "data" object, so we can consider the "description" field optional.
Parameters
callFrames array[ CallFrame ]Call stack the virtual machine stopped on.
reason stringPause reason.
Allowed values: XHR, DOM, EventListener, exception, assert, debugCommand, promiseRejection, other
dataOptional
objectObject containing break-specific auxiliary properties.
hitBreakpointsOptional
array[ string ]Hit breakpoints IDs
asyncStackTraceOptional
Async stack trace, if any.
Debugger.scriptFailedToParse #
Fired when virtual machine fails to parse the script.
Parameters
scriptId Identifier of the script parsed.
url stringURL or name of the script parsed (if any).
startLine integerLine offset of the script within the resource with given URL (for script tags).
startColumn integerColumn offset of the script within the resource with given URL.
endLine integerLast line of the script.
endColumn integerLength of the last line of the script.
executionContextId Specifies script creation context.
hash stringContent hash of the script.
executionContextAuxDataOptional
objectEmbedder-specific auxiliary data.
sourceMapURLOptional
stringURL of source map associated with script (if any).
hasSourceURLOptional
booleanTrue, if this script has sourceURL.
Debugger.scriptParsed #
Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.
Parameters
scriptId Identifier of the script parsed.
url stringURL or name of the script parsed (if any).
startLine integerLine offset of the script within the resource with given URL (for script tags).
startColumn integerColumn offset of the script within the resource with given URL.
endLine integerLast line of the script.
endColumn integerLength of the last line of the script.
executionContextId Specifies script creation context.
hash stringContent hash of the script.
executionContextAuxDataOptional
objectEmbedder-specific auxiliary data.
isLiveEditOptional
booleanTrue, if this script is generated as a result of the live edit operation.
sourceMapURLOptional
stringURL of source map associated with script (if any).
hasSourceURLOptional
booleanTrue, if this script has sourceURL.
Types
Debugger.CallFrame #
JavaScript call frame. Array of call frames form the call stack.
Type: object
Properties
callFrameId Call frame identifier. This identifier is only valid while the virtual machine is paused.
functionName stringName of the JavaScript function called on this call frame.
functionLocationOptional
location Location in the source code.
scopeChain array[ Scope ]Scope chain for this call frame.
this this object for this call frame.
returnValueOptional
The value being returned, if the function is at return point.
Debugger.Location #
Location in the source code.
Type: object
Properties
scriptId Script identifier as reported in the Debugger.scriptParsed.
lineNumber integerLine number in the script (0-based).
columnNumberOptional
integerColumn number in the script (0-based).
Debugger.Scope #
Scope description.
Type: object
Properties
type stringScope type.
Allowed values: global, local, with, closure, catch, block, script
object Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties.
nameOptional
stringstartLocationOptional
Location in the source code where scope starts
endLocationOptional
Location in the source code where scope ends