Breakpoint handlers

This article covers features introduced in SpiderMonkey 1.8.6

Note: Some or all of this exposition needs to move to the Guide.

When you set a breakpoint using the JavaScript Debugger API, you do so by specifying the offset at which the breakpoint should occur and a breakpoint handler object, whose hit() method is called when the breakpoint is reached. You should implement your breakpoint handler to perform whatever tasks you'd like to handle when a breakpoint occurs.

You can use a single breakpoint handler for multiple breakpoints, or have different handlers for different breakpoints. This lets you have the same (or different) behavior as you see fit, allowing the creation of multiple types of breakpoints.

You can set as many breakpoints as you like at a single location. When execution reaches that point, SpiderMonkey calls all of the breakpoint handlers, one after another. The order in which they get called is unspecified and must not be relied upon.

Calls to breakpoint handlers are cross-compartment, intra-thread calls.


These methods must be called with a this value referring to the Debugger.Frame instance.

Method Return value Description
hit() Resumption value Called when the breakpoint is reached, before executing the code at the offset at which the breakpoint was set.


Called when a breakpoint was reached, before executing the corresponding bytecode.

Note: This method must be in the debugger's compartment, and will be executed in that compartment. However, execution will occur in the same thread that hit the breakpoint.
A Debugger.Frame instance representing the currently executing stack frame. You can get all the information you need to handle the breakpoint from this object.
Return value

Return a resumption value indicating how execution of the script should proceed.

Document Tags and Contributors

Contributors to this page: Sheppy
Last updated by: Sheppy,