Script Panel Refactoring

From FirebugWiki

(Difference between revisions)
Jump to: navigation, search
(Script Panel Architecture)
(Debugger)
Line 83: Line 83:
This object is derived from <code>Firebug.Module</code> and represents Firebug's debugger. It's also registered as a debugger into ''Firebug Service'' (FBS). This object should be the only one accessing FBS. It calls FBS API and receives various callbacks and events.
This object is derived from <code>Firebug.Module</code> and represents Firebug's debugger. It's also registered as a debugger into ''Firebug Service'' (FBS). This object should be the only one accessing FBS. It calls FBS API and receives various callbacks and events.
-
This object implements methods that can be used by the Script panel or other parts of Firebug (e.g. by those panels which implements BON). A few examples of the API:
+
This object implements methods that can be used by the Script panel or other parts of Firebug (e.g. by those panels which implements BON).
 +
 
 +
Some examples of the API:
* ''evaluate'', ''evaluateInCallingFrame''
* ''evaluate'', ''evaluateInCallingFrame''
* ''breakNow'', ''getCurrentStackTrace''
* ''breakNow'', ''getCurrentStackTrace''
Line 92: Line 94:
* ''monitorScript'', ''unmonitorScript''
* ''monitorScript'', ''unmonitorScript''
* ''activateDebugger'', ''deactivateDebugger''
* ''activateDebugger'', ''deactivateDebugger''
 +
 +
Implementation of these methods is based on FBS API.
 +
There is also <code>Firebug.DebuggerListener</code> that defines the interface used by FBS  
There is also <code>Firebug.DebuggerListener</code> that defines the interface used by FBS  
* ''onStop'', ''onResume'', ''onThrow'', ''onError'', ''onScriptCreated'' (there is more ''onScriptCreated'' events)
* ''onStop'', ''onResume'', ''onThrow'', ''onError'', ''onScriptCreated'' (there is more ''onScriptCreated'' events)
 +
This object is ''observable'' and it activates the underlying JSD only if an observer exists. The observer is currently the Script panel even if it would make a bit more sense if it's actually the ''JavaScriptTool''.
This object is ''observable'' and it activates the underlying JSD only if an observer exists. The observer is currently the Script panel even if it would make a bit more sense if it's actually the ''JavaScriptTool''.

Revision as of 12:52, 22 August 2012

This page summarizes refactoring the Firebug debugger to use JSD2 and adding support for remote JavaScript debugging. Issue 5421 tracks the actual changes done.

Contents

Resources

Firebug Wiki:

Mozilla Wiki:

Goals

  • Adopt JSD2 (get rid of all JSD1 APIs)
  • Support remote debugging

Related Issues

JSD2 API Requirements

The following list summarizes the high-level features that Firebug needs to support. It should be verified that all the features can re-implemented on top of JSD2 before starting the refactoring.

Not Ready in JSD2

  • There is not source for evals.
  • new Function scripts?
  • Meta bug: Implement a script Debugger
    • As soon as this one is fixed
    • Profiling is unrelated to JSD2. What is the plan here?
    • Tracking (break on) throw/catch/error; also what is the plan?
  • Conditional breakpoints (bug 740825)

Script Panel Architecture

The Script panel needs to be built on top of JSD2, remote protocol and Firebug remote architecture. Remoting is already supported by HTTP Monitor and both components should share the same approaches and API.

TBD

Current Debugger Architecture

This section describes the current debugger architecture.

Current-debugger-architecture.png

There are several layers/objects so, lets describe them step by step starting from the bottom.

JSD1

This layer represents JSD1 platform API. These API allows to implement script debuggers and represent direct competition to JSD2 API. Of course this layer should entirely disappear and should be replaced by JSD2.

Firebug Service

Firebug service is implemented as js module on top of JSD1 layer. The object is called FBS and it's purpose is to wrap JSD1 API so, they are not directly accessed anywhere else. This layer also maintain list of registered debuggers (usually Firebug.Debugger module) and fires various events to them (e.g. onToggleBreakpoint, onToggleMonitor, etc.) or execute theirs callback (e.g. onBreak, onFunctionCall, onError, onThrow, onScriptCreated, etc.)

Main responsibilities:

  • Activate/deactivate JSD in the browser. The activation is global for all current browser windows.
  • Hook debugger events (interrupts, break on a breakpoint, etc.)
  • Maintains list of registered debuggers (there is usually just one - Firebug debugger) and sends events to them.
  • Manages nested event loop that is created for the debugger UI when page JS execution breaks.
  • Sets/removes/enables/disables/saves/loads breakpoints
  • Implements debugger stepping over/in/out/runUntil
  • Monitors function calls
  • Starts/stops profiling
  • Tracks exceptions and errors (not working well)
  • Tracks compiled scripts (not all of them)

Debugger

This object is derived from Firebug.Module and represents Firebug's debugger. It's also registered as a debugger into Firebug Service (FBS). This object should be the only one accessing FBS. It calls FBS API and receives various callbacks and events.

This object implements methods that can be used by the Script panel or other parts of Firebug (e.g. by those panels which implements BON).

Some examples of the API:

  • evaluate, evaluateInCallingFrame
  • breakNow, getCurrentStackTrace
  • rerun
  • stepOver, stepInto, stepOut, runUntil, resume
  • setBreakpoint, clearBrakpoint, etc.
  • monitorFunction, unmonitorFunction
  • monitorScript, unmonitorScript
  • activateDebugger, deactivateDebugger

Implementation of these methods is based on FBS API.


There is also Firebug.DebuggerListener that defines the interface used by FBS

  • onStop, onResume, onThrow, onError, onScriptCreated (there is more onScriptCreated events)


This object is observable and it activates the underlying JSD only if an observer exists. The observer is currently the Script panel even if it would make a bit more sense if it's actually the JavaScriptTool.

JavaScriptTool

ScriptPanel

Personal tools