资源描述:
《linux下gdb单步调试(gdb single step debugging under linux)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、linux下gdb单步调试(GDBsinglestepdebuggingunderLinux)GDBsinglestepdebuggingunderLinuxSetbreakpoint(BreakPoint)Wesetbreakpointswiththebreakcommand.Howmanybreakpointsaresetonthefront?:BreakStopwhenyouenterthespecifiedfunction.InC++,youcanspecifythefunctionnameinclass::functi
2、onorfunction(type,type)format.BreakStopatthespecifiedlinenumber.Break+offsetBreak-offsetStopsatthefrontorbackofthecurrentlinenumberintheoffsetrow.Offisetisanaturalnumber.Breakfilename:linenumStopatthelinenumrowofthesourcefilefilename.Breakfilename:functionStopattheent
3、ranceofthefunctionfunctionofthesourcefilefilename.Break*addressStopatthememoryaddressoftheprogramrunning.BreakWhenthebreakcommanddoesnothaveaparameter,itmeansthatitstopsatthenextinstruction.Break...IfItcanbetheparametermentionedabove.Conditionrepresentstheconditiona
4、ndstopswhentheconditionisestablished.Forexample,intheloopbody,youcansetthebreakifi=100toindicatethestopprogramwhenIis100.Whenyoulookatbreakpoints,youcanusetheinfocommand,asfollows:(Note:nrepresentsbreakpointnumber)Infobreakpoints[n]Infobreak[n]Two.Setobservationpoints(WatchPoi
5、nt)Observationpointsaregenerallyusedtoobservewhetheranexpression(variableisalsoanexpression)haschanged,andifthereisachange,stoptheprogramimmediately.Wehaveseveralwaystosetupobservationpoints:WatchSetanobservationpointfortheexpression(variable)expr.Stoptheprogramimmediate
6、lywhenthereisachangeintheexpressionvalue.RwatchWhentheexpressionofexpr(variable)read,stopprogram.AwatchWhentheexpression(variable)valuesreadorwrittento,stoptheprogram.InfowatchpointsListsalltheobservationpointscurrentlysetup.Three,setthecapturepoint(CatchPoint)Youc
7、ansetupcapturepointstocatchsomeeventswhentheprogramisrunning.Forexample,loadingasharedlibrary(DLL)oranexceptiontoC++.Setthecapturepointintheformof:CatchWheneventoccurs,stopprogram.Eventcanbethefollowing:1,throwanexceptionthrownbyC++.(throwkeyword)2,catchaC++captureofthe
8、exception.(catchkeyword)3,execcallsystemcallexec.(execisakeyw