GDB使用手册Word格式.docx

上传人:b****1 文档编号:1442242 上传时间:2023-04-30 格式:DOCX 页数:16 大小:26.20KB
下载 相关 举报
GDB使用手册Word格式.docx_第1页
第1页 / 共16页
GDB使用手册Word格式.docx_第2页
第2页 / 共16页
GDB使用手册Word格式.docx_第3页
第3页 / 共16页
GDB使用手册Word格式.docx_第4页
第4页 / 共16页
GDB使用手册Word格式.docx_第5页
第5页 / 共16页
GDB使用手册Word格式.docx_第6页
第6页 / 共16页
GDB使用手册Word格式.docx_第7页
第7页 / 共16页
GDB使用手册Word格式.docx_第8页
第8页 / 共16页
GDB使用手册Word格式.docx_第9页
第9页 / 共16页
GDB使用手册Word格式.docx_第10页
第10页 / 共16页
GDB使用手册Word格式.docx_第11页
第11页 / 共16页
GDB使用手册Word格式.docx_第12页
第12页 / 共16页
GDB使用手册Word格式.docx_第13页
第13页 / 共16页
GDB使用手册Word格式.docx_第14页
第14页 / 共16页
GDB使用手册Word格式.docx_第15页
第15页 / 共16页
GDB使用手册Word格式.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

GDB使用手册Word格式.docx

《GDB使用手册Word格式.docx》由会员分享,可在线阅读,更多相关《GDB使用手册Word格式.docx(16页珍藏版)》请在冰点文库上搜索。

GDB使用手册Word格式.docx

filefilename

Usefilenameastheprogramtobedebugged.Itisreadforitssymbolsandforthecontentsofpurememory.Itisalsotheprogramexecutedwhenyouusetheruncommand.IfyoudonotspecifyadirectoryandthefileisnotfoundintheGDBworkingdirectory,GDBusestheenvironmentvariablePATHasalistofdirectoriestosearch,justastheshelldoeswhenlookingforaprogramtorun.Youcanchangethevalueofthisvariable,forbothGDBandyourprogram,usingthepathcommand.

使用filename作为要调试的程序。

它的符号表被读取,或者是单一的内存的内容。

它也是你运行run命令时执行的程序。

如果没有指定目录,这一文件也没有在GDB的工作目录中找到,GDB将使用环境变量PATH作为要搜索的目录列表,就像shell查找要运行的程序一样。

你可以改变这一变量的值,用于GDB和你的程序,请使用path命令。

