Search code examples
firebugfirefox-addon-sdknpapispidermonkey

Freezing and resuming execution using SpiderMonkey debug API


I want to implement my own GWT plugin for Firefox, and I have one problem. Consider, we have a function that causes program to suspend until remote debugger, running on IDE, says "ok, you can continue". AFAIK, this was possible with old NPAPI, at least the old plugin used NPAPI. I guess that is was capable of doing synchronous socket I/O. Now NPAPI is deprecated, and GWT plugin does not work. As an alternative I found JS Debugger API and I hope it could help. Unfortunately, documentation is very poor. I tried to learn Firebug, since I suppose that it uses debug API, but I failed to understand anything. What I really need is to freeze execution when it reaches some function call and signal somewhere. Then I need to signal back to Firefox to resume execution. Does debugger API allows to do it? If it does, where can I find code snippets for the described goal?


Solution

  • Firebug, even in 2.0, mostly doesn't use the Debugger API directly, instead it communicates using the Remote Debugging Protocol (RDP), which definitely sounds like it could be a good option for you.

    If you want to do things more manually, take a look at the implementation of the RDP backend. In particular, pausing/resuming execution (which there is no explicit support for in the Debugger API) is done through nested event loops.