跳到主要内容

Debugger

调试器(Debugger)域提供了JavaScript调试功能。它允许设置和移除断点、单步执行、查看堆栈跟踪等操作。

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

✅️️ Methods

🔨Debugger.continueToLocation

继续执行,直到到达特定位置。

EN
Continues execution until specific location is reached.
参数必填标记类型描述原文
location✔️Location继续前往的位置。
ENLocation to continue to.
targetCallFramesstring允许的值:anycurrent
ENAllowed Values: any, current

🔨Debugger.disable

禁用给定页面的调试器。

EN
Disables debugger for given page.

🔨Debugger.enable

为指定页面启用调试器。在收到此命令的结果之前,客户端不应假定调试功能已启用。

EN
Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.
参数必填标记类型描述原文
maxScriptsCacheSize🧪number调试器可容纳的已收集脚本(未被其他堆对象引用)的最大字节数。如果省略参数,则不设限制。
ENThe maximum size in bytes of collected scripts (not referenced by other heap objects) the debugger can hold. Puts no limit if parameter is omitted.
返回对象类型描述原文
debuggerIdRuntime.UniqueDebuggerId调试器的唯一标识符。
ENUnique identifier of the debugger.

🔨Debugger.evaluateOnCallFrame

在指定的调用帧上评估表达式。

EN
Evaluates expression on a given call frame.
参数必填标记类型描述原文
callFrameId✔️CallFrameId要在其上评估的调用帧标识符。
ENCall frame identifier to evaluate on.
expression✔️string要评估的表达式。
ENExpression to evaluate.
objectGroupstring将结果放入的字符串对象组名称(允许使用releaseObjectGroup快速释放结果对象句柄)。
ENString object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup).
includeCommandLineAPIboolean指定命令行API是否应对被评估的表达式可用,默认为false。
ENSpecifies whether command line API should be available to the evaluated expression, defaults to false.
silentboolean在静默模式下,评估期间抛出的异常不会被报告,也不会暂停执行。这会覆盖 setPauseOnException 状态。
ENIn silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
returnByValueboolean结果是否预期为一个应通过值传递的JSON对象。
ENWhether the result is expected to be a JSON object that should be sent by value.
generatePreview🧪boolean是否应为结果生成预览。
ENWhether preview should be generated for the result.
throwOnSideEffectboolean是否在评估过程中无法排除副作用时抛出异常。
ENWhether to throw an exception if side effect cannot be ruled out during evaluation.
timeout🧪Runtime.TimeDelta执行在超时后终止(毫秒数)。
ENTerminate execution after timing out (number of milliseconds).
返回对象类型描述原文
resultRuntime.RemoteObject评估结果的对象包装器。
ENObject wrapper for the evaluation result.
exceptionDetailsRuntime.ExceptionDetails异常详情。
ENException details.

🔨Debugger.getPossibleBreakpoints

返回断点的可能位置。起始和结束范围位置中的脚本ID应相同。

EN
Returns possible locations for breakpoint. scriptId in start and end range locations should be the same.
参数必填标记类型描述原文
start✔️Location搜索可能断点位置范围的起始点。
ENStart of range to search possible breakpoint locations in.
endLocation在脚本中搜索可能的断点位置的范围结束位置(不包含)。当未指定时,脚本的结尾将作为范围的结束。
ENEnd of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range.
restrictToFunctionboolean仅考虑与起始点位于同一(非嵌套)函数内的位置。
ENOnly consider locations which are in the same (non-nested) function as start.
返回对象类型描述原文
locationsarray[BreakLocation]可能的断点位置列表。
ENList of the possible breakpoint locations.

🔨Debugger.getScriptSource

返回具有给定ID的脚本的源代码。

EN
Returns source for the script with given id.
参数必填标记类型描述原文
scriptId✔️Runtime.ScriptId获取源代码的脚本ID。
ENId of the script to get source for.
返回对象类型描述原文
scriptSourcestring脚本源(在Wasm字节码情况下为空)。
ENScript source (empty in case of Wasm bytecode).
bytecodestringWasm字节码。(通过JSON传递时,编码为base64字符串)
ENWasm bytecode. (Encoded as a base64 string when passed over JSON)