Youcanloadunlinkedobject`.o'

filesintoGDBusingthefilecommand.Youwillnotbeableto"

run"

anobjectfile,butyoucandisassemblefunctionsandinspectvariables.Also,iftheunderlyingBFDfunctionalitysupportsit,youcouldusegdb-writetopatchobjectfilesusingthistechnique.NotethatGDBcanneitherinterpretnormodifyrelocationsinthiscase,sobranchesandsomeinitializedvariableswillappeartogotothewrongplace.Butthisfeatureisstillhandyfromtimetotime.

你可以使用file命令在GDB中载入没有被链接的"

.o"

文件。

你将不可能“运行”一个这样的对象文件,但是你可以反汇编函数和观察变量。

同时,如果内在的BFD功能性地支持它,你可以使用这一技术用gdb-write给对象文件打上补丁。

注意在这种情况下,GDB既不能转换,也不能修改重定向表,所以函数分支和一些已初始化的变量看起来是呆在不合适的地方。

但是这一特征将始终被保留,以备不时之需。

file

filewithnoargumentmakesGDBdiscardanyinformationithasonbothexecutablefileandthesymboltable.

没有参数的file使GDB丢弃可执行程序和符号表中的任何信息。

exec-file[filename]

Specifythattheprogramtoberun(butnotthesymboltable)isfoundinfilename.GDBsearchestheenvironmentvariablePATHifnecessarytolocateyourprogram.Omittingfilenamemeanstodiscardinformationontheexecutablefile.

指定在filename中找到的要运行的程序(不是符号表)。

GDB根据需要查找PATH变量以定位指定的程序。

省略filename意味放弃可执行文件的信息。

symbol-file[filename]

Readsymboltableinformationfromfilefilename.PATHissearchedwhennecessary.Usethefilecommandtogetbothsymboltableandprogramtorunfromthesamefile.

从filename中读符号表信息。

同样地根据需要查找PATH。

使用file命令从同一文件得到符号表和要运行的程序。

symbol-filewithnoargumentclearsoutGDBinformationonyourprogram'

ssymboltable.

symbol-file没有参数时,清除GDB中的程序的符号表信息。

Thesymbol-filecommandcausesGDBtoforgetthecontentsofsomebreakpointsandauto-displayexpressions.Thisisbecausetheymaycontainpointerstotheinternaldatarecordingsymbolsanddatatypes,whicharepartoftheoldsymboltabledatabeingdiscardedinsideGDB.

symbol-file命令让GDB忘记一些断点和auto-display表达式的内容。

这是因为他们可能包含指向内部数据(记录符号和数据类型)的指针(旧的被GDB放弃的符号表的一部分)。

symbol-filedoesnotrepeatifyoupressRETagainafterexecutingitonce.

在执行symbol-file一次之后,如果按下回车键,它并不会重复执行。

WhenGDBisconfiguredforaparticularenvironment,itunderstandsdebugginginformationinwhateverformatisthestandardgeneratedforthatenvironment;

youmayuseeitheraGNUcompiler,orothercompilersthatadheretothelocalconventions.BestresultsareusuallyobtainedfromGNUcompilers;

forexample,usinggccyoucangeneratedebugginginformationforoptimizedcode.

当GDB为一个特别的环境配置好后,它识别这一环境中产生的标准的不分格式的调试信息;

你既可以使用一个GNU的编译器,也可以使用遵循本地习惯的编译器。

最好的选择通常来自GNU的编译器;

比如,使用gcc可以产生优化的代码的调试信息。

Formostkindsofobjectfiles,withtheexceptionofoldSVR3systemsusingCOFF,thesymbol-filecommanddoesnotnormallyreadthesymboltableinfullrightaway.Instead,itscansthesymboltablequicklytofindwhichsourcefilesandwhichsymbolsarepresent.Thedetailsarereadlater,onesourcefileatatime,astheyareneeded.

对大多数对象文件来说,老的SVR3系统使用COFF,symbol-file命令并不马上读取符号表。

而是快速地扫描符号表,找出哪些源文件,还有哪些符号表是存在的。

更多的细节信息将在随后读取,一次读一个所需的源文件。

Thepurposeofthistwo-stagereadingstrategyistomakeGDBstartupfaster.Forthemostpart,itisinvisibleexceptforoccasionalpauseswhilethesymboltabledetailsforaparticularsourcefilearebeingread.(Thesetverbosecommandcanturnthesepausesintomessagesifdesired.SeesectionOptionalwarningsandmessages.)

two-stage的读取策略是让GDB启动更快。

在多数情况下,当一个源文件的符号表细节信息被读取的时候,存在一定的暂停。

(setverbose命令可以让这些暂停显示需要的信息,请看段“可选的警告和消息”)

Wehavenotimplementedthetwo-stagestrategyforCOFFyet.WhenthesymboltableisstoredinCOFFformat,symbol-filereadsthesymboltabledatainfullrightaway.Notethat"

stabs-in-COFF"

stilldoesthetwo-stagestrategy,sincethedebuginfoisactuallyinstabsformat.

我们还没有实现针对COFF的two-stage。

当符号表被存储为COFF格式时,symbol-file立刻完全地读取符号表。

注意“stabs-in-COFF”仍然做two-stage策略,因为调试信息实际上是stab格式的。

symbol-filefilename[-readnow]

filefilename[-readnow]

YoucanoverridetheGDBtwo-stagestrategyforreadingsymboltablesbyusingthe`-readnow'

optionwithanyofthecommandsthatloadsymboltableinformation,ifyouwanttobesureGDBhastheentiresymboltableavailable.

如果你想确定GDB读取了整个符号表,你可以使用“-readnow”选项调整GDB的读取符号表的two-stage策略,这一选项在所有的载入符号表的命令中存在。

core-file[filename]

core

Specifythewhereaboutsofacoredumpfiletobeusedasthe"

contentsofmemory"

.Traditionally,corefilescontainonlysomepartsoftheaddressspaceoftheprocessthatgeneratedthem;

GDBcanaccesstheexecutablefileitselfforotherparts.

指定要用作“内存内容”的coredump文件。

按照惯例,core文件只包含部分产生他们的进程的地址空间;

GDB可以访问可执行文件以得到其他的部分。

core-filewithnoargumentspecifiesthatnocorefileistobeused.

core-file不带参数表示不使用core文件。

NotethatthecorefileisignoredwhenyourprogramisactuallyrunningunderGDB.So,ifyouhavebeenrunningyourprogramandyouwishtodebugacorefileinstead,youmustkillthesubprocessinwhichtheprogramisrunning.Todothis,usethekillcommand(seesectionKillingthechildprocess).

注意core文件在你的程序运行于GDB下时是被忽略的。

所以,如果你正在运行一个程序,而想改为调试一个core文件,那么你必须杀死程序运行的进程。

要做这一事情,使用kill命令(请看段“杀死子进程”)。

add-symbol-filefilenameaddress

add-symbol-filefilenameaddress[-readnow]

add-symbol-filefilename-ssectionaddress...

Theadd-symbol-filecommandreadsadditionalsymboltableinformationfromthefilefilename.Youwouldusethiscommandwhenfilenamehasbeendynamicallyloaded(bysomeothermeans)intotheprogramthatisrunning.addressshouldbethememoryaddressatwhichthefilehasbeenloaded;

GDBcannotfigurethisoutforitself.Youcanadditionallyspecifyanarbitrarynumberof`-ssectionaddress'

pairs,togiveanexplicitsectionnameandbaseaddressforthatsection.Youcanspecifyanyaddressasanexpression.

add-symbol-file命令从filename中读取增加的符号表信息。

你将在filename被动态载入运行中的程序(通过一些其他的途径)时使用这一命令。

address是文件被载入时的地址;

GDB不能指出这一点。

你可以指定任意数量的“-ssectionaddress”对,以给出显式的段名和基地址。

你可以把address指定为表达式。

Thesymboltableofthefilefilenameisaddedtothesymboltableoriginallyreadwiththesymbol-filecommand.Youcanusetheadd-symbol-filecommandanynumberoftimes;

thenewsymboldatathusreadkeepsaddingtotheold.Todiscardalloldsymboldatainstead,usethesymbol-filecommandwithoutanyarguments.

filename的符号表被增加到使用symbol-file命令读取的符号表中。

你可以任意次地使用add-symbol-file命令:

新的符号就这样被增加到旧的之上。

要丢弃所有旧的符号数据,使用不带参数的symbol-file命令。

Althoughfilenameistypicallyasharedlibraryfile,anexecutablefile,orsomeotherobjectfilewhichhasbeenfullyrelocatedforloadingintoaprocess,youcanalsoloadsymbolicinformationfromrelocatable`.o'

files,aslongas:

虽然filename通常是一个共享库文件,一个可执行文件,或者其他为了载入进程而完全重分配的对象文件,你也可以从可重定位的“.o”文件中载入符号信息。

只要:

?

thefile'

ssymbolicinformationrefersonlytolinkersymbolsdefinedinthatfile,nottosymbolsdefinedbyotherobjectfiles,

文件的符号信息都在这一文件中,而不指向其他的对象文件。

everysectionthefile'

ssymbolicinformationreferstohasactuallybeenloadedintotheinferior,asitappearsinthefile,and?

youcandeterminetheaddressatwhicheverysectionwasloaded,andprovidethesetotheadd-symbol-filecommand.

文件符号信息有关的每个段实际上已被载入inferior,就像在文件中显示的一样。

并且你可以决定每个段载入的地址,提供它们给add-symbol-file命令。

Someembeddedoperatingsystems,likeSunChorusandVxWorks,canloadrelocatablefilesintoanalreadyrunningprogram;

suchsystemstypicallymaketherequirementsaboveeasytomeet.However,it'

simportanttorecognizethatmanynativesystemsusecomplexlinkprocedures(.linkoncesectionfactoringandC++constructortableassembly,forexample)thatmaketherequirementsdifficulttomeet.Ingeneral,onecannotassumethatusingadd-symbol-filetoreadarelocatableobjectfile'

ssymbolicinformationwillhavethesameeffectaslinkingtherelocatableobjectfileintotheprograminthenormalway.

一些嵌入式系统,比如SunChorus和VxWorks,可以载入可重定位的文件到一个已经运行的系统;

这些系统可以让需求很容易地得到满足。

然而,要认识到的重要的一点是,许多本地系统使用复杂的链接过程(比如.linkonce段因子和C++构造表的装配),而让需求很难得到满足。

通常来说,我们不能假定使用add-symbol-file读取一个可重定位的对象文件的符号信息,和链接这一对象文件到程序是一样的效果。

add-symbol-filedoesnotrepeatifyoupressRETafterusingit.

add-symbol-file在你使用它后按下回车时,并不重复执行。

add-symbol-file-from-memoryaddress

Loadsymbolsfromthegivenaddressinadynamicallyloadedobjectfilewhoseimageismappeddirectlyintotheinferior'

smemory.Forexample,theLinuxkernelmapsasyscallDSOintoeachprocess'

saddressspace;

thisDSOprovideskernel-specificcodeforsomesystemcalls.Thear

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 营销活动策划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2