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. | |
| targetCallFrames | string | 允许的值:any、current | 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. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| debuggerId | Runtime.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. | |
| objectGroup | string | 将结果放入的字符串对象组名称(允许使用releaseObjectGroup快速释放结果对象句柄)。 | ENString object group name to put result into (allows rapid releasing resulting object handles usingreleaseObjectGroup). | ||
| includeCommandLineAPI | boolean | 指定命令行API是否应对被评估的表达式可用,默认为false。 | ENSpecifies whether command line API should be available to the evaluated expression, defaults to false. | ||
| silent | boolean | 在静默模式下,评估期间抛出的异常不会被报告,也不会暂停执行。这会 覆盖 setPauseOnException 状态。 | ENIn silent mode exceptions thrown during evaluation are not reported and do not pause execution. OverridessetPauseOnException state. | ||
| returnByValue | boolean | 结果是否预期为一个应通过值传递的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. | |
| throwOnSideEffect | boolean | 是否在评估过程中无法排除副作用时抛出异常。 | 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). |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| result | Runtime.RemoteObject | 评估结果的 对象包装器。 | ENObject wrapper for the evaluation result. |
| exceptionDetails | Runtime.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. | |
| end | Location | 在脚本中搜索可能的断点位置的范围结束位置(不包含)。当未指定时,脚本的结尾将作为范围的结束。 | ENEnd of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range. | ||
| restrictToFunction | boolean | 仅考虑与起始点位于同一(非嵌套)函数内的位置。 | ENOnly consider locations which are in the same (non-nested) function as start. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| locations | array[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. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| scriptSource | string | 脚本源(在Wasm字节码情况下为空)。 | ENScript source (empty in case of Wasm bytecode). |
| bytecode | string | Wasm字节码。(通过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
To stay back-wards compatible,
The various return values are deprecated and
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 | 🧪 | string | mode 参数必须存在且设置为 'StepInto',否则 restartFrame 将出错。允许的值: StepInto | ENThemode parameter must be present and set to 'StepInto', otherwise restartFrame will error out.Allowed Values: StepInto |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| callFrames | array[CallFrame] | 新堆栈跟踪。 | ENNew stack trace. |
| asyncStackTrace | Runtime.StackTrace | 异步堆栈跟踪(如果有的话)。 | ENAsync stack trace, if any. |
| asyncStackTraceId | Runtime.StackTraceId | 异步堆栈跟踪(如果有的话)。 | ENAsync stack trace, if any. |
🔨Debugger.resume
恢复 JavaScript 执行。
EN
Resumes JavaScript execution.
| 参数 | 必填 | 标记 | 类型 | 描述 | 原文 |
|---|---|---|---|---|---|
| terminateOnResume | boolean | 设置为 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. | |
| caseSensitive | boolean | 如果为真,则搜索区分大小写。 | ENIf true, search is case sensitive. | ||
| isRegex | boolean | 如果为真,将字符串参数视为正则表达式。 | ENIf true, treats string parameter as regex. |
| 返回对象 | 类型 | 描述 | 原文 |
|---|---|---|---|
| result | array[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 to0 will effectively disable collecting async call stacks (default). |
🔨Debugger.setBreakpoint
在指定位置设置JavaScript断点。
EN
Sets JavaScript breakpoint at a given location.
| 参数 |
|---|