保存程序状态(Visual Studio 2008)

发布于 2024-11-09 14:09:26 字数 201 浏览 4 评论 0原文

我正在调试(在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

混吃等死 2024-11-16 14:09:26

我不确定 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

一笑百媚生 2024-11-16 14:09:26

您需要的是条件断点...有关更多详细信息,请参阅此网址:

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 with ADPlus 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文