Debugging dump files in Visual Studio

I am using Visual Studio 2010 Professional Edition and Windows Vista.

First off, I have this code. As you can see, this will crash the program!

using System; namespace Crash { class Program { static void Main(string[] args) { string a = null; if (a.Length == 12) { // ^^ Crash } } } } 

The program will crash in the if statement. Now I want to know that he collapsed on this if statement.

If I run without debugging from Visual Studio, Crash.exe fails. It uses 1.356 KB of memory. I get the Vista Close Program / Debug option. If I select Debug, I can open a new instance of Visual Studio, and it points me to a NullReferenceException in the if statement. It's good.

Now let me assume that it crashes on another computer, and I force them to give me a dump file through the task manager. This is 54,567kb. Why so big! It's simple! Anyway, I'm less interested in (slightly)

If I open this dump with Windbg, I get very little benefit from my unprepared eye:

 Microsoft (R) Windows Debugger Version 6.12.0002.633 X86 Copyright (c) Microsoft Corporation. All rights reserved. Loading Dump File [C:\Users\Richard\Desktop\Crash.DMP] User Mini Dump File with Full Memory: Only application data is available Symbol search path is: SRV*C:\SYMBOLS*http://msdl.microsoft.com/download/symbols Executable search path is: Windows Server 2008/Windows Vista Version 6002 (Service Pack 2) MP (4 procs) Free x86 compatible Product: WinNt, suite: SingleUserTS Personal Machine Name: Debug session time: Sat Jan 15 11:07:36.000 2011 (UTC + 0:00) System Uptime: 0 days 4:24:57.783 Process Uptime: 0 days 0:00:05.000 ........................ eax=002afd40 ebx=77afa6b4 ecx=002afd48 edx=00000001 esi=001cdaa4 edi=00000000 eip=77bf5e74 esp=001cda5c ebp=001cdacc iopl=0 nv up ei ng nz ac pe cy cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000297 ntdll!KiFastSystemCallRet: 77bf5e74 c3 ret 

However, this does not interest me. As far as I can tell, I need to write commands to get useful output, and Visual Studio is better.

So I open it with Visual Studio. I can choose "Debug with Native Only", but I get a lot of things that mean something smart people like you, and I'm not smart! I get these two screens:

enter image description here

enter image description here

So my question is:

How to show Visual Studio source code?

Also, is there a way to get a smaller dump file? It seems ridiculously large, even after squeezing. I don’t understand why there cannot be one that will be just a little bigger than the size of the program, and still get good debugging with the source code.

+45
debugging c # visual-studio-2010 crash-dumps
Jan 15 '11 at 11:23
source share
3 answers

The significant advertising feature that Visual Studio 2010 allows you to debug emergency dump files and go through managed source code comes with gotcha: it only works for the .NET 4.0 build . Here are the steps:

  • Create a crash dump file on another computer using task manager
  • Open the solution in VS2010
  • Open the .DMP file (File-> Open ...)
  • Click Debug With Mixed (This will only be visible for .NET 4.0)
  • The source code opens and you can verify the exact cause and location of the exception.

As for debugging with native only, Visual Studio is no more useful than WinDbg.

+41
Jan 15 '11 at 11:59
source share

The tool you use here has never been developed to troubleshoot managed programs. Minidumps and Windbg are what you use to find out what is wrong with code written in C or C ++. Quite important tools are languages ​​in which the battery life does not support the advantages that you can get from a managed program. As an exception with a stack trace.

The reason mini-drives are so different is due to the mini-mini pump. By design, it is designed to capture a small snapshot of the process. The corresponding argument is the DumpType in the MiniDumpWriteDump function . There really is smart code in this function that can determine which parts of the process state do not need to be written because you are unlikely to use it in a debugger session. What you can override by providing additional dump type flags. The minidump that Explorer generates includes all these flags, you get the whole kit and caboodle.

This is really very important for a managed program. The heuristic used by this minidump creator is one that is only suitable for unmanaged code. Debugging a managed program dump only works well when you include all garbage collected in a heap. Yes, it will be a big dump, mini is no longer used.

Your next problem is that you get the soul of the machine from the minidump data. Screenshots show machine code. In these frames, you ended up inside Windows, notice how ntdll.dll is on top of the stack. Mscorwks.dll entries are CLR. Further down, out of sight, you should see stack frames from your own code. However, you will see the machine code that was generated by the JIT compiler. Not your C # code.

There is a Windbg add-in called sos.dll that extends the Windbg command set to be able to verify managed data. Just google "sos.dll" to get good hits. However, this is still far from what debugging experience you choose from the Visual Studio debugger. Which deeply knows managed code, very different from Windbg or the VS debugger, which can load mini-drives. Sos was really designed to troubleshoot CLR errors.

There were no significant improvements in VS2010 other than the minidump page information you are currently seeing. In fact, this is not so at all. I suspect that the debugger team should have this on its to-do list, there are certain fundamental problems to overcome. Especially in the minidump format and in the creation code. Use connect.microsoft.com to provide feedback, they pay attention to this and allow voting to influence their priority list.

+38
Jan 15 '11 at 12:11
source share

You must supply the linked pdb file (program file) to the debugger so that it can load characters. Also, for a better overview, use the Microsoft Public Symbol server. This article contains information about this.

+5
Jan 15 '11 at 11:55
source share



All Articles