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

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

问题描述

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



首先,我有这个代码。正如你所看到的,它将会崩溃程序!

  using System; 

命名空间崩溃
{
类程序
{
static void Main(string [] args)
{
string a = null;

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

程序将在if语句上崩溃。现在,我想知道它在if语句中崩溃了。



如果我从Visual Studio启动不调试,Crash.exe崩溃。它使用1,356kb的内存。我得到了关闭程序/调试的Vista选项。如果我选择Debug,我可以打开一个新的Visual Studio实例,它指向一个NullReferenceException对if语句。这是很好的。



现在让我假设它在另一台电脑上崩溃,我让他们通过任务管理器给我一个转储文件。是54,567kb。为什么这么大!很厉害无论如何,我对这个不太感兴趣(略)



如果我用Windbg打开转储,我对我未经训练的眼睛很少使用:

  Microsoft(R)Windows Debugger版本6.12.0002.633 X86 
版权所有(c)Microsoft Corporation。版权所有。


加载转储文件[C:\Users\Richard\Desktop\Crash.DMP]
具有完整内存的用户微型转储文件:只有应用程序数据可用

符号搜索路径是:SRV * C:\SYMBOLS * http://msdl.microsoft.com/download/symbols
可执行搜索路径是:
Windows Server 2008 / Windows Vista版本6002(Service Pack 2)MP(4 procs)免费x86兼容
产品:WinNt,suite:SingleUserTS个人
机器名称:
调试会话时间:Sat Jan 15 11: 07:36.000 2011(UTC + 0:00)
系统正常运行时间:0天4:24:57.783
处理正常运行时间:0天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

Howe对我来说,这不太感兴趣。据我所知,我需要编写命令来获得有用的输出,Visual Studio更好。



所以我用Visual Studio打开它。我可以选择只用本机调试,但是我会得到很多东西,这意味着聪明的人喜欢你,而且我不是很聪明!我得到这两个屏幕:







所以,我的问题:



如何将Visual Studio显示给我的源代码? / p>

另外,有没有办法获得较小的转储文件?这似乎是可笑的,甚至在压缩之后。我不明白为什么不能有一个只比程序的脚印稍微大一些,并且仍然得到一个很好的调试与源代码。

解决方案

Visual Studio 2010允许您调试崩溃转储文件并逐步完成托管源代码的广告功能有一个getcha:它的工作原理仅适用于.NET 4.0程序集。以下是步骤:


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

  2. 打开VS2010中的解决方案

  3. 打开.DMP文件(File-> Open ...)

  4. 点击调试使用Mixed (这将仅在.NET 4.0中可见)

  5. 源代码将打开,您将能够检查异常的确切原因和位置

只要使用本机调试,Visual Studio不如WinDbg更有用。


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
            }
        }
    }
}

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

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.

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)

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

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.

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:

So, my question:

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.

解决方案

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. 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

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

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

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