How do I tell what an UnsafeNativeMethods.DispatchMessageA call is doing using windbg?
Question
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()
Solution
!dumpstack
does the trick, nice detailed stacktrace into the unmanaged dll
OTHER TIPS
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow