JsBreakpointDebugger Class
A debugger that pauses the scripts at breakpoints, at the debugger statements and on request, and steps through their statements. Set it in JsEngineOptions.Debugger before the code is compiled.
public class JsBreakpointDebugger : JsDebuggerRemarks
When the script pauses, JsBreakpointDebugger.OnPaused (or the callback given to the constructor) is called on the thread of the engine. The script waits until it returns: it can read the scopes, the call stack and evaluate code at the statement (JsDebugPause.Event), then return how the script resumes. To stop the script, throw a JsTerminationException.
The breakpoints can be added, removed, enabled and disabled from any thread, including while a script runs.
A step is based on the call depth of the statements: a step that leaves the code being run (e.g. the end of a script, or an await) pauses at the next statement that runs, such as the statement of a promise job.
- Inheritance
JsDebuggerJsBreakpointDebugger
Constructors
| Name | Description |
|---|---|
| JsBreakpointDebugger() | Initializes a new instance of the JsBreakpointDebugger class, for a class that overrides JsBreakpointDebugger.OnPaused. |
| JsBreakpointDebugger(Func<JsDebugPause, JsStepAction>) | Initializes a new instance of the JsBreakpointDebugger class. |
JsBreakpointDebugger overloads
JsBreakpointDebugger()
JsBreakpointDebugger.csInitializes a new instance of the JsBreakpointDebugger class, for a class that overrides JsBreakpointDebugger.OnPaused.
protected JsBreakpointDebugger()JsBreakpointDebugger(Func<JsDebugPause, JsStepAction>)
JsBreakpointDebugger.csInitializes a new instance of the JsBreakpointDebugger class.
public JsBreakpointDebugger(Func<JsDebugPause, JsStepAction> onPaused)Parameters
onPausedFunc<JsDebugPause, JsStepAction>- Called when a script pauses. It returns how the script resumes.
Properties
| Name | Description |
|---|---|
| Breakpoints | Gets the breakpoints, in the order they were added. |
| PauseOnDebuggerStatements | Gets or sets whether the debugger statements pause the scripts. The default is true. |
Breakpoints
JsBreakpointDebugger.csGets the breakpoints, in the order they were added.
public IReadOnlyList<JsBreakpoint> Breakpoints { get; }Property value
PauseOnDebuggerStatements
JsBreakpointDebugger.csMethods
| Name | Description |
|---|---|
| AddBreakpoint(string?, int, int?, string?) | Adds a breakpoint. |
| ClearBreakpoints() | Removes all the breakpoints. |
| OnDebuggerStatement(JsDebugEvent) | Called when a debugger statement runs. |
| OnPaused(JsDebugPause) | Called when a script pauses, on the thread of the engine. The script waits until it returns. |
| OnStatement(JsDebugEvent) | Called before a statement runs. |
| RemoveBreakpoint(JsBreakpoint) | Removes a breakpoint. |
| RequestPause() | Pauses the script at the next statement that runs. It can be called from any thread. |
AddBreakpoint(string?, int, int?, string?)
JsBreakpointDebugger.csAdds a breakpoint.
public JsBreakpoint AddBreakpoint(string? url, int line, int? column = null, string? condition = null)Parameters
urlstring?- The URL of the code (the name given to the script, the module, or the
//# sourceURL=comment of eval code). lineint- The line, 1-based.
columnint?- The column of the statement, 1-based in UTF-16 code units, or null to pause at each statement that starts on the line.
conditionstring?- The code evaluated at the statement: the script pauses when its value is truthy. Null to always pause.
Returns
JsBreakpoint The breakpoint.
Exceptions
ArgumentOutOfRangeExceptionlineorcolumnis less than 1.
ClearBreakpoints()
JsBreakpointDebugger.csRemoves all the breakpoints.
public void ClearBreakpoints()OnDebuggerStatement(JsDebugEvent)
JsBreakpointDebugger.csCalled when a debugger statement runs.
protected internal override void OnDebuggerStatement(JsDebugEvent debugEvent)Parameters
debugEventJsDebugEvent- The statement. It is valid until the method returns.
OnPaused(JsDebugPause)
JsBreakpointDebugger.csCalled when a script pauses, on the thread of the engine. The script waits until it returns.
protected virtual JsStepAction OnPaused(JsDebugPause pause)Parameters
pauseJsDebugPause- The statement where the script is paused, and why. It is valid until the method returns.
Returns
JsStepAction How the script resumes.
OnStatement(JsDebugEvent)
JsBreakpointDebugger.csCalled before a statement runs.
protected internal override void OnStatement(JsDebugEvent debugEvent)Parameters
debugEventJsDebugEvent- The statement. It is valid until the method returns.
RemoveBreakpoint(JsBreakpoint)
JsBreakpointDebugger.csRemoves a breakpoint.
public bool RemoveBreakpoint(JsBreakpoint breakpoint)Parameters
breakpointJsBreakpoint- The breakpoint.
Returns
bool True when the breakpoint was removed; false when it is not a breakpoint of the debugger.
RequestPause()
JsBreakpointDebugger.csPauses the script at the next statement that runs. It can be called from any thread.
public void RequestPause()