使用DebugDiag在托管代码中设置断点

时间:2015-12-09 18:29:39

标签: c# debugdiag debug-diagnostic-tool

每次调用特定方法时,我都会尝试使用Debug Diagnostic Tool来创建Minidump。

我从简单的控制台应用开始:

namespace FastFailApp {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine("Starting...");
            for (int i = 0; i < 20; i++) {
                Console.Write(".");
                Thread.Sleep(1000);
            }
            Environment.FailFast("Not so unexpected failure...");
        }
    }
}

然后我在DebugDiag中创建了规则,以便在每次Program.Main调用时创建minidump: screenshot of debugdiag 不幸的是它没有用,在DebugDiag日志中我得到了消息:

[12/9/2015 8:05:15 PM] Attempting to set managed breakpoint at FailFastApp.dll!FailFastApp.Program.Main
[12/9/2015 8:05:15 PM] bpID = -2
[12/9/2015 8:05:15 PM] Current Breakpoint List(BL)
SYMSRV:  https://msdl.microsoft.com/download/symbols/kernel32.pdb/996C94DB18DE43688CA110D2FF25B8542/kernel32.pdb not found
SYMSRV:  C:\Program Files\DebugDiag\sym\kernel32.pdb\996C94DB18DE43688CA110D2FF25B8542\kernel32.pdb not found
DBGHELP: C:\Windows\system32\kernel32.pdb - file not found
DBGHELP: kernel32.pdb - file not found
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\system32\KERNEL32.dll - 
DBGHELP: KERNEL32 - export symbols
SYMSRV:  https://msdl.microsoft.com/download/symbols/ntdll.pdb/6048FDB62DCD41C18835594844CE71432/ntdll.pdb not found
SYMSRV:  C:\Program Files\DebugDiag\sym\ntdll.pdb\6048FDB62DCD41C18835594844CE71432\ntdll.pdb not found
DBGHELP: C:\Windows\SYSTEM32\ntdll.pdb - file not found
DBGHELP: ntdll.pdb - file not found
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\SYSTEM32\ntdll.dll - 
DBGHELP: ntdll - export symbols
[12/9/2015 8:05:15 PM] Thread exited. Exiting thread system id - System ID: 3568. Exit code - 0x00000000
CLR: Managed code called FailFast, saying "Not so unexpected failure..."

我已经在DebugDiag中设置了符号服务器,我用WinDBG检查了这个配置: enter image description here

有人有任何建议吗?

PS。我尝试调试的应用程序是64位。我尝试将当前进程目录(带有pdb文件)添加到符号路径,并使用各种格式进行断点表达(如Module!Class::MethodModule.dll!Class.Method(OtherType))而不成功。

1 个答案:

答案 0 :(得分:0)

不应该是FailFastApp.exe!FailFastApp.Program.Main?不确定你是否已将代码放在类库中并将其编译为DLL但如果你没有这样做,那么它应该是.exe

如果这不起作用,那么看看你是否可以通过使用此断点获得睡眠方法转储

mscorlib.dll!System.Threading.Thread.Sleep

希望这有帮助