如何使用 Windbg 判断 UnsafeNativeMethods.DispatchMessageA 调用正在做什么?
我已经追踪到该线程不再发送消息的死锁,但我如何更进一步并找出该线程当前正在做什么?我正在使用 Windbg 并使用 !do 进行随机游走,到目前为止还没有给我任何东西,
非常感谢
Oskar
0:057> !clrstack
OS Thread Id: 0x17f8 (57)
ESP EIP
1393f1ac 2070a64a [NDirectMethodFrameStandalone: 1393f1ac] System.Windows.Forms.UnsafeNativeMethods.DispatchMessageA(MSG ByRef)
1393f1bc 04851c91 System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32)
1393f258 04851276 System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
1393f2a0 048507e3 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
1393f2d0 0485062f System.Windows.Forms.Application.Run()
I have tracked down my deadlock to this thread not pumping messages anymore, but how do I take it one step further and figure out what the thread is currently doing? I'm using windbg and random walks using !do hasn't given me anuthing so far
many thanks
Oskar
0:057> !clrstack
OS Thread Id: 0x17f8 (57)
ESP EIP
1393f1ac 2070a64a [NDirectMethodFrameStandalone: 1393f1ac] System.Windows.Forms.UnsafeNativeMethods.DispatchMessageA(MSG ByRef)
1393f1bc 04851c91 System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32, Int32, Int32)
1393f258 04851276 System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
1393f2a0 048507e3 System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
1393f2d0 0485062f System.Windows.Forms.Application.Run()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
成功了,对非托管 dll 进行了详细的堆栈跟踪
does the trick, nice detailed stacktrace into the unmanaged dll
kn100 将为您提供本机堆栈,但看起来它正在调用 DispatchMessage,这意味着它可能卡在目标窗口的窗口处理程序中(即“OnSize”事件或代码中的某些内容)
破解打开 MSG 结构,以便您可以看到窗口及其尝试发送的消息,然后在代码中找到相应的事件处理程序。
kn100 will give you the native stack, but it looks like it's calling DispatchMessage, which means that it's probably stuck in the target window's window handler (i.e. an "OnSize" event or something in your code)
Crack open the MSG struct so you can see the window and the message it's trying to send, then find the corresponding event handler in your code.