如何使用 Windbg 判断 UnsafeNativeMethods.DispatchMessageA 调用正在做什么?

发布于 2024-08-04 18:17:29 字数 823 浏览 6 评论 0原文

我已经追踪到该线程不再发送消息的死锁,但我如何更进一步并找出该线程当前正在做什么?我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不疑不惑不回忆 2024-08-11 18:17:29
!dumpstack 

成功了,对非托管 dll 进行了详细的堆栈跟踪

!dumpstack 

does the trick, nice detailed stacktrace into the unmanaged dll

狼性发作 2024-08-11 18:17:29

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文