gpt4 book ai didi

c++ - 如何在visual studio 2008中进行调试

转载 作者:可可西里 更新时间:2023-11-01 11:10:08 26 4
gpt4 key购买 nike

我一直在为外部库 cpp 文件中的错误获取这些行号,我无法知道我的代码的哪一部分导致了这个错误。有时它甚至会在崩溃的地方显示汇编代码片段......

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

有时它甚至不告诉任何行号,我真的不明白这种 Debug模式是如何工作的。我用过application verifier,它有时会给出一些行号。它看起来像是随机告诉我这些事情...我该如何解决这个问题?

这是我得到的:

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..

最佳答案

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

您可以告诉调试器中断任何未处理的异常。这是默认关闭的。在你的情况下,你想打破第一次机会的异常(exception)。这样做:

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

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

请记住,第一次机会异常在 MFC 中广泛用于组件之间的通信。这些不是错误。但是您会在输出窗口中看到它们的报告。如果它们未得到处理,那就是您必须解决的问题。

关于c++ - 如何在visual studio 2008中进行调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4292734/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com