🔨Debugger.pause

在下一个JavaScript语句处停止。

EN
Stops on the next JavaScript statement.

🔨Debugger.removeBreakpoint

移除JavaScript断点。

EN
Removes JavaScript breakpoint.
参数必填标记类型描述原文
breakpointId✔️BreakpointId

🔨Debugger.restartFrame

从起始处重新执行特定的调用栈帧。restartFrame 已弃用的旧行为是在重启计划后保持暂停状态并允许进一步的 CDP 命令。这可能导致重启时出现问题,因此我们现在在计划重启后立即继续执行,直到到达重启栈帧的起始位置。
为保持向后兼容性,restartFrame 现在要求提供 mode 参数。如果缺少 mode 参数,restartFrame 将报错。
各种返回值均已弃用,且 callFrames 始终为空。请改用 Debugger#paused 事件中的调用栈帧,该事件会在 V8 在重启函数起始处暂停时触发。

EN
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.
To stay back-wards compatible, restartFrame now expects a mode parameter to be present. If the mode parameter is missing, restartFrame errors out.
The various return values are deprecated and callFrames is always empty. Use the call frames from the Debugger#paused events instead, that fires once V8 pauses at the beginning of the restarted function.
参数必填标记类型描述原文
callFrameId✔️CallFrameId要在其上评估的调用帧标识符。
ENCall frame identifier to evaluate on.
mode🧪stringmode 参数必须存在且设置为 'StepInto',否则 restartFrame 将出错。
允许的值:StepInto
ENThe mode parameter must be present and set to 'StepInto', otherwise restartFrame will error out.
Allowed Values: StepInto
返回对象类型描述原文
callFramesarray[CallFrame]新堆栈跟踪。
ENNew stack trace.
asyncStackTraceRuntime.StackTrace异步堆栈跟踪(如果有的话)。
ENAsync stack trace, if any.
asyncStackTraceIdRuntime.StackTraceId异步堆栈跟踪(如果有的话)。
ENAsync stack trace, if any.

🔨Debugger.resume

恢复 JavaScript 执行。

EN
Resumes JavaScript execution.
参数必填标记类型描述原文
terminateOnResumeboolean设置为 true 以在恢复执行时终止执行。与 Runtime.terminateExecution 不同,这将允许执行更多 JavaScript(例如通过求值),直到实际恢复暂停代码的执行,此时会触发终止。如果当前执行未暂停,则此参数无效。
ENSet 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.searchInContent

在脚本内容中搜索给定的字符串。

EN
Searches for given string in script content.
参数必填标记类型描述原文
scriptId✔️Runtime.ScriptId在脚本中搜索的Id。
ENId of the script to search in.
query✔️string要搜索的字符串。
ENString to search for.
caseSensitiveboolean如果为真,则搜索区分大小写。
ENIf true, search is case sensitive.
isRegexboolean如果为真,将字符串参数视为正则表达式。
ENIf true, treats string parameter as regex.
返回对象类型描述原文
resultarray[SearchMatch]搜索结果列表。
ENList of search matches.

🔨Debugger.setAsyncCallStackDepth

启用或禁用异步调用堆栈跟踪。

EN
Enables or disables async call stacks tracking.
参数必填标记类型描述原文
maxDepth✔️integer异步调用栈的最大深度。设置为 0 将有效禁用收集异步调用栈(默认)。
ENMaximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default).

🔨Debugger.setBreakpoint

在指定位置设置JavaScript断点。

EN
Sets JavaScript breakpoint at a given location.
参数必填标记类型描述原文
location✔️Location在''和``内的内容保持不变的情况下,翻译文本为:设置断点的位置。
ENLocation to set breakpoint in.
conditionstring用作断点条件的表达式。当指定时,调试器仅在此表达式求值为真时才会在断点处停止。
ENExpression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
返回对象类型描述原文
breakpointIdBreakpointId创建的断点ID,用于后续引用。
ENId of the created breakpoint for further reference.
actualLocationLocation此断点解析到的位置。
ENLocation this breakpoint resolved into.

🔨Debugger.setBreakpointByUrl

