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

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

问题描述

我使用的是 Visual Studio 2010 专业版和 Windows Vista.

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

首先,我有这个代码.如您所见,它会使程序崩溃!

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:UsersRichardDesktopCrash.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?

How do I show Visual Studio to my source code?

另外,有没有办法获得更小的转储文件?即使在压缩之后,它看起来也大得离谱.我不明白为什么不能有一个只比程序的占用空间大一点点的,并且仍然可以用源代码进行很好的调试.

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 允许您调试故障转储文件并逐步执行托管源代码的广为宣传的功能带来了一个问题:它可以工作 仅适用于 .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. 点击Debug With Mixed(这仅在 .NET 4.0 中可见)
  5. 源代码将打开,您将能够检查异常的确切原因和位置
  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天全站免登陆