seb*_*ebf 5 c++ exception-handling visual-studio-debugging visual-studio-2017
我的代码抛出未处理的异常,但Visual Studio中的调试器只会破坏系统抛出的异常.
例如,下面的返回值getaddrinfo
不为零,我的异常应该首先抛出 - 实际上,如果我在第171行放置一个断点,它就会被命中 - 但是调试器只会在调用时中断socket
.
我知道我必须明确地添加自己的类型,否则检查All C++ Exceptions not in this list
,在Exception Settings
,但是这是一个std::exception
我抛出,并且std::exception
被选中.
如何在我的例外情况下自动使Visual Studio调试器中断?
调试器在抛出时中断,但您没有显示调用堆栈中实际上引发异常的最顶层函数。
您所展示的是堆栈中更下方的函数。这表明当当前正在调用的函数返回时,下一行要执行的就是该socket(...)
行。这就是为什么该行上的图标是绿色的小“返回”图标,而不是黄色的“当前正在执行”图标。
右键单击调用堆栈,单击“显示外部代码”,您将看到类似以下内容的内容:
KernelBase.dll!RaiseException(unsigned long dwExceptionCode, unsigned long dwExceptionFlags, unsigned long nNumberOfArguments, const unsigned long * lpArguments) Line 904 C
vcruntime140d.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 136 C++
ConsoleApplication5.exe!main() Line 6 C++
ConsoleApplication5.exe!invoke_main() Line 64 C++
Run Code Online (Sandbox Code Playgroud)
请注意,它是KernelBase.dll!RaiseException
实际抛出异常的位置。
是的,我同意这不太像 C++,但抛出异常是一种需要复杂代码的机制,所以它是这样发生的。
归档时间: |
|
查看次数: |
709 次 |
最近记录: |