在由URL或URL正则表达式指定的给定位置设置JavaScript断点。一旦发出此命令,所有已解析的脚本将解析断点并在locations属性中返回。后续匹配的脚本解析将触发breakpointResolved事件。此逻辑断点将在页面重新加载后保持有效。

EN
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.
参数必填标记类型描述原文
lineNumber✔️integer设置断点的行号。
ENLine number to set breakpoint at.
urlstring要在其上设置断点的资源URL。
ENURL of the resources to set breakpoint on.
urlRegexstring用于设置断点的资源URL的正则表达式模式。必须指定 urlurlRegex 中的一项。
ENRegex pattern for the URLs of the resources to set breakpoints on. Either url or urlRegex must be specified.
scriptHashstring要设置断点的资源的脚本哈希。
ENScript hash of the resources to set breakpoint on.
columnNumberinteger在行内设置断点的偏移量。
ENOffset in the line to set breakpoint at.
conditionstring用作断点条件的表达式。当指定后,调试器仅在该表达式求值为真时才会在断点处停止。
ENExpression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
返回对象类型描述原文
breakpointIdBreakpointId创建的断点ID,用于后续引用。
ENId of the created breakpoint for further reference.
locationsarray[Location]此断点添加时解析到的位置列表。
ENList of the locations this breakpoint resolved into upon addition.

🔨Debugger.setBreakpointsActive

激活/停用页面上的所有断点。

EN
Activates / deactivates all breakpoints on the page.
参数必填标记类型描述原文
active✔️boolean断点活动状态的新值。
ENNew value for breakpoints active state.

🔨Debugger.setInstrumentationBreakpoint

设置检测断点。

EN
Sets instrumentation breakpoint.
参数必填标记类型描述原文
instrumentation✔️string仪器名称。
允许值:beforeScriptExecutionbeforeScriptWithSourceMapExecution
ENInstrumentation name.
Allowed Values: beforeScriptExecution, beforeScriptWithSourceMapExecution
返回对象类型描述原文
breakpointIdBreakpointId所创建断点的ID,用于后续引用。
ENId of the created breakpoint for further reference.

🔨Debugger.setPauseOnExceptions

定义异常暂停状态。可设置为在所有异常、未捕获异常、捕获异常或无异常时暂停。初始异常暂停状态为 none

EN
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.
参数必填标记类型描述原文
state✔️string异常暂停模式。
允许值:nonecaughtuncaughtall
ENPause on exceptions mode.
Allowed Values: none, caught, uncaught, all

🔨Debugger.setScriptSource

实时编辑JavaScript源代码。

通常情况下,当前位于调用栈中的函数无法被编辑,但有一个例外:如果被编辑的函数位于调用栈的最顶层,并且该函数在栈中仅被激活一次。在这种情况下,实时编辑将会成功,并且会自动触发对最顶层函数的Debugger.restartFrame操作。

EN
Edits JavaScript source live.
In general, functions that are currently on the stack can not be edited with a single exception: If the edited function is the top-most stack frame and that is the only activation of that function on the stack. In this case the live edit will be successful and a Debugger.restartFrame for the top-most function is automatically triggered.
参数必填标记类型描述原文
scriptId✔️Runtime.ScriptId要编辑的脚本的Id。
ENId of the script to edit.
scriptSource✔️string脚本的新内容。
ENNew content of the script.
dryRunboolean如果为真,则更改实际上不会被应用。空运行可用于在不实际修改代码的情况下获取结果描述。
ENIf true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code.
allowTopFrameEditing🧪boolean如果为真,则允许 scriptSource 修改调用栈顶部的函数,前提是最顶层的堆栈帧是该函数的唯一激活实例。
ENIf true, then scriptSource is allowed to change the function on top of the stack as long as the top-most stack frame is the only activation of that function.
返回对象类型描述原文
callFramesarray[CallFrame]VM停止时发生编辑情况下的新堆栈跟踪。
ENNew stack trace in case editing has happened while VM was stopped.
stackChangedboolean应用更改后,当前调用堆栈是否被修改。
ENWhether current call stack was modified after applying the changes.
asyncStackTraceRuntime.StackTrace异步堆栈跟踪(如果有的话)。
ENAsync stack trace, if any.
asyncStackTraceIdRuntime.StackTraceId异步堆栈跟踪(如果有的话)。
ENAsync stack trace, if any.
statusstring操作是否成功。只有Ok表示实时编辑成功,而其他枚举变体表示实时编辑失败的原因。

