Debugger

class Debugger(cdp: CDP) : Domain

Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.

Constructors

Link copied to clipboard
constructor(cdp: CDP)

Types

Link copied to clipboard
@Serializable
data class BreakLocation(val scriptId: String, val lineNumber: Int, val columnNumber: Int? = null, val type: String? = null)
Link copied to clipboard
@Serializable
data class BreakpointResolvedParameter(val breakpointId: String, val location: Debugger.Location)

Fired when breakpoint is resolved to an actual script and location. Deprecated in favor of resolvedBreakpoints in the scriptParsed event.

Link copied to clipboard
@Serializable
data class CallFrame(val callFrameId: String, val functionName: String, val functionLocation: Debugger.Location? = null, val location: Debugger.Location, val url: String, val scopeChain: List<Debugger.Scope>, val this: Runtime.RemoteObject, val returnValue: Runtime.RemoteObject? = null, val canBeRestarted: Boolean? = null)

JavaScript call frame. Array of call frames form the call stack.

Link copied to clipboard
@Serializable
data class ContinueToLocationParameter(val location: Debugger.Location, val targetCallFrames: String? = null)
Link copied to clipboard
@Serializable
data class DebugSymbols(val type: String, val externalURL: String? = null)

Debug symbols available for a wasm script.

Link copied to clipboard
@Serializable
data class DisassembleWasmModuleParameter(val scriptId: String)
Link copied to clipboard
@Serializable
data class DisassembleWasmModuleReturn(val streamId: String?, val totalNumberOfLines: Int, val functionBodyOffsets: List<Int>, val chunk: Debugger.WasmDisassemblyChunk)
Link copied to clipboard
@Serializable
data class EnableParameter(val maxScriptsCacheSize: Double? = null)
Link copied to clipboard
@Serializable
data class EnableReturn(val debuggerId: String)
Link copied to clipboard
@Serializable
data class EvaluateOnCallFrameParameter(val callFrameId: String, val expression: String, val objectGroup: String? = null, val includeCommandLineAPI: Boolean? = null, val silent: Boolean? = null, val returnByValue: Boolean? = null, val generatePreview: Boolean? = null, val throwOnSideEffect: Boolean? = null, val timeout: Double? = null)
Link copied to clipboard
@Serializable
data class EvaluateOnCallFrameReturn(val result: Runtime.RemoteObject, val exceptionDetails: Runtime.ExceptionDetails?)
Link copied to clipboard
@Serializable
data class GetPossibleBreakpointsParameter(val start: Debugger.Location, val end: Debugger.Location? = null, val restrictToFunction: Boolean? = null)
Link copied to clipboard
@Serializable
data class GetPossibleBreakpointsReturn(val locations: List<Debugger.BreakLocation>)
Link copied to clipboard
@Serializable
data class GetScriptSourceParameter(val scriptId: String)
Link copied to clipboard
@Serializable
data class GetScriptSourceReturn(val scriptSource: String, val bytecode: String?)
Link copied to clipboard
@Serializable
data class GetStackTraceParameter(val stackTraceId: Runtime.StackTraceId)
Link copied to clipboard
@Serializable
data class GetStackTraceReturn(val stackTrace: Runtime.StackTrace)
Link copied to clipboard
@Serializable
data class GetWasmBytecodeParameter(val scriptId: String)
Link copied to clipboard
@Serializable
data class GetWasmBytecodeReturn(val bytecode: String)
Link copied to clipboard
@Serializable
data class Location(val scriptId: String, val lineNumber: Int, val columnNumber: Int? = null)

Location in the source code.

Link copied to clipboard
@Serializable
data class LocationRange(val scriptId: String, val start: Debugger.ScriptPosition, val end: Debugger.ScriptPosition)

Location range within one script.

Link copied to clipboard
@Serializable
data class NextWasmDisassemblyChunkParameter(val streamId: String)
Link copied to clipboard
Link copied to clipboard
@Serializable
data class PausedParameter(val callFrames: List<Debugger.CallFrame>, val reason: String, val data: Map<String, JsonElement>? = null, val hitBreakpoints: List<String>? = null, val asyncStackTrace: Runtime.StackTrace? = null, val asyncStackTraceId: Runtime.StackTraceId? = null, val asyncCallStackTraceId: Runtime.StackTraceId? = null)

Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.

