2010-11-27 75 views
1

我不断收到外部库cpp文件中的错误的这些行号,我无法知道我的代码中哪部分会导致此错误。有时它甚至会显示汇编代码块在哪里崩溃...如何在Visual Studio 2008中进行调试

如何获取我自己的代码导致此错误的行?或者至少有一个线索,我的代码的一部分,使这次崩溃...

有时它甚至不告诉任何行号,我真的不明白这种调试模式如何工作。我使用了应用程序验证器,并且它有时会给出一些行号。它看起来像随机告诉我这些东西......我该如何解决这个问题?

这是我所得到的:在这行代码

First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dd4c.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc50.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc50.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dd48.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012d9a8.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc6c.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dcd0.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db5c.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc30.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db48.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db64.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db5c.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db48.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db04.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012da04.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc30.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dcd0.. 

回答

2

使用断点要“暂停”的程序执行。这样你就可以看到程序状态(变量的值等)。

这里有一系列关于如何安装所有东西以获得调试的教程。

+0

啊......我开始明白了,但是现在我对此有不好的感觉,它在`glewInit();崩溃了,我该怎么解决这个问题? – Newbie 2010-11-27 17:01:33

4

的MSVC调试器是非常强大的。你付出的代价是复杂的。

您可以告诉调试器打破任何未处理的异常。这是默认关闭的。在你的情况下,你想打破第一次机会的例外。执行此操作:

转到调试>例外... 在出现的对话框中,选中“C++异常”和“Win32异常”旁边的框。

运行你的程序。发生这些异常时应该中断。

请记住,在MFC内部广泛使用第一次机会异常来在组件之间进行通信。这些都不是错误。但是你会在输出窗口中看到它们。如果他们没有得到处理,那么当它成为一个问题,你必须解决。

相关问题