允许的值:OkCompileErrorBlockedByActiveGeneratorBlockedByActiveFunctionBlockedByTopLevelEsModuleChange
ENWhether the operation was successful or not. Only Ok denotes a successful live edit while the other enum variants denote why the live edit failed.
Allowed Values: Ok, CompileError, BlockedByActiveGenerator, BlockedByActiveFunction, BlockedByTopLevelEsModuleChange
exceptionDetailsRuntime.ExceptionDetails异常详情(如果有)。仅在statusCompileError时出现。
ENException details if any. Only present when status is CompileError.

🔨Debugger.setSkipAllPauses

使页面在任何暂停(断点、异常、DOM异常等)时不会中断。

EN
Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).
参数必填标记类型描述原文
skip✔️boolean跳过暂停状态的新值。
ENNew value for skip pauses state.

🔨Debugger.setVariableValue

修改调用帧中变量的值。不支持基于对象的作用域,必须手动进行修改。

EN
Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually.
参数必填标记类型描述原文
scopeNumber✔️integer基于0的编号,对应在作用域链中列出的顺序。仅允许'local'、'closure'和'catch'这三种作用域类型。其他作用域类型可能需要手动处理。
EN0-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✔️string变量名。
ENVariable name.
newValue✔️Runtime.CallArgument新变量值。
ENNew variable value.
callFrameId✔️CallFrameId保存变量的调用帧的Id。
ENId of callframe that holds variable.

🔨Debugger.stepInto

单步进入函数调用。

EN
Steps into the function call.
参数必填标记类型描述原文
breakOnAsyncCall🧪boolean调试器将在执行第一个异步任务时暂停,该任务是在下一次暂停之前安排的。
ENDebugger will pause on the execution of the first async task which was scheduled before next pause.
skipList🧪array[LocationRange]skipList指定了在单步进入时应跳过的位置范围。
ENThe skipList specifies location ranges that should be skipped on step into.

🔨Debugger.stepOut

退出函数调用。

EN
Steps out of the function call.

🔨Debugger.stepOver

单步跳过该语句。

EN
Steps over the statement.
参数必填标记类型描述原文
skipList🧪array[LocationRange]skipList指定了在单步跳过时应跳过的位置范围。
ENThe skipList specifies location ranges that should be skipped on step over.

🔨Debugger.getWasmBytecode❌️

此命令已弃用。请改用 getScriptSource

EN
This command is deprecated. Use getScriptSource instead.
参数必填标记类型描述原文
scriptId✔️Runtime.ScriptId获取源代码的Wasm脚本ID。
ENId of the Wasm script to get source for.
返回对象类型描述原文
bytecodestring脚本源。(通过JSON传递时编码为base64字符串)
ENScript source. (Encoded as a base64 string when passed over JSON)

🔨Debugger.disassembleWasmModule🧪

参数必填标记类型描述原文
scriptId✔️Runtime.ScriptId要反汇编的脚本的Id
ENId of the script to disassemble
返回对象类型描述原文
streamIdstring对于大型模块,返回一个流,可以从中连续读取额外的反汇编代码块。
ENFor large modules, return a stream from which additional chunks of disassembly can be read successively.
totalNumberOfLinesinteger反汇编文本中的总行数。
ENThe total number of lines in the disassembly text.
functionBodyOffsetsarray[integer]所有函数体的偏移量,格式为 [start1, end1, start2, end2, ...],其中所有 end 值均为不包含的。
ENThe offsets of all function bodies, in the format [start1, end1, start2, end2, ...] where all ends are exclusive.
chunkWasmDisassemblyChunk这是反汇编的第一部分。
ENThe first chunk of disassembly.

🔨Debugger.getStackTrace🧪

返回具有给定 stackTraceId 的堆栈跟踪。

