历史调试(C#、Visual Basic、C++)Historical debugging (C#, Visual Basic, C++)

历史调试是取决于 IntelliTrace 所收集信息的调试模式。Historical debugging is a mode of debugging that depends on the information collected by IntelliTrace. 它允许你向前和前后移动应用程序的执行,并检查其状态。It allows you to move backward and forward through the execution of your application and inspect its state.

可以在 Visual Studio 企业版(但不可在专业版或社区版)中使用 IntelliTrace。You can use IntelliTrace in Visual Studio Enterprise edition (but not the Professional or Community editions).

为什么要使用历史调试?Why use historical debugging?

设置断点来查找 Bug 是一件没有太多确定性的事。Setting breakpoints to find bugs can be a rather hit-or-miss affair. 在你怀疑代码中可能存在 Bug 的位置附近设置断点,然后在调试器中运行应用程序,希望断点发挥作用,执行中断的位置就可以揭露 Bug 的来源。You set a breakpoint close to the place in your code where you suspect the bug to be, then run the application in the debugger and hope your breakpoint gets hit, and that the place where execution breaks can reveal the source of the bug. 如果不起作用,需要在代码的其他位置尝试设置一个断点,然后重新运行调试器,反复执行测试步骤,直到找到问题。If not, you'll have to try setting a breakpoint somewhere else in the code and rerun the debugger, executing your test steps over and over until you find the problem.

设置断点setting a breakpoint

可以使用 IntelliTrace 和历史调试,在你的应用程序中四处漫游,以查看其状态 (调用堆栈和局部变量),而无需设置断点、重新启动调试、重复测试步骤。You can use IntelliTrace and historical debugging to roam around in your application and inspect its state (call stack and local variables) without having to set breakpoints, restart debugging, and repeat test steps. 这可以为你节省大量时间,特别是在 Bug 位于需要很长时间才能完成执行的测试方案的深处时。This can save you a lot of time, especially when the bug is located deep in a test scenario that takes a long time to execute.

如何开始使用历史调试?How do I start using historical debugging?

默认启用 IntelliTrace。IntelliTrace is on by default. 你需要确定感兴趣的事件和函数调用,以及是否希望查看完整应用程序状态的快照。All you have to do is decide which events and function calls are of interest to you, and whether you want to view snapshots of your full application state. 要详细了解如何定义想查看的内容,请参阅 IntelliTrace 功能For more information about defining what you want to look for, see IntelliTrace Features. 功能支持因语言和应用类型而异。Feature support varies by language and app type.