Debugger Domain
Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.
Methods
- Debugger.disable
- Debugger.enable
- Debugger.evaluateOnCallFrame
- Debugger.pause
- Debugger.removeBreakpoint
- Debugger.resume
- Debugger.setBreakpoint
- Debugger.setBreakpointByUrl
- Debugger.setBreakpointsActive
- Debugger.setPauseOnExceptions
- Debugger.stepInto
- Debugger.stepOut
- Debugger.stepOver
Events
Types
Methods
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.
Parameters
maxScriptsCacheSize
Optional
number
The maximum size in bytes of collected scripts (not referenced by other heap objects) the debugger can hold. Puts no limit if parameter is omitted.
Return object
debuggerId
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
string
Expression to evaluate.
objectGroup
Optional
string
String object group name to put result into (allows rapid releasing resulting object handles
using releaseObjectGroup
).
includeCommandLineAPI
Optional
boolean
Specifies whether command line API should be available to the evaluated expression, defaults to false.
silent
Optional
boolean
In silent mode exceptions thrown during evaluation are not reported and do not pause
execution. Overrides setPauseOnException
state.
returnByValue
Optional
boolean
Whether the result is expected to be a JSON object that should be sent by value.
generatePreview
Optional
boolean
Whether preview should be generated for the result.
throwOnSideEffect
Optional
boolean
Whether to throw an exception if side effect cannot be ruled out during evaluation.
timeout
Optional
Return object
result
Object wrapper for the evaluation result.
exceptionDetails
Optional
Exception details.
Debugger.resume #
Resumes JavaScript execution.
Parameters
terminateOnResume
Optional
boolean
Set to true to terminate execution upon resuming execution. In contrast to Runtime.terminateExecution, this will allows to execute further JavaScript (i.e. via evaluation) until execution of the paused code is actually resumed, at which point termination is triggered. If execution is currently not paused, this parameter has no effect.
Debugger.setBreakpoint #
Sets JavaScript breakpoint at a given location.
Parameters
location
Location to set breakpoint in.
condition
Optional
string
Expression 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
integer
Line number to set breakpoint at.
url
Optional
string
URL of the resources to set breakpoint on.
urlRegex
Optional
string
Regex pattern for the URLs of the resources to set breakpoints on. Either url
or
urlRegex
must be specified.
scriptHash
Optional
string
Script hash of the resources to set breakpoint on.
columnNumber
Optional
integer
Offset in the line to set breakpoint at.
condition
Optional
string
Expression 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
boolean
New value for breakpoints active state.
Debugger.setPauseOnExceptions #
Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions,
or caught exceptions, no exceptions. Initial pause on exceptions state is none
.
Parameters
state
string
Pause on exceptions mode.
Allowed values: none
, caught
, uncaught
, all
Debugger.stepInto #
Steps into the function call.
Parameters
breakOnAsyncCall
Optional
boolean
Debugger will pause on the execution of the first async task which was scheduled before next pause.
skipList
Optional
array[ LocationRange ]
The skipList specifies location ranges that should be skipped on step into.
Debugger.stepOver #
Steps over the statement.
Parameters
skipList
Optional
array[ LocationRange ]
The skipList specifies location ranges that should be skipped on step over.
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
string
Pause reason.
Allowed values: ambiguous
, assert
, CSPViolation
, debugCommand
, DOM
, EventListener
, exception
, instrumentation
, OOM
, other
, promiseRejection
, XHR
, step
data
Optional
object
Object containing break-specific auxiliary properties.
hitBreakpoints
Optional
array[ string
]
Hit breakpoints IDs
asyncStackTrace
Optional
Async stack trace, if any.
asyncStackTraceId
Optional
asyncCallStackTraceId
Optional
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
string
URL or name of the script parsed (if any).
startLine
integer
Line offset of the script within the resource with given URL (for script tags).
startColumn
integer
Column offset of the script within the resource with given URL.
endLine
integer
Last line of the script.
endColumn
integer
Length of the last line of the script.
executionContextId
Specifies script creation context.
hash
string
Content hash of the script, SHA-256.
executionContextAuxData
Optional
object
Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}
isLiveEdit
Optional
boolean
True, if this script is generated as a result of the live edit operation.
sourceMapURL
Optional
string
URL of source map associated with script (if any).
hasSourceURL
Optional
boolean
True, if this script has sourceURL.
isModule
Optional
boolean
True, if this script is ES6 module.
length
Optional
integer
This script length.
stackTrace
Optional
JavaScript top stack frame of where the script parsed event was triggered if available.
codeOffset
Optional
integer
If the scriptLanguage is WebAssembly, the code section offset in the module.
scriptLanguage
Optional
debugSymbols
Optional
If the scriptLanguage is WebASsembly, the source of debug symbols for the module.
embedderName
Optional
string
The name the embedder supplied for this script.
Types
Debugger.DebugSymbols #
Debug symbols available for a wasm script.
Type: object
Properties
type
string
Type of the debug symbols.
Allowed values: None
, SourceMap
, EmbeddedDWARF
, ExternalDWARF
externalURL
Optional
string
URL of the external symbol source.
Debugger.ScriptLanguage #
Enum of possible script languages.
Type: string
Allowed values: JavaScript
, WebAssembly