Using a mini-dump for debugging (Visual Studio)
[Previously on my old site]
I recently had an issue where a program wasn’t working on a server, but everything looked fine when I ran it locally. After writing a small test program, I was able to duplicate the issue and narrow it down to the few lines of code that were causing the problem.
Unfortunately, the server had a firewall that didn’t let me connect a remote debugger. but that’s no problem: Mini Dump to the rescue!
- In task manager, right click on your process and create a dump file. Once it completes, it will give you the location of the file it created.
- Copy the file to the machine you'll be debugging from.
- With Visual Studio 2013 installed, double click the dump file to open it.
- On the right hand side, it will give an option to debug mixed(.Net) or un-managed (native) code. Click your favorite, and you have a debug session in place showing where the program is stuck.
(Variations of this functionality in previous versions of Visual Studio. It may look slightly different, but it should work. I’ve done this in VS2012 and 2013, and it has some slightly different looks, but it’s essentially the same.)
Longer version, with screen prints. This is a dummy program that I’m doing all from the same machine, so there isn’t any need to copy from one location to another.
After a moment, it will pop up a dialog giving the location of the dump file. Copy the file to your dev machine, or in this case, I’m on the same machine, so I just double click the .dmp in place. Visual Studio will open.
Notice the information it gives: Names and paths to the dump files, a full callstack, and on the right, actions you can choose.
- Click the “Debug with Mixed” or “Debug with Managed” (depending on your version), and the program will pop-up, showing where the hanging condition is.
From here, you can view the code, and maybe get some good insight to whats going on.
Note that this works with “real” executables. If you try to do this with a program running in visual studio, with the .vshost.exe name, it doesn’t work.
Hope you find this tip handy.