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