I´ve created a visual debugger for Jint that allows to run a bunch of script files, set breakpoints in each as well as do step by step debugging through them all.
I would need to find out in which scriptFile (all running in the same instance/context) the debugger is stepping through (or where a break point lands).
Here is what I´m doing (simplified the code to make it, hopefully, clearer):
// init the engine
JintEngine jEngine = new JintEngine();
// Loops over all the script files in the list. Made separate calls here for illustrative purpose
// At the debug step...
public static void DebugStep(object sender, Jint.Debugger.DebugInformation info)
int scriptFile=info.CurrentStatement.Source.Script; // something like this would be good... replacing int with some pointer to the instance or so..
scriptFile1 contains a function:
return x * x;
scriptFile2 calls this function.
var four=square(2); // will call function in scriptFile1
So the problem is that if I´m visually debugging and step through it, I will get into scriptFile2, when it then calls the function square, I do not get information to find out which file to show.
It will just give me information on the line number and source code line, not which of the script files it jumped to.
A possible hack would be to search all script files for the line number and source line and show this one, but that would be slow. Another choice is to pre-parse for all function calls and use the call stack in combination with the first idea. Still, I´m
sure both these solutions will cause problems in many other scenarios that I´ve not even thought of yet :)
I guess Jint internally might already have this information easily accessible that could be provided with the "Jint.Debugger.DebugInformation info" parameter on step or breakpoint events.
Is this something that could be quickly added? Or is there some other way of getting this information that I might have missed?
Thanks in advance!