Step by step debugging

Aug 4, 2010 at 2:45 PM

Hi and congratulations for this great project!

I'm trying to integrate AvalonEdit component from SharpDevelop ( and Jint to obtain a simple javascript editor/evaluator as a component for the application I'm working at currently, and I was asked to try and develop some sort of debugging feature "a la" firebug.

Reading the documentation I couldn't be able to understand how to obtain a steb by step execution, as the step event is launched for every statement, but  all together, when I call my jEngine.Run(script);

Should I add a breakpoint each time the anonymous delegate manages the step event?

Something similar to:

jEngine.Step += (stepSender, info) =>
    jEngine.BreakPoints.Add(new BreakPoint(info.CurrentStatement.Source.Start.Line+1, 0));

Any advice is welcome! Thank you in advance.

ps: has anybody done something similar, used Jint in an editor with debugging feature?

Aug 19, 2010 at 6:26 AM
Hi, Thanks. You do not need to add a breakpoint at each step event. the step event is called on each line of code. I think what you would need to do would be to develop your own debugger. and use the Debugger.Break() .NET method, when your debugger is attached. Unfortunately, I have no idea on how to develop such a debugger. Another simple way would be to have a AutoResetEvent that you would unlock/set from your debugger. In other words, what you need to do is prevent the execution of the script within your step event handler until you decide to continue (this is actually the definition of the step by step debugging).
Aug 19, 2010 at 7:41 AM

Thank you very very much for your reply, actually I am nearly using your second solution, using WaitAny with something like:

ManualResetEvent[] evtSet = new ManualResetEvent[] { stepEvt, runEvt, stopDbgEvt };

in the break event handler (I'm still adding a "stepByStep Breakpoint" but as you are saying I think I can get rid of it).

Now I'm working on WatchList management and I have some trouble, but this is another discussion thread, if I can't manage to go on I'll post a new thread. Thank you again.