Windows应⽤程序调试必备的--符号⽂件(Symbols)(vc设
置符号表)
Windows Symbol Files
from:
1.什么是Symbol File?
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(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
3.如何在VC6中集成Symbol Files??
1.Open your workspace in VC6++;
2.Open the Options dialog box (Tools->Options);
3.Click the Directoties tab;
4.Click Executable files from the Show directories for drop-down list;
5.Add the path of symbol-files  to path-list;
6.Click OK to finish.
4.如何在VC6++中编译产⽣Release版本的⼆进制⽂件的PDB⽂件?
这是Microsoft的⽅法,实战中为了使得我们的代码被别⼈Copy到其他地⽅也可以编译通过我⼀般⽤#pragma预编译开关来帮助我产⽣我需要的⽂件:
5.Free Build(retail build) and Checked Build(debug build)
Two different builds of each NT-based operating system exist:
The free build (or retail build) of Windows is the end-user version of the operating system. The system and drivers are built with full optimization, debugging asserts are disabled, and debugging information is stripped from the binaries. A free system and driver are smaller and faster, and it uses less memory.
The checked build (or debug build) of Windows serves as a testing and debugging aid in the developing of the operating system and kernel-mode drivers. The checked build contains extra error checking, argument verification, and debugging information that is not available in the free build. A checked system or driver can help isolate and track down driver problems that can cause unpredictable behavior, result in memory leaks, or result in improper device configuration.
Although the checked build provides extra protection, it consumes more memory and disk space than the free build. System and driver performance is slower for the following reasons:
pdb文件阅读器安卓The executables contain symbolic debugging information.
Additional code paths are executed due to parameter checking and output of diagnostic messages for debugging purposes.
6.如何更新Symbols
如果⼤家⽤上了WinDbg会发现符号⽂件(PDB)有多么的重要,可是这些⽂件都是和本地的OS相关的⽐如说你的WinXP打了SP补丁的话可能原来的符号⽂件就会出现不匹配的想象怎么办?⽹上更新!请在你们的WinDbg的Symbols Path⾥⾯输⼊下⾯⼀⾏:
SRV*D:\Symbols\websymbols*msdl.microsoft/download/symbols
(红⾊部分写上你们想保存的本地路径)
如果你不是通过代理上⽹,那么在你⽤WinDbg打开⼀个被调试程序后,输⼊symchk回车,windbg就会⾃动的连到微软的⽹站根据你的机器的情况更新新的PDB⽂件并保存在上⾯红⾊部分的本地路径⾥⾯,这样你就可以确保你的符号⽂件版本和你机器上的⽂件的版本⼀致(我指的是系统⽂件:).
如果你是通过代理上⽹那么你需要配置⼀下:
注意:home.lenovo/proxy.pac是我假设的代理配置脚本地址;10.99.20.26:8080是我假设的代理服务器地址和端⼝,实战中请根据你⾃⼰的情况设置.
1.配置好IE;
2.设置⼀个环境变量;
该环境变量为:_NT_SYMBOL_PATH;像我这样填写就可以了
3.告诉WinDbg:以后可以去微软⽹站下载PDB⽂件了

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。