Profile Picture

Debugging a strategy

Posted By Atul H 8 Years Ago
Message
Posted Thursday February 19 2009
RE does not have debugging built-in, but .Net library power and RE's open model enables you to debug anyways.

Here is a workaround for debugging your strategy code using Visual Studio if you have it installed:  Simply add a line and call the debugger through .Net library.

System.Diagnostics.Debugger.Break();

Posted Thursday February 19 2009
Also, with Visual Studio (not express editions) you do have full blown debugging within a strategy.  If you haven't found the posts that outline this, let me know and I'll be happy to dig them up.
phg
Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)
Posted Tuesday February 24 2009
I can't get this to work:

#define DEBUG

using System.Diagnostics;

public class MySystem : MySystemBase

public override void Startup()

System.Diagnostics.Debugger.Launch; <- Won't compile. (.BREAK doesn't compile either)

I'm not doing something I should????

 

-Pete

See also Yahoo group about applying RE.

Posted Tuesday February 24 2009
Launch is a method, so System.Diagnostics.Debugger.Launch();

phg (2/24/2009)
I can't get this to work:

#define DEBUG

using System.Diagnostics;

public class MySystem : MySystemBase

public override void Startup()

System.Diagnostics.Debugger.Launch; <- Won't compile. (.BREAK doesn't compile either)

I'm not doing something I should????

 

phg
Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)
Posted Wednesday February 25 2009
Duh. Of course. Thanks. This causes a break and allows the locals to be reviewed:
System.Diagnostics.Debugger.Break();

But if you click "Stop Debugging" it encounters an unhandled exception and enters a loop of creating debuggers. Is there a way around that?

Thanks for your help.



-Pete

See also Yahoo group about applying RE.

Posted Wednesday February 25 2009
I'm not sure, since I'm not real familiar with this method, but maybe someone else knows how to make this work properly.
phg
Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)
Posted Wednesday February 25 2009
I solved it this way:
if(dbg==true) System.Diagnostics.Debugger.Break();

dbg is declared a gobal (public) variable. Set to true to cause the debugger to be invoked. When you want debugging to stop, use the Immediate window to set dbg=false. Then hit 'continue' debugging. (I haven't tried 'stop debugging' before a simulation completes yet.)

This is by far the easiest way I have seen yet to invoke the debugger so you can check on some local variables. It works like a charm.



-Pete

See also Yahoo group about applying RE.

Posted Wednesday February 25 2009
If you have a few spare moments and wouldn't mind, could you throw together some step-by-step on debugging strategies on RightEdge using Visual Studio Express versions?  It's something I'd like to pin in the forums and also add to our FAQs.  If you don't have the time (understandable), can I give you a quick interview so that I may write it up myself?

Thanks.

phg
Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)Supreme Being (48,655 reputation)
Posted Thursday February 26 2009
Bill, this does not involve the Express editions at all. It is all done right within RE!!
- Right click the project. Under properties check "Generate Debug Info" (from Daniel's post).
- At the top of your strategy (first line) include '#define DEBUG'. (I don't know whether the 'Generate' is still needed??)
- Set 'using System.Diagnostics'
- In MySymbolScript put 'public bool dbg=true;' Set this to 'false' to not invoke the debugger.
Where ever you want the debugger invoked put this: (There can be more than one instance.) (This starts the debugger if it is not already running.)
if(dbg==true) System.Diagnostics.Debugger.Break();

You may be given a choice of debuggers; pick 2005. BEFORE stopping the debugger use the Immediate window to set dbg=false. Hit "Continue". (After that you may be able to click "Stop debugging" and close the debugger; I just always leave it alone.) Also consider 'Debugger.Log()' and 'Debugger.Launch()'.

Nifty.

[I should have added that the Debugger is part of the .NET Framework, which is why neither an Express VS nor the SDK are needed.]



-Pete

See also Yahoo group about applying RE.


Edited: Wednesday March 11 2009 by phg
Posted Tuesday March 10 2009
Hello,

i've got it to work, at least at home where i have visual studio installed. At work with the express edition i get a message, that RightEdge is stopped, but i don't get the choice to select a debugger as i get at home. Instead i can only select "Close" and this ends up in a endless loop. Can i anywhere define the debugger?

Edited: Tuesday March 10 2009 by Tradix


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems