在调试器中设置符号服务器
¥Setting Up Symbol Server in Debugger
调试符号可以让你获得更好的调试会话。它们具有有关可执行文件和动态库中包含的函数的信息,并为你提供获取干净调用堆栈的信息。符号服务器允许调试器自动加载正确的符号、二进制文件和源代码,而无需强迫用户下载大型调试文件。该服务器的功能类似于 微软的符号服务器,因此那里的文档可能很有用。
¥Debug symbols allow you to have better debugging sessions. They have information about the functions contained in executables and dynamic libraries and provide you with information to get clean call stacks. A Symbol Server allows the debugger to load the correct symbols, binaries and sources automatically without forcing users to download large debugging files. The server functions like Microsoft's symbol server so the documentation there can be useful.
请注意,由于已发布的 Electron 版本经过了大量优化,因此调试并不总是那么容易。调试器将无法向你显示所有变量的内容,并且由于内联、尾调用和其他编译器优化,执行路径可能看起来很奇怪。唯一的解决方法是构建一个未优化的本地构建。
¥Note that because released Electron builds are heavily optimized, debugging is not always easy. The debugger will not be able to show you the content of all variables and the execution path can seem strange because of inlining, tail calls, and other compiler optimizations. The only workaround is to build an unoptimized local build.
Electron 的官方符号服务器 URL 是 https://symbols.electronjs.org。你不能直接访问此 URL,必须将其添加到调试工具的符号路径中。在下面的示例中,使用本地缓存目录来避免重复从服务器获取 PDB。将 c:\code\symbols
替换为计算机上适当的缓存目录。
¥The official symbol server URL for Electron is
https://symbols.electronjs.org.
You cannot visit this URL directly, you must add it to the symbol path of your
debugging tool. In the examples below, a local cache directory is used to avoid
repeatedly fetching the PDB from the server. Replace c:\code\symbols
with an
appropriate cache directory on your machine.
在 Windbg 中使用符号服务器
¥Using the Symbol Server in Windbg
Windbg 符号路径配置有以星号字符分隔的字符串值。要仅使用 Electron 符号服务器,请将以下条目添加到符号路径中(注意:如果你希望下载符号位于不同的位置,则可以将 c:\code\symbols
替换为计算机上的任何可写目录):
¥The Windbg symbol path is configured with a string value delimited with asterisk
characters. To use only the Electron symbol server, add the following entry to
your symbol path (Note: you can replace c:\code\symbols
with any writable
directory on your computer, if you'd prefer a different location for downloaded
symbols):
SRV*c:\code\symbols\*https://symbols.electronjs.org
使用 Windbg 菜单或键入 .sympath
命令在环境中将此字符串设置为 _NT_SYMBOL_PATH
。如果你还想从 Microsoft 的符号服务器获取符号,则应首先列出:
¥Set this string as _NT_SYMBOL_PATH
in the environment, using the Windbg menus,
or by typing the .sympath
command. If you would like to get symbols from
Microsoft's symbol server as well, you should list that first:
SRV*c:\code\symbols\*https://msdl.microsoft.com/download/symbols;SRV*c:\code\symbols\*https://symbols.electronjs.org
在 Visual Studio 中使用符号服务器
¥Using the symbol server in Visual Studio
故障排除:符号不会加载
¥Troubleshooting: Symbols will not load
在 Windbg 中键入以下命令来打印符号未加载的原因:
¥Type the following commands in Windbg to print why symbols are not loading:
> !sym noisy
> .reload /f electron.exe