rtems-gdb-stub

  • 格式:pdf
  • 大小:106.38 KB
  • 文档页数:10

GDBAgentforRTEMSTillStraumann3/14/2005;lastmodified7/29/2008

Contents1IntroductionandFeatures11.1Architecture...........................11.2Multithreading..........................21.3CexpSupport...........................21.4SupportedTargets........................21.5SupportedConnectionMethods................31.6GDBPatches...........................3

2Building33DebuggingSession53.1Prerequisites...........................53.2StartingtheDebuggingAgent.................63.3ConnectingtotheTarget....................63.3.1SharingtheConsoleSerialLine............73.4SwitchingThreadContext...................73.5ExecutingSubroutinesontheTarget.............83.6DDDNote.............................9

4RTEMSSpecificGDBCommands95ExampleSession9

1IntroductionandFeaturesThisdocumentcoversversion1.5ofthetargetagent.1.1ArchitectureThisgdbstubisanimplementationoftheremoteendoftheGDBremoteprotocolforaRTEMStarget.Unlikeotherstubsavailablefor

1RTEMS(e.g.,them68kimplementation),thisversiondoesNOTrunat‘exception’levelbutisintendedtobelessintrusive.It’sprimaryuseisdebuggingofuser-level/applicationcoderatherthanthekernelit-self(kerneldebuggingisstillpossibletoacertainextentbutthestubessentiallyneedsafunctionalandinitializedsystemtooperate).Thestubrunsasa‘daemontask’executingdebuggingcommandsasdemandedbythehostgdb.Unlikea‘low-levelstub’whichinter-rupts/stopsthetargetsystemasawholewhiletalkingtogdb,thisimplementationonlyaffectstheexecutionofoneormultiple‘targetthreads’leavingothertasksalone.Asaconsequence,itispossibletouseTCP/IPasacommunicationprotocol(nobreakpointsinnetworkingmustbeset,though!).

1.2MultithreadingGdbsemanticsexpectthetargetsystemtobe‘interrupted’or‘stopped’whilelisteningtogdbcommands.Thisimplementation,OTOH,at-temptstobeaslittleintrusiveaspossible.Forthispurpose,alistof‘stopped’tasksismaintainedinternally.Tasksareinterruptedonlyasaresultofhittingabreakpoint,incurringanexceptionoranexplicitrequestbythedebugger.Interruptedtaskscanbeinspectedasusual(stackframe,registercontentsetc.)andcanbe‘continued/resumed’.Only‘stopped’taskscanbeinspected-theotherscontinueexecutingnormally.Thestubalsocreatesaspecialhelpertaskcontextwhichisalwaysinterruptedwhenthetargetisstopped,henceitispossibletodonon-taskrelatedwork(inspect/changememory,disassemble,...)withouthavingtostopanapplicationtask.

1.3CexpSupportApatchto‘gdb’isprovidedextendingtheremoteprotocolinordertosupportloadablemodules.Gdbcaninquirethelistofcurrentlyloadedmodulesandtheirsectionaddressesaswellasload/unloadadditionalmodulesonthefly.

1.4SupportedTargetsWhilemanypartsofthestubareintendedtobeportableandtarget-architectureindependent,thereareafewpiecesofcodewhichareBSP/CPUdependent.Currently,low-levelsupporthasbeenimple-mentedforthei386/pc386,m68k/coldfireandpowerpc/shared(andderived-shouldprobablyworkonany‘new-exceptionprocessing’ppcBSP)BSPs.

2Addingsupportforanewtargetshouldnotbeextremelyhard.Itmainlyconsistsofwritingtworoutinesforpacking/unpackingregistervaluesintoanarrayformattedasexpectedbygdb.Also,alow-levelexceptionhandlerneedstobewritten(mostlyformappingexceptioncodestosignalnumbers).E.g.,thei386/pc386specificfileconsistsof400linesofquitestraightforwardcode.

1.5SupportedConnectionMethodsOneofthestrengthsofthegdbremoteprotocolisitssimplicitywhichmakesitpossibletousemanycharacter-streambasedI/Omethodsforexchangingmessages.Currently,thestubsupportsTCP/IP,serialportcommunicationviaRTEMS’termiosdriverandplain“dumb”characterdevicesaslongastheycanbeaccessedviathefile-system(/dev/xzy).

1.6GDBPatchesOneimportantdesigngoalwasnothavingtopatchgdbitself.Unfor-tunately,itwasnotcompletelypossibletomeetthisgoal.However,thenecessarypatchesarebelievedtobeassmallandasmodularaspossible.

•Asmallpatchisneededtofixabug[hasbeensubmittedasGDBbug#2029butto-date,Idon’tknowifithasbeenmerged]inthepowerpcstackunwinding.

•Asmallpatchisneededtomakeitpossibletoobtainthelistoftasksrunningonthetargetwithoutinterruptingandstoppingthemall(whichwouldresultinviolatingdesigngoal#1:onlyin-terrupttasksonrequest[explicitorbreakpoint]).

•Anadditionalpatchaddsanewgdbtarget(“rtems-remote”)withprotocolextentionstosupportloadablemodules(CEXP).NotethatthestubworksfinewithoutCEXP,however.

Allofthesepatchesareusuallyavailablewiththesource-codeofthestubasa“.diff”-fileoftheformatgdb--.diff.

2BuildingFortheprerequisitesconsulttable1•Changedirectorytothegdbsourcetopdir,createabuildsub-directory(nameofyourchoice),chdirthereandconfigure(be-sides‘powerpc’,the‘i386’and’m68k’CPUsaresupportedandthecross-debuggermaybeconfiguredaccordingly)1: