Lightweight .NET debugger? [closed]
Asked Answered
C

8

28

I frequently need to debug .NET binaries on test machines (by test-machine, I mean that the machine doesn't have Visual Studio installed on it, it's frequently re-imaged, It's not the same machine that I do my development on, etc).

I love the Visual Studio debugger, but it's not practical for me to install visual studios on a freshly imaged test-machine just to debug an assertion or crash (the install takes way too long, the footprint is too large, etc).

I'd really like a quickly installed program that could break into a running process, let me specify the location of symbols/source code, and let me jump right into debugging. For native binaries, windbg works great, but I haven't found anything similiar for managed binaries. Any recommendations?

(as a side note, I am aware of visual studios remote debugging capabilities, but for some reason it never seems to work consistently for me... I often have connection issues)

Coverlet answered 2/10, 2008 at 17:47 Comment(0)
C
6

I've finally found extensions for Windbg that do just what I wanted: Sosex.dll, lets me use windbg to debug managed applications with very minimal installation required. I've used it for more than a year now, and It's worked, without fault, for every debugging scenario I've encountered.

Coverlet answered 9/2, 2011 at 20:56 Comment(0)
M
11

Use dnSpy.

dnSpy is a debugger and .NET assembly editor. You can use it to edit and debug assemblies even if you don't have any source code available.

It's so wonderful. Very small and lightweight. No installation or configuration needed. Its interface is exactly like Visual Studio. Even its shortcuts are the same as VS.

Features:

Debugger

  • Debug .NET Framework, .NET Core and Unity game assemblies, no source code required
  • Set breakpoints and step into any assembly
  • Locals, watch, autos windows
  • Variables windows supports saving variables (eg. decrypted byte arrays) to disk or view them in the hex editor (memory window)
  • Object IDs
  • Multiple processes can be debugged at the same time
  • Break on module load
  • Tracepoints and conditional breakpoints
  • Export/import breakpoints and tracepoints
  • Call stack, threads, modules, processes windows
  • Break on thrown exceptions (1st chance)
  • Variables windows support evaluating C# / Visual Basic expressions
  • Dynamic modules can be debugged (but not dynamic methods due to CLR limitations)
  • Output window logs various debugging events, and it shows timestamps by default :)
  • Assemblies that decrypt themselves at runtime can be debugged, dnSpy will use the in-memory image. You can also force dnSpy to always use in-memory images instead of disk files.
  • Public API, you can write an extension or use the C# Interactive window to control the debugger

Assembly Editor

  • All metadata can be edited
  • Edit methods and classes in C# or Visual Basic with IntelliSense, no source code required
  • Add new methods, classes or members in C# or Visual Basic
  • IL editor for low level IL method body editing
  • Low level metadata tables can be edited. This uses the hex editor internally.

Hex Editor

  • Click on an address in the decompiled code to go to its IL code in the hex editor
  • Reverse of above, press F12 in an IL body in the hex editor to go to the decompiled code or other high level representation of the bits. It's great to find out which statement a patch modified.
  • Highlights .NET metadata structures and PE structures
  • Tooltips shows more info about the selected .NET metadata / PE field
  • Go to position, file, RVA
  • Go to .NET metadata token, method body, #Blob / #Strings / #US heap offset or #GUID heap index
  • Follow references (Ctrl+F12)

Other

  • BAML decompiler
  • Blue, light and dark themes (and a dark high contrast theme)
  • Bookmarks
  • C# Interactive window can be used to script dnSpy
  • Search assemblies for classes, methods, strings etc
  • Analyze class and method usage, find callers etc
  • Multiple tabs and tab groups
  • References are highlighted, use Tab / Shift+Tab to move to next reference
  • Go to entry point and module initializer commands
  • Go to metadata token or metadata row commands
  • Code tooltips (C# and Visual Basic)
  • Export to project
Myrwyn answered 8/9, 2018 at 14:3 Comment(1)
But DnSpy is very heavy and always need newest runtime(and developer always delete old release version.)Vickievicksburg
C
10

For a bit nicer interface than MDbg or cordbg take a look at DbgCLR - a cut-down version of the Visual Studio debugger (at least it looks like one) that handles only managed code. It comes with the .NET Framework (I'm not sure if it's in the runtime or if you need the Framework SDK):

Note that cordbg is deprecated in favor of MDbg (even though MDbg doesn't have all of cordbg's features):

And in looking back at MDbg whle writing this post, I found that there's a GUI wrapper available for MDbg (which I haven't tried):

Craft answered 16/10, 2008 at 21:35 Comment(2)
No, there is not: blogs.msdn.com/b/andypennell/archive/2005/02/21/…Linkous
Update: The MDBG 4.0 Sample has been released to microsoft.com/downloads/en/… Thanks,AaronCulbertson
C
6

I've finally found extensions for Windbg that do just what I wanted: Sosex.dll, lets me use windbg to debug managed applications with very minimal installation required. I've used it for more than a year now, and It's worked, without fault, for every debugging scenario I've encountered.

Coverlet answered 9/2, 2011 at 20:56 Comment(0)
D
4

There is always mdbg and cordbg, but I would suggest digging more into why remote debugging doesn't work consistently.

VS2005/8 seem a lot more reliable than earlier versions here (though I primarily do unmanaged) and it saves you from having to have the symbols accessible on the target machine.

Discountenance answered 2/10, 2008 at 17:53 Comment(0)
Y
3

Version 2 of ILSpy contains a debugger. And it works awesome!

It is still in very early stages, but have helped me several times.

Just watch out for bugs! :)

Youngyoungblood answered 4/8, 2011 at 5:47 Comment(1)
I'm having ILSpy version 2.4.0.1963 and can finde no whatsoever clue on how to actually use the debugger you mention. No debugger executable in the ILSpy folder, no right-click in the tree, nothing. Can you give me a hint, please?Depreciatory
I
1

You could check out MDbg: http://blogs.msdn.com/jmstall/archive/2006/11/22/mdbg-sample-2-1.aspx. It looks like it comes with the .NET 3.5 SDK at least (and it's probably included with 2.0+).

Windbg has managed extensions (called SOS I believe), though I don't know if they allow source-level debugging.

Intermingle answered 2/10, 2008 at 18:0 Comment(0)
W
1

Have your tried using Cracked.NET ?

It's a runtime debugging and scripting tool that gives you access to the internals of any .NET desktop application running on your computer.

Wolfgram answered 16/4, 2011 at 1:23 Comment(0)
I
0

Maybe you can try using Live Tuning combined with an Ocf Server?

It's not a debugger per-se, but it's pretty easy to get a connection between an app and Live Tuning. Like, literally 3 lines of code. Then you have access to all the variables you choose to publish.

I found it useful when trying to debug my programs without having access to the decompiled code or a real debugger. You can't really have breakpoints but it turns out there's sometimes better ways to debug.

Interruption answered 28/4, 2014 at 15:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.