Link copied to clipboard
@Serializable
data class PauseOnAsyncCallParameter(val parentStackTraceId: Runtime.StackTraceId)
Link copied to clipboard
@Serializable
data class RemoveBreakpointParameter(val breakpointId: String)
Link copied to clipboard
@Serializable
data class ResolvedBreakpoint(val breakpointId: String, val location: Debugger.Location)
Link copied to clipboard
@Serializable
data class RestartFrameParameter(val callFrameId: String, val mode: String? = null)
Link copied to clipboard
@Serializable
data class RestartFrameReturn(val callFrames: List<Debugger.CallFrame>, val asyncStackTrace: Runtime.StackTrace?, val asyncStackTraceId: Runtime.StackTraceId?)
Link copied to clipboard
@Serializable
data class ResumeParameter(val terminateOnResume: Boolean? = null)
Link copied to clipboard
@Serializable
data class Scope(val type: String, val object: Runtime.RemoteObject, val name: String? = null, val startLocation: Debugger.Location? = null, val endLocation: Debugger.Location? = null)

Scope description.

Link copied to clipboard
@Serializable
data class ScriptFailedToParseParameter(val scriptId: String, val url: String, val startLine: Int, val startColumn: Int, val endLine: Int, val endColumn: Int, val executionContextId: Int, val hash: String, val buildId: String, val executionContextAuxData: Map<String, JsonElement>? = null, val sourceMapURL: String? = null, val hasSourceURL: Boolean? = null, val isModule: Boolean? = null, val length: Int? = null, val stackTrace: Runtime.StackTrace? = null, val codeOffset: Int? = null, val scriptLanguage: Debugger.ScriptLanguage? = null, val embedderName: String? = null)

Fired when virtual machine fails to parse the script.

Link copied to clipboard

Enum of possible script languages.

Link copied to clipboard
@Serializable
data class ScriptParsedParameter(val scriptId: String, val url: String, val startLine: Int, val startColumn: Int, val endLine: Int, val endColumn: Int, val executionContextId: Int, val hash: String, val buildId: String, val executionContextAuxData: Map<String, JsonElement>? = null, val isLiveEdit: Boolean? = null, val sourceMapURL: String? = null, val hasSourceURL: Boolean? = null, val isModule: Boolean? = null, val length: Int? = null, val stackTrace: Runtime.StackTrace? = null, val codeOffset: Int? = null, val scriptLanguage: Debugger.ScriptLanguage? = null, val debugSymbols: List<Debugger.DebugSymbols>? = null, val embedderName: String? = null, val resolvedBreakpoints: List<Debugger.ResolvedBreakpoint>? = null)

Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.

Link copied to clipboard
@Serializable
data class ScriptPosition(val lineNumber: Int, val columnNumber: Int)

Location in the source code.

Link copied to clipboard
@Serializable
data class SearchInContentParameter(val scriptId: String, val query: String, val caseSensitive: Boolean? = null, val isRegex: Boolean? = null)
Link copied to clipboard
@Serializable
data class SearchInContentReturn(val result: List<Debugger.SearchMatch>)
Link copied to clipboard
@Serializable
data class SearchMatch(val lineNumber: Double, val lineContent: String)

Search match for resource.

