Search code examples
javascriptfirefoxfirefox-addonfirebugjavascript-engine

How to access JavaScript execution trace at runtime in Firefox?


I want to know how to access JavaScript execution trace at runtime. I saw Firebug can do something like this:

enter image description here

Refer to the image above, all the line numbers executed are highlighted in green. They are achieved at runtime. I guess there must be some way to access those info from the JavaScript engine used by the browser.

Say now I want to build a firebug plugin to access those info and examine all the variables in each executed line at the runtime, how should I start?


Solution

  • Obviously you asked the same question in the Firebug forum.

    To duplicate Honza's answer:

    Firebug is currently using JSD (jsdIDebuggerService) to figure out, which line is executable. However, the plan is to switch to JSD2 (work in progress) https://wiki.mozilla.org/Debugger

    You should also base your extension on JSD2

    Look for getLineOffsets(line) and getOffsetLine(offset) in the Debugger document. I didn't test it, but I think that if getLineOffset returns null, the line is not executable.

    Sebastian