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)
2.如何得到Symbol Files?
要安装Symbol Files请先确定你的OS版本再到微软的网站上去下载相应的Symbol Files安装,安装没有什么特殊的要求,只需要随便安装到一个目录,然后在Windows的环境变量中中设定这个Path(也可以在VC6,WinDbg中设置,这样的话只有Vc6或者是WinDbg自己能看到了…)然后WinDbg,Ntsd,
DrWatson之类的调试软件就可以找到了.
安装Symbol Files就一个原则,请大家注意:
"If you plan to install symbols manually, it is crucial that you remember this basic rule: the symbol files on the host computer are required to match the version of Windows installed on the target computer"
host computer The host computer is the machine that runs the debugging session. In a typical two-system debugging session, the host can be any computer which can be connected to the target computer
target computer The target computer is the machine that has experienced the failure of a software component, system service, an application, or of the operating system. This is the computer that needs to be debugged and is the focus of the debugging session. This can be a computer located within a few feet of the computer on which you run the debugging session, or it can be in a completely different location. Sometimes referred to as the debuggee
6.如何更新Symbols
如果大家用上了WinDbg会发现符号文件(PDB)有多么的重要,可是这些文件都是和本地的OS相关的比如说你的WinXP打了SP补丁的话可能原来的符号文件就会出现不匹配的想象怎么办?网上更新!请在你们的WinDbg的Symbols Path里面输入下面一行:
SRV*D:/Symbols/websymbols*http://msdl.microsoft.com/download/symbols
(红色部分写上你们想保存的本地路径)
如果你不是通过代理上网,那么在你用WinDbg打开一个被调试程序后,输入symchk回车,windbg就会自动的连到微软的网站根据你的机器的情况更新新的PDB文件并保存在上面红色部分的本地路径里面,这样你就可以确保你的符号文件版本和你机器上的文件的版本一致(我指的是系统文件:DLL,SYS...).
如果你是通过代理上网那么你需要配置一下:
注意:http://home.lenovo/proxy.pac是我假设的代理配置脚本地址;10.99.20.26:8080是我假设的代理服务器地址和端口,实战中请根据你自己的情况设置.
1.配置好IE;
2.设置一个环境变量;
该环境变量为:_NT_SYMBOL_PATH;像我这样填写就可以了
3.告诉WinDbg:以后可以去微软网站下载PDB文件了
有任何问题欢迎邮件交流:yangminga@lenovo.com或perdubug@hotmail.com