Visual Studio考虑“用户代码”? [英] What does Visual Studio consider "User Code"?
问题描述
如果Visual Studio确定第三方DLL, party DLL不是用户代码(如下图所示),那么默认情况下它将停止我的异常,即使稍后处理。这样做不正确不正确;它清楚地解释了用户代码未被处理的异常。但是这是什么让Visual Studio调用一些DLL的用户代码,而其他的没有?
我有一个理论认为,这是因为符号没有加载,列表已加载符号但仍不被视为用户代码。
是的,没有.pdb文件,调试器可以不知道是否是用户代码。这在 MSDN中得到很好的解释文章:
为了区分用户代码和非用户代码,Just My Code查看三件事:DBG文件,PDB文件和优化。
在标准的Debug构建中,关闭优化,并为所有模块创建调试符号。当您运行调试版本时,这些模块被认为是用户代码。但是,如果我调用一个优化的库函数,而不是调试符号,那么它不是用户代码。只是我的代码阻止执行停止在库代码中的断点,这通常不是你有兴趣调试的代码。在断点窗口中,这些断点将显示禁用断点图标。
Suppose I have a function that throws an exception. Suppose this function is called by a third-party DLL, and the third-party DLL will handle the exception I’ve thrown.
If Visual Studio decides that the third-party DLL is not "user code" (as seen in the image below) then it will stop on my exception by default, even though it gets handled later. It isn’t exactly wrong to do so; it clearly explains that the exception was unhandled by user code. But what is it that makes Visual Studio call some DLLs "user code" and others not?
I had a theory that this happens because the symbols aren’t loaded, but there are modules in the list that have loaded symbols but are still not considered "user code".
Yes, without a .pdb file the debugger can't tell whether it is user code or not. It is explained reasonably well in the MSDN article:
To distinguish user code from non-user code, Just My Code looks at three things: DBG Files, PDB files, and optimization.
In a standard Debug build, optimization is turned off and debug symbols are created for all modules. When you run a debug build, those modules are considered to be user code. If I call a library function that is optimized and does not have debug symbols, however, it is not user code. Just My Code prevents execution from stopping at breakpoints in the library code, which is usually not code you are interested in debugging. In the Breakpoints window, those breakpoints will appear with the Disabled Breakpoint icon.
这篇关于Visual Studio考虑“用户代码”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!