17

I've been searching around the internet - and StackOverflow - for some recommendations on some lightweight .NET debuggers, but so far I haven't had a lot of luck. Some articles/posts are either pretty dated, or otherwise don't exactly suit me needs.

What I'm specifically looking for is a very light-weight .NET debugger that I can wrap into my application, where I can create a "Debug mode" for administrators/developers. Because this application is very specific to the data, and environment it runs in, and features some scripting as well, it would be really useful to allow users the ability to debug their scripts, and in some cases the underlying engine.

In short, the requirements are:

  1. Lightweight,
  2. Allows users to set up custom breakpoints,
  3. And finally, allows users to step-through code

I could use the standard Visual Studio debugger, and use Debugger.Break(), but ultimately, this fails requirement number 1 of it being lightweight - I need something I can wrap into my application.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
AlishahNovin
  • 1,904
  • 3
  • 20
  • 37
  • I think using the standard VS debugger in your application fails test #4: You can't distribute MS's property. – NotMe Aug 30 '11 at 15:33
  • Stack Overflow _isn't_ the internet?!? On another note, one of the requirements of the debugger should be that it can handle your (as yet undefined) scripting language, right? – Grant Thomas Aug 30 '11 at 15:35
  • 1
    The setup of SharpDevelop is 16Mb: does this help? – Jeremy McGee Aug 30 '11 at 15:44
  • @Chris Lively : You're right about that too - the VS Debugger was never truly considered, I supplied it as an example, because it best illustrates my needs. – AlishahNovin Aug 30 '11 at 15:47
  • @Mr. Disappointment : Well, the scripting language is in C# - it's more procedure based, but the script would tie in to the data, which is the main motivation for debugging (i.e. I can't predict the script, Users can't predict the data, so debugging would help both myself and the Users...). Also, by allowing the debugger to step into the underlying engine, it would allow me to trouble-shoot rarer cases. – AlishahNovin Aug 30 '11 at 15:47
  • @Jeremy I may try it out. I had been reading an article on CodeProject about using SharpDevelop within your own application (http://www.codeproject.com/KB/cs/ICSharpCodeCore.aspx) and it may help me out with some other aspects too. Though, I think that would be undertaking a much larger task than what I'm hoping for. – AlishahNovin Aug 30 '11 at 15:57
  • 3
    This is not possible, a fundamental limitation in Windows. A program cannot debug itself. Intuitively obvious: a breakpoint suspends the debugger as well. You'll need to use an external debugger that runs in another process. – Hans Passant Aug 30 '11 at 19:26
  • 1
    @Hans - it depends on what you mean by "program." If your program consists of a number of wrapped executables (i.e. a program comprised of programs), it is possible. – AlishahNovin Aug 31 '11 at 13:42

3 Answers3

6

The CLR Managed Debugger (mdbg) Sample should get you started.

Eric Farr
  • 2,683
  • 21
  • 30
  • The link ist dead for me. Redirects to https://www.microsoft.com/library/errorpages/smarterror.aspx – Uwe Keim Aug 26 '16 at 08:53
2

What about using the CSharpCodeProvider class? This will at least provide compiling, and I believe will provide debugging info. Although I'm not sure of the detail. Maybe between the CLR mdbg as @Eric recommends and the CodeProvider, you will get what you want.

You should be able to compile stand-alone scripts and debug. Although, it would be impossible to debug the application itself, while it is running - a point I certainly missed while @Hans is sharp enough to point out in his comment.

IAbstract
  • 19,551
  • 15
  • 98
  • 146
0

.NET Framework 2.0 Software Development Kit contains what you want