Engine - Attaching a Debugger

Jul 20, 2015 at 7:03 PM
I am interested in getting a debugger attached to the jurassic engine running in my Unity5 game. The jurassic/unity integration works fine, but I don't see any information on how to attach a debugger (like VS2013) to the javascript engine. My goal is to create my own code editor and debugger and use it along with the game.

I read this page: Jurassic Debugging which says to enable debugging, but nothing about how to attach a debugger and what the interface is to the debugger.

Can anyone provide some step-by-step guide to attaching a debugger to a jurassic engine process?
Jul 20, 2015 at 11:36 PM
  1. Enable debug support by setting scriptEngine.EnableDebugging = true;
  2. Debug your program from Visual Studio, either via "Start with Debugging" or "Attach to Process...". If using "Attach to Process..." make sure the Managed code type is selected.
  3. Stop the debugger, either using a breakpoint in the script file that you are running, or by modifying the JS source code to include a "debugger" statement.
Jul 21, 2015 at 2:40 PM
Paul - thanks for your reply. Still not able to get this to work with VS2013:

I've tried your steps above - attaching to my test executable JurassicTest.exe, build with Unity5 and MonoDevelop.
Here's what I did:
  1. start the test game (JurassicTest.exe)
  2. start visual studio 2013
  3. open the javascript source code file in VS2013 (in my case c:\test\nbScript.js)
  4. attach to process JurassicTest.exe using Managed Code option.
  5. set a breakpoint in the code.
when I try to set a breakpoint in the source in VS2013, I get this warning:

The breakpoint will not currently be hit. No symbols loaded for this document.

Normally I'd have some associated .pdb file for the debug symbols.
But since this is a script interpreted/compiled at run time, there doesn't seem to be a symbol file.

So what am I missing?
Aug 1, 2015 at 1:20 PM
Sorry for the slow response.

There's another couple of conditions that I failed to mention.
  1. When you execute script, you must supply a file path. This can be done by using ExecuteFile, or by using FileScriptSource, or by using StringScriptSource with the path parameter provided.
  2. The file path must correspond to a file containing the JavaScript source code. If you are generating script on the fly, or your script is encrypted, or is contained within another file, you must save the contents of the source code to a temporary file and pass Jurassic the path to that file.
This is required by the debugger, since the debugging symbols only contain a file path reference to the source code, not the source code itself. Note that a .pdb file is not necessary because the debugging symbols are generated in memory.
Aug 1, 2015 at 1:54 PM
Note that you also need to enable "Show External Code" by right-clicking on the stack trace window.

It seems that the method I am using to support debugging is not really supported. The official way to support debugging is to write a debug engine, which must be installed as a VSIX. I may attempt this if I find the time and inclination.