3

I am looking for a JavaScript JavaScript debugger.

The situation is as follows: I am making a JS game engine. The AI scripts as well as various other actions are implemented in JS. It is possible, from the engine's developer mode, to edit this code from the browser itself (using Ace).

Now I want to add debugging capabilities. Mostly I am looking for breakpoints with step into/step over support.

I couldn't find any such library. The best I could find is the outdated debug-js project.

Note that this debugger is intended for developers who are building games using my engine. This happens from inside the browser. The engine is in JS. The debugger should be in JS as well. I want full control over these debugging features, so I can't just use the browser's debugger.

For example if you type the ID of a character in an AI script, I highlight this character. This is the kind of things I can't provide if I edit the scripts in the browser's debugger, but that I can do from Ace running in the page.

MasterScrat
  • 7,090
  • 14
  • 48
  • 80
  • What are you using to run this game? Node, IO, a browser, Rhino, Nashorn? – ssube Feb 20 '15 at 15:34
  • Good point: it runs in modern browsers. – MasterScrat Feb 20 '15 at 15:34
  • 4
    Chrome has a built-in JS debugger - press `F12` and go to `Sources` to access it – Gillespie Feb 20 '15 at 15:35
  • http://stackoverflow.com/questions/5067532/editing-in-the-chrome-debugger This might help – Jared Teng Feb 20 '15 at 15:36
  • @RPGillespie I am well aware of that, but I don't have any control over the browser's debugger. For example it wouldn't make sense to end up in the game engine's code while debugging a character's AI. – MasterScrat Feb 20 '15 at 15:36
  • 2
    Couldn't you just put breakpoints in the relevant AI code? Also, you can edit scripts in Chrome (at least, I can in v40) – Gillespie Feb 20 '15 at 15:37
  • @RPGillespie yes but then I don't have control over the editor anymore. I want this debugger to be part of my game engine development tools, if I use the native debugger I lose a lot of control. – MasterScrat Feb 20 '15 at 15:39
  • 1
    I agree with @RPGillespie > you're talking about control of the editor, but not on the whole. If your engine is a blackbox (in this case) won't you limit the control the developer has? Why would you want to control what the debugger can (or cannot) see? A debugger is a debugger . your code or not – Leon Feb 20 '15 at 15:47
  • 1
    You might ask the creators of [js.js](https://github.com/jterrace/js.js/) if there's any way to enable debug support, perhaps. – apsillers Feb 20 '15 at 15:48
  • @Leon yes you got it right! well I need to limit the debugger's scope for the same reason Chrome's debugger doesn't let you inspect native code... You aren't supposed to change it, so why bother? – MasterScrat Feb 20 '15 at 15:51
  • "For example if you type the ID of a character I am currently highlighting it." Correct me if I'm wrong, but that would require your character to be a global variable, otherwise it will likely get garbage collected when the scope closes. Even if you stop execution inside the scope, highlighting a character would require a `highlight(_id)` function as the language doesn't know what highlighting means natively. – Matt K Feb 20 '15 at 15:53
  • If you use the [debugger extension](https://developer.chrome.com/devtools/docs/debugger-protocol#extension) you have greater control over Chrome's debugger. However, this is more for Chrome plugins (since Firefox wouldn't be able to use it). – Gillespie Feb 20 '15 at 16:07

1 Answers1

2

Esprima looks like an interesting starting point. It makes it possible to instrument JavaScript code. This JavaScript execution visualization looks particularly promising.

MasterScrat
  • 7,090
  • 14
  • 48
  • 80