Link copied to clipboard
@Serializable
data class SetAsyncCallStackDepthParameter(val maxDepth: Int)
Link copied to clipboard
@Serializable
data class SetBlackboxedRangesParameter(val scriptId: String, val positions: List<Debugger.ScriptPosition>)
Link copied to clipboard
@Serializable
data class SetBlackboxExecutionContextsParameter(val uniqueIds: List<String>)
Link copied to clipboard
@Serializable
data class SetBlackboxPatternsParameter(val patterns: List<String>, val skipAnonymous: Boolean? = null)
Link copied to clipboard
@Serializable
data class SetBreakpointByUrlParameter(val lineNumber: Int, val url: String? = null, val urlRegex: String? = null, val scriptHash: String? = null, val columnNumber: Int? = null, val condition: String? = null)
Link copied to clipboard
@Serializable
data class SetBreakpointByUrlReturn(val breakpointId: String, val locations: List<Debugger.Location>)
Link copied to clipboard
@Serializable
data class SetBreakpointOnFunctionCallParameter(val objectId: String, val condition: String? = null)
Link copied to clipboard
@Serializable
data class SetBreakpointOnFunctionCallReturn(val breakpointId: String)
Link copied to clipboard
@Serializable
data class SetBreakpointParameter(val location: Debugger.Location, val condition: String? = null)
Link copied to clipboard
@Serializable
data class SetBreakpointReturn(val breakpointId: String, val actualLocation: Debugger.Location)
Link copied to clipboard
@Serializable
data class SetBreakpointsActiveParameter(val active: Boolean)
Link copied to clipboard
@Serializable
data class SetInstrumentationBreakpointParameter(val instrumentation: String)
Link copied to clipboard
@Serializable
data class SetInstrumentationBreakpointReturn(val breakpointId: String)
Link copied to clipboard
@Serializable
data class SetPauseOnExceptionsParameter(val state: String)
Link copied to clipboard
@Serializable
data class SetReturnValueParameter(val newValue: Runtime.CallArgument)
Link copied to clipboard
@Serializable
data class SetScriptSourceParameter(val scriptId: String, val scriptSource: String, val dryRun: Boolean? = null, val allowTopFrameEditing: Boolean? = null)
Link copied to clipboard
@Serializable
data class SetScriptSourceReturn(val callFrames: List<Debugger.CallFrame>?, val stackChanged: Boolean?, val asyncStackTrace: Runtime.StackTrace?, val asyncStackTraceId: Runtime.StackTraceId?, val status: String, val exceptionDetails: Runtime.ExceptionDetails?)
Link copied to clipboard
@Serializable
data class SetSkipAllPausesParameter(val skip: Boolean)
Link copied to clipboard
@Serializable
data class SetVariableValueParameter(val scopeNumber: Int, val variableName: String, val newValue: Runtime.CallArgument, val callFrameId: String)
Link copied to clipboard
@Serializable
data class StepIntoParameter(val breakOnAsyncCall: Boolean? = null, val skipList: List<Debugger.LocationRange>? = null)
Link copied to clipboard
@Serializable
data class StepOverParameter(val skipList: List<Debugger.LocationRange>? = null)
Link copied to clipboard
@Serializable
data class WasmDisassemblyChunk(val lines: List<String>, val bytecodeOffsets: List<Int>)

Properties

Link copied to clipboard

Fired when breakpoint is resolved to an actual script and location. Deprecated in favor of resolvedBreakpoints in the scriptParsed event.

Link copied to clipboard

Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.

Link copied to clipboard
val resumed: Flow<Unit>

Fired when the virtual machine resumed execution.

Link copied to clipboard

Fired when virtual machine fails to parse the script.

Link copied to clipboard

Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.

Functions

