c# – 使用WinDbg从minidump确定InnerException的行号

前端之家收集整理的这篇文章主要介绍了c# – 使用WinDbg从minidump确定InnerException的行号前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试从转储中追踪NullReferenceException. NullReferenceException不是崩溃异常,而是崩溃异常是TargetInvocationException,其InnerException是NullReferenceException.

我正在使用Windbg和SOS,我使用命令analyze -v,这给了我NullReferenceException的调用堆栈:

  1. EXCEPTION_OBJECT: !pe f6cb150
  2. Exception object: 000000000f6cb150
  3. Exception type: System.NullReferenceException
  4. Message: Object reference not set to an instance of an object.
  5. InnerException: <none>
  6. StackTrace (generated):
  7. SP IP Function
  8. 000000002CD9D8C0 000007FF01E7C639 MyDll!DoSomething2()+0xe99
  9. 000000002CD9DBE0 000007FF01E7B11D MyDll!DoSomething1()+0x43d
  10. 000000002CD9DD20 000007FF01E7AB11 MyDll!WorkerDoWork(System.Object,System.ComponentModel.DoWorkEventArgs)+0x51
  11. 000000002CD9DD80 000007FEEA68A0F2 System_ni!System.ComponentModel.BackgroundWorker.WorkerThreadStart(System.Object)+0x62

请注意,我得到了具有字节偏移的方法名称,但没有行号. DoSomething2是一个很大的函数,因此NullReferenceException发生的位置并不明显.

我试图按照Tess Ferrandez博客中的说明操作:

.Net exceptions – Tracking down where in the code the exceptions occurred

但是我很早就陷入困境,我尝试使用DoSomething2:7FF01E7C639的IP来确定方法DoSomething2的方法描述符!ip2md:

  1. > !ip2md 7FF01E7C639
  2. Failed to request MethodData,not in JIT code range

请注意,!ip2md命令在发生TargetInvocationException的方法的IP上成功.

题:

我在哪里可以从这里开始缩小DoSomething2中的哪一行崩溃?
请注意,我无法重现崩溃,所以我只有这个(和几个重复的)转储.

补充说明:

> .NET 4.0
> Windbg版本:6.12.0002.633 AMD64
>我是Windbg的新手:所以信息越多越好

编辑1

如果我没有正确设置符号,我会得到以下信息:

  1. STACK_TEXT:
  2. 00000000`2cd9d8c0 00000000`ffffffff MyDll!Unknown_0xe99+0xe99
  3. 00000000`2cd9dbe0 00000000`ffffffff MyDll!Unknown_0x43d+0x43d
  4. 00000000`2cd9dd20 00000000`ffffffff MyDll!Unknown_0x51+0x51
  5. 00000000`2cd9dd80 00000000`ffffffff system_ni! System.ComponentModel.BackgroundWorker.WorkerThreadStart+0x62

当我将其设置为指向我的符号服务器并打开!sym noisy时,它似乎正确加载符号:

  1. 0:000> ld MyDll
  2. DBGHELP: C:\Program Files\Debugging Tools for Windows (x64)\MyDll.dll - file not found
  3. SYMSRV: c:\symbols\MyDll.dll\4F3D6F4B154000\MyDll.dll not found
  4. SYMSRV: http://msdl.microsoft.com/download/symbols/MyDll.dll/4F3D6F4B154000/MyDll.dll not found
  5. SYMSRV: \\mysymbolserver\store\Mydll.dll\4F3D6F4B154000\file.ptr
  6. SYMSRV: MyDll.dl_ from \\mysymbolserver\store: uncompressed
  7. DBGHELP: c:\symbols\MyDll.dll\4F3D6F4B154000\MyDll.dll - OK
  8. DBGENG: c:\symbols\MyDll.dll\4F3D6F4B154000\MyDll.dll - Mapped image memory
  9. SYMSRV: c:\symbols\MyDll.pdb\8AFC2BE7529A41289FA9FBCEDB6836161\Mydll.pdb not found
  10. SYMSRV: http://msdl.microsoft.com/download/symbols/Mydll.pdb/8AFC2BE7529A41289FA9FBCEDB6836161/MyDll.pdb not found
  11. SYMSRV: \\mysymbolserver\store\MyDll.pdb\8AFC2BE7529A41289FA9FBCEDB6836161\file.ptr
  12. SYMSRV: MyDll.pd_ from \\mysymbolserver\store: uncompressed
  13. DBGHELP: MyDll - private symbols & lines
  14. c:\symbols\MyDll.pdb\8AFC2BE7529A41289FA9FBCEDB6836161\MyDll.pdb
  15. Symbols loaded for MyDll

