Yes, using the Debugger interface directly requires wrapping your brain
around what it means to have your code and debugger code running on the
same stack. Hitting a `debugger;` statement or a breakpoint means
invoking the debugger script as if the application code called it.
Resuming execution means returning from the debugger code.
There is an example debugger that works with the JS shell in the Gecko
repository at `js/examples/jorendb.js`. As the comment at the top says:
/*
* jorendb is a simple command-line debugger for shell-js programs. It is
* intended as a demo of the Debugger object (as there are no shell js
programs
* to speak of).
*
* To run it: $JS -d path/to/this/file/jorendb.js
* To run some JS code under it, try:
* (jorendb) print load("my-script-to-debug.js")
* Execution will stop at debugger statements and you'll get a jorendb
prompt.
*/
It is bare-bones, and as nbp said it was written before Promises and
associated async/await syntax existed. It still works, more or less, but
it's not a supported or maintained tool. (It has precisely one user --
me -- who attempts to use it for anything "real".) The author, Jason
Orendorff (hence the name), only wrote it as a demonstration and does
not use it. It doesn't support breakpoints -- or rather, it doesn't
support *setting* breakpoints because the APIs for enumerating available
scripts in which to set breakpoints were problematic for a long time and
changed a bunch.
That said, if you want to decipher how one would write an in-process
debugger with the Debugger API, it should provide a good example.