调试本机代码Debugging Native Code

本节讲述本机应用程序的一些常见调试问题和调试技术。The section covers some common debugging problems and techniques for native applications. 本节阐述的技术属于高级别技术。The techniques covered in this section are high-level techniques. 有关使用 Visual Studio 调试器的机制,请参阅第一次查看调试器)。For the mechanics of using the Visual Studio debugger, see First look at the debugger).

本节内容In This Section

如何:调试优化的代码提供调试优化代码的提示,具体而言,调试优化的程序版本的原因,调试和发布配置的默认优化设置,以及查找只出现在优化代码中的 bug 的提示(启用调试生成配置中的优化。How to: Debug 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).

DebugBreak 和 __debugbreak介绍 Win32 DebugBreak 函数,并提供指向平台 SDK 中的参考主题的链接。DebugBreak and __debugbreak Describes the Win32 DebugBreak function and provides a link to its reference topic in the Platform SDK. 还描述了 __debugbreak 内部。Also describes the __debugbreak intrinsic.

C/C++断言讨论断言语句,它们的工作原理、使用它们的好处(捕获逻辑错误、检查操作的结果和测试错误条件)、它们与 _DEBUG 的交互以及 Visual StudioVisual Studio 中支持的断言类型。C/C++ Assertions 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 StudioVisual Studio.

如何:调试内联程序集代码提供有关使用 "反汇编" 窗口查看程序集指令和 "寄存器" 窗口以查看寄存器内容的简短说明,并提供指向有关这些窗口的主题的链接。How to: Debug 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.

MFC 调试技术链接到 MFC 程序的调试技术,包括: afxDebugBreak,跟踪宏,检测 MFC 中的内存泄漏,MFC 断言,并减小 MFC 调试生成的大小。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 调试技术链接到 C 运行时库的调试技术,包括使用 CRT 调试库、用于报告的宏、malloc 和 _malloc_dbg 之间的差异、编写调试挂钩函数以及 CRT 调试堆。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.

调试本机代码常见问题解答提供有关调试C++程序的常见问题的解答Debugging Native Code FAQs Provides answers to frequently asked questions about debugging C++ programs

COM 和 ActiveX 调试提供有关调试 COM 和 ActiveX 应用程序的信息,包括可用于 COM 和 ActiveX 调试的工具。COM and ActiveX Debugging Provides information on debugging COM and ActiveX applications, including tools you can use for COM and ActiveX debugging.

如何:调试插入的代码提供有关调试使用特性的代码的指南。How to: Debug 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.

演练:调试并行应用程序介绍如何使用 "并行任务" 和 "并行堆栈" 工具窗口调试并行应用程序。Walkthrough: Debugging a Parallel Application Describes how to use the Parallel Tasks and Parallel Stacks tool windows to debug a parallel application.

"准备调试C++项目" 提供了一些主题的链接,这些主题描述如何调试由C++项目模板创建的本机项目类型。Prepare to debug C++ projects Provides links to topics that describe how to debug the native project types created by the C++ project templates.

调试 DLL 项目提供有关如何调试本机和托管的 Dll 的信息。Debugging DLL Projects Provides information on how to debug native and managed DLLs.

首先查看调试器提供指向调试文档的较大章节的链接。First look at the debugger Provides links to the larger sections of the debugging documentation. 涉及的信息包括:调试器的新增功能、设置和准备、断点、处理异常、编辑和继续、调试托管代码、调试本机代码、调试 SQL 以及用户界面参考。Information includes what's new in the debugger, settings and preparation, breakpoints, handling exceptions, edit and continue, debugging managed code, debugging native code, debugging SQL, and the user interface references.

请参阅See also