王朝网络
分享
 
 
 

Windows应用程序调试必备的--符号文件(Symbols)

王朝c#·作者佚名  2006-12-16
宽屏版  字体: |||超大  

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

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:

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*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文件了

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
>>返回首页<<
推荐阅读
 
 
频道精选
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有