调试在Visual Studio中转储文件 [英] Debugging dump files in Visual Studio

查看:412
本文介绍了调试在Visual Studio中转储文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Visual Studio 2010专业版和Windows Vista。

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

首先,我有这样的code。正如你所看到的,它会使程序崩溃!

Firstly, I have this code. As you can see, it will crash the program!

using System;

namespace Crash
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = null;

            if (a.Length == 12)
            {
                // ^^ Crash
            }
        }
    }
}

程序会崩溃的if语句。现在,我想找出它坠毁,机上的if语句。

The program will crash on the if statement. Now, I want to find out that it crashed on that if statement.

如果我开始不调试从Visual Studio,Crash.exe崩溃。它采用的内存1,356kb。我得到的关闭程序/调试的Vista的选项。如果让我选择调试,我可以打开Visual Studio中的一个新实例,并且它指向我的if语句一个NullReferenceException。这是不错的。

If I "Start without Debugging" from Visual Studio, Crash.exe crashes. It uses 1,356kb of memory. I get the Vista option of Close Program/Debug. If I choose Debug, I can open a new instance of Visual Studio, and it points me to a NullReferenceException on the if statement. This is good.

现在让我假设它崩溃另一台计算机上,而且我让他们给我通过任务管理器转储文件。这是54,567kb。为什么这么大!这是广大!不管怎么说,我在这不感兴趣(略)

Now let me assume that it crashes on another computer, and I get them to give me a Dump File via Task Manager. It is 54,567kb. Why so big! It's vast! Anyway, I am less interested in that (slightly)

如果我打开使用WinDbg该转储,我得到很少使用到我的未经训练的眼睛:

If I open that dump with Windbg, I get very little of use to my untrained 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

不过,这对我不感兴趣的。至于我可以告诉大家,我需要在写入命令来获得有用的输出,和Visual Studio更好。

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

于是,我与Visual Studio打开。我可以选择调试与本土只有,但我得到很多事情意味着什么巧妙的人喜欢你,我不聪明!我得到这两个屏幕:

So I open it with Visual Studio. I can choose to "Debug with Native Only", but I get lots of things that mean something to clever people like you, and I am not clever! I get these two screens:

所以,我的问题:

我如何展示Visual Studio中我的源$ C ​​$ C?

How do I show Visual Studio to my source code?

此外,有没有一种方式来获得转储文件更小?这似乎大得离谱,即使经过COM pressing。我不明白为什么不能成为其中一个比程序的足迹只大只是一点点,而且还得到一个不错的调试,源$ C ​​$ C。

Also, is there a way to get a smaller dump file? It seems ridiculously big, even after compressing. I don't understand why there couldn't be one which is only just a tiny bit bigger than the program's footprint, and still get a nice debugging, with the source code.

推荐答案

备受标榜的功能,Visual Studio 2010中,您可以调试故障转储文件,并通过托管源$ C ​​$ C步骤带有一个疑难杂症:它的工作原理<一个href=\"http://blogs.msdn.com/b/debugger/archive/2010/04/28/why-don-t-i-see-debug-with-mixed-when-debugging-the-dump-of-a-managed-process-in-visual-studio-2010.aspx\">only对于.NET 4.0组件的。具体操作步骤如下:

The much advertised feature that Visual Studio 2010 allows you to debug crash dump files and step through the managed source code comes with a gotcha: it works only for .NET 4.0 assemblies. Here are the steps:


  1. 创建使用任务管理器另一台计算机上崩溃转储文件

  2. 打开VS2010中的解决方案

  3. 打开.dmp文件(文件 - >打开...)

  4. 单击关于调试期混合(这将是可见的仅适用于.NET 4.0)

  5. 来源$ C ​​$ C将打开,你将能够检查异常
  6. 的确切原因和位置
  1. Create a crash dump file on another computer using the Task Manager
  2. Open the solution in VS2010
  3. Open the .DMP file (File->Open...)
  4. Click on Debug With Mixed (This will be visible only for .NET 4.0)
  5. Source code will open and you will be able to inspect the exact cause and location of the exception

至于与本地唯一担心的Visual Studio调试不超过WinDbg的更加有用。

As far as debugging with native only is concerned Visual Studio is no more useful than WinDbg.

这篇关于调试在Visual Studio中转储文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