VS2008 DEBUG很慢

本文解决了一个关于Visual Studio 2008在调试模式下加载符号异常缓慢的问题。通过调整环境变量_NT_SYMBOL_PATH并清理指定的符号路径,成功解决了调试速度慢的问题。

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.

Debug

 

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.

Debugging , VSTS

 

 

解决方法:


通过分析发现问题是因为 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.

### VSCode 调试性能优化 VSCode 的调试性能可能会受到多种因素的影响,包括编译器优化设置、扩展加载情况以及项目本身的复杂度。以下是针对此问题的一些分析和解决方案: #### 编译器优化与调试的关系 由于编译器优化可能改变生成的代码结构,建议先在未启用优化的情况下调试应用程序并测量其性能,然后再考虑对代码进行优化[^1]。这意味着,在开发阶段应关闭编译器优化选项(如 GCC 中的 `-O0`),以便获得更精确的调试体验。 #### Open vSwitch 性能优化思路借鉴 虽然 Open vSwitch (OVS) 主要用于网络数据包处理,但它的设计理念可以为其他高性能场景提供启发。例如,OVS 将流量分为快速路径(fast path)和慢速路径(slow path)。对于频繁执行的任务,可以通过缓存机制减少重复计算;而对于不常见的操作,则允许稍高的延迟来换取灵活性[^2]。这一理念同样适用于提升 VSCode 调试效率——通过识别瓶颈并将资源集中在核心功能上,从而改善整体表现。 #### 提高VS Code Debugging Performance的具体措施 1. **禁用不必要的插件**: 运行 `code --list-extensions | xargs -L1 code --uninstall-extension` 命令卸载那些当前项目不需要使用的第三方插件。 2. **调整launch.json配置文件**: 如果正在使用C++语言编程的话, 可尝试如下配置以加快启动时间. ```json { "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/build/main.out", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "build" } ] } ``` 3. **利用远程附件模式(Attach Mode)**而非本地启动(Launch Mode),这样可以让程序独立运行于IDE之外,仅当遇到断点时才连接到进程,有效降低开销。 4. **升级LLDB/GDB版本**, 更新的调试工具往往具备更好的兼容性和更高的效能. 5. **审查工作区大小**, 对特别庞大的工程而言, 减少索引范围或者分割成多个子模块有助于缓解内存压力。 6. **定期清理临时文件夹**, 如`.vscode`, `.cache`等目录下的陈旧资料也可能拖累速度。 7. **探索轻量级替代方案**, 当面对极其苛刻的速度需求时, 或许应该重新评估是否继续沿用复杂的集成环境还是转向更为精简的手动流程。 以上方法均旨在帮助开发者找到适合自己的方式去克服VS Code调试过程中可能出现的各种挑战。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值