EN
Returns stack trace with given stackTraceId.
参数必填标记类型描述原文
stackTraceId✔️Runtime.StackTraceId
返回对象类型描述原文
stackTraceRuntime.StackTrace

🔨Debugger.nextWasmDisassemblyChunk🧪

为对应流的模块反汇编下一块代码行。如果反汇编完成,此API将使streamId失效并返回空数据块。任何后续对现已失效流的调用都将返回错误。

EN
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.
参数必填标记类型描述原文
streamId✔️string
返回对象类型描述原文
chunkWasmDisassemblyChunk下一段反汇编代码。
ENThe next chunk of disassembly.

🔨Debugger.setBlackboxedRanges🧪

使后端在脚本的黑盒范围内跳过步骤。虚拟机将尝试通过多次执行“步入”操作来离开黑名单脚本,如果不成功则最终采取“步出”操作。位置数组包含黑盒状态发生改变的位置。第一个区间不是黑盒化的。数组应已排序。

EN
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.
参数必填标记类型描述原文
scriptId✔️Runtime.ScriptId脚本的Id。
ENId of the script.
positions✔️array[ScriptPosition]

🔨Debugger.setBlackboxExecutionContexts🧪

将之前的黑盒执行上下文替换为传入的执行上下文。强制后端在这些执行上下文中跳过脚本的步进/暂停。虚拟机将尝试通过多次执行“步入”操作离开黑盒脚本,如果失败则最终采用“跳出”操作。

EN
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.
参数必填标记类型描述原文
uniqueIds✔️array[string]调试器应忽略的执行上下文唯一标识符数组。
ENArray of execution context unique ids for the debugger to ignore.

🔨Debugger.setBlackboxPatterns🧪

将之前的黑盒模式替换为传入的模式。强制后端跳过在与任一模式匹配的URL脚本中的单步执行/暂停。虚拟机将尝试通过多次执行“步入”操作离开黑盒脚本,若失败则最终采用“跳出”策略。

EN
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.
参数必填标记类型描述原文
patterns✔️array[string]用于检查脚本URL是否处于黑盒状态的正则表达式数组。
ENArray of regexps that will be used to check script url for blackbox state.
skipAnonymousboolean如果为真,同时忽略没有源URL的脚本。
ENIf true, also ignore scripts with no source url.

🔨Debugger.setBreakpointOnFunctionCall🧪

在每次调用给定函数之前设置 JavaScript 断点。如果另一个函数与给定函数源自同一源代码,调用该函数也会触发断点。

EN
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.
参数必填标记类型描述原文
objectId✔️Runtime.RemoteObjectId函数对象标识符。
ENFunction object id.
conditionstring用作断点条件的表达式。当指定时,如果此表达式的求值结果为真,调试器将在断点处停止。
ENExpression to use as a breakpoint condition. When specified, debugger will stop on the breakpoint if this expression evaluates to true.
返回对象类型描述原文
breakpointIdBreakpointId创建的断点ID,用于后续引用。
ENId of the created breakpoint for further reference.

🔨Debugger.setReturnValue🧪

在顶层帧中更改返回值。仅在返回断点位置可用。

EN
Changes return value in top frame. Available only at return break position.
参数必填标记类型描述原文
newValue✔️Runtime.CallArgument新的返回值。
ENNew return value.

🔨Debugger.pauseOnAsyncCall🧪❌️

参数必填标记类型描述原文
parentStackTraceId✔️Runtime.StackTraceId当带有指定堆栈跟踪的异步调用开始时,调试器将暂停。
ENDebugger will pause when async call with given stack trace is started.

✅️️ Events

👋Debugger.paused

当虚拟机在断点、异常或任何其他停止条件上停止时触发。

