Javascript:SpiderMonkey:Debugging

From MozillaWiki
Jump to: navigation, search

With the foundations now in place (the Debugger API and the debugging protocol), there are many specific areas of our JavaScript debugging support that need attention.

Debugging Protocol

There are two significant changes underway here:

  • We need protocol extensions for communicating with content and web application subprocesses on Firefox OS (Bug 797627).
  • The profiler needs to transmit large blocks of profile data across the remote protocol efficiently. Bug 797639 proposes a general mechanism that any sort of tool could use for payloads that don't work well using the simpler JSON-based protocol. (Draft spec.)

Column positions

When a single source line contains several statements, developers should be able to set breakpoints at the start of any statement on that line, not only at the start of the first. However, at present, the Debugger API distinguishes only between different lines of source code, not between statements within a single line. Internally, SpiderMonkey does retain the starting line and column of each statement; the Debugger API should be improved to use that finer-grained information.

Distinguishing statements at different columns within a line would also allow us to fully support source maps. JavaScript is often deployed in minimized form, with all unnecessary whitespace removed. While this may help the page load faster, it also complicates debugging, because the minimized source code is usually illegible. To help developers, a site can publish the original, un-minified code at a separate URL, along with a source map that relates positions in the minified code to the corresponding positions in the original code. When available, this metadata is enough to allow the JavaScript debugger to behave as if the original, legible code were being run, even as the minified code is actually what is running. However, since the minified code is usually a single (very long) line of source code, the ability to distinguish between statements on the same line is critical to making this work.

We've begun work on this in Bug 757188 (RESOLVED FIXED in Firefox 22).

Retained source code

For various reasons, SpiderMonkey usually retains a copy of all JavaScript code presented to the compiler. The Debugger.Source extension to the Debugger API, proposed in Bug 637572, would make that retained code available to Firefox's developer tools, allowing them to present the developer with source code for any JavaScript present in the browser, whether it appeared statically in a markup document or an external script, was passed to eval, or was attached to a dynamically inserted <script> element.