保存程序状态(Visual Studio 2008)
我正在调试(在 Visual Studio 2008 中)我用 C++ 编写的实用程序。将大量输入文件与我的慢速机器相结合,可能需要 6 个小时以上才能达到我需要观察程序执行是否存在异常情况的程度。
我可能在这里抓住了救命稻草,但是有人知道 Visual Studio 中的功能或插件或类似的东西,我可以在其中保存程序执行状态,以便我可以绕过到达我需要的地方所需的时间吗?
I am debugging (in Visual Studio 2008) a utility I have written in C++. Combining massive input files with my slow machine and it can take upwards of 6 hours to get to the point where I need to watch the program execution for irregularities.
I am probably grasping at straws here, but is anyone aware of feature or plugin or something within Visual Studio or something of the like where I can save program execution state so that I can bypass the time it takes to get where I need to be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定 Visual Studio 中是否有可能做这样的事情,但如果你找不到任何东西,我会尝试使用虚拟机并保存机器的状态。
它可能会非常慢,但从长远来看可能会有所帮助。
祝你好运
I'm not sure of possibilities within Visual Studio for doing such a thing, but if you can't find anything I would try using a Virtual Machine and saving the state of the machine.
It will probably be horribly slow but may help in the long run.
Good luck
您需要的是
条件断点
...有关更多详细信息,请参阅此网址:http://msdn.microsoft.com/en-us/library/7sye83ce%28v=VS.90%29.aspx
这个想法是您知道断点生效的条件是什么,那么当这些条件成立时,断点将触发,暂停执行。然后您可以在早上过来并开始逐步执行代码。
如果您确实想要在某个确切的点引发中断,则可以放入一个编程断点 DebugBreak(),这将导致引发断点异常。 Visual Studio 调试器将捕获它并在此时暂停执行。
或者,启用
gflags
使用ADPlus
运行程序,并在您认为导致问题的代码处抛出未处理的异常。让程序崩溃,ADPlus 将生成进程内存的完整崩溃转储。事实上,您启用了 gflags 意味着您将获得带有漂亮边框的内存分配(通常为 0xCDCCDCD),以便于调试。最后,您还可以使用
DbgHelp.dll
来自 Microsoft 的库,用于生成一个小型转储,该转储可以以编程方式捕获各种级别的信息(不会像上述解决方案那样发生崩溃)。您想要的功能是 MiniDumpWriteDump。您可以使用这些参数编写普通的小型转储或完整内存转储。如果可能的话,这应该从单独的进程完成(您可以在自己的进程中等待句柄)。What you need is a
conditional breakpoint
... see this url for more details:http://msdn.microsoft.com/en-us/library/7sye83ce%28v=VS.90%29.aspx
The idea is that you know what conditions are true for the breakpoint to become valid, then when those conditions are true the breakpoint will trigger, pausing execution. You can then come along in the morning and begin to step through the code.
If you DO have an exact point that you want to cause a break at you can put in a programmatic break point DebugBreak() which will cause a break point exception to be thrown. The Visual Studio debugger will catch it and pause execution at that point.
Alternatively, enable
gflags
run the program withADPlus
and at the point of the code that you think has caused the problem throw an exception which is not handled. Let the program crash and ADPlus will generate a full crash dump of the process memory. The fact that you had gflags enabled means you will get memory allocations with nice borders around them (0xCDCDCDCD
usually) for easy debugging.Finally you can also use the
DbgHelp.dll
library from Microsoft to generate a mini-dump which can capture various levels of information programmatically (without a crash as the solution above entails). The function you want is MiniDumpWriteDump. You can write a normal mini-dump or a full memory dump using the parameters. This should be done from a separate process if possible (you can await the handle in your own process).