Windows Symbol Files

Windows Symbol Files

1.什么是Symbol File?

Symbol files hold a variety of data which are not actually needed when running the binaries(Dll,EXE...), but which could be very useful in the debugging process(It´s a good partner for VC6++ and WinDbg).

通俗的说,Symbol File是包含了相关二进制文件(EXE,DLL)调试信息的一种文件,它以.pdb为扩展名,比如WinXP下有一个GDI32.dll,那么微软在编 译该DLL的时候会产生一个GDI32.pdb文件,程序员有了这个PDB文件愿意的话就可以用它来调试,跟踪到GDI32.dll的内部去!

该文件和二进制文件的编译版本密切相关,比如你修改了DLL的输出函数等,再编译该DLL那么原先的PDB文件就过时了,不能再胜任调试的重担了,这时候你需要的是修改后编译产生的PDB文件.

大家在用VC6编译的时候会发现PDB文件会存在于Debug/Release目录下(关于如何产生Release版本的PDB请参看4.如何在VC6++中编译产生Release版本的二进制文件的PDB文件?).

Typically, symbol files might contain:

1.全局变量(Global variables)

2.局部变量(Local variables)

3.函数名和它们的入口地址(Function names and the addresses of their entry points)

4.FPO data(frame pointer omission),frame pointer是一种用来在调用堆栈(Call stack)中找到下一 个将要被调用的函数的数据结构源代码的行序号(Source-line numbers)


Symbol Files

A symbol file contains the same debugging information that an executable file would contain. However, the information is stored in a debug (.dbg) file or a program database (.pdb), rather than the executable file. Therefore, you can install only the symbol files you will need during debugging. This reduces the file size of the executable, saving load time and disk storage.

The operating system dynamic-link libraries (DLL) have associated symbol files. These .pdb files are not installed during installation. To install the system symbol files, create a directory on your hard disk, and copy the files from your system installation compact disc (CD). The symbol files are located in the SUPPORT\DEBUG\I386\SYMBOLS directory tree.

A debug symbol is information that tells you which programming-language constructs generated a specific piece of machine code in a given executable module. Sometimes the symbolic information is compiled together with the module's binary file, or distributed in separate file, or simply discarded during the compilation and/or linking. This information enables a person using a symbolic debugger to gain additional information about the binary, such as the names of variables and routines from the original source code. This information is sometimes extremely helpful while trying to investigate and fix a crashing application or any other fault.

When the debug symbols are embedded in the binary itself, the file can then grow significantly larger (sometimes by several megabytes). To avoid this extra size, modern compilers and early mainframe debugging systems output the symbolic information into a separate file (for Microsoft compilers, this file is called a PDB file). Some companies ship the PDB on their CD/DVD to enable troubleshooting and other companies (like Microsoft) have special online servers from which it's possible to download the debug symbols separately. When using Microsoft's WinDBG debugger it automatically downloads debug symbols for Windows DLLs on demand as they are needed. However, the PDB debug symbols that Microsoft distributes are only partial (they include only public functions, global variables and their data types). Other vendors, such as the Mozilla Corporation have similar infrastructure but their symbol server distributes full debug information, making it easier to find bugs because this data contains all functions, all variables and all data types.

In 2008, Microsoft also started to offer the source code for certain components (most of the .NET Framework for instance) to make debugging easier and some debuggers, like WinDbg and Microsoft Visual Studio, will actually download the code on demand in a fashion similar to how debug symbols are retrieved (there is a special source server that serves the requested code). Mozilla operated such a source server several years before this.

转自 http://hi.baidu.com/donghaozheng/blog/item/af5f0d3b628eb7e214cecb6c.html
posted @ 2009-09-22 12:39  ttthinks  阅读(1486)  评论(0编辑  收藏  举报