Provide message based debugging
The debugger in VS is farily decent. However it appears to be lacking one essential feature for debugging Windows applications that are event based. That would be the ability to easily debug the source of messages being posted to a window.
I typically have to resort to Spyxx.exe to view events while I am also debugging in Visual Studio. That is fraught with issues as Spyxx has problems when the debugger is running. Spy can detect an issue with "hooks" that can cause the system to lock up so spy tells me it is refusing to log messages. Sometimes I just have to either exit Visual Studio and start all over as the recommedation from spyxx to restart spy does not always help.
Even with spy, debugging messages posted to a window is almost impossible. Spy can show me the message, but it doesn't show me from where the message is posted. That is frequently the key to debugging an issue in a message based system. And the VS debugger appears to have nothing (that I know of) to help with this difficult issue.
What I would like to see is another breakpoint command. It could be added to the "Breakpoints" window's "New" dropdown. I would love to be able to set a breakpoint whenever, for example, WM_PAINT or WM_SETFOCUS is posted to a particular hWnd. This would give me the ability to quickly and easily determine from where a message is posted.
If anywone knows where this feature is in the debugger, please let me know. If it is not available, this seems like a fundamental feature for debugging a message based application so why hasn't Visual Studio added this ability and more importantly, can it be added in a future version of Visual Studio?
As another suggestion, I think integrating the Spyxx.exe message logging directly into the debugger would really be useful and could avoid the lockup (now potential) issues due to two separate hook based tools trying to hook into a process. Being able to open a debug/messages window for an hWnd would be very useful. And when I right-click on a message I see, having the shortcut menu have "stop logging message", "start logging message", "logging options", ... etc as well as two commands Spyxx's shortcut menu doesn't have, "Break when posted" and "Break when sent" commands would be a great addition to the debugging ability of Visual Studio.
Dekel Cohen commented
Currently, IntelliTrace is what VS.NET provides for logging system messages. I believe Win32 WM_XXX messages are not currently covered (but one can create custom trace provider).
Workaround: Set some conditional breakpoint (tracepoint ?) at SendMessage / PostMessage / Other .NET or Windows relevant API.
It would be great if we saw received window messages as asynchronous calls (http://blogs.msdn.com/b/visualstudioalm/archive/2013/07/01/debugging-asynchronous-code-in-visual-studio-2013-call-stack-enhancements.aspx) in call stack window
Dennis Weldy commented
Integrate the functionality of ProcessMonitor where you can get a stack trace from the event listing and design it so the stack listing entries will jump to the source (i.e., you wouldn't need to break the debugger to get to the source). That way you can leave the process running and investigate where messages are coming from after the fact without having to deal with activation/focus change events which can ***** up workflow testing because of extra messages that occur from the debugging process.
Alex Nelson commented