EN
Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.
参数必填标记类型描述原文
callFrames✔️array[CallFrame]虚拟机停止时所在的调用堆栈。
ENCall stack the virtual machine stopped on.
reason✔️string暂停原因。
允许的值:ambiguousassertCSPViolationdebugCommandDOMEventListenerexceptioninstrumentationOOMotherpromiseRejectionXHRstep
ENPause reason.
Allowed Values: ambiguous, assert, CSPViolation, debugCommand, DOM, EventListener, exception, instrumentation, OOM, other, promiseRejection, XHR, step
dataobject包含断点特定辅助属性的对象。
ENObject containing break-specific auxiliary properties.
hitBreakpointsarray[string]命中断点ID
ENHit breakpoints IDs
asyncStackTraceRuntime.StackTrace异步堆栈跟踪(如果有的话)。
ENAsync stack trace, if any.
asyncStackTraceId🧪Runtime.StackTraceId异步堆栈跟踪(如果有的话)。
ENAsync stack trace, if any.
asyncCallStackTraceId🧪Runtime.StackTraceId永不出现,将被移除。
ENNever present, will be removed.

👋Debugger.resumed

当虚拟机恢复执行时触发。

EN
Fired when the virtual machine resumed execution.

👋Debugger.scriptFailedToParse

当虚拟机无法解析脚本时触发。

EN
Fired when virtual machine fails to parse the script.
参数必填标记类型描述原文
scriptId✔️Runtime.ScriptId已解析脚本的标识符。
ENIdentifier of the script parsed.
url✔️stringURL或脚本解析的名称(如果有的话)。
ENURL or name of the script parsed (if any).
startLine✔️integer脚本在给定URL资源中的行偏移量(针对script标签)。
ENLine offset of the script within the resource with given URL (for script tags).
startColumn✔️integer给定URL资源中脚本的列偏移量。
ENColumn offset of the script within the resource with given URL.
endLine✔️integer脚本的最后一行。
ENLast line of the script.
endColumn✔️integer脚本最后一行的长度。
ENLength of the last line of the script.
executionContextId✔️Runtime.ExecutionContextId指定脚本创建上下文。
ENSpecifies script creation context.
hash✔️string脚本的内容哈希值,SHA-256。
ENContent hash of the script, SHA-256.
buildId✔️string对于 Wasm 模块,build_id 自定义节的内容。对于 JavaScript,debugId 魔法注释。
ENFor Wasm modules, the content of the build_id custom section. For JavaScript the debugId magic comment.
executionContextAuxDataobject嵌入器特定的辅助数据,可能匹配 {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}
ENEmbedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}
sourceMapURLstring与脚本关联的源映射的URL(如果有的话)。
ENURL of source map associated with script (if any).
hasSourceURLboolean是的,如果此脚本具有 sourceURL。
ENTrue, if this script has sourceURL.
isModuleboolean是的,如果此脚本是 ES6 模块。
ENTrue, if this script is ES6 module.
lengthinteger这个脚本长度。
ENThis script length.
stackTrace🧪Runtime.StackTraceJavaScript脚本解析事件触发时的顶层堆栈帧(如果可用)。
ENJavaScript top stack frame of where the script parsed event was triggered if available.
codeOffset🧪integer如果脚本语言是WebAssembly,模块中的代码段偏移量。
ENIf the scriptLanguage is WebAssembly, the code section offset in the module.
scriptLanguage🧪Debugger.ScriptLanguage脚本的语言。
ENThe language of the script.
embedderName🧪string嵌入器为此脚本提供的名称。
ENThe name the embedder supplied for this script.

👋Debugger.scriptParsed

当虚拟机解析脚本时触发。此事件也会在启用调试器时对所有已知和未收集的脚本触发。

EN
Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.
参数必填标记类型描述原文
scriptId✔️Runtime.ScriptId已解析脚本的标识符。
ENIdentifier of the script parsed.
url✔️stringURL或脚本解析的名称(如果有的话)。
ENURL or name of the script parsed (if any).
startLine✔️integer脚本在给定URL资源中的行偏移量(针对脚本标签)。
ENLine offset of the script within the resource with given URL (for script tags).
startColumn✔️integer脚本在给定URL资源中的列偏移量。
ENColumn offset of the script within the resource with given URL.
endLine✔️integer脚本的最后一行。
ENLast line of the script.
endColumn✔️integer脚本最后一行的长度。
ENLength of the last line of the script.
executionContextId✔️Runtime.ExecutionContextId指定脚本创建上下文。
ENSpecifies script creation context.
hash✔️string脚本的内容哈希值,SHA-256。
ENContent hash of the script, SHA-256.
buildId✔️string对于Wasm模块,build_id自定义部分的内容。对于JavaScript,debugId魔法注释。
ENFor Wasm modules, the content of the build_id custom section. For JavaScript the debugId magic comment.
executionContextAuxDataobject嵌入器特定的辅助数据,可能匹配 {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}
ENEmbedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}
isLiveEdit🧪boolean是的,如果此脚本是实时编辑操作的结果。
ENTrue, if this script is generated as a result of the live edit operation.
sourceMapURLstring与脚本关联的源映射的URL(如果有)。
ENURL of source map associated with script (if any).
hasSourceURLboolean是的,如果这个脚本有sourceURL。
ENTrue, if this script has sourceURL.
isModuleboolean是的,如果这个脚本是 ES6 模块。
ENTrue, if this script is ES6 module.
lengthinteger这个脚本长度。
ENThis script length.
stackTrace🧪Runtime.StackTraceJavaScript 脚本解析事件触发时的顶层堆栈帧(如果可用)。
ENJavaScript top stack frame of where the script parsed event was triggered if available.
codeOffset🧪integer如果脚本语言是WebAssembly,模块中代码段的偏移量。
ENIf the scriptLanguage is WebAssembly, the code section offset in the module.
scriptLanguage🧪Debugger.ScriptLanguage脚本的语言。
ENThe language of the script.
debugSymbols🧪array[Debugger.DebugSymbols]如果脚本语言是WebAssembly,模块的调试符号来源。
ENIf the scriptLanguage is WebAssembly, the source of debug symbols for the module.
embedderName🧪string嵌入者为该脚本提供的名称。
ENThe name the embedder supplied for this script.
resolvedBreakpoints🧪array[ResolvedBreakpoint]此脚本中设置的断点列表,如果对setBreakpointByUrl的调用匹配此脚本的URL或哈希值。使用此列表的客户端可以忽略breakpointResolved事件,它们是等效的。
ENThe list of set breakpoints in this script if calls to setBreakpointByUrl matches this script's URL or hash. Clients that use this list can ignore the breakpointResolved event. They are equivalent.

👋Debugger.breakpointResolved❌️

当断点被解析为实际的脚本和位置时触发。已弃用,建议使用 scriptParsed 事件中的 resolvedBreakpoints 替代。

EN
Fired when breakpoint is resolved to an actual script and location. Deprecated in favor of resolvedBreakpoints in the scriptParsed event.
参数必填标记类型描述原文
breakpointId✔️BreakpointId断点唯一标识符。
ENBreakpoint unique identifier.
location✔️Location实际断点位置。
ENActual breakpoint location.

✅️️ Types

📌Debugger.BreakLocation

返回类型:object

属性必填标记类型描述原文
scriptId✔️Runtime.ScriptIdDebugger.scriptParsed 中报告的脚本标识符。
ENScript identifier as reported in the Debugger.scriptParsed.
lineNumber✔️integer脚本中的行号(从0开始计数)。
ENLine number in the script (0-based).
columnNumberinteger脚本中的列号(从0开始计数)。
ENColumn number in the script (0-based).
typestring允许的值:debuggerStatementcallreturn
ENAllowed Values: debuggerStatement, call, return

📌Debugger.BreakpointId

断点标识符。

EN
Breakpoint identifier.

返回类型:string


📌Debugger.CallFrame

JavaScript 调用帧。调用帧数组构成调用栈。

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

返回类型:object

属性必填标记类型描述原文
callFrameId✔️CallFrameId调用帧标识符。此标识符仅在虚拟机暂停时有效。
ENCall frame identifier. This identifier is only valid while the virtual machine is paused.
functionName✔️string此调用帧上调用的JavaScript函数的名称。
ENName of the JavaScript function called on this call frame.
functionLocationLocation源代码中的位置。
ENLocation in the source code.
location✔️Location源代码中的位置。
ENLocation in the source code.
url✔️❌️stringJavaScript脚本名称或URL。已弃用,建议使用location.scriptId,通过先前发送的Debugger.scriptParsed事件来解析URL。
ENJavaScript script name or url. Deprecated in favor of using the location.scriptId to resolve the URL via a previously sent Debugger.scriptParsed event.
scopeChain✔️array[Scope]此调用帧的作用域链。
ENScope chain for this call frame.
this✔️Runtime.RemoteObjectthis 对象,对应此调用帧。
ENthis object for this call frame.
returnValueRuntime.RemoteObject如果函数处于返回点,则返回的值。
ENThe value being returned, if the function is at return point.
canBeRestarted🧪boolean仅在虚拟机暂停时有效,表示此帧是否可以重新启动。请注意,这里的 true 值并不能保证使用此 CallFrameId 调用 Debugger#restartFrame 一定会成功,但可能性很大。
ENValid only while the VM is paused and indicates whether this frame can be restarted or not. Note that a true value here does not guarantee that Debugger#restartFrame with this CallFrameId will be successful, but it is very likely.