编辑2

我尝试使用!name2ee如下:

  1. 0:000> !name2ee MyDll!MyType.DoSomething2
  2. Module: 000007ff004995b8
  3. Assembly: Autodesk.DataManagement.Client.Framework.Vault.dll
  4. <invalid module token>

所以,那里没有运气.但后来我几乎似乎得到了这个:

  1. 0:000> !name2ee MyDll.dll!MyNamespace.MyType
  2. Module: 000007ff004995b8
  3. Assembly: MyDll.dll
  4. Token: 000000000200008c
  5. MethodTable: 000007ff01b2e258
  6. EEClass: 000007ff01b415e0
  7. Name: MyNamespace.MyType
  8.  
  9. 0:000> !dumpmt -md 7ff01b2e258
  10. EEClass: 000007ff01b415e0
  11. Module: 000007ff004995b8
  12. Name: MyNamspace.MyType
  13. mdToken: 000000000200008c
  14. File: C:\Program Files\MyCompany\MyProduct\Bin\MyDll.dll
  15. BaseSize: 0x30
  16. ComponentSize: 0x0
  17. Slots in VTable: 31
  18. Number of IFaces in IFaceMap: 2
  19. --------------------------------------
  20. MethodDesc Table
  21. Entry MethodDesc JIT Name
  22. 000007feeb31a2c0 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  23. 000007feeb3689f0 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  24. 000007feeb3688c0 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  25. 000007feeb353440 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  26. 000007ff01b01300 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  27. 000007ff01e89140 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  28. 000007ff01b9c080 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  29. 000007ff01f45f40 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  30. 000007ff01a9b358 000007ff01b2e128 NONE MyType.DoSomething3()
  31. 000007ff01a9b360 000007ff01b2e130 NONE MyType.DoSomething4()
  32. 000007ff01a9b368 000007ff01b2e138 NONE MyType.DoSomething5()
  33. 000007ff01e79800 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  34. 000007ff020fea80 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  35. 000007ff01a9b3b0 000007ff01b2e1b0 NONE MyType.DoSomething6()
  36. 000007ff01a9b3b8 000007ff01b2e1b8 NONE MyType.DoSomething7()
  37. 000007ff01a9b328 000007ff01b2e0f0 NONE MyType..ctor()
  38. 000007ff01b01280 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  39. 000007ff01e7a810 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  40. 000007ff01e7aac0 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  41. 000007ff01e83240 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  42. 000007ff01f19520 000007ff01b2e178 JIT MyType.RunWorkerCompleted(System.Object,System.ComponentModel.RunWorkerCompletedEventArgs)
  43. 000007ff01e7ace0 0000000000000000 JIT 0000000000000000 is not a MethodDesc
  44. 000007ff01e7b7a0 0000000000000000 JIT 0000000000000000 is not a MethodDesc
  45. 000007ff01e7b710 0000000000000000 JIT 0000000000000000 is not a MethodDesc
  46. 000007ff01e7d2b0 0000000000000000 JIT 0000000000000000 is not a MethodDesc
  47. 000007ff01b015f0 0000000000000000 JIT 0000000000000000 is not a MethodDesc
  48. 000007ff01b88ce0 0000000000000000 JIT 0000000000000000 is not a MethodDesc
  49. 000007ff01a9b3e0 000007ff01b2e200 NONE MyType.DoSomething8()
  50. 000007ff01b921e0 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  51. 000007ff01b933b0 0000000000000000 NONE 0000000000000000 is not a MethodDesc
  52. 000007ff01b93870 0000000000000000 NONE 0000000000000000 is not a MethodDesc

我猜测所有缺失的条目(那些列出的“不是MethodDesc”)是由于这不是一个完整的迷你转储.是对的吗?

解决方法

在上面的评论中,你提到了||命令产生“用户迷你转储”.为了正确调试.NET代码,您需要一个完整转储,它将指示来自||的“完全内存用户迷你转储”命令.我想这是你的问题.如果无法访问完整的加载程序堆,则无法将代码地址映射回.NET方法,因此无法获得堆栈跟踪.如果可以重现此问题,请捕获完整转储.您可以使用ADPlus,ProcDump或DebugDiag在崩溃时捕获转储.

猜你在找的C#相关文章