This documentation is archived and is not being maintained.

Debugging Visual C++

The section covers some common debugging problems and techniques for C and C++ applications. The techniques covered in this section are high-level techniques. For the mechanics of using the Visual Studio debugger with C and C++ programs, see Using the Debugger.

In This Section

Debugging Injected Code
Provides guidance on debugging code that uses attributes. Instructions include how to turn on Source Annotation, how to view injected code, and how to view the disassembly code at the current execution point.
Debugging Optimized Code
Gives tips for debugging optimized code, specifically, why you should debug an unoptimized version of your program, default optimization settings for Debug and Release configurations, and tips for finding bugs that only appear in optimized code (turning on optimization in a Debug build configuration).
Describes the Win32 DebugBreak function and provides a link to its reference topic in the Platform SDK.
Assertions (Assertion Failed Dialog Box)
Discusses assertion statements, how they work, the benefits of using them (catching logic errors, checking results of an operation, and testing error conditions), their interaction with _DEBUG, and the types of assertions supported in Visual Studio.
Detecting and Isolating Memory Leaks
Covers memory leaks and provides links to topics regarding the tools in the debugger, the C Run-Time Library, and MFC for detecting and identifying memory leaks. Links include enabling memory leak detection, interpreting memory block types, setting a breakpoint on a memory allocation number, comparing memory states, and detecting memory leaks in MFC.
Debugging Inline Assembly Code
Provides short instructions on using the Disassembly window to view the assembly instructions and the Registers window to view register contents and provides links to topics regarding those windows.
ATL Debugging Techniques
Links you to debugging techniques for ATL projects, including: debugging QueryInterface calls, tracking reference counts, debugging and error reporting global functions, and debugging and error reporting macros.
MFC Debugging Techniques
Links you to debugging techniques for MFC programs, including: afxDebugBreak, the TRACE macro, detecting memory leaks in MFC, MFC assertions, and reducing the size of MFC Debug builds.
CRT Debugging Techniques
Links you to debugging techniques for the C Run-Time Library, including using the CRT Debug Library, macros for reporting, differences between malloc and _malloc_dbg, writing debug hook functions, and the CRT debug heap.
Debugging an ISAPI Application
Provides information on debugging an ISAPI application, including setup steps, troubleshooting breakpoints, debugging remotely, and tips for getting the Microsoft Internet Information Services (IIS) up and running with your DLL in the Visual Studio debugger.
Debugging Visual C++ FAQs
Provides answers to frequently asked questions about debugging Visual C++ programs.

Related Sections

Debugging Preparation: Visual C++ Project Types
Provides links to topics that describe how to debug the basic project types created by the Visual C++ project templates. Links include: Visual C++ Windows Applications, Visual C++ Console Applications, MFC DLLs, Console Applications Created with Managed Extensions for C++, Class Libraries Created with Managed Extensions, and ASP.NET Web Services Created with Managed Extensions.
Debugging DLLs
Describes debugging DLLs from the project used to create the executable that calls the DLL or debugging DLLs from the project used to create the DLL itself. This section also includes frequently asked questions about debugging DLLs.
Debugging COM and ActiveX
Lists links to sections on debugging COM applications and ActiveX controls, including debugging COM servers, debugging COM clients and servers using RPC debugging, debugging ActiveX controls, test applications, and viewers and spy programs.
Debugging Home Page
Provides links to the larger sections of the debugging documentation. Information includes what's new in the debugger, settings and preparation, breakpoints, handling exceptions, edit and continue, debugging managed code, debugging Visual C++ projects, debugging COM and ActiveX, debugging DLLs, debugging SQL, and the user interface references.