Unity Visual Studio Debugging Tricks

This topic is 3902 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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?

Share on other sites
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.

Share on other sites
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).

Share on other sites
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..

Share on other sites
Quote:
 Original post by skyfire360True, 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.

Share on other sites
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.

Share on other sites
Quote:
 Original post by yahastuOutputDebugString("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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
frob
13
5. 5

• 9
• 18
• 11
• 9
• 17
• Forum Statistics

• Total Topics
632605
• Total Posts
3007371

×