Changes between Initial Version and Version 1 of JavascriptDebugging


Ignore:
Timestamp:
Jan 14, 2013, 8:40:52 PM (11 years ago)
Author:
Yves
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • JavascriptDebugging

    v1 v1  
     1== Introduction ==
     2A large part of the game like components, GUI scripts or the AI are written in Javascript. If you have programmed C++ or used Javascript for Websites you probably know how important a good Debugger can be and how much it helps to find Bugs or learn how a Part of code works.
     3The web based Tools like Firebug can't be used for 0 A.D. because the debugger has to be very closely connected to the Javascript runtime. However, there's a dedicated tool for 0 A.D. and the Pyrogenesis engine being developed at the moment that should hopefully be ready to use soon.
     4
     5== Technical background ==
     6The DebuggingServer component makes debugging commands like (ToggleBreakpoint, Step, Continue etc...) available using a mongoose webserver.
     7The format used for return values is JSON, which should be easy to parse from a Web-GUI.
     8 
     9The Debugger uses the JSDBGAPI provided by Spidermonkey 1.8.5. Newer versions of Spidermonkey provide a simplified new API (along with memory leak fixes, performance improvements and more), but unfortunately Mozilla isn't interested in doing the work and publishing a independent build from Firefox at the moment.
     10We had a [http://irclogs.wildfiregames.com/2013-01-02-QuakeNet-%230ad-dev.log discussion about that on IRC].
     11
     12The JSDBGAPI isn't thread-safe and also our current implementation of ScriptInterfaces (which are basically abstractions of Spidermonkey) isn't thread-safe either.
     13As a general rule, all Javascript objects are tied to one ScriptInterface which represents one Javascript runtime and one Javascript context and can only be used in one thread. We do use multiple threads, but each of them only uses one ScriptInterface.
     14On major difficulty about implementing a debugger is not to violate these constraints.
     15
     16The idea is that there's one CThreadDebugger class which is responsible for tracking hooks, callbacks, breakpoints and general state information for each of those ScriptInterfaces. The class CDebuggingServer manages multiple threads using multiple objects of CThreadDebugger.
     17It passes commands from the mongoose webserver (triggered by the user) to the CThreadDebugger objects and retrieves state information from these objects and returns it to the user as JSON. The DebuggingServer makes sure not to access any Spidermonkey functions or Javascript objects directly (because they belong to the ScriptInterface's thread).
     18The DebuggingServer itself should also be thread-safe to accept multiple request asynchronously.
     19
     20
     21== Available commands ==
     22This section lists all currently implemented commands and gives some examples of data they return.
     23
     24=== Toggling (setting/removing) breakpoints: ===
     25{{{
     26http://127.0.0.1:9000/ToggleBreakpoint?filename=gui/gamesetup/gamesetup.js&line=1481
     27}}}
     28
     29Nothing returned
     30
     31{{{
     32#!js
     33
     34}}}
     35