Link copied to clipboard
suspend fun continueToLocation(args: Debugger.ContinueToLocationParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun continueToLocation(location: Debugger.Location, targetCallFrames: String? = null)

Continues execution until specific location is reached.

Link copied to clipboard
suspend fun disable(mode: CommandMode = CommandMode.DEFAULT)

Disables debugger for given page.

Link copied to clipboard
suspend fun enable(maxScriptsCacheSize: Double? = null): Debugger.EnableReturn
suspend fun enable(args: Debugger.EnableParameter, mode: CommandMode = CommandMode.DEFAULT): Debugger.EnableReturn

Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.

Link copied to clipboard
suspend fun evaluateOnCallFrame(callFrameId: String, expression: String, objectGroup: String? = null, includeCommandLineAPI: Boolean? = null, silent: Boolean? = null, returnByValue: Boolean? = null, generatePreview: Boolean? = null, throwOnSideEffect: Boolean? = null, timeout: Double? = null): Debugger.EvaluateOnCallFrameReturn

Evaluates expression on a given call frame.

Link copied to clipboard
suspend fun getPossibleBreakpoints(start: Debugger.Location, end: Debugger.Location? = null, restrictToFunction: Boolean? = null): Debugger.GetPossibleBreakpointsReturn

Returns possible locations for breakpoint. scriptId in start and end range locations should be the same.

Link copied to clipboard

Returns source for the script with given id.

Link copied to clipboard

Returns stack trace with given stackTraceId.

Link copied to clipboard

This command is deprecated. Use getScriptSource instead.

Link copied to clipboard

Disassemble the next chunk of lines for the module corresponding to the stream. If disassembly is complete, this API will invalidate the streamId and return an empty chunk. Any subsequent calls for the now invalid stream will return errors.

Link copied to clipboard
suspend fun pause(mode: CommandMode = CommandMode.DEFAULT)

Stops on the next JavaScript statement.

Link copied to clipboard
suspend fun pauseOnAsyncCall(parentStackTraceId: Runtime.StackTraceId)
suspend fun pauseOnAsyncCall(args: Debugger.PauseOnAsyncCallParameter, mode: CommandMode = CommandMode.DEFAULT)
Link copied to clipboard
suspend fun removeBreakpoint(breakpointId: String)
suspend fun removeBreakpoint(args: Debugger.RemoveBreakpointParameter, mode: CommandMode = CommandMode.DEFAULT)

Removes JavaScript breakpoint.

Link copied to clipboard
suspend fun restartFrame(callFrameId: String, mode: String? = null): Debugger.RestartFrameReturn

Restarts particular call frame from the beginning. The old, deprecated behavior of restartFrame is to stay paused and allow further CDP commands after a restart was scheduled. This can cause problems with restarting, so we now continue execution immediatly after it has been scheduled until we reach the beginning of the restarted frame.

Link copied to clipboard
suspend fun resume(terminateOnResume: Boolean? = null)
suspend fun resume(args: Debugger.ResumeParameter, mode: CommandMode = CommandMode.DEFAULT)

Resumes JavaScript execution.

Link copied to clipboard
suspend fun searchInContent(scriptId: String, query: String, caseSensitive: Boolean? = null, isRegex: Boolean? = null): Debugger.SearchInContentReturn

Searches for given string in script content.

Link copied to clipboard
suspend fun setAsyncCallStackDepth(maxDepth: Int)
suspend fun setAsyncCallStackDepth(args: Debugger.SetAsyncCallStackDepthParameter, mode: CommandMode = CommandMode.DEFAULT)

Enables or disables async call stacks tracking.

Link copied to clipboard
suspend fun setBlackboxedRanges(args: Debugger.SetBlackboxedRangesParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setBlackboxedRanges(scriptId: String, positions: List<Debugger.ScriptPosition>)

Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted.

Link copied to clipboard
suspend fun setBlackboxExecutionContexts(uniqueIds: List<String>)

Replace previous blackbox execution contexts with passed ones. Forces backend to skip stepping/pausing in scripts in these execution contexts. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful.

Link copied to clipboard
suspend fun setBlackboxPatterns(args: Debugger.SetBlackboxPatternsParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setBlackboxPatterns(patterns: List<String>, skipAnonymous: Boolean? = null)

Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful.

Link copied to clipboard
suspend fun setBreakpoint(location: Debugger.Location, condition: String? = null): Debugger.SetBreakpointReturn

Sets JavaScript breakpoint at a given location.

Link copied to clipboard
suspend fun setBreakpointByUrl(lineNumber: Int, url: String? = null, urlRegex: String? = null, scriptHash: String? = null, columnNumber: Int? = null, condition: String? = null): Debugger.SetBreakpointByUrlReturn

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.

Link copied to clipboard

Sets JavaScript breakpoint before each call to the given function. If another function was created from the same source as a given one, calling it will also trigger the breakpoint.

Link copied to clipboard
suspend fun setBreakpointsActive(active: Boolean)
suspend fun setBreakpointsActive(args: Debugger.SetBreakpointsActiveParameter, mode: CommandMode = CommandMode.DEFAULT)

Activates / deactivates all breakpoints on the page.

Link copied to clipboard
suspend fun setPauseOnExceptions(state: String)
suspend fun setPauseOnExceptions(args: Debugger.SetPauseOnExceptionsParameter, mode: CommandMode = CommandMode.DEFAULT)

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.

Link copied to clipboard
suspend fun setReturnValue(newValue: Runtime.CallArgument)
suspend fun setReturnValue(args: Debugger.SetReturnValueParameter, mode: CommandMode = CommandMode.DEFAULT)

Changes return value in top frame. Available only at return break position.

Link copied to clipboard
suspend fun setScriptSource(scriptId: String, scriptSource: String, dryRun: Boolean? = null, allowTopFrameEditing: Boolean? = null): Debugger.SetScriptSourceReturn

Edits JavaScript source live.

Link copied to clipboard
suspend fun setSkipAllPauses(skip: Boolean)
suspend fun setSkipAllPauses(args: Debugger.SetSkipAllPausesParameter, mode: CommandMode = CommandMode.DEFAULT)

Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).

Link copied to clipboard
suspend fun setVariableValue(args: Debugger.SetVariableValueParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun setVariableValue(scopeNumber: Int, variableName: String, newValue: Runtime.CallArgument, callFrameId: String)

Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually.

Link copied to clipboard
suspend fun stepInto(args: Debugger.StepIntoParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun stepInto(breakOnAsyncCall: Boolean? = null, skipList: List<Debugger.LocationRange>? = null)

Steps into the function call.

Link copied to clipboard
suspend fun stepOut(mode: CommandMode = CommandMode.DEFAULT)

Steps out of the function call.

Link copied to clipboard
suspend fun stepOver(skipList: List<Debugger.LocationRange>? = null)
suspend fun stepOver(args: Debugger.StepOverParameter, mode: CommandMode = CommandMode.DEFAULT)

Steps over the statement.