Debugging in Visual Studio
Debugging in Visual Studio
By Steve Jones
Game Institute
• Starting / Stopping
• Breaking
• Stepping through your
application
F11 F10 Shift + F11
– (F10, F11 or Toolbar Step Into Step Over Step Out
buttons)
• Run to a specific location Equivalent hot-keys
– Run To Cursor (right-click menu)
1. Add a breakpoint on
the line you’re
interested in.
_CrtDumpMemoryLeaks()
Performs leak checking where called. You want to place this call at all
possible exits of your app.
_CrtSetDbgFlag ()
Sets debugging flags for the C run-time library.
• Including crtdbg.h, you map the malloc and free functions to their
Debug versions, _malloc_dbg and _free_dbg, which keep track of
memory allocation and deallocation
• Without #define _CRTDBG_MAP_ALLOC:
• Memory allocation number (inside curly braces)
• Block type (normal, client or CRT)
• Memory location in hex
• Size of block in bytes
• Contents of the first 16 bytes in hex
• With it defined you get all the above plus:
• File name
• Line number
Line
Source file Memory Block Memory Block
number
where leak allocation type location size
within
occurred number
source file
_CrtSetBreakAlloc(<allocation number>)
• Sets a breakpoint on a specified object allocation order number
(debug version only).
Drill down through Call Stack window to find the last called function that
belongs to your application. (not a function from a library)