Visual Studio Debugging Tricks

Started by
5 comments, last by frob 16 years, 3 months ago
I just remembered a really, really useful debugging trick in Visual Studio that I had forgotten a few years ago. Makes debugging dynamically allocated arrays so easy... really wish I had remembered this :) Anyone else know any good debugging tricks like this?
I do real things with imaginary numbers
Advertisement
I wouldn't call that a "trick", so much as "how you use the debugger". Regardless, among the most useful and most overlooked features of the debugger are conditional breakpoints and data breakpoints.
True, but conditional breakpoints and data breakpoints are present in most modern debuggers (VS, gdb, etc). I was under the assumption (and I could very well be wrong) that this was exclusive to the Visual Studio debugging environment (akin to toying around with autoexp.dat).
I do real things with imaginary numbers
Here's one:

OutputDebugString("testing");

This will print a message out into the debug area when it hits the code during runtime.

There's also

( #pragma message which you can use to output a message at compile time)

I also find it useful to do

#pragma warning (push)#pragma warning (disable : 4996 )//deprecated code here#pragma warning (pop)


to avoid obscuring the debug window with warnings..
Quote:Original post by skyfire360
True, but conditional breakpoints and data breakpoints are present in most modern debuggers (VS, gdb, etc). I was under the assumption (and I could very well be wrong) that this was exclusive to the Visual Studio debugging environment (akin to toying around with autoexp.dat).
The syntax might be, but I've never used a debugger without this feature. Under GDB, you use an at-sign instead of a comma. Actually, data breakpoints are probably the least common debugger feature, because of the hardware support required.
I find tracepoints invaluable, especially when debugging UI code where breaking into the debugger interferes with the scenario. Typically I set tracepoints on interesting functions to log calls, parameters, and other state.

Quote:Original post by yahastu
OutputDebugString("testing");

Minor warning on this one: If you don't have a debugger attached to listen to the string, Windows will set the error flag on GetLastError(). I believe it set it to ERROR_FILE_NOT_FOUND.

This topic is closed to new replies.

Advertisement