符号和符号文件Symbols and Symbol Files

链接器创建.exe 和.dll 文件的链接的应用程序、 库、 驱动程序或操作系统,还会创建一个名为其他文件数符号文件When applications, libraries, drivers, or operating systems are linked, the linker that creates the .exe and .dll files also creates a number of additional files known as symbol files.

符号文件包含的各种数据的实际并不需要时运行的二进制文件,但这可能在调试过程中非常有用。Symbol files hold a variety of data which are not actually needed when running the binaries, but which could be very useful in the debugging process.

通常情况下,可能包含符号文件:Typically, symbol files might contain:

  • 全局变量Global variables

  • 本地变量Local variables

  • 函数名称和其入口点的地址Function names and the addresses of their entry points

  • 帧指针省略 (FPO) 记录Frame pointer omission (FPO) records

  • 源行号Source-line numbers

这些项的每个调用时,分别符号Each of these items is called, individually, a symbol. 例如,单个符号文件 Myprogram.pdb 可能包含多个几百个符号,包括全局变量和函数名称和数百个本地变量。For example, a single symbol file Myprogram.pdb might contain several hundred symbols, including global variables and function names and hundreds of local variables. 通常情况下,软件公司发布的每个符号文件的两个版本: 完整符号文件同时包含这两者公共符号私有符号,和减少 (去除) 文件包含唯一公共符号。Often, software companies release two versions of each symbol file: a full symbol file containing both public symbols and private symbols, and a reduced (stripped) file containing only public symbols. 有关详细信息,请参阅公共和私有符号For details, see Public and Private Symbols.

在调试时,必须确保调试器可以访问与正在调试的目标相关联的符号文件。When debugging, you must make sure that the debugger can access the symbol files that are associated with the target you are debugging. 实时调试和故障转储文件调试需要符号。Both live debugging and debugging crash dump files require symbols. 必须获取你想要调试的代码的正确符号,并将这些符号加载到调试器。You must obtain the proper symbols for the code that you wish to debug, and load these symbols into the debugger.

Windows 符号Windows Symbols

Windows 具有扩展名为.pdb 的文件中保留其符号。Windows keeps its symbols in files with the extension .pdb.

编译器和链接器控制符号格式。The compiler and the linker control the symbol format. 视觉对象C++链接器将所有符号都放入.pdb 文件。The Visual C++ linker, places all symbols into .pdb files.

Windows 操作系统是内置的两个版本。The Windows operating system is built in two versions. 免费生成(或零售生成) 具有相对较小的二进制文件,并已检验版本(或调试版本) 具有更大的二进制文件与代码本身中更多的调试符号。The free build (or retail build) has relatively small binaries, and the checked build (or debug build) has larger binaries, with more debugging symbols in the code itself. 这些生成的每个有其自己的符号文件。Each of these builds has its own symbol files. 在调试时在 Windows 上的目标,必须使用与匹配的目标上的 Windows 生成的符号文件。When debugging a target on Windows, you must use the symbol files that match the build of Windows on the target.

下表列出了几种标准的 Windows 符号树中存在的目录:The following table lists several of the directories which exist in a standard Windows symbol tree:

DirectoryDirectory 包含符号文件Contains Symbol Files for

ACMACM

Microsoft 音频压缩管理器文件Microsoft Audio Compression Manager files

COMCOM

可执行文件 (.com)Executable files (.com)

CPLCPL

控件面板程序Control Panel programs

DLLDLL

动态链接库文件 (.dll)Dynamic-link library files (.dll)

DRVDRV

驱动程序文件 (.drv)Driver files (.drv)

EXEEXE

可执行文件 (.exe)Executable files (.exe)

SCRSCR

屏幕保护程序文件Screen-saver files

SYSSYS

驱动程序文件 (.sys)Driver files (.sys)