Skip to main content
gamedev.net
🔒 Locked

Visual Studio Debugging Tricks

Started by skyfire360 Jan 15, 2008 at 9:38 PM 5 replies 1.1k views
Original Post
skyfire360
skyfire360
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
Sneftel
Sneftel
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.
skyfire360
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).
I do real things with imaginary numbers
yahastu
yahastu
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..
Sneftel
Sneftel
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.
mutex
mutex
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.

frob
frob
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.