資源描述:
《linux下gdb單步調(diào)試(gdb single step debugging under linux)》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、linux下gdb單步調(diào)試(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