【问题标题】:Get object details from clrstack output in windbg从 windbg 中的 clrstack 输出获取对象详细信息
【发布时间】:2012-03-28 15:36:13
【问题描述】:

我有一个挂在 OnUserPreferenceChanged 事件上的多线程 .NET 应用程序。这通常是由在后台线程上启动的 UI 控件或消息循环引起的(参见例如http://www.ikriv.com/en/prog/info/dotnet/MysteriousHang.html),但据我所知,这里并非如此。我通过在 WindowsFormsSynchronizationContext 中设置断点来验证这一点(如此处建议的 http://www.aaronlerch.com/blog/2008/12/15/debugging-ui/),它只在主 UI 线程中构造一次。

这是windbg中 !clrstack 的输出:

0013eea8 7c90e514 [HelperMethodFrame_1OBJ: 0013eea8] System.Threading.WaitHandle.WaitOneNative(Microsoft.Win32.SafeHandles.SafeWaitHandle, UInt32,布尔值,布尔值)0013ef54 792b68af System.Threading.WaitHandle.WaitOne(Int64, Boolean) 0013ef70 792b6865 System.Threading.WaitHandle.WaitOne(Int32, Boolean) 0013ef84 7b6f1a4f System.Windows.Forms.Control.WaitForWaitHandle(System.Threading.WaitHandle) 0013ef98 7ba2d68b System.Windows.Forms.Control.MarshaledInvoke(System.Windows.Forms.Control, System.Delegate、System.Object[]、布尔值)0013f038 7b6f33ac System.Windows.Forms.Control.Invoke(System.Delegate,System.Object[]) 0013f06c 7b920bd7 System.Windows.Forms.WindowsFormsSynchronizationContext.Send(System.Threading.SendOrPostCallback, System.Object) 0013f084 7a92ed62 Microsoft.Win32.SystemEvents+SystemEventInvokeInfo.Invoke(布尔值, System.Object[]) 0013f0b8 7a92dc8f Microsoft.Win32.SystemEvents.RaiseEvent(布尔,System.Object, System.Object[]) 0013f104 7a92e227 Microsoft.Win32.SystemEvents.OnUserPreferenceChanged(Int32,IntPtr, IntPtr) 0013f124 7aaa06ec Microsoft.Win32.SystemEvents.WindowProc(IntPtr, Int32, IntPtr, IntPtr)

我可以获取参数信息的最后一种方法是:

0013f084 7a92ed62 Microsoft.Win32.SystemEvents+SystemEventInvokeInfo.Invoke(布尔值, 系统.对象[]) 参数: 这 = 0x01404420 checkFinalization = 0x00000001 args = 0x0144a298

这是我的问题:如何在此处获取更多信息?最终,我想知道这个 Invoke 用于哪些对象和/或线程。像“!do 0x01404420”或“!do 0x0144a298”之类的东西,但我不知道从那里去哪里。

【问题讨论】:

    标签: c# .net clr windbg


    【解决方案1】:

    使用 !dumpheap -type Exception 在堆中搜索异常。

    您还可以查看类中变量的值,这将有助于了解类的状态。使用 !dumpheap -type ClassName。您将获得一个 MT(方法表)地址。从 MT 地址查看对象地址。使用 !do 地址转储类。

    使用!syncblk查看锁定的线程

    【讨论】:

    • 这是很好的信息,但在这种情况下,我有一个已知的死锁场景:线程 0 正在等待调用其他线程的 OnUserPreferenceChanged 事件。我只需要知道它正在调用哪个线程。
    【解决方案2】:

    关于 SystemEvents 类引起的问题,特别是 OnUserPreferenceChanged 事件,尝试使用 this answer 中的 CheckSystemEventsHandlersForFreeze() 函数,这可以帮助找到根本原因,即哪些控件是在错误的线程上创建的,从而导致冻结。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-19
      • 2022-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-18
      • 1970-01-01
      相关资源
      最近更新 更多