📌Debugger.CallFrameId

调用帧标识符。

EN
Call frame identifier.

返回类型:string


📌Debugger.DebugSymbols

可用于 wasm 脚本的调试符号。

EN
Debug symbols available for a wasm script.

返回类型:object

属性必填标记类型描述原文
type✔️string调试符号的类型。
允许的值:SourceMapEmbeddedDWARFExternalDWARF
ENType of the debug symbols.
Allowed Values: SourceMap, EmbeddedDWARF, ExternalDWARF
externalURLstring外部符号源的URL。
ENURL of the external symbol source.

📌Debugger.Location

源代码中的位置。

EN
Location in the source code.

返回类型:object

属性必填标记类型描述原文
scriptId✔️Runtime.ScriptId脚本标识符,如 Debugger.scriptParsed 中报告的那样。
ENScript identifier as reported in the Debugger.scriptParsed.
lineNumber✔️integer脚本中的行号(从0开始计数)。
ENLine number in the script (0-based).
columnNumberinteger脚本中的列号(从0开始计数)。
ENColumn number in the script (0-based).

📌Debugger.ResolvedBreakpoint

返回类型:object

属性必填标记类型描述原文
breakpointId✔️BreakpointId断点唯一标识符。
ENBreakpoint unique identifier.
location✔️Location实际断点位置。
ENActual breakpoint location.

📌Debugger.Scope

作用域描述。

EN
Scope description.

返回类型:object

属性必填标记类型描述原文
type✔️string作用域类型。
允许的值:globallocalwithclosurecatchblockscriptevalmodulewasm-expression-stack
ENScope type.
Allowed Values: global, local, with, closure, catch, block, script, eval, module, wasm-expression-stack
object✔️Runtime.RemoteObject表示作用域的对象。对于globalwith作用域,它代表实际对象;对于其余作用域,它是一个人工临时对象,将作用域变量枚举为其属性。
ENObject 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.
namestring
startLocationLocation源代码中作用域开始的位置
ENLocation in the source code where scope starts
endLocationLocation源代码中作用域结束的位置
ENLocation in the source code where scope ends

📌Debugger.ScriptLanguage

可能的脚本语言枚举。
允许的值:JavaScriptWebAssembly

EN
Enum of possible script languages.
Allowed Values: JavaScript, WebAssembly

返回类型:string


📌Debugger.SearchMatch

搜索匹配资源。

EN
Search match for resource.

返回类型:object

属性必填标记类型描述原文
lineNumber✔️number资源内容中的行号。
ENLine number in resource content.
lineContent✔️string包含匹配内容的行。
ENLine with match content.

📌Debugger.LocationRange🧪

一个脚本内的位置范围。

EN
Location range within one script.

返回类型:object

属性必填标记类型描述原文
scriptId✔️Runtime.ScriptId
start✔️ScriptPosition
end✔️ScriptPosition

📌Debugger.ScriptPosition🧪

源代码中的位置。

EN
Location in the source code.

返回类型:object

属性必填标记类型描述原文
lineNumber✔️integer
columnNumber✔️integer

📌Debugger.WasmDisassemblyChunk🧪

返回类型:object

属性必填标记类型描述原文
lines✔️array[string]下一段反汇编行。
ENThe next chunk of disassembled lines.
bytecodeOffsets✔️array[integer]描述每行起始位置的字节码偏移量。
ENThe bytecode offsets describing the start of each line.