织梦CMS - 轻松建站从此开始!

罗索

当前位置: 主页>杂项技术>VC(MFC)>

解决VS2008 调试启动特别慢

jackyhwei 发布于 2016-12-07 10:54 点击:次 
自动安装了WinDbg,并且下载了那些symbol文件之后,VC每次启动debug调试都超级慢,一等就等半天。实在没办法,先用下面的方法把它给干掉。
TAG: 调试  WinDbg  启动慢  

Resolving Very Slow Symbol Loading with VS 2008 during debugging

Recently, I was encountering insanely slow project loading times during debugging in Visual Studio 2008. Interestingly, this only happened while loading the project only in debug mode. Also, during the slow symbol loading time, the status bar at Visual Studio 2008 always showed Loading Symbols For ____.Dll .

To track it down, I enabled logging for the VS 2008 IDE. This can be done by adding the following entries to its configuration file.

1) Navigate to: C:/Program Files/Microsoft Visual Studio 9.0/Common7/IDE   in Windows Explorer

2) Load devenv.exe.config in text editor.

3) Add the following entries into it

  <system.diagnostics>
        <trace autoflush="true" indentsize="4">
            <listeners>
               <add name="myListener" 
type="System.Diagnostics.TextWriterTraceListener, System version=1.0.3300.0, 
Culture=neutral, PublicKeyToken=b77a5c561934e089" 
initializeData="c:/myListener.log" />
               <remove name="Default" />
            </listeners>
        </trace>
    </system.diagnostics>

As per this configuration, the trace log would be saved to C:/myListener.Log. Now I fired up VS 2008 and loaded to project in debug mode to reproduce the issues.

I also ran couple of unit test cases in debug mode which were also not able to load. I opened the trace log and found these exceptions:

[V, 5820, 7, 2008/07/04 14:00:33.412] devenv.exe: DIA thew in retrieving symbols: System.Runtime.InteropServices.COMException (0x806D0005): Exception from HRESULT: 0x806D0005

at Microsoft.VisualStudio.TestTools.Common.Dia2Lib.IDiaDataSource.loadDataForExe(String executable, String searchPath, Object pCallback)

at Microsoft.VisualStudio.TestTools.Common.DiaHelper.GetSymbolsFileName(String imagePath)

Confirmed with the issue was related to loading of Symbols. I realized that I had once set up a dedicated symbol directory on machine at C:/symbols to enable debugging with WinDbg.

I checked the Debugging Options in VS 2008 to see if its trying to load symbols from somewhere else.

Then suddenly, I was reminded that I had once set up a environment variable _NT_SYMBOL_PATH to an Internet location while debugging in WinDbg to enable automatic downloading of symbols.

I originally thought that this setting was only applicable to WinDbg. But I was mistaken. In fact, this setting will be used across by all debuggers (atleast Microsoft debuggers). This is documented here . I was pretty sure that VS 2008 was trying to load symbols from the Internet location and since many of the assemblies in my application didn't had symbols were them, it must have been failing.

To confirm, I fired My Computer -> Properties -> Advanced -> Environment Variables and cleared out the line

_NT_SYMBOL_PATH=srv*c:/mysymbols*http://msdl.microsoft.com/download/symbols;cache*c:/mysymbols

I reloaded the my project in VS 2008 in debug mode and Bingo, the problem was solved :)

While investigating this problem, I came across many other sources which could cause this issue , so I thought I can post it here for the benefit of community. The credit for these tips goes to Azeem Khan who is working with VSTS team at Microsoft.

  • Make sure that you don't have a symbol path specified in VS under Tools | Options | Debugging | Symbols and also, that you don't have the NT_SYMBOL_PATH environment variable set on your machine.
  • Verify that you haven't specified any network shares under the same setting to server that do not exist anymore. This will require timeouts.
  • Specify a local cache for symbols under the same setting. After you have downloaded symbols once from network shares you can disable those locations. Symbol loading will go a lot faster after the first attempt.
  • Do not specify any symbol lookup paths at all either in environment variable and specify paths in the options page but specify that they be used for manual loading. You can then manually load symbols for modules you care about either via the context menu in call stack or the modules window.
  • VS 2008 SP1 has made a few improvements in this area. It allows for canceling loading of symbols as it is happening. This will allow you to get to your debug session much faster. Note that this is currently in Beta.
  • Clearing the breakpoints also serve to solve this problem for some people.

解决方法:


通过分析发现问题是因为 Load Symbol 过慢造成的

将环境变量中的:

_NT_SYMBOL_PATH=srv*c:/mysymbols*http://msdl.microsoft.com/download/symbols;cache*c:/mysymbols

键删除,并重新启动 VS2008 即可,因为此键的存在会使 VS2008 到此键中标记的地址去下载 Symbol ,而造成调试启动的极度下降。

我的情况:

 

通过查找,在环境变量中没有看到_NT_SYMBOL_PATH ,设置SYMBOL的字眼都没有。通过搜索,在C:/WINDOWS/Symbols看到有个DLL的文件夹,里面全部是pdb文件。将dll文件夹改名(因为对这些文件的用途不大了解,删除是不可恢复,所以改名避免删除导致其他错误 ),然后重启VS2008就OK.

(sky04)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/201612/17480.html]
本文出处:CSDN博客 作者:sky04
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容