gdb.texinfo 1.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404
  1. \input texinfo @c -*-texinfo-*-
  2. @c Copyright (C) 1988--2022 Free Software Foundation, Inc.
  3. @c
  4. @c %**start of header
  5. @c makeinfo ignores cmds prev to setfilename, so its arg cannot make use
  6. @c of @set vars. However, you can override filename with makeinfo -o.
  7. @setfilename gdb.info
  8. @c
  9. @c man begin INCLUDE
  10. @include gdb-cfg.texi
  11. @c man end
  12. @c
  13. @settitle Debugging with @value{GDBN}
  14. @setchapternewpage odd
  15. @c %**end of header
  16. @iftex
  17. @c @smallbook
  18. @c @cropmarks
  19. @end iftex
  20. @finalout
  21. @c To avoid file-name clashes between index.html and Index.html, when
  22. @c the manual is produced on a Posix host and then moved to a
  23. @c case-insensitive filesystem (e.g., MS-Windows), we separate the
  24. @c indices into two: Concept Index and all the rest.
  25. @syncodeindex ky fn
  26. @syncodeindex tp fn
  27. @c readline appendices use @vindex, @findex and @ftable,
  28. @c annotate.texi and gdbmi use @findex.
  29. @syncodeindex vr fn
  30. @c !!set GDB manual's edition---not the same as GDB version!
  31. @c This is updated by GNU Press.
  32. @set EDITION Tenth
  33. @c !!set GDB edit command default editor
  34. @set EDITOR /bin/ex
  35. @c THIS MANUAL REQUIRES TEXINFO 4.0 OR LATER.
  36. @c This is a dir.info fragment to support semi-automated addition of
  37. @c manuals to an info tree.
  38. @dircategory Software development
  39. @direntry
  40. * Gdb: (gdb). The GNU debugger.
  41. * gdbserver: (gdb) Server. The GNU debugging server.
  42. @end direntry
  43. @copying
  44. @c man begin COPYRIGHT
  45. Copyright @copyright{} 1988-2022 Free Software Foundation, Inc.
  46. Permission is granted to copy, distribute and/or modify this document
  47. under the terms of the GNU Free Documentation License, Version 1.3 or
  48. any later version published by the Free Software Foundation; with the
  49. Invariant Sections being ``Free Software'' and ``Free Software Needs
  50. Free Documentation'', with the Front-Cover Texts being ``A GNU Manual,''
  51. and with the Back-Cover Texts as in (a) below.
  52. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  53. this GNU Manual. Buying copies from GNU Press supports the FSF in
  54. developing GNU and promoting software freedom.''
  55. @c man end
  56. @end copying
  57. @ifnottex
  58. This file documents the @sc{gnu} debugger @value{GDBN}.
  59. This is the @value{EDITION} Edition, of @cite{Debugging with
  60. @value{GDBN}: the @sc{gnu} Source-Level Debugger} for @value{GDBN}
  61. @ifset VERSION_PACKAGE
  62. @value{VERSION_PACKAGE}
  63. @end ifset
  64. Version @value{GDBVN}.
  65. @insertcopying
  66. @end ifnottex
  67. @titlepage
  68. @title Debugging with @value{GDBN}
  69. @subtitle The @sc{gnu} Source-Level Debugger
  70. @sp 1
  71. @subtitle @value{EDITION} Edition, for @value{GDBN} version @value{GDBVN}
  72. @ifset VERSION_PACKAGE
  73. @sp 1
  74. @subtitle @value{VERSION_PACKAGE}
  75. @end ifset
  76. @author Richard Stallman, Roland Pesch, Stan Shebs, et al.
  77. @page
  78. @tex
  79. {\parskip=0pt
  80. \hfill (Send bugs and comments on @value{GDBN} to @value{BUGURL}.)\par
  81. \hfill {\it Debugging with @value{GDBN}}\par
  82. \hfill \TeX{}info \texinfoversion\par
  83. }
  84. @end tex
  85. @vskip 0pt plus 1filll
  86. Published by the Free Software Foundation @*
  87. 51 Franklin Street, Fifth Floor,
  88. Boston, MA 02110-1301, USA@*
  89. ISBN 978-0-9831592-3-0 @*
  90. @insertcopying
  91. @end titlepage
  92. @page
  93. @ifnottex
  94. @node Top, Summary
  95. @top Debugging with @value{GDBN}
  96. This file describes @value{GDBN}, the @sc{gnu} symbolic debugger.
  97. This is the @value{EDITION} Edition, for @value{GDBN}
  98. @ifset VERSION_PACKAGE
  99. @value{VERSION_PACKAGE}
  100. @end ifset
  101. Version @value{GDBVN}.
  102. Copyright (C) 1988-2022 Free Software Foundation, Inc.
  103. This edition of the GDB manual is dedicated to the memory of Fred
  104. Fish. Fred was a long-standing contributor to GDB and to Free
  105. software in general. We will miss him.
  106. @menu
  107. * Summary:: Summary of @value{GDBN}
  108. * Sample Session:: A sample @value{GDBN} session
  109. * Invocation:: Getting in and out of @value{GDBN}
  110. * Commands:: @value{GDBN} commands
  111. * Running:: Running programs under @value{GDBN}
  112. * Stopping:: Stopping and continuing
  113. * Reverse Execution:: Running programs backward
  114. * Process Record and Replay:: Recording inferior's execution and replaying it
  115. * Stack:: Examining the stack
  116. * Source:: Examining source files
  117. * Data:: Examining data
  118. * Optimized Code:: Debugging optimized code
  119. * Macros:: Preprocessor Macros
  120. * Tracepoints:: Debugging remote targets non-intrusively
  121. * Overlays:: Debugging programs that use overlays
  122. * Languages:: Using @value{GDBN} with different languages
  123. * Symbols:: Examining the symbol table
  124. * Altering:: Altering execution
  125. * GDB Files:: @value{GDBN} files
  126. * Targets:: Specifying a debugging target
  127. * Remote Debugging:: Debugging remote programs
  128. * Configurations:: Configuration-specific information
  129. * Controlling GDB:: Controlling @value{GDBN}
  130. * Extending GDB:: Extending @value{GDBN}
  131. * Interpreters:: Command Interpreters
  132. * TUI:: @value{GDBN} Text User Interface
  133. * Emacs:: Using @value{GDBN} under @sc{gnu} Emacs
  134. * GDB/MI:: @value{GDBN}'s Machine Interface.
  135. * Annotations:: @value{GDBN}'s annotation interface.
  136. * JIT Interface:: Using the JIT debugging interface.
  137. * In-Process Agent:: In-Process Agent
  138. * GDB Bugs:: Reporting bugs in @value{GDBN}
  139. @ifset SYSTEM_READLINE
  140. * Command Line Editing: (rluserman). Command Line Editing
  141. * Using History Interactively: (history). Using History Interactively
  142. @end ifset
  143. @ifclear SYSTEM_READLINE
  144. * Command Line Editing:: Command Line Editing
  145. * Using History Interactively:: Using History Interactively
  146. @end ifclear
  147. * In Memoriam:: In Memoriam
  148. * Formatting Documentation:: How to format and print @value{GDBN} documentation
  149. * Installing GDB:: Installing GDB
  150. * Maintenance Commands:: Maintenance Commands
  151. * Remote Protocol:: GDB Remote Serial Protocol
  152. * Agent Expressions:: The GDB Agent Expression Mechanism
  153. * Target Descriptions:: How targets can describe themselves to
  154. @value{GDBN}
  155. * Operating System Information:: Getting additional information from
  156. the operating system
  157. * Trace File Format:: GDB trace file format
  158. * Index Section Format:: .gdb_index section format
  159. * Debuginfod:: Download debugging resources with @code{debuginfod}
  160. * Man Pages:: Manual pages
  161. * Copying:: GNU General Public License says
  162. how you can copy and share GDB
  163. * GNU Free Documentation License:: The license for this documentation
  164. * Concept Index:: Index of @value{GDBN} concepts
  165. * Command and Variable Index:: Index of @value{GDBN} commands, variables,
  166. functions, and Python data types
  167. @end menu
  168. @end ifnottex
  169. @contents
  170. @node Summary
  171. @unnumbered Summary of @value{GDBN}
  172. The purpose of a debugger such as @value{GDBN} is to allow you to see what is
  173. going on ``inside'' another program while it executes---or what another
  174. program was doing at the moment it crashed.
  175. @value{GDBN} can do four main kinds of things (plus other things in support of
  176. these) to help you catch bugs in the act:
  177. @itemize @bullet
  178. @item
  179. Start your program, specifying anything that might affect its behavior.
  180. @item
  181. Make your program stop on specified conditions.
  182. @item
  183. Examine what has happened, when your program has stopped.
  184. @item
  185. Change things in your program, so you can experiment with correcting the
  186. effects of one bug and go on to learn about another.
  187. @end itemize
  188. You can use @value{GDBN} to debug programs written in C and C@t{++}.
  189. For more information, see @ref{Supported Languages,,Supported Languages}.
  190. For more information, see @ref{C,,C and C++}.
  191. Support for D is partial. For information on D, see
  192. @ref{D,,D}.
  193. @cindex Modula-2
  194. Support for Modula-2 is partial. For information on Modula-2, see
  195. @ref{Modula-2,,Modula-2}.
  196. Support for OpenCL C is partial. For information on OpenCL C, see
  197. @ref{OpenCL C,,OpenCL C}.
  198. @cindex Pascal
  199. Debugging Pascal programs which use sets, subranges, file variables, or
  200. nested functions does not currently work. @value{GDBN} does not support
  201. entering expressions, printing values, or similar features using Pascal
  202. syntax.
  203. @cindex Fortran
  204. @value{GDBN} can be used to debug programs written in Fortran, although
  205. it may be necessary to refer to some variables with a trailing
  206. underscore.
  207. @value{GDBN} can be used to debug programs written in Objective-C,
  208. using either the Apple/NeXT or the GNU Objective-C runtime.
  209. @menu
  210. * Free Software:: Freely redistributable software
  211. * Free Documentation:: Free Software Needs Free Documentation
  212. * Contributors:: Contributors to GDB
  213. @end menu
  214. @node Free Software
  215. @unnumberedsec Free Software
  216. @value{GDBN} is @dfn{free software}, protected by the @sc{gnu}
  217. General Public License
  218. (GPL). The GPL gives you the freedom to copy or adapt a licensed
  219. program---but every person getting a copy also gets with it the
  220. freedom to modify that copy (which means that they must get access to
  221. the source code), and the freedom to distribute further copies.
  222. Typical software companies use copyrights to limit your freedoms; the
  223. Free Software Foundation uses the GPL to preserve these freedoms.
  224. Fundamentally, the General Public License is a license which says that
  225. you have these freedoms and that you cannot take these freedoms away
  226. from anyone else.
  227. @node Free Documentation
  228. @unnumberedsec Free Software Needs Free Documentation
  229. The biggest deficiency in the free software community today is not in
  230. the software---it is the lack of good free documentation that we can
  231. include with the free software. Many of our most important
  232. programs do not come with free reference manuals and free introductory
  233. texts. Documentation is an essential part of any software package;
  234. when an important free software package does not come with a free
  235. manual and a free tutorial, that is a major gap. We have many such
  236. gaps today.
  237. Consider Perl, for instance. The tutorial manuals that people
  238. normally use are non-free. How did this come about? Because the
  239. authors of those manuals published them with restrictive terms---no
  240. copying, no modification, source files not available---which exclude
  241. them from the free software world.
  242. That wasn't the first time this sort of thing happened, and it was far
  243. from the last. Many times we have heard a GNU user eagerly describe a
  244. manual that he is writing, his intended contribution to the community,
  245. only to learn that he had ruined everything by signing a publication
  246. contract to make it non-free.
  247. Free documentation, like free software, is a matter of freedom, not
  248. price. The problem with the non-free manual is not that publishers
  249. charge a price for printed copies---that in itself is fine. (The Free
  250. Software Foundation sells printed copies of manuals, too.) The
  251. problem is the restrictions on the use of the manual. Free manuals
  252. are available in source code form, and give you permission to copy and
  253. modify. Non-free manuals do not allow this.
  254. The criteria of freedom for a free manual are roughly the same as for
  255. free software. Redistribution (including the normal kinds of
  256. commercial redistribution) must be permitted, so that the manual can
  257. accompany every copy of the program, both on-line and on paper.
  258. Permission for modification of the technical content is crucial too.
  259. When people modify the software, adding or changing features, if they
  260. are conscientious they will change the manual too---so they can
  261. provide accurate and clear documentation for the modified program. A
  262. manual that leaves you no choice but to write a new manual to document
  263. a changed version of the program is not really available to our
  264. community.
  265. Some kinds of limits on the way modification is handled are
  266. acceptable. For example, requirements to preserve the original
  267. author's copyright notice, the distribution terms, or the list of
  268. authors, are ok. It is also no problem to require modified versions
  269. to include notice that they were modified. Even entire sections that
  270. may not be deleted or changed are acceptable, as long as they deal
  271. with nontechnical topics (like this one). These kinds of restrictions
  272. are acceptable because they don't obstruct the community's normal use
  273. of the manual.
  274. However, it must be possible to modify all the @emph{technical}
  275. content of the manual, and then distribute the result in all the usual
  276. media, through all the usual channels. Otherwise, the restrictions
  277. obstruct the use of the manual, it is not free, and we need another
  278. manual to replace it.
  279. Please spread the word about this issue. Our community continues to
  280. lose manuals to proprietary publishing. If we spread the word that
  281. free software needs free reference manuals and free tutorials, perhaps
  282. the next person who wants to contribute by writing documentation will
  283. realize, before it is too late, that only free manuals contribute to
  284. the free software community.
  285. If you are writing documentation, please insist on publishing it under
  286. the GNU Free Documentation License or another free documentation
  287. license. Remember that this decision requires your approval---you
  288. don't have to let the publisher decide. Some commercial publishers
  289. will use a free license if you insist, but they will not propose the
  290. option; it is up to you to raise the issue and say firmly that this is
  291. what you want. If the publisher you are dealing with refuses, please
  292. try other publishers. If you're not sure whether a proposed license
  293. is free, write to @email{licensing@@gnu.org}.
  294. You can encourage commercial publishers to sell more free, copylefted
  295. manuals and tutorials by buying them, and particularly by buying
  296. copies from the publishers that paid for their writing or for major
  297. improvements. Meanwhile, try to avoid buying non-free documentation
  298. at all. Check the distribution terms of a manual before you buy it,
  299. and insist that whoever seeks your business must respect your freedom.
  300. Check the history of the book, and try to reward the publishers that
  301. have paid or pay the authors to work on it.
  302. The Free Software Foundation maintains a list of free documentation
  303. published by other publishers, at
  304. @url{http://www.fsf.org/doc/other-free-books.html}.
  305. @node Contributors
  306. @unnumberedsec Contributors to @value{GDBN}
  307. Richard Stallman was the original author of @value{GDBN}, and of many
  308. other @sc{gnu} programs. Many others have contributed to its
  309. development. This section attempts to credit major contributors. One
  310. of the virtues of free software is that everyone is free to contribute
  311. to it; with regret, we cannot actually acknowledge everyone here. The
  312. file @file{ChangeLog} in the @value{GDBN} distribution approximates a
  313. blow-by-blow account.
  314. Changes much prior to version 2.0 are lost in the mists of time.
  315. @quotation
  316. @emph{Plea:} Additions to this section are particularly welcome. If you
  317. or your friends (or enemies, to be evenhanded) have been unfairly
  318. omitted from this list, we would like to add your names!
  319. @end quotation
  320. So that they may not regard their many labors as thankless, we
  321. particularly thank those who shepherded @value{GDBN} through major
  322. releases:
  323. Andrew Cagney (releases 6.3, 6.2, 6.1, 6.0, 5.3, 5.2, 5.1 and 5.0);
  324. Jim Blandy (release 4.18);
  325. Jason Molenda (release 4.17);
  326. Stan Shebs (release 4.14);
  327. Fred Fish (releases 4.16, 4.15, 4.13, 4.12, 4.11, 4.10, and 4.9);
  328. Stu Grossman and John Gilmore (releases 4.8, 4.7, 4.6, 4.5, and 4.4);
  329. John Gilmore (releases 4.3, 4.2, 4.1, 4.0, and 3.9);
  330. Jim Kingdon (releases 3.5, 3.4, and 3.3);
  331. and Randy Smith (releases 3.2, 3.1, and 3.0).
  332. Richard Stallman, assisted at various times by Peter TerMaat, Chris
  333. Hanson, and Richard Mlynarik, handled releases through 2.8.
  334. Michael Tiemann is the author of most of the @sc{gnu} C@t{++} support
  335. in @value{GDBN}, with significant additional contributions from Per
  336. Bothner and Daniel Berlin. James Clark wrote the @sc{gnu} C@t{++}
  337. demangler. Early work on C@t{++} was by Peter TerMaat (who also did
  338. much general update work leading to release 3.0).
  339. @value{GDBN} uses the BFD subroutine library to examine multiple
  340. object-file formats; BFD was a joint project of David V.
  341. Henkel-Wallace, Rich Pixley, Steve Chamberlain, and John Gilmore.
  342. David Johnson wrote the original COFF support; Pace Willison did
  343. the original support for encapsulated COFF.
  344. Brent Benson of Harris Computer Systems contributed DWARF 2 support.
  345. Adam de Boor and Bradley Davis contributed the ISI Optimum V support.
  346. Per Bothner, Noboyuki Hikichi, and Alessandro Forin contributed MIPS
  347. support.
  348. Jean-Daniel Fekete contributed Sun 386i support.
  349. Chris Hanson improved the HP9000 support.
  350. Noboyuki Hikichi and Tomoyuki Hasei contributed Sony/News OS 3 support.
  351. David Johnson contributed Encore Umax support.
  352. Jyrki Kuoppala contributed Altos 3068 support.
  353. Jeff Law contributed HP PA and SOM support.
  354. Keith Packard contributed NS32K support.
  355. Doug Rabson contributed Acorn Risc Machine support.
  356. Bob Rusk contributed Harris Nighthawk CX-UX support.
  357. Chris Smith contributed Convex support (and Fortran debugging).
  358. Jonathan Stone contributed Pyramid support.
  359. Michael Tiemann contributed SPARC support.
  360. Tim Tucker contributed support for the Gould NP1 and Gould Powernode.
  361. Pace Willison contributed Intel 386 support.
  362. Jay Vosburgh contributed Symmetry support.
  363. Marko Mlinar contributed OpenRISC 1000 support.
  364. Andreas Schwab contributed M68K @sc{gnu}/Linux support.
  365. Rich Schaefer and Peter Schauer helped with support of SunOS shared
  366. libraries.
  367. Jay Fenlason and Roland McGrath ensured that @value{GDBN} and GAS agree
  368. about several machine instruction sets.
  369. Patrick Duval, Ted Goldstein, Vikram Koka and Glenn Engel helped develop
  370. remote debugging. Intel Corporation, Wind River Systems, AMD, and ARM
  371. contributed remote debugging modules for the i960, VxWorks, A29K UDI,
  372. and RDI targets, respectively.
  373. Brian Fox is the author of the readline libraries providing
  374. command-line editing and command history.
  375. Andrew Beers of SUNY Buffalo wrote the language-switching code, the
  376. Modula-2 support, and contributed the Languages chapter of this manual.
  377. Fred Fish wrote most of the support for Unix System Vr4.
  378. He also enhanced the command-completion support to cover C@t{++} overloaded
  379. symbols.
  380. Hitachi America (now Renesas America), Ltd. sponsored the support for
  381. H8/300, H8/500, and Super-H processors.
  382. NEC sponsored the support for the v850, Vr4xxx, and Vr5xxx processors.
  383. Mitsubishi (now Renesas) sponsored the support for D10V, D30V, and M32R/D
  384. processors.
  385. Toshiba sponsored the support for the TX39 Mips processor.
  386. Matsushita sponsored the support for the MN10200 and MN10300 processors.
  387. Fujitsu sponsored the support for SPARClite and FR30 processors.
  388. Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware
  389. watchpoints.
  390. Michael Snyder added support for tracepoints.
  391. Stu Grossman wrote gdbserver.
  392. Jim Kingdon, Peter Schauer, Ian Taylor, and Stu Grossman made
  393. nearly innumerable bug fixes and cleanups throughout @value{GDBN}.
  394. The following people at the Hewlett-Packard Company contributed
  395. support for the PA-RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0
  396. (narrow mode), HP's implementation of kernel threads, HP's aC@t{++}
  397. compiler, and the Text User Interface (nee Terminal User Interface):
  398. Ben Krepp, Richard Title, John Bishop, Susan Macchia, Kathy Mann,
  399. Satish Pai, India Paul, Steve Rehrauer, and Elena Zannoni. Kim Haase
  400. provided HP-specific information in this manual.
  401. DJ Delorie ported @value{GDBN} to MS-DOS, for the DJGPP project.
  402. Robert Hoehne made significant contributions to the DJGPP port.
  403. Cygnus Solutions has sponsored @value{GDBN} maintenance and much of its
  404. development since 1991. Cygnus engineers who have worked on @value{GDBN}
  405. fulltime include Mark Alexander, Jim Blandy, Per Bothner, Kevin
  406. Buettner, Edith Epstein, Chris Faylor, Fred Fish, Martin Hunt, Jim
  407. Ingham, John Gilmore, Stu Grossman, Kung Hsu, Jim Kingdon, John Metzler,
  408. Fernando Nasser, Geoffrey Noer, Dawn Perchik, Rich Pixley, Zdenek
  409. Radouch, Keith Seitz, Stan Shebs, David Taylor, and Elena Zannoni. In
  410. addition, Dave Brolley, Ian Carmichael, Steve Chamberlain, Nick Clifton,
  411. JT Conklin, Stan Cox, DJ Delorie, Ulrich Drepper, Frank Eigler, Doug
  412. Evans, Sean Fagan, David Henkel-Wallace, Richard Henderson, Jeff
  413. Holcomb, Jeff Law, Jim Lemke, Tom Lord, Bob Manson, Michael Meissner,
  414. Jason Merrill, Catherine Moore, Drew Moseley, Ken Raeburn, Gavin
  415. Romig-Koch, Rob Savoye, Jamie Smith, Mike Stump, Ian Taylor, Angela
  416. Thomas, Michael Tiemann, Tom Tromey, Ron Unrau, Jim Wilson, and David
  417. Zuhn have made contributions both large and small.
  418. Andrew Cagney, Fernando Nasser, and Elena Zannoni, while working for
  419. Cygnus Solutions, implemented the original @sc{gdb/mi} interface.
  420. Jim Blandy added support for preprocessor macros, while working for Red
  421. Hat.
  422. Andrew Cagney designed @value{GDBN}'s architecture vector. Many
  423. people including Andrew Cagney, Stephane Carrez, Randolph Chung, Nick
  424. Duffek, Richard Henderson, Mark Kettenis, Grace Sainsbury, Kei
  425. Sakamoto, Yoshinori Sato, Michael Snyder, Andreas Schwab, Jason
  426. Thorpe, Corinna Vinschen, Ulrich Weigand, and Elena Zannoni, helped
  427. with the migration of old architectures to this new framework.
  428. Andrew Cagney completely re-designed and re-implemented @value{GDBN}'s
  429. unwinder framework, this consisting of a fresh new design featuring
  430. frame IDs, independent frame sniffers, and the sentinel frame. Mark
  431. Kettenis implemented the @sc{dwarf 2} unwinder, Jeff Johnston the
  432. libunwind unwinder, and Andrew Cagney the dummy, sentinel, tramp, and
  433. trad unwinders. The architecture-specific changes, each involving a
  434. complete rewrite of the architecture's frame code, were carried out by
  435. Jim Blandy, Joel Brobecker, Kevin Buettner, Andrew Cagney, Stephane
  436. Carrez, Randolph Chung, Orjan Friberg, Richard Henderson, Daniel
  437. Jacobowitz, Jeff Johnston, Mark Kettenis, Theodore A. Roth, Kei
  438. Sakamoto, Yoshinori Sato, Michael Snyder, Corinna Vinschen, and Ulrich
  439. Weigand.
  440. Christian Zankel, Ross Morley, Bob Wilson, and Maxim Grigoriev from
  441. Tensilica, Inc.@: contributed support for Xtensa processors. Others
  442. who have worked on the Xtensa port of @value{GDBN} in the past include
  443. Steve Tjiang, John Newlin, and Scott Foehner.
  444. Michael Eager and staff of Xilinx, Inc., contributed support for the
  445. Xilinx MicroBlaze architecture.
  446. Initial support for the FreeBSD/mips target and native configuration
  447. was developed by SRI International and the University of Cambridge
  448. Computer Laboratory under DARPA/AFRL contract FA8750-10-C-0237
  449. ("CTSRD"), as part of the DARPA CRASH research programme.
  450. Initial support for the FreeBSD/riscv target and native configuration
  451. was developed by SRI International and the University of Cambridge
  452. Computer Laboratory (Department of Computer Science and Technology)
  453. under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the DARPA
  454. SSITH research programme.
  455. The original port to the OpenRISC 1000 is believed to be due to
  456. Alessandro Forin and Per Bothner. More recent ports have been the work
  457. of Jeremy Bennett, Franck Jullien, Stefan Wallentowitz and
  458. Stafford Horne.
  459. Weimin Pan, David Faust and Jose E. Marchesi contributed support for
  460. the Linux kernel BPF virtual architecture. This work was sponsored by
  461. Oracle.
  462. @node Sample Session
  463. @chapter A Sample @value{GDBN} Session
  464. You can use this manual at your leisure to read all about @value{GDBN}.
  465. However, a handful of commands are enough to get started using the
  466. debugger. This chapter illustrates those commands.
  467. @iftex
  468. In this sample session, we emphasize user input like this: @b{input},
  469. to make it easier to pick out from the surrounding output.
  470. @end iftex
  471. @c FIXME: this example may not be appropriate for some configs, where
  472. @c FIXME...primary interest is in remote use.
  473. One of the preliminary versions of @sc{gnu} @code{m4} (a generic macro
  474. processor) exhibits the following bug: sometimes, when we change its
  475. quote strings from the default, the commands used to capture one macro
  476. definition within another stop working. In the following short @code{m4}
  477. session, we define a macro @code{foo} which expands to @code{0000}; we
  478. then use the @code{m4} built-in @code{defn} to define @code{bar} as the
  479. same thing. However, when we change the open quote string to
  480. @code{<QUOTE>} and the close quote string to @code{<UNQUOTE>}, the same
  481. procedure fails to define a new synonym @code{baz}:
  482. @smallexample
  483. $ @b{cd gnu/m4}
  484. $ @b{./m4}
  485. @b{define(foo,0000)}
  486. @b{foo}
  487. 0000
  488. @b{define(bar,defn(`foo'))}
  489. @b{bar}
  490. 0000
  491. @b{changequote(<QUOTE>,<UNQUOTE>)}
  492. @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
  493. @b{baz}
  494. @b{Ctrl-d}
  495. m4: End of input: 0: fatal error: EOF in string
  496. @end smallexample
  497. @noindent
  498. Let us use @value{GDBN} to try to see what is going on.
  499. @smallexample
  500. $ @b{@value{GDBP} m4}
  501. @c FIXME: this falsifies the exact text played out, to permit smallbook
  502. @c FIXME... format to come out better.
  503. @value{GDBN} is free software and you are welcome to distribute copies
  504. of it under certain conditions; type "show copying" to see
  505. the conditions.
  506. There is absolutely no warranty for @value{GDBN}; type "show warranty"
  507. for details.
  508. @value{GDBN} @value{GDBVN}, Copyright 1999 Free Software Foundation, Inc...
  509. (@value{GDBP})
  510. @end smallexample
  511. @noindent
  512. @value{GDBN} reads only enough symbol data to know where to find the
  513. rest when needed; as a result, the first prompt comes up very quickly.
  514. We now tell @value{GDBN} to use a narrower display width than usual, so
  515. that examples fit in this manual.
  516. @smallexample
  517. (@value{GDBP}) @b{set width 70}
  518. @end smallexample
  519. @noindent
  520. We need to see how the @code{m4} built-in @code{changequote} works.
  521. Having looked at the source, we know the relevant subroutine is
  522. @code{m4_changequote}, so we set a breakpoint there with the @value{GDBN}
  523. @code{break} command.
  524. @smallexample
  525. (@value{GDBP}) @b{break m4_changequote}
  526. Breakpoint 1 at 0x62f4: file builtin.c, line 879.
  527. @end smallexample
  528. @noindent
  529. Using the @code{run} command, we start @code{m4} running under @value{GDBN}
  530. control; as long as control does not reach the @code{m4_changequote}
  531. subroutine, the program runs as usual:
  532. @smallexample
  533. (@value{GDBP}) @b{run}
  534. Starting program: /work/Editorial/gdb/gnu/m4/m4
  535. @b{define(foo,0000)}
  536. @b{foo}
  537. 0000
  538. @end smallexample
  539. @noindent
  540. To trigger the breakpoint, we call @code{changequote}. @value{GDBN}
  541. suspends execution of @code{m4}, displaying information about the
  542. context where it stops.
  543. @smallexample
  544. @b{changequote(<QUOTE>,<UNQUOTE>)}
  545. Breakpoint 1, m4_changequote (argc=3, argv=0x33c70)
  546. at builtin.c:879
  547. 879 if (bad_argc(TOKEN_DATA_TEXT(argv[0]),argc,1,3))
  548. @end smallexample
  549. @noindent
  550. Now we use the command @code{n} (@code{next}) to advance execution to
  551. the next line of the current function.
  552. @smallexample
  553. (@value{GDBP}) @b{n}
  554. 882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
  555. : nil,
  556. @end smallexample
  557. @noindent
  558. @code{set_quotes} looks like a promising subroutine. We can go into it
  559. by using the command @code{s} (@code{step}) instead of @code{next}.
  560. @code{step} goes to the next line to be executed in @emph{any}
  561. subroutine, so it steps into @code{set_quotes}.
  562. @smallexample
  563. (@value{GDBP}) @b{s}
  564. set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  565. at input.c:530
  566. 530 if (lquote != def_lquote)
  567. @end smallexample
  568. @noindent
  569. The display that shows the subroutine where @code{m4} is now
  570. suspended (and its arguments) is called a stack frame display. It
  571. shows a summary of the stack. We can use the @code{backtrace}
  572. command (which can also be spelled @code{bt}), to see where we are
  573. in the stack as a whole: the @code{backtrace} command displays a
  574. stack frame for each active subroutine.
  575. @smallexample
  576. (@value{GDBP}) @b{bt}
  577. #0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
  578. at input.c:530
  579. #1 0x6344 in m4_changequote (argc=3, argv=0x33c70)
  580. at builtin.c:882
  581. #2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
  582. #3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
  583. at macro.c:71
  584. #4 0x79dc in expand_input () at macro.c:40
  585. #5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
  586. @end smallexample
  587. @noindent
  588. We step through a few more lines to see what happens. The first two
  589. times, we can use @samp{s}; the next two times we use @code{n} to avoid
  590. falling into the @code{xstrdup} subroutine.
  591. @smallexample
  592. (@value{GDBP}) @b{s}
  593. 0x3b5c 532 if (rquote != def_rquote)
  594. (@value{GDBP}) @b{s}
  595. 0x3b80 535 lquote = (lq == nil || *lq == '\0') ? \
  596. def_lquote : xstrdup(lq);
  597. (@value{GDBP}) @b{n}
  598. 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
  599. : xstrdup(rq);
  600. (@value{GDBP}) @b{n}
  601. 538 len_lquote = strlen(rquote);
  602. @end smallexample
  603. @noindent
  604. The last line displayed looks a little odd; we can examine the variables
  605. @code{lquote} and @code{rquote} to see if they are in fact the new left
  606. and right quotes we specified. We use the command @code{p}
  607. (@code{print}) to see their values.
  608. @smallexample
  609. (@value{GDBP}) @b{p lquote}
  610. $1 = 0x35d40 "<QUOTE>"
  611. (@value{GDBP}) @b{p rquote}
  612. $2 = 0x35d50 "<UNQUOTE>"
  613. @end smallexample
  614. @noindent
  615. @code{lquote} and @code{rquote} are indeed the new left and right quotes.
  616. To look at some context, we can display ten lines of source
  617. surrounding the current line with the @code{l} (@code{list}) command.
  618. @smallexample
  619. (@value{GDBP}) @b{l}
  620. 533 xfree(rquote);
  621. 534
  622. 535 lquote = (lq == nil || *lq == '\0') ? def_lquote\
  623. : xstrdup (lq);
  624. 536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
  625. : xstrdup (rq);
  626. 537
  627. 538 len_lquote = strlen(rquote);
  628. 539 len_rquote = strlen(lquote);
  629. 540 @}
  630. 541
  631. 542 void
  632. @end smallexample
  633. @noindent
  634. Let us step past the two lines that set @code{len_lquote} and
  635. @code{len_rquote}, and then examine the values of those variables.
  636. @smallexample
  637. (@value{GDBP}) @b{n}
  638. 539 len_rquote = strlen(lquote);
  639. (@value{GDBP}) @b{n}
  640. 540 @}
  641. (@value{GDBP}) @b{p len_lquote}
  642. $3 = 9
  643. (@value{GDBP}) @b{p len_rquote}
  644. $4 = 7
  645. @end smallexample
  646. @noindent
  647. That certainly looks wrong, assuming @code{len_lquote} and
  648. @code{len_rquote} are meant to be the lengths of @code{lquote} and
  649. @code{rquote} respectively. We can set them to better values using
  650. the @code{p} command, since it can print the value of
  651. any expression---and that expression can include subroutine calls and
  652. assignments.
  653. @smallexample
  654. (@value{GDBP}) @b{p len_lquote=strlen(lquote)}
  655. $5 = 7
  656. (@value{GDBP}) @b{p len_rquote=strlen(rquote)}
  657. $6 = 9
  658. @end smallexample
  659. @noindent
  660. Is that enough to fix the problem of using the new quotes with the
  661. @code{m4} built-in @code{defn}? We can allow @code{m4} to continue
  662. executing with the @code{c} (@code{continue}) command, and then try the
  663. example that caused trouble initially:
  664. @smallexample
  665. (@value{GDBP}) @b{c}
  666. Continuing.
  667. @b{define(baz,defn(<QUOTE>foo<UNQUOTE>))}
  668. baz
  669. 0000
  670. @end smallexample
  671. @noindent
  672. Success! The new quotes now work just as well as the default ones. The
  673. problem seems to have been just the two typos defining the wrong
  674. lengths. We allow @code{m4} exit by giving it an EOF as input:
  675. @smallexample
  676. @b{Ctrl-d}
  677. Program exited normally.
  678. @end smallexample
  679. @noindent
  680. The message @samp{Program exited normally.} is from @value{GDBN}; it
  681. indicates @code{m4} has finished executing. We can end our @value{GDBN}
  682. session with the @value{GDBN} @code{quit} command.
  683. @smallexample
  684. (@value{GDBP}) @b{quit}
  685. @end smallexample
  686. @node Invocation
  687. @chapter Getting In and Out of @value{GDBN}
  688. This chapter discusses how to start @value{GDBN}, and how to get out of it.
  689. The essentials are:
  690. @itemize @bullet
  691. @item
  692. type @samp{@value{GDBP}} to start @value{GDBN}.
  693. @item
  694. type @kbd{quit}, @kbd{exit} or @kbd{Ctrl-d} to exit.
  695. @end itemize
  696. @menu
  697. * Invoking GDB:: How to start @value{GDBN}
  698. * Quitting GDB:: How to quit @value{GDBN}
  699. * Shell Commands:: How to use shell commands inside @value{GDBN}
  700. * Logging Output:: How to log @value{GDBN}'s output to a file
  701. @end menu
  702. @node Invoking GDB
  703. @section Invoking @value{GDBN}
  704. Invoke @value{GDBN} by running the program @code{@value{GDBP}}. Once started,
  705. @value{GDBN} reads commands from the terminal until you tell it to exit.
  706. You can also run @code{@value{GDBP}} with a variety of arguments and options,
  707. to specify more of your debugging environment at the outset.
  708. The command-line options described here are designed
  709. to cover a variety of situations; in some environments, some of these
  710. options may effectively be unavailable.
  711. The most usual way to start @value{GDBN} is with one argument,
  712. specifying an executable program:
  713. @smallexample
  714. @value{GDBP} @var{program}
  715. @end smallexample
  716. @noindent
  717. You can also start with both an executable program and a core file
  718. specified:
  719. @smallexample
  720. @value{GDBP} @var{program} @var{core}
  721. @end smallexample
  722. You can, instead, specify a process ID as a second argument or use option
  723. @code{-p}, if you want to debug a running process:
  724. @smallexample
  725. @value{GDBP} @var{program} 1234
  726. @value{GDBP} -p 1234
  727. @end smallexample
  728. @noindent
  729. would attach @value{GDBN} to process @code{1234}. With option @option{-p} you
  730. can omit the @var{program} filename.
  731. Taking advantage of the second command-line argument requires a fairly
  732. complete operating system; when you use @value{GDBN} as a remote
  733. debugger attached to a bare board, there may not be any notion of
  734. ``process'', and there is often no way to get a core dump. @value{GDBN}
  735. will warn you if it is unable to attach or to read core dumps.
  736. You can optionally have @code{@value{GDBP}} pass any arguments after the
  737. executable file to the inferior using @code{--args}. This option stops
  738. option processing.
  739. @smallexample
  740. @value{GDBP} --args gcc -O2 -c foo.c
  741. @end smallexample
  742. This will cause @code{@value{GDBP}} to debug @code{gcc}, and to set
  743. @code{gcc}'s command-line arguments (@pxref{Arguments}) to @samp{-O2 -c foo.c}.
  744. You can run @code{@value{GDBP}} without printing the front material, which describes
  745. @value{GDBN}'s non-warranty, by specifying @code{--silent}
  746. (or @code{-q}/@code{--quiet}):
  747. @smallexample
  748. @value{GDBP} --silent
  749. @end smallexample
  750. @noindent
  751. You can further control how @value{GDBN} starts up by using command-line
  752. options. @value{GDBN} itself can remind you of the options available.
  753. @noindent
  754. Type
  755. @smallexample
  756. @value{GDBP} -help
  757. @end smallexample
  758. @noindent
  759. to display all available options and briefly describe their use
  760. (@samp{@value{GDBP} -h} is a shorter equivalent).
  761. All options and command line arguments you give are processed
  762. in sequential order. The order makes a difference when the
  763. @samp{-x} option is used.
  764. @menu
  765. * File Options:: Choosing files
  766. * Mode Options:: Choosing modes
  767. * Startup:: What @value{GDBN} does during startup
  768. * Initialization Files:: Initialization Files
  769. @end menu
  770. @node File Options
  771. @subsection Choosing Files
  772. When @value{GDBN} starts, it reads any arguments other than options as
  773. specifying an executable file and core file (or process ID). This is
  774. the same as if the arguments were specified by the @samp{-se} and
  775. @samp{-c} (or @samp{-p}) options respectively. (@value{GDBN} reads the
  776. first argument that does not have an associated option flag as
  777. equivalent to the @samp{-se} option followed by that argument; and the
  778. second argument that does not have an associated option flag, if any, as
  779. equivalent to the @samp{-c}/@samp{-p} option followed by that argument.)
  780. If the second argument begins with a decimal digit, @value{GDBN} will
  781. first attempt to attach to it as a process, and if that fails, attempt
  782. to open it as a corefile. If you have a corefile whose name begins with
  783. a digit, you can prevent @value{GDBN} from treating it as a pid by
  784. prefixing it with @file{./}, e.g.@: @file{./12345}.
  785. If @value{GDBN} has not been configured to included core file support,
  786. such as for most embedded targets, then it will complain about a second
  787. argument and ignore it.
  788. Many options have both long and short forms; both are shown in the
  789. following list. @value{GDBN} also recognizes the long forms if you truncate
  790. them, so long as enough of the option is present to be unambiguous.
  791. (If you prefer, you can flag option arguments with @samp{--} rather
  792. than @samp{-}, though we illustrate the more usual convention.)
  793. @c NOTE: the @cindex entries here use double dashes ON PURPOSE. This
  794. @c way, both those who look for -foo and --foo in the index, will find
  795. @c it.
  796. @table @code
  797. @item -symbols @var{file}
  798. @itemx -s @var{file}
  799. @cindex @code{--symbols}
  800. @cindex @code{-s}
  801. Read symbol table from file @var{file}.
  802. @item -exec @var{file}
  803. @itemx -e @var{file}
  804. @cindex @code{--exec}
  805. @cindex @code{-e}
  806. Use file @var{file} as the executable file to execute when appropriate,
  807. and for examining pure data in conjunction with a core dump.
  808. @item -se @var{file}
  809. @cindex @code{--se}
  810. Read symbol table from file @var{file} and use it as the executable
  811. file.
  812. @item -core @var{file}
  813. @itemx -c @var{file}
  814. @cindex @code{--core}
  815. @cindex @code{-c}
  816. Use file @var{file} as a core dump to examine.
  817. @item -pid @var{number}
  818. @itemx -p @var{number}
  819. @cindex @code{--pid}
  820. @cindex @code{-p}
  821. Connect to process ID @var{number}, as with the @code{attach} command.
  822. @item -command @var{file}
  823. @itemx -x @var{file}
  824. @cindex @code{--command}
  825. @cindex @code{-x}
  826. Execute commands from file @var{file}. The contents of this file is
  827. evaluated exactly as the @code{source} command would.
  828. @xref{Command Files,, Command files}.
  829. @item -eval-command @var{command}
  830. @itemx -ex @var{command}
  831. @cindex @code{--eval-command}
  832. @cindex @code{-ex}
  833. Execute a single @value{GDBN} command.
  834. This option may be used multiple times to call multiple commands. It may
  835. also be interleaved with @samp{-command} as required.
  836. @smallexample
  837. @value{GDBP} -ex 'target sim' -ex 'load' \
  838. -x setbreakpoints -ex 'run' a.out
  839. @end smallexample
  840. @item -init-command @var{file}
  841. @itemx -ix @var{file}
  842. @cindex @code{--init-command}
  843. @cindex @code{-ix}
  844. Execute commands from file @var{file} before loading the inferior (but
  845. after loading gdbinit files).
  846. @xref{Startup}.
  847. @item -init-eval-command @var{command}
  848. @itemx -iex @var{command}
  849. @cindex @code{--init-eval-command}
  850. @cindex @code{-iex}
  851. Execute a single @value{GDBN} command before loading the inferior (but
  852. after loading gdbinit files).
  853. @xref{Startup}.
  854. @item -early-init-command @var{file}
  855. @itemx -eix @var{file}
  856. @cindex @code{--early-init-command}
  857. @cindex @code{-eix}
  858. Execute commands from @var{file} very early in the initialization
  859. process, before any output is produced. @xref{Startup}.
  860. @item -early-init-eval-command @var{command}
  861. @itemx -eiex @var{command}
  862. @cindex @code{--early-init-eval-command}
  863. @cindex @code{-eiex}
  864. Execute a single @value{GDBN} command very early in the initialization
  865. process, before any output is produced.
  866. @item -directory @var{directory}
  867. @itemx -d @var{directory}
  868. @cindex @code{--directory}
  869. @cindex @code{-d}
  870. Add @var{directory} to the path to search for source and script files.
  871. @item -r
  872. @itemx -readnow
  873. @cindex @code{--readnow}
  874. @cindex @code{-r}
  875. Read each symbol file's entire symbol table immediately, rather than
  876. the default, which is to read it incrementally as it is needed.
  877. This makes startup slower, but makes future operations faster.
  878. @item --readnever
  879. @anchor{--readnever}
  880. @cindex @code{--readnever}, command-line option
  881. Do not read each symbol file's symbolic debug information. This makes
  882. startup faster but at the expense of not being able to perform
  883. symbolic debugging. DWARF unwind information is also not read,
  884. meaning backtraces may become incomplete or inaccurate. One use of
  885. this is when a user simply wants to do the following sequence: attach,
  886. dump core, detach. Loading the debugging information in this case is
  887. an unnecessary cause of delay.
  888. @end table
  889. @node Mode Options
  890. @subsection Choosing Modes
  891. You can run @value{GDBN} in various alternative modes---for example, in
  892. batch mode or quiet mode.
  893. @table @code
  894. @anchor{-nx}
  895. @item -nx
  896. @itemx -n
  897. @cindex @code{--nx}
  898. @cindex @code{-n}
  899. Do not execute commands found in any initialization files
  900. (@pxref{Initialization Files}).
  901. @anchor{-nh}
  902. @item -nh
  903. @cindex @code{--nh}
  904. Do not execute commands found in any home directory initialization
  905. file (@pxref{Initialization Files,,Home directory initialization
  906. file}). The system wide and current directory initialization files
  907. are still loaded.
  908. @item -quiet
  909. @itemx -silent
  910. @itemx -q
  911. @cindex @code{--quiet}
  912. @cindex @code{--silent}
  913. @cindex @code{-q}
  914. ``Quiet''. Do not print the introductory and copyright messages. These
  915. messages are also suppressed in batch mode.
  916. @kindex set startup-quietly
  917. @kindex show startup-quietly
  918. This can also be enabled using @code{set startup-quietly on}. The
  919. default is @code{off}. Use @code{show startup-quietly} to see the
  920. current setting. Place @code{set startup-quietly on} into your early
  921. initialization file (@pxref{Initialization Files,,Initialization
  922. Files}) to have future @value{GDBN} sessions startup quietly.
  923. @item -batch
  924. @cindex @code{--batch}
  925. Run in batch mode. Exit with status @code{0} after processing all the
  926. command files specified with @samp{-x} (and all commands from
  927. initialization files, if not inhibited with @samp{-n}). Exit with
  928. nonzero status if an error occurs in executing the @value{GDBN} commands
  929. in the command files. Batch mode also disables pagination, sets unlimited
  930. terminal width and height @pxref{Screen Size}, and acts as if @kbd{set confirm
  931. off} were in effect (@pxref{Messages/Warnings}).
  932. Batch mode may be useful for running @value{GDBN} as a filter, for
  933. example to download and run a program on another computer; in order to
  934. make this more useful, the message
  935. @smallexample
  936. Program exited normally.
  937. @end smallexample
  938. @noindent
  939. (which is ordinarily issued whenever a program running under
  940. @value{GDBN} control terminates) is not issued when running in batch
  941. mode.
  942. @item -batch-silent
  943. @cindex @code{--batch-silent}
  944. Run in batch mode exactly like @samp{-batch}, but totally silently. All
  945. @value{GDBN} output to @code{stdout} is prevented (@code{stderr} is
  946. unaffected). This is much quieter than @samp{-silent} and would be useless
  947. for an interactive session.
  948. This is particularly useful when using targets that give @samp{Loading section}
  949. messages, for example.
  950. Note that targets that give their output via @value{GDBN}, as opposed to
  951. writing directly to @code{stdout}, will also be made silent.
  952. @item -return-child-result
  953. @cindex @code{--return-child-result}
  954. The return code from @value{GDBN} will be the return code from the child
  955. process (the process being debugged), with the following exceptions:
  956. @itemize @bullet
  957. @item
  958. @value{GDBN} exits abnormally. E.g., due to an incorrect argument or an
  959. internal error. In this case the exit code is the same as it would have been
  960. without @samp{-return-child-result}.
  961. @item
  962. The user quits with an explicit value. E.g., @samp{quit 1}.
  963. @item
  964. The child process never runs, or is not allowed to terminate, in which case
  965. the exit code will be -1.
  966. @end itemize
  967. This option is useful in conjunction with @samp{-batch} or @samp{-batch-silent},
  968. when @value{GDBN} is being used as a remote program loader or simulator
  969. interface.
  970. @item -nowindows
  971. @itemx -nw
  972. @cindex @code{--nowindows}
  973. @cindex @code{-nw}
  974. ``No windows''. If @value{GDBN} comes with a graphical user interface
  975. (GUI) built in, then this option tells @value{GDBN} to only use the command-line
  976. interface. If no GUI is available, this option has no effect.
  977. @item -windows
  978. @itemx -w
  979. @cindex @code{--windows}
  980. @cindex @code{-w}
  981. If @value{GDBN} includes a GUI, then this option requires it to be
  982. used if possible.
  983. @item -cd @var{directory}
  984. @cindex @code{--cd}
  985. Run @value{GDBN} using @var{directory} as its working directory,
  986. instead of the current directory.
  987. @item -data-directory @var{directory}
  988. @itemx -D @var{directory}
  989. @cindex @code{--data-directory}
  990. @cindex @code{-D}
  991. Run @value{GDBN} using @var{directory} as its data directory.
  992. The data directory is where @value{GDBN} searches for its
  993. auxiliary files. @xref{Data Files}.
  994. @item -fullname
  995. @itemx -f
  996. @cindex @code{--fullname}
  997. @cindex @code{-f}
  998. @sc{gnu} Emacs sets this option when it runs @value{GDBN} as a
  999. subprocess. It tells @value{GDBN} to output the full file name and line
  1000. number in a standard, recognizable fashion each time a stack frame is
  1001. displayed (which includes each time your program stops). This
  1002. recognizable format looks like two @samp{\032} characters, followed by
  1003. the file name, line number and character position separated by colons,
  1004. and a newline. The Emacs-to-@value{GDBN} interface program uses the two
  1005. @samp{\032} characters as a signal to display the source code for the
  1006. frame.
  1007. @item -annotate @var{level}
  1008. @cindex @code{--annotate}
  1009. This option sets the @dfn{annotation level} inside @value{GDBN}. Its
  1010. effect is identical to using @samp{set annotate @var{level}}
  1011. (@pxref{Annotations}). The annotation @var{level} controls how much
  1012. information @value{GDBN} prints together with its prompt, values of
  1013. expressions, source lines, and other types of output. Level 0 is the
  1014. normal, level 1 is for use when @value{GDBN} is run as a subprocess of
  1015. @sc{gnu} Emacs, level 3 is the maximum annotation suitable for programs
  1016. that control @value{GDBN}, and level 2 has been deprecated.
  1017. The annotation mechanism has largely been superseded by @sc{gdb/mi}
  1018. (@pxref{GDB/MI}).
  1019. @item --args
  1020. @cindex @code{--args}
  1021. Change interpretation of command line so that arguments following the
  1022. executable file are passed as command line arguments to the inferior.
  1023. This option stops option processing.
  1024. @item -baud @var{bps}
  1025. @itemx -b @var{bps}
  1026. @cindex @code{--baud}
  1027. @cindex @code{-b}
  1028. Set the line speed (baud rate or bits per second) of any serial
  1029. interface used by @value{GDBN} for remote debugging.
  1030. @item -l @var{timeout}
  1031. @cindex @code{-l}
  1032. Set the timeout (in seconds) of any communication used by @value{GDBN}
  1033. for remote debugging.
  1034. @item -tty @var{device}
  1035. @itemx -t @var{device}
  1036. @cindex @code{--tty}
  1037. @cindex @code{-t}
  1038. Run using @var{device} for your program's standard input and output.
  1039. @c FIXME: kingdon thinks there is more to -tty. Investigate.
  1040. @c resolve the situation of these eventually
  1041. @item -tui
  1042. @cindex @code{--tui}
  1043. Activate the @dfn{Text User Interface} when starting. The Text User
  1044. Interface manages several text windows on the terminal, showing
  1045. source, assembly, registers and @value{GDBN} command outputs
  1046. (@pxref{TUI, ,@value{GDBN} Text User Interface}). Do not use this
  1047. option if you run @value{GDBN} from Emacs (@pxref{Emacs, ,
  1048. Using @value{GDBN} under @sc{gnu} Emacs}).
  1049. @item -interpreter @var{interp}
  1050. @cindex @code{--interpreter}
  1051. Use the interpreter @var{interp} for interface with the controlling
  1052. program or device. This option is meant to be set by programs which
  1053. communicate with @value{GDBN} using it as a back end.
  1054. @xref{Interpreters, , Command Interpreters}.
  1055. @samp{--interpreter=mi} (or @samp{--interpreter=mi3}) causes
  1056. @value{GDBN} to use the @dfn{@sc{gdb/mi} interface} version 3 (@pxref{GDB/MI, ,
  1057. The @sc{gdb/mi} Interface}) included since @value{GDBN} version 9.1. @sc{gdb/mi}
  1058. version 2 (@code{mi2}), included in @value{GDBN} 6.0 and version 1 (@code{mi1}),
  1059. included in @value{GDBN} 5.3, are also available. Earlier @sc{gdb/mi}
  1060. interfaces are no longer supported.
  1061. @item -write
  1062. @cindex @code{--write}
  1063. Open the executable and core files for both reading and writing. This
  1064. is equivalent to the @samp{set write on} command inside @value{GDBN}
  1065. (@pxref{Patching}).
  1066. @item -statistics
  1067. @cindex @code{--statistics}
  1068. This option causes @value{GDBN} to print statistics about time and
  1069. memory usage after it completes each command and returns to the prompt.
  1070. @item -version
  1071. @cindex @code{--version}
  1072. This option causes @value{GDBN} to print its version number and
  1073. no-warranty blurb, and exit.
  1074. @item -configuration
  1075. @cindex @code{--configuration}
  1076. This option causes @value{GDBN} to print details about its build-time
  1077. configuration parameters, and then exit. These details can be
  1078. important when reporting @value{GDBN} bugs (@pxref{GDB Bugs}).
  1079. @end table
  1080. @node Startup
  1081. @subsection What @value{GDBN} Does During Startup
  1082. @cindex @value{GDBN} startup
  1083. Here's the description of what @value{GDBN} does during session startup:
  1084. @enumerate
  1085. @item
  1086. Performs minimal setup required to initialize basic internal state.
  1087. @item
  1088. @cindex early initialization file
  1089. Reads commands from the early initialization file (if any) in your
  1090. home directory. Only a restricted set of commands can be placed into
  1091. an early initialization file, see @ref{Initialization Files}, for
  1092. details.
  1093. @item
  1094. Executes commands and command files specified by the @samp{-eiex} and
  1095. @samp{-eix} command line options in their specified order. Only a
  1096. restricted set of commands can be used with @samp{-eiex} and
  1097. @samp{eix}, see @ref{Initialization Files}, for details.
  1098. @item
  1099. Sets up the command interpreter as specified by the command line
  1100. (@pxref{Mode Options, interpreter}).
  1101. @item
  1102. @cindex init file
  1103. Reads the system wide initialization file and the files from the
  1104. system wide initialization directory, @pxref{System Wide Init Files}.
  1105. @item
  1106. Reads the initialization file (if any) in your home directory and
  1107. executes all the commands in that file, @pxref{Home Directory Init
  1108. File}.
  1109. @anchor{Option -init-eval-command}
  1110. @item
  1111. Executes commands and command files specified by the @samp{-iex} and
  1112. @samp{-ix} options in their specified order. Usually you should use the
  1113. @samp{-ex} and @samp{-x} options instead, but this way you can apply
  1114. settings before @value{GDBN} init files get executed and before inferior
  1115. gets loaded.
  1116. @item
  1117. Processes command line options and operands.
  1118. @item
  1119. Reads and executes the commands from the initialization file (if any)
  1120. in the current working directory as long as @samp{set auto-load
  1121. local-gdbinit} is set to @samp{on} (@pxref{Init File in the Current
  1122. Directory}). This is only done if the current directory is different
  1123. from your home directory. Thus, you can have more than one init file,
  1124. one generic in your home directory, and another, specific to the
  1125. program you are debugging, in the directory where you invoke
  1126. @value{GDBN}. @xref{Init File in the Current Directory during
  1127. Startup}.
  1128. @item
  1129. If the command line specified a program to debug, or a process to
  1130. attach to, or a core file, @value{GDBN} loads any auto-loaded
  1131. scripts provided for the program or for its loaded shared libraries.
  1132. @xref{Auto-loading}.
  1133. If you wish to disable the auto-loading during startup,
  1134. you must do something like the following:
  1135. @smallexample
  1136. $ gdb -iex "set auto-load python-scripts off" myprogram
  1137. @end smallexample
  1138. Option @samp{-ex} does not work because the auto-loading is then turned
  1139. off too late.
  1140. @item
  1141. Executes commands and command files specified by the @samp{-ex} and
  1142. @samp{-x} options in their specified order. @xref{Command Files}, for
  1143. more details about @value{GDBN} command files.
  1144. @item
  1145. Reads the command history recorded in the @dfn{history file}.
  1146. @xref{Command History}, for more details about the command history and the
  1147. files where @value{GDBN} records it.
  1148. @end enumerate
  1149. @node Initialization Files
  1150. @subsection Initialization Files
  1151. @cindex init file name
  1152. During startup (@pxref{Startup}) @value{GDBN} will execute commands
  1153. from several initialization files. These initialization files use the
  1154. same syntax as @dfn{command files} (@pxref{Command Files}) and are
  1155. processed by @value{GDBN} in the same way.
  1156. To display the list of initialization files loaded by @value{GDBN} at
  1157. startup, in the order they will be loaded, you can use @kbd{gdb
  1158. --help}.
  1159. @cindex early initialization
  1160. The @dfn{early initialization} file is loaded very early in
  1161. @value{GDBN}'s initialization process, before the interpreter
  1162. (@pxref{Interpreters}) has been initialized, and before the default
  1163. target (@pxref{Targets}) is initialized. Only @code{set} or
  1164. @code{source} commands should be placed into an early initialization
  1165. file, and the only @code{set} commands that can be used are those that
  1166. control how @value{GDBN} starts up.
  1167. Commands that can be placed into an early initialization file will be
  1168. documented as such throughout this manual. Any command that is not
  1169. documented as being suitable for an early initialization file should
  1170. instead be placed into a general initialization file. Command files
  1171. passed to @code{--early-init-command} or @code{-eix} are also early
  1172. initialization files, with the same command restrictions. Only
  1173. commands that can appear in an early initialization file should be
  1174. passed to @code{--early-init-eval-command} or @code{-eiex}.
  1175. @cindex general initialization
  1176. In contrast, the @dfn{general initialization} files are processed
  1177. later, after @value{GDBN} has finished its own internal initialization
  1178. process, any valid command can be used in these files.
  1179. @cindex initialization file
  1180. Throughout the rest of this document the term @dfn{initialization
  1181. file} refers to one of the general initialization files, not the early
  1182. initialization file. Any discussion of the early initialization file
  1183. will specifically mention that it is the early initialization file
  1184. being discussed.
  1185. As the system wide and home directory initialization files are
  1186. processed before most command line options, changes to settings
  1187. (e.g.@: @samp{set complaints}) can affect subsequent processing of
  1188. command line options and operands.
  1189. The following sections describe where @value{GDBN} looks for the early
  1190. initialization and initialization files, and the order that the files
  1191. are searched for.
  1192. @subsubsection Home directory early initialization files
  1193. @value{GDBN} initially looks for an early initialization file in the
  1194. users home directory@footnote{On DOS/Windows systems, the home
  1195. directory is the one pointed to by the @env{HOME} environment
  1196. variable.}. There are a number of locations that @value{GDBN} will
  1197. search in the home directory, these locations are searched in order
  1198. and @value{GDBN} will load the first file that it finds, and
  1199. subsequent locations will not be checked.
  1200. On non-macOS hosts the locations searched are:
  1201. @itemize
  1202. @item
  1203. The file @file{gdb/gdbearlyinit} within the directory pointed to by the
  1204. environment variable @env{XDG_CONFIG_HOME}, if it is defined.
  1205. @item
  1206. The file @file{.config/gdb/gdbearlyinit} within the directory pointed to
  1207. by the environment variable @env{HOME}, if it is defined.
  1208. @item
  1209. The file @file{.gdbearlyinit} within the directory pointed to by the
  1210. environment variable @env{HOME}, if it is defined.
  1211. @end itemize
  1212. By contrast, on macOS hosts the locations searched are:
  1213. @itemize
  1214. @item
  1215. The file @file{Library/Preferences/gdb/gdbearlyinit} within the
  1216. directory pointed to by the environment variable @env{HOME}, if it is
  1217. defined.
  1218. @item
  1219. The file @file{.gdbearlyinit} within the directory pointed to by the
  1220. environment variable @env{HOME}, if it is defined.
  1221. @end itemize
  1222. It is possible to prevent the home directory early initialization file
  1223. from being loaded using the @samp{-nx} or @samp{-nh} command line
  1224. options, @pxref{Mode Options,,Choosing Modes}.
  1225. @anchor{System Wide Init Files}
  1226. @subsubsection System wide initialization files
  1227. There are two locations that are searched for system wide
  1228. initialization files. Both of these locations are always checked:
  1229. @table @code
  1230. @item @file{system.gdbinit}
  1231. This is a single system-wide initialization file. Its location is
  1232. specified with the @code{--with-system-gdbinit} configure option
  1233. (@pxref{System-wide configuration}). It is loaded first when
  1234. @value{GDBN} starts, before command line options have been processed.
  1235. @item @file{system.gdbinit.d}
  1236. This is the system-wide initialization directory. Its location is
  1237. specified with the @code{--with-system-gdbinit-dir} configure option
  1238. (@pxref{System-wide configuration}). Files in this directory are
  1239. loaded in alphabetical order immediately after @file{system.gdbinit}
  1240. (if enabled) when @value{GDBN} starts, before command line options
  1241. have been processed. Files need to have a recognized scripting
  1242. language extension (@file{.py}/@file{.scm}) or be named with a
  1243. @file{.gdb} extension to be interpreted as regular @value{GDBN}
  1244. commands. @value{GDBN} will not recurse into any subdirectories of
  1245. this directory.
  1246. @end table
  1247. It is possible to prevent the system wide initialization files from
  1248. being loaded using the @samp{-nx} command line option, @pxref{Mode
  1249. Options,,Choosing Modes}.
  1250. @anchor{Home Directory Init File}
  1251. @subsubsection Home directory initialization file
  1252. @cindex @file{gdbinit}
  1253. @cindex @file{.gdbinit}
  1254. @cindex @file{gdb.ini}
  1255. After loading the system wide initialization files @value{GDBN} will
  1256. look for an initialization file in the users home
  1257. directory@footnote{On DOS/Windows systems, the home directory is the
  1258. one pointed to by the @env{HOME} environment variable.}. There are a
  1259. number of locations that @value{GDBN} will search in the home
  1260. directory, these locations are searched in order and @value{GDBN} will
  1261. load the first file that it finds, and subsequent locations will not
  1262. be checked.
  1263. On non-Apple hosts the locations searched are:
  1264. @table @file
  1265. @item $XDG_CONFIG_HOME/gdb/gdbinit
  1266. @item $HOME/.config/gdb/gdbinit
  1267. @item $HOME/.gdbinit
  1268. @end table
  1269. While on Apple hosts the locations searched are:
  1270. @table @file
  1271. @item $HOME/Library/Preferences/gdb/gdbinit
  1272. @item $HOME/.gdbinit
  1273. @end table
  1274. It is possible to prevent the home directory initialization file from
  1275. being loaded using the @samp{-nx} or @samp{-nh} command line options,
  1276. @pxref{Mode Options,,Choosing Modes}.
  1277. The DJGPP port of @value{GDBN} uses the name @file{gdb.ini} instead of
  1278. @file{.gdbinit} or @file{gdbinit}, due to the limitations of file
  1279. names imposed by DOS filesystems. The Windows port of @value{GDBN}
  1280. uses the standard name, but if it finds a @file{gdb.ini} file in your
  1281. home directory, it warns you about that and suggests to rename the
  1282. file to the standard name.
  1283. @anchor{Init File in the Current Directory during Startup}
  1284. @subsubsection Local directory initialization file
  1285. @value{GDBN} will check the current directory for a file called
  1286. @file{.gdbinit}. It is loaded last, after command line options
  1287. other than @samp{-x} and @samp{-ex} have been processed. The command
  1288. line options @samp{-x} and @samp{-ex} are processed last, after
  1289. @file{.gdbinit} has been loaded, @pxref{File Options,,Choosing
  1290. Files}.
  1291. If the file in the current directory was already loaded as the home
  1292. directory initialization file then it will not be loaded a second
  1293. time.
  1294. It is possible to prevent the local directory initialization file from
  1295. being loaded using the @samp{-nx} command line option, @pxref{Mode
  1296. Options,,Choosing Modes}.
  1297. @node Quitting GDB
  1298. @section Quitting @value{GDBN}
  1299. @cindex exiting @value{GDBN}
  1300. @cindex leaving @value{GDBN}
  1301. @table @code
  1302. @kindex quit @r{[}@var{expression}@r{]}
  1303. @kindex exit @r{[}@var{expression}@r{]}
  1304. @kindex q @r{(@code{quit})}
  1305. @item quit @r{[}@var{expression}@r{]}
  1306. @itemx exit @r{[}@var{expression}@r{]}
  1307. @itemx q
  1308. To exit @value{GDBN}, use the @code{quit} command (abbreviated
  1309. @code{q}), the @code{exit} command, or type an end-of-file
  1310. character (usually @kbd{Ctrl-d}). If you do not supply @var{expression},
  1311. @value{GDBN} will terminate normally; otherwise it will terminate using
  1312. the result of @var{expression} as the error code.
  1313. @end table
  1314. @cindex interrupt
  1315. An interrupt (often @kbd{Ctrl-c}) does not exit from @value{GDBN}, but rather
  1316. terminates the action of any @value{GDBN} command that is in progress and
  1317. returns to @value{GDBN} command level. It is safe to type the interrupt
  1318. character at any time because @value{GDBN} does not allow it to take effect
  1319. until a time when it is safe.
  1320. If you have been using @value{GDBN} to control an attached process or
  1321. device, you can release it with the @code{detach} command
  1322. (@pxref{Attach, ,Debugging an Already-running Process}).
  1323. @node Shell Commands
  1324. @section Shell Commands
  1325. If you need to execute occasional shell commands during your
  1326. debugging session, there is no need to leave or suspend @value{GDBN}; you can
  1327. just use the @code{shell} command.
  1328. @table @code
  1329. @kindex shell
  1330. @kindex !
  1331. @cindex shell escape
  1332. @item shell @var{command-string}
  1333. @itemx !@var{command-string}
  1334. Invoke a standard shell to execute @var{command-string}.
  1335. Note that no space is needed between @code{!} and @var{command-string}.
  1336. On GNU and Unix systems, the environment variable @env{SHELL}, if it
  1337. exists, determines which shell to run. Otherwise @value{GDBN} uses
  1338. the default shell (@file{/bin/sh} on GNU and Unix systems,
  1339. @file{cmd.exe} on MS-Windows, @file{COMMAND.COM} on MS-DOS, etc.).
  1340. @end table
  1341. The utility @code{make} is often needed in development environments.
  1342. You do not have to use the @code{shell} command for this purpose in
  1343. @value{GDBN}:
  1344. @table @code
  1345. @kindex make
  1346. @cindex calling make
  1347. @item make @var{make-args}
  1348. Execute the @code{make} program with the specified
  1349. arguments. This is equivalent to @samp{shell make @var{make-args}}.
  1350. @end table
  1351. @table @code
  1352. @kindex pipe
  1353. @kindex |
  1354. @cindex send the output of a gdb command to a shell command
  1355. @anchor{pipe}
  1356. @item pipe [@var{command}] | @var{shell_command}
  1357. @itemx | [@var{command}] | @var{shell_command}
  1358. @itemx pipe -d @var{delim} @var{command} @var{delim} @var{shell_command}
  1359. @itemx | -d @var{delim} @var{command} @var{delim} @var{shell_command}
  1360. Executes @var{command} and sends its output to @var{shell_command}.
  1361. Note that no space is needed around @code{|}.
  1362. If no @var{command} is provided, the last command executed is repeated.
  1363. In case the @var{command} contains a @code{|}, the option @code{-d @var{delim}}
  1364. can be used to specify an alternate delimiter string @var{delim} that separates
  1365. the @var{command} from the @var{shell_command}.
  1366. Example:
  1367. @smallexample
  1368. @group
  1369. (gdb) p var
  1370. $1 = @{
  1371. black = 144,
  1372. red = 233,
  1373. green = 377,
  1374. blue = 610,
  1375. white = 987
  1376. @}
  1377. @end group
  1378. @group
  1379. (gdb) pipe p var|wc
  1380. 7 19 80
  1381. (gdb) |p var|wc -l
  1382. 7
  1383. @end group
  1384. @group
  1385. (gdb) p /x var
  1386. $4 = @{
  1387. black = 0x90,
  1388. red = 0xe9,
  1389. green = 0x179,
  1390. blue = 0x262,
  1391. white = 0x3db
  1392. @}
  1393. (gdb) ||grep red
  1394. red => 0xe9,
  1395. @end group
  1396. @group
  1397. (gdb) | -d ! echo this contains a | char\n ! sed -e 's/|/PIPE/'
  1398. this contains a PIPE char
  1399. (gdb) | -d xxx echo this contains a | char!\n xxx sed -e 's/|/PIPE/'
  1400. this contains a PIPE char!
  1401. (gdb)
  1402. @end group
  1403. @end smallexample
  1404. @end table
  1405. The convenience variables @code{$_shell_exitcode} and @code{$_shell_exitsignal}
  1406. can be used to examine the exit status of the last shell command launched
  1407. by @code{shell}, @code{make}, @code{pipe} and @code{|}.
  1408. @xref{Convenience Vars,, Convenience Variables}.
  1409. @node Logging Output
  1410. @section Logging Output
  1411. @cindex logging @value{GDBN} output
  1412. @cindex save @value{GDBN} output to a file
  1413. You may want to save the output of @value{GDBN} commands to a file.
  1414. There are several commands to control @value{GDBN}'s logging.
  1415. @table @code
  1416. @kindex set logging enabled
  1417. @item set logging enabled [on|off]
  1418. Enable or disable logging.
  1419. @cindex logging file name
  1420. @item set logging file @var{file}
  1421. Change the name of the current logfile. The default logfile is @file{gdb.txt}.
  1422. @item set logging overwrite [on|off]
  1423. By default, @value{GDBN} will append to the logfile. Set @code{overwrite} if
  1424. you want @code{set logging enabled on} to overwrite the logfile instead.
  1425. @item set logging redirect [on|off]
  1426. By default, @value{GDBN} output will go to both the terminal and the logfile.
  1427. Set @code{redirect} if you want output to go only to the log file.
  1428. @item set logging debugredirect [on|off]
  1429. By default, @value{GDBN} debug output will go to both the terminal and the logfile.
  1430. Set @code{debugredirect} if you want debug output to go only to the log file.
  1431. @kindex show logging
  1432. @item show logging
  1433. Show the current values of the logging settings.
  1434. @end table
  1435. You can also redirect the output of a @value{GDBN} command to a
  1436. shell command. @xref{pipe}.
  1437. @node Commands
  1438. @chapter @value{GDBN} Commands
  1439. You can abbreviate a @value{GDBN} command to the first few letters of the command
  1440. name, if that abbreviation is unambiguous; and you can repeat certain
  1441. @value{GDBN} commands by typing just @key{RET}. You can also use the @key{TAB}
  1442. key to get @value{GDBN} to fill out the rest of a word in a command (or to
  1443. show you the alternatives available, if there is more than one possibility).
  1444. @menu
  1445. * Command Syntax:: How to give commands to @value{GDBN}
  1446. * Command Settings:: How to change default behavior of commands
  1447. * Completion:: Command completion
  1448. * Command Options:: Command options
  1449. * Help:: How to ask @value{GDBN} for help
  1450. @end menu
  1451. @node Command Syntax
  1452. @section Command Syntax
  1453. A @value{GDBN} command is a single line of input. There is no limit on
  1454. how long it can be. It starts with a command name, which is followed by
  1455. arguments whose meaning depends on the command name. For example, the
  1456. command @code{step} accepts an argument which is the number of times to
  1457. step, as in @samp{step 5}. You can also use the @code{step} command
  1458. with no arguments. Some commands do not allow any arguments.
  1459. @cindex abbreviation
  1460. @value{GDBN} command names may always be truncated if that abbreviation is
  1461. unambiguous. Other possible command abbreviations are listed in the
  1462. documentation for individual commands. In some cases, even ambiguous
  1463. abbreviations are allowed; for example, @code{s} is specially defined as
  1464. equivalent to @code{step} even though there are other commands whose
  1465. names start with @code{s}. You can test abbreviations by using them as
  1466. arguments to the @code{help} command.
  1467. @cindex repeating commands
  1468. @kindex RET @r{(repeat last command)}
  1469. A blank line as input to @value{GDBN} (typing just @key{RET}) means to
  1470. repeat the previous command. Certain commands (for example, @code{run})
  1471. will not repeat this way; these are commands whose unintentional
  1472. repetition might cause trouble and which you are unlikely to want to
  1473. repeat. User-defined commands can disable this feature; see
  1474. @ref{Define, dont-repeat}.
  1475. The @code{list} and @code{x} commands, when you repeat them with
  1476. @key{RET}, construct new arguments rather than repeating
  1477. exactly as typed. This permits easy scanning of source or memory.
  1478. @value{GDBN} can also use @key{RET} in another way: to partition lengthy
  1479. output, in a way similar to the common utility @code{more}
  1480. (@pxref{Screen Size,,Screen Size}). Since it is easy to press one
  1481. @key{RET} too many in this situation, @value{GDBN} disables command
  1482. repetition after any command that generates this sort of display.
  1483. @kindex # @r{(a comment)}
  1484. @cindex comment
  1485. Any text from a @kbd{#} to the end of the line is a comment; it does
  1486. nothing. This is useful mainly in command files (@pxref{Command
  1487. Files,,Command Files}).
  1488. @cindex repeating command sequences
  1489. @kindex Ctrl-o @r{(operate-and-get-next)}
  1490. The @kbd{Ctrl-o} binding is useful for repeating a complex sequence of
  1491. commands. This command accepts the current line, like @key{RET}, and
  1492. then fetches the next line relative to the current line from the history
  1493. for editing.
  1494. @node Command Settings
  1495. @section Command Settings
  1496. @cindex default behavior of commands, changing
  1497. @cindex default settings, changing
  1498. Many commands change their behavior according to command-specific
  1499. variables or settings. These settings can be changed with the
  1500. @code{set} subcommands. For example, the @code{print} command
  1501. (@pxref{Data, ,Examining Data}) prints arrays differently depending on
  1502. settings changeable with the commands @code{set print elements
  1503. NUMBER-OF-ELEMENTS} and @code{set print array-indexes}, among others.
  1504. You can change these settings to your preference in the gdbinit files
  1505. loaded at @value{GDBN} startup. @xref{Startup}.
  1506. The settings can also be changed interactively during the debugging
  1507. session. For example, to change the limit of array elements to print,
  1508. you can do the following:
  1509. @smallexample
  1510. (@value{GDBN}) set print elements 10
  1511. (@value{GDBN}) print some_array
  1512. $1 = @{0, 10, 20, 30, 40, 50, 60, 70, 80, 90...@}
  1513. @end smallexample
  1514. The above @code{set print elements 10} command changes the number of
  1515. elements to print from the default of 200 to 10. If you only intend
  1516. this limit of 10 to be used for printing @code{some_array}, then you
  1517. must restore the limit back to 200, with @code{set print elements
  1518. 200}.
  1519. Some commands allow overriding settings with command options. For
  1520. example, the @code{print} command supports a number of options that
  1521. allow overriding relevant global print settings as set by @code{set
  1522. print} subcommands. @xref{print options}. The example above could be
  1523. rewritten as:
  1524. @smallexample
  1525. (@value{GDBN}) print -elements 10 -- some_array
  1526. $1 = @{0, 10, 20, 30, 40, 50, 60, 70, 80, 90...@}
  1527. @end smallexample
  1528. Alternatively, you can use the @code{with} command to change a setting
  1529. temporarily, for the duration of a command invocation.
  1530. @table @code
  1531. @kindex with command
  1532. @kindex w @r{(@code{with})}
  1533. @cindex settings
  1534. @cindex temporarily change settings
  1535. @item with @var{setting} [@var{value}] [-- @var{command}]
  1536. @itemx w @var{setting} [@var{value}] [-- @var{command}]
  1537. Temporarily set @var{setting} to @var{value} for the duration of
  1538. @var{command}.
  1539. @var{setting} is any setting you can change with the @code{set}
  1540. subcommands. @var{value} is the value to assign to @code{setting}
  1541. while running @code{command}.
  1542. If no @var{command} is provided, the last command executed is
  1543. repeated.
  1544. If a @var{command} is provided, it must be preceded by a double dash
  1545. (@code{--}) separator. This is required because some settings accept
  1546. free-form arguments, such as expressions or filenames.
  1547. For example, the command
  1548. @smallexample
  1549. (@value{GDBN}) with print array on -- print some_array
  1550. @end smallexample
  1551. @noindent
  1552. is equivalent to the following 3 commands:
  1553. @smallexample
  1554. (@value{GDBN}) set print array on
  1555. (@value{GDBN}) print some_array
  1556. (@value{GDBN}) set print array off
  1557. @end smallexample
  1558. The @code{with} command is particularly useful when you want to
  1559. override a setting while running user-defined commands, or commands
  1560. defined in Python or Guile. @xref{Extending GDB,, Extending GDB}.
  1561. @smallexample
  1562. (@value{GDBN}) with print pretty on -- my_complex_command
  1563. @end smallexample
  1564. To change several settings for the same command, you can nest
  1565. @code{with} commands. For example, @code{with language ada -- with
  1566. print elements 10} temporarily changes the language to Ada and sets a
  1567. limit of 10 elements to print for arrays and strings.
  1568. @end table
  1569. @node Completion
  1570. @section Command Completion
  1571. @cindex completion
  1572. @cindex word completion
  1573. @value{GDBN} can fill in the rest of a word in a command for you, if there is
  1574. only one possibility; it can also show you what the valid possibilities
  1575. are for the next word in a command, at any time. This works for @value{GDBN}
  1576. commands, @value{GDBN} subcommands, command options, and the names of symbols
  1577. in your program.
  1578. Press the @key{TAB} key whenever you want @value{GDBN} to fill out the rest
  1579. of a word. If there is only one possibility, @value{GDBN} fills in the
  1580. word, and waits for you to finish the command (or press @key{RET} to
  1581. enter it). For example, if you type
  1582. @c FIXME "@key" does not distinguish its argument sufficiently to permit
  1583. @c complete accuracy in these examples; space introduced for clarity.
  1584. @c If texinfo enhancements make it unnecessary, it would be nice to
  1585. @c replace " @key" by "@key" in the following...
  1586. @smallexample
  1587. (@value{GDBP}) info bre @key{TAB}
  1588. @end smallexample
  1589. @noindent
  1590. @value{GDBN} fills in the rest of the word @samp{breakpoints}, since that is
  1591. the only @code{info} subcommand beginning with @samp{bre}:
  1592. @smallexample
  1593. (@value{GDBP}) info breakpoints
  1594. @end smallexample
  1595. @noindent
  1596. You can either press @key{RET} at this point, to run the @code{info
  1597. breakpoints} command, or backspace and enter something else, if
  1598. @samp{breakpoints} does not look like the command you expected. (If you
  1599. were sure you wanted @code{info breakpoints} in the first place, you
  1600. might as well just type @key{RET} immediately after @samp{info bre},
  1601. to exploit command abbreviations rather than command completion).
  1602. If there is more than one possibility for the next word when you press
  1603. @key{TAB}, @value{GDBN} sounds a bell. You can either supply more
  1604. characters and try again, or just press @key{TAB} a second time;
  1605. @value{GDBN} displays all the possible completions for that word. For
  1606. example, you might want to set a breakpoint on a subroutine whose name
  1607. begins with @samp{make_}, but when you type @kbd{b make_@key{TAB}} @value{GDBN}
  1608. just sounds the bell. Typing @key{TAB} again displays all the
  1609. function names in your program that begin with those characters, for
  1610. example:
  1611. @smallexample
  1612. (@value{GDBP}) b make_ @key{TAB}
  1613. @exdent @value{GDBN} sounds bell; press @key{TAB} again, to see:
  1614. make_a_section_from_file make_environ
  1615. make_abs_section make_function_type
  1616. make_blockvector make_pointer_type
  1617. make_cleanup make_reference_type
  1618. make_command make_symbol_completion_list
  1619. (@value{GDBP}) b make_
  1620. @end smallexample
  1621. @noindent
  1622. After displaying the available possibilities, @value{GDBN} copies your
  1623. partial input (@samp{b make_} in the example) so you can finish the
  1624. command.
  1625. If you just want to see the list of alternatives in the first place, you
  1626. can press @kbd{M-?} rather than pressing @key{TAB} twice. @kbd{M-?}
  1627. means @kbd{@key{META} ?}. You can type this either by holding down a
  1628. key designated as the @key{META} shift on your keyboard (if there is
  1629. one) while typing @kbd{?}, or as @key{ESC} followed by @kbd{?}.
  1630. If the number of possible completions is large, @value{GDBN} will
  1631. print as much of the list as it has collected, as well as a message
  1632. indicating that the list may be truncated.
  1633. @smallexample
  1634. (@value{GDBP}) b m@key{TAB}@key{TAB}
  1635. main
  1636. <... the rest of the possible completions ...>
  1637. *** List may be truncated, max-completions reached. ***
  1638. (@value{GDBP}) b m
  1639. @end smallexample
  1640. @noindent
  1641. This behavior can be controlled with the following commands:
  1642. @table @code
  1643. @kindex set max-completions
  1644. @item set max-completions @var{limit}
  1645. @itemx set max-completions unlimited
  1646. Set the maximum number of completion candidates. @value{GDBN} will
  1647. stop looking for more completions once it collects this many candidates.
  1648. This is useful when completing on things like function names as collecting
  1649. all the possible candidates can be time consuming.
  1650. The default value is 200. A value of zero disables tab-completion.
  1651. Note that setting either no limit or a very large limit can make
  1652. completion slow.
  1653. @kindex show max-completions
  1654. @item show max-completions
  1655. Show the maximum number of candidates that @value{GDBN} will collect and show
  1656. during completion.
  1657. @end table
  1658. @cindex quotes in commands
  1659. @cindex completion of quoted strings
  1660. Sometimes the string you need, while logically a ``word'', may contain
  1661. parentheses or other characters that @value{GDBN} normally excludes from
  1662. its notion of a word. To permit word completion to work in this
  1663. situation, you may enclose words in @code{'} (single quote marks) in
  1664. @value{GDBN} commands.
  1665. A likely situation where you might need this is in typing an
  1666. expression that involves a C@t{++} symbol name with template
  1667. parameters. This is because when completing expressions, GDB treats
  1668. the @samp{<} character as word delimiter, assuming that it's the
  1669. less-than comparison operator (@pxref{C Operators, , C and C@t{++}
  1670. Operators}).
  1671. For example, when you want to call a C@t{++} template function
  1672. interactively using the @code{print} or @code{call} commands, you may
  1673. need to distinguish whether you mean the version of @code{name} that
  1674. was specialized for @code{int}, @code{name<int>()}, or the version
  1675. that was specialized for @code{float}, @code{name<float>()}. To use
  1676. the word-completion facilities in this situation, type a single quote
  1677. @code{'} at the beginning of the function name. This alerts
  1678. @value{GDBN} that it may need to consider more information than usual
  1679. when you press @key{TAB} or @kbd{M-?} to request word completion:
  1680. @smallexample
  1681. (@value{GDBP}) p 'func< @kbd{M-?}
  1682. func<int>() func<float>()
  1683. (@value{GDBP}) p 'func<
  1684. @end smallexample
  1685. When setting breakpoints however (@pxref{Specify Location}), you don't
  1686. usually need to type a quote before the function name, because
  1687. @value{GDBN} understands that you want to set a breakpoint on a
  1688. function:
  1689. @smallexample
  1690. (@value{GDBP}) b func< @kbd{M-?}
  1691. func<int>() func<float>()
  1692. (@value{GDBP}) b func<
  1693. @end smallexample
  1694. This is true even in the case of typing the name of C@t{++} overloaded
  1695. functions (multiple definitions of the same function, distinguished by
  1696. argument type). For example, when you want to set a breakpoint you
  1697. don't need to distinguish whether you mean the version of @code{name}
  1698. that takes an @code{int} parameter, @code{name(int)}, or the version
  1699. that takes a @code{float} parameter, @code{name(float)}.
  1700. @smallexample
  1701. (@value{GDBP}) b bubble( @kbd{M-?}
  1702. bubble(int) bubble(double)
  1703. (@value{GDBP}) b bubble(dou @kbd{M-?}
  1704. bubble(double)
  1705. @end smallexample
  1706. See @ref{quoting names} for a description of other scenarios that
  1707. require quoting.
  1708. For more information about overloaded functions, see @ref{C Plus Plus
  1709. Expressions, ,C@t{++} Expressions}. You can use the command @code{set
  1710. overload-resolution off} to disable overload resolution;
  1711. see @ref{Debugging C Plus Plus, ,@value{GDBN} Features for C@t{++}}.
  1712. @cindex completion of structure field names
  1713. @cindex structure field name completion
  1714. @cindex completion of union field names
  1715. @cindex union field name completion
  1716. When completing in an expression which looks up a field in a
  1717. structure, @value{GDBN} also tries@footnote{The completer can be
  1718. confused by certain kinds of invalid expressions. Also, it only
  1719. examines the static type of the expression, not the dynamic type.} to
  1720. limit completions to the field names available in the type of the
  1721. left-hand-side:
  1722. @smallexample
  1723. (@value{GDBP}) p gdb_stdout.@kbd{M-?}
  1724. magic to_fputs to_rewind
  1725. to_data to_isatty to_write
  1726. to_delete to_put to_write_async_safe
  1727. to_flush to_read
  1728. @end smallexample
  1729. @noindent
  1730. This is because the @code{gdb_stdout} is a variable of the type
  1731. @code{struct ui_file} that is defined in @value{GDBN} sources as
  1732. follows:
  1733. @smallexample
  1734. struct ui_file
  1735. @{
  1736. int *magic;
  1737. ui_file_flush_ftype *to_flush;
  1738. ui_file_write_ftype *to_write;
  1739. ui_file_write_async_safe_ftype *to_write_async_safe;
  1740. ui_file_fputs_ftype *to_fputs;
  1741. ui_file_read_ftype *to_read;
  1742. ui_file_delete_ftype *to_delete;
  1743. ui_file_isatty_ftype *to_isatty;
  1744. ui_file_rewind_ftype *to_rewind;
  1745. ui_file_put_ftype *to_put;
  1746. void *to_data;
  1747. @}
  1748. @end smallexample
  1749. @node Command Options
  1750. @section Command options
  1751. @cindex command options
  1752. Some commands accept options starting with a leading dash. For
  1753. example, @code{print -pretty}. Similarly to command names, you can
  1754. abbreviate a @value{GDBN} option to the first few letters of the
  1755. option name, if that abbreviation is unambiguous, and you can also use
  1756. the @key{TAB} key to get @value{GDBN} to fill out the rest of a word
  1757. in an option (or to show you the alternatives available, if there is
  1758. more than one possibility).
  1759. @cindex command options, raw input
  1760. Some commands take raw input as argument. For example, the print
  1761. command processes arbitrary expressions in any of the languages
  1762. supported by @value{GDBN}. With such commands, because raw input may
  1763. start with a leading dash that would be confused with an option or any
  1764. of its abbreviations, e.g.@: @code{print -p} (short for @code{print
  1765. -pretty} or printing negative @code{p}?), if you specify any command
  1766. option, then you must use a double-dash (@code{--}) delimiter to
  1767. indicate the end of options.
  1768. @cindex command options, boolean
  1769. Some options are described as accepting an argument which can be
  1770. either @code{on} or @code{off}. These are known as @dfn{boolean
  1771. options}. Similarly to boolean settings commands---@code{on} and
  1772. @code{off} are the typical values, but any of @code{1}, @code{yes} and
  1773. @code{enable} can also be used as ``true'' value, and any of @code{0},
  1774. @code{no} and @code{disable} can also be used as ``false'' value. You
  1775. can also omit a ``true'' value, as it is implied by default.
  1776. For example, these are equivalent:
  1777. @smallexample
  1778. (@value{GDBP}) print -object on -pretty off -element unlimited -- *myptr
  1779. (@value{GDBP}) p -o -p 0 -e u -- *myptr
  1780. @end smallexample
  1781. You can discover the set of options some command accepts by completing
  1782. on @code{-} after the command name. For example:
  1783. @smallexample
  1784. (@value{GDBP}) print -@key{TAB}@key{TAB}
  1785. -address -max-depth -pretty -symbol
  1786. -array -memory-tag-violations -raw-values -union
  1787. -array-indexes -null-stop -repeats -vtbl
  1788. -elements -object -static-members
  1789. @end smallexample
  1790. Completion will in some cases guide you with a suggestion of what kind
  1791. of argument an option expects. For example:
  1792. @smallexample
  1793. (@value{GDBP}) print -elements @key{TAB}@key{TAB}
  1794. NUMBER unlimited
  1795. @end smallexample
  1796. Here, the option expects a number (e.g., @code{100}), not literal
  1797. @code{NUMBER}. Such metasyntactical arguments are always presented in
  1798. uppercase.
  1799. (For more on using the @code{print} command, see @ref{Data, ,Examining
  1800. Data}.)
  1801. @node Help
  1802. @section Getting Help
  1803. @cindex online documentation
  1804. @kindex help
  1805. You can always ask @value{GDBN} itself for information on its commands,
  1806. using the command @code{help}.
  1807. @table @code
  1808. @kindex h @r{(@code{help})}
  1809. @item help
  1810. @itemx h
  1811. You can use @code{help} (abbreviated @code{h}) with no arguments to
  1812. display a short list of named classes of commands:
  1813. @smallexample
  1814. (@value{GDBP}) help
  1815. List of classes of commands:
  1816. aliases -- User-defined aliases of other commands
  1817. breakpoints -- Making program stop at certain points
  1818. data -- Examining data
  1819. files -- Specifying and examining files
  1820. internals -- Maintenance commands
  1821. obscure -- Obscure features
  1822. running -- Running the program
  1823. stack -- Examining the stack
  1824. status -- Status inquiries
  1825. support -- Support facilities
  1826. tracepoints -- Tracing of program execution without
  1827. stopping the program
  1828. user-defined -- User-defined commands
  1829. Type "help" followed by a class name for a list of
  1830. commands in that class.
  1831. Type "help" followed by command name for full
  1832. documentation.
  1833. Command name abbreviations are allowed if unambiguous.
  1834. (@value{GDBP})
  1835. @end smallexample
  1836. @c the above line break eliminates huge line overfull...
  1837. @item help @var{class}
  1838. Using one of the general help classes as an argument, you can get a
  1839. list of the individual commands in that class. If a command has
  1840. aliases, the aliases are given after the command name, separated by
  1841. commas. If an alias has default arguments, the full definition of
  1842. the alias is given after the first line.
  1843. For example, here is the help display for the class @code{status}:
  1844. @smallexample
  1845. (@value{GDBP}) help status
  1846. Status inquiries.
  1847. List of commands:
  1848. @c Line break in "show" line falsifies real output, but needed
  1849. @c to fit in smallbook page size.
  1850. info, inf, i -- Generic command for showing things
  1851. about the program being debugged
  1852. info address, iamain -- Describe where symbol SYM is stored.
  1853. alias iamain = info address main
  1854. info all-registers -- List of all registers and their contents,
  1855. for selected stack frame.
  1856. ...
  1857. show, info set -- Generic command for showing things
  1858. about the debugger
  1859. Type "help" followed by command name for full
  1860. documentation.
  1861. Command name abbreviations are allowed if unambiguous.
  1862. (@value{GDBP})
  1863. @end smallexample
  1864. @item help @var{command}
  1865. With a command name as @code{help} argument, @value{GDBN} displays a
  1866. short paragraph on how to use that command. If that command has
  1867. one or more aliases, @value{GDBN} will display a first line with
  1868. the command name and all its aliases separated by commas.
  1869. This first line will be followed by the full definition of all aliases
  1870. having default arguments.
  1871. @kindex apropos
  1872. @item apropos [-v] @var{regexp}
  1873. The @code{apropos} command searches through all of the @value{GDBN}
  1874. commands, and their documentation, for the regular expression specified in
  1875. @var{args}. It prints out all matches found. The optional flag @samp{-v},
  1876. which stands for @samp{verbose}, indicates to output the full documentation
  1877. of the matching commands and highlight the parts of the documentation
  1878. matching @var{regexp}. For example:
  1879. @smallexample
  1880. apropos alias
  1881. @end smallexample
  1882. @noindent
  1883. results in:
  1884. @smallexample
  1885. @group
  1886. alias -- Define a new command that is an alias of an existing command
  1887. aliases -- User-defined aliases of other commands
  1888. @end group
  1889. @end smallexample
  1890. @noindent
  1891. while
  1892. @smallexample
  1893. apropos -v cut.*thread apply
  1894. @end smallexample
  1895. @noindent
  1896. results in the below output, where @samp{cut for 'thread apply}
  1897. is highlighted if styling is enabled.
  1898. @smallexample
  1899. @group
  1900. taas -- Apply a command to all threads (ignoring errors
  1901. and empty output).
  1902. Usage: taas COMMAND
  1903. shortcut for 'thread apply all -s COMMAND'
  1904. tfaas -- Apply a command to all frames of all threads
  1905. (ignoring errors and empty output).
  1906. Usage: tfaas COMMAND
  1907. shortcut for 'thread apply all -s frame apply all -s COMMAND'
  1908. @end group
  1909. @end smallexample
  1910. @kindex complete
  1911. @item complete @var{args}
  1912. The @code{complete @var{args}} command lists all the possible completions
  1913. for the beginning of a command. Use @var{args} to specify the beginning of the
  1914. command you want completed. For example:
  1915. @smallexample
  1916. complete i
  1917. @end smallexample
  1918. @noindent results in:
  1919. @smallexample
  1920. @group
  1921. if
  1922. ignore
  1923. info
  1924. inspect
  1925. @end group
  1926. @end smallexample
  1927. @noindent This is intended for use by @sc{gnu} Emacs.
  1928. @end table
  1929. In addition to @code{help}, you can use the @value{GDBN} commands @code{info}
  1930. and @code{show} to inquire about the state of your program, or the state
  1931. of @value{GDBN} itself. Each command supports many topics of inquiry; this
  1932. manual introduces each of them in the appropriate context. The listings
  1933. under @code{info} and under @code{show} in the Command, Variable, and
  1934. Function Index point to all the sub-commands. @xref{Command and Variable
  1935. Index}.
  1936. @c @group
  1937. @table @code
  1938. @kindex info
  1939. @kindex i @r{(@code{info})}
  1940. @item info
  1941. This command (abbreviated @code{i}) is for describing the state of your
  1942. program. For example, you can show the arguments passed to a function
  1943. with @code{info args}, list the registers currently in use with @code{info
  1944. registers}, or list the breakpoints you have set with @code{info breakpoints}.
  1945. You can get a complete list of the @code{info} sub-commands with
  1946. @w{@code{help info}}.
  1947. @kindex set
  1948. @item set
  1949. You can assign the result of an expression to an environment variable with
  1950. @code{set}. For example, you can set the @value{GDBN} prompt to a $-sign with
  1951. @code{set prompt $}.
  1952. @kindex show
  1953. @item show
  1954. In contrast to @code{info}, @code{show} is for describing the state of
  1955. @value{GDBN} itself.
  1956. You can change most of the things you can @code{show}, by using the
  1957. related command @code{set}; for example, you can control what number
  1958. system is used for displays with @code{set radix}, or simply inquire
  1959. which is currently in use with @code{show radix}.
  1960. @kindex info set
  1961. To display all the settable parameters and their current
  1962. values, you can use @code{show} with no arguments; you may also use
  1963. @code{info set}. Both commands produce the same display.
  1964. @c FIXME: "info set" violates the rule that "info" is for state of
  1965. @c FIXME...program. Ck w/ GNU: "info set" to be called something else,
  1966. @c FIXME...or change desc of rule---eg "state of prog and debugging session"?
  1967. @end table
  1968. @c @end group
  1969. Here are several miscellaneous @code{show} subcommands, all of which are
  1970. exceptional in lacking corresponding @code{set} commands:
  1971. @table @code
  1972. @kindex show version
  1973. @cindex @value{GDBN} version number
  1974. @item show version
  1975. Show what version of @value{GDBN} is running. You should include this
  1976. information in @value{GDBN} bug-reports. If multiple versions of
  1977. @value{GDBN} are in use at your site, you may need to determine which
  1978. version of @value{GDBN} you are running; as @value{GDBN} evolves, new
  1979. commands are introduced, and old ones may wither away. Also, many
  1980. system vendors ship variant versions of @value{GDBN}, and there are
  1981. variant versions of @value{GDBN} in @sc{gnu}/Linux distributions as well.
  1982. The version number is the same as the one announced when you start
  1983. @value{GDBN}.
  1984. @kindex show copying
  1985. @kindex info copying
  1986. @cindex display @value{GDBN} copyright
  1987. @item show copying
  1988. @itemx info copying
  1989. Display information about permission for copying @value{GDBN}.
  1990. @kindex show warranty
  1991. @kindex info warranty
  1992. @item show warranty
  1993. @itemx info warranty
  1994. Display the @sc{gnu} ``NO WARRANTY'' statement, or a warranty,
  1995. if your version of @value{GDBN} comes with one.
  1996. @kindex show configuration
  1997. @item show configuration
  1998. Display detailed information about the way @value{GDBN} was configured
  1999. when it was built. This displays the optional arguments passed to the
  2000. @file{configure} script and also configuration parameters detected
  2001. automatically by @command{configure}. When reporting a @value{GDBN}
  2002. bug (@pxref{GDB Bugs}), it is important to include this information in
  2003. your report.
  2004. @end table
  2005. @node Running
  2006. @chapter Running Programs Under @value{GDBN}
  2007. When you run a program under @value{GDBN}, you must first generate
  2008. debugging information when you compile it.
  2009. You may start @value{GDBN} with its arguments, if any, in an environment
  2010. of your choice. If you are doing native debugging, you may redirect
  2011. your program's input and output, debug an already running process, or
  2012. kill a child process.
  2013. @menu
  2014. * Compilation:: Compiling for debugging
  2015. * Starting:: Starting your program
  2016. * Arguments:: Your program's arguments
  2017. * Environment:: Your program's environment
  2018. * Working Directory:: Your program's working directory
  2019. * Input/Output:: Your program's input and output
  2020. * Attach:: Debugging an already-running process
  2021. * Kill Process:: Killing the child process
  2022. * Inferiors Connections and Programs:: Debugging multiple inferiors
  2023. connections and programs
  2024. * Threads:: Debugging programs with multiple threads
  2025. * Forks:: Debugging forks
  2026. * Checkpoint/Restart:: Setting a @emph{bookmark} to return to later
  2027. @end menu
  2028. @node Compilation
  2029. @section Compiling for Debugging
  2030. In order to debug a program effectively, you need to generate
  2031. debugging information when you compile it. This debugging information
  2032. is stored in the object file; it describes the data type of each
  2033. variable or function and the correspondence between source line numbers
  2034. and addresses in the executable code.
  2035. To request debugging information, specify the @samp{-g} option when you run
  2036. the compiler.
  2037. Programs that are to be shipped to your customers are compiled with
  2038. optimizations, using the @samp{-O} compiler option. However, some
  2039. compilers are unable to handle the @samp{-g} and @samp{-O} options
  2040. together. Using those compilers, you cannot generate optimized
  2041. executables containing debugging information.
  2042. @value{NGCC}, the @sc{gnu} C/C@t{++} compiler, supports @samp{-g} with or
  2043. without @samp{-O}, making it possible to debug optimized code. We
  2044. recommend that you @emph{always} use @samp{-g} whenever you compile a
  2045. program. You may think your program is correct, but there is no sense
  2046. in pushing your luck. For more information, see @ref{Optimized Code}.
  2047. Older versions of the @sc{gnu} C compiler permitted a variant option
  2048. @w{@samp{-gg}} for debugging information. @value{GDBN} no longer supports this
  2049. format; if your @sc{gnu} C compiler has this option, do not use it.
  2050. @value{GDBN} knows about preprocessor macros and can show you their
  2051. expansion (@pxref{Macros}). Most compilers do not include information
  2052. about preprocessor macros in the debugging information if you specify
  2053. the @option{-g} flag alone. Version 3.1 and later of @value{NGCC},
  2054. the @sc{gnu} C compiler, provides macro information if you are using
  2055. the DWARF debugging format, and specify the option @option{-g3}.
  2056. @xref{Debugging Options,,Options for Debugging Your Program or GCC,
  2057. gcc, Using the @sc{gnu} Compiler Collection (GCC)}, for more
  2058. information on @value{NGCC} options affecting debug information.
  2059. You will have the best debugging experience if you use the latest
  2060. version of the DWARF debugging format that your compiler supports.
  2061. DWARF is currently the most expressive and best supported debugging
  2062. format in @value{GDBN}.
  2063. @need 2000
  2064. @node Starting
  2065. @section Starting your Program
  2066. @cindex starting
  2067. @cindex running
  2068. @table @code
  2069. @kindex run
  2070. @kindex r @r{(@code{run})}
  2071. @item run
  2072. @itemx r
  2073. Use the @code{run} command to start your program under @value{GDBN}.
  2074. You must first specify the program name with an argument to
  2075. @value{GDBN} (@pxref{Invocation, ,Getting In and Out of
  2076. @value{GDBN}}), or by using the @code{file} or @code{exec-file}
  2077. command (@pxref{Files, ,Commands to Specify Files}).
  2078. @end table
  2079. If you are running your program in an execution environment that
  2080. supports processes, @code{run} creates an inferior process and makes
  2081. that process run your program. In some environments without processes,
  2082. @code{run} jumps to the start of your program. Other targets,
  2083. like @samp{remote}, are always running. If you get an error
  2084. message like this one:
  2085. @smallexample
  2086. The "remote" target does not support "run".
  2087. Try "help target" or "continue".
  2088. @end smallexample
  2089. @noindent
  2090. then use @code{continue} to run your program. You may need @code{load}
  2091. first (@pxref{load}).
  2092. The execution of a program is affected by certain information it
  2093. receives from its superior. @value{GDBN} provides ways to specify this
  2094. information, which you must do @emph{before} starting your program. (You
  2095. can change it after starting your program, but such changes only affect
  2096. your program the next time you start it.) This information may be
  2097. divided into four categories:
  2098. @table @asis
  2099. @item The @emph{arguments.}
  2100. Specify the arguments to give your program as the arguments of the
  2101. @code{run} command. If a shell is available on your target, the shell
  2102. is used to pass the arguments, so that you may use normal conventions
  2103. (such as wildcard expansion or variable substitution) in describing
  2104. the arguments.
  2105. In Unix systems, you can control which shell is used with the
  2106. @env{SHELL} environment variable. If you do not define @env{SHELL},
  2107. @value{GDBN} uses the default shell (@file{/bin/sh}). You can disable
  2108. use of any shell with the @code{set startup-with-shell} command (see
  2109. below for details).
  2110. @item The @emph{environment.}
  2111. Your program normally inherits its environment from @value{GDBN}, but you can
  2112. use the @value{GDBN} commands @code{set environment} and @code{unset
  2113. environment} to change parts of the environment that affect
  2114. your program. @xref{Environment, ,Your Program's Environment}.
  2115. @item The @emph{working directory.}
  2116. You can set your program's working directory with the command
  2117. @kbd{set cwd}. If you do not set any working directory with this
  2118. command, your program will inherit @value{GDBN}'s working directory if
  2119. native debugging, or the remote server's working directory if remote
  2120. debugging. @xref{Working Directory, ,Your Program's Working
  2121. Directory}.
  2122. @item The @emph{standard input and output.}
  2123. Your program normally uses the same device for standard input and
  2124. standard output as @value{GDBN} is using. You can redirect input and output
  2125. in the @code{run} command line, or you can use the @code{tty} command to
  2126. set a different device for your program.
  2127. @xref{Input/Output, ,Your Program's Input and Output}.
  2128. @cindex pipes
  2129. @emph{Warning:} While input and output redirection work, you cannot use
  2130. pipes to pass the output of the program you are debugging to another
  2131. program; if you attempt this, @value{GDBN} is likely to wind up debugging the
  2132. wrong program.
  2133. @end table
  2134. When you issue the @code{run} command, your program begins to execute
  2135. immediately. @xref{Stopping, ,Stopping and Continuing}, for discussion
  2136. of how to arrange for your program to stop. Once your program has
  2137. stopped, you may call functions in your program, using the @code{print}
  2138. or @code{call} commands. @xref{Data, ,Examining Data}.
  2139. If the modification time of your symbol file has changed since the last
  2140. time @value{GDBN} read its symbols, @value{GDBN} discards its symbol
  2141. table, and reads it again. When it does this, @value{GDBN} tries to retain
  2142. your current breakpoints.
  2143. @table @code
  2144. @kindex start
  2145. @item start
  2146. @cindex run to main procedure
  2147. The name of the main procedure can vary from language to language.
  2148. With C or C@t{++}, the main procedure name is always @code{main}, but
  2149. other languages such as Ada do not require a specific name for their
  2150. main procedure. The debugger provides a convenient way to start the
  2151. execution of the program and to stop at the beginning of the main
  2152. procedure, depending on the language used.
  2153. The @samp{start} command does the equivalent of setting a temporary
  2154. breakpoint at the beginning of the main procedure and then invoking
  2155. the @samp{run} command.
  2156. @cindex elaboration phase
  2157. Some programs contain an @dfn{elaboration} phase where some startup code is
  2158. executed before the main procedure is called. This depends on the
  2159. languages used to write your program. In C@t{++}, for instance,
  2160. constructors for static and global objects are executed before
  2161. @code{main} is called. It is therefore possible that the debugger stops
  2162. before reaching the main procedure. However, the temporary breakpoint
  2163. will remain to halt execution.
  2164. Specify the arguments to give to your program as arguments to the
  2165. @samp{start} command. These arguments will be given verbatim to the
  2166. underlying @samp{run} command. Note that the same arguments will be
  2167. reused if no argument is provided during subsequent calls to
  2168. @samp{start} or @samp{run}.
  2169. It is sometimes necessary to debug the program during elaboration. In
  2170. these cases, using the @code{start} command would stop the execution
  2171. of your program too late, as the program would have already completed
  2172. the elaboration phase. Under these circumstances, either insert
  2173. breakpoints in your elaboration code before running your program or
  2174. use the @code{starti} command.
  2175. @kindex starti
  2176. @item starti
  2177. @cindex run to first instruction
  2178. The @samp{starti} command does the equivalent of setting a temporary
  2179. breakpoint at the first instruction of a program's execution and then
  2180. invoking the @samp{run} command. For programs containing an
  2181. elaboration phase, the @code{starti} command will stop execution at
  2182. the start of the elaboration phase.
  2183. @anchor{set exec-wrapper}
  2184. @kindex set exec-wrapper
  2185. @item set exec-wrapper @var{wrapper}
  2186. @itemx show exec-wrapper
  2187. @itemx unset exec-wrapper
  2188. When @samp{exec-wrapper} is set, the specified wrapper is used to
  2189. launch programs for debugging. @value{GDBN} starts your program
  2190. with a shell command of the form @kbd{exec @var{wrapper}
  2191. @var{program}}. Quoting is added to @var{program} and its
  2192. arguments, but not to @var{wrapper}, so you should add quotes if
  2193. appropriate for your shell. The wrapper runs until it executes
  2194. your program, and then @value{GDBN} takes control.
  2195. You can use any program that eventually calls @code{execve} with
  2196. its arguments as a wrapper. Several standard Unix utilities do
  2197. this, e.g.@: @code{env} and @code{nohup}. Any Unix shell script ending
  2198. with @code{exec "$@@"} will also work.
  2199. For example, you can use @code{env} to pass an environment variable to
  2200. the debugged program, without setting the variable in your shell's
  2201. environment:
  2202. @smallexample
  2203. (@value{GDBP}) set exec-wrapper env 'LD_PRELOAD=libtest.so'
  2204. (@value{GDBP}) run
  2205. @end smallexample
  2206. This command is available when debugging locally on most targets, excluding
  2207. @sc{djgpp}, Cygwin, MS Windows, and QNX Neutrino.
  2208. @kindex set startup-with-shell
  2209. @anchor{set startup-with-shell}
  2210. @item set startup-with-shell
  2211. @itemx set startup-with-shell on
  2212. @itemx set startup-with-shell off
  2213. @itemx show startup-with-shell
  2214. On Unix systems, by default, if a shell is available on your target,
  2215. @value{GDBN}) uses it to start your program. Arguments of the
  2216. @code{run} command are passed to the shell, which does variable
  2217. substitution, expands wildcard characters and performs redirection of
  2218. I/O. In some circumstances, it may be useful to disable such use of a
  2219. shell, for example, when debugging the shell itself or diagnosing
  2220. startup failures such as:
  2221. @smallexample
  2222. (@value{GDBP}) run
  2223. Starting program: ./a.out
  2224. During startup program terminated with signal SIGSEGV, Segmentation fault.
  2225. @end smallexample
  2226. @noindent
  2227. which indicates the shell or the wrapper specified with
  2228. @samp{exec-wrapper} crashed, not your program. Most often, this is
  2229. caused by something odd in your shell's non-interactive mode
  2230. initialization file---such as @file{.cshrc} for C-shell,
  2231. $@file{.zshenv} for the Z shell, or the file specified in the
  2232. @env{BASH_ENV} environment variable for BASH.
  2233. @anchor{set auto-connect-native-target}
  2234. @kindex set auto-connect-native-target
  2235. @item set auto-connect-native-target
  2236. @itemx set auto-connect-native-target on
  2237. @itemx set auto-connect-native-target off
  2238. @itemx show auto-connect-native-target
  2239. By default, if the current inferior is not connected to any target yet
  2240. (e.g., with @code{target remote}), the @code{run} command starts your
  2241. program as a native process under @value{GDBN}, on your local machine.
  2242. If you're sure you don't want to debug programs on your local machine,
  2243. you can tell @value{GDBN} to not connect to the native target
  2244. automatically with the @code{set auto-connect-native-target off}
  2245. command.
  2246. If @code{on}, which is the default, and if the current inferior is not
  2247. connected to a target already, the @code{run} command automaticaly
  2248. connects to the native target, if one is available.
  2249. If @code{off}, and if the current inferior is not connected to a
  2250. target already, the @code{run} command fails with an error:
  2251. @smallexample
  2252. (@value{GDBP}) run
  2253. Don't know how to run. Try "help target".
  2254. @end smallexample
  2255. If the current inferior is already connected to a target, @value{GDBN}
  2256. always uses it with the @code{run} command.
  2257. In any case, you can explicitly connect to the native target with the
  2258. @code{target native} command. For example,
  2259. @smallexample
  2260. (@value{GDBP}) set auto-connect-native-target off
  2261. (@value{GDBP}) run
  2262. Don't know how to run. Try "help target".
  2263. (@value{GDBP}) target native
  2264. (@value{GDBP}) run
  2265. Starting program: ./a.out
  2266. [Inferior 1 (process 10421) exited normally]
  2267. @end smallexample
  2268. In case you connected explicitly to the @code{native} target,
  2269. @value{GDBN} remains connected even if all inferiors exit, ready for
  2270. the next @code{run} command. Use the @code{disconnect} command to
  2271. disconnect.
  2272. Examples of other commands that likewise respect the
  2273. @code{auto-connect-native-target} setting: @code{attach}, @code{info
  2274. proc}, @code{info os}.
  2275. @kindex set disable-randomization
  2276. @item set disable-randomization
  2277. @itemx set disable-randomization on
  2278. This option (enabled by default in @value{GDBN}) will turn off the native
  2279. randomization of the virtual address space of the started program. This option
  2280. is useful for multiple debugging sessions to make the execution better
  2281. reproducible and memory addresses reusable across debugging sessions.
  2282. This feature is implemented only on certain targets, including @sc{gnu}/Linux.
  2283. On @sc{gnu}/Linux you can get the same behavior using
  2284. @smallexample
  2285. (@value{GDBP}) set exec-wrapper setarch `uname -m` -R
  2286. @end smallexample
  2287. @item set disable-randomization off
  2288. Leave the behavior of the started executable unchanged. Some bugs rear their
  2289. ugly heads only when the program is loaded at certain addresses. If your bug
  2290. disappears when you run the program under @value{GDBN}, that might be because
  2291. @value{GDBN} by default disables the address randomization on platforms, such
  2292. as @sc{gnu}/Linux, which do that for stand-alone programs. Use @kbd{set
  2293. disable-randomization off} to try to reproduce such elusive bugs.
  2294. On targets where it is available, virtual address space randomization
  2295. protects the programs against certain kinds of security attacks. In these
  2296. cases the attacker needs to know the exact location of a concrete executable
  2297. code. Randomizing its location makes it impossible to inject jumps misusing
  2298. a code at its expected addresses.
  2299. Prelinking shared libraries provides a startup performance advantage but it
  2300. makes addresses in these libraries predictable for privileged processes by
  2301. having just unprivileged access at the target system. Reading the shared
  2302. library binary gives enough information for assembling the malicious code
  2303. misusing it. Still even a prelinked shared library can get loaded at a new
  2304. random address just requiring the regular relocation process during the
  2305. startup. Shared libraries not already prelinked are always loaded at
  2306. a randomly chosen address.
  2307. Position independent executables (PIE) contain position independent code
  2308. similar to the shared libraries and therefore such executables get loaded at
  2309. a randomly chosen address upon startup. PIE executables always load even
  2310. already prelinked shared libraries at a random address. You can build such
  2311. executable using @command{gcc -fPIE -pie}.
  2312. Heap (malloc storage), stack and custom mmap areas are always placed randomly
  2313. (as long as the randomization is enabled).
  2314. @item show disable-randomization
  2315. Show the current setting of the explicit disable of the native randomization of
  2316. the virtual address space of the started program.
  2317. @end table
  2318. @node Arguments
  2319. @section Your Program's Arguments
  2320. @cindex arguments (to your program)
  2321. The arguments to your program can be specified by the arguments of the
  2322. @code{run} command.
  2323. They are passed to a shell, which expands wildcard characters and
  2324. performs redirection of I/O, and thence to your program. Your
  2325. @env{SHELL} environment variable (if it exists) specifies what shell
  2326. @value{GDBN} uses. If you do not define @env{SHELL}, @value{GDBN} uses
  2327. the default shell (@file{/bin/sh} on Unix).
  2328. On non-Unix systems, the program is usually invoked directly by
  2329. @value{GDBN}, which emulates I/O redirection via the appropriate system
  2330. calls, and the wildcard characters are expanded by the startup code of
  2331. the program, not by the shell.
  2332. @code{run} with no arguments uses the same arguments used by the previous
  2333. @code{run}, or those set by the @code{set args} command.
  2334. @table @code
  2335. @kindex set args
  2336. @item set args
  2337. Specify the arguments to be used the next time your program is run. If
  2338. @code{set args} has no arguments, @code{run} executes your program
  2339. with no arguments. Once you have run your program with arguments,
  2340. using @code{set args} before the next @code{run} is the only way to run
  2341. it again without arguments.
  2342. @kindex show args
  2343. @item show args
  2344. Show the arguments to give your program when it is started.
  2345. @end table
  2346. @node Environment
  2347. @section Your Program's Environment
  2348. @cindex environment (of your program)
  2349. The @dfn{environment} consists of a set of environment variables and
  2350. their values. Environment variables conventionally record such things as
  2351. your user name, your home directory, your terminal type, and your search
  2352. path for programs to run. Usually you set up environment variables with
  2353. the shell and they are inherited by all the other programs you run. When
  2354. debugging, it can be useful to try running your program with a modified
  2355. environment without having to start @value{GDBN} over again.
  2356. @table @code
  2357. @kindex path
  2358. @item path @var{directory}
  2359. Add @var{directory} to the front of the @env{PATH} environment variable
  2360. (the search path for executables) that will be passed to your program.
  2361. The value of @env{PATH} used by @value{GDBN} does not change.
  2362. You may specify several directory names, separated by whitespace or by a
  2363. system-dependent separator character (@samp{:} on Unix, @samp{;} on
  2364. MS-DOS and MS-Windows). If @var{directory} is already in the path, it
  2365. is moved to the front, so it is searched sooner.
  2366. You can use the string @samp{$cwd} to refer to whatever is the current
  2367. working directory at the time @value{GDBN} searches the path. If you
  2368. use @samp{.} instead, it refers to the directory where you executed the
  2369. @code{path} command. @value{GDBN} replaces @samp{.} in the
  2370. @var{directory} argument (with the current path) before adding
  2371. @var{directory} to the search path.
  2372. @c 'path' is explicitly nonrepeatable, but RMS points out it is silly to
  2373. @c document that, since repeating it would be a no-op.
  2374. @kindex show paths
  2375. @item show paths
  2376. Display the list of search paths for executables (the @env{PATH}
  2377. environment variable).
  2378. @kindex show environment
  2379. @item show environment @r{[}@var{varname}@r{]}
  2380. Print the value of environment variable @var{varname} to be given to
  2381. your program when it starts. If you do not supply @var{varname},
  2382. print the names and values of all environment variables to be given to
  2383. your program. You can abbreviate @code{environment} as @code{env}.
  2384. @kindex set environment
  2385. @anchor{set environment}
  2386. @item set environment @var{varname} @r{[}=@var{value}@r{]}
  2387. Set environment variable @var{varname} to @var{value}. The value
  2388. changes for your program (and the shell @value{GDBN} uses to launch
  2389. it), not for @value{GDBN} itself. The @var{value} may be any string; the
  2390. values of environment variables are just strings, and any
  2391. interpretation is supplied by your program itself. The @var{value}
  2392. parameter is optional; if it is eliminated, the variable is set to a
  2393. null value.
  2394. @c "any string" here does not include leading, trailing
  2395. @c blanks. Gnu asks: does anyone care?
  2396. For example, this command:
  2397. @smallexample
  2398. set env USER = foo
  2399. @end smallexample
  2400. @noindent
  2401. tells the debugged program, when subsequently run, that its user is named
  2402. @samp{foo}. (The spaces around @samp{=} are used for clarity here; they
  2403. are not actually required.)
  2404. Note that on Unix systems, @value{GDBN} runs your program via a shell,
  2405. which also inherits the environment set with @code{set environment}.
  2406. If necessary, you can avoid that by using the @samp{env} program as a
  2407. wrapper instead of using @code{set environment}. @xref{set
  2408. exec-wrapper}, for an example doing just that.
  2409. Environment variables that are set by the user are also transmitted to
  2410. @command{gdbserver} to be used when starting the remote inferior.
  2411. @pxref{QEnvironmentHexEncoded}.
  2412. @kindex unset environment
  2413. @anchor{unset environment}
  2414. @item unset environment @var{varname}
  2415. Remove variable @var{varname} from the environment to be passed to your
  2416. program. This is different from @samp{set env @var{varname} =};
  2417. @code{unset environment} removes the variable from the environment,
  2418. rather than assigning it an empty value.
  2419. Environment variables that are unset by the user are also unset on
  2420. @command{gdbserver} when starting the remote inferior.
  2421. @pxref{QEnvironmentUnset}.
  2422. @end table
  2423. @emph{Warning:} On Unix systems, @value{GDBN} runs your program using
  2424. the shell indicated by your @env{SHELL} environment variable if it
  2425. exists (or @code{/bin/sh} if not). If your @env{SHELL} variable
  2426. names a shell that runs an initialization file when started
  2427. non-interactively---such as @file{.cshrc} for C-shell, $@file{.zshenv}
  2428. for the Z shell, or the file specified in the @env{BASH_ENV}
  2429. environment variable for BASH---any variables you set in that file
  2430. affect your program. You may wish to move setting of environment
  2431. variables to files that are only run when you sign on, such as
  2432. @file{.login} or @file{.profile}.
  2433. @node Working Directory
  2434. @section Your Program's Working Directory
  2435. @cindex working directory (of your program)
  2436. Each time you start your program with @code{run}, the inferior will be
  2437. initialized with the current working directory specified by the
  2438. @kbd{set cwd} command. If no directory has been specified by this
  2439. command, then the inferior will inherit @value{GDBN}'s current working
  2440. directory as its working directory if native debugging, or it will
  2441. inherit the remote server's current working directory if remote
  2442. debugging.
  2443. @table @code
  2444. @kindex set cwd
  2445. @cindex change inferior's working directory
  2446. @anchor{set cwd command}
  2447. @item set cwd @r{[}@var{directory}@r{]}
  2448. Set the inferior's working directory to @var{directory}, which will be
  2449. @code{glob}-expanded in order to resolve tildes (@file{~}). If no
  2450. argument has been specified, the command clears the setting and resets
  2451. it to an empty state. This setting has no effect on @value{GDBN}'s
  2452. working directory, and it only takes effect the next time you start
  2453. the inferior. The @file{~} in @var{directory} is a short for the
  2454. @dfn{home directory}, usually pointed to by the @env{HOME} environment
  2455. variable. On MS-Windows, if @env{HOME} is not defined, @value{GDBN}
  2456. uses the concatenation of @env{HOMEDRIVE} and @env{HOMEPATH} as
  2457. fallback.
  2458. You can also change @value{GDBN}'s current working directory by using
  2459. the @code{cd} command.
  2460. @xref{cd command}.
  2461. @kindex show cwd
  2462. @cindex show inferior's working directory
  2463. @item show cwd
  2464. Show the inferior's working directory. If no directory has been
  2465. specified by @kbd{set cwd}, then the default inferior's working
  2466. directory is the same as @value{GDBN}'s working directory.
  2467. @kindex cd
  2468. @cindex change @value{GDBN}'s working directory
  2469. @anchor{cd command}
  2470. @item cd @r{[}@var{directory}@r{]}
  2471. Set the @value{GDBN} working directory to @var{directory}. If not
  2472. given, @var{directory} uses @file{'~'}.
  2473. The @value{GDBN} working directory serves as a default for the
  2474. commands that specify files for @value{GDBN} to operate on.
  2475. @xref{Files, ,Commands to Specify Files}.
  2476. @xref{set cwd command}.
  2477. @kindex pwd
  2478. @item pwd
  2479. Print the @value{GDBN} working directory.
  2480. @end table
  2481. It is generally impossible to find the current working directory of
  2482. the process being debugged (since a program can change its directory
  2483. during its run). If you work on a system where @value{GDBN} supports
  2484. the @code{info proc} command (@pxref{Process Information}), you can
  2485. use the @code{info proc} command to find out the
  2486. current working directory of the debuggee.
  2487. @node Input/Output
  2488. @section Your Program's Input and Output
  2489. @cindex redirection
  2490. @cindex i/o
  2491. @cindex terminal
  2492. By default, the program you run under @value{GDBN} does input and output to
  2493. the same terminal that @value{GDBN} uses. @value{GDBN} switches the terminal
  2494. to its own terminal modes to interact with you, but it records the terminal
  2495. modes your program was using and switches back to them when you continue
  2496. running your program.
  2497. @table @code
  2498. @kindex info terminal
  2499. @item info terminal
  2500. Displays information recorded by @value{GDBN} about the terminal modes your
  2501. program is using.
  2502. @end table
  2503. You can redirect your program's input and/or output using shell
  2504. redirection with the @code{run} command. For example,
  2505. @smallexample
  2506. run > outfile
  2507. @end smallexample
  2508. @noindent
  2509. starts your program, diverting its output to the file @file{outfile}.
  2510. @kindex tty
  2511. @cindex controlling terminal
  2512. Another way to specify where your program should do input and output is
  2513. with the @code{tty} command. This command accepts a file name as
  2514. argument, and causes this file to be the default for future @code{run}
  2515. commands. It also resets the controlling terminal for the child
  2516. process, for future @code{run} commands. For example,
  2517. @smallexample
  2518. tty /dev/ttyb
  2519. @end smallexample
  2520. @noindent
  2521. directs that processes started with subsequent @code{run} commands
  2522. default to do input and output on the terminal @file{/dev/ttyb} and have
  2523. that as their controlling terminal.
  2524. An explicit redirection in @code{run} overrides the @code{tty} command's
  2525. effect on the input/output device, but not its effect on the controlling
  2526. terminal.
  2527. When you use the @code{tty} command or redirect input in the @code{run}
  2528. command, only the input @emph{for your program} is affected. The input
  2529. for @value{GDBN} still comes from your terminal. @code{tty} is an alias
  2530. for @code{set inferior-tty}.
  2531. @cindex inferior tty
  2532. @cindex set inferior controlling terminal
  2533. You can use the @code{show inferior-tty} command to tell @value{GDBN} to
  2534. display the name of the terminal that will be used for future runs of your
  2535. program.
  2536. @table @code
  2537. @item set inferior-tty [ @var{tty} ]
  2538. @kindex set inferior-tty
  2539. Set the tty for the program being debugged to @var{tty}. Omitting @var{tty}
  2540. restores the default behavior, which is to use the same terminal as
  2541. @value{GDBN}.
  2542. @item show inferior-tty
  2543. @kindex show inferior-tty
  2544. Show the current tty for the program being debugged.
  2545. @end table
  2546. @node Attach
  2547. @section Debugging an Already-running Process
  2548. @kindex attach
  2549. @cindex attach
  2550. @table @code
  2551. @item attach @var{process-id}
  2552. This command attaches to a running process---one that was started
  2553. outside @value{GDBN}. (@code{info files} shows your active
  2554. targets.) The command takes as argument a process ID. The usual way to
  2555. find out the @var{process-id} of a Unix process is with the @code{ps} utility,
  2556. or with the @samp{jobs -l} shell command.
  2557. @code{attach} does not repeat if you press @key{RET} a second time after
  2558. executing the command.
  2559. @end table
  2560. To use @code{attach}, your program must be running in an environment
  2561. which supports processes; for example, @code{attach} does not work for
  2562. programs on bare-board targets that lack an operating system. You must
  2563. also have permission to send the process a signal.
  2564. When you use @code{attach}, the debugger finds the program running in
  2565. the process first by looking in the current working directory, then (if
  2566. the program is not found) by using the source file search path
  2567. (@pxref{Source Path, ,Specifying Source Directories}). You can also use
  2568. the @code{file} command to load the program. @xref{Files, ,Commands to
  2569. Specify Files}.
  2570. @anchor{set exec-file-mismatch}
  2571. If the debugger can determine that the executable file running in the
  2572. process it is attaching to does not match the current exec-file loaded
  2573. by @value{GDBN}, the option @code{exec-file-mismatch} specifies how to
  2574. handle the mismatch. @value{GDBN} tries to compare the files by
  2575. comparing their build IDs (@pxref{build ID}), if available.
  2576. @table @code
  2577. @kindex exec-file-mismatch
  2578. @cindex set exec-file-mismatch
  2579. @item set exec-file-mismatch @samp{ask|warn|off}
  2580. Whether to detect mismatch between the current executable file loaded
  2581. by @value{GDBN} and the executable file used to start the process. If
  2582. @samp{ask}, the default, display a warning and ask the user whether to
  2583. load the process executable file; if @samp{warn}, just display a
  2584. warning; if @samp{off}, don't attempt to detect a mismatch.
  2585. If the user confirms loading the process executable file, then its symbols
  2586. will be loaded as well.
  2587. @cindex show exec-file-mismatch
  2588. @item show exec-file-mismatch
  2589. Show the current value of @code{exec-file-mismatch}.
  2590. @end table
  2591. The first thing @value{GDBN} does after arranging to debug the specified
  2592. process is to stop it. You can examine and modify an attached process
  2593. with all the @value{GDBN} commands that are ordinarily available when
  2594. you start processes with @code{run}. You can insert breakpoints; you
  2595. can step and continue; you can modify storage. If you would rather the
  2596. process continue running, you may use the @code{continue} command after
  2597. attaching @value{GDBN} to the process.
  2598. @table @code
  2599. @kindex detach
  2600. @item detach
  2601. When you have finished debugging the attached process, you can use the
  2602. @code{detach} command to release it from @value{GDBN} control. Detaching
  2603. the process continues its execution. After the @code{detach} command,
  2604. that process and @value{GDBN} become completely independent once more, and you
  2605. are ready to @code{attach} another process or start one with @code{run}.
  2606. @code{detach} does not repeat if you press @key{RET} again after
  2607. executing the command.
  2608. @end table
  2609. If you exit @value{GDBN} while you have an attached process, you detach
  2610. that process. If you use the @code{run} command, you kill that process.
  2611. By default, @value{GDBN} asks for confirmation if you try to do either of these
  2612. things; you can control whether or not you need to confirm by using the
  2613. @code{set confirm} command (@pxref{Messages/Warnings, ,Optional Warnings and
  2614. Messages}).
  2615. @node Kill Process
  2616. @section Killing the Child Process
  2617. @table @code
  2618. @kindex kill
  2619. @item kill
  2620. Kill the child process in which your program is running under @value{GDBN}.
  2621. @end table
  2622. This command is useful if you wish to debug a core dump instead of a
  2623. running process. @value{GDBN} ignores any core dump file while your program
  2624. is running.
  2625. On some operating systems, a program cannot be executed outside @value{GDBN}
  2626. while you have breakpoints set on it inside @value{GDBN}. You can use the
  2627. @code{kill} command in this situation to permit running your program
  2628. outside the debugger.
  2629. The @code{kill} command is also useful if you wish to recompile and
  2630. relink your program, since on many systems it is impossible to modify an
  2631. executable file while it is running in a process. In this case, when you
  2632. next type @code{run}, @value{GDBN} notices that the file has changed, and
  2633. reads the symbol table again (while trying to preserve your current
  2634. breakpoint settings).
  2635. @node Inferiors Connections and Programs
  2636. @section Debugging Multiple Inferiors Connections and Programs
  2637. @value{GDBN} lets you run and debug multiple programs in a single
  2638. session. In addition, @value{GDBN} on some systems may let you run
  2639. several programs simultaneously (otherwise you have to exit from one
  2640. before starting another). On some systems @value{GDBN} may even let
  2641. you debug several programs simultaneously on different remote systems.
  2642. In the most general case, you can have multiple threads of execution
  2643. in each of multiple processes, launched from multiple executables,
  2644. running on different machines.
  2645. @cindex inferior
  2646. @value{GDBN} represents the state of each program execution with an
  2647. object called an @dfn{inferior}. An inferior typically corresponds to
  2648. a process, but is more general and applies also to targets that do not
  2649. have processes. Inferiors may be created before a process runs, and
  2650. may be retained after a process exits. Inferiors have unique
  2651. identifiers that are different from process ids. Usually each
  2652. inferior will also have its own distinct address space, although some
  2653. embedded targets may have several inferiors running in different parts
  2654. of a single address space. Each inferior may in turn have multiple
  2655. threads running in it.
  2656. To find out what inferiors exist at any moment, use @w{@code{info
  2657. inferiors}}:
  2658. @table @code
  2659. @kindex info inferiors [ @var{id}@dots{} ]
  2660. @item info inferiors
  2661. Print a list of all inferiors currently being managed by @value{GDBN}.
  2662. By default all inferiors are printed, but the argument @var{id}@dots{}
  2663. -- a space separated list of inferior numbers -- can be used to limit
  2664. the display to just the requested inferiors.
  2665. @value{GDBN} displays for each inferior (in this order):
  2666. @enumerate
  2667. @item
  2668. the inferior number assigned by @value{GDBN}
  2669. @item
  2670. the target system's inferior identifier
  2671. @item
  2672. the target connection the inferior is bound to, including the unique
  2673. connection number assigned by @value{GDBN}, and the protocol used by
  2674. the connection.
  2675. @item
  2676. the name of the executable the inferior is running.
  2677. @end enumerate
  2678. @noindent
  2679. An asterisk @samp{*} preceding the @value{GDBN} inferior number
  2680. indicates the current inferior.
  2681. For example,
  2682. @end table
  2683. @c end table here to get a little more width for example
  2684. @smallexample
  2685. (@value{GDBP}) info inferiors
  2686. Num Description Connection Executable
  2687. * 1 process 3401 1 (native) goodbye
  2688. 2 process 2307 2 (extended-remote host:10000) hello
  2689. @end smallexample
  2690. To get informations about the current inferior, use @code{inferior}:
  2691. @table @code
  2692. @kindex inferior
  2693. @item inferior
  2694. Shows information about the current inferior.
  2695. For example,
  2696. @end table
  2697. @c end table here to get a little more width for example
  2698. @smallexample
  2699. (@value{GDBP}) inferior
  2700. [Current inferior is 1 [process 3401] (helloworld)]
  2701. @end smallexample
  2702. To find out what open target connections exist at any moment, use
  2703. @w{@code{info connections}}:
  2704. @table @code
  2705. @kindex info connections [ @var{id}@dots{} ]
  2706. @item info connections
  2707. Print a list of all open target connections currently being managed by
  2708. @value{GDBN}. By default all connections are printed, but the
  2709. argument @var{id}@dots{} -- a space separated list of connections
  2710. numbers -- can be used to limit the display to just the requested
  2711. connections.
  2712. @value{GDBN} displays for each connection (in this order):
  2713. @enumerate
  2714. @item
  2715. the connection number assigned by @value{GDBN}.
  2716. @item
  2717. the protocol used by the connection.
  2718. @item
  2719. a textual description of the protocol used by the connection.
  2720. @end enumerate
  2721. @noindent
  2722. An asterisk @samp{*} preceding the connection number indicates the
  2723. connection of the current inferior.
  2724. For example,
  2725. @end table
  2726. @c end table here to get a little more width for example
  2727. @smallexample
  2728. (@value{GDBP}) info connections
  2729. Num What Description
  2730. * 1 extended-remote host:10000 Extended remote serial target in gdb-specific protocol
  2731. 2 native Native process
  2732. 3 core Local core dump file
  2733. @end smallexample
  2734. To switch focus between inferiors, use the @code{inferior} command:
  2735. @table @code
  2736. @kindex inferior @var{infno}
  2737. @item inferior @var{infno}
  2738. Make inferior number @var{infno} the current inferior. The argument
  2739. @var{infno} is the inferior number assigned by @value{GDBN}, as shown
  2740. in the first field of the @samp{info inferiors} display.
  2741. @end table
  2742. @vindex $_inferior@r{, convenience variable}
  2743. The debugger convenience variable @samp{$_inferior} contains the
  2744. number of the current inferior. You may find this useful in writing
  2745. breakpoint conditional expressions, command scripts, and so forth.
  2746. @xref{Convenience Vars,, Convenience Variables}, for general
  2747. information on convenience variables.
  2748. You can get multiple executables into a debugging session via the
  2749. @code{add-inferior} and @w{@code{clone-inferior}} commands. On some
  2750. systems @value{GDBN} can add inferiors to the debug session
  2751. automatically by following calls to @code{fork} and @code{exec}. To
  2752. remove inferiors from the debugging session use the
  2753. @w{@code{remove-inferiors}} command.
  2754. @table @code
  2755. @anchor{add_inferior_cli}
  2756. @kindex add-inferior
  2757. @item add-inferior [ -copies @var{n} ] [ -exec @var{executable} ] [-no-connection ]
  2758. Adds @var{n} inferiors to be run using @var{executable} as the
  2759. executable; @var{n} defaults to 1. If no executable is specified,
  2760. the inferiors begins empty, with no program. You can still assign or
  2761. change the program assigned to the inferior at any time by using the
  2762. @code{file} command with the executable name as its argument.
  2763. By default, the new inferior begins connected to the same target
  2764. connection as the current inferior. For example, if the current
  2765. inferior was connected to @code{gdbserver} with @code{target remote},
  2766. then the new inferior will be connected to the same @code{gdbserver}
  2767. instance. The @samp{-no-connection} option starts the new inferior
  2768. with no connection yet. You can then for example use the @code{target
  2769. remote} command to connect to some other @code{gdbserver} instance,
  2770. use @code{run} to spawn a local program, etc.
  2771. @kindex clone-inferior
  2772. @item clone-inferior [ -copies @var{n} ] [ @var{infno} ]
  2773. Adds @var{n} inferiors ready to execute the same program as inferior
  2774. @var{infno}; @var{n} defaults to 1, and @var{infno} defaults to the
  2775. number of the current inferior. This command copies the values of the
  2776. @var{args}, @w{@var{inferior-tty}} and @var{cwd} properties from the
  2777. current inferior to the new one. It also propagates changes the user
  2778. made to environment variables using the @w{@code{set environment}} and
  2779. @w{@code{unset environment}} commands. This is a convenient command
  2780. when you want to run another instance of the inferior you are debugging.
  2781. @smallexample
  2782. (@value{GDBP}) info inferiors
  2783. Num Description Connection Executable
  2784. * 1 process 29964 1 (native) helloworld
  2785. (@value{GDBP}) clone-inferior
  2786. Added inferior 2.
  2787. 1 inferiors added.
  2788. (@value{GDBP}) info inferiors
  2789. Num Description Connection Executable
  2790. * 1 process 29964 1 (native) helloworld
  2791. 2 <null> 1 (native) helloworld
  2792. @end smallexample
  2793. You can now simply switch focus to inferior 2 and run it.
  2794. @kindex remove-inferiors
  2795. @item remove-inferiors @var{infno}@dots{}
  2796. Removes the inferior or inferiors @var{infno}@dots{}. It is not
  2797. possible to remove an inferior that is running with this command. For
  2798. those, use the @code{kill} or @code{detach} command first.
  2799. @end table
  2800. To quit debugging one of the running inferiors that is not the current
  2801. inferior, you can either detach from it by using the @w{@code{detach
  2802. inferior}} command (allowing it to run independently), or kill it
  2803. using the @w{@code{kill inferiors}} command:
  2804. @table @code
  2805. @kindex detach inferiors @var{infno}@dots{}
  2806. @item detach inferior @var{infno}@dots{}
  2807. Detach from the inferior or inferiors identified by @value{GDBN}
  2808. inferior number(s) @var{infno}@dots{}. Note that the inferior's entry
  2809. still stays on the list of inferiors shown by @code{info inferiors},
  2810. but its Description will show @samp{<null>}.
  2811. @kindex kill inferiors @var{infno}@dots{}
  2812. @item kill inferiors @var{infno}@dots{}
  2813. Kill the inferior or inferiors identified by @value{GDBN} inferior
  2814. number(s) @var{infno}@dots{}. Note that the inferior's entry still
  2815. stays on the list of inferiors shown by @code{info inferiors}, but its
  2816. Description will show @samp{<null>}.
  2817. @end table
  2818. After the successful completion of a command such as @code{detach},
  2819. @code{detach inferiors}, @code{kill} or @code{kill inferiors}, or after
  2820. a normal process exit, the inferior is still valid and listed with
  2821. @code{info inferiors}, ready to be restarted.
  2822. To be notified when inferiors are started or exit under @value{GDBN}'s
  2823. control use @w{@code{set print inferior-events}}:
  2824. @table @code
  2825. @kindex set print inferior-events
  2826. @cindex print messages on inferior start and exit
  2827. @item set print inferior-events
  2828. @itemx set print inferior-events on
  2829. @itemx set print inferior-events off
  2830. The @code{set print inferior-events} command allows you to enable or
  2831. disable printing of messages when @value{GDBN} notices that new
  2832. inferiors have started or that inferiors have exited or have been
  2833. detached. By default, these messages will be printed.
  2834. @kindex show print inferior-events
  2835. @item show print inferior-events
  2836. Show whether messages will be printed when @value{GDBN} detects that
  2837. inferiors have started, exited or have been detached.
  2838. @end table
  2839. Many commands will work the same with multiple programs as with a
  2840. single program: e.g., @code{print myglobal} will simply display the
  2841. value of @code{myglobal} in the current inferior.
  2842. Occasionally, when debugging @value{GDBN} itself, it may be useful to
  2843. get more info about the relationship of inferiors, programs, address
  2844. spaces in a debug session. You can do that with the @w{@code{maint
  2845. info program-spaces}} command.
  2846. @table @code
  2847. @kindex maint info program-spaces
  2848. @item maint info program-spaces
  2849. Print a list of all program spaces currently being managed by
  2850. @value{GDBN}.
  2851. @value{GDBN} displays for each program space (in this order):
  2852. @enumerate
  2853. @item
  2854. the program space number assigned by @value{GDBN}
  2855. @item
  2856. the name of the executable loaded into the program space, with e.g.,
  2857. the @code{file} command.
  2858. @end enumerate
  2859. @noindent
  2860. An asterisk @samp{*} preceding the @value{GDBN} program space number
  2861. indicates the current program space.
  2862. In addition, below each program space line, @value{GDBN} prints extra
  2863. information that isn't suitable to display in tabular form. For
  2864. example, the list of inferiors bound to the program space.
  2865. @smallexample
  2866. (@value{GDBP}) maint info program-spaces
  2867. Id Executable
  2868. * 1 hello
  2869. 2 goodbye
  2870. Bound inferiors: ID 1 (process 21561)
  2871. @end smallexample
  2872. Here we can see that no inferior is running the program @code{hello},
  2873. while @code{process 21561} is running the program @code{goodbye}. On
  2874. some targets, it is possible that multiple inferiors are bound to the
  2875. same program space. The most common example is that of debugging both
  2876. the parent and child processes of a @code{vfork} call. For example,
  2877. @smallexample
  2878. (@value{GDBP}) maint info program-spaces
  2879. Id Executable
  2880. * 1 vfork-test
  2881. Bound inferiors: ID 2 (process 18050), ID 1 (process 18045)
  2882. @end smallexample
  2883. Here, both inferior 2 and inferior 1 are running in the same program
  2884. space as a result of inferior 1 having executed a @code{vfork} call.
  2885. @end table
  2886. @node Threads
  2887. @section Debugging Programs with Multiple Threads
  2888. @cindex threads of execution
  2889. @cindex multiple threads
  2890. @cindex switching threads
  2891. In some operating systems, such as GNU/Linux and Solaris, a single program
  2892. may have more than one @dfn{thread} of execution. The precise semantics
  2893. of threads differ from one operating system to another, but in general
  2894. the threads of a single program are akin to multiple processes---except
  2895. that they share one address space (that is, they can all examine and
  2896. modify the same variables). On the other hand, each thread has its own
  2897. registers and execution stack, and perhaps private memory.
  2898. @value{GDBN} provides these facilities for debugging multi-thread
  2899. programs:
  2900. @itemize @bullet
  2901. @item automatic notification of new threads
  2902. @item @samp{thread @var{thread-id}}, a command to switch among threads
  2903. @item @samp{info threads}, a command to inquire about existing threads
  2904. @item @samp{thread apply [@var{thread-id-list} | all] @var{args}},
  2905. a command to apply a command to a list of threads
  2906. @item thread-specific breakpoints
  2907. @item @samp{set print thread-events}, which controls printing of
  2908. messages on thread start and exit.
  2909. @item @samp{set libthread-db-search-path @var{path}}, which lets
  2910. the user specify which @code{libthread_db} to use if the default choice
  2911. isn't compatible with the program.
  2912. @end itemize
  2913. @cindex focus of debugging
  2914. @cindex current thread
  2915. The @value{GDBN} thread debugging facility allows you to observe all
  2916. threads while your program runs---but whenever @value{GDBN} takes
  2917. control, one thread in particular is always the focus of debugging.
  2918. This thread is called the @dfn{current thread}. Debugging commands show
  2919. program information from the perspective of the current thread.
  2920. @cindex @code{New} @var{systag} message
  2921. @cindex thread identifier (system)
  2922. @c FIXME-implementors!! It would be more helpful if the [New...] message
  2923. @c included GDB's numeric thread handle, so you could just go to that
  2924. @c thread without first checking `info threads'.
  2925. Whenever @value{GDBN} detects a new thread in your program, it displays
  2926. the target system's identification for the thread with a message in the
  2927. form @samp{[New @var{systag}]}, where @var{systag} is a thread identifier
  2928. whose form varies depending on the particular system. For example, on
  2929. @sc{gnu}/Linux, you might see
  2930. @smallexample
  2931. [New Thread 0x41e02940 (LWP 25582)]
  2932. @end smallexample
  2933. @noindent
  2934. when @value{GDBN} notices a new thread. In contrast, on other systems,
  2935. the @var{systag} is simply something like @samp{process 368}, with no
  2936. further qualifier.
  2937. @c FIXME!! (1) Does the [New...] message appear even for the very first
  2938. @c thread of a program, or does it only appear for the
  2939. @c second---i.e.@: when it becomes obvious we have a multithread
  2940. @c program?
  2941. @c (2) *Is* there necessarily a first thread always? Or do some
  2942. @c multithread systems permit starting a program with multiple
  2943. @c threads ab initio?
  2944. @anchor{thread numbers}
  2945. @cindex thread number, per inferior
  2946. @cindex thread identifier (GDB)
  2947. For debugging purposes, @value{GDBN} associates its own thread number
  2948. ---always a single integer---with each thread of an inferior. This
  2949. number is unique between all threads of an inferior, but not unique
  2950. between threads of different inferiors.
  2951. @cindex qualified thread ID
  2952. You can refer to a given thread in an inferior using the qualified
  2953. @var{inferior-num}.@var{thread-num} syntax, also known as
  2954. @dfn{qualified thread ID}, with @var{inferior-num} being the inferior
  2955. number and @var{thread-num} being the thread number of the given
  2956. inferior. For example, thread @code{2.3} refers to thread number 3 of
  2957. inferior 2. If you omit @var{inferior-num} (e.g., @code{thread 3}),
  2958. then @value{GDBN} infers you're referring to a thread of the current
  2959. inferior.
  2960. Until you create a second inferior, @value{GDBN} does not show the
  2961. @var{inferior-num} part of thread IDs, even though you can always use
  2962. the full @var{inferior-num}.@var{thread-num} form to refer to threads
  2963. of inferior 1, the initial inferior.
  2964. @anchor{thread ID lists}
  2965. @cindex thread ID lists
  2966. Some commands accept a space-separated @dfn{thread ID list} as
  2967. argument. A list element can be:
  2968. @enumerate
  2969. @item
  2970. A thread ID as shown in the first field of the @samp{info threads}
  2971. display, with or without an inferior qualifier. E.g., @samp{2.1} or
  2972. @samp{1}.
  2973. @item
  2974. A range of thread numbers, again with or without an inferior
  2975. qualifier, as in @var{inf}.@var{thr1}-@var{thr2} or
  2976. @var{thr1}-@var{thr2}. E.g., @samp{1.2-4} or @samp{2-4}.
  2977. @item
  2978. All threads of an inferior, specified with a star wildcard, with or
  2979. without an inferior qualifier, as in @var{inf}.@code{*} (e.g.,
  2980. @samp{1.*}) or @code{*}. The former refers to all threads of the
  2981. given inferior, and the latter form without an inferior qualifier
  2982. refers to all threads of the current inferior.
  2983. @end enumerate
  2984. For example, if the current inferior is 1, and inferior 7 has one
  2985. thread with ID 7.1, the thread list @samp{1 2-3 4.5 6.7-9 7.*}
  2986. includes threads 1 to 3 of inferior 1, thread 5 of inferior 4, threads
  2987. 7 to 9 of inferior 6 and all threads of inferior 7. That is, in
  2988. expanded qualified form, the same as @samp{1.1 1.2 1.3 4.5 6.7 6.8 6.9
  2989. 7.1}.
  2990. @anchor{global thread numbers}
  2991. @cindex global thread number
  2992. @cindex global thread identifier (GDB)
  2993. In addition to a @emph{per-inferior} number, each thread is also
  2994. assigned a unique @emph{global} number, also known as @dfn{global
  2995. thread ID}, a single integer. Unlike the thread number component of
  2996. the thread ID, no two threads have the same global ID, even when
  2997. you're debugging multiple inferiors.
  2998. From @value{GDBN}'s perspective, a process always has at least one
  2999. thread. In other words, @value{GDBN} assigns a thread number to the
  3000. program's ``main thread'' even if the program is not multi-threaded.
  3001. @vindex $_thread@r{, convenience variable}
  3002. @vindex $_gthread@r{, convenience variable}
  3003. The debugger convenience variables @samp{$_thread} and
  3004. @samp{$_gthread} contain, respectively, the per-inferior thread number
  3005. and the global thread number of the current thread. You may find this
  3006. useful in writing breakpoint conditional expressions, command scripts,
  3007. and so forth. @xref{Convenience Vars,, Convenience Variables}, for
  3008. general information on convenience variables.
  3009. If @value{GDBN} detects the program is multi-threaded, it augments the
  3010. usual message about stopping at a breakpoint with the ID and name of
  3011. the thread that hit the breakpoint.
  3012. @smallexample
  3013. Thread 2 "client" hit Breakpoint 1, send_message () at client.c:68
  3014. @end smallexample
  3015. Likewise when the program receives a signal:
  3016. @smallexample
  3017. Thread 1 "main" received signal SIGINT, Interrupt.
  3018. @end smallexample
  3019. @table @code
  3020. @anchor{info_threads}
  3021. @kindex info threads
  3022. @item info threads @r{[}@var{thread-id-list}@r{]}
  3023. Display information about one or more threads. With no arguments
  3024. displays information about all threads. You can specify the list of
  3025. threads that you want to display using the thread ID list syntax
  3026. (@pxref{thread ID lists}).
  3027. @value{GDBN} displays for each thread (in this order):
  3028. @enumerate
  3029. @item
  3030. the per-inferior thread number assigned by @value{GDBN}
  3031. @item
  3032. the global thread number assigned by @value{GDBN}, if the @samp{-gid}
  3033. option was specified
  3034. @item
  3035. the target system's thread identifier (@var{systag})
  3036. @item
  3037. the thread's name, if one is known. A thread can either be named by
  3038. the user (see @code{thread name}, below), or, in some cases, by the
  3039. program itself.
  3040. @item
  3041. the current stack frame summary for that thread
  3042. @end enumerate
  3043. @noindent
  3044. An asterisk @samp{*} to the left of the @value{GDBN} thread number
  3045. indicates the current thread.
  3046. For example,
  3047. @end table
  3048. @c end table here to get a little more width for example
  3049. @smallexample
  3050. (@value{GDBP}) info threads
  3051. Id Target Id Frame
  3052. * 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
  3053. 2 process 35 thread 23 0x34e5 in sigpause ()
  3054. 3 process 35 thread 27 0x34e5 in sigpause ()
  3055. at threadtest.c:68
  3056. @end smallexample
  3057. If you're debugging multiple inferiors, @value{GDBN} displays thread
  3058. IDs using the qualified @var{inferior-num}.@var{thread-num} format.
  3059. Otherwise, only @var{thread-num} is shown.
  3060. If you specify the @samp{-gid} option, @value{GDBN} displays a column
  3061. indicating each thread's global thread ID:
  3062. @smallexample
  3063. (@value{GDBP}) info threads
  3064. Id GId Target Id Frame
  3065. 1.1 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8)
  3066. 1.2 3 process 35 thread 23 0x34e5 in sigpause ()
  3067. 1.3 4 process 35 thread 27 0x34e5 in sigpause ()
  3068. * 2.1 2 process 65 thread 1 main (argc=1, argv=0x7ffffff8)
  3069. @end smallexample
  3070. On Solaris, you can display more information about user threads with a
  3071. Solaris-specific command:
  3072. @table @code
  3073. @item maint info sol-threads
  3074. @kindex maint info sol-threads
  3075. @cindex thread info (Solaris)
  3076. Display info on Solaris user threads.
  3077. @end table
  3078. @table @code
  3079. @kindex thread @var{thread-id}
  3080. @item thread @var{thread-id}
  3081. Make thread ID @var{thread-id} the current thread. The command
  3082. argument @var{thread-id} is the @value{GDBN} thread ID, as shown in
  3083. the first field of the @samp{info threads} display, with or without an
  3084. inferior qualifier (e.g., @samp{2.1} or @samp{1}).
  3085. @value{GDBN} responds by displaying the system identifier of the
  3086. thread you selected, and its current stack frame summary:
  3087. @smallexample
  3088. (@value{GDBP}) thread 2
  3089. [Switching to thread 2 (Thread 0xb7fdab70 (LWP 12747))]
  3090. #0 some_function (ignore=0x0) at example.c:8
  3091. 8 printf ("hello\n");
  3092. @end smallexample
  3093. @noindent
  3094. As with the @samp{[New @dots{}]} message, the form of the text after
  3095. @samp{Switching to} depends on your system's conventions for identifying
  3096. threads.
  3097. @anchor{thread apply all}
  3098. @kindex thread apply
  3099. @cindex apply command to several threads
  3100. @item thread apply [@var{thread-id-list} | all [-ascending]] [@var{flag}]@dots{} @var{command}
  3101. The @code{thread apply} command allows you to apply the named
  3102. @var{command} to one or more threads. Specify the threads that you
  3103. want affected using the thread ID list syntax (@pxref{thread ID
  3104. lists}), or specify @code{all} to apply to all threads. To apply a
  3105. command to all threads in descending order, type @kbd{thread apply all
  3106. @var{command}}. To apply a command to all threads in ascending order,
  3107. type @kbd{thread apply all -ascending @var{command}}.
  3108. The @var{flag} arguments control what output to produce and how to handle
  3109. errors raised when applying @var{command} to a thread. @var{flag}
  3110. must start with a @code{-} directly followed by one letter in
  3111. @code{qcs}. If several flags are provided, they must be given
  3112. individually, such as @code{-c -q}.
  3113. By default, @value{GDBN} displays some thread information before the
  3114. output produced by @var{command}, and an error raised during the
  3115. execution of a @var{command} will abort @code{thread apply}. The
  3116. following flags can be used to fine-tune this behavior:
  3117. @table @code
  3118. @item -c
  3119. The flag @code{-c}, which stands for @samp{continue}, causes any
  3120. errors in @var{command} to be displayed, and the execution of
  3121. @code{thread apply} then continues.
  3122. @item -s
  3123. The flag @code{-s}, which stands for @samp{silent}, causes any errors
  3124. or empty output produced by a @var{command} to be silently ignored.
  3125. That is, the execution continues, but the thread information and errors
  3126. are not printed.
  3127. @item -q
  3128. The flag @code{-q} (@samp{quiet}) disables printing the thread
  3129. information.
  3130. @end table
  3131. Flags @code{-c} and @code{-s} cannot be used together.
  3132. @kindex taas
  3133. @cindex apply command to all threads (ignoring errors and empty output)
  3134. @item taas [@var{option}]@dots{} @var{command}
  3135. Shortcut for @code{thread apply all -s [@var{option}]@dots{} @var{command}}.
  3136. Applies @var{command} on all threads, ignoring errors and empty output.
  3137. The @code{taas} command accepts the same options as the @code{thread
  3138. apply all} command. @xref{thread apply all}.
  3139. @kindex tfaas
  3140. @cindex apply a command to all frames of all threads (ignoring errors and empty output)
  3141. @item tfaas [@var{option}]@dots{} @var{command}
  3142. Shortcut for @code{thread apply all -s -- frame apply all -s [@var{option}]@dots{} @var{command}}.
  3143. Applies @var{command} on all frames of all threads, ignoring errors
  3144. and empty output. Note that the flag @code{-s} is specified twice:
  3145. The first @code{-s} ensures that @code{thread apply} only shows the thread
  3146. information of the threads for which @code{frame apply} produces
  3147. some output. The second @code{-s} is needed to ensure that @code{frame
  3148. apply} shows the frame information of a frame only if the
  3149. @var{command} successfully produced some output.
  3150. It can for example be used to print a local variable or a function
  3151. argument without knowing the thread or frame where this variable or argument
  3152. is, using:
  3153. @smallexample
  3154. (@value{GDBP}) tfaas p some_local_var_i_do_not_remember_where_it_is
  3155. @end smallexample
  3156. The @code{tfaas} command accepts the same options as the @code{frame
  3157. apply} command. @xref{Frame Apply,,frame apply}.
  3158. @kindex thread name
  3159. @cindex name a thread
  3160. @item thread name [@var{name}]
  3161. This command assigns a name to the current thread. If no argument is
  3162. given, any existing user-specified name is removed. The thread name
  3163. appears in the @samp{info threads} display.
  3164. On some systems, such as @sc{gnu}/Linux, @value{GDBN} is able to
  3165. determine the name of the thread as given by the OS. On these
  3166. systems, a name specified with @samp{thread name} will override the
  3167. system-give name, and removing the user-specified name will cause
  3168. @value{GDBN} to once again display the system-specified name.
  3169. @kindex thread find
  3170. @cindex search for a thread
  3171. @item thread find [@var{regexp}]
  3172. Search for and display thread ids whose name or @var{systag}
  3173. matches the supplied regular expression.
  3174. As well as being the complement to the @samp{thread name} command,
  3175. this command also allows you to identify a thread by its target
  3176. @var{systag}. For instance, on @sc{gnu}/Linux, the target @var{systag}
  3177. is the LWP id.
  3178. @smallexample
  3179. (@value{GDBN}) thread find 26688
  3180. Thread 4 has target id 'Thread 0x41e02940 (LWP 26688)'
  3181. (@value{GDBN}) info thread 4
  3182. Id Target Id Frame
  3183. 4 Thread 0x41e02940 (LWP 26688) 0x00000031ca6cd372 in select ()
  3184. @end smallexample
  3185. @kindex set print thread-events
  3186. @cindex print messages on thread start and exit
  3187. @item set print thread-events
  3188. @itemx set print thread-events on
  3189. @itemx set print thread-events off
  3190. The @code{set print thread-events} command allows you to enable or
  3191. disable printing of messages when @value{GDBN} notices that new threads have
  3192. started or that threads have exited. By default, these messages will
  3193. be printed if detection of these events is supported by the target.
  3194. Note that these messages cannot be disabled on all targets.
  3195. @kindex show print thread-events
  3196. @item show print thread-events
  3197. Show whether messages will be printed when @value{GDBN} detects that threads
  3198. have started and exited.
  3199. @end table
  3200. @xref{Thread Stops,,Stopping and Starting Multi-thread Programs}, for
  3201. more information about how @value{GDBN} behaves when you stop and start
  3202. programs with multiple threads.
  3203. @xref{Set Watchpoints,,Setting Watchpoints}, for information about
  3204. watchpoints in programs with multiple threads.
  3205. @anchor{set libthread-db-search-path}
  3206. @table @code
  3207. @kindex set libthread-db-search-path
  3208. @cindex search path for @code{libthread_db}
  3209. @item set libthread-db-search-path @r{[}@var{path}@r{]}
  3210. If this variable is set, @var{path} is a colon-separated list of
  3211. directories @value{GDBN} will use to search for @code{libthread_db}.
  3212. If you omit @var{path}, @samp{libthread-db-search-path} will be reset to
  3213. its default value (@code{$sdir:$pdir} on @sc{gnu}/Linux and Solaris systems).
  3214. Internally, the default value comes from the @code{LIBTHREAD_DB_SEARCH_PATH}
  3215. macro.
  3216. On @sc{gnu}/Linux and Solaris systems, @value{GDBN} uses a ``helper''
  3217. @code{libthread_db} library to obtain information about threads in the
  3218. inferior process. @value{GDBN} will use @samp{libthread-db-search-path}
  3219. to find @code{libthread_db}. @value{GDBN} also consults first if inferior
  3220. specific thread debugging library loading is enabled
  3221. by @samp{set auto-load libthread-db} (@pxref{libthread_db.so.1 file}).
  3222. A special entry @samp{$sdir} for @samp{libthread-db-search-path}
  3223. refers to the default system directories that are
  3224. normally searched for loading shared libraries. The @samp{$sdir} entry
  3225. is the only kind not needing to be enabled by @samp{set auto-load libthread-db}
  3226. (@pxref{libthread_db.so.1 file}).
  3227. A special entry @samp{$pdir} for @samp{libthread-db-search-path}
  3228. refers to the directory from which @code{libpthread}
  3229. was loaded in the inferior process.
  3230. For any @code{libthread_db} library @value{GDBN} finds in above directories,
  3231. @value{GDBN} attempts to initialize it with the current inferior process.
  3232. If this initialization fails (which could happen because of a version
  3233. mismatch between @code{libthread_db} and @code{libpthread}), @value{GDBN}
  3234. will unload @code{libthread_db}, and continue with the next directory.
  3235. If none of @code{libthread_db} libraries initialize successfully,
  3236. @value{GDBN} will issue a warning and thread debugging will be disabled.
  3237. Setting @code{libthread-db-search-path} is currently implemented
  3238. only on some platforms.
  3239. @kindex show libthread-db-search-path
  3240. @item show libthread-db-search-path
  3241. Display current libthread_db search path.
  3242. @kindex set debug libthread-db
  3243. @kindex show debug libthread-db
  3244. @cindex debugging @code{libthread_db}
  3245. @item set debug libthread-db
  3246. @itemx show debug libthread-db
  3247. Turns on or off display of @code{libthread_db}-related events.
  3248. Use @code{1} to enable, @code{0} to disable.
  3249. @kindex set debug threads
  3250. @kindex show debug threads
  3251. @cindex debugging @code{threads}
  3252. @item set debug threads @r{[}on@r{|}off@r{]}
  3253. @itemx show debug threads
  3254. When @samp{on} @value{GDBN} will print additional messages when
  3255. threads are created and deleted.
  3256. @end table
  3257. @node Forks
  3258. @section Debugging Forks
  3259. @cindex fork, debugging programs which call
  3260. @cindex multiple processes
  3261. @cindex processes, multiple
  3262. On most systems, @value{GDBN} has no special support for debugging
  3263. programs which create additional processes using the @code{fork}
  3264. function. When a program forks, @value{GDBN} will continue to debug the
  3265. parent process and the child process will run unimpeded. If you have
  3266. set a breakpoint in any code which the child then executes, the child
  3267. will get a @code{SIGTRAP} signal which (unless it catches the signal)
  3268. will cause it to terminate.
  3269. However, if you want to debug the child process there is a workaround
  3270. which isn't too painful. Put a call to @code{sleep} in the code which
  3271. the child process executes after the fork. It may be useful to sleep
  3272. only if a certain environment variable is set, or a certain file exists,
  3273. so that the delay need not occur when you don't want to run @value{GDBN}
  3274. on the child. While the child is sleeping, use the @code{ps} program to
  3275. get its process ID. Then tell @value{GDBN} (a new invocation of
  3276. @value{GDBN} if you are also debugging the parent process) to attach to
  3277. the child process (@pxref{Attach}). From that point on you can debug
  3278. the child process just like any other process which you attached to.
  3279. On some systems, @value{GDBN} provides support for debugging programs
  3280. that create additional processes using the @code{fork} or @code{vfork}
  3281. functions. On @sc{gnu}/Linux platforms, this feature is supported
  3282. with kernel version 2.5.46 and later.
  3283. The fork debugging commands are supported in native mode and when
  3284. connected to @code{gdbserver} in either @code{target remote} mode or
  3285. @code{target extended-remote} mode.
  3286. By default, when a program forks, @value{GDBN} will continue to debug
  3287. the parent process and the child process will run unimpeded.
  3288. If you want to follow the child process instead of the parent process,
  3289. use the command @w{@code{set follow-fork-mode}}.
  3290. @table @code
  3291. @kindex set follow-fork-mode
  3292. @item set follow-fork-mode @var{mode}
  3293. Set the debugger response to a program call of @code{fork} or
  3294. @code{vfork}. A call to @code{fork} or @code{vfork} creates a new
  3295. process. The @var{mode} argument can be:
  3296. @table @code
  3297. @item parent
  3298. The original process is debugged after a fork. The child process runs
  3299. unimpeded. This is the default.
  3300. @item child
  3301. The new process is debugged after a fork. The parent process runs
  3302. unimpeded.
  3303. @end table
  3304. @kindex show follow-fork-mode
  3305. @item show follow-fork-mode
  3306. Display the current debugger response to a @code{fork} or @code{vfork} call.
  3307. @end table
  3308. @cindex debugging multiple processes
  3309. On Linux, if you want to debug both the parent and child processes, use the
  3310. command @w{@code{set detach-on-fork}}.
  3311. @table @code
  3312. @kindex set detach-on-fork
  3313. @item set detach-on-fork @var{mode}
  3314. Tells gdb whether to detach one of the processes after a fork, or
  3315. retain debugger control over them both.
  3316. @table @code
  3317. @item on
  3318. The child process (or parent process, depending on the value of
  3319. @code{follow-fork-mode}) will be detached and allowed to run
  3320. independently. This is the default.
  3321. @item off
  3322. Both processes will be held under the control of @value{GDBN}.
  3323. One process (child or parent, depending on the value of
  3324. @code{follow-fork-mode}) is debugged as usual, while the other
  3325. is held suspended.
  3326. @end table
  3327. @kindex show detach-on-fork
  3328. @item show detach-on-fork
  3329. Show whether detach-on-fork mode is on/off.
  3330. @end table
  3331. If you choose to set @samp{detach-on-fork} mode off, then @value{GDBN}
  3332. will retain control of all forked processes (including nested forks).
  3333. You can list the forked processes under the control of @value{GDBN} by
  3334. using the @w{@code{info inferiors}} command, and switch from one fork
  3335. to another by using the @code{inferior} command (@pxref{Inferiors Connections and
  3336. Programs, ,Debugging Multiple Inferiors Connections and Programs}).
  3337. To quit debugging one of the forked processes, you can either detach
  3338. from it by using the @w{@code{detach inferiors}} command (allowing it
  3339. to run independently), or kill it using the @w{@code{kill inferiors}}
  3340. command. @xref{Inferiors Connections and Programs, ,Debugging
  3341. Multiple Inferiors Connections and Programs}.
  3342. If you ask to debug a child process and a @code{vfork} is followed by an
  3343. @code{exec}, @value{GDBN} executes the new target up to the first
  3344. breakpoint in the new target. If you have a breakpoint set on
  3345. @code{main} in your original program, the breakpoint will also be set on
  3346. the child process's @code{main}.
  3347. On some systems, when a child process is spawned by @code{vfork}, you
  3348. cannot debug the child or parent until an @code{exec} call completes.
  3349. If you issue a @code{run} command to @value{GDBN} after an @code{exec}
  3350. call executes, the new target restarts. To restart the parent
  3351. process, use the @code{file} command with the parent executable name
  3352. as its argument. By default, after an @code{exec} call executes,
  3353. @value{GDBN} discards the symbols of the previous executable image.
  3354. You can change this behaviour with the @w{@code{set follow-exec-mode}}
  3355. command.
  3356. @table @code
  3357. @kindex set follow-exec-mode
  3358. @item set follow-exec-mode @var{mode}
  3359. Set debugger response to a program call of @code{exec}. An
  3360. @code{exec} call replaces the program image of a process.
  3361. @code{follow-exec-mode} can be:
  3362. @table @code
  3363. @item new
  3364. @value{GDBN} creates a new inferior and rebinds the process to this
  3365. new inferior. The program the process was running before the
  3366. @code{exec} call can be restarted afterwards by restarting the
  3367. original inferior.
  3368. For example:
  3369. @smallexample
  3370. (@value{GDBP}) info inferiors
  3371. (gdb) info inferior
  3372. Id Description Executable
  3373. * 1 <null> prog1
  3374. (@value{GDBP}) run
  3375. process 12020 is executing new program: prog2
  3376. Program exited normally.
  3377. (@value{GDBP}) info inferiors
  3378. Id Description Executable
  3379. 1 <null> prog1
  3380. * 2 <null> prog2
  3381. @end smallexample
  3382. @item same
  3383. @value{GDBN} keeps the process bound to the same inferior. The new
  3384. executable image replaces the previous executable loaded in the
  3385. inferior. Restarting the inferior after the @code{exec} call, with
  3386. e.g., the @code{run} command, restarts the executable the process was
  3387. running after the @code{exec} call. This is the default mode.
  3388. For example:
  3389. @smallexample
  3390. (@value{GDBP}) info inferiors
  3391. Id Description Executable
  3392. * 1 <null> prog1
  3393. (@value{GDBP}) run
  3394. process 12020 is executing new program: prog2
  3395. Program exited normally.
  3396. (@value{GDBP}) info inferiors
  3397. Id Description Executable
  3398. * 1 <null> prog2
  3399. @end smallexample
  3400. @end table
  3401. @end table
  3402. @code{follow-exec-mode} is supported in native mode and
  3403. @code{target extended-remote} mode.
  3404. You can use the @code{catch} command to make @value{GDBN} stop whenever
  3405. a @code{fork}, @code{vfork}, or @code{exec} call is made. @xref{Set
  3406. Catchpoints, ,Setting Catchpoints}.
  3407. @node Checkpoint/Restart
  3408. @section Setting a @emph{Bookmark} to Return to Later
  3409. @cindex checkpoint
  3410. @cindex restart
  3411. @cindex bookmark
  3412. @cindex snapshot of a process
  3413. @cindex rewind program state
  3414. On certain operating systems@footnote{Currently, only
  3415. @sc{gnu}/Linux.}, @value{GDBN} is able to save a @dfn{snapshot} of a
  3416. program's state, called a @dfn{checkpoint}, and come back to it
  3417. later.
  3418. Returning to a checkpoint effectively undoes everything that has
  3419. happened in the program since the @code{checkpoint} was saved. This
  3420. includes changes in memory, registers, and even (within some limits)
  3421. system state. Effectively, it is like going back in time to the
  3422. moment when the checkpoint was saved.
  3423. Thus, if you're stepping thru a program and you think you're
  3424. getting close to the point where things go wrong, you can save
  3425. a checkpoint. Then, if you accidentally go too far and miss
  3426. the critical statement, instead of having to restart your program
  3427. from the beginning, you can just go back to the checkpoint and
  3428. start again from there.
  3429. This can be especially useful if it takes a lot of time or
  3430. steps to reach the point where you think the bug occurs.
  3431. To use the @code{checkpoint}/@code{restart} method of debugging:
  3432. @table @code
  3433. @kindex checkpoint
  3434. @item checkpoint
  3435. Save a snapshot of the debugged program's current execution state.
  3436. The @code{checkpoint} command takes no arguments, but each checkpoint
  3437. is assigned a small integer id, similar to a breakpoint id.
  3438. @kindex info checkpoints
  3439. @item info checkpoints
  3440. List the checkpoints that have been saved in the current debugging
  3441. session. For each checkpoint, the following information will be
  3442. listed:
  3443. @table @code
  3444. @item Checkpoint ID
  3445. @item Process ID
  3446. @item Code Address
  3447. @item Source line, or label
  3448. @end table
  3449. @kindex restart @var{checkpoint-id}
  3450. @item restart @var{checkpoint-id}
  3451. Restore the program state that was saved as checkpoint number
  3452. @var{checkpoint-id}. All program variables, registers, stack frames
  3453. etc.@: will be returned to the values that they had when the checkpoint
  3454. was saved. In essence, gdb will ``wind back the clock'' to the point
  3455. in time when the checkpoint was saved.
  3456. Note that breakpoints, @value{GDBN} variables, command history etc.
  3457. are not affected by restoring a checkpoint. In general, a checkpoint
  3458. only restores things that reside in the program being debugged, not in
  3459. the debugger.
  3460. @kindex delete checkpoint @var{checkpoint-id}
  3461. @item delete checkpoint @var{checkpoint-id}
  3462. Delete the previously-saved checkpoint identified by @var{checkpoint-id}.
  3463. @end table
  3464. Returning to a previously saved checkpoint will restore the user state
  3465. of the program being debugged, plus a significant subset of the system
  3466. (OS) state, including file pointers. It won't ``un-write'' data from
  3467. a file, but it will rewind the file pointer to the previous location,
  3468. so that the previously written data can be overwritten. For files
  3469. opened in read mode, the pointer will also be restored so that the
  3470. previously read data can be read again.
  3471. Of course, characters that have been sent to a printer (or other
  3472. external device) cannot be ``snatched back'', and characters received
  3473. from eg.@: a serial device can be removed from internal program buffers,
  3474. but they cannot be ``pushed back'' into the serial pipeline, ready to
  3475. be received again. Similarly, the actual contents of files that have
  3476. been changed cannot be restored (at this time).
  3477. However, within those constraints, you actually can ``rewind'' your
  3478. program to a previously saved point in time, and begin debugging it
  3479. again --- and you can change the course of events so as to debug a
  3480. different execution path this time.
  3481. @cindex checkpoints and process id
  3482. Finally, there is one bit of internal program state that will be
  3483. different when you return to a checkpoint --- the program's process
  3484. id. Each checkpoint will have a unique process id (or @var{pid}),
  3485. and each will be different from the program's original @var{pid}.
  3486. If your program has saved a local copy of its process id, this could
  3487. potentially pose a problem.
  3488. @subsection A Non-obvious Benefit of Using Checkpoints
  3489. On some systems such as @sc{gnu}/Linux, address space randomization
  3490. is performed on new processes for security reasons. This makes it
  3491. difficult or impossible to set a breakpoint, or watchpoint, on an
  3492. absolute address if you have to restart the program, since the
  3493. absolute location of a symbol will change from one execution to the
  3494. next.
  3495. A checkpoint, however, is an @emph{identical} copy of a process.
  3496. Therefore if you create a checkpoint at (eg.@:) the start of main,
  3497. and simply return to that checkpoint instead of restarting the
  3498. process, you can avoid the effects of address randomization and
  3499. your symbols will all stay in the same place.
  3500. @node Stopping
  3501. @chapter Stopping and Continuing
  3502. The principal purposes of using a debugger are so that you can stop your
  3503. program before it terminates; or so that, if your program runs into
  3504. trouble, you can investigate and find out why.
  3505. Inside @value{GDBN}, your program may stop for any of several reasons,
  3506. such as a signal, a breakpoint, or reaching a new line after a
  3507. @value{GDBN} command such as @code{step}. You may then examine and
  3508. change variables, set new breakpoints or remove old ones, and then
  3509. continue execution. Usually, the messages shown by @value{GDBN} provide
  3510. ample explanation of the status of your program---but you can also
  3511. explicitly request this information at any time.
  3512. @table @code
  3513. @kindex info program
  3514. @item info program
  3515. Display information about the status of your program: whether it is
  3516. running or not, what process it is, and why it stopped.
  3517. @end table
  3518. @menu
  3519. * Breakpoints:: Breakpoints, watchpoints, and catchpoints
  3520. * Continuing and Stepping:: Resuming execution
  3521. * Skipping Over Functions and Files::
  3522. Skipping over functions and files
  3523. * Signals:: Signals
  3524. * Thread Stops:: Stopping and starting multi-thread programs
  3525. @end menu
  3526. @node Breakpoints
  3527. @section Breakpoints, Watchpoints, and Catchpoints
  3528. @cindex breakpoints
  3529. A @dfn{breakpoint} makes your program stop whenever a certain point in
  3530. the program is reached. For each breakpoint, you can add conditions to
  3531. control in finer detail whether your program stops. You can set
  3532. breakpoints with the @code{break} command and its variants (@pxref{Set
  3533. Breaks, ,Setting Breakpoints}), to specify the place where your program
  3534. should stop by line number, function name or exact address in the
  3535. program.
  3536. On some systems, you can set breakpoints in shared libraries before
  3537. the executable is run.
  3538. @cindex watchpoints
  3539. @cindex data breakpoints
  3540. @cindex memory tracing
  3541. @cindex breakpoint on memory address
  3542. @cindex breakpoint on variable modification
  3543. A @dfn{watchpoint} is a special breakpoint that stops your program
  3544. when the value of an expression changes. The expression may be a value
  3545. of a variable, or it could involve values of one or more variables
  3546. combined by operators, such as @samp{a + b}. This is sometimes called
  3547. @dfn{data breakpoints}. You must use a different command to set
  3548. watchpoints (@pxref{Set Watchpoints, ,Setting Watchpoints}), but aside
  3549. from that, you can manage a watchpoint like any other breakpoint: you
  3550. enable, disable, and delete both breakpoints and watchpoints using the
  3551. same commands.
  3552. You can arrange to have values from your program displayed automatically
  3553. whenever @value{GDBN} stops at a breakpoint. @xref{Auto Display,,
  3554. Automatic Display}.
  3555. @cindex catchpoints
  3556. @cindex breakpoint on events
  3557. A @dfn{catchpoint} is another special breakpoint that stops your program
  3558. when a certain kind of event occurs, such as the throwing of a C@t{++}
  3559. exception or the loading of a library. As with watchpoints, you use a
  3560. different command to set a catchpoint (@pxref{Set Catchpoints, ,Setting
  3561. Catchpoints}), but aside from that, you can manage a catchpoint like any
  3562. other breakpoint. (To stop when your program receives a signal, use the
  3563. @code{handle} command; see @ref{Signals, ,Signals}.)
  3564. @cindex breakpoint numbers
  3565. @cindex numbers for breakpoints
  3566. @value{GDBN} assigns a number to each breakpoint, watchpoint, or
  3567. catchpoint when you create it; these numbers are successive integers
  3568. starting with one. In many of the commands for controlling various
  3569. features of breakpoints you use the breakpoint number to say which
  3570. breakpoint you want to change. Each breakpoint may be @dfn{enabled} or
  3571. @dfn{disabled}; if disabled, it has no effect on your program until you
  3572. enable it again.
  3573. @cindex breakpoint ranges
  3574. @cindex breakpoint lists
  3575. @cindex ranges of breakpoints
  3576. @cindex lists of breakpoints
  3577. Some @value{GDBN} commands accept a space-separated list of breakpoints
  3578. on which to operate. A list element can be either a single breakpoint number,
  3579. like @samp{5}, or a range of such numbers, like @samp{5-7}.
  3580. When a breakpoint list is given to a command, all breakpoints in that list
  3581. are operated on.
  3582. @menu
  3583. * Set Breaks:: Setting breakpoints
  3584. * Set Watchpoints:: Setting watchpoints
  3585. * Set Catchpoints:: Setting catchpoints
  3586. * Delete Breaks:: Deleting breakpoints
  3587. * Disabling:: Disabling breakpoints
  3588. * Conditions:: Break conditions
  3589. * Break Commands:: Breakpoint command lists
  3590. * Dynamic Printf:: Dynamic printf
  3591. * Save Breakpoints:: How to save breakpoints in a file
  3592. * Static Probe Points:: Listing static probe points
  3593. * Error in Breakpoints:: ``Cannot insert breakpoints''
  3594. * Breakpoint-related Warnings:: ``Breakpoint address adjusted...''
  3595. @end menu
  3596. @node Set Breaks
  3597. @subsection Setting Breakpoints
  3598. @c FIXME LMB what does GDB do if no code on line of breakpt?
  3599. @c consider in particular declaration with/without initialization.
  3600. @c
  3601. @c FIXME 2 is there stuff on this already? break at fun start, already init?
  3602. @kindex break
  3603. @kindex b @r{(@code{break})}
  3604. @vindex $bpnum@r{, convenience variable}
  3605. @cindex latest breakpoint
  3606. Breakpoints are set with the @code{break} command (abbreviated
  3607. @code{b}). The debugger convenience variable @samp{$bpnum} records the
  3608. number of the breakpoint you've set most recently; see @ref{Convenience
  3609. Vars,, Convenience Variables}, for a discussion of what you can do with
  3610. convenience variables.
  3611. @table @code
  3612. @item break @var{location}
  3613. Set a breakpoint at the given @var{location}, which can specify a
  3614. function name, a line number, or an address of an instruction.
  3615. (@xref{Specify Location}, for a list of all the possible ways to
  3616. specify a @var{location}.) The breakpoint will stop your program just
  3617. before it executes any of the code in the specified @var{location}.
  3618. When using source languages that permit overloading of symbols, such as
  3619. C@t{++}, a function name may refer to more than one possible place to break.
  3620. @xref{Ambiguous Expressions,,Ambiguous Expressions}, for a discussion of
  3621. that situation.
  3622. It is also possible to insert a breakpoint that will stop the program
  3623. only if a specific thread (@pxref{Thread-Specific Breakpoints})
  3624. or a specific task (@pxref{Ada Tasks}) hits that breakpoint.
  3625. @item break
  3626. When called without any arguments, @code{break} sets a breakpoint at
  3627. the next instruction to be executed in the selected stack frame
  3628. (@pxref{Stack, ,Examining the Stack}). In any selected frame but the
  3629. innermost, this makes your program stop as soon as control
  3630. returns to that frame. This is similar to the effect of a
  3631. @code{finish} command in the frame inside the selected frame---except
  3632. that @code{finish} does not leave an active breakpoint. If you use
  3633. @code{break} without an argument in the innermost frame, @value{GDBN} stops
  3634. the next time it reaches the current location; this may be useful
  3635. inside loops.
  3636. @value{GDBN} normally ignores breakpoints when it resumes execution, until at
  3637. least one instruction has been executed. If it did not do this, you
  3638. would be unable to proceed past a breakpoint without first disabling the
  3639. breakpoint. This rule applies whether or not the breakpoint already
  3640. existed when your program stopped.
  3641. @item break @dots{} if @var{cond}
  3642. Set a breakpoint with condition @var{cond}; evaluate the expression
  3643. @var{cond} each time the breakpoint is reached, and stop only if the
  3644. value is nonzero---that is, if @var{cond} evaluates as true.
  3645. @samp{@dots{}} stands for one of the possible arguments described
  3646. above (or no argument) specifying where to break. @xref{Conditions,
  3647. ,Break Conditions}, for more information on breakpoint conditions.
  3648. The breakpoint may be mapped to multiple locations. If the breakpoint
  3649. condition @var{cond} is invalid at some but not all of the locations,
  3650. the locations for which the condition is invalid are disabled. For
  3651. example, @value{GDBN} reports below that two of the three locations
  3652. are disabled.
  3653. @smallexample
  3654. (@value{GDBP}) break func if a == 10
  3655. warning: failed to validate condition at location 0x11ce, disabling:
  3656. No symbol "a" in current context.
  3657. warning: failed to validate condition at location 0x11b6, disabling:
  3658. No symbol "a" in current context.
  3659. Breakpoint 1 at 0x11b6: func. (3 locations)
  3660. @end smallexample
  3661. Locations that are disabled because of the condition are denoted by an
  3662. uppercase @code{N} in the output of the @code{info breakpoints}
  3663. command:
  3664. @smallexample
  3665. (@value{GDBP}) info breakpoints
  3666. Num Type Disp Enb Address What
  3667. 1 breakpoint keep y <MULTIPLE>
  3668. stop only if a == 10
  3669. 1.1 N* 0x00000000000011b6 in ...
  3670. 1.2 y 0x00000000000011c2 in ...
  3671. 1.3 N* 0x00000000000011ce in ...
  3672. (*): Breakpoint condition is invalid at this location.
  3673. @end smallexample
  3674. If the breakpoint condition @var{cond} is invalid in the context of
  3675. @emph{all} the locations of the breakpoint, @value{GDBN} refuses to
  3676. define the breakpoint. For example, if variable @code{foo} is an
  3677. undefined variable:
  3678. @smallexample
  3679. (@value{GDBP}) break func if foo
  3680. No symbol "foo" in current context.
  3681. @end smallexample
  3682. @item break @dots{} -force-condition if @var{cond}
  3683. There may be cases where the condition @var{cond} is invalid at all
  3684. the current locations, but the user knows that it will be valid at a
  3685. future location; for example, because of a library load. In such
  3686. cases, by using the @code{-force-condition} keyword before @samp{if},
  3687. @value{GDBN} can be forced to define the breakpoint with the given
  3688. condition expression instead of refusing it.
  3689. @smallexample
  3690. (@value{GDBP}) break func -force-condition if foo
  3691. warning: failed to validate condition at location 1, disabling:
  3692. No symbol "foo" in current context.
  3693. warning: failed to validate condition at location 2, disabling:
  3694. No symbol "foo" in current context.
  3695. warning: failed to validate condition at location 3, disabling:
  3696. No symbol "foo" in current context.
  3697. Breakpoint 1 at 0x1158: test.c:18. (3 locations)
  3698. @end smallexample
  3699. This causes all the present locations where the breakpoint would
  3700. otherwise be inserted, to be disabled, as seen in the example above.
  3701. However, if there exist locations at which the condition is valid, the
  3702. @code{-force-condition} keyword has no effect.
  3703. @kindex tbreak
  3704. @item tbreak @var{args}
  3705. Set a breakpoint enabled only for one stop. The @var{args} are the
  3706. same as for the @code{break} command, and the breakpoint is set in the same
  3707. way, but the breakpoint is automatically deleted after the first time your
  3708. program stops there. @xref{Disabling, ,Disabling Breakpoints}.
  3709. @kindex hbreak
  3710. @cindex hardware breakpoints
  3711. @item hbreak @var{args}
  3712. Set a hardware-assisted breakpoint. The @var{args} are the same as for the
  3713. @code{break} command and the breakpoint is set in the same way, but the
  3714. breakpoint requires hardware support and some target hardware may not
  3715. have this support. The main purpose of this is EPROM/ROM code
  3716. debugging, so you can set a breakpoint at an instruction without
  3717. changing the instruction. This can be used with the new trap-generation
  3718. provided by SPARClite DSU and most x86-based targets. These targets
  3719. will generate traps when a program accesses some data or instruction
  3720. address that is assigned to the debug registers. However the hardware
  3721. breakpoint registers can take a limited number of breakpoints. For
  3722. example, on the DSU, only two data breakpoints can be set at a time, and
  3723. @value{GDBN} will reject this command if more than two are used. Delete
  3724. or disable unused hardware breakpoints before setting new ones
  3725. (@pxref{Disabling, ,Disabling Breakpoints}).
  3726. @xref{Conditions, ,Break Conditions}.
  3727. For remote targets, you can restrict the number of hardware
  3728. breakpoints @value{GDBN} will use, see @ref{set remote
  3729. hardware-breakpoint-limit}.
  3730. @kindex thbreak
  3731. @item thbreak @var{args}
  3732. Set a hardware-assisted breakpoint enabled only for one stop. The @var{args}
  3733. are the same as for the @code{hbreak} command and the breakpoint is set in
  3734. the same way. However, like the @code{tbreak} command,
  3735. the breakpoint is automatically deleted after the
  3736. first time your program stops there. Also, like the @code{hbreak}
  3737. command, the breakpoint requires hardware support and some target hardware
  3738. may not have this support. @xref{Disabling, ,Disabling Breakpoints}.
  3739. See also @ref{Conditions, ,Break Conditions}.
  3740. @kindex rbreak
  3741. @cindex regular expression
  3742. @cindex breakpoints at functions matching a regexp
  3743. @cindex set breakpoints in many functions
  3744. @item rbreak @var{regex}
  3745. Set breakpoints on all functions matching the regular expression
  3746. @var{regex}. This command sets an unconditional breakpoint on all
  3747. matches, printing a list of all breakpoints it set. Once these
  3748. breakpoints are set, they are treated just like the breakpoints set with
  3749. the @code{break} command. You can delete them, disable them, or make
  3750. them conditional the same way as any other breakpoint.
  3751. In programs using different languages, @value{GDBN} chooses the syntax
  3752. to print the list of all breakpoints it sets according to the
  3753. @samp{set language} value: using @samp{set language auto}
  3754. (see @ref{Automatically, ,Set Language Automatically}) means to use the
  3755. language of the breakpoint's function, other values mean to use
  3756. the manually specified language (see @ref{Manually, ,Set Language Manually}).
  3757. The syntax of the regular expression is the standard one used with tools
  3758. like @file{grep}. Note that this is different from the syntax used by
  3759. shells, so for instance @code{foo*} matches all functions that include
  3760. an @code{fo} followed by zero or more @code{o}s. There is an implicit
  3761. @code{.*} leading and trailing the regular expression you supply, so to
  3762. match only functions that begin with @code{foo}, use @code{^foo}.
  3763. @cindex non-member C@t{++} functions, set breakpoint in
  3764. When debugging C@t{++} programs, @code{rbreak} is useful for setting
  3765. breakpoints on overloaded functions that are not members of any special
  3766. classes.
  3767. @cindex set breakpoints on all functions
  3768. The @code{rbreak} command can be used to set breakpoints in
  3769. @strong{all} the functions in a program, like this:
  3770. @smallexample
  3771. (@value{GDBP}) rbreak .
  3772. @end smallexample
  3773. @item rbreak @var{file}:@var{regex}
  3774. If @code{rbreak} is called with a filename qualification, it limits
  3775. the search for functions matching the given regular expression to the
  3776. specified @var{file}. This can be used, for example, to set breakpoints on
  3777. every function in a given file:
  3778. @smallexample
  3779. (@value{GDBP}) rbreak file.c:.
  3780. @end smallexample
  3781. The colon separating the filename qualifier from the regex may
  3782. optionally be surrounded by spaces.
  3783. @kindex info breakpoints
  3784. @cindex @code{$_} and @code{info breakpoints}
  3785. @item info breakpoints @r{[}@var{list}@dots{}@r{]}
  3786. @itemx info break @r{[}@var{list}@dots{}@r{]}
  3787. Print a table of all breakpoints, watchpoints, and catchpoints set and
  3788. not deleted. Optional argument @var{n} means print information only
  3789. about the specified breakpoint(s) (or watchpoint(s) or catchpoint(s)).
  3790. For each breakpoint, following columns are printed:
  3791. @table @emph
  3792. @item Breakpoint Numbers
  3793. @item Type
  3794. Breakpoint, watchpoint, or catchpoint.
  3795. @item Disposition
  3796. Whether the breakpoint is marked to be disabled or deleted when hit.
  3797. @item Enabled or Disabled
  3798. Enabled breakpoints are marked with @samp{y}. @samp{n} marks breakpoints
  3799. that are not enabled.
  3800. @item Address
  3801. Where the breakpoint is in your program, as a memory address. For a
  3802. pending breakpoint whose address is not yet known, this field will
  3803. contain @samp{<PENDING>}. Such breakpoint won't fire until a shared
  3804. library that has the symbol or line referred by breakpoint is loaded.
  3805. See below for details. A breakpoint with several locations will
  3806. have @samp{<MULTIPLE>} in this field---see below for details.
  3807. @item What
  3808. Where the breakpoint is in the source for your program, as a file and
  3809. line number. For a pending breakpoint, the original string passed to
  3810. the breakpoint command will be listed as it cannot be resolved until
  3811. the appropriate shared library is loaded in the future.
  3812. @end table
  3813. @noindent
  3814. If a breakpoint is conditional, there are two evaluation modes: ``host'' and
  3815. ``target''. If mode is ``host'', breakpoint condition evaluation is done by
  3816. @value{GDBN} on the host's side. If it is ``target'', then the condition
  3817. is evaluated by the target. The @code{info break} command shows
  3818. the condition on the line following the affected breakpoint, together with
  3819. its condition evaluation mode in between parentheses.
  3820. Breakpoint commands, if any, are listed after that. A pending breakpoint is
  3821. allowed to have a condition specified for it. The condition is not parsed for
  3822. validity until a shared library is loaded that allows the pending
  3823. breakpoint to resolve to a valid location.
  3824. @noindent
  3825. @code{info break} with a breakpoint
  3826. number @var{n} as argument lists only that breakpoint. The
  3827. convenience variable @code{$_} and the default examining-address for
  3828. the @code{x} command are set to the address of the last breakpoint
  3829. listed (@pxref{Memory, ,Examining Memory}).
  3830. @noindent
  3831. @code{info break} displays a count of the number of times the breakpoint
  3832. has been hit. This is especially useful in conjunction with the
  3833. @code{ignore} command. You can ignore a large number of breakpoint
  3834. hits, look at the breakpoint info to see how many times the breakpoint
  3835. was hit, and then run again, ignoring one less than that number. This
  3836. will get you quickly to the last hit of that breakpoint.
  3837. @noindent
  3838. For a breakpoints with an enable count (xref) greater than 1,
  3839. @code{info break} also displays that count.
  3840. @end table
  3841. @value{GDBN} allows you to set any number of breakpoints at the same place in
  3842. your program. There is nothing silly or meaningless about this. When
  3843. the breakpoints are conditional, this is even useful
  3844. (@pxref{Conditions, ,Break Conditions}).
  3845. @cindex multiple locations, breakpoints
  3846. @cindex breakpoints, multiple locations
  3847. It is possible that a breakpoint corresponds to several locations
  3848. in your program. Examples of this situation are:
  3849. @itemize @bullet
  3850. @item
  3851. Multiple functions in the program may have the same name.
  3852. @item
  3853. For a C@t{++} constructor, the @value{NGCC} compiler generates several
  3854. instances of the function body, used in different cases.
  3855. @item
  3856. For a C@t{++} template function, a given line in the function can
  3857. correspond to any number of instantiations.
  3858. @item
  3859. For an inlined function, a given source line can correspond to
  3860. several places where that function is inlined.
  3861. @end itemize
  3862. In all those cases, @value{GDBN} will insert a breakpoint at all
  3863. the relevant locations.
  3864. A breakpoint with multiple locations is displayed in the breakpoint
  3865. table using several rows---one header row, followed by one row for
  3866. each breakpoint location. The header row has @samp{<MULTIPLE>} in the
  3867. address column. The rows for individual locations contain the actual
  3868. addresses for locations, and show the functions to which those
  3869. locations belong. The number column for a location is of the form
  3870. @var{breakpoint-number}.@var{location-number}.
  3871. For example:
  3872. @smallexample
  3873. Num Type Disp Enb Address What
  3874. 1 breakpoint keep y <MULTIPLE>
  3875. stop only if i==1
  3876. breakpoint already hit 1 time
  3877. 1.1 y 0x080486a2 in void foo<int>() at t.cc:8
  3878. 1.2 y 0x080486ca in void foo<double>() at t.cc:8
  3879. @end smallexample
  3880. You cannot delete the individual locations from a breakpoint. However,
  3881. each location can be individually enabled or disabled by passing
  3882. @var{breakpoint-number}.@var{location-number} as argument to the
  3883. @code{enable} and @code{disable} commands. It's also possible to
  3884. @code{enable} and @code{disable} a range of @var{location-number}
  3885. locations using a @var{breakpoint-number} and two @var{location-number}s,
  3886. in increasing order, separated by a hyphen, like
  3887. @kbd{@var{breakpoint-number}.@var{location-number1}-@var{location-number2}},
  3888. in which case @value{GDBN} acts on all the locations in the range (inclusive).
  3889. Disabling or enabling the parent breakpoint (@pxref{Disabling}) affects
  3890. all of the locations that belong to that breakpoint.
  3891. @cindex pending breakpoints
  3892. It's quite common to have a breakpoint inside a shared library.
  3893. Shared libraries can be loaded and unloaded explicitly,
  3894. and possibly repeatedly, as the program is executed. To support
  3895. this use case, @value{GDBN} updates breakpoint locations whenever
  3896. any shared library is loaded or unloaded. Typically, you would
  3897. set a breakpoint in a shared library at the beginning of your
  3898. debugging session, when the library is not loaded, and when the
  3899. symbols from the library are not available. When you try to set
  3900. breakpoint, @value{GDBN} will ask you if you want to set
  3901. a so called @dfn{pending breakpoint}---breakpoint whose address
  3902. is not yet resolved.
  3903. After the program is run, whenever a new shared library is loaded,
  3904. @value{GDBN} reevaluates all the breakpoints. When a newly loaded
  3905. shared library contains the symbol or line referred to by some
  3906. pending breakpoint, that breakpoint is resolved and becomes an
  3907. ordinary breakpoint. When a library is unloaded, all breakpoints
  3908. that refer to its symbols or source lines become pending again.
  3909. This logic works for breakpoints with multiple locations, too. For
  3910. example, if you have a breakpoint in a C@t{++} template function, and
  3911. a newly loaded shared library has an instantiation of that template,
  3912. a new location is added to the list of locations for the breakpoint.
  3913. Except for having unresolved address, pending breakpoints do not
  3914. differ from regular breakpoints. You can set conditions or commands,
  3915. enable and disable them and perform other breakpoint operations.
  3916. @value{GDBN} provides some additional commands for controlling what
  3917. happens when the @samp{break} command cannot resolve breakpoint
  3918. address specification to an address:
  3919. @kindex set breakpoint pending
  3920. @kindex show breakpoint pending
  3921. @table @code
  3922. @item set breakpoint pending auto
  3923. This is the default behavior. When @value{GDBN} cannot find the breakpoint
  3924. location, it queries you whether a pending breakpoint should be created.
  3925. @item set breakpoint pending on
  3926. This indicates that an unrecognized breakpoint location should automatically
  3927. result in a pending breakpoint being created.
  3928. @item set breakpoint pending off
  3929. This indicates that pending breakpoints are not to be created. Any
  3930. unrecognized breakpoint location results in an error. This setting does
  3931. not affect any pending breakpoints previously created.
  3932. @item show breakpoint pending
  3933. Show the current behavior setting for creating pending breakpoints.
  3934. @end table
  3935. The settings above only affect the @code{break} command and its
  3936. variants. Once breakpoint is set, it will be automatically updated
  3937. as shared libraries are loaded and unloaded.
  3938. @cindex automatic hardware breakpoints
  3939. For some targets, @value{GDBN} can automatically decide if hardware or
  3940. software breakpoints should be used, depending on whether the
  3941. breakpoint address is read-only or read-write. This applies to
  3942. breakpoints set with the @code{break} command as well as to internal
  3943. breakpoints set by commands like @code{next} and @code{finish}. For
  3944. breakpoints set with @code{hbreak}, @value{GDBN} will always use hardware
  3945. breakpoints.
  3946. You can control this automatic behaviour with the following commands:
  3947. @kindex set breakpoint auto-hw
  3948. @kindex show breakpoint auto-hw
  3949. @table @code
  3950. @item set breakpoint auto-hw on
  3951. This is the default behavior. When @value{GDBN} sets a breakpoint, it
  3952. will try to use the target memory map to decide if software or hardware
  3953. breakpoint must be used.
  3954. @item set breakpoint auto-hw off
  3955. This indicates @value{GDBN} should not automatically select breakpoint
  3956. type. If the target provides a memory map, @value{GDBN} will warn when
  3957. trying to set software breakpoint at a read-only address.
  3958. @end table
  3959. @value{GDBN} normally implements breakpoints by replacing the program code
  3960. at the breakpoint address with a special instruction, which, when
  3961. executed, given control to the debugger. By default, the program
  3962. code is so modified only when the program is resumed. As soon as
  3963. the program stops, @value{GDBN} restores the original instructions. This
  3964. behaviour guards against leaving breakpoints inserted in the
  3965. target should gdb abrubptly disconnect. However, with slow remote
  3966. targets, inserting and removing breakpoint can reduce the performance.
  3967. This behavior can be controlled with the following commands::
  3968. @kindex set breakpoint always-inserted
  3969. @kindex show breakpoint always-inserted
  3970. @table @code
  3971. @item set breakpoint always-inserted off
  3972. All breakpoints, including newly added by the user, are inserted in
  3973. the target only when the target is resumed. All breakpoints are
  3974. removed from the target when it stops. This is the default mode.
  3975. @item set breakpoint always-inserted on
  3976. Causes all breakpoints to be inserted in the target at all times. If
  3977. the user adds a new breakpoint, or changes an existing breakpoint, the
  3978. breakpoints in the target are updated immediately. A breakpoint is
  3979. removed from the target only when breakpoint itself is deleted.
  3980. @end table
  3981. @value{GDBN} handles conditional breakpoints by evaluating these conditions
  3982. when a breakpoint breaks. If the condition is true, then the process being
  3983. debugged stops, otherwise the process is resumed.
  3984. If the target supports evaluating conditions on its end, @value{GDBN} may
  3985. download the breakpoint, together with its conditions, to it.
  3986. This feature can be controlled via the following commands:
  3987. @kindex set breakpoint condition-evaluation
  3988. @kindex show breakpoint condition-evaluation
  3989. @table @code
  3990. @item set breakpoint condition-evaluation host
  3991. This option commands @value{GDBN} to evaluate the breakpoint
  3992. conditions on the host's side. Unconditional breakpoints are sent to
  3993. the target which in turn receives the triggers and reports them back to GDB
  3994. for condition evaluation. This is the standard evaluation mode.
  3995. @item set breakpoint condition-evaluation target
  3996. This option commands @value{GDBN} to download breakpoint conditions
  3997. to the target at the moment of their insertion. The target
  3998. is responsible for evaluating the conditional expression and reporting
  3999. breakpoint stop events back to @value{GDBN} whenever the condition
  4000. is true. Due to limitations of target-side evaluation, some conditions
  4001. cannot be evaluated there, e.g., conditions that depend on local data
  4002. that is only known to the host. Examples include
  4003. conditional expressions involving convenience variables, complex types
  4004. that cannot be handled by the agent expression parser and expressions
  4005. that are too long to be sent over to the target, specially when the
  4006. target is a remote system. In these cases, the conditions will be
  4007. evaluated by @value{GDBN}.
  4008. @item set breakpoint condition-evaluation auto
  4009. This is the default mode. If the target supports evaluating breakpoint
  4010. conditions on its end, @value{GDBN} will download breakpoint conditions to
  4011. the target (limitations mentioned previously apply). If the target does
  4012. not support breakpoint condition evaluation, then @value{GDBN} will fallback
  4013. to evaluating all these conditions on the host's side.
  4014. @end table
  4015. @cindex negative breakpoint numbers
  4016. @cindex internal @value{GDBN} breakpoints
  4017. @value{GDBN} itself sometimes sets breakpoints in your program for
  4018. special purposes, such as proper handling of @code{longjmp} (in C
  4019. programs). These internal breakpoints are assigned negative numbers,
  4020. starting with @code{-1}; @samp{info breakpoints} does not display them.
  4021. You can see these breakpoints with the @value{GDBN} maintenance command
  4022. @samp{maint info breakpoints} (@pxref{maint info breakpoints}).
  4023. @node Set Watchpoints
  4024. @subsection Setting Watchpoints
  4025. @cindex setting watchpoints
  4026. You can use a watchpoint to stop execution whenever the value of an
  4027. expression changes, without having to predict a particular place where
  4028. this may happen. (This is sometimes called a @dfn{data breakpoint}.)
  4029. The expression may be as simple as the value of a single variable, or
  4030. as complex as many variables combined by operators. Examples include:
  4031. @itemize @bullet
  4032. @item
  4033. A reference to the value of a single variable.
  4034. @item
  4035. An address cast to an appropriate data type. For example,
  4036. @samp{*(int *)0x12345678} will watch a 4-byte region at the specified
  4037. address (assuming an @code{int} occupies 4 bytes).
  4038. @item
  4039. An arbitrarily complex expression, such as @samp{a*b + c/d}. The
  4040. expression can use any operators valid in the program's native
  4041. language (@pxref{Languages}).
  4042. @end itemize
  4043. You can set a watchpoint on an expression even if the expression can
  4044. not be evaluated yet. For instance, you can set a watchpoint on
  4045. @samp{*global_ptr} before @samp{global_ptr} is initialized.
  4046. @value{GDBN} will stop when your program sets @samp{global_ptr} and
  4047. the expression produces a valid value. If the expression becomes
  4048. valid in some other way than changing a variable (e.g.@: if the memory
  4049. pointed to by @samp{*global_ptr} becomes readable as the result of a
  4050. @code{malloc} call), @value{GDBN} may not stop until the next time
  4051. the expression changes.
  4052. @cindex software watchpoints
  4053. @cindex hardware watchpoints
  4054. Depending on your system, watchpoints may be implemented in software or
  4055. hardware. @value{GDBN} does software watchpointing by single-stepping your
  4056. program and testing the variable's value each time, which is hundreds of
  4057. times slower than normal execution. (But this may still be worth it, to
  4058. catch errors where you have no clue what part of your program is the
  4059. culprit.)
  4060. On some systems, such as most PowerPC or x86-based targets,
  4061. @value{GDBN} includes support for hardware watchpoints, which do not
  4062. slow down the running of your program.
  4063. @table @code
  4064. @kindex watch
  4065. @item watch @r{[}-l@r{|}-location@r{]} @var{expr} @r{[}thread @var{thread-id}@r{]} @r{[}mask @var{maskvalue}@r{]} @r{[}task @var{task-id}@r{]}
  4066. Set a watchpoint for an expression. @value{GDBN} will break when the
  4067. expression @var{expr} is written into by the program and its value
  4068. changes. The simplest (and the most popular) use of this command is
  4069. to watch the value of a single variable:
  4070. @smallexample
  4071. (@value{GDBP}) watch foo
  4072. @end smallexample
  4073. If the command includes a @code{@r{[}thread @var{thread-id}@r{]}}
  4074. argument, @value{GDBN} breaks only when the thread identified by
  4075. @var{thread-id} changes the value of @var{expr}. If any other threads
  4076. change the value of @var{expr}, @value{GDBN} will not break. Note
  4077. that watchpoints restricted to a single thread in this way only work
  4078. with Hardware Watchpoints.
  4079. Similarly, if the @code{task} argument is given, then the watchpoint
  4080. will be specific to the indicated Ada task (@pxref{Ada Tasks}).
  4081. Ordinarily a watchpoint respects the scope of variables in @var{expr}
  4082. (see below). The @code{-location} argument tells @value{GDBN} to
  4083. instead watch the memory referred to by @var{expr}. In this case,
  4084. @value{GDBN} will evaluate @var{expr}, take the address of the result,
  4085. and watch the memory at that address. The type of the result is used
  4086. to determine the size of the watched memory. If the expression's
  4087. result does not have an address, then @value{GDBN} will print an
  4088. error.
  4089. The @code{@r{[}mask @var{maskvalue}@r{]}} argument allows creation
  4090. of masked watchpoints, if the current architecture supports this
  4091. feature (e.g., PowerPC Embedded architecture, see @ref{PowerPC
  4092. Embedded}.) A @dfn{masked watchpoint} specifies a mask in addition
  4093. to an address to watch. The mask specifies that some bits of an address
  4094. (the bits which are reset in the mask) should be ignored when matching
  4095. the address accessed by the inferior against the watchpoint address.
  4096. Thus, a masked watchpoint watches many addresses simultaneously---those
  4097. addresses whose unmasked bits are identical to the unmasked bits in the
  4098. watchpoint address. The @code{mask} argument implies @code{-location}.
  4099. Examples:
  4100. @smallexample
  4101. (@value{GDBP}) watch foo mask 0xffff00ff
  4102. (@value{GDBP}) watch *0xdeadbeef mask 0xffffff00
  4103. @end smallexample
  4104. @kindex rwatch
  4105. @item rwatch @r{[}-l@r{|}-location@r{]} @var{expr} @r{[}thread @var{thread-id}@r{]} @r{[}mask @var{maskvalue}@r{]}
  4106. Set a watchpoint that will break when the value of @var{expr} is read
  4107. by the program.
  4108. @kindex awatch
  4109. @item awatch @r{[}-l@r{|}-location@r{]} @var{expr} @r{[}thread @var{thread-id}@r{]} @r{[}mask @var{maskvalue}@r{]}
  4110. Set a watchpoint that will break when @var{expr} is either read from
  4111. or written into by the program.
  4112. @kindex info watchpoints @r{[}@var{list}@dots{}@r{]}
  4113. @item info watchpoints @r{[}@var{list}@dots{}@r{]}
  4114. This command prints a list of watchpoints, using the same format as
  4115. @code{info break} (@pxref{Set Breaks}).
  4116. @end table
  4117. If you watch for a change in a numerically entered address you need to
  4118. dereference it, as the address itself is just a constant number which will
  4119. never change. @value{GDBN} refuses to create a watchpoint that watches
  4120. a never-changing value:
  4121. @smallexample
  4122. (@value{GDBP}) watch 0x600850
  4123. Cannot watch constant value 0x600850.
  4124. (@value{GDBP}) watch *(int *) 0x600850
  4125. Watchpoint 1: *(int *) 6293584
  4126. @end smallexample
  4127. @value{GDBN} sets a @dfn{hardware watchpoint} if possible. Hardware
  4128. watchpoints execute very quickly, and the debugger reports a change in
  4129. value at the exact instruction where the change occurs. If @value{GDBN}
  4130. cannot set a hardware watchpoint, it sets a software watchpoint, which
  4131. executes more slowly and reports the change in value at the next
  4132. @emph{statement}, not the instruction, after the change occurs.
  4133. @cindex use only software watchpoints
  4134. You can force @value{GDBN} to use only software watchpoints with the
  4135. @kbd{set can-use-hw-watchpoints 0} command. With this variable set to
  4136. zero, @value{GDBN} will never try to use hardware watchpoints, even if
  4137. the underlying system supports them. (Note that hardware-assisted
  4138. watchpoints that were set @emph{before} setting
  4139. @code{can-use-hw-watchpoints} to zero will still use the hardware
  4140. mechanism of watching expression values.)
  4141. @table @code
  4142. @item set can-use-hw-watchpoints
  4143. @kindex set can-use-hw-watchpoints
  4144. Set whether or not to use hardware watchpoints.
  4145. @item show can-use-hw-watchpoints
  4146. @kindex show can-use-hw-watchpoints
  4147. Show the current mode of using hardware watchpoints.
  4148. @end table
  4149. For remote targets, you can restrict the number of hardware
  4150. watchpoints @value{GDBN} will use, see @ref{set remote
  4151. hardware-breakpoint-limit}.
  4152. When you issue the @code{watch} command, @value{GDBN} reports
  4153. @smallexample
  4154. Hardware watchpoint @var{num}: @var{expr}
  4155. @end smallexample
  4156. @noindent
  4157. if it was able to set a hardware watchpoint.
  4158. Currently, the @code{awatch} and @code{rwatch} commands can only set
  4159. hardware watchpoints, because accesses to data that don't change the
  4160. value of the watched expression cannot be detected without examining
  4161. every instruction as it is being executed, and @value{GDBN} does not do
  4162. that currently. If @value{GDBN} finds that it is unable to set a
  4163. hardware breakpoint with the @code{awatch} or @code{rwatch} command, it
  4164. will print a message like this:
  4165. @smallexample
  4166. Expression cannot be implemented with read/access watchpoint.
  4167. @end smallexample
  4168. Sometimes, @value{GDBN} cannot set a hardware watchpoint because the
  4169. data type of the watched expression is wider than what a hardware
  4170. watchpoint on the target machine can handle. For example, some systems
  4171. can only watch regions that are up to 4 bytes wide; on such systems you
  4172. cannot set hardware watchpoints for an expression that yields a
  4173. double-precision floating-point number (which is typically 8 bytes
  4174. wide). As a work-around, it might be possible to break the large region
  4175. into a series of smaller ones and watch them with separate watchpoints.
  4176. If you set too many hardware watchpoints, @value{GDBN} might be unable
  4177. to insert all of them when you resume the execution of your program.
  4178. Since the precise number of active watchpoints is unknown until such
  4179. time as the program is about to be resumed, @value{GDBN} might not be
  4180. able to warn you about this when you set the watchpoints, and the
  4181. warning will be printed only when the program is resumed:
  4182. @smallexample
  4183. Hardware watchpoint @var{num}: Could not insert watchpoint
  4184. @end smallexample
  4185. @noindent
  4186. If this happens, delete or disable some of the watchpoints.
  4187. Watching complex expressions that reference many variables can also
  4188. exhaust the resources available for hardware-assisted watchpoints.
  4189. That's because @value{GDBN} needs to watch every variable in the
  4190. expression with separately allocated resources.
  4191. If you call a function interactively using @code{print} or @code{call},
  4192. any watchpoints you have set will be inactive until @value{GDBN} reaches another
  4193. kind of breakpoint or the call completes.
  4194. @value{GDBN} automatically deletes watchpoints that watch local
  4195. (automatic) variables, or expressions that involve such variables, when
  4196. they go out of scope, that is, when the execution leaves the block in
  4197. which these variables were defined. In particular, when the program
  4198. being debugged terminates, @emph{all} local variables go out of scope,
  4199. and so only watchpoints that watch global variables remain set. If you
  4200. rerun the program, you will need to set all such watchpoints again. One
  4201. way of doing that would be to set a code breakpoint at the entry to the
  4202. @code{main} function and when it breaks, set all the watchpoints.
  4203. @cindex watchpoints and threads
  4204. @cindex threads and watchpoints
  4205. In multi-threaded programs, watchpoints will detect changes to the
  4206. watched expression from every thread.
  4207. @quotation
  4208. @emph{Warning:} In multi-threaded programs, software watchpoints
  4209. have only limited usefulness. If @value{GDBN} creates a software
  4210. watchpoint, it can only watch the value of an expression @emph{in a
  4211. single thread}. If you are confident that the expression can only
  4212. change due to the current thread's activity (and if you are also
  4213. confident that no other thread can become current), then you can use
  4214. software watchpoints as usual. However, @value{GDBN} may not notice
  4215. when a non-current thread's activity changes the expression. (Hardware
  4216. watchpoints, in contrast, watch an expression in all threads.)
  4217. @end quotation
  4218. @xref{set remote hardware-watchpoint-limit}.
  4219. @node Set Catchpoints
  4220. @subsection Setting Catchpoints
  4221. @cindex catchpoints, setting
  4222. @cindex exception handlers
  4223. @cindex event handling
  4224. You can use @dfn{catchpoints} to cause the debugger to stop for certain
  4225. kinds of program events, such as C@t{++} exceptions or the loading of a
  4226. shared library. Use the @code{catch} command to set a catchpoint.
  4227. @table @code
  4228. @kindex catch
  4229. @item catch @var{event}
  4230. Stop when @var{event} occurs. The @var{event} can be any of the following:
  4231. @table @code
  4232. @item throw @r{[}@var{regexp}@r{]}
  4233. @itemx rethrow @r{[}@var{regexp}@r{]}
  4234. @itemx catch @r{[}@var{regexp}@r{]}
  4235. @kindex catch throw
  4236. @kindex catch rethrow
  4237. @kindex catch catch
  4238. @cindex stop on C@t{++} exceptions
  4239. The throwing, re-throwing, or catching of a C@t{++} exception.
  4240. If @var{regexp} is given, then only exceptions whose type matches the
  4241. regular expression will be caught.
  4242. @vindex $_exception@r{, convenience variable}
  4243. The convenience variable @code{$_exception} is available at an
  4244. exception-related catchpoint, on some systems. This holds the
  4245. exception being thrown.
  4246. There are currently some limitations to C@t{++} exception handling in
  4247. @value{GDBN}:
  4248. @itemize @bullet
  4249. @item
  4250. The support for these commands is system-dependent. Currently, only
  4251. systems using the @samp{gnu-v3} C@t{++} ABI (@pxref{ABI}) are
  4252. supported.
  4253. @item
  4254. The regular expression feature and the @code{$_exception} convenience
  4255. variable rely on the presence of some SDT probes in @code{libstdc++}.
  4256. If these probes are not present, then these features cannot be used.
  4257. These probes were first available in the GCC 4.8 release, but whether
  4258. or not they are available in your GCC also depends on how it was
  4259. built.
  4260. @item
  4261. The @code{$_exception} convenience variable is only valid at the
  4262. instruction at which an exception-related catchpoint is set.
  4263. @item
  4264. When an exception-related catchpoint is hit, @value{GDBN} stops at a
  4265. location in the system library which implements runtime exception
  4266. support for C@t{++}, usually @code{libstdc++}. You can use @code{up}
  4267. (@pxref{Selection}) to get to your code.
  4268. @item
  4269. If you call a function interactively, @value{GDBN} normally returns
  4270. control to you when the function has finished executing. If the call
  4271. raises an exception, however, the call may bypass the mechanism that
  4272. returns control to you and cause your program either to abort or to
  4273. simply continue running until it hits a breakpoint, catches a signal
  4274. that @value{GDBN} is listening for, or exits. This is the case even if
  4275. you set a catchpoint for the exception; catchpoints on exceptions are
  4276. disabled within interactive calls. @xref{Calling}, for information on
  4277. controlling this with @code{set unwind-on-terminating-exception}.
  4278. @item
  4279. You cannot raise an exception interactively.
  4280. @item
  4281. You cannot install an exception handler interactively.
  4282. @end itemize
  4283. @item exception @r{[}@var{name}@r{]}
  4284. @kindex catch exception
  4285. @cindex Ada exception catching
  4286. @cindex catch Ada exceptions
  4287. An Ada exception being raised. If an exception name is specified
  4288. at the end of the command (eg @code{catch exception Program_Error}),
  4289. the debugger will stop only when this specific exception is raised.
  4290. Otherwise, the debugger stops execution when any Ada exception is raised.
  4291. When inserting an exception catchpoint on a user-defined exception whose
  4292. name is identical to one of the exceptions defined by the language, the
  4293. fully qualified name must be used as the exception name. Otherwise,
  4294. @value{GDBN} will assume that it should stop on the pre-defined exception
  4295. rather than the user-defined one. For instance, assuming an exception
  4296. called @code{Constraint_Error} is defined in package @code{Pck}, then
  4297. the command to use to catch such exceptions is @kbd{catch exception
  4298. Pck.Constraint_Error}.
  4299. @vindex $_ada_exception@r{, convenience variable}
  4300. The convenience variable @code{$_ada_exception} holds the address of
  4301. the exception being thrown. This can be useful when setting a
  4302. condition for such a catchpoint.
  4303. @item exception unhandled
  4304. @kindex catch exception unhandled
  4305. An exception that was raised but is not handled by the program. The
  4306. convenience variable @code{$_ada_exception} is set as for @code{catch
  4307. exception}.
  4308. @item handlers @r{[}@var{name}@r{]}
  4309. @kindex catch handlers
  4310. @cindex Ada exception handlers catching
  4311. @cindex catch Ada exceptions when handled
  4312. An Ada exception being handled. If an exception name is
  4313. specified at the end of the command
  4314. (eg @kbd{catch handlers Program_Error}), the debugger will stop
  4315. only when this specific exception is handled.
  4316. Otherwise, the debugger stops execution when any Ada exception is handled.
  4317. When inserting a handlers catchpoint on a user-defined
  4318. exception whose name is identical to one of the exceptions
  4319. defined by the language, the fully qualified name must be used
  4320. as the exception name. Otherwise, @value{GDBN} will assume that it
  4321. should stop on the pre-defined exception rather than the
  4322. user-defined one. For instance, assuming an exception called
  4323. @code{Constraint_Error} is defined in package @code{Pck}, then the
  4324. command to use to catch such exceptions handling is
  4325. @kbd{catch handlers Pck.Constraint_Error}.
  4326. The convenience variable @code{$_ada_exception} is set as for
  4327. @code{catch exception}.
  4328. @item assert
  4329. @kindex catch assert
  4330. A failed Ada assertion. Note that the convenience variable
  4331. @code{$_ada_exception} is @emph{not} set by this catchpoint.
  4332. @item exec
  4333. @kindex catch exec
  4334. @cindex break on fork/exec
  4335. A call to @code{exec}.
  4336. @anchor{catch syscall}
  4337. @item syscall
  4338. @itemx syscall @r{[}@var{name} @r{|} @var{number} @r{|} @r{group:}@var{groupname} @r{|} @r{g:}@var{groupname}@r{]} @dots{}
  4339. @kindex catch syscall
  4340. @cindex break on a system call.
  4341. A call to or return from a system call, a.k.a.@: @dfn{syscall}. A
  4342. syscall is a mechanism for application programs to request a service
  4343. from the operating system (OS) or one of the OS system services.
  4344. @value{GDBN} can catch some or all of the syscalls issued by the
  4345. debuggee, and show the related information for each syscall. If no
  4346. argument is specified, calls to and returns from all system calls
  4347. will be caught.
  4348. @var{name} can be any system call name that is valid for the
  4349. underlying OS. Just what syscalls are valid depends on the OS. On
  4350. GNU and Unix systems, you can find the full list of valid syscall
  4351. names on @file{/usr/include/asm/unistd.h}.
  4352. @c For MS-Windows, the syscall names and the corresponding numbers
  4353. @c can be found, e.g., on this URL:
  4354. @c http://www.metasploit.com/users/opcode/syscalls.html
  4355. @c but we don't support Windows syscalls yet.
  4356. Normally, @value{GDBN} knows in advance which syscalls are valid for
  4357. each OS, so you can use the @value{GDBN} command-line completion
  4358. facilities (@pxref{Completion,, command completion}) to list the
  4359. available choices.
  4360. You may also specify the system call numerically. A syscall's
  4361. number is the value passed to the OS's syscall dispatcher to
  4362. identify the requested service. When you specify the syscall by its
  4363. name, @value{GDBN} uses its database of syscalls to convert the name
  4364. into the corresponding numeric code, but using the number directly
  4365. may be useful if @value{GDBN}'s database does not have the complete
  4366. list of syscalls on your system (e.g., because @value{GDBN} lags
  4367. behind the OS upgrades).
  4368. You may specify a group of related syscalls to be caught at once using
  4369. the @code{group:} syntax (@code{g:} is a shorter equivalent). For
  4370. instance, on some platforms @value{GDBN} allows you to catch all
  4371. network related syscalls, by passing the argument @code{group:network}
  4372. to @code{catch syscall}. Note that not all syscall groups are
  4373. available in every system. You can use the command completion
  4374. facilities (@pxref{Completion,, command completion}) to list the
  4375. syscall groups available on your environment.
  4376. The example below illustrates how this command works if you don't provide
  4377. arguments to it:
  4378. @smallexample
  4379. (@value{GDBP}) catch syscall
  4380. Catchpoint 1 (syscall)
  4381. (@value{GDBP}) r
  4382. Starting program: /tmp/catch-syscall
  4383. Catchpoint 1 (call to syscall 'close'), \
  4384. 0xffffe424 in __kernel_vsyscall ()
  4385. (@value{GDBP}) c
  4386. Continuing.
  4387. Catchpoint 1 (returned from syscall 'close'), \
  4388. 0xffffe424 in __kernel_vsyscall ()
  4389. (@value{GDBP})
  4390. @end smallexample
  4391. Here is an example of catching a system call by name:
  4392. @smallexample
  4393. (@value{GDBP}) catch syscall chroot
  4394. Catchpoint 1 (syscall 'chroot' [61])
  4395. (@value{GDBP}) r
  4396. Starting program: /tmp/catch-syscall
  4397. Catchpoint 1 (call to syscall 'chroot'), \
  4398. 0xffffe424 in __kernel_vsyscall ()
  4399. (@value{GDBP}) c
  4400. Continuing.
  4401. Catchpoint 1 (returned from syscall 'chroot'), \
  4402. 0xffffe424 in __kernel_vsyscall ()
  4403. (@value{GDBP})
  4404. @end smallexample
  4405. An example of specifying a system call numerically. In the case
  4406. below, the syscall number has a corresponding entry in the XML
  4407. file, so @value{GDBN} finds its name and prints it:
  4408. @smallexample
  4409. (@value{GDBP}) catch syscall 252
  4410. Catchpoint 1 (syscall(s) 'exit_group')
  4411. (@value{GDBP}) r
  4412. Starting program: /tmp/catch-syscall
  4413. Catchpoint 1 (call to syscall 'exit_group'), \
  4414. 0xffffe424 in __kernel_vsyscall ()
  4415. (@value{GDBP}) c
  4416. Continuing.
  4417. Program exited normally.
  4418. (@value{GDBP})
  4419. @end smallexample
  4420. Here is an example of catching a syscall group:
  4421. @smallexample
  4422. (@value{GDBP}) catch syscall group:process
  4423. Catchpoint 1 (syscalls 'exit' [1] 'fork' [2] 'waitpid' [7]
  4424. 'execve' [11] 'wait4' [114] 'clone' [120] 'vfork' [190]
  4425. 'exit_group' [252] 'waitid' [284] 'unshare' [310])
  4426. (@value{GDBP}) r
  4427. Starting program: /tmp/catch-syscall
  4428. Catchpoint 1 (call to syscall fork), 0x00007ffff7df4e27 in open64 ()
  4429. from /lib64/ld-linux-x86-64.so.2
  4430. (@value{GDBP}) c
  4431. Continuing.
  4432. @end smallexample
  4433. However, there can be situations when there is no corresponding name
  4434. in XML file for that syscall number. In this case, @value{GDBN} prints
  4435. a warning message saying that it was not able to find the syscall name,
  4436. but the catchpoint will be set anyway. See the example below:
  4437. @smallexample
  4438. (@value{GDBP}) catch syscall 764
  4439. warning: The number '764' does not represent a known syscall.
  4440. Catchpoint 2 (syscall 764)
  4441. (@value{GDBP})
  4442. @end smallexample
  4443. If you configure @value{GDBN} using the @samp{--without-expat} option,
  4444. it will not be able to display syscall names. Also, if your
  4445. architecture does not have an XML file describing its system calls,
  4446. you will not be able to see the syscall names. It is important to
  4447. notice that these two features are used for accessing the syscall
  4448. name database. In either case, you will see a warning like this:
  4449. @smallexample
  4450. (@value{GDBP}) catch syscall
  4451. warning: Could not open "syscalls/i386-linux.xml"
  4452. warning: Could not load the syscall XML file 'syscalls/i386-linux.xml'.
  4453. GDB will not be able to display syscall names.
  4454. Catchpoint 1 (syscall)
  4455. (@value{GDBP})
  4456. @end smallexample
  4457. Of course, the file name will change depending on your architecture and system.
  4458. Still using the example above, you can also try to catch a syscall by its
  4459. number. In this case, you would see something like:
  4460. @smallexample
  4461. (@value{GDBP}) catch syscall 252
  4462. Catchpoint 1 (syscall(s) 252)
  4463. @end smallexample
  4464. Again, in this case @value{GDBN} would not be able to display syscall's names.
  4465. @item fork
  4466. @kindex catch fork
  4467. A call to @code{fork}.
  4468. @item vfork
  4469. @kindex catch vfork
  4470. A call to @code{vfork}.
  4471. @item load @r{[}@var{regexp}@r{]}
  4472. @itemx unload @r{[}@var{regexp}@r{]}
  4473. @kindex catch load
  4474. @kindex catch unload
  4475. The loading or unloading of a shared library. If @var{regexp} is
  4476. given, then the catchpoint will stop only if the regular expression
  4477. matches one of the affected libraries.
  4478. @item signal @r{[}@var{signal}@dots{} @r{|} @samp{all}@r{]}
  4479. @kindex catch signal
  4480. The delivery of a signal.
  4481. With no arguments, this catchpoint will catch any signal that is not
  4482. used internally by @value{GDBN}, specifically, all signals except
  4483. @samp{SIGTRAP} and @samp{SIGINT}.
  4484. With the argument @samp{all}, all signals, including those used by
  4485. @value{GDBN}, will be caught. This argument cannot be used with other
  4486. signal names.
  4487. Otherwise, the arguments are a list of signal names as given to
  4488. @code{handle} (@pxref{Signals}). Only signals specified in this list
  4489. will be caught.
  4490. One reason that @code{catch signal} can be more useful than
  4491. @code{handle} is that you can attach commands and conditions to the
  4492. catchpoint.
  4493. When a signal is caught by a catchpoint, the signal's @code{stop} and
  4494. @code{print} settings, as specified by @code{handle}, are ignored.
  4495. However, whether the signal is still delivered to the inferior depends
  4496. on the @code{pass} setting; this can be changed in the catchpoint's
  4497. commands.
  4498. @end table
  4499. @item tcatch @var{event}
  4500. @kindex tcatch
  4501. Set a catchpoint that is enabled only for one stop. The catchpoint is
  4502. automatically deleted after the first time the event is caught.
  4503. @end table
  4504. Use the @code{info break} command to list the current catchpoints.
  4505. @node Delete Breaks
  4506. @subsection Deleting Breakpoints
  4507. @cindex clearing breakpoints, watchpoints, catchpoints
  4508. @cindex deleting breakpoints, watchpoints, catchpoints
  4509. It is often necessary to eliminate a breakpoint, watchpoint, or
  4510. catchpoint once it has done its job and you no longer want your program
  4511. to stop there. This is called @dfn{deleting} the breakpoint. A
  4512. breakpoint that has been deleted no longer exists; it is forgotten.
  4513. With the @code{clear} command you can delete breakpoints according to
  4514. where they are in your program. With the @code{delete} command you can
  4515. delete individual breakpoints, watchpoints, or catchpoints by specifying
  4516. their breakpoint numbers.
  4517. It is not necessary to delete a breakpoint to proceed past it. @value{GDBN}
  4518. automatically ignores breakpoints on the first instruction to be executed
  4519. when you continue execution without changing the execution address.
  4520. @table @code
  4521. @kindex clear
  4522. @item clear
  4523. Delete any breakpoints at the next instruction to be executed in the
  4524. selected stack frame (@pxref{Selection, ,Selecting a Frame}). When
  4525. the innermost frame is selected, this is a good way to delete a
  4526. breakpoint where your program just stopped.
  4527. @item clear @var{location}
  4528. Delete any breakpoints set at the specified @var{location}.
  4529. @xref{Specify Location}, for the various forms of @var{location}; the
  4530. most useful ones are listed below:
  4531. @table @code
  4532. @item clear @var{function}
  4533. @itemx clear @var{filename}:@var{function}
  4534. Delete any breakpoints set at entry to the named @var{function}.
  4535. @item clear @var{linenum}
  4536. @itemx clear @var{filename}:@var{linenum}
  4537. Delete any breakpoints set at or within the code of the specified
  4538. @var{linenum} of the specified @var{filename}.
  4539. @end table
  4540. @cindex delete breakpoints
  4541. @kindex delete
  4542. @kindex d @r{(@code{delete})}
  4543. @item delete @r{[}breakpoints@r{]} @r{[}@var{list}@dots{}@r{]}
  4544. Delete the breakpoints, watchpoints, or catchpoints of the breakpoint
  4545. list specified as argument. If no argument is specified, delete all
  4546. breakpoints (@value{GDBN} asks confirmation, unless you have @code{set
  4547. confirm off}). You can abbreviate this command as @code{d}.
  4548. @end table
  4549. @node Disabling
  4550. @subsection Disabling Breakpoints
  4551. @cindex enable/disable a breakpoint
  4552. Rather than deleting a breakpoint, watchpoint, or catchpoint, you might
  4553. prefer to @dfn{disable} it. This makes the breakpoint inoperative as if
  4554. it had been deleted, but remembers the information on the breakpoint so
  4555. that you can @dfn{enable} it again later.
  4556. You disable and enable breakpoints, watchpoints, and catchpoints with
  4557. the @code{enable} and @code{disable} commands, optionally specifying
  4558. one or more breakpoint numbers as arguments. Use @code{info break} to
  4559. print a list of all breakpoints, watchpoints, and catchpoints if you
  4560. do not know which numbers to use.
  4561. Disabling and enabling a breakpoint that has multiple locations
  4562. affects all of its locations.
  4563. A breakpoint, watchpoint, or catchpoint can have any of several
  4564. different states of enablement:
  4565. @itemize @bullet
  4566. @item
  4567. Enabled. The breakpoint stops your program. A breakpoint set
  4568. with the @code{break} command starts out in this state.
  4569. @item
  4570. Disabled. The breakpoint has no effect on your program.
  4571. @item
  4572. Enabled once. The breakpoint stops your program, but then becomes
  4573. disabled.
  4574. @item
  4575. Enabled for a count. The breakpoint stops your program for the next
  4576. N times, then becomes disabled.
  4577. @item
  4578. Enabled for deletion. The breakpoint stops your program, but
  4579. immediately after it does so it is deleted permanently. A breakpoint
  4580. set with the @code{tbreak} command starts out in this state.
  4581. @end itemize
  4582. You can use the following commands to enable or disable breakpoints,
  4583. watchpoints, and catchpoints:
  4584. @table @code
  4585. @kindex disable
  4586. @kindex dis @r{(@code{disable})}
  4587. @item disable @r{[}breakpoints@r{]} @r{[}@var{list}@dots{}@r{]}
  4588. Disable the specified breakpoints---or all breakpoints, if none are
  4589. listed. A disabled breakpoint has no effect but is not forgotten. All
  4590. options such as ignore-counts, conditions and commands are remembered in
  4591. case the breakpoint is enabled again later. You may abbreviate
  4592. @code{disable} as @code{dis}.
  4593. @kindex enable
  4594. @item enable @r{[}breakpoints@r{]} @r{[}@var{list}@dots{}@r{]}
  4595. Enable the specified breakpoints (or all defined breakpoints). They
  4596. become effective once again in stopping your program.
  4597. @item enable @r{[}breakpoints@r{]} once @var{list}@dots{}
  4598. Enable the specified breakpoints temporarily. @value{GDBN} disables any
  4599. of these breakpoints immediately after stopping your program.
  4600. @item enable @r{[}breakpoints@r{]} count @var{count} @var{list}@dots{}
  4601. Enable the specified breakpoints temporarily. @value{GDBN} records
  4602. @var{count} with each of the specified breakpoints, and decrements a
  4603. breakpoint's count when it is hit. When any count reaches 0,
  4604. @value{GDBN} disables that breakpoint. If a breakpoint has an ignore
  4605. count (@pxref{Conditions, ,Break Conditions}), that will be
  4606. decremented to 0 before @var{count} is affected.
  4607. @item enable @r{[}breakpoints@r{]} delete @var{list}@dots{}
  4608. Enable the specified breakpoints to work once, then die. @value{GDBN}
  4609. deletes any of these breakpoints as soon as your program stops there.
  4610. Breakpoints set by the @code{tbreak} command start out in this state.
  4611. @end table
  4612. @c FIXME: I think the following ``Except for [...] @code{tbreak}'' is
  4613. @c confusing: tbreak is also initially enabled.
  4614. Except for a breakpoint set with @code{tbreak} (@pxref{Set Breaks,
  4615. ,Setting Breakpoints}), breakpoints that you set are initially enabled;
  4616. subsequently, they become disabled or enabled only when you use one of
  4617. the commands above. (The command @code{until} can set and delete a
  4618. breakpoint of its own, but it does not change the state of your other
  4619. breakpoints; see @ref{Continuing and Stepping, ,Continuing and
  4620. Stepping}.)
  4621. @node Conditions
  4622. @subsection Break Conditions
  4623. @cindex conditional breakpoints
  4624. @cindex breakpoint conditions
  4625. @c FIXME what is scope of break condition expr? Context where wanted?
  4626. @c in particular for a watchpoint?
  4627. The simplest sort of breakpoint breaks every time your program reaches a
  4628. specified place. You can also specify a @dfn{condition} for a
  4629. breakpoint. A condition is just a Boolean expression in your
  4630. programming language (@pxref{Expressions, ,Expressions}). A breakpoint with
  4631. a condition evaluates the expression each time your program reaches it,
  4632. and your program stops only if the condition is @emph{true}.
  4633. This is the converse of using assertions for program validation; in that
  4634. situation, you want to stop when the assertion is violated---that is,
  4635. when the condition is false. In C, if you want to test an assertion expressed
  4636. by the condition @var{assert}, you should set the condition
  4637. @samp{! @var{assert}} on the appropriate breakpoint.
  4638. Conditions are also accepted for watchpoints; you may not need them,
  4639. since a watchpoint is inspecting the value of an expression anyhow---but
  4640. it might be simpler, say, to just set a watchpoint on a variable name,
  4641. and specify a condition that tests whether the new value is an interesting
  4642. one.
  4643. Break conditions can have side effects, and may even call functions in
  4644. your program. This can be useful, for example, to activate functions
  4645. that log program progress, or to use your own print functions to
  4646. format special data structures. The effects are completely predictable
  4647. unless there is another enabled breakpoint at the same address. (In
  4648. that case, @value{GDBN} might see the other breakpoint first and stop your
  4649. program without checking the condition of this one.) Note that
  4650. breakpoint commands are usually more convenient and flexible than break
  4651. conditions for the
  4652. purpose of performing side effects when a breakpoint is reached
  4653. (@pxref{Break Commands, ,Breakpoint Command Lists}).
  4654. Breakpoint conditions can also be evaluated on the target's side if
  4655. the target supports it. Instead of evaluating the conditions locally,
  4656. @value{GDBN} encodes the expression into an agent expression
  4657. (@pxref{Agent Expressions}) suitable for execution on the target,
  4658. independently of @value{GDBN}. Global variables become raw memory
  4659. locations, locals become stack accesses, and so forth.
  4660. In this case, @value{GDBN} will only be notified of a breakpoint trigger
  4661. when its condition evaluates to true. This mechanism may provide faster
  4662. response times depending on the performance characteristics of the target
  4663. since it does not need to keep @value{GDBN} informed about
  4664. every breakpoint trigger, even those with false conditions.
  4665. Break conditions can be specified when a breakpoint is set, by using
  4666. @samp{if} in the arguments to the @code{break} command. @xref{Set
  4667. Breaks, ,Setting Breakpoints}. They can also be changed at any time
  4668. with the @code{condition} command.
  4669. You can also use the @code{if} keyword with the @code{watch} command.
  4670. The @code{catch} command does not recognize the @code{if} keyword;
  4671. @code{condition} is the only way to impose a further condition on a
  4672. catchpoint.
  4673. @table @code
  4674. @kindex condition
  4675. @item condition @var{bnum} @var{expression}
  4676. Specify @var{expression} as the break condition for breakpoint,
  4677. watchpoint, or catchpoint number @var{bnum}. After you set a condition,
  4678. breakpoint @var{bnum} stops your program only if the value of
  4679. @var{expression} is true (nonzero, in C). When you use
  4680. @code{condition}, @value{GDBN} checks @var{expression} immediately for
  4681. syntactic correctness, and to determine whether symbols in it have
  4682. referents in the context of your breakpoint. If @var{expression} uses
  4683. symbols not referenced in the context of the breakpoint, @value{GDBN}
  4684. prints an error message:
  4685. @smallexample
  4686. No symbol "foo" in current context.
  4687. @end smallexample
  4688. @noindent
  4689. @value{GDBN} does
  4690. not actually evaluate @var{expression} at the time the @code{condition}
  4691. command (or a command that sets a breakpoint with a condition, like
  4692. @code{break if @dots{}}) is given, however. @xref{Expressions, ,Expressions}.
  4693. @item condition -force @var{bnum} @var{expression}
  4694. When the @code{-force} flag is used, define the condition even if
  4695. @var{expression} is invalid at all the current locations of breakpoint
  4696. @var{bnum}. This is similar to the @code{-force-condition} option
  4697. of the @code{break} command.
  4698. @item condition @var{bnum}
  4699. Remove the condition from breakpoint number @var{bnum}. It becomes
  4700. an ordinary unconditional breakpoint.
  4701. @end table
  4702. @cindex ignore count (of breakpoint)
  4703. A special case of a breakpoint condition is to stop only when the
  4704. breakpoint has been reached a certain number of times. This is so
  4705. useful that there is a special way to do it, using the @dfn{ignore
  4706. count} of the breakpoint. Every breakpoint has an ignore count, which
  4707. is an integer. Most of the time, the ignore count is zero, and
  4708. therefore has no effect. But if your program reaches a breakpoint whose
  4709. ignore count is positive, then instead of stopping, it just decrements
  4710. the ignore count by one and continues. As a result, if the ignore count
  4711. value is @var{n}, the breakpoint does not stop the next @var{n} times
  4712. your program reaches it.
  4713. @table @code
  4714. @kindex ignore
  4715. @item ignore @var{bnum} @var{count}
  4716. Set the ignore count of breakpoint number @var{bnum} to @var{count}.
  4717. The next @var{count} times the breakpoint is reached, your program's
  4718. execution does not stop; other than to decrement the ignore count, @value{GDBN}
  4719. takes no action.
  4720. To make the breakpoint stop the next time it is reached, specify
  4721. a count of zero.
  4722. When you use @code{continue} to resume execution of your program from a
  4723. breakpoint, you can specify an ignore count directly as an argument to
  4724. @code{continue}, rather than using @code{ignore}. @xref{Continuing and
  4725. Stepping,,Continuing and Stepping}.
  4726. If a breakpoint has a positive ignore count and a condition, the
  4727. condition is not checked. Once the ignore count reaches zero,
  4728. @value{GDBN} resumes checking the condition.
  4729. You could achieve the effect of the ignore count with a condition such
  4730. as @w{@samp{$foo-- <= 0}} using a debugger convenience variable that
  4731. is decremented each time. @xref{Convenience Vars, ,Convenience
  4732. Variables}.
  4733. @end table
  4734. Ignore counts apply to breakpoints, watchpoints, and catchpoints.
  4735. @node Break Commands
  4736. @subsection Breakpoint Command Lists
  4737. @cindex breakpoint commands
  4738. You can give any breakpoint (or watchpoint or catchpoint) a series of
  4739. commands to execute when your program stops due to that breakpoint. For
  4740. example, you might want to print the values of certain expressions, or
  4741. enable other breakpoints.
  4742. @table @code
  4743. @kindex commands
  4744. @kindex end@r{ (breakpoint commands)}
  4745. @item commands @r{[}@var{list}@dots{}@r{]}
  4746. @itemx @dots{} @var{command-list} @dots{}
  4747. @itemx end
  4748. Specify a list of commands for the given breakpoints. The commands
  4749. themselves appear on the following lines. Type a line containing just
  4750. @code{end} to terminate the commands.
  4751. To remove all commands from a breakpoint, type @code{commands} and
  4752. follow it immediately with @code{end}; that is, give no commands.
  4753. With no argument, @code{commands} refers to the last breakpoint,
  4754. watchpoint, or catchpoint set (not to the breakpoint most recently
  4755. encountered). If the most recent breakpoints were set with a single
  4756. command, then the @code{commands} will apply to all the breakpoints
  4757. set by that command. This applies to breakpoints set by
  4758. @code{rbreak}, and also applies when a single @code{break} command
  4759. creates multiple breakpoints (@pxref{Ambiguous Expressions,,Ambiguous
  4760. Expressions}).
  4761. @end table
  4762. Pressing @key{RET} as a means of repeating the last @value{GDBN} command is
  4763. disabled within a @var{command-list}.
  4764. You can use breakpoint commands to start your program up again. Simply
  4765. use the @code{continue} command, or @code{step}, or any other command
  4766. that resumes execution.
  4767. Any other commands in the command list, after a command that resumes
  4768. execution, are ignored. This is because any time you resume execution
  4769. (even with a simple @code{next} or @code{step}), you may encounter
  4770. another breakpoint---which could have its own command list, leading to
  4771. ambiguities about which list to execute.
  4772. @kindex silent
  4773. If the first command you specify in a command list is @code{silent}, the
  4774. usual message about stopping at a breakpoint is not printed. This may
  4775. be desirable for breakpoints that are to print a specific message and
  4776. then continue. If none of the remaining commands print anything, you
  4777. see no sign that the breakpoint was reached. @code{silent} is
  4778. meaningful only at the beginning of a breakpoint command list.
  4779. The commands @code{echo}, @code{output}, and @code{printf} allow you to
  4780. print precisely controlled output, and are often useful in silent
  4781. breakpoints. @xref{Output, ,Commands for Controlled Output}.
  4782. For example, here is how you could use breakpoint commands to print the
  4783. value of @code{x} at entry to @code{foo} whenever @code{x} is positive.
  4784. @smallexample
  4785. break foo if x>0
  4786. commands
  4787. silent
  4788. printf "x is %d\n",x
  4789. cont
  4790. end
  4791. @end smallexample
  4792. One application for breakpoint commands is to compensate for one bug so
  4793. you can test for another. Put a breakpoint just after the erroneous line
  4794. of code, give it a condition to detect the case in which something
  4795. erroneous has been done, and give it commands to assign correct values
  4796. to any variables that need them. End with the @code{continue} command
  4797. so that your program does not stop, and start with the @code{silent}
  4798. command so that no output is produced. Here is an example:
  4799. @smallexample
  4800. break 403
  4801. commands
  4802. silent
  4803. set x = y + 4
  4804. cont
  4805. end
  4806. @end smallexample
  4807. @node Dynamic Printf
  4808. @subsection Dynamic Printf
  4809. @cindex dynamic printf
  4810. @cindex dprintf
  4811. The dynamic printf command @code{dprintf} combines a breakpoint with
  4812. formatted printing of your program's data to give you the effect of
  4813. inserting @code{printf} calls into your program on-the-fly, without
  4814. having to recompile it.
  4815. In its most basic form, the output goes to the GDB console. However,
  4816. you can set the variable @code{dprintf-style} for alternate handling.
  4817. For instance, you can ask to format the output by calling your
  4818. program's @code{printf} function. This has the advantage that the
  4819. characters go to the program's output device, so they can recorded in
  4820. redirects to files and so forth.
  4821. If you are doing remote debugging with a stub or agent, you can also
  4822. ask to have the printf handled by the remote agent. In addition to
  4823. ensuring that the output goes to the remote program's device along
  4824. with any other output the program might produce, you can also ask that
  4825. the dprintf remain active even after disconnecting from the remote
  4826. target. Using the stub/agent is also more efficient, as it can do
  4827. everything without needing to communicate with @value{GDBN}.
  4828. @table @code
  4829. @kindex dprintf
  4830. @item dprintf @var{location},@var{template},@var{expression}[,@var{expression}@dots{}]
  4831. Whenever execution reaches @var{location}, print the values of one or
  4832. more @var{expressions} under the control of the string @var{template}.
  4833. To print several values, separate them with commas.
  4834. @item set dprintf-style @var{style}
  4835. Set the dprintf output to be handled in one of several different
  4836. styles enumerated below. A change of style affects all existing
  4837. dynamic printfs immediately. (If you need individual control over the
  4838. print commands, simply define normal breakpoints with
  4839. explicitly-supplied command lists.)
  4840. @table @code
  4841. @item gdb
  4842. @kindex dprintf-style gdb
  4843. Handle the output using the @value{GDBN} @code{printf} command.
  4844. @item call
  4845. @kindex dprintf-style call
  4846. Handle the output by calling a function in your program (normally
  4847. @code{printf}).
  4848. @item agent
  4849. @kindex dprintf-style agent
  4850. Have the remote debugging agent (such as @code{gdbserver}) handle
  4851. the output itself. This style is only available for agents that
  4852. support running commands on the target.
  4853. @end table
  4854. @item set dprintf-function @var{function}
  4855. Set the function to call if the dprintf style is @code{call}. By
  4856. default its value is @code{printf}. You may set it to any expression.
  4857. that @value{GDBN} can evaluate to a function, as per the @code{call}
  4858. command.
  4859. @item set dprintf-channel @var{channel}
  4860. Set a ``channel'' for dprintf. If set to a non-empty value,
  4861. @value{GDBN} will evaluate it as an expression and pass the result as
  4862. a first argument to the @code{dprintf-function}, in the manner of
  4863. @code{fprintf} and similar functions. Otherwise, the dprintf format
  4864. string will be the first argument, in the manner of @code{printf}.
  4865. As an example, if you wanted @code{dprintf} output to go to a logfile
  4866. that is a standard I/O stream assigned to the variable @code{mylog},
  4867. you could do the following:
  4868. @example
  4869. (gdb) set dprintf-style call
  4870. (gdb) set dprintf-function fprintf
  4871. (gdb) set dprintf-channel mylog
  4872. (gdb) dprintf 25,"at line 25, glob=%d\n",glob
  4873. Dprintf 1 at 0x123456: file main.c, line 25.
  4874. (gdb) info break
  4875. 1 dprintf keep y 0x00123456 in main at main.c:25
  4876. call (void) fprintf (mylog,"at line 25, glob=%d\n",glob)
  4877. continue
  4878. (gdb)
  4879. @end example
  4880. Note that the @code{info break} displays the dynamic printf commands
  4881. as normal breakpoint commands; you can thus easily see the effect of
  4882. the variable settings.
  4883. @item set disconnected-dprintf on
  4884. @itemx set disconnected-dprintf off
  4885. @kindex set disconnected-dprintf
  4886. Choose whether @code{dprintf} commands should continue to run if
  4887. @value{GDBN} has disconnected from the target. This only applies
  4888. if the @code{dprintf-style} is @code{agent}.
  4889. @item show disconnected-dprintf off
  4890. @kindex show disconnected-dprintf
  4891. Show the current choice for disconnected @code{dprintf}.
  4892. @end table
  4893. @value{GDBN} does not check the validity of function and channel,
  4894. relying on you to supply values that are meaningful for the contexts
  4895. in which they are being used. For instance, the function and channel
  4896. may be the values of local variables, but if that is the case, then
  4897. all enabled dynamic prints must be at locations within the scope of
  4898. those locals. If evaluation fails, @value{GDBN} will report an error.
  4899. @node Save Breakpoints
  4900. @subsection How to save breakpoints to a file
  4901. To save breakpoint definitions to a file use the @w{@code{save
  4902. breakpoints}} command.
  4903. @table @code
  4904. @kindex save breakpoints
  4905. @cindex save breakpoints to a file for future sessions
  4906. @item save breakpoints [@var{filename}]
  4907. This command saves all current breakpoint definitions together with
  4908. their commands and ignore counts, into a file @file{@var{filename}}
  4909. suitable for use in a later debugging session. This includes all
  4910. types of breakpoints (breakpoints, watchpoints, catchpoints,
  4911. tracepoints). To read the saved breakpoint definitions, use the
  4912. @code{source} command (@pxref{Command Files}). Note that watchpoints
  4913. with expressions involving local variables may fail to be recreated
  4914. because it may not be possible to access the context where the
  4915. watchpoint is valid anymore. Because the saved breakpoint definitions
  4916. are simply a sequence of @value{GDBN} commands that recreate the
  4917. breakpoints, you can edit the file in your favorite editing program,
  4918. and remove the breakpoint definitions you're not interested in, or
  4919. that can no longer be recreated.
  4920. @end table
  4921. @node Static Probe Points
  4922. @subsection Static Probe Points
  4923. @cindex static probe point, SystemTap
  4924. @cindex static probe point, DTrace
  4925. @value{GDBN} supports @dfn{SDT} probes in the code. @acronym{SDT} stands
  4926. for Statically Defined Tracing, and the probes are designed to have a tiny
  4927. runtime code and data footprint, and no dynamic relocations.
  4928. Currently, the following types of probes are supported on
  4929. ELF-compatible systems:
  4930. @itemize @bullet
  4931. @item @code{SystemTap} (@uref{http://sourceware.org/systemtap/})
  4932. @acronym{SDT} probes@footnote{See
  4933. @uref{http://sourceware.org/systemtap/wiki/AddingUserSpaceProbingToApps}
  4934. for more information on how to add @code{SystemTap} @acronym{SDT}
  4935. probes in your applications.}. @code{SystemTap} probes are usable
  4936. from assembly, C and C@t{++} languages@footnote{See
  4937. @uref{http://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation}
  4938. for a good reference on how the @acronym{SDT} probes are implemented.}.
  4939. @item @code{DTrace} (@uref{http://oss.oracle.com/projects/DTrace})
  4940. @acronym{USDT} probes. @code{DTrace} probes are usable from C and
  4941. C@t{++} languages.
  4942. @end itemize
  4943. @cindex semaphores on static probe points
  4944. Some @code{SystemTap} probes have an associated semaphore variable;
  4945. for instance, this happens automatically if you defined your probe
  4946. using a DTrace-style @file{.d} file. If your probe has a semaphore,
  4947. @value{GDBN} will automatically enable it when you specify a
  4948. breakpoint using the @samp{-probe-stap} notation. But, if you put a
  4949. breakpoint at a probe's location by some other method (e.g.,
  4950. @code{break file:line}), then @value{GDBN} will not automatically set
  4951. the semaphore. @code{DTrace} probes do not support semaphores.
  4952. You can examine the available static static probes using @code{info
  4953. probes}, with optional arguments:
  4954. @table @code
  4955. @kindex info probes
  4956. @item info probes @r{[}@var{type}@r{]} @r{[}@var{provider} @r{[}@var{name} @r{[}@var{objfile}@r{]}@r{]}@r{]}
  4957. If given, @var{type} is either @code{stap} for listing
  4958. @code{SystemTap} probes or @code{dtrace} for listing @code{DTrace}
  4959. probes. If omitted all probes are listed regardless of their types.
  4960. If given, @var{provider} is a regular expression used to match against provider
  4961. names when selecting which probes to list. If omitted, probes by all
  4962. probes from all providers are listed.
  4963. If given, @var{name} is a regular expression to match against probe names
  4964. when selecting which probes to list. If omitted, probe names are not
  4965. considered when deciding whether to display them.
  4966. If given, @var{objfile} is a regular expression used to select which
  4967. object files (executable or shared libraries) to examine. If not
  4968. given, all object files are considered.
  4969. @item info probes all
  4970. List the available static probes, from all types.
  4971. @end table
  4972. @cindex enabling and disabling probes
  4973. Some probe points can be enabled and/or disabled. The effect of
  4974. enabling or disabling a probe depends on the type of probe being
  4975. handled. Some @code{DTrace} probes can be enabled or
  4976. disabled, but @code{SystemTap} probes cannot be disabled.
  4977. You can enable (or disable) one or more probes using the following
  4978. commands, with optional arguments:
  4979. @table @code
  4980. @kindex enable probes
  4981. @item enable probes @r{[}@var{provider} @r{[}@var{name} @r{[}@var{objfile}@r{]}@r{]}@r{]}
  4982. If given, @var{provider} is a regular expression used to match against
  4983. provider names when selecting which probes to enable. If omitted,
  4984. all probes from all providers are enabled.
  4985. If given, @var{name} is a regular expression to match against probe
  4986. names when selecting which probes to enable. If omitted, probe names
  4987. are not considered when deciding whether to enable them.
  4988. If given, @var{objfile} is a regular expression used to select which
  4989. object files (executable or shared libraries) to examine. If not
  4990. given, all object files are considered.
  4991. @kindex disable probes
  4992. @item disable probes @r{[}@var{provider} @r{[}@var{name} @r{[}@var{objfile}@r{]}@r{]}@r{]}
  4993. See the @code{enable probes} command above for a description of the
  4994. optional arguments accepted by this command.
  4995. @end table
  4996. @vindex $_probe_arg@r{, convenience variable}
  4997. A probe may specify up to twelve arguments. These are available at the
  4998. point at which the probe is defined---that is, when the current PC is
  4999. at the probe's location. The arguments are available using the
  5000. convenience variables (@pxref{Convenience Vars})
  5001. @code{$_probe_arg0}@dots{}@code{$_probe_arg11}. In @code{SystemTap}
  5002. probes each probe argument is an integer of the appropriate size;
  5003. types are not preserved. In @code{DTrace} probes types are preserved
  5004. provided that they are recognized as such by @value{GDBN}; otherwise
  5005. the value of the probe argument will be a long integer. The
  5006. convenience variable @code{$_probe_argc} holds the number of arguments
  5007. at the current probe point.
  5008. These variables are always available, but attempts to access them at
  5009. any location other than a probe point will cause @value{GDBN} to give
  5010. an error message.
  5011. @c @ifclear BARETARGET
  5012. @node Error in Breakpoints
  5013. @subsection ``Cannot insert breakpoints''
  5014. If you request too many active hardware-assisted breakpoints and
  5015. watchpoints, you will see this error message:
  5016. @c FIXME: the precise wording of this message may change; the relevant
  5017. @c source change is not committed yet (Sep 3, 1999).
  5018. @smallexample
  5019. Stopped; cannot insert breakpoints.
  5020. You may have requested too many hardware breakpoints and watchpoints.
  5021. @end smallexample
  5022. @noindent
  5023. This message is printed when you attempt to resume the program, since
  5024. only then @value{GDBN} knows exactly how many hardware breakpoints and
  5025. watchpoints it needs to insert.
  5026. When this message is printed, you need to disable or remove some of the
  5027. hardware-assisted breakpoints and watchpoints, and then continue.
  5028. @node Breakpoint-related Warnings
  5029. @subsection ``Breakpoint address adjusted...''
  5030. @cindex breakpoint address adjusted
  5031. Some processor architectures place constraints on the addresses at
  5032. which breakpoints may be placed. For architectures thus constrained,
  5033. @value{GDBN} will attempt to adjust the breakpoint's address to comply
  5034. with the constraints dictated by the architecture.
  5035. One example of such an architecture is the Fujitsu FR-V. The FR-V is
  5036. a VLIW architecture in which a number of RISC-like instructions may be
  5037. bundled together for parallel execution. The FR-V architecture
  5038. constrains the location of a breakpoint instruction within such a
  5039. bundle to the instruction with the lowest address. @value{GDBN}
  5040. honors this constraint by adjusting a breakpoint's address to the
  5041. first in the bundle.
  5042. It is not uncommon for optimized code to have bundles which contain
  5043. instructions from different source statements, thus it may happen that
  5044. a breakpoint's address will be adjusted from one source statement to
  5045. another. Since this adjustment may significantly alter @value{GDBN}'s
  5046. breakpoint related behavior from what the user expects, a warning is
  5047. printed when the breakpoint is first set and also when the breakpoint
  5048. is hit.
  5049. A warning like the one below is printed when setting a breakpoint
  5050. that's been subject to address adjustment:
  5051. @smallexample
  5052. warning: Breakpoint address adjusted from 0x00010414 to 0x00010410.
  5053. @end smallexample
  5054. Such warnings are printed both for user settable and @value{GDBN}'s
  5055. internal breakpoints. If you see one of these warnings, you should
  5056. verify that a breakpoint set at the adjusted address will have the
  5057. desired affect. If not, the breakpoint in question may be removed and
  5058. other breakpoints may be set which will have the desired behavior.
  5059. E.g., it may be sufficient to place the breakpoint at a later
  5060. instruction. A conditional breakpoint may also be useful in some
  5061. cases to prevent the breakpoint from triggering too often.
  5062. @value{GDBN} will also issue a warning when stopping at one of these
  5063. adjusted breakpoints:
  5064. @smallexample
  5065. warning: Breakpoint 1 address previously adjusted from 0x00010414
  5066. to 0x00010410.
  5067. @end smallexample
  5068. When this warning is encountered, it may be too late to take remedial
  5069. action except in cases where the breakpoint is hit earlier or more
  5070. frequently than expected.
  5071. @node Continuing and Stepping
  5072. @section Continuing and Stepping
  5073. @cindex stepping
  5074. @cindex continuing
  5075. @cindex resuming execution
  5076. @dfn{Continuing} means resuming program execution until your program
  5077. completes normally. In contrast, @dfn{stepping} means executing just
  5078. one more ``step'' of your program, where ``step'' may mean either one
  5079. line of source code, or one machine instruction (depending on what
  5080. particular command you use). Either when continuing or when stepping,
  5081. your program may stop even sooner, due to a breakpoint or a signal. (If
  5082. it stops due to a signal, you may want to use @code{handle}, or use
  5083. @samp{signal 0} to resume execution (@pxref{Signals, ,Signals}),
  5084. or you may step into the signal's handler (@pxref{stepping and signal
  5085. handlers}).)
  5086. @table @code
  5087. @kindex continue
  5088. @kindex c @r{(@code{continue})}
  5089. @kindex fg @r{(resume foreground execution)}
  5090. @item continue @r{[}@var{ignore-count}@r{]}
  5091. @itemx c @r{[}@var{ignore-count}@r{]}
  5092. @itemx fg @r{[}@var{ignore-count}@r{]}
  5093. Resume program execution, at the address where your program last stopped;
  5094. any breakpoints set at that address are bypassed. The optional argument
  5095. @var{ignore-count} allows you to specify a further number of times to
  5096. ignore a breakpoint at this location; its effect is like that of
  5097. @code{ignore} (@pxref{Conditions, ,Break Conditions}).
  5098. The argument @var{ignore-count} is meaningful only when your program
  5099. stopped due to a breakpoint. At other times, the argument to
  5100. @code{continue} is ignored.
  5101. The synonyms @code{c} and @code{fg} (for @dfn{foreground}, as the
  5102. debugged program is deemed to be the foreground program) are provided
  5103. purely for convenience, and have exactly the same behavior as
  5104. @code{continue}.
  5105. @end table
  5106. To resume execution at a different place, you can use @code{return}
  5107. (@pxref{Returning, ,Returning from a Function}) to go back to the
  5108. calling function; or @code{jump} (@pxref{Jumping, ,Continuing at a
  5109. Different Address}) to go to an arbitrary location in your program.
  5110. A typical technique for using stepping is to set a breakpoint
  5111. (@pxref{Breakpoints, ,Breakpoints; Watchpoints; and Catchpoints}) at the
  5112. beginning of the function or the section of your program where a problem
  5113. is believed to lie, run your program until it stops at that breakpoint,
  5114. and then step through the suspect area, examining the variables that are
  5115. interesting, until you see the problem happen.
  5116. @table @code
  5117. @kindex step
  5118. @kindex s @r{(@code{step})}
  5119. @item step
  5120. Continue running your program until control reaches a different source
  5121. line, then stop it and return control to @value{GDBN}. This command is
  5122. abbreviated @code{s}.
  5123. @quotation
  5124. @c "without debugging information" is imprecise; actually "without line
  5125. @c numbers in the debugging information". (gcc -g1 has debugging info but
  5126. @c not line numbers). But it seems complex to try to make that
  5127. @c distinction here.
  5128. @emph{Warning:} If you use the @code{step} command while control is
  5129. within a function that was compiled without debugging information,
  5130. execution proceeds until control reaches a function that does have
  5131. debugging information. Likewise, it will not step into a function which
  5132. is compiled without debugging information. To step through functions
  5133. without debugging information, use the @code{stepi} command, described
  5134. below.
  5135. @end quotation
  5136. The @code{step} command only stops at the first instruction of a source
  5137. line. This prevents the multiple stops that could otherwise occur in
  5138. @code{switch} statements, @code{for} loops, etc. @code{step} continues
  5139. to stop if a function that has debugging information is called within
  5140. the line. In other words, @code{step} @emph{steps inside} any functions
  5141. called within the line.
  5142. Also, the @code{step} command only enters a function if there is line
  5143. number information for the function. Otherwise it acts like the
  5144. @code{next} command. This avoids problems when using @code{cc -gl}
  5145. on @acronym{MIPS} machines. Previously, @code{step} entered subroutines if there
  5146. was any debugging information about the routine.
  5147. @item step @var{count}
  5148. Continue running as in @code{step}, but do so @var{count} times. If a
  5149. breakpoint is reached, or a signal not related to stepping occurs before
  5150. @var{count} steps, stepping stops right away.
  5151. @kindex next
  5152. @kindex n @r{(@code{next})}
  5153. @item next @r{[}@var{count}@r{]}
  5154. Continue to the next source line in the current (innermost) stack frame.
  5155. This is similar to @code{step}, but function calls that appear within
  5156. the line of code are executed without stopping. Execution stops when
  5157. control reaches a different line of code at the original stack level
  5158. that was executing when you gave the @code{next} command. This command
  5159. is abbreviated @code{n}.
  5160. An argument @var{count} is a repeat count, as for @code{step}.
  5161. @c FIX ME!! Do we delete this, or is there a way it fits in with
  5162. @c the following paragraph? --- Vctoria
  5163. @c
  5164. @c @code{next} within a function that lacks debugging information acts like
  5165. @c @code{step}, but any function calls appearing within the code of the
  5166. @c function are executed without stopping.
  5167. The @code{next} command only stops at the first instruction of a
  5168. source line. This prevents multiple stops that could otherwise occur in
  5169. @code{switch} statements, @code{for} loops, etc.
  5170. @kindex set step-mode
  5171. @item set step-mode
  5172. @cindex functions without line info, and stepping
  5173. @cindex stepping into functions with no line info
  5174. @itemx set step-mode on
  5175. The @code{set step-mode on} command causes the @code{step} command to
  5176. stop at the first instruction of a function which contains no debug line
  5177. information rather than stepping over it.
  5178. This is useful in cases where you may be interested in inspecting the
  5179. machine instructions of a function which has no symbolic info and do not
  5180. want @value{GDBN} to automatically skip over this function.
  5181. @item set step-mode off
  5182. Causes the @code{step} command to step over any functions which contains no
  5183. debug information. This is the default.
  5184. @item show step-mode
  5185. Show whether @value{GDBN} will stop in or step over functions without
  5186. source line debug information.
  5187. @kindex finish
  5188. @kindex fin @r{(@code{finish})}
  5189. @item finish
  5190. Continue running until just after function in the selected stack frame
  5191. returns. Print the returned value (if any). This command can be
  5192. abbreviated as @code{fin}.
  5193. Contrast this with the @code{return} command (@pxref{Returning,
  5194. ,Returning from a Function}).
  5195. @kindex set print finish
  5196. @kindex show print finish
  5197. @item set print finish @r{[}on|off@r{]}
  5198. @itemx show print finish
  5199. By default the @code{finish} command will show the value that is
  5200. returned by the function. This can be disabled using @code{set print
  5201. finish off}. When disabled, the value is still entered into the value
  5202. history (@pxref{Value History}), but not displayed.
  5203. @kindex until
  5204. @kindex u @r{(@code{until})}
  5205. @cindex run until specified location
  5206. @item until
  5207. @itemx u
  5208. Continue running until a source line past the current line, in the
  5209. current stack frame, is reached. This command is used to avoid single
  5210. stepping through a loop more than once. It is like the @code{next}
  5211. command, except that when @code{until} encounters a jump, it
  5212. automatically continues execution until the program counter is greater
  5213. than the address of the jump.
  5214. This means that when you reach the end of a loop after single stepping
  5215. though it, @code{until} makes your program continue execution until it
  5216. exits the loop. In contrast, a @code{next} command at the end of a loop
  5217. simply steps back to the beginning of the loop, which forces you to step
  5218. through the next iteration.
  5219. @code{until} always stops your program if it attempts to exit the current
  5220. stack frame.
  5221. @code{until} may produce somewhat counterintuitive results if the order
  5222. of machine code does not match the order of the source lines. For
  5223. example, in the following excerpt from a debugging session, the @code{f}
  5224. (@code{frame}) command shows that execution is stopped at line
  5225. @code{206}; yet when we use @code{until}, we get to line @code{195}:
  5226. @smallexample
  5227. (@value{GDBP}) f
  5228. #0 main (argc=4, argv=0xf7fffae8) at m4.c:206
  5229. 206 expand_input();
  5230. (@value{GDBP}) until
  5231. 195 for ( ; argc > 0; NEXTARG) @{
  5232. @end smallexample
  5233. This happened because, for execution efficiency, the compiler had
  5234. generated code for the loop closure test at the end, rather than the
  5235. start, of the loop---even though the test in a C @code{for}-loop is
  5236. written before the body of the loop. The @code{until} command appeared
  5237. to step back to the beginning of the loop when it advanced to this
  5238. expression; however, it has not really gone to an earlier
  5239. statement---not in terms of the actual machine code.
  5240. @code{until} with no argument works by means of single
  5241. instruction stepping, and hence is slower than @code{until} with an
  5242. argument.
  5243. @item until @var{location}
  5244. @itemx u @var{location}
  5245. Continue running your program until either the specified @var{location} is
  5246. reached, or the current stack frame returns. The location is any of
  5247. the forms described in @ref{Specify Location}.
  5248. This form of the command uses temporary breakpoints, and
  5249. hence is quicker than @code{until} without an argument. The specified
  5250. location is actually reached only if it is in the current frame. This
  5251. implies that @code{until} can be used to skip over recursive function
  5252. invocations. For instance in the code below, if the current location is
  5253. line @code{96}, issuing @code{until 99} will execute the program up to
  5254. line @code{99} in the same invocation of factorial, i.e., after the inner
  5255. invocations have returned.
  5256. @smallexample
  5257. 94 int factorial (int value)
  5258. 95 @{
  5259. 96 if (value > 1) @{
  5260. 97 value *= factorial (value - 1);
  5261. 98 @}
  5262. 99 return (value);
  5263. 100 @}
  5264. @end smallexample
  5265. @kindex advance @var{location}
  5266. @item advance @var{location}
  5267. Continue running the program up to the given @var{location}. An argument is
  5268. required, which should be of one of the forms described in
  5269. @ref{Specify Location}.
  5270. Execution will also stop upon exit from the current stack
  5271. frame. This command is similar to @code{until}, but @code{advance} will
  5272. not skip over recursive function calls, and the target location doesn't
  5273. have to be in the same frame as the current one.
  5274. @kindex stepi
  5275. @kindex si @r{(@code{stepi})}
  5276. @item stepi
  5277. @itemx stepi @var{arg}
  5278. @itemx si
  5279. Execute one machine instruction, then stop and return to the debugger.
  5280. It is often useful to do @samp{display/i $pc} when stepping by machine
  5281. instructions. This makes @value{GDBN} automatically display the next
  5282. instruction to be executed, each time your program stops. @xref{Auto
  5283. Display,, Automatic Display}.
  5284. An argument is a repeat count, as in @code{step}.
  5285. @need 750
  5286. @kindex nexti
  5287. @kindex ni @r{(@code{nexti})}
  5288. @item nexti
  5289. @itemx nexti @var{arg}
  5290. @itemx ni
  5291. Execute one machine instruction, but if it is a function call,
  5292. proceed until the function returns.
  5293. An argument is a repeat count, as in @code{next}.
  5294. @end table
  5295. @anchor{range stepping}
  5296. @cindex range stepping
  5297. @cindex target-assisted range stepping
  5298. By default, and if available, @value{GDBN} makes use of
  5299. target-assisted @dfn{range stepping}. In other words, whenever you
  5300. use a stepping command (e.g., @code{step}, @code{next}), @value{GDBN}
  5301. tells the target to step the corresponding range of instruction
  5302. addresses instead of issuing multiple single-steps. This speeds up
  5303. line stepping, particularly for remote targets. Ideally, there should
  5304. be no reason you would want to turn range stepping off. However, it's
  5305. possible that a bug in the debug info, a bug in the remote stub (for
  5306. remote targets), or even a bug in @value{GDBN} could make line
  5307. stepping behave incorrectly when target-assisted range stepping is
  5308. enabled. You can use the following command to turn off range stepping
  5309. if necessary:
  5310. @table @code
  5311. @kindex set range-stepping
  5312. @kindex show range-stepping
  5313. @item set range-stepping
  5314. @itemx show range-stepping
  5315. Control whether range stepping is enabled.
  5316. If @code{on}, and the target supports it, @value{GDBN} tells the
  5317. target to step a range of addresses itself, instead of issuing
  5318. multiple single-steps. If @code{off}, @value{GDBN} always issues
  5319. single-steps, even if range stepping is supported by the target. The
  5320. default is @code{on}.
  5321. @end table
  5322. @node Skipping Over Functions and Files
  5323. @section Skipping Over Functions and Files
  5324. @cindex skipping over functions and files
  5325. The program you are debugging may contain some functions which are
  5326. uninteresting to debug. The @code{skip} command lets you tell @value{GDBN} to
  5327. skip a function, all functions in a file or a particular function in
  5328. a particular file when stepping.
  5329. For example, consider the following C function:
  5330. @smallexample
  5331. 101 int func()
  5332. 102 @{
  5333. 103 foo(boring());
  5334. 104 bar(boring());
  5335. 105 @}
  5336. @end smallexample
  5337. @noindent
  5338. Suppose you wish to step into the functions @code{foo} and @code{bar}, but you
  5339. are not interested in stepping through @code{boring}. If you run @code{step}
  5340. at line 103, you'll enter @code{boring()}, but if you run @code{next}, you'll
  5341. step over both @code{foo} and @code{boring}!
  5342. One solution is to @code{step} into @code{boring} and use the @code{finish}
  5343. command to immediately exit it. But this can become tedious if @code{boring}
  5344. is called from many places.
  5345. A more flexible solution is to execute @kbd{skip boring}. This instructs
  5346. @value{GDBN} never to step into @code{boring}. Now when you execute
  5347. @code{step} at line 103, you'll step over @code{boring} and directly into
  5348. @code{foo}.
  5349. Functions may be skipped by providing either a function name, linespec
  5350. (@pxref{Specify Location}), regular expression that matches the function's
  5351. name, file name or a @code{glob}-style pattern that matches the file name.
  5352. On Posix systems the form of the regular expression is
  5353. ``Extended Regular Expressions''. See for example @samp{man 7 regex}
  5354. on @sc{gnu}/Linux systems. On non-Posix systems the form of the regular
  5355. expression is whatever is provided by the @code{regcomp} function of
  5356. the underlying system.
  5357. See for example @samp{man 7 glob} on @sc{gnu}/Linux systems for a
  5358. description of @code{glob}-style patterns.
  5359. @table @code
  5360. @kindex skip
  5361. @item skip @r{[}@var{options}@r{]}
  5362. The basic form of the @code{skip} command takes zero or more options
  5363. that specify what to skip.
  5364. The @var{options} argument is any useful combination of the following:
  5365. @table @code
  5366. @item -file @var{file}
  5367. @itemx -fi @var{file}
  5368. Functions in @var{file} will be skipped over when stepping.
  5369. @item -gfile @var{file-glob-pattern}
  5370. @itemx -gfi @var{file-glob-pattern}
  5371. @cindex skipping over files via glob-style patterns
  5372. Functions in files matching @var{file-glob-pattern} will be skipped
  5373. over when stepping.
  5374. @smallexample
  5375. (gdb) skip -gfi utils/*.c
  5376. @end smallexample
  5377. @item -function @var{linespec}
  5378. @itemx -fu @var{linespec}
  5379. Functions named by @var{linespec} or the function containing the line
  5380. named by @var{linespec} will be skipped over when stepping.
  5381. @xref{Specify Location}.
  5382. @item -rfunction @var{regexp}
  5383. @itemx -rfu @var{regexp}
  5384. @cindex skipping over functions via regular expressions
  5385. Functions whose name matches @var{regexp} will be skipped over when stepping.
  5386. This form is useful for complex function names.
  5387. For example, there is generally no need to step into C@t{++} @code{std::string}
  5388. constructors or destructors. Plus with C@t{++} templates it can be hard to
  5389. write out the full name of the function, and often it doesn't matter what
  5390. the template arguments are. Specifying the function to be skipped as a
  5391. regular expression makes this easier.
  5392. @smallexample
  5393. (gdb) skip -rfu ^std::(allocator|basic_string)<.*>::~?\1 *\(
  5394. @end smallexample
  5395. If you want to skip every templated C@t{++} constructor and destructor
  5396. in the @code{std} namespace you can do:
  5397. @smallexample
  5398. (gdb) skip -rfu ^std::([a-zA-z0-9_]+)<.*>::~?\1 *\(
  5399. @end smallexample
  5400. @end table
  5401. If no options are specified, the function you're currently debugging
  5402. will be skipped.
  5403. @kindex skip function
  5404. @item skip function @r{[}@var{linespec}@r{]}
  5405. After running this command, the function named by @var{linespec} or the
  5406. function containing the line named by @var{linespec} will be skipped over when
  5407. stepping. @xref{Specify Location}.
  5408. If you do not specify @var{linespec}, the function you're currently debugging
  5409. will be skipped.
  5410. (If you have a function called @code{file} that you want to skip, use
  5411. @kbd{skip function file}.)
  5412. @kindex skip file
  5413. @item skip file @r{[}@var{filename}@r{]}
  5414. After running this command, any function whose source lives in @var{filename}
  5415. will be skipped over when stepping.
  5416. @smallexample
  5417. (gdb) skip file boring.c
  5418. File boring.c will be skipped when stepping.
  5419. @end smallexample
  5420. If you do not specify @var{filename}, functions whose source lives in the file
  5421. you're currently debugging will be skipped.
  5422. @end table
  5423. Skips can be listed, deleted, disabled, and enabled, much like breakpoints.
  5424. These are the commands for managing your list of skips:
  5425. @table @code
  5426. @kindex info skip
  5427. @item info skip @r{[}@var{range}@r{]}
  5428. Print details about the specified skip(s). If @var{range} is not specified,
  5429. print a table with details about all functions and files marked for skipping.
  5430. @code{info skip} prints the following information about each skip:
  5431. @table @emph
  5432. @item Identifier
  5433. A number identifying this skip.
  5434. @item Enabled or Disabled
  5435. Enabled skips are marked with @samp{y}.
  5436. Disabled skips are marked with @samp{n}.
  5437. @item Glob
  5438. If the file name is a @samp{glob} pattern this is @samp{y}.
  5439. Otherwise it is @samp{n}.
  5440. @item File
  5441. The name or @samp{glob} pattern of the file to be skipped.
  5442. If no file is specified this is @samp{<none>}.
  5443. @item RE
  5444. If the function name is a @samp{regular expression} this is @samp{y}.
  5445. Otherwise it is @samp{n}.
  5446. @item Function
  5447. The name or regular expression of the function to skip.
  5448. If no function is specified this is @samp{<none>}.
  5449. @end table
  5450. @kindex skip delete
  5451. @item skip delete @r{[}@var{range}@r{]}
  5452. Delete the specified skip(s). If @var{range} is not specified, delete all
  5453. skips.
  5454. @kindex skip enable
  5455. @item skip enable @r{[}@var{range}@r{]}
  5456. Enable the specified skip(s). If @var{range} is not specified, enable all
  5457. skips.
  5458. @kindex skip disable
  5459. @item skip disable @r{[}@var{range}@r{]}
  5460. Disable the specified skip(s). If @var{range} is not specified, disable all
  5461. skips.
  5462. @kindex set debug skip
  5463. @item set debug skip @r{[}on|off@r{]}
  5464. Set whether to print the debug output about skipping files and functions.
  5465. @kindex show debug skip
  5466. @item show debug skip
  5467. Show whether the debug output about skipping files and functions is printed.
  5468. @end table
  5469. @node Signals
  5470. @section Signals
  5471. @cindex signals
  5472. A signal is an asynchronous event that can happen in a program. The
  5473. operating system defines the possible kinds of signals, and gives each
  5474. kind a name and a number. For example, in Unix @code{SIGINT} is the
  5475. signal a program gets when you type an interrupt character (often @kbd{Ctrl-c});
  5476. @code{SIGSEGV} is the signal a program gets from referencing a place in
  5477. memory far away from all the areas in use; @code{SIGALRM} occurs when
  5478. the alarm clock timer goes off (which happens only if your program has
  5479. requested an alarm).
  5480. @cindex fatal signals
  5481. Some signals, including @code{SIGALRM}, are a normal part of the
  5482. functioning of your program. Others, such as @code{SIGSEGV}, indicate
  5483. errors; these signals are @dfn{fatal} (they kill your program immediately) if the
  5484. program has not specified in advance some other way to handle the signal.
  5485. @code{SIGINT} does not indicate an error in your program, but it is normally
  5486. fatal so it can carry out the purpose of the interrupt: to kill the program.
  5487. @value{GDBN} has the ability to detect any occurrence of a signal in your
  5488. program. You can tell @value{GDBN} in advance what to do for each kind of
  5489. signal.
  5490. @cindex handling signals
  5491. Normally, @value{GDBN} is set up to let the non-erroneous signals like
  5492. @code{SIGALRM} be silently passed to your program
  5493. (so as not to interfere with their role in the program's functioning)
  5494. but to stop your program immediately whenever an error signal happens.
  5495. You can change these settings with the @code{handle} command.
  5496. @table @code
  5497. @kindex info signals
  5498. @kindex info handle
  5499. @item info signals
  5500. @itemx info handle
  5501. Print a table of all the kinds of signals and how @value{GDBN} has been told to
  5502. handle each one. You can use this to see the signal numbers of all
  5503. the defined types of signals.
  5504. @item info signals @var{sig}
  5505. Similar, but print information only about the specified signal number.
  5506. @code{info handle} is an alias for @code{info signals}.
  5507. @item catch signal @r{[}@var{signal}@dots{} @r{|} @samp{all}@r{]}
  5508. Set a catchpoint for the indicated signals. @xref{Set Catchpoints},
  5509. for details about this command.
  5510. @kindex handle
  5511. @item handle @var{signal} @r{[}@var{keywords}@dots{}@r{]}
  5512. Change the way @value{GDBN} handles signal @var{signal}. The @var{signal}
  5513. can be the number of a signal or its name (with or without the
  5514. @samp{SIG} at the beginning); a list of signal numbers of the form
  5515. @samp{@var{low}-@var{high}}; or the word @samp{all}, meaning all the
  5516. known signals. Optional arguments @var{keywords}, described below,
  5517. say what change to make.
  5518. @end table
  5519. @c @group
  5520. The keywords allowed by the @code{handle} command can be abbreviated.
  5521. Their full names are:
  5522. @table @code
  5523. @item nostop
  5524. @value{GDBN} should not stop your program when this signal happens. It may
  5525. still print a message telling you that the signal has come in.
  5526. @item stop
  5527. @value{GDBN} should stop your program when this signal happens. This implies
  5528. the @code{print} keyword as well.
  5529. @item print
  5530. @value{GDBN} should print a message when this signal happens.
  5531. @item noprint
  5532. @value{GDBN} should not mention the occurrence of the signal at all. This
  5533. implies the @code{nostop} keyword as well.
  5534. @item pass
  5535. @itemx noignore
  5536. @value{GDBN} should allow your program to see this signal; your program
  5537. can handle the signal, or else it may terminate if the signal is fatal
  5538. and not handled. @code{pass} and @code{noignore} are synonyms.
  5539. @item nopass
  5540. @itemx ignore
  5541. @value{GDBN} should not allow your program to see this signal.
  5542. @code{nopass} and @code{ignore} are synonyms.
  5543. @end table
  5544. @c @end group
  5545. When a signal stops your program, the signal is not visible to the
  5546. program until you
  5547. continue. Your program sees the signal then, if @code{pass} is in
  5548. effect for the signal in question @emph{at that time}. In other words,
  5549. after @value{GDBN} reports a signal, you can use the @code{handle}
  5550. command with @code{pass} or @code{nopass} to control whether your
  5551. program sees that signal when you continue.
  5552. The default is set to @code{nostop}, @code{noprint}, @code{pass} for
  5553. non-erroneous signals such as @code{SIGALRM}, @code{SIGWINCH} and
  5554. @code{SIGCHLD}, and to @code{stop}, @code{print}, @code{pass} for the
  5555. erroneous signals.
  5556. You can also use the @code{signal} command to prevent your program from
  5557. seeing a signal, or cause it to see a signal it normally would not see,
  5558. or to give it any signal at any time. For example, if your program stopped
  5559. due to some sort of memory reference error, you might store correct
  5560. values into the erroneous variables and continue, hoping to see more
  5561. execution; but your program would probably terminate immediately as
  5562. a result of the fatal signal once it saw the signal. To prevent this,
  5563. you can continue with @samp{signal 0}. @xref{Signaling, ,Giving your
  5564. Program a Signal}.
  5565. @cindex stepping and signal handlers
  5566. @anchor{stepping and signal handlers}
  5567. @value{GDBN} optimizes for stepping the mainline code. If a signal
  5568. that has @code{handle nostop} and @code{handle pass} set arrives while
  5569. a stepping command (e.g., @code{stepi}, @code{step}, @code{next}) is
  5570. in progress, @value{GDBN} lets the signal handler run and then resumes
  5571. stepping the mainline code once the signal handler returns. In other
  5572. words, @value{GDBN} steps over the signal handler. This prevents
  5573. signals that you've specified as not interesting (with @code{handle
  5574. nostop}) from changing the focus of debugging unexpectedly. Note that
  5575. the signal handler itself may still hit a breakpoint, stop for another
  5576. signal that has @code{handle stop} in effect, or for any other event
  5577. that normally results in stopping the stepping command sooner. Also
  5578. note that @value{GDBN} still informs you that the program received a
  5579. signal if @code{handle print} is set.
  5580. @anchor{stepping into signal handlers}
  5581. If you set @code{handle pass} for a signal, and your program sets up a
  5582. handler for it, then issuing a stepping command, such as @code{step}
  5583. or @code{stepi}, when your program is stopped due to the signal will
  5584. step @emph{into} the signal handler (if the target supports that).
  5585. Likewise, if you use the @code{queue-signal} command to queue a signal
  5586. to be delivered to the current thread when execution of the thread
  5587. resumes (@pxref{Signaling, ,Giving your Program a Signal}), then a
  5588. stepping command will step into the signal handler.
  5589. Here's an example, using @code{stepi} to step to the first instruction
  5590. of @code{SIGUSR1}'s handler:
  5591. @smallexample
  5592. (@value{GDBP}) handle SIGUSR1
  5593. Signal Stop Print Pass to program Description
  5594. SIGUSR1 Yes Yes Yes User defined signal 1
  5595. (@value{GDBP}) c
  5596. Continuing.
  5597. Program received signal SIGUSR1, User defined signal 1.
  5598. main () sigusr1.c:28
  5599. 28 p = 0;
  5600. (@value{GDBP}) si
  5601. sigusr1_handler () at sigusr1.c:9
  5602. 9 @{
  5603. @end smallexample
  5604. The same, but using @code{queue-signal} instead of waiting for the
  5605. program to receive the signal first:
  5606. @smallexample
  5607. (@value{GDBP}) n
  5608. 28 p = 0;
  5609. (@value{GDBP}) queue-signal SIGUSR1
  5610. (@value{GDBP}) si
  5611. sigusr1_handler () at sigusr1.c:9
  5612. 9 @{
  5613. (@value{GDBP})
  5614. @end smallexample
  5615. @cindex extra signal information
  5616. @anchor{extra signal information}
  5617. On some targets, @value{GDBN} can inspect extra signal information
  5618. associated with the intercepted signal, before it is actually
  5619. delivered to the program being debugged. This information is exported
  5620. by the convenience variable @code{$_siginfo}, and consists of data
  5621. that is passed by the kernel to the signal handler at the time of the
  5622. receipt of a signal. The data type of the information itself is
  5623. target dependent. You can see the data type using the @code{ptype
  5624. $_siginfo} command. On Unix systems, it typically corresponds to the
  5625. standard @code{siginfo_t} type, as defined in the @file{signal.h}
  5626. system header.
  5627. Here's an example, on a @sc{gnu}/Linux system, printing the stray
  5628. referenced address that raised a segmentation fault.
  5629. @smallexample
  5630. @group
  5631. (@value{GDBP}) continue
  5632. Program received signal SIGSEGV, Segmentation fault.
  5633. 0x0000000000400766 in main ()
  5634. 69 *(int *)p = 0;
  5635. (@value{GDBP}) ptype $_siginfo
  5636. type = struct @{
  5637. int si_signo;
  5638. int si_errno;
  5639. int si_code;
  5640. union @{
  5641. int _pad[28];
  5642. struct @{...@} _kill;
  5643. struct @{...@} _timer;
  5644. struct @{...@} _rt;
  5645. struct @{...@} _sigchld;
  5646. struct @{...@} _sigfault;
  5647. struct @{...@} _sigpoll;
  5648. @} _sifields;
  5649. @}
  5650. (@value{GDBP}) ptype $_siginfo._sifields._sigfault
  5651. type = struct @{
  5652. void *si_addr;
  5653. @}
  5654. (@value{GDBP}) p $_siginfo._sifields._sigfault.si_addr
  5655. $1 = (void *) 0x7ffff7ff7000
  5656. @end group
  5657. @end smallexample
  5658. Depending on target support, @code{$_siginfo} may also be writable.
  5659. @cindex Intel MPX boundary violations
  5660. @cindex boundary violations, Intel MPX
  5661. On some targets, a @code{SIGSEGV} can be caused by a boundary
  5662. violation, i.e., accessing an address outside of the allowed range.
  5663. In those cases @value{GDBN} may displays additional information,
  5664. depending on how @value{GDBN} has been told to handle the signal.
  5665. With @code{handle stop SIGSEGV}, @value{GDBN} displays the violation
  5666. kind: "Upper" or "Lower", the memory address accessed and the
  5667. bounds, while with @code{handle nostop SIGSEGV} no additional
  5668. information is displayed.
  5669. The usual output of a segfault is:
  5670. @smallexample
  5671. Program received signal SIGSEGV, Segmentation fault
  5672. 0x0000000000400d7c in upper () at i386-mpx-sigsegv.c:68
  5673. 68 value = *(p + len);
  5674. @end smallexample
  5675. While a bound violation is presented as:
  5676. @smallexample
  5677. Program received signal SIGSEGV, Segmentation fault
  5678. Upper bound violation while accessing address 0x7fffffffc3b3
  5679. Bounds: [lower = 0x7fffffffc390, upper = 0x7fffffffc3a3]
  5680. 0x0000000000400d7c in upper () at i386-mpx-sigsegv.c:68
  5681. 68 value = *(p + len);
  5682. @end smallexample
  5683. @node Thread Stops
  5684. @section Stopping and Starting Multi-thread Programs
  5685. @cindex stopped threads
  5686. @cindex threads, stopped
  5687. @cindex continuing threads
  5688. @cindex threads, continuing
  5689. @value{GDBN} supports debugging programs with multiple threads
  5690. (@pxref{Threads,, Debugging Programs with Multiple Threads}). There
  5691. are two modes of controlling execution of your program within the
  5692. debugger. In the default mode, referred to as @dfn{all-stop mode},
  5693. when any thread in your program stops (for example, at a breakpoint
  5694. or while being stepped), all other threads in the program are also stopped by
  5695. @value{GDBN}. On some targets, @value{GDBN} also supports
  5696. @dfn{non-stop mode}, in which other threads can continue to run freely while
  5697. you examine the stopped thread in the debugger.
  5698. @menu
  5699. * All-Stop Mode:: All threads stop when GDB takes control
  5700. * Non-Stop Mode:: Other threads continue to execute
  5701. * Background Execution:: Running your program asynchronously
  5702. * Thread-Specific Breakpoints:: Controlling breakpoints
  5703. * Interrupted System Calls:: GDB may interfere with system calls
  5704. * Observer Mode:: GDB does not alter program behavior
  5705. @end menu
  5706. @node All-Stop Mode
  5707. @subsection All-Stop Mode
  5708. @cindex all-stop mode
  5709. In all-stop mode, whenever your program stops under @value{GDBN} for any reason,
  5710. @emph{all} threads of execution stop, not just the current thread. This
  5711. allows you to examine the overall state of the program, including
  5712. switching between threads, without worrying that things may change
  5713. underfoot.
  5714. Conversely, whenever you restart the program, @emph{all} threads start
  5715. executing. @emph{This is true even when single-stepping} with commands
  5716. like @code{step} or @code{next}.
  5717. In particular, @value{GDBN} cannot single-step all threads in lockstep.
  5718. Since thread scheduling is up to your debugging target's operating
  5719. system (not controlled by @value{GDBN}), other threads may
  5720. execute more than one statement while the current thread completes a
  5721. single step. Moreover, in general other threads stop in the middle of a
  5722. statement, rather than at a clean statement boundary, when the program
  5723. stops.
  5724. You might even find your program stopped in another thread after
  5725. continuing or even single-stepping. This happens whenever some other
  5726. thread runs into a breakpoint, a signal, or an exception before the
  5727. first thread completes whatever you requested.
  5728. @cindex automatic thread selection
  5729. @cindex switching threads automatically
  5730. @cindex threads, automatic switching
  5731. Whenever @value{GDBN} stops your program, due to a breakpoint or a
  5732. signal, it automatically selects the thread where that breakpoint or
  5733. signal happened. @value{GDBN} alerts you to the context switch with a
  5734. message such as @samp{[Switching to Thread @var{n}]} to identify the
  5735. thread.
  5736. On some OSes, you can modify @value{GDBN}'s default behavior by
  5737. locking the OS scheduler to allow only a single thread to run.
  5738. @table @code
  5739. @item set scheduler-locking @var{mode}
  5740. @cindex scheduler locking mode
  5741. @cindex lock scheduler
  5742. Set the scheduler locking mode. It applies to normal execution,
  5743. record mode, and replay mode. If it is @code{off}, then there is no
  5744. locking and any thread may run at any time. If @code{on}, then only
  5745. the current thread may run when the inferior is resumed. The
  5746. @code{step} mode optimizes for single-stepping; it prevents other
  5747. threads from preempting the current thread while you are stepping, so
  5748. that the focus of debugging does not change unexpectedly. Other
  5749. threads never get a chance to run when you step, and they are
  5750. completely free to run when you use commands like @samp{continue},
  5751. @samp{until}, or @samp{finish}. However, unless another thread hits a
  5752. breakpoint during its timeslice, @value{GDBN} does not change the
  5753. current thread away from the thread that you are debugging. The
  5754. @code{replay} mode behaves like @code{off} in record mode and like
  5755. @code{on} in replay mode.
  5756. @item show scheduler-locking
  5757. Display the current scheduler locking mode.
  5758. @end table
  5759. @cindex resume threads of multiple processes simultaneously
  5760. By default, when you issue one of the execution commands such as
  5761. @code{continue}, @code{next} or @code{step}, @value{GDBN} allows only
  5762. threads of the current inferior to run. For example, if @value{GDBN}
  5763. is attached to two inferiors, each with two threads, the
  5764. @code{continue} command resumes only the two threads of the current
  5765. inferior. This is useful, for example, when you debug a program that
  5766. forks and you want to hold the parent stopped (so that, for instance,
  5767. it doesn't run to exit), while you debug the child. In other
  5768. situations, you may not be interested in inspecting the current state
  5769. of any of the processes @value{GDBN} is attached to, and you may want
  5770. to resume them all until some breakpoint is hit. In the latter case,
  5771. you can instruct @value{GDBN} to allow all threads of all the
  5772. inferiors to run with the @w{@code{set schedule-multiple}} command.
  5773. @table @code
  5774. @kindex set schedule-multiple
  5775. @item set schedule-multiple
  5776. Set the mode for allowing threads of multiple processes to be resumed
  5777. when an execution command is issued. When @code{on}, all threads of
  5778. all processes are allowed to run. When @code{off}, only the threads
  5779. of the current process are resumed. The default is @code{off}. The
  5780. @code{scheduler-locking} mode takes precedence when set to @code{on},
  5781. or while you are stepping and set to @code{step}.
  5782. @item show schedule-multiple
  5783. Display the current mode for resuming the execution of threads of
  5784. multiple processes.
  5785. @end table
  5786. @node Non-Stop Mode
  5787. @subsection Non-Stop Mode
  5788. @cindex non-stop mode
  5789. @c This section is really only a place-holder, and needs to be expanded
  5790. @c with more details.
  5791. For some multi-threaded targets, @value{GDBN} supports an optional
  5792. mode of operation in which you can examine stopped program threads in
  5793. the debugger while other threads continue to execute freely. This
  5794. minimizes intrusion when debugging live systems, such as programs
  5795. where some threads have real-time constraints or must continue to
  5796. respond to external events. This is referred to as @dfn{non-stop} mode.
  5797. In non-stop mode, when a thread stops to report a debugging event,
  5798. @emph{only} that thread is stopped; @value{GDBN} does not stop other
  5799. threads as well, in contrast to the all-stop mode behavior. Additionally,
  5800. execution commands such as @code{continue} and @code{step} apply by default
  5801. only to the current thread in non-stop mode, rather than all threads as
  5802. in all-stop mode. This allows you to control threads explicitly in
  5803. ways that are not possible in all-stop mode --- for example, stepping
  5804. one thread while allowing others to run freely, stepping
  5805. one thread while holding all others stopped, or stepping several threads
  5806. independently and simultaneously.
  5807. To enter non-stop mode, use this sequence of commands before you run
  5808. or attach to your program:
  5809. @smallexample
  5810. # If using the CLI, pagination breaks non-stop.
  5811. set pagination off
  5812. # Finally, turn it on!
  5813. set non-stop on
  5814. @end smallexample
  5815. You can use these commands to manipulate the non-stop mode setting:
  5816. @table @code
  5817. @kindex set non-stop
  5818. @item set non-stop on
  5819. Enable selection of non-stop mode.
  5820. @item set non-stop off
  5821. Disable selection of non-stop mode.
  5822. @kindex show non-stop
  5823. @item show non-stop
  5824. Show the current non-stop enablement setting.
  5825. @end table
  5826. Note these commands only reflect whether non-stop mode is enabled,
  5827. not whether the currently-executing program is being run in non-stop mode.
  5828. In particular, the @code{set non-stop} preference is only consulted when
  5829. @value{GDBN} starts or connects to the target program, and it is generally
  5830. not possible to switch modes once debugging has started. Furthermore,
  5831. since not all targets support non-stop mode, even when you have enabled
  5832. non-stop mode, @value{GDBN} may still fall back to all-stop operation by
  5833. default.
  5834. In non-stop mode, all execution commands apply only to the current thread
  5835. by default. That is, @code{continue} only continues one thread.
  5836. To continue all threads, issue @code{continue -a} or @code{c -a}.
  5837. You can use @value{GDBN}'s background execution commands
  5838. (@pxref{Background Execution}) to run some threads in the background
  5839. while you continue to examine or step others from @value{GDBN}.
  5840. The MI execution commands (@pxref{GDB/MI Program Execution}) are
  5841. always executed asynchronously in non-stop mode.
  5842. Suspending execution is done with the @code{interrupt} command when
  5843. running in the background, or @kbd{Ctrl-c} during foreground execution.
  5844. In all-stop mode, this stops the whole process;
  5845. but in non-stop mode the interrupt applies only to the current thread.
  5846. To stop the whole program, use @code{interrupt -a}.
  5847. Other execution commands do not currently support the @code{-a} option.
  5848. In non-stop mode, when a thread stops, @value{GDBN} doesn't automatically make
  5849. that thread current, as it does in all-stop mode. This is because the
  5850. thread stop notifications are asynchronous with respect to @value{GDBN}'s
  5851. command interpreter, and it would be confusing if @value{GDBN} unexpectedly
  5852. changed to a different thread just as you entered a command to operate on the
  5853. previously current thread.
  5854. @node Background Execution
  5855. @subsection Background Execution
  5856. @cindex foreground execution
  5857. @cindex background execution
  5858. @cindex asynchronous execution
  5859. @cindex execution, foreground, background and asynchronous
  5860. @value{GDBN}'s execution commands have two variants: the normal
  5861. foreground (synchronous) behavior, and a background
  5862. (asynchronous) behavior. In foreground execution, @value{GDBN} waits for
  5863. the program to report that some thread has stopped before prompting for
  5864. another command. In background execution, @value{GDBN} immediately gives
  5865. a command prompt so that you can issue other commands while your program runs.
  5866. If the target doesn't support async mode, @value{GDBN} issues an error
  5867. message if you attempt to use the background execution commands.
  5868. @cindex @code{&}, background execution of commands
  5869. To specify background execution, add a @code{&} to the command. For example,
  5870. the background form of the @code{continue} command is @code{continue&}, or
  5871. just @code{c&}. The execution commands that accept background execution
  5872. are:
  5873. @table @code
  5874. @kindex run&
  5875. @item run
  5876. @xref{Starting, , Starting your Program}.
  5877. @item attach
  5878. @kindex attach&
  5879. @xref{Attach, , Debugging an Already-running Process}.
  5880. @item step
  5881. @kindex step&
  5882. @xref{Continuing and Stepping, step}.
  5883. @item stepi
  5884. @kindex stepi&
  5885. @xref{Continuing and Stepping, stepi}.
  5886. @item next
  5887. @kindex next&
  5888. @xref{Continuing and Stepping, next}.
  5889. @item nexti
  5890. @kindex nexti&
  5891. @xref{Continuing and Stepping, nexti}.
  5892. @item continue
  5893. @kindex continue&
  5894. @xref{Continuing and Stepping, continue}.
  5895. @item finish
  5896. @kindex finish&
  5897. @xref{Continuing and Stepping, finish}.
  5898. @item until
  5899. @kindex until&
  5900. @xref{Continuing and Stepping, until}.
  5901. @end table
  5902. Background execution is especially useful in conjunction with non-stop
  5903. mode for debugging programs with multiple threads; see @ref{Non-Stop Mode}.
  5904. However, you can also use these commands in the normal all-stop mode with
  5905. the restriction that you cannot issue another execution command until the
  5906. previous one finishes. Examples of commands that are valid in all-stop
  5907. mode while the program is running include @code{help} and @code{info break}.
  5908. You can interrupt your program while it is running in the background by
  5909. using the @code{interrupt} command.
  5910. @table @code
  5911. @kindex interrupt
  5912. @item interrupt
  5913. @itemx interrupt -a
  5914. Suspend execution of the running program. In all-stop mode,
  5915. @code{interrupt} stops the whole process, but in non-stop mode, it stops
  5916. only the current thread. To stop the whole program in non-stop mode,
  5917. use @code{interrupt -a}.
  5918. @end table
  5919. @node Thread-Specific Breakpoints
  5920. @subsection Thread-Specific Breakpoints
  5921. When your program has multiple threads (@pxref{Threads,, Debugging
  5922. Programs with Multiple Threads}), you can choose whether to set
  5923. breakpoints on all threads, or on a particular thread.
  5924. @table @code
  5925. @cindex breakpoints and threads
  5926. @cindex thread breakpoints
  5927. @kindex break @dots{} thread @var{thread-id}
  5928. @item break @var{location} thread @var{thread-id}
  5929. @itemx break @var{location} thread @var{thread-id} if @dots{}
  5930. @var{location} specifies source lines; there are several ways of
  5931. writing them (@pxref{Specify Location}), but the effect is always to
  5932. specify some source line.
  5933. Use the qualifier @samp{thread @var{thread-id}} with a breakpoint command
  5934. to specify that you only want @value{GDBN} to stop the program when a
  5935. particular thread reaches this breakpoint. The @var{thread-id} specifier
  5936. is one of the thread identifiers assigned by @value{GDBN}, shown
  5937. in the first column of the @samp{info threads} display.
  5938. If you do not specify @samp{thread @var{thread-id}} when you set a
  5939. breakpoint, the breakpoint applies to @emph{all} threads of your
  5940. program.
  5941. You can use the @code{thread} qualifier on conditional breakpoints as
  5942. well; in this case, place @samp{thread @var{thread-id}} before or
  5943. after the breakpoint condition, like this:
  5944. @smallexample
  5945. (@value{GDBP}) break frik.c:13 thread 28 if bartab > lim
  5946. @end smallexample
  5947. @end table
  5948. Thread-specific breakpoints are automatically deleted when
  5949. @value{GDBN} detects the corresponding thread is no longer in the
  5950. thread list. For example:
  5951. @smallexample
  5952. (@value{GDBP}) c
  5953. Thread-specific breakpoint 3 deleted - thread 28 no longer in the thread list.
  5954. @end smallexample
  5955. There are several ways for a thread to disappear, such as a regular
  5956. thread exit, but also when you detach from the process with the
  5957. @code{detach} command (@pxref{Attach, ,Debugging an Already-running
  5958. Process}), or if @value{GDBN} loses the remote connection
  5959. (@pxref{Remote Debugging}), etc. Note that with some targets,
  5960. @value{GDBN} is only able to detect a thread has exited when the user
  5961. explictly asks for the thread list with the @code{info threads}
  5962. command.
  5963. @node Interrupted System Calls
  5964. @subsection Interrupted System Calls
  5965. @cindex thread breakpoints and system calls
  5966. @cindex system calls and thread breakpoints
  5967. @cindex premature return from system calls
  5968. There is an unfortunate side effect when using @value{GDBN} to debug
  5969. multi-threaded programs. If one thread stops for a
  5970. breakpoint, or for some other reason, and another thread is blocked in a
  5971. system call, then the system call may return prematurely. This is a
  5972. consequence of the interaction between multiple threads and the signals
  5973. that @value{GDBN} uses to implement breakpoints and other events that
  5974. stop execution.
  5975. To handle this problem, your program should check the return value of
  5976. each system call and react appropriately. This is good programming
  5977. style anyways.
  5978. For example, do not write code like this:
  5979. @smallexample
  5980. sleep (10);
  5981. @end smallexample
  5982. The call to @code{sleep} will return early if a different thread stops
  5983. at a breakpoint or for some other reason.
  5984. Instead, write this:
  5985. @smallexample
  5986. int unslept = 10;
  5987. while (unslept > 0)
  5988. unslept = sleep (unslept);
  5989. @end smallexample
  5990. A system call is allowed to return early, so the system is still
  5991. conforming to its specification. But @value{GDBN} does cause your
  5992. multi-threaded program to behave differently than it would without
  5993. @value{GDBN}.
  5994. Also, @value{GDBN} uses internal breakpoints in the thread library to
  5995. monitor certain events such as thread creation and thread destruction.
  5996. When such an event happens, a system call in another thread may return
  5997. prematurely, even though your program does not appear to stop.
  5998. @node Observer Mode
  5999. @subsection Observer Mode
  6000. If you want to build on non-stop mode and observe program behavior
  6001. without any chance of disruption by @value{GDBN}, you can set
  6002. variables to disable all of the debugger's attempts to modify state,
  6003. whether by writing memory, inserting breakpoints, etc. These operate
  6004. at a low level, intercepting operations from all commands.
  6005. When all of these are set to @code{off}, then @value{GDBN} is said to
  6006. be @dfn{observer mode}. As a convenience, the variable
  6007. @code{observer} can be set to disable these, plus enable non-stop
  6008. mode.
  6009. Note that @value{GDBN} will not prevent you from making nonsensical
  6010. combinations of these settings. For instance, if you have enabled
  6011. @code{may-insert-breakpoints} but disabled @code{may-write-memory},
  6012. then breakpoints that work by writing trap instructions into the code
  6013. stream will still not be able to be placed.
  6014. @table @code
  6015. @kindex observer
  6016. @item set observer on
  6017. @itemx set observer off
  6018. When set to @code{on}, this disables all the permission variables
  6019. below (except for @code{insert-fast-tracepoints}), plus enables
  6020. non-stop debugging. Setting this to @code{off} switches back to
  6021. normal debugging, though remaining in non-stop mode.
  6022. @item show observer
  6023. Show whether observer mode is on or off.
  6024. @kindex may-write-registers
  6025. @item set may-write-registers on
  6026. @itemx set may-write-registers off
  6027. This controls whether @value{GDBN} will attempt to alter the values of
  6028. registers, such as with assignment expressions in @code{print}, or the
  6029. @code{jump} command. It defaults to @code{on}.
  6030. @item show may-write-registers
  6031. Show the current permission to write registers.
  6032. @kindex may-write-memory
  6033. @item set may-write-memory on
  6034. @itemx set may-write-memory off
  6035. This controls whether @value{GDBN} will attempt to alter the contents
  6036. of memory, such as with assignment expressions in @code{print}. It
  6037. defaults to @code{on}.
  6038. @item show may-write-memory
  6039. Show the current permission to write memory.
  6040. @kindex may-insert-breakpoints
  6041. @item set may-insert-breakpoints on
  6042. @itemx set may-insert-breakpoints off
  6043. This controls whether @value{GDBN} will attempt to insert breakpoints.
  6044. This affects all breakpoints, including internal breakpoints defined
  6045. by @value{GDBN}. It defaults to @code{on}.
  6046. @item show may-insert-breakpoints
  6047. Show the current permission to insert breakpoints.
  6048. @kindex may-insert-tracepoints
  6049. @item set may-insert-tracepoints on
  6050. @itemx set may-insert-tracepoints off
  6051. This controls whether @value{GDBN} will attempt to insert (regular)
  6052. tracepoints at the beginning of a tracing experiment. It affects only
  6053. non-fast tracepoints, fast tracepoints being under the control of
  6054. @code{may-insert-fast-tracepoints}. It defaults to @code{on}.
  6055. @item show may-insert-tracepoints
  6056. Show the current permission to insert tracepoints.
  6057. @kindex may-insert-fast-tracepoints
  6058. @item set may-insert-fast-tracepoints on
  6059. @itemx set may-insert-fast-tracepoints off
  6060. This controls whether @value{GDBN} will attempt to insert fast
  6061. tracepoints at the beginning of a tracing experiment. It affects only
  6062. fast tracepoints, regular (non-fast) tracepoints being under the
  6063. control of @code{may-insert-tracepoints}. It defaults to @code{on}.
  6064. @item show may-insert-fast-tracepoints
  6065. Show the current permission to insert fast tracepoints.
  6066. @kindex may-interrupt
  6067. @item set may-interrupt on
  6068. @itemx set may-interrupt off
  6069. This controls whether @value{GDBN} will attempt to interrupt or stop
  6070. program execution. When this variable is @code{off}, the
  6071. @code{interrupt} command will have no effect, nor will
  6072. @kbd{Ctrl-c}. It defaults to @code{on}.
  6073. @item show may-interrupt
  6074. Show the current permission to interrupt or stop the program.
  6075. @end table
  6076. @node Reverse Execution
  6077. @chapter Running programs backward
  6078. @cindex reverse execution
  6079. @cindex running programs backward
  6080. When you are debugging a program, it is not unusual to realize that
  6081. you have gone too far, and some event of interest has already happened.
  6082. If the target environment supports it, @value{GDBN} can allow you to
  6083. ``rewind'' the program by running it backward.
  6084. A target environment that supports reverse execution should be able
  6085. to ``undo'' the changes in machine state that have taken place as the
  6086. program was executing normally. Variables, registers etc.@: should
  6087. revert to their previous values. Obviously this requires a great
  6088. deal of sophistication on the part of the target environment; not
  6089. all target environments can support reverse execution.
  6090. When a program is executed in reverse, the instructions that
  6091. have most recently been executed are ``un-executed'', in reverse
  6092. order. The program counter runs backward, following the previous
  6093. thread of execution in reverse. As each instruction is ``un-executed'',
  6094. the values of memory and/or registers that were changed by that
  6095. instruction are reverted to their previous states. After executing
  6096. a piece of source code in reverse, all side effects of that code
  6097. should be ``undone'', and all variables should be returned to their
  6098. prior values@footnote{
  6099. Note that some side effects are easier to undo than others. For instance,
  6100. memory and registers are relatively easy, but device I/O is hard. Some
  6101. targets may be able undo things like device I/O, and some may not.
  6102. The contract between @value{GDBN} and the reverse executing target
  6103. requires only that the target do something reasonable when
  6104. @value{GDBN} tells it to execute backwards, and then report the
  6105. results back to @value{GDBN}. Whatever the target reports back to
  6106. @value{GDBN}, @value{GDBN} will report back to the user. @value{GDBN}
  6107. assumes that the memory and registers that the target reports are in a
  6108. consistent state, but @value{GDBN} accepts whatever it is given.
  6109. }.
  6110. On some platforms, @value{GDBN} has built-in support for reverse
  6111. execution, activated with the @code{record} or @code{record btrace}
  6112. commands. @xref{Process Record and Replay}. Some remote targets,
  6113. typically full system emulators, support reverse execution directly
  6114. without requiring any special command.
  6115. If you are debugging in a target environment that supports
  6116. reverse execution, @value{GDBN} provides the following commands.
  6117. @table @code
  6118. @kindex reverse-continue
  6119. @kindex rc @r{(@code{reverse-continue})}
  6120. @item reverse-continue @r{[}@var{ignore-count}@r{]}
  6121. @itemx rc @r{[}@var{ignore-count}@r{]}
  6122. Beginning at the point where your program last stopped, start executing
  6123. in reverse. Reverse execution will stop for breakpoints and synchronous
  6124. exceptions (signals), just like normal execution. Behavior of
  6125. asynchronous signals depends on the target environment.
  6126. @kindex reverse-step
  6127. @kindex rs @r{(@code{step})}
  6128. @item reverse-step @r{[}@var{count}@r{]}
  6129. Run the program backward until control reaches the start of a
  6130. different source line; then stop it, and return control to @value{GDBN}.
  6131. Like the @code{step} command, @code{reverse-step} will only stop
  6132. at the beginning of a source line. It ``un-executes'' the previously
  6133. executed source line. If the previous source line included calls to
  6134. debuggable functions, @code{reverse-step} will step (backward) into
  6135. the called function, stopping at the beginning of the @emph{last}
  6136. statement in the called function (typically a return statement).
  6137. Also, as with the @code{step} command, if non-debuggable functions are
  6138. called, @code{reverse-step} will run thru them backward without stopping.
  6139. @kindex reverse-stepi
  6140. @kindex rsi @r{(@code{reverse-stepi})}
  6141. @item reverse-stepi @r{[}@var{count}@r{]}
  6142. Reverse-execute one machine instruction. Note that the instruction
  6143. to be reverse-executed is @emph{not} the one pointed to by the program
  6144. counter, but the instruction executed prior to that one. For instance,
  6145. if the last instruction was a jump, @code{reverse-stepi} will take you
  6146. back from the destination of the jump to the jump instruction itself.
  6147. @kindex reverse-next
  6148. @kindex rn @r{(@code{reverse-next})}
  6149. @item reverse-next @r{[}@var{count}@r{]}
  6150. Run backward to the beginning of the previous line executed in
  6151. the current (innermost) stack frame. If the line contains function
  6152. calls, they will be ``un-executed'' without stopping. Starting from
  6153. the first line of a function, @code{reverse-next} will take you back
  6154. to the caller of that function, @emph{before} the function was called,
  6155. just as the normal @code{next} command would take you from the last
  6156. line of a function back to its return to its caller
  6157. @footnote{Unless the code is too heavily optimized.}.
  6158. @kindex reverse-nexti
  6159. @kindex rni @r{(@code{reverse-nexti})}
  6160. @item reverse-nexti @r{[}@var{count}@r{]}
  6161. Like @code{nexti}, @code{reverse-nexti} executes a single instruction
  6162. in reverse, except that called functions are ``un-executed'' atomically.
  6163. That is, if the previously executed instruction was a return from
  6164. another function, @code{reverse-nexti} will continue to execute
  6165. in reverse until the call to that function (from the current stack
  6166. frame) is reached.
  6167. @kindex reverse-finish
  6168. @item reverse-finish
  6169. Just as the @code{finish} command takes you to the point where the
  6170. current function returns, @code{reverse-finish} takes you to the point
  6171. where it was called. Instead of ending up at the end of the current
  6172. function invocation, you end up at the beginning.
  6173. @kindex set exec-direction
  6174. @item set exec-direction
  6175. Set the direction of target execution.
  6176. @item set exec-direction reverse
  6177. @cindex execute forward or backward in time
  6178. @value{GDBN} will perform all execution commands in reverse, until the
  6179. exec-direction mode is changed to ``forward''. Affected commands include
  6180. @code{step, stepi, next, nexti, continue, and finish}. The @code{return}
  6181. command cannot be used in reverse mode.
  6182. @item set exec-direction forward
  6183. @value{GDBN} will perform all execution commands in the normal fashion.
  6184. This is the default.
  6185. @end table
  6186. @node Process Record and Replay
  6187. @chapter Recording Inferior's Execution and Replaying It
  6188. @cindex process record and replay
  6189. @cindex recording inferior's execution and replaying it
  6190. On some platforms, @value{GDBN} provides a special @dfn{process record
  6191. and replay} target that can record a log of the process execution, and
  6192. replay it later with both forward and reverse execution commands.
  6193. @cindex replay mode
  6194. When this target is in use, if the execution log includes the record
  6195. for the next instruction, @value{GDBN} will debug in @dfn{replay
  6196. mode}. In the replay mode, the inferior does not really execute code
  6197. instructions. Instead, all the events that normally happen during
  6198. code execution are taken from the execution log. While code is not
  6199. really executed in replay mode, the values of registers (including the
  6200. program counter register) and the memory of the inferior are still
  6201. changed as they normally would. Their contents are taken from the
  6202. execution log.
  6203. @cindex record mode
  6204. If the record for the next instruction is not in the execution log,
  6205. @value{GDBN} will debug in @dfn{record mode}. In this mode, the
  6206. inferior executes normally, and @value{GDBN} records the execution log
  6207. for future replay.
  6208. The process record and replay target supports reverse execution
  6209. (@pxref{Reverse Execution}), even if the platform on which the
  6210. inferior runs does not. However, the reverse execution is limited in
  6211. this case by the range of the instructions recorded in the execution
  6212. log. In other words, reverse execution on platforms that don't
  6213. support it directly can only be done in the replay mode.
  6214. When debugging in the reverse direction, @value{GDBN} will work in
  6215. replay mode as long as the execution log includes the record for the
  6216. previous instruction; otherwise, it will work in record mode, if the
  6217. platform supports reverse execution, or stop if not.
  6218. Currently, process record and replay is supported on ARM, Aarch64,
  6219. Moxie, PowerPC, PowerPC64, S/390, and x86 (i386/amd64) running
  6220. GNU/Linux. Process record and replay can be used both when native
  6221. debugging, and when remote debugging via @code{gdbserver}.
  6222. For architecture environments that support process record and replay,
  6223. @value{GDBN} provides the following commands:
  6224. @table @code
  6225. @kindex target record
  6226. @kindex target record-full
  6227. @kindex target record-btrace
  6228. @kindex record
  6229. @kindex record full
  6230. @kindex record btrace
  6231. @kindex record btrace bts
  6232. @kindex record btrace pt
  6233. @kindex record bts
  6234. @kindex record pt
  6235. @kindex rec
  6236. @kindex rec full
  6237. @kindex rec btrace
  6238. @kindex rec btrace bts
  6239. @kindex rec btrace pt
  6240. @kindex rec bts
  6241. @kindex rec pt
  6242. @item record @var{method}
  6243. This command starts the process record and replay target. The
  6244. recording method can be specified as parameter. Without a parameter
  6245. the command uses the @code{full} recording method. The following
  6246. recording methods are available:
  6247. @table @code
  6248. @item full
  6249. Full record/replay recording using @value{GDBN}'s software record and
  6250. replay implementation. This method allows replaying and reverse
  6251. execution.
  6252. @item btrace @var{format}
  6253. Hardware-supported instruction recording, supported on Intel
  6254. processors. This method does not record data. Further, the data is
  6255. collected in a ring buffer so old data will be overwritten when the
  6256. buffer is full. It allows limited reverse execution. Variables and
  6257. registers are not available during reverse execution. In remote
  6258. debugging, recording continues on disconnect. Recorded data can be
  6259. inspected after reconnecting. The recording may be stopped using
  6260. @code{record stop}.
  6261. The recording format can be specified as parameter. Without a parameter
  6262. the command chooses the recording format. The following recording
  6263. formats are available:
  6264. @table @code
  6265. @item bts
  6266. @cindex branch trace store
  6267. Use the @dfn{Branch Trace Store} (@acronym{BTS}) recording format. In
  6268. this format, the processor stores a from/to record for each executed
  6269. branch in the btrace ring buffer.
  6270. @item pt
  6271. @cindex Intel Processor Trace
  6272. Use the @dfn{Intel Processor Trace} recording format. In this
  6273. format, the processor stores the execution trace in a compressed form
  6274. that is afterwards decoded by @value{GDBN}.
  6275. The trace can be recorded with very low overhead. The compressed
  6276. trace format also allows small trace buffers to already contain a big
  6277. number of instructions compared to @acronym{BTS}.
  6278. Decoding the recorded execution trace, on the other hand, is more
  6279. expensive than decoding @acronym{BTS} trace. This is mostly due to the
  6280. increased number of instructions to process. You should increase the
  6281. buffer-size with care.
  6282. @end table
  6283. Not all recording formats may be available on all processors.
  6284. @end table
  6285. The process record and replay target can only debug a process that is
  6286. already running. Therefore, you need first to start the process with
  6287. the @kbd{run} or @kbd{start} commands, and then start the recording
  6288. with the @kbd{record @var{method}} command.
  6289. @cindex displaced stepping, and process record and replay
  6290. Displaced stepping (@pxref{Maintenance Commands,, displaced stepping})
  6291. will be automatically disabled when process record and replay target
  6292. is started. That's because the process record and replay target
  6293. doesn't support displaced stepping.
  6294. @cindex non-stop mode, and process record and replay
  6295. @cindex asynchronous execution, and process record and replay
  6296. If the inferior is in the non-stop mode (@pxref{Non-Stop Mode}) or in
  6297. the asynchronous execution mode (@pxref{Background Execution}), not
  6298. all recording methods are available. The @code{full} recording method
  6299. does not support these two modes.
  6300. @kindex record stop
  6301. @kindex rec s
  6302. @item record stop
  6303. Stop the process record and replay target. When process record and
  6304. replay target stops, the entire execution log will be deleted and the
  6305. inferior will either be terminated, or will remain in its final state.
  6306. When you stop the process record and replay target in record mode (at
  6307. the end of the execution log), the inferior will be stopped at the
  6308. next instruction that would have been recorded. In other words, if
  6309. you record for a while and then stop recording, the inferior process
  6310. will be left in the same state as if the recording never happened.
  6311. On the other hand, if the process record and replay target is stopped
  6312. while in replay mode (that is, not at the end of the execution log,
  6313. but at some earlier point), the inferior process will become ``live''
  6314. at that earlier state, and it will then be possible to continue the
  6315. usual ``live'' debugging of the process from that state.
  6316. When the inferior process exits, or @value{GDBN} detaches from it,
  6317. process record and replay target will automatically stop itself.
  6318. @kindex record goto
  6319. @item record goto
  6320. Go to a specific location in the execution log. There are several
  6321. ways to specify the location to go to:
  6322. @table @code
  6323. @item record goto begin
  6324. @itemx record goto start
  6325. Go to the beginning of the execution log.
  6326. @item record goto end
  6327. Go to the end of the execution log.
  6328. @item record goto @var{n}
  6329. Go to instruction number @var{n} in the execution log.
  6330. @end table
  6331. @kindex record save
  6332. @item record save @var{filename}
  6333. Save the execution log to a file @file{@var{filename}}.
  6334. Default filename is @file{gdb_record.@var{process_id}}, where
  6335. @var{process_id} is the process ID of the inferior.
  6336. This command may not be available for all recording methods.
  6337. @kindex record restore
  6338. @item record restore @var{filename}
  6339. Restore the execution log from a file @file{@var{filename}}.
  6340. File must have been created with @code{record save}.
  6341. @kindex set record full
  6342. @item set record full insn-number-max @var{limit}
  6343. @itemx set record full insn-number-max unlimited
  6344. Set the limit of instructions to be recorded for the @code{full}
  6345. recording method. Default value is 200000.
  6346. If @var{limit} is a positive number, then @value{GDBN} will start
  6347. deleting instructions from the log once the number of the record
  6348. instructions becomes greater than @var{limit}. For every new recorded
  6349. instruction, @value{GDBN} will delete the earliest recorded
  6350. instruction to keep the number of recorded instructions at the limit.
  6351. (Since deleting recorded instructions loses information, @value{GDBN}
  6352. lets you control what happens when the limit is reached, by means of
  6353. the @code{stop-at-limit} option, described below.)
  6354. If @var{limit} is @code{unlimited} or zero, @value{GDBN} will never
  6355. delete recorded instructions from the execution log. The number of
  6356. recorded instructions is limited only by the available memory.
  6357. @kindex show record full
  6358. @item show record full insn-number-max
  6359. Show the limit of instructions to be recorded with the @code{full}
  6360. recording method.
  6361. @item set record full stop-at-limit
  6362. Control the behavior of the @code{full} recording method when the
  6363. number of recorded instructions reaches the limit. If ON (the
  6364. default), @value{GDBN} will stop when the limit is reached for the
  6365. first time and ask you whether you want to stop the inferior or
  6366. continue running it and recording the execution log. If you decide
  6367. to continue recording, each new recorded instruction will cause the
  6368. oldest one to be deleted.
  6369. If this option is OFF, @value{GDBN} will automatically delete the
  6370. oldest record to make room for each new one, without asking.
  6371. @item show record full stop-at-limit
  6372. Show the current setting of @code{stop-at-limit}.
  6373. @item set record full memory-query
  6374. Control the behavior when @value{GDBN} is unable to record memory
  6375. changes caused by an instruction for the @code{full} recording method.
  6376. If ON, @value{GDBN} will query whether to stop the inferior in that
  6377. case.
  6378. If this option is OFF (the default), @value{GDBN} will automatically
  6379. ignore the effect of such instructions on memory. Later, when
  6380. @value{GDBN} replays this execution log, it will mark the log of this
  6381. instruction as not accessible, and it will not affect the replay
  6382. results.
  6383. @item show record full memory-query
  6384. Show the current setting of @code{memory-query}.
  6385. @kindex set record btrace
  6386. The @code{btrace} record target does not trace data. As a
  6387. convenience, when replaying, @value{GDBN} reads read-only memory off
  6388. the live program directly, assuming that the addresses of the
  6389. read-only areas don't change. This for example makes it possible to
  6390. disassemble code while replaying, but not to print variables.
  6391. In some cases, being able to inspect variables might be useful.
  6392. You can use the following command for that:
  6393. @item set record btrace replay-memory-access
  6394. Control the behavior of the @code{btrace} recording method when
  6395. accessing memory during replay. If @code{read-only} (the default),
  6396. @value{GDBN} will only allow accesses to read-only memory.
  6397. If @code{read-write}, @value{GDBN} will allow accesses to read-only
  6398. and to read-write memory. Beware that the accessed memory corresponds
  6399. to the live target and not necessarily to the current replay
  6400. position.
  6401. @item set record btrace cpu @var{identifier}
  6402. Set the processor to be used for enabling workarounds for processor
  6403. errata when decoding the trace.
  6404. Processor errata are defects in processor operation, caused by its
  6405. design or manufacture. They can cause a trace not to match the
  6406. specification. This, in turn, may cause trace decode to fail.
  6407. @value{GDBN} can detect erroneous trace packets and correct them, thus
  6408. avoiding the decoding failures. These corrections are known as
  6409. @dfn{errata workarounds}, and are enabled based on the processor on
  6410. which the trace was recorded.
  6411. By default, @value{GDBN} attempts to detect the processor
  6412. automatically, and apply the necessary workarounds for it. However,
  6413. you may need to specify the processor if @value{GDBN} does not yet
  6414. support it. This command allows you to do that, and also allows to
  6415. disable the workarounds.
  6416. The argument @var{identifier} identifies the @sc{cpu} and is of the
  6417. form: @code{@var{vendor}:@var{processor identifier}}. In addition,
  6418. there are two special identifiers, @code{none} and @code{auto}
  6419. (default).
  6420. The following vendor identifiers and corresponding processor
  6421. identifiers are currently supported:
  6422. @multitable @columnfractions .1 .9
  6423. @item @code{intel}
  6424. @tab @var{family}/@var{model}[/@var{stepping}]
  6425. @end multitable
  6426. On GNU/Linux systems, the processor @var{family}, @var{model}, and
  6427. @var{stepping} can be obtained from @code{/proc/cpuinfo}.
  6428. If @var{identifier} is @code{auto}, enable errata workarounds for the
  6429. processor on which the trace was recorded. If @var{identifier} is
  6430. @code{none}, errata workarounds are disabled.
  6431. For example, when using an old @value{GDBN} on a new system, decode
  6432. may fail because @value{GDBN} does not support the new processor. It
  6433. often suffices to specify an older processor that @value{GDBN}
  6434. supports.
  6435. @smallexample
  6436. (gdb) info record
  6437. Active record target: record-btrace
  6438. Recording format: Intel Processor Trace.
  6439. Buffer size: 16kB.
  6440. Failed to configure the Intel Processor Trace decoder: unknown cpu.
  6441. (gdb) set record btrace cpu intel:6/158
  6442. (gdb) info record
  6443. Active record target: record-btrace
  6444. Recording format: Intel Processor Trace.
  6445. Buffer size: 16kB.
  6446. Recorded 84872 instructions in 3189 functions (0 gaps) for thread 1 (...).
  6447. @end smallexample
  6448. @kindex show record btrace
  6449. @item show record btrace replay-memory-access
  6450. Show the current setting of @code{replay-memory-access}.
  6451. @item show record btrace cpu
  6452. Show the processor to be used for enabling trace decode errata
  6453. workarounds.
  6454. @kindex set record btrace bts
  6455. @item set record btrace bts buffer-size @var{size}
  6456. @itemx set record btrace bts buffer-size unlimited
  6457. Set the requested ring buffer size for branch tracing in @acronym{BTS}
  6458. format. Default is 64KB.
  6459. If @var{size} is a positive number, then @value{GDBN} will try to
  6460. allocate a buffer of at least @var{size} bytes for each new thread
  6461. that uses the btrace recording method and the @acronym{BTS} format.
  6462. The actually obtained buffer size may differ from the requested
  6463. @var{size}. Use the @code{info record} command to see the actual
  6464. buffer size for each thread that uses the btrace recording method and
  6465. the @acronym{BTS} format.
  6466. If @var{limit} is @code{unlimited} or zero, @value{GDBN} will try to
  6467. allocate a buffer of 4MB.
  6468. Bigger buffers mean longer traces. On the other hand, @value{GDBN} will
  6469. also need longer to process the branch trace data before it can be used.
  6470. @item show record btrace bts buffer-size @var{size}
  6471. Show the current setting of the requested ring buffer size for branch
  6472. tracing in @acronym{BTS} format.
  6473. @kindex set record btrace pt
  6474. @item set record btrace pt buffer-size @var{size}
  6475. @itemx set record btrace pt buffer-size unlimited
  6476. Set the requested ring buffer size for branch tracing in Intel
  6477. Processor Trace format. Default is 16KB.
  6478. If @var{size} is a positive number, then @value{GDBN} will try to
  6479. allocate a buffer of at least @var{size} bytes for each new thread
  6480. that uses the btrace recording method and the Intel Processor Trace
  6481. format. The actually obtained buffer size may differ from the
  6482. requested @var{size}. Use the @code{info record} command to see the
  6483. actual buffer size for each thread.
  6484. If @var{limit} is @code{unlimited} or zero, @value{GDBN} will try to
  6485. allocate a buffer of 4MB.
  6486. Bigger buffers mean longer traces. On the other hand, @value{GDBN} will
  6487. also need longer to process the branch trace data before it can be used.
  6488. @item show record btrace pt buffer-size @var{size}
  6489. Show the current setting of the requested ring buffer size for branch
  6490. tracing in Intel Processor Trace format.
  6491. @kindex info record
  6492. @item info record
  6493. Show various statistics about the recording depending on the recording
  6494. method:
  6495. @table @code
  6496. @item full
  6497. For the @code{full} recording method, it shows the state of process
  6498. record and its in-memory execution log buffer, including:
  6499. @itemize @bullet
  6500. @item
  6501. Whether in record mode or replay mode.
  6502. @item
  6503. Lowest recorded instruction number (counting from when the current execution log started recording instructions).
  6504. @item
  6505. Highest recorded instruction number.
  6506. @item
  6507. Current instruction about to be replayed (if in replay mode).
  6508. @item
  6509. Number of instructions contained in the execution log.
  6510. @item
  6511. Maximum number of instructions that may be contained in the execution log.
  6512. @end itemize
  6513. @item btrace
  6514. For the @code{btrace} recording method, it shows:
  6515. @itemize @bullet
  6516. @item
  6517. Recording format.
  6518. @item
  6519. Number of instructions that have been recorded.
  6520. @item
  6521. Number of blocks of sequential control-flow formed by the recorded
  6522. instructions.
  6523. @item
  6524. Whether in record mode or replay mode.
  6525. @end itemize
  6526. For the @code{bts} recording format, it also shows:
  6527. @itemize @bullet
  6528. @item
  6529. Size of the perf ring buffer.
  6530. @end itemize
  6531. For the @code{pt} recording format, it also shows:
  6532. @itemize @bullet
  6533. @item
  6534. Size of the perf ring buffer.
  6535. @end itemize
  6536. @end table
  6537. @kindex record delete
  6538. @kindex rec del
  6539. @item record delete
  6540. When record target runs in replay mode (``in the past''), delete the
  6541. subsequent execution log and begin to record a new execution log starting
  6542. from the current address. This means you will abandon the previously
  6543. recorded ``future'' and begin recording a new ``future''.
  6544. @kindex record instruction-history
  6545. @kindex rec instruction-history
  6546. @item record instruction-history
  6547. Disassembles instructions from the recorded execution log. By
  6548. default, ten instructions are disassembled. This can be changed using
  6549. the @code{set record instruction-history-size} command. Instructions
  6550. are printed in execution order.
  6551. It can also print mixed source+disassembly if you specify the the
  6552. @code{/m} or @code{/s} modifier, and print the raw instructions in hex
  6553. as well as in symbolic form by specifying the @code{/r} modifier.
  6554. The current position marker is printed for the instruction at the
  6555. current program counter value. This instruction can appear multiple
  6556. times in the trace and the current position marker will be printed
  6557. every time. To omit the current position marker, specify the
  6558. @code{/p} modifier.
  6559. To better align the printed instructions when the trace contains
  6560. instructions from more than one function, the function name may be
  6561. omitted by specifying the @code{/f} modifier.
  6562. Speculatively executed instructions are prefixed with @samp{?}. This
  6563. feature is not available for all recording formats.
  6564. There are several ways to specify what part of the execution log to
  6565. disassemble:
  6566. @table @code
  6567. @item record instruction-history @var{insn}
  6568. Disassembles ten instructions starting from instruction number
  6569. @var{insn}.
  6570. @item record instruction-history @var{insn}, +/-@var{n}
  6571. Disassembles @var{n} instructions around instruction number
  6572. @var{insn}. If @var{n} is preceded with @code{+}, disassembles
  6573. @var{n} instructions after instruction number @var{insn}. If
  6574. @var{n} is preceded with @code{-}, disassembles @var{n}
  6575. instructions before instruction number @var{insn}.
  6576. @item record instruction-history
  6577. Disassembles ten more instructions after the last disassembly.
  6578. @item record instruction-history -
  6579. Disassembles ten more instructions before the last disassembly.
  6580. @item record instruction-history @var{begin}, @var{end}
  6581. Disassembles instructions beginning with instruction number
  6582. @var{begin} until instruction number @var{end}. The instruction
  6583. number @var{end} is included.
  6584. @end table
  6585. This command may not be available for all recording methods.
  6586. @kindex set record
  6587. @item set record instruction-history-size @var{size}
  6588. @itemx set record instruction-history-size unlimited
  6589. Define how many instructions to disassemble in the @code{record
  6590. instruction-history} command. The default value is 10.
  6591. A @var{size} of @code{unlimited} means unlimited instructions.
  6592. @kindex show record
  6593. @item show record instruction-history-size
  6594. Show how many instructions to disassemble in the @code{record
  6595. instruction-history} command.
  6596. @kindex record function-call-history
  6597. @kindex rec function-call-history
  6598. @item record function-call-history
  6599. Prints the execution history at function granularity. For each sequence
  6600. of instructions that belong to the same function, it prints the name of
  6601. that function, the source lines for this instruction sequence (if the
  6602. @code{/l} modifier is specified), and the instructions numbers that form
  6603. the sequence (if the @code{/i} modifier is specified). The function names
  6604. are indented to reflect the call stack depth if the @code{/c} modifier is
  6605. specified. The @code{/l}, @code{/i}, and @code{/c} modifiers can be given
  6606. together.
  6607. @smallexample
  6608. (@value{GDBP}) @b{list 1, 10}
  6609. 1 void foo (void)
  6610. 2 @{
  6611. 3 @}
  6612. 4
  6613. 5 void bar (void)
  6614. 6 @{
  6615. 7 ...
  6616. 8 foo ();
  6617. 9 ...
  6618. 10 @}
  6619. (@value{GDBP}) @b{record function-call-history /ilc}
  6620. 1 bar inst 1,4 at foo.c:6,8
  6621. 2 foo inst 5,10 at foo.c:2,3
  6622. 3 bar inst 11,13 at foo.c:9,10
  6623. @end smallexample
  6624. By default, ten functions are printed. This can be changed using the
  6625. @code{set record function-call-history-size} command. Functions are
  6626. printed in execution order. There are several ways to specify what
  6627. to print:
  6628. @table @code
  6629. @item record function-call-history @var{func}
  6630. Prints ten functions starting from function number @var{func}.
  6631. @item record function-call-history @var{func}, +/-@var{n}
  6632. Prints @var{n} functions around function number @var{func}. If
  6633. @var{n} is preceded with @code{+}, prints @var{n} functions after
  6634. function number @var{func}. If @var{n} is preceded with @code{-},
  6635. prints @var{n} functions before function number @var{func}.
  6636. @item record function-call-history
  6637. Prints ten more functions after the last ten-function print.
  6638. @item record function-call-history -
  6639. Prints ten more functions before the last ten-function print.
  6640. @item record function-call-history @var{begin}, @var{end}
  6641. Prints functions beginning with function number @var{begin} until
  6642. function number @var{end}. The function number @var{end} is included.
  6643. @end table
  6644. This command may not be available for all recording methods.
  6645. @item set record function-call-history-size @var{size}
  6646. @itemx set record function-call-history-size unlimited
  6647. Define how many functions to print in the
  6648. @code{record function-call-history} command. The default value is 10.
  6649. A size of @code{unlimited} means unlimited functions.
  6650. @item show record function-call-history-size
  6651. Show how many functions to print in the
  6652. @code{record function-call-history} command.
  6653. @end table
  6654. @node Stack
  6655. @chapter Examining the Stack
  6656. When your program has stopped, the first thing you need to know is where it
  6657. stopped and how it got there.
  6658. @cindex call stack
  6659. Each time your program performs a function call, information about the call
  6660. is generated.
  6661. That information includes the location of the call in your program,
  6662. the arguments of the call,
  6663. and the local variables of the function being called.
  6664. The information is saved in a block of data called a @dfn{stack frame}.
  6665. The stack frames are allocated in a region of memory called the @dfn{call
  6666. stack}.
  6667. When your program stops, the @value{GDBN} commands for examining the
  6668. stack allow you to see all of this information.
  6669. @cindex selected frame
  6670. One of the stack frames is @dfn{selected} by @value{GDBN} and many
  6671. @value{GDBN} commands refer implicitly to the selected frame. In
  6672. particular, whenever you ask @value{GDBN} for the value of a variable in
  6673. your program, the value is found in the selected frame. There are
  6674. special @value{GDBN} commands to select whichever frame you are
  6675. interested in. @xref{Selection, ,Selecting a Frame}.
  6676. When your program stops, @value{GDBN} automatically selects the
  6677. currently executing frame and describes it briefly, similar to the
  6678. @code{frame} command (@pxref{Frame Info, ,Information about a Frame}).
  6679. @menu
  6680. * Frames:: Stack frames
  6681. * Backtrace:: Backtraces
  6682. * Selection:: Selecting a frame
  6683. * Frame Info:: Information on a frame
  6684. * Frame Apply:: Applying a command to several frames
  6685. * Frame Filter Management:: Managing frame filters
  6686. @end menu
  6687. @node Frames
  6688. @section Stack Frames
  6689. @cindex frame, definition
  6690. @cindex stack frame
  6691. The call stack is divided up into contiguous pieces called @dfn{stack
  6692. frames}, or @dfn{frames} for short; each frame is the data associated
  6693. with one call to one function. The frame contains the arguments given
  6694. to the function, the function's local variables, and the address at
  6695. which the function is executing.
  6696. @cindex initial frame
  6697. @cindex outermost frame
  6698. @cindex innermost frame
  6699. When your program is started, the stack has only one frame, that of the
  6700. function @code{main}. This is called the @dfn{initial} frame or the
  6701. @dfn{outermost} frame. Each time a function is called, a new frame is
  6702. made. Each time a function returns, the frame for that function invocation
  6703. is eliminated. If a function is recursive, there can be many frames for
  6704. the same function. The frame for the function in which execution is
  6705. actually occurring is called the @dfn{innermost} frame. This is the most
  6706. recently created of all the stack frames that still exist.
  6707. @cindex frame pointer
  6708. Inside your program, stack frames are identified by their addresses. A
  6709. stack frame consists of many bytes, each of which has its own address; each
  6710. kind of computer has a convention for choosing one byte whose
  6711. address serves as the address of the frame. Usually this address is kept
  6712. in a register called the @dfn{frame pointer register}
  6713. (@pxref{Registers, $fp}) while execution is going on in that frame.
  6714. @cindex frame level
  6715. @cindex frame number
  6716. @value{GDBN} labels each existing stack frame with a @dfn{level}, a
  6717. number that is zero for the innermost frame, one for the frame that
  6718. called it, and so on upward. These level numbers give you a way of
  6719. designating stack frames in @value{GDBN} commands. The terms
  6720. @dfn{frame number} and @dfn{frame level} can be used interchangeably to
  6721. describe this number.
  6722. @c The -fomit-frame-pointer below perennially causes hbox overflow
  6723. @c underflow problems.
  6724. @cindex frameless execution
  6725. Some compilers provide a way to compile functions so that they operate
  6726. without stack frames. (For example, the @value{NGCC} option
  6727. @smallexample
  6728. @samp{-fomit-frame-pointer}
  6729. @end smallexample
  6730. generates functions without a frame.)
  6731. This is occasionally done with heavily used library functions to save
  6732. the frame setup time. @value{GDBN} has limited facilities for dealing
  6733. with these function invocations. If the innermost function invocation
  6734. has no stack frame, @value{GDBN} nevertheless regards it as though
  6735. it had a separate frame, which is numbered zero as usual, allowing
  6736. correct tracing of the function call chain. However, @value{GDBN} has
  6737. no provision for frameless functions elsewhere in the stack.
  6738. @node Backtrace
  6739. @section Backtraces
  6740. @cindex traceback
  6741. @cindex call stack traces
  6742. A backtrace is a summary of how your program got where it is. It shows one
  6743. line per frame, for many frames, starting with the currently executing
  6744. frame (frame zero), followed by its caller (frame one), and on up the
  6745. stack.
  6746. @anchor{backtrace-command}
  6747. @kindex backtrace
  6748. @kindex bt @r{(@code{backtrace})}
  6749. To print a backtrace of the entire stack, use the @code{backtrace}
  6750. command, or its alias @code{bt}. This command will print one line per
  6751. frame for frames in the stack. By default, all stack frames are
  6752. printed. You can stop the backtrace at any time by typing the system
  6753. interrupt character, normally @kbd{Ctrl-c}.
  6754. @table @code
  6755. @item backtrace [@var{option}]@dots{} [@var{qualifier}]@dots{} [@var{count}]
  6756. @itemx bt [@var{option}]@dots{} [@var{qualifier}]@dots{} [@var{count}]
  6757. Print the backtrace of the entire stack.
  6758. The optional @var{count} can be one of the following:
  6759. @table @code
  6760. @item @var{n}
  6761. @itemx @var{n}
  6762. Print only the innermost @var{n} frames, where @var{n} is a positive
  6763. number.
  6764. @item -@var{n}
  6765. @itemx -@var{n}
  6766. Print only the outermost @var{n} frames, where @var{n} is a positive
  6767. number.
  6768. @end table
  6769. Options:
  6770. @table @code
  6771. @item -full
  6772. Print the values of the local variables also. This can be combined
  6773. with the optional @var{count} to limit the number of frames shown.
  6774. @item -no-filters
  6775. Do not run Python frame filters on this backtrace. @xref{Frame
  6776. Filter API}, for more information. Additionally use @ref{disable
  6777. frame-filter all} to turn off all frame filters. This is only
  6778. relevant when @value{GDBN} has been configured with @code{Python}
  6779. support.
  6780. @item -hide
  6781. A Python frame filter might decide to ``elide'' some frames. Normally
  6782. such elided frames are still printed, but they are indented relative
  6783. to the filtered frames that cause them to be elided. The @code{-hide}
  6784. option causes elided frames to not be printed at all.
  6785. @end table
  6786. The @code{backtrace} command also supports a number of options that
  6787. allow overriding relevant global print settings as set by @code{set
  6788. backtrace} and @code{set print} subcommands:
  6789. @table @code
  6790. @item -past-main [@code{on}|@code{off}]
  6791. Set whether backtraces should continue past @code{main}. Related setting:
  6792. @ref{set backtrace past-main}.
  6793. @item -past-entry [@code{on}|@code{off}]
  6794. Set whether backtraces should continue past the entry point of a program.
  6795. Related setting: @ref{set backtrace past-entry}.
  6796. @item -entry-values @code{no}|@code{only}|@code{preferred}|@code{if-needed}|@code{both}|@code{compact}|@code{default}
  6797. Set printing of function arguments at function entry.
  6798. Related setting: @ref{set print entry-values}.
  6799. @item -frame-arguments @code{all}|@code{scalars}|@code{none}
  6800. Set printing of non-scalar frame arguments.
  6801. Related setting: @ref{set print frame-arguments}.
  6802. @item -raw-frame-arguments [@code{on}|@code{off}]
  6803. Set whether to print frame arguments in raw form.
  6804. Related setting: @ref{set print raw-frame-arguments}.
  6805. @item -frame-info @code{auto}|@code{source-line}|@code{location}|@code{source-and-location}|@code{location-and-address}|@code{short-location}
  6806. Set printing of frame information.
  6807. Related setting: @ref{set print frame-info}.
  6808. @end table
  6809. The optional @var{qualifier} is maintained for backward compatibility.
  6810. It can be one of the following:
  6811. @table @code
  6812. @item full
  6813. Equivalent to the @code{-full} option.
  6814. @item no-filters
  6815. Equivalent to the @code{-no-filters} option.
  6816. @item hide
  6817. Equivalent to the @code{-hide} option.
  6818. @end table
  6819. @end table
  6820. @kindex where
  6821. @kindex info stack
  6822. The names @code{where} and @code{info stack} (abbreviated @code{info s})
  6823. are additional aliases for @code{backtrace}.
  6824. @cindex multiple threads, backtrace
  6825. In a multi-threaded program, @value{GDBN} by default shows the
  6826. backtrace only for the current thread. To display the backtrace for
  6827. several or all of the threads, use the command @code{thread apply}
  6828. (@pxref{Threads, thread apply}). For example, if you type @kbd{thread
  6829. apply all backtrace}, @value{GDBN} will display the backtrace for all
  6830. the threads; this is handy when you debug a core dump of a
  6831. multi-threaded program.
  6832. Each line in the backtrace shows the frame number and the function name.
  6833. The program counter value is also shown---unless you use @code{set
  6834. print address off}. The backtrace also shows the source file name and
  6835. line number, as well as the arguments to the function. The program
  6836. counter value is omitted if it is at the beginning of the code for that
  6837. line number.
  6838. Here is an example of a backtrace. It was made with the command
  6839. @samp{bt 3}, so it shows the innermost three frames.
  6840. @smallexample
  6841. @group
  6842. #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
  6843. at builtin.c:993
  6844. #1 0x6e38 in expand_macro (sym=0x2b600, data=...) at macro.c:242
  6845. #2 0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
  6846. at macro.c:71
  6847. (More stack frames follow...)
  6848. @end group
  6849. @end smallexample
  6850. @noindent
  6851. The display for frame zero does not begin with a program counter
  6852. value, indicating that your program has stopped at the beginning of the
  6853. code for line @code{993} of @code{builtin.c}.
  6854. @noindent
  6855. The value of parameter @code{data} in frame 1 has been replaced by
  6856. @code{@dots{}}. By default, @value{GDBN} prints the value of a parameter
  6857. only if it is a scalar (integer, pointer, enumeration, etc). See command
  6858. @kbd{set print frame-arguments} in @ref{Print Settings} for more details
  6859. on how to configure the way function parameter values are printed.
  6860. The command @kbd{set print frame-info} (@pxref{Print Settings}) controls
  6861. what frame information is printed.
  6862. @cindex optimized out, in backtrace
  6863. @cindex function call arguments, optimized out
  6864. If your program was compiled with optimizations, some compilers will
  6865. optimize away arguments passed to functions if those arguments are
  6866. never used after the call. Such optimizations generate code that
  6867. passes arguments through registers, but doesn't store those arguments
  6868. in the stack frame. @value{GDBN} has no way of displaying such
  6869. arguments in stack frames other than the innermost one. Here's what
  6870. such a backtrace might look like:
  6871. @smallexample
  6872. @group
  6873. #0 m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
  6874. at builtin.c:993
  6875. #1 0x6e38 in expand_macro (sym=<optimized out>) at macro.c:242
  6876. #2 0x6840 in expand_token (obs=0x0, t=<optimized out>, td=0xf7fffb08)
  6877. at macro.c:71
  6878. (More stack frames follow...)
  6879. @end group
  6880. @end smallexample
  6881. @noindent
  6882. The values of arguments that were not saved in their stack frames are
  6883. shown as @samp{<optimized out>}.
  6884. If you need to display the values of such optimized-out arguments,
  6885. either deduce that from other variables whose values depend on the one
  6886. you are interested in, or recompile without optimizations.
  6887. @cindex backtrace beyond @code{main} function
  6888. @cindex program entry point
  6889. @cindex startup code, and backtrace
  6890. Most programs have a standard user entry point---a place where system
  6891. libraries and startup code transition into user code. For C this is
  6892. @code{main}@footnote{
  6893. Note that embedded programs (the so-called ``free-standing''
  6894. environment) are not required to have a @code{main} function as the
  6895. entry point. They could even have multiple entry points.}.
  6896. When @value{GDBN} finds the entry function in a backtrace
  6897. it will terminate the backtrace, to avoid tracing into highly
  6898. system-specific (and generally uninteresting) code.
  6899. If you need to examine the startup code, or limit the number of levels
  6900. in a backtrace, you can change this behavior:
  6901. @table @code
  6902. @item set backtrace past-main
  6903. @itemx set backtrace past-main on
  6904. @anchor{set backtrace past-main}
  6905. @kindex set backtrace
  6906. Backtraces will continue past the user entry point.
  6907. @item set backtrace past-main off
  6908. Backtraces will stop when they encounter the user entry point. This is the
  6909. default.
  6910. @item show backtrace past-main
  6911. @kindex show backtrace
  6912. Display the current user entry point backtrace policy.
  6913. @item set backtrace past-entry
  6914. @itemx set backtrace past-entry on
  6915. @anchor{set backtrace past-entry}
  6916. Backtraces will continue past the internal entry point of an application.
  6917. This entry point is encoded by the linker when the application is built,
  6918. and is likely before the user entry point @code{main} (or equivalent) is called.
  6919. @item set backtrace past-entry off
  6920. Backtraces will stop when they encounter the internal entry point of an
  6921. application. This is the default.
  6922. @item show backtrace past-entry
  6923. Display the current internal entry point backtrace policy.
  6924. @item set backtrace limit @var{n}
  6925. @itemx set backtrace limit 0
  6926. @itemx set backtrace limit unlimited
  6927. @anchor{set backtrace limit}
  6928. @cindex backtrace limit
  6929. Limit the backtrace to @var{n} levels. A value of @code{unlimited}
  6930. or zero means unlimited levels.
  6931. @item show backtrace limit
  6932. Display the current limit on backtrace levels.
  6933. @end table
  6934. You can control how file names are displayed.
  6935. @table @code
  6936. @item set filename-display
  6937. @itemx set filename-display relative
  6938. @cindex filename-display
  6939. Display file names relative to the compilation directory. This is the default.
  6940. @item set filename-display basename
  6941. Display only basename of a filename.
  6942. @item set filename-display absolute
  6943. Display an absolute filename.
  6944. @item show filename-display
  6945. Show the current way to display filenames.
  6946. @end table
  6947. @node Selection
  6948. @section Selecting a Frame
  6949. Most commands for examining the stack and other data in your program work on
  6950. whichever stack frame is selected at the moment. Here are the commands for
  6951. selecting a stack frame; all of them finish by printing a brief description
  6952. of the stack frame just selected.
  6953. @table @code
  6954. @kindex frame@r{, selecting}
  6955. @kindex f @r{(@code{frame})}
  6956. @item frame @r{[} @var{frame-selection-spec} @r{]}
  6957. @item f @r{[} @var{frame-selection-spec} @r{]}
  6958. The @command{frame} command allows different stack frames to be
  6959. selected. The @var{frame-selection-spec} can be any of the following:
  6960. @table @code
  6961. @kindex frame level
  6962. @item @var{num}
  6963. @item level @var{num}
  6964. Select frame level @var{num}. Recall that frame zero is the innermost
  6965. (currently executing) frame, frame one is the frame that called the
  6966. innermost one, and so on. The highest level frame is usually the one
  6967. for @code{main}.
  6968. As this is the most common method of navigating the frame stack, the
  6969. string @command{level} can be omitted. For example, the following two
  6970. commands are equivalent:
  6971. @smallexample
  6972. (@value{GDBP}) frame 3
  6973. (@value{GDBP}) frame level 3
  6974. @end smallexample
  6975. @kindex frame address
  6976. @item address @var{stack-address}
  6977. Select the frame with stack address @var{stack-address}. The
  6978. @var{stack-address} for a frame can be seen in the output of
  6979. @command{info frame}, for example:
  6980. @smallexample
  6981. (gdb) info frame
  6982. Stack level 1, frame at 0x7fffffffda30:
  6983. rip = 0x40066d in b (amd64-entry-value.cc:59); saved rip 0x4004c5
  6984. tail call frame, caller of frame at 0x7fffffffda30
  6985. source language c++.
  6986. Arglist at unknown address.
  6987. Locals at unknown address, Previous frame's sp is 0x7fffffffda30
  6988. @end smallexample
  6989. The @var{stack-address} for this frame is @code{0x7fffffffda30} as
  6990. indicated by the line:
  6991. @smallexample
  6992. Stack level 1, frame at 0x7fffffffda30:
  6993. @end smallexample
  6994. @kindex frame function
  6995. @item function @var{function-name}
  6996. Select the stack frame for function @var{function-name}. If there are
  6997. multiple stack frames for function @var{function-name} then the inner
  6998. most stack frame is selected.
  6999. @kindex frame view
  7000. @item view @var{stack-address} @r{[} @var{pc-addr} @r{]}
  7001. View a frame that is not part of @value{GDBN}'s backtrace. The frame
  7002. viewed has stack address @var{stack-addr}, and optionally, a program
  7003. counter address of @var{pc-addr}.
  7004. This is useful mainly if the chaining of stack frames has been
  7005. damaged by a bug, making it impossible for @value{GDBN} to assign
  7006. numbers properly to all frames. In addition, this can be useful
  7007. when your program has multiple stacks and switches between them.
  7008. When viewing a frame outside the current backtrace using
  7009. @command{frame view} then you can always return to the original
  7010. stack using one of the previous stack frame selection instructions,
  7011. for example @command{frame level 0}.
  7012. @end table
  7013. @kindex up
  7014. @item up @var{n}
  7015. Move @var{n} frames up the stack; @var{n} defaults to 1. For positive
  7016. numbers @var{n}, this advances toward the outermost frame, to higher
  7017. frame numbers, to frames that have existed longer.
  7018. @kindex down
  7019. @kindex do @r{(@code{down})}
  7020. @item down @var{n}
  7021. Move @var{n} frames down the stack; @var{n} defaults to 1. For
  7022. positive numbers @var{n}, this advances toward the innermost frame, to
  7023. lower frame numbers, to frames that were created more recently.
  7024. You may abbreviate @code{down} as @code{do}.
  7025. @end table
  7026. All of these commands end by printing two lines of output describing the
  7027. frame. The first line shows the frame number, the function name, the
  7028. arguments, and the source file and line number of execution in that
  7029. frame. The second line shows the text of that source line.
  7030. @need 1000
  7031. For example:
  7032. @smallexample
  7033. @group
  7034. (@value{GDBP}) up
  7035. #1 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
  7036. at env.c:10
  7037. 10 read_input_file (argv[i]);
  7038. @end group
  7039. @end smallexample
  7040. After such a printout, the @code{list} command with no arguments
  7041. prints ten lines centered on the point of execution in the frame.
  7042. You can also edit the program at the point of execution with your favorite
  7043. editing program by typing @code{edit}.
  7044. @xref{List, ,Printing Source Lines},
  7045. for details.
  7046. @table @code
  7047. @kindex select-frame
  7048. @item select-frame @r{[} @var{frame-selection-spec} @r{]}
  7049. The @code{select-frame} command is a variant of @code{frame} that does
  7050. not display the new frame after selecting it. This command is
  7051. intended primarily for use in @value{GDBN} command scripts, where the
  7052. output might be unnecessary and distracting. The
  7053. @var{frame-selection-spec} is as for the @command{frame} command
  7054. described in @ref{Selection, ,Selecting a Frame}.
  7055. @kindex down-silently
  7056. @kindex up-silently
  7057. @item up-silently @var{n}
  7058. @itemx down-silently @var{n}
  7059. These two commands are variants of @code{up} and @code{down},
  7060. respectively; they differ in that they do their work silently, without
  7061. causing display of the new frame. They are intended primarily for use
  7062. in @value{GDBN} command scripts, where the output might be unnecessary and
  7063. distracting.
  7064. @end table
  7065. @node Frame Info
  7066. @section Information About a Frame
  7067. There are several other commands to print information about the selected
  7068. stack frame.
  7069. @table @code
  7070. @item frame
  7071. @itemx f
  7072. When used without any argument, this command does not change which
  7073. frame is selected, but prints a brief description of the currently
  7074. selected stack frame. It can be abbreviated @code{f}. With an
  7075. argument, this command is used to select a stack frame.
  7076. @xref{Selection, ,Selecting a Frame}.
  7077. @kindex info frame
  7078. @kindex info f @r{(@code{info frame})}
  7079. @item info frame
  7080. @itemx info f
  7081. This command prints a verbose description of the selected stack frame,
  7082. including:
  7083. @itemize @bullet
  7084. @item
  7085. the address of the frame
  7086. @item
  7087. the address of the next frame down (called by this frame)
  7088. @item
  7089. the address of the next frame up (caller of this frame)
  7090. @item
  7091. the language in which the source code corresponding to this frame is written
  7092. @item
  7093. the address of the frame's arguments
  7094. @item
  7095. the address of the frame's local variables
  7096. @item
  7097. the program counter saved in it (the address of execution in the caller frame)
  7098. @item
  7099. which registers were saved in the frame
  7100. @end itemize
  7101. @noindent The verbose description is useful when
  7102. something has gone wrong that has made the stack format fail to fit
  7103. the usual conventions.
  7104. @item info frame @r{[} @var{frame-selection-spec} @r{]}
  7105. @itemx info f @r{[} @var{frame-selection-spec} @r{]}
  7106. Print a verbose description of the frame selected by
  7107. @var{frame-selection-spec}. The @var{frame-selection-spec} is the
  7108. same as for the @command{frame} command (@pxref{Selection, ,Selecting
  7109. a Frame}). The selected frame remains unchanged by this command.
  7110. @kindex info args
  7111. @item info args [-q]
  7112. Print the arguments of the selected frame, each on a separate line.
  7113. The optional flag @samp{-q}, which stands for @samp{quiet}, disables
  7114. printing header information and messages explaining why no argument
  7115. have been printed.
  7116. @item info args [-q] [-t @var{type_regexp}] [@var{regexp}]
  7117. Like @kbd{info args}, but only print the arguments selected
  7118. with the provided regexp(s).
  7119. If @var{regexp} is provided, print only the arguments whose names
  7120. match the regular expression @var{regexp}.
  7121. If @var{type_regexp} is provided, print only the arguments whose
  7122. types, as printed by the @code{whatis} command, match
  7123. the regular expression @var{type_regexp}.
  7124. If @var{type_regexp} contains space(s), it should be enclosed in
  7125. quote characters. If needed, use backslash to escape the meaning
  7126. of special characters or quotes.
  7127. If both @var{regexp} and @var{type_regexp} are provided, an argument
  7128. is printed only if its name matches @var{regexp} and its type matches
  7129. @var{type_regexp}.
  7130. @item info locals [-q]
  7131. @kindex info locals
  7132. Print the local variables of the selected frame, each on a separate
  7133. line. These are all variables (declared either static or automatic)
  7134. accessible at the point of execution of the selected frame.
  7135. The optional flag @samp{-q}, which stands for @samp{quiet}, disables
  7136. printing header information and messages explaining why no local variables
  7137. have been printed.
  7138. @item info locals [-q] [-t @var{type_regexp}] [@var{regexp}]
  7139. Like @kbd{info locals}, but only print the local variables selected
  7140. with the provided regexp(s).
  7141. If @var{regexp} is provided, print only the local variables whose names
  7142. match the regular expression @var{regexp}.
  7143. If @var{type_regexp} is provided, print only the local variables whose
  7144. types, as printed by the @code{whatis} command, match
  7145. the regular expression @var{type_regexp}.
  7146. If @var{type_regexp} contains space(s), it should be enclosed in
  7147. quote characters. If needed, use backslash to escape the meaning
  7148. of special characters or quotes.
  7149. If both @var{regexp} and @var{type_regexp} are provided, a local variable
  7150. is printed only if its name matches @var{regexp} and its type matches
  7151. @var{type_regexp}.
  7152. The command @kbd{info locals -q -t @var{type_regexp}} can usefully be
  7153. combined with the commands @kbd{frame apply} and @kbd{thread apply}.
  7154. For example, your program might use Resource Acquisition Is
  7155. Initialization types (RAII) such as @code{lock_something_t}: each
  7156. local variable of type @code{lock_something_t} automatically places a
  7157. lock that is destroyed when the variable goes out of scope. You can
  7158. then list all acquired locks in your program by doing
  7159. @smallexample
  7160. thread apply all -s frame apply all -s info locals -q -t lock_something_t
  7161. @end smallexample
  7162. @noindent
  7163. or the equivalent shorter form
  7164. @smallexample
  7165. tfaas i lo -q -t lock_something_t
  7166. @end smallexample
  7167. @end table
  7168. @node Frame Apply
  7169. @section Applying a Command to Several Frames.
  7170. @kindex frame apply
  7171. @cindex apply command to several frames
  7172. @table @code
  7173. @item frame apply [all | @var{count} | @var{-count} | level @var{level}@dots{}] [@var{option}]@dots{} @var{command}
  7174. The @code{frame apply} command allows you to apply the named
  7175. @var{command} to one or more frames.
  7176. @table @code
  7177. @item @code{all}
  7178. Specify @code{all} to apply @var{command} to all frames.
  7179. @item @var{count}
  7180. Use @var{count} to apply @var{command} to the innermost @var{count}
  7181. frames, where @var{count} is a positive number.
  7182. @item @var{-count}
  7183. Use @var{-count} to apply @var{command} to the outermost @var{count}
  7184. frames, where @var{count} is a positive number.
  7185. @item @code{level}
  7186. Use @code{level} to apply @var{command} to the set of frames identified
  7187. by the @var{level} list. @var{level} is a frame level or a range of frame
  7188. levels as @var{level1}-@var{level2}. The frame level is the number shown
  7189. in the first field of the @samp{backtrace} command output.
  7190. E.g., @samp{2-4 6-8 3} indicates to apply @var{command} for the frames
  7191. at levels 2, 3, 4, 6, 7, 8, and then again on frame at level 3.
  7192. @end table
  7193. Note that the frames on which @code{frame apply} applies a command are
  7194. also influenced by the @code{set backtrace} settings such as @code{set
  7195. backtrace past-main} and @code{set backtrace limit N}.
  7196. @xref{Backtrace,,Backtraces}.
  7197. The @code{frame apply} command also supports a number of options that
  7198. allow overriding relevant @code{set backtrace} settings:
  7199. @table @code
  7200. @item -past-main [@code{on}|@code{off}]
  7201. Whether backtraces should continue past @code{main}.
  7202. Related setting: @ref{set backtrace past-main}.
  7203. @item -past-entry [@code{on}|@code{off}]
  7204. Whether backtraces should continue past the entry point of a program.
  7205. Related setting: @ref{set backtrace past-entry}.
  7206. @end table
  7207. By default, @value{GDBN} displays some frame information before the
  7208. output produced by @var{command}, and an error raised during the
  7209. execution of a @var{command} will abort @code{frame apply}. The
  7210. following options can be used to fine-tune these behaviors:
  7211. @table @code
  7212. @item -c
  7213. The flag @code{-c}, which stands for @samp{continue}, causes any
  7214. errors in @var{command} to be displayed, and the execution of
  7215. @code{frame apply} then continues.
  7216. @item -s
  7217. The flag @code{-s}, which stands for @samp{silent}, causes any errors
  7218. or empty output produced by a @var{command} to be silently ignored.
  7219. That is, the execution continues, but the frame information and errors
  7220. are not printed.
  7221. @item -q
  7222. The flag @code{-q} (@samp{quiet}) disables printing the frame
  7223. information.
  7224. @end table
  7225. The following example shows how the flags @code{-c} and @code{-s} are
  7226. working when applying the command @code{p j} to all frames, where
  7227. variable @code{j} can only be successfully printed in the outermost
  7228. @code{#1 main} frame.
  7229. @smallexample
  7230. @group
  7231. (gdb) frame apply all p j
  7232. #0 some_function (i=5) at fun.c:4
  7233. No symbol "j" in current context.
  7234. (gdb) frame apply all -c p j
  7235. #0 some_function (i=5) at fun.c:4
  7236. No symbol "j" in current context.
  7237. #1 0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
  7238. $1 = 5
  7239. (gdb) frame apply all -s p j
  7240. #1 0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
  7241. $2 = 5
  7242. (gdb)
  7243. @end group
  7244. @end smallexample
  7245. By default, @samp{frame apply}, prints the frame location
  7246. information before the command output:
  7247. @smallexample
  7248. @group
  7249. (gdb) frame apply all p $sp
  7250. #0 some_function (i=5) at fun.c:4
  7251. $4 = (void *) 0xffffd1e0
  7252. #1 0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
  7253. $5 = (void *) 0xffffd1f0
  7254. (gdb)
  7255. @end group
  7256. @end smallexample
  7257. If the flag @code{-q} is given, no frame information is printed:
  7258. @smallexample
  7259. @group
  7260. (gdb) frame apply all -q p $sp
  7261. $12 = (void *) 0xffffd1e0
  7262. $13 = (void *) 0xffffd1f0
  7263. (gdb)
  7264. @end group
  7265. @end smallexample
  7266. @end table
  7267. @table @code
  7268. @kindex faas
  7269. @cindex apply a command to all frames (ignoring errors and empty output)
  7270. @item faas @var{command}
  7271. Shortcut for @code{frame apply all -s @var{command}}.
  7272. Applies @var{command} on all frames, ignoring errors and empty output.
  7273. It can for example be used to print a local variable or a function
  7274. argument without knowing the frame where this variable or argument
  7275. is, using:
  7276. @smallexample
  7277. (@value{GDBP}) faas p some_local_var_i_do_not_remember_where_it_is
  7278. @end smallexample
  7279. The @code{faas} command accepts the same options as the @code{frame
  7280. apply} command. @xref{Frame Apply,,frame apply}.
  7281. Note that the command @code{tfaas @var{command}} applies @var{command}
  7282. on all frames of all threads. See @xref{Threads,,Threads}.
  7283. @end table
  7284. @node Frame Filter Management
  7285. @section Management of Frame Filters.
  7286. @cindex managing frame filters
  7287. Frame filters are Python based utilities to manage and decorate the
  7288. output of frames. @xref{Frame Filter API}, for further information.
  7289. Managing frame filters is performed by several commands available
  7290. within @value{GDBN}, detailed here.
  7291. @table @code
  7292. @kindex info frame-filter
  7293. @item info frame-filter
  7294. Print a list of installed frame filters from all dictionaries, showing
  7295. their name, priority and enabled status.
  7296. @kindex disable frame-filter
  7297. @anchor{disable frame-filter all}
  7298. @item disable frame-filter @var{filter-dictionary} @var{filter-name}
  7299. Disable a frame filter in the dictionary matching
  7300. @var{filter-dictionary} and @var{filter-name}. The
  7301. @var{filter-dictionary} may be @code{all}, @code{global},
  7302. @code{progspace}, or the name of the object file where the frame filter
  7303. dictionary resides. When @code{all} is specified, all frame filters
  7304. across all dictionaries are disabled. The @var{filter-name} is the name
  7305. of the frame filter and is used when @code{all} is not the option for
  7306. @var{filter-dictionary}. A disabled frame-filter is not deleted, it
  7307. may be enabled again later.
  7308. @kindex enable frame-filter
  7309. @item enable frame-filter @var{filter-dictionary} @var{filter-name}
  7310. Enable a frame filter in the dictionary matching
  7311. @var{filter-dictionary} and @var{filter-name}. The
  7312. @var{filter-dictionary} may be @code{all}, @code{global},
  7313. @code{progspace} or the name of the object file where the frame filter
  7314. dictionary resides. When @code{all} is specified, all frame filters across
  7315. all dictionaries are enabled. The @var{filter-name} is the name of the frame
  7316. filter and is used when @code{all} is not the option for
  7317. @var{filter-dictionary}.
  7318. Example:
  7319. @smallexample
  7320. (gdb) info frame-filter
  7321. global frame-filters:
  7322. Priority Enabled Name
  7323. 1000 No PrimaryFunctionFilter
  7324. 100 Yes Reverse
  7325. progspace /build/test frame-filters:
  7326. Priority Enabled Name
  7327. 100 Yes ProgspaceFilter
  7328. objfile /build/test frame-filters:
  7329. Priority Enabled Name
  7330. 999 Yes BuildProgramFilter
  7331. (gdb) disable frame-filter /build/test BuildProgramFilter
  7332. (gdb) info frame-filter
  7333. global frame-filters:
  7334. Priority Enabled Name
  7335. 1000 No PrimaryFunctionFilter
  7336. 100 Yes Reverse
  7337. progspace /build/test frame-filters:
  7338. Priority Enabled Name
  7339. 100 Yes ProgspaceFilter
  7340. objfile /build/test frame-filters:
  7341. Priority Enabled Name
  7342. 999 No BuildProgramFilter
  7343. (gdb) enable frame-filter global PrimaryFunctionFilter
  7344. (gdb) info frame-filter
  7345. global frame-filters:
  7346. Priority Enabled Name
  7347. 1000 Yes PrimaryFunctionFilter
  7348. 100 Yes Reverse
  7349. progspace /build/test frame-filters:
  7350. Priority Enabled Name
  7351. 100 Yes ProgspaceFilter
  7352. objfile /build/test frame-filters:
  7353. Priority Enabled Name
  7354. 999 No BuildProgramFilter
  7355. @end smallexample
  7356. @kindex set frame-filter priority
  7357. @item set frame-filter priority @var{filter-dictionary} @var{filter-name} @var{priority}
  7358. Set the @var{priority} of a frame filter in the dictionary matching
  7359. @var{filter-dictionary}, and the frame filter name matching
  7360. @var{filter-name}. The @var{filter-dictionary} may be @code{global},
  7361. @code{progspace} or the name of the object file where the frame filter
  7362. dictionary resides. The @var{priority} is an integer.
  7363. @kindex show frame-filter priority
  7364. @item show frame-filter priority @var{filter-dictionary} @var{filter-name}
  7365. Show the @var{priority} of a frame filter in the dictionary matching
  7366. @var{filter-dictionary}, and the frame filter name matching
  7367. @var{filter-name}. The @var{filter-dictionary} may be @code{global},
  7368. @code{progspace} or the name of the object file where the frame filter
  7369. dictionary resides.
  7370. Example:
  7371. @smallexample
  7372. (gdb) info frame-filter
  7373. global frame-filters:
  7374. Priority Enabled Name
  7375. 1000 Yes PrimaryFunctionFilter
  7376. 100 Yes Reverse
  7377. progspace /build/test frame-filters:
  7378. Priority Enabled Name
  7379. 100 Yes ProgspaceFilter
  7380. objfile /build/test frame-filters:
  7381. Priority Enabled Name
  7382. 999 No BuildProgramFilter
  7383. (gdb) set frame-filter priority global Reverse 50
  7384. (gdb) info frame-filter
  7385. global frame-filters:
  7386. Priority Enabled Name
  7387. 1000 Yes PrimaryFunctionFilter
  7388. 50 Yes Reverse
  7389. progspace /build/test frame-filters:
  7390. Priority Enabled Name
  7391. 100 Yes ProgspaceFilter
  7392. objfile /build/test frame-filters:
  7393. Priority Enabled Name
  7394. 999 No BuildProgramFilter
  7395. @end smallexample
  7396. @end table
  7397. @node Source
  7398. @chapter Examining Source Files
  7399. @value{GDBN} can print parts of your program's source, since the debugging
  7400. information recorded in the program tells @value{GDBN} what source files were
  7401. used to build it. When your program stops, @value{GDBN} spontaneously prints
  7402. the line where it stopped. Likewise, when you select a stack frame
  7403. (@pxref{Selection, ,Selecting a Frame}), @value{GDBN} prints the line where
  7404. execution in that frame has stopped. You can print other portions of
  7405. source files by explicit command.
  7406. If you use @value{GDBN} through its @sc{gnu} Emacs interface, you may
  7407. prefer to use Emacs facilities to view source; see @ref{Emacs, ,Using
  7408. @value{GDBN} under @sc{gnu} Emacs}.
  7409. @menu
  7410. * List:: Printing source lines
  7411. * Specify Location:: How to specify code locations
  7412. * Edit:: Editing source files
  7413. * Search:: Searching source files
  7414. * Source Path:: Specifying source directories
  7415. * Machine Code:: Source and machine code
  7416. * Disable Reading Source:: Disable Reading Source Code
  7417. @end menu
  7418. @node List
  7419. @section Printing Source Lines
  7420. @kindex list
  7421. @kindex l @r{(@code{list})}
  7422. To print lines from a source file, use the @code{list} command
  7423. (abbreviated @code{l}). By default, ten lines are printed.
  7424. There are several ways to specify what part of the file you want to
  7425. print; see @ref{Specify Location}, for the full list.
  7426. Here are the forms of the @code{list} command most commonly used:
  7427. @table @code
  7428. @item list @var{linenum}
  7429. Print lines centered around line number @var{linenum} in the
  7430. current source file.
  7431. @item list @var{function}
  7432. Print lines centered around the beginning of function
  7433. @var{function}.
  7434. @item list
  7435. Print more lines. If the last lines printed were printed with a
  7436. @code{list} command, this prints lines following the last lines
  7437. printed; however, if the last line printed was a solitary line printed
  7438. as part of displaying a stack frame (@pxref{Stack, ,Examining the
  7439. Stack}), this prints lines centered around that line.
  7440. @item list -
  7441. Print lines just before the lines last printed.
  7442. @end table
  7443. @cindex @code{list}, how many lines to display
  7444. By default, @value{GDBN} prints ten source lines with any of these forms of
  7445. the @code{list} command. You can change this using @code{set listsize}:
  7446. @table @code
  7447. @kindex set listsize
  7448. @item set listsize @var{count}
  7449. @itemx set listsize unlimited
  7450. Make the @code{list} command display @var{count} source lines (unless
  7451. the @code{list} argument explicitly specifies some other number).
  7452. Setting @var{count} to @code{unlimited} or 0 means there's no limit.
  7453. @kindex show listsize
  7454. @item show listsize
  7455. Display the number of lines that @code{list} prints.
  7456. @end table
  7457. Repeating a @code{list} command with @key{RET} discards the argument,
  7458. so it is equivalent to typing just @code{list}. This is more useful
  7459. than listing the same lines again. An exception is made for an
  7460. argument of @samp{-}; that argument is preserved in repetition so that
  7461. each repetition moves up in the source file.
  7462. In general, the @code{list} command expects you to supply zero, one or two
  7463. @dfn{locations}. Locations specify source lines; there are several ways
  7464. of writing them (@pxref{Specify Location}), but the effect is always
  7465. to specify some source line.
  7466. Here is a complete description of the possible arguments for @code{list}:
  7467. @table @code
  7468. @item list @var{location}
  7469. Print lines centered around the line specified by @var{location}.
  7470. @item list @var{first},@var{last}
  7471. Print lines from @var{first} to @var{last}. Both arguments are
  7472. locations. When a @code{list} command has two locations, and the
  7473. source file of the second location is omitted, this refers to
  7474. the same source file as the first location.
  7475. @item list ,@var{last}
  7476. Print lines ending with @var{last}.
  7477. @item list @var{first},
  7478. Print lines starting with @var{first}.
  7479. @item list +
  7480. Print lines just after the lines last printed.
  7481. @item list -
  7482. Print lines just before the lines last printed.
  7483. @item list
  7484. As described in the preceding table.
  7485. @end table
  7486. @node Specify Location
  7487. @section Specifying a Location
  7488. @cindex specifying location
  7489. @cindex location
  7490. @cindex source location
  7491. Several @value{GDBN} commands accept arguments that specify a location
  7492. of your program's code. Since @value{GDBN} is a source-level
  7493. debugger, a location usually specifies some line in the source code.
  7494. Locations may be specified using three different formats:
  7495. linespec locations, explicit locations, or address locations.
  7496. @menu
  7497. * Linespec Locations:: Linespec locations
  7498. * Explicit Locations:: Explicit locations
  7499. * Address Locations:: Address locations
  7500. @end menu
  7501. @node Linespec Locations
  7502. @subsection Linespec Locations
  7503. @cindex linespec locations
  7504. A @dfn{linespec} is a colon-separated list of source location parameters such
  7505. as file name, function name, etc. Here are all the different ways of
  7506. specifying a linespec:
  7507. @table @code
  7508. @item @var{linenum}
  7509. Specifies the line number @var{linenum} of the current source file.
  7510. @item -@var{offset}
  7511. @itemx +@var{offset}
  7512. Specifies the line @var{offset} lines before or after the @dfn{current
  7513. line}. For the @code{list} command, the current line is the last one
  7514. printed; for the breakpoint commands, this is the line at which
  7515. execution stopped in the currently selected @dfn{stack frame}
  7516. (@pxref{Frames, ,Frames}, for a description of stack frames.) When
  7517. used as the second of the two linespecs in a @code{list} command,
  7518. this specifies the line @var{offset} lines up or down from the first
  7519. linespec.
  7520. @item @var{filename}:@var{linenum}
  7521. Specifies the line @var{linenum} in the source file @var{filename}.
  7522. If @var{filename} is a relative file name, then it will match any
  7523. source file name with the same trailing components. For example, if
  7524. @var{filename} is @samp{gcc/expr.c}, then it will match source file
  7525. name of @file{/build/trunk/gcc/expr.c}, but not
  7526. @file{/build/trunk/libcpp/expr.c} or @file{/build/trunk/gcc/x-expr.c}.
  7527. @item @var{function}
  7528. Specifies the line that begins the body of the function @var{function}.
  7529. For example, in C, this is the line with the open brace.
  7530. By default, in C@t{++} and Ada, @var{function} is interpreted as
  7531. specifying all functions named @var{function} in all scopes. For
  7532. C@t{++}, this means in all namespaces and classes. For Ada, this
  7533. means in all packages.
  7534. For example, assuming a program with C@t{++} symbols named
  7535. @code{A::B::func} and @code{B::func}, both commands @w{@kbd{break
  7536. func}} and @w{@kbd{break B::func}} set a breakpoint on both symbols.
  7537. Commands that accept a linespec let you override this with the
  7538. @code{-qualified} option. For example, @w{@kbd{break -qualified
  7539. func}} sets a breakpoint on a free-function named @code{func} ignoring
  7540. any C@t{++} class methods and namespace functions called @code{func}.
  7541. @xref{Explicit Locations}.
  7542. @item @var{function}:@var{label}
  7543. Specifies the line where @var{label} appears in @var{function}.
  7544. @item @var{filename}:@var{function}
  7545. Specifies the line that begins the body of the function @var{function}
  7546. in the file @var{filename}. You only need the file name with a
  7547. function name to avoid ambiguity when there are identically named
  7548. functions in different source files.
  7549. @item @var{label}
  7550. Specifies the line at which the label named @var{label} appears
  7551. in the function corresponding to the currently selected stack frame.
  7552. If there is no current selected stack frame (for instance, if the inferior
  7553. is not running), then @value{GDBN} will not search for a label.
  7554. @cindex breakpoint at static probe point
  7555. @item -pstap|-probe-stap @r{[}@var{objfile}:@r{[}@var{provider}:@r{]}@r{]}@var{name}
  7556. The @sc{gnu}/Linux tool @code{SystemTap} provides a way for
  7557. applications to embed static probes. @xref{Static Probe Points}, for more
  7558. information on finding and using static probes. This form of linespec
  7559. specifies the location of such a static probe.
  7560. If @var{objfile} is given, only probes coming from that shared library
  7561. or executable matching @var{objfile} as a regular expression are considered.
  7562. If @var{provider} is given, then only probes from that provider are considered.
  7563. If several probes match the spec, @value{GDBN} will insert a breakpoint at
  7564. each one of those probes.
  7565. @end table
  7566. @node Explicit Locations
  7567. @subsection Explicit Locations
  7568. @cindex explicit locations
  7569. @dfn{Explicit locations} allow the user to directly specify the source
  7570. location's parameters using option-value pairs.
  7571. Explicit locations are useful when several functions, labels, or
  7572. file names have the same name (base name for files) in the program's
  7573. sources. In these cases, explicit locations point to the source
  7574. line you meant more accurately and unambiguously. Also, using
  7575. explicit locations might be faster in large programs.
  7576. For example, the linespec @samp{foo:bar} may refer to a function @code{bar}
  7577. defined in the file named @file{foo} or the label @code{bar} in a function
  7578. named @code{foo}. @value{GDBN} must search either the file system or
  7579. the symbol table to know.
  7580. The list of valid explicit location options is summarized in the
  7581. following table:
  7582. @table @code
  7583. @item -source @var{filename}
  7584. The value specifies the source file name. To differentiate between
  7585. files with the same base name, prepend as many directories as is necessary
  7586. to uniquely identify the desired file, e.g., @file{foo/bar/baz.c}. Otherwise
  7587. @value{GDBN} will use the first file it finds with the given base
  7588. name. This option requires the use of either @code{-function} or @code{-line}.
  7589. @item -function @var{function}
  7590. The value specifies the name of a function. Operations
  7591. on function locations unmodified by other options (such as @code{-label}
  7592. or @code{-line}) refer to the line that begins the body of the function.
  7593. In C, for example, this is the line with the open brace.
  7594. By default, in C@t{++} and Ada, @var{function} is interpreted as
  7595. specifying all functions named @var{function} in all scopes. For
  7596. C@t{++}, this means in all namespaces and classes. For Ada, this
  7597. means in all packages.
  7598. For example, assuming a program with C@t{++} symbols named
  7599. @code{A::B::func} and @code{B::func}, both commands @w{@kbd{break
  7600. -function func}} and @w{@kbd{break -function B::func}} set a
  7601. breakpoint on both symbols.
  7602. You can use the @kbd{-qualified} flag to override this (see below).
  7603. @item -qualified
  7604. This flag makes @value{GDBN} interpret a function name specified with
  7605. @kbd{-function} as a complete fully-qualified name.
  7606. For example, assuming a C@t{++} program with symbols named
  7607. @code{A::B::func} and @code{B::func}, the @w{@kbd{break -qualified
  7608. -function B::func}} command sets a breakpoint on @code{B::func}, only.
  7609. (Note: the @kbd{-qualified} option can precede a linespec as well
  7610. (@pxref{Linespec Locations}), so the particular example above could be
  7611. simplified as @w{@kbd{break -qualified B::func}}.)
  7612. @item -label @var{label}
  7613. The value specifies the name of a label. When the function
  7614. name is not specified, the label is searched in the function of the currently
  7615. selected stack frame.
  7616. @item -line @var{number}
  7617. The value specifies a line offset for the location. The offset may either
  7618. be absolute (@code{-line 3}) or relative (@code{-line +3}), depending on
  7619. the command. When specified without any other options, the line offset is
  7620. relative to the current line.
  7621. @end table
  7622. Explicit location options may be abbreviated by omitting any non-unique
  7623. trailing characters from the option name, e.g., @w{@kbd{break -s main.c -li 3}}.
  7624. @node Address Locations
  7625. @subsection Address Locations
  7626. @cindex address locations
  7627. @dfn{Address locations} indicate a specific program address. They have
  7628. the generalized form *@var{address}.
  7629. For line-oriented commands, such as @code{list} and @code{edit}, this
  7630. specifies a source line that contains @var{address}. For @code{break} and
  7631. other breakpoint-oriented commands, this can be used to set breakpoints in
  7632. parts of your program which do not have debugging information or
  7633. source files.
  7634. Here @var{address} may be any expression valid in the current working
  7635. language (@pxref{Languages, working language}) that specifies a code
  7636. address. In addition, as a convenience, @value{GDBN} extends the
  7637. semantics of expressions used in locations to cover several situations
  7638. that frequently occur during debugging. Here are the various forms
  7639. of @var{address}:
  7640. @table @code
  7641. @item @var{expression}
  7642. Any expression valid in the current working language.
  7643. @item @var{funcaddr}
  7644. An address of a function or procedure derived from its name. In C,
  7645. C@t{++}, Objective-C, Fortran, minimal, and assembly, this is
  7646. simply the function's name @var{function} (and actually a special case
  7647. of a valid expression). In Pascal and Modula-2, this is
  7648. @code{&@var{function}}. In Ada, this is @code{@var{function}'Address}
  7649. (although the Pascal form also works).
  7650. This form specifies the address of the function's first instruction,
  7651. before the stack frame and arguments have been set up.
  7652. @item '@var{filename}':@var{funcaddr}
  7653. Like @var{funcaddr} above, but also specifies the name of the source
  7654. file explicitly. This is useful if the name of the function does not
  7655. specify the function unambiguously, e.g., if there are several
  7656. functions with identical names in different source files.
  7657. @end table
  7658. @node Edit
  7659. @section Editing Source Files
  7660. @cindex editing source files
  7661. @kindex edit
  7662. @kindex e @r{(@code{edit})}
  7663. To edit the lines in a source file, use the @code{edit} command.
  7664. The editing program of your choice
  7665. is invoked with the current line set to
  7666. the active line in the program.
  7667. Alternatively, there are several ways to specify what part of the file you
  7668. want to print if you want to see other parts of the program:
  7669. @table @code
  7670. @item edit @var{location}
  7671. Edit the source file specified by @code{location}. Editing starts at
  7672. that @var{location}, e.g., at the specified source line of the
  7673. specified file. @xref{Specify Location}, for all the possible forms
  7674. of the @var{location} argument; here are the forms of the @code{edit}
  7675. command most commonly used:
  7676. @table @code
  7677. @item edit @var{number}
  7678. Edit the current source file with @var{number} as the active line number.
  7679. @item edit @var{function}
  7680. Edit the file containing @var{function} at the beginning of its definition.
  7681. @end table
  7682. @end table
  7683. @subsection Choosing your Editor
  7684. You can customize @value{GDBN} to use any editor you want
  7685. @footnote{
  7686. The only restriction is that your editor (say @code{ex}), recognizes the
  7687. following command-line syntax:
  7688. @smallexample
  7689. ex +@var{number} file
  7690. @end smallexample
  7691. The optional numeric value +@var{number} specifies the number of the line in
  7692. the file where to start editing.}.
  7693. By default, it is @file{@value{EDITOR}}, but you can change this
  7694. by setting the environment variable @env{EDITOR} before using
  7695. @value{GDBN}. For example, to configure @value{GDBN} to use the
  7696. @code{vi} editor, you could use these commands with the @code{sh} shell:
  7697. @smallexample
  7698. EDITOR=/usr/bin/vi
  7699. export EDITOR
  7700. gdb @dots{}
  7701. @end smallexample
  7702. or in the @code{csh} shell,
  7703. @smallexample
  7704. setenv EDITOR /usr/bin/vi
  7705. gdb @dots{}
  7706. @end smallexample
  7707. @node Search
  7708. @section Searching Source Files
  7709. @cindex searching source files
  7710. There are two commands for searching through the current source file for a
  7711. regular expression.
  7712. @table @code
  7713. @kindex search
  7714. @kindex forward-search
  7715. @kindex fo @r{(@code{forward-search})}
  7716. @item forward-search @var{regexp}
  7717. @itemx search @var{regexp}
  7718. The command @samp{forward-search @var{regexp}} checks each line,
  7719. starting with the one following the last line listed, for a match for
  7720. @var{regexp}. It lists the line that is found. You can use the
  7721. synonym @samp{search @var{regexp}} or abbreviate the command name as
  7722. @code{fo}.
  7723. @kindex reverse-search
  7724. @item reverse-search @var{regexp}
  7725. The command @samp{reverse-search @var{regexp}} checks each line, starting
  7726. with the one before the last line listed and going backward, for a match
  7727. for @var{regexp}. It lists the line that is found. You can abbreviate
  7728. this command as @code{rev}.
  7729. @end table
  7730. @node Source Path
  7731. @section Specifying Source Directories
  7732. @cindex source path
  7733. @cindex directories for source files
  7734. Executable programs sometimes do not record the directories of the source
  7735. files from which they were compiled, just the names. Even when they do,
  7736. the directories could be moved between the compilation and your debugging
  7737. session. @value{GDBN} has a list of directories to search for source files;
  7738. this is called the @dfn{source path}. Each time @value{GDBN} wants a source file,
  7739. it tries all the directories in the list, in the order they are present
  7740. in the list, until it finds a file with the desired name.
  7741. For example, suppose an executable references the file
  7742. @file{/usr/src/foo-1.0/lib/foo.c}, does not record a compilation
  7743. directory, and the @dfn{source path} is @file{/mnt/cross}.
  7744. @value{GDBN} would look for the source file in the following
  7745. locations:
  7746. @enumerate
  7747. @item @file{/usr/src/foo-1.0/lib/foo.c}
  7748. @item @file{/mnt/cross/usr/src/foo-1.0/lib/foo.c}
  7749. @item @file{/mnt/cross/foo.c}
  7750. @end enumerate
  7751. If the source file is not present at any of the above locations then
  7752. an error is printed. @value{GDBN} does not look up the parts of the
  7753. source file name, such as @file{/mnt/cross/src/foo-1.0/lib/foo.c}.
  7754. Likewise, the subdirectories of the source path are not searched: if
  7755. the source path is @file{/mnt/cross}, and the binary refers to
  7756. @file{foo.c}, @value{GDBN} would not find it under
  7757. @file{/mnt/cross/usr/src/foo-1.0/lib}.
  7758. Plain file names, relative file names with leading directories, file
  7759. names containing dots, etc.@: are all treated as described above,
  7760. except that non-absolute file names are not looked up literally. If
  7761. the @dfn{source path} is @file{/mnt/cross}, the source file is
  7762. recorded as @file{../lib/foo.c}, and no compilation directory is
  7763. recorded, then @value{GDBN} will search in the following locations:
  7764. @enumerate
  7765. @item @file{/mnt/cross/../lib/foo.c}
  7766. @item @file{/mnt/cross/foo.c}
  7767. @end enumerate
  7768. @kindex cdir
  7769. @kindex cwd
  7770. @vindex $cdir@r{, convenience variable}
  7771. @vindex $cwd@r{, convenience variable}
  7772. @cindex compilation directory
  7773. @cindex current directory
  7774. @cindex working directory
  7775. @cindex directory, current
  7776. @cindex directory, compilation
  7777. The @dfn{source path} will always include two special entries
  7778. @samp{$cdir} and @samp{$cwd}, these refer to the compilation directory
  7779. (if one is recorded) and the current working directory respectively.
  7780. @samp{$cdir} causes @value{GDBN} to search within the compilation
  7781. directory, if one is recorded in the debug information. If no
  7782. compilation directory is recorded in the debug information then
  7783. @samp{$cdir} is ignored.
  7784. @samp{$cwd} is not the same as @samp{.}---the former tracks the
  7785. current working directory as it changes during your @value{GDBN}
  7786. session, while the latter is immediately expanded to the current
  7787. directory at the time you add an entry to the source path.
  7788. If a compilation directory is recorded in the debug information, and
  7789. @value{GDBN} has not found the source file after the first search
  7790. using @dfn{source path}, then @value{GDBN} will combine the
  7791. compilation directory and the filename, and then search for the source
  7792. file again using the @dfn{source path}.
  7793. For example, if the executable records the source file as
  7794. @file{/usr/src/foo-1.0/lib/foo.c}, the compilation directory is
  7795. recorded as @file{/project/build}, and the @dfn{source path} is
  7796. @file{/mnt/cross:$cdir:$cwd} while the current working directory of
  7797. the @value{GDBN} session is @file{/home/user}, then @value{GDBN} will
  7798. search for the source file in the following locations:
  7799. @enumerate
  7800. @item @file{/usr/src/foo-1.0/lib/foo.c}
  7801. @item @file{/mnt/cross/usr/src/foo-1.0/lib/foo.c}
  7802. @item @file{/project/build/usr/src/foo-1.0/lib/foo.c}
  7803. @item @file{/home/user/usr/src/foo-1.0/lib/foo.c}
  7804. @item @file{/mnt/cross/project/build/usr/src/foo-1.0/lib/foo.c}
  7805. @item @file{/project/build/project/build/usr/src/foo-1.0/lib/foo.c}
  7806. @item @file{/home/user/project/build/usr/src/foo-1.0/lib/foo.c}
  7807. @item @file{/mnt/cross/foo.c}
  7808. @item @file{/project/build/foo.c}
  7809. @item @file{/home/user/foo.c}
  7810. @end enumerate
  7811. If the file name in the previous example had been recorded in the
  7812. executable as a relative path rather than an absolute path, then the
  7813. first look up would not have occurred, but all of the remaining steps
  7814. would be similar.
  7815. When searching for source files on MS-DOS and MS-Windows, where
  7816. absolute paths start with a drive letter (e.g.@:
  7817. @file{C:/project/foo.c}), @value{GDBN} will remove the drive letter
  7818. from the file name before appending it to a search directory from
  7819. @dfn{source path}; for instance if the executable references the
  7820. source file @file{C:/project/foo.c} and @dfn{source path} is set to
  7821. @file{D:/mnt/cross}, then @value{GDBN} will search in the following
  7822. locations for the source file:
  7823. @enumerate
  7824. @item @file{C:/project/foo.c}
  7825. @item @file{D:/mnt/cross/project/foo.c}
  7826. @item @file{D:/mnt/cross/foo.c}
  7827. @end enumerate
  7828. Note that the executable search path is @emph{not} used to locate the
  7829. source files.
  7830. Whenever you reset or rearrange the source path, @value{GDBN} clears out
  7831. any information it has cached about where source files are found and where
  7832. each line is in the file.
  7833. @kindex directory
  7834. @kindex dir
  7835. When you start @value{GDBN}, its source path includes only @samp{$cdir}
  7836. and @samp{$cwd}, in that order.
  7837. To add other directories, use the @code{directory} command.
  7838. The search path is used to find both program source files and @value{GDBN}
  7839. script files (read using the @samp{-command} option and @samp{source} command).
  7840. In addition to the source path, @value{GDBN} provides a set of commands
  7841. that manage a list of source path substitution rules. A @dfn{substitution
  7842. rule} specifies how to rewrite source directories stored in the program's
  7843. debug information in case the sources were moved to a different
  7844. directory between compilation and debugging. A rule is made of
  7845. two strings, the first specifying what needs to be rewritten in
  7846. the path, and the second specifying how it should be rewritten.
  7847. In @ref{set substitute-path}, we name these two parts @var{from} and
  7848. @var{to} respectively. @value{GDBN} does a simple string replacement
  7849. of @var{from} with @var{to} at the start of the directory part of the
  7850. source file name, and uses that result instead of the original file
  7851. name to look up the sources.
  7852. Using the previous example, suppose the @file{foo-1.0} tree has been
  7853. moved from @file{/usr/src} to @file{/mnt/cross}, then you can tell
  7854. @value{GDBN} to replace @file{/usr/src} in all source path names with
  7855. @file{/mnt/cross}. The first lookup will then be
  7856. @file{/mnt/cross/foo-1.0/lib/foo.c} in place of the original location
  7857. of @file{/usr/src/foo-1.0/lib/foo.c}. To define a source path
  7858. substitution rule, use the @code{set substitute-path} command
  7859. (@pxref{set substitute-path}).
  7860. To avoid unexpected substitution results, a rule is applied only if the
  7861. @var{from} part of the directory name ends at a directory separator.
  7862. For instance, a rule substituting @file{/usr/source} into
  7863. @file{/mnt/cross} will be applied to @file{/usr/source/foo-1.0} but
  7864. not to @file{/usr/sourceware/foo-2.0}. And because the substitution
  7865. is applied only at the beginning of the directory name, this rule will
  7866. not be applied to @file{/root/usr/source/baz.c} either.
  7867. In many cases, you can achieve the same result using the @code{directory}
  7868. command. However, @code{set substitute-path} can be more efficient in
  7869. the case where the sources are organized in a complex tree with multiple
  7870. subdirectories. With the @code{directory} command, you need to add each
  7871. subdirectory of your project. If you moved the entire tree while
  7872. preserving its internal organization, then @code{set substitute-path}
  7873. allows you to direct the debugger to all the sources with one single
  7874. command.
  7875. @code{set substitute-path} is also more than just a shortcut command.
  7876. The source path is only used if the file at the original location no
  7877. longer exists. On the other hand, @code{set substitute-path} modifies
  7878. the debugger behavior to look at the rewritten location instead. So, if
  7879. for any reason a source file that is not relevant to your executable is
  7880. located at the original location, a substitution rule is the only
  7881. method available to point @value{GDBN} at the new location.
  7882. @cindex @samp{--with-relocated-sources}
  7883. @cindex default source path substitution
  7884. You can configure a default source path substitution rule by
  7885. configuring @value{GDBN} with the
  7886. @samp{--with-relocated-sources=@var{dir}} option. The @var{dir}
  7887. should be the name of a directory under @value{GDBN}'s configured
  7888. prefix (set with @samp{--prefix} or @samp{--exec-prefix}), and
  7889. directory names in debug information under @var{dir} will be adjusted
  7890. automatically if the installed @value{GDBN} is moved to a new
  7891. location. This is useful if @value{GDBN}, libraries or executables
  7892. with debug information and corresponding source code are being moved
  7893. together.
  7894. @table @code
  7895. @item directory @var{dirname} @dots{}
  7896. @item dir @var{dirname} @dots{}
  7897. Add directory @var{dirname} to the front of the source path. Several
  7898. directory names may be given to this command, separated by @samp{:}
  7899. (@samp{;} on MS-DOS and MS-Windows, where @samp{:} usually appears as
  7900. part of absolute file names) or
  7901. whitespace. You may specify a directory that is already in the source
  7902. path; this moves it forward, so @value{GDBN} searches it sooner.
  7903. The special strings @samp{$cdir} (to refer to the compilation
  7904. directory, if one is recorded), and @samp{$cwd} (to refer to the
  7905. current working directory) can also be included in the list of
  7906. directories @var{dirname}. Though these will already be in the source
  7907. path they will be moved forward in the list so @value{GDBN} searches
  7908. them sooner.
  7909. @item directory
  7910. Reset the source path to its default value (@samp{$cdir:$cwd} on Unix systems). This requires confirmation.
  7911. @c RET-repeat for @code{directory} is explicitly disabled, but since
  7912. @c repeating it would be a no-op we do not say that. (thanks to RMS)
  7913. @item set directories @var{path-list}
  7914. @kindex set directories
  7915. Set the source path to @var{path-list}.
  7916. @samp{$cdir:$cwd} are added if missing.
  7917. @item show directories
  7918. @kindex show directories
  7919. Print the source path: show which directories it contains.
  7920. @anchor{set substitute-path}
  7921. @item set substitute-path @var{from} @var{to}
  7922. @kindex set substitute-path
  7923. Define a source path substitution rule, and add it at the end of the
  7924. current list of existing substitution rules. If a rule with the same
  7925. @var{from} was already defined, then the old rule is also deleted.
  7926. For example, if the file @file{/foo/bar/baz.c} was moved to
  7927. @file{/mnt/cross/baz.c}, then the command
  7928. @smallexample
  7929. (@value{GDBP}) set substitute-path /foo/bar /mnt/cross
  7930. @end smallexample
  7931. @noindent
  7932. will tell @value{GDBN} to replace @samp{/foo/bar} with
  7933. @samp{/mnt/cross}, which will allow @value{GDBN} to find the file
  7934. @file{baz.c} even though it was moved.
  7935. In the case when more than one substitution rule have been defined,
  7936. the rules are evaluated one by one in the order where they have been
  7937. defined. The first one matching, if any, is selected to perform
  7938. the substitution.
  7939. For instance, if we had entered the following commands:
  7940. @smallexample
  7941. (@value{GDBP}) set substitute-path /usr/src/include /mnt/include
  7942. (@value{GDBP}) set substitute-path /usr/src /mnt/src
  7943. @end smallexample
  7944. @noindent
  7945. @value{GDBN} would then rewrite @file{/usr/src/include/defs.h} into
  7946. @file{/mnt/include/defs.h} by using the first rule. However, it would
  7947. use the second rule to rewrite @file{/usr/src/lib/foo.c} into
  7948. @file{/mnt/src/lib/foo.c}.
  7949. @item unset substitute-path [path]
  7950. @kindex unset substitute-path
  7951. If a path is specified, search the current list of substitution rules
  7952. for a rule that would rewrite that path. Delete that rule if found.
  7953. A warning is emitted by the debugger if no rule could be found.
  7954. If no path is specified, then all substitution rules are deleted.
  7955. @item show substitute-path [path]
  7956. @kindex show substitute-path
  7957. If a path is specified, then print the source path substitution rule
  7958. which would rewrite that path, if any.
  7959. If no path is specified, then print all existing source path substitution
  7960. rules.
  7961. @end table
  7962. If your source path is cluttered with directories that are no longer of
  7963. interest, @value{GDBN} may sometimes cause confusion by finding the wrong
  7964. versions of source. You can correct the situation as follows:
  7965. @enumerate
  7966. @item
  7967. Use @code{directory} with no argument to reset the source path to its default value.
  7968. @item
  7969. Use @code{directory} with suitable arguments to reinstall the
  7970. directories you want in the source path. You can add all the
  7971. directories in one command.
  7972. @end enumerate
  7973. @node Machine Code
  7974. @section Source and Machine Code
  7975. @cindex source line and its code address
  7976. You can use the command @code{info line} to map source lines to program
  7977. addresses (and vice versa), and the command @code{disassemble} to display
  7978. a range of addresses as machine instructions. You can use the command
  7979. @code{set disassemble-next-line} to set whether to disassemble next
  7980. source line when execution stops. When run under @sc{gnu} Emacs
  7981. mode, the @code{info line} command causes the arrow to point to the
  7982. line specified. Also, @code{info line} prints addresses in symbolic form as
  7983. well as hex.
  7984. @table @code
  7985. @kindex info line
  7986. @item info line
  7987. @itemx info line @var{location}
  7988. Print the starting and ending addresses of the compiled code for
  7989. source line @var{location}. You can specify source lines in any of
  7990. the ways documented in @ref{Specify Location}. With no @var{location}
  7991. information about the current source line is printed.
  7992. @end table
  7993. For example, we can use @code{info line} to discover the location of
  7994. the object code for the first line of function
  7995. @code{m4_changequote}:
  7996. @smallexample
  7997. (@value{GDBP}) info line m4_changequote
  7998. Line 895 of "builtin.c" starts at pc 0x634c <m4_changequote> and \
  7999. ends at 0x6350 <m4_changequote+4>.
  8000. @end smallexample
  8001. @noindent
  8002. @cindex code address and its source line
  8003. We can also inquire (using @code{*@var{addr}} as the form for
  8004. @var{location}) what source line covers a particular address:
  8005. @smallexample
  8006. (@value{GDBP}) info line *0x63ff
  8007. Line 926 of "builtin.c" starts at pc 0x63e4 <m4_changequote+152> and \
  8008. ends at 0x6404 <m4_changequote+184>.
  8009. @end smallexample
  8010. @cindex @code{$_} and @code{info line}
  8011. @cindex @code{x} command, default address
  8012. @kindex x@r{(examine), and} info line
  8013. After @code{info line}, the default address for the @code{x} command
  8014. is changed to the starting address of the line, so that @samp{x/i} is
  8015. sufficient to begin examining the machine code (@pxref{Memory,
  8016. ,Examining Memory}). Also, this address is saved as the value of the
  8017. convenience variable @code{$_} (@pxref{Convenience Vars, ,Convenience
  8018. Variables}).
  8019. @cindex info line, repeated calls
  8020. After @code{info line}, using @code{info line} again without
  8021. specifying a location will display information about the next source
  8022. line.
  8023. @table @code
  8024. @kindex disassemble
  8025. @cindex assembly instructions
  8026. @cindex instructions, assembly
  8027. @cindex machine instructions
  8028. @cindex listing machine instructions
  8029. @item disassemble
  8030. @itemx disassemble /m
  8031. @itemx disassemble /s
  8032. @itemx disassemble /r
  8033. This specialized command dumps a range of memory as machine
  8034. instructions. It can also print mixed source+disassembly by specifying
  8035. the @code{/m} or @code{/s} modifier and print the raw instructions in hex
  8036. as well as in symbolic form by specifying the @code{/r} modifier.
  8037. The default memory range is the function surrounding the
  8038. program counter of the selected frame. A single argument to this
  8039. command is a program counter value; @value{GDBN} dumps the function
  8040. surrounding this value. When two arguments are given, they should
  8041. be separated by a comma, possibly surrounded by whitespace. The
  8042. arguments specify a range of addresses to dump, in one of two forms:
  8043. @table @code
  8044. @item @var{start},@var{end}
  8045. the addresses from @var{start} (inclusive) to @var{end} (exclusive)
  8046. @item @var{start},+@var{length}
  8047. the addresses from @var{start} (inclusive) to
  8048. @code{@var{start}+@var{length}} (exclusive).
  8049. @end table
  8050. @noindent
  8051. When 2 arguments are specified, the name of the function is also
  8052. printed (since there could be several functions in the given range).
  8053. The argument(s) can be any expression yielding a numeric value, such as
  8054. @samp{0x32c4}, @samp{&main+10} or @samp{$pc - 8}.
  8055. If the range of memory being disassembled contains current program counter,
  8056. the instruction at that location is shown with a @code{=>} marker.
  8057. @end table
  8058. The following example shows the disassembly of a range of addresses of
  8059. HP PA-RISC 2.0 code:
  8060. @smallexample
  8061. (@value{GDBP}) disas 0x32c4, 0x32e4
  8062. Dump of assembler code from 0x32c4 to 0x32e4:
  8063. 0x32c4 <main+204>: addil 0,dp
  8064. 0x32c8 <main+208>: ldw 0x22c(sr0,r1),r26
  8065. 0x32cc <main+212>: ldil 0x3000,r31
  8066. 0x32d0 <main+216>: ble 0x3f8(sr4,r31)
  8067. 0x32d4 <main+220>: ldo 0(r31),rp
  8068. 0x32d8 <main+224>: addil -0x800,dp
  8069. 0x32dc <main+228>: ldo 0x588(r1),r26
  8070. 0x32e0 <main+232>: ldil 0x3000,r31
  8071. End of assembler dump.
  8072. @end smallexample
  8073. Here is an example showing mixed source+assembly for Intel x86
  8074. with @code{/m} or @code{/s}, when the program is stopped just after
  8075. function prologue in a non-optimized function with no inline code.
  8076. @smallexample
  8077. (@value{GDBP}) disas /m main
  8078. Dump of assembler code for function main:
  8079. 5 @{
  8080. 0x08048330 <+0>: push %ebp
  8081. 0x08048331 <+1>: mov %esp,%ebp
  8082. 0x08048333 <+3>: sub $0x8,%esp
  8083. 0x08048336 <+6>: and $0xfffffff0,%esp
  8084. 0x08048339 <+9>: sub $0x10,%esp
  8085. 6 printf ("Hello.\n");
  8086. => 0x0804833c <+12>: movl $0x8048440,(%esp)
  8087. 0x08048343 <+19>: call 0x8048284 <puts@@plt>
  8088. 7 return 0;
  8089. 8 @}
  8090. 0x08048348 <+24>: mov $0x0,%eax
  8091. 0x0804834d <+29>: leave
  8092. 0x0804834e <+30>: ret
  8093. End of assembler dump.
  8094. @end smallexample
  8095. The @code{/m} option is deprecated as its output is not useful when
  8096. there is either inlined code or re-ordered code.
  8097. The @code{/s} option is the preferred choice.
  8098. Here is an example for AMD x86-64 showing the difference between
  8099. @code{/m} output and @code{/s} output.
  8100. This example has one inline function defined in a header file,
  8101. and the code is compiled with @samp{-O2} optimization.
  8102. Note how the @code{/m} output is missing the disassembly of
  8103. several instructions that are present in the @code{/s} output.
  8104. @file{foo.h}:
  8105. @smallexample
  8106. int
  8107. foo (int a)
  8108. @{
  8109. if (a < 0)
  8110. return a * 2;
  8111. if (a == 0)
  8112. return 1;
  8113. return a + 10;
  8114. @}
  8115. @end smallexample
  8116. @file{foo.c}:
  8117. @smallexample
  8118. #include "foo.h"
  8119. volatile int x, y;
  8120. int
  8121. main ()
  8122. @{
  8123. x = foo (y);
  8124. return 0;
  8125. @}
  8126. @end smallexample
  8127. @smallexample
  8128. (@value{GDBP}) disas /m main
  8129. Dump of assembler code for function main:
  8130. 5 @{
  8131. 6 x = foo (y);
  8132. 0x0000000000400400 <+0>: mov 0x200c2e(%rip),%eax # 0x601034 <y>
  8133. 0x0000000000400417 <+23>: mov %eax,0x200c13(%rip) # 0x601030 <x>
  8134. 7 return 0;
  8135. 8 @}
  8136. 0x000000000040041d <+29>: xor %eax,%eax
  8137. 0x000000000040041f <+31>: retq
  8138. 0x0000000000400420 <+32>: add %eax,%eax
  8139. 0x0000000000400422 <+34>: jmp 0x400417 <main+23>
  8140. End of assembler dump.
  8141. (@value{GDBP}) disas /s main
  8142. Dump of assembler code for function main:
  8143. foo.c:
  8144. 5 @{
  8145. 6 x = foo (y);
  8146. 0x0000000000400400 <+0>: mov 0x200c2e(%rip),%eax # 0x601034 <y>
  8147. foo.h:
  8148. 4 if (a < 0)
  8149. 0x0000000000400406 <+6>: test %eax,%eax
  8150. 0x0000000000400408 <+8>: js 0x400420 <main+32>
  8151. 6 if (a == 0)
  8152. 7 return 1;
  8153. 8 return a + 10;
  8154. 0x000000000040040a <+10>: lea 0xa(%rax),%edx
  8155. 0x000000000040040d <+13>: test %eax,%eax
  8156. 0x000000000040040f <+15>: mov $0x1,%eax
  8157. 0x0000000000400414 <+20>: cmovne %edx,%eax
  8158. foo.c:
  8159. 6 x = foo (y);
  8160. 0x0000000000400417 <+23>: mov %eax,0x200c13(%rip) # 0x601030 <x>
  8161. 7 return 0;
  8162. 8 @}
  8163. 0x000000000040041d <+29>: xor %eax,%eax
  8164. 0x000000000040041f <+31>: retq
  8165. foo.h:
  8166. 5 return a * 2;
  8167. 0x0000000000400420 <+32>: add %eax,%eax
  8168. 0x0000000000400422 <+34>: jmp 0x400417 <main+23>
  8169. End of assembler dump.
  8170. @end smallexample
  8171. Here is another example showing raw instructions in hex for AMD x86-64,
  8172. @smallexample
  8173. (gdb) disas /r 0x400281,+10
  8174. Dump of assembler code from 0x400281 to 0x40028b:
  8175. 0x0000000000400281: 38 36 cmp %dh,(%rsi)
  8176. 0x0000000000400283: 2d 36 34 2e 73 sub $0x732e3436,%eax
  8177. 0x0000000000400288: 6f outsl %ds:(%rsi),(%dx)
  8178. 0x0000000000400289: 2e 32 00 xor %cs:(%rax),%al
  8179. End of assembler dump.
  8180. @end smallexample
  8181. Addresses cannot be specified as a location (@pxref{Specify Location}).
  8182. So, for example, if you want to disassemble function @code{bar}
  8183. in file @file{foo.c}, you must type @samp{disassemble 'foo.c'::bar}
  8184. and not @samp{disassemble foo.c:bar}.
  8185. Some architectures have more than one commonly-used set of instruction
  8186. mnemonics or other syntax.
  8187. For programs that were dynamically linked and use shared libraries,
  8188. instructions that call functions or branch to locations in the shared
  8189. libraries might show a seemingly bogus location---it's actually a
  8190. location of the relocation table. On some architectures, @value{GDBN}
  8191. might be able to resolve these to actual function names.
  8192. @table @code
  8193. @kindex set disassembler-options
  8194. @cindex disassembler options
  8195. @item set disassembler-options @var{option1}[,@var{option2}@dots{}]
  8196. This command controls the passing of target specific information to
  8197. the disassembler. For a list of valid options, please refer to the
  8198. @code{-M}/@code{--disassembler-options} section of the @samp{objdump}
  8199. manual and/or the output of @kbd{objdump --help}
  8200. (@pxref{objdump,,objdump,binutils,The GNU Binary Utilities}).
  8201. The default value is the empty string.
  8202. If it is necessary to specify more than one disassembler option, then
  8203. multiple options can be placed together into a comma separated list.
  8204. Currently this command is only supported on targets ARC, ARM, MIPS,
  8205. PowerPC and S/390.
  8206. @kindex show disassembler-options
  8207. @item show disassembler-options
  8208. Show the current setting of the disassembler options.
  8209. @end table
  8210. @table @code
  8211. @kindex set disassembly-flavor
  8212. @cindex Intel disassembly flavor
  8213. @cindex AT&T disassembly flavor
  8214. @item set disassembly-flavor @var{instruction-set}
  8215. Select the instruction set to use when disassembling the
  8216. program via the @code{disassemble} or @code{x/i} commands.
  8217. Currently this command is only defined for the Intel x86 family. You
  8218. can set @var{instruction-set} to either @code{intel} or @code{att}.
  8219. The default is @code{att}, the AT&T flavor used by default by Unix
  8220. assemblers for x86-based targets.
  8221. @kindex show disassembly-flavor
  8222. @item show disassembly-flavor
  8223. Show the current setting of the disassembly flavor.
  8224. @end table
  8225. @table @code
  8226. @kindex set disassemble-next-line
  8227. @kindex show disassemble-next-line
  8228. @item set disassemble-next-line
  8229. @itemx show disassemble-next-line
  8230. Control whether or not @value{GDBN} will disassemble the next source
  8231. line or instruction when execution stops. If ON, @value{GDBN} will
  8232. display disassembly of the next source line when execution of the
  8233. program being debugged stops. This is @emph{in addition} to
  8234. displaying the source line itself, which @value{GDBN} always does if
  8235. possible. If the next source line cannot be displayed for some reason
  8236. (e.g., if @value{GDBN} cannot find the source file, or there's no line
  8237. info in the debug info), @value{GDBN} will display disassembly of the
  8238. next @emph{instruction} instead of showing the next source line. If
  8239. AUTO, @value{GDBN} will display disassembly of next instruction only
  8240. if the source line cannot be displayed. This setting causes
  8241. @value{GDBN} to display some feedback when you step through a function
  8242. with no line info or whose source file is unavailable. The default is
  8243. OFF, which means never display the disassembly of the next line or
  8244. instruction.
  8245. @end table
  8246. @node Disable Reading Source
  8247. @section Disable Reading Source Code
  8248. @cindex source code, disable access
  8249. In some cases it can be desirable to prevent @value{GDBN} from
  8250. accessing source code files. One case where this might be desirable
  8251. is if the source code files are located over a slow network
  8252. connection.
  8253. The following command can be used to control whether @value{GDBN}
  8254. should access source code files or not:
  8255. @table @code
  8256. @kindex set source open
  8257. @kindex show source open
  8258. @item set source open @r{[}on@r{|}off@r{]}
  8259. @itemx show source open
  8260. When this option is @code{on}, which is the default, @value{GDBN} will
  8261. access source code files when needed, for example to print source
  8262. lines when @value{GDBN} stops, or in response to the @code{list}
  8263. command.
  8264. When this option is @code{off}, @value{GDBN} will not access source
  8265. code files.
  8266. @end table
  8267. @node Data
  8268. @chapter Examining Data
  8269. @cindex printing data
  8270. @cindex examining data
  8271. @kindex print
  8272. @kindex inspect
  8273. The usual way to examine data in your program is with the @code{print}
  8274. command (abbreviated @code{p}), or its synonym @code{inspect}. It
  8275. evaluates and prints the value of an expression of the language your
  8276. program is written in (@pxref{Languages, ,Using @value{GDBN} with
  8277. Different Languages}). It may also print the expression using a
  8278. Python-based pretty-printer (@pxref{Pretty Printing}).
  8279. @table @code
  8280. @item print [[@var{options}] --] @var{expr}
  8281. @itemx print [[@var{options}] --] /@var{f} @var{expr}
  8282. @var{expr} is an expression (in the source language). By default the
  8283. value of @var{expr} is printed in a format appropriate to its data type;
  8284. you can choose a different format by specifying @samp{/@var{f}}, where
  8285. @var{f} is a letter specifying the format; see @ref{Output Formats,,Output
  8286. Formats}.
  8287. @anchor{print options}
  8288. The @code{print} command supports a number of options that allow
  8289. overriding relevant global print settings as set by @code{set print}
  8290. subcommands:
  8291. @table @code
  8292. @item -address [@code{on}|@code{off}]
  8293. Set printing of addresses.
  8294. Related setting: @ref{set print address}.
  8295. @item -array [@code{on}|@code{off}]
  8296. Pretty formatting of arrays.
  8297. Related setting: @ref{set print array}.
  8298. @item -array-indexes [@code{on}|@code{off}]
  8299. Set printing of array indexes.
  8300. Related setting: @ref{set print array-indexes}.
  8301. @item -elements @var{number-of-elements}|@code{unlimited}
  8302. Set limit on string chars or array elements to print. The value
  8303. @code{unlimited} causes there to be no limit. Related setting:
  8304. @ref{set print elements}.
  8305. @item -max-depth @var{depth}|@code{unlimited}
  8306. Set the threshold after which nested structures are replaced with
  8307. ellipsis. Related setting: @ref{set print max-depth}.
  8308. @item -memory-tag-violations [@code{on}|@code{off}]
  8309. Set printing of additional information about memory tag violations.
  8310. @xref{set print memory-tag-violations}.
  8311. @item -null-stop [@code{on}|@code{off}]
  8312. Set printing of char arrays to stop at first null char. Related
  8313. setting: @ref{set print null-stop}.
  8314. @item -object [@code{on}|@code{off}]
  8315. Set printing C@t{++} virtual function tables. Related setting:
  8316. @ref{set print object}.
  8317. @item -pretty [@code{on}|@code{off}]
  8318. Set pretty formatting of structures. Related setting: @ref{set print
  8319. pretty}.
  8320. @item -raw-values [@code{on}|@code{off}]
  8321. Set whether to print values in raw form, bypassing any
  8322. pretty-printers for that value. Related setting: @ref{set print
  8323. raw-values}.
  8324. @item -repeats @var{number-of-repeats}|@code{unlimited}
  8325. Set threshold for repeated print elements. @code{unlimited} causes
  8326. all elements to be individually printed. Related setting: @ref{set
  8327. print repeats}.
  8328. @item -static-members [@code{on}|@code{off}]
  8329. Set printing C@t{++} static members. Related setting: @ref{set print
  8330. static-members}.
  8331. @item -symbol [@code{on}|@code{off}]
  8332. Set printing of symbol names when printing pointers. Related setting:
  8333. @ref{set print symbol}.
  8334. @item -union [@code{on}|@code{off}]
  8335. Set printing of unions interior to structures. Related setting:
  8336. @ref{set print union}.
  8337. @item -vtbl [@code{on}|@code{off}]
  8338. Set printing of C++ virtual function tables. Related setting:
  8339. @ref{set print vtbl}.
  8340. @end table
  8341. Because the @code{print} command accepts arbitrary expressions which
  8342. may look like options (including abbreviations), if you specify any
  8343. command option, then you must use a double dash (@code{--}) to mark
  8344. the end of option processing.
  8345. For example, this prints the value of the @code{-p} expression:
  8346. @smallexample
  8347. (@value{GDBP}) print -p
  8348. @end smallexample
  8349. While this repeats the last value in the value history (see below)
  8350. with the @code{-pretty} option in effect:
  8351. @smallexample
  8352. (@value{GDBP}) print -p --
  8353. @end smallexample
  8354. Here is an example including both on option and an expression:
  8355. @smallexample
  8356. @group
  8357. (@value{GDBP}) print -pretty -- *myptr
  8358. $1 = @{
  8359. next = 0x0,
  8360. flags = @{
  8361. sweet = 1,
  8362. sour = 1
  8363. @},
  8364. meat = 0x54 "Pork"
  8365. @}
  8366. @end group
  8367. @end smallexample
  8368. @item print [@var{options}]
  8369. @itemx print [@var{options}] /@var{f}
  8370. @cindex reprint the last value
  8371. If you omit @var{expr}, @value{GDBN} displays the last value again (from the
  8372. @dfn{value history}; @pxref{Value History, ,Value History}). This allows you to
  8373. conveniently inspect the same value in an alternative format.
  8374. @end table
  8375. If the architecture supports memory tagging, the @code{print} command will
  8376. display pointer/memory tag mismatches if what is being printed is a pointer
  8377. or reference type. @xref{Memory Tagging}.
  8378. A more low-level way of examining data is with the @code{x} command.
  8379. It examines data in memory at a specified address and prints it in a
  8380. specified format. @xref{Memory, ,Examining Memory}.
  8381. If you are interested in information about types, or about how the
  8382. fields of a struct or a class are declared, use the @code{ptype @var{exp}}
  8383. command rather than @code{print}. @xref{Symbols, ,Examining the Symbol
  8384. Table}.
  8385. @cindex exploring hierarchical data structures
  8386. @kindex explore
  8387. Another way of examining values of expressions and type information is
  8388. through the Python extension command @code{explore} (available only if
  8389. the @value{GDBN} build is configured with @code{--with-python}). It
  8390. offers an interactive way to start at the highest level (or, the most
  8391. abstract level) of the data type of an expression (or, the data type
  8392. itself) and explore all the way down to leaf scalar values/fields
  8393. embedded in the higher level data types.
  8394. @table @code
  8395. @item explore @var{arg}
  8396. @var{arg} is either an expression (in the source language), or a type
  8397. visible in the current context of the program being debugged.
  8398. @end table
  8399. The working of the @code{explore} command can be illustrated with an
  8400. example. If a data type @code{struct ComplexStruct} is defined in your
  8401. C program as
  8402. @smallexample
  8403. struct SimpleStruct
  8404. @{
  8405. int i;
  8406. double d;
  8407. @};
  8408. struct ComplexStruct
  8409. @{
  8410. struct SimpleStruct *ss_p;
  8411. int arr[10];
  8412. @};
  8413. @end smallexample
  8414. @noindent
  8415. followed by variable declarations as
  8416. @smallexample
  8417. struct SimpleStruct ss = @{ 10, 1.11 @};
  8418. struct ComplexStruct cs = @{ &ss, @{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 @} @};
  8419. @end smallexample
  8420. @noindent
  8421. then, the value of the variable @code{cs} can be explored using the
  8422. @code{explore} command as follows.
  8423. @smallexample
  8424. (gdb) explore cs
  8425. The value of `cs' is a struct/class of type `struct ComplexStruct' with
  8426. the following fields:
  8427. ss_p = <Enter 0 to explore this field of type `struct SimpleStruct *'>
  8428. arr = <Enter 1 to explore this field of type `int [10]'>
  8429. Enter the field number of choice:
  8430. @end smallexample
  8431. @noindent
  8432. Since the fields of @code{cs} are not scalar values, you are being
  8433. prompted to chose the field you want to explore. Let's say you choose
  8434. the field @code{ss_p} by entering @code{0}. Then, since this field is a
  8435. pointer, you will be asked if it is pointing to a single value. From
  8436. the declaration of @code{cs} above, it is indeed pointing to a single
  8437. value, hence you enter @code{y}. If you enter @code{n}, then you will
  8438. be asked if it were pointing to an array of values, in which case this
  8439. field will be explored as if it were an array.
  8440. @smallexample
  8441. `cs.ss_p' is a pointer to a value of type `struct SimpleStruct'
  8442. Continue exploring it as a pointer to a single value [y/n]: y
  8443. The value of `*(cs.ss_p)' is a struct/class of type `struct
  8444. SimpleStruct' with the following fields:
  8445. i = 10 .. (Value of type `int')
  8446. d = 1.1100000000000001 .. (Value of type `double')
  8447. Press enter to return to parent value:
  8448. @end smallexample
  8449. @noindent
  8450. If the field @code{arr} of @code{cs} was chosen for exploration by
  8451. entering @code{1} earlier, then since it is as array, you will be
  8452. prompted to enter the index of the element in the array that you want
  8453. to explore.
  8454. @smallexample
  8455. `cs.arr' is an array of `int'.
  8456. Enter the index of the element you want to explore in `cs.arr': 5
  8457. `(cs.arr)[5]' is a scalar value of type `int'.
  8458. (cs.arr)[5] = 4
  8459. Press enter to return to parent value:
  8460. @end smallexample
  8461. In general, at any stage of exploration, you can go deeper towards the
  8462. leaf values by responding to the prompts appropriately, or hit the
  8463. return key to return to the enclosing data structure (the @i{higher}
  8464. level data structure).
  8465. Similar to exploring values, you can use the @code{explore} command to
  8466. explore types. Instead of specifying a value (which is typically a
  8467. variable name or an expression valid in the current context of the
  8468. program being debugged), you specify a type name. If you consider the
  8469. same example as above, your can explore the type
  8470. @code{struct ComplexStruct} by passing the argument
  8471. @code{struct ComplexStruct} to the @code{explore} command.
  8472. @smallexample
  8473. (gdb) explore struct ComplexStruct
  8474. @end smallexample
  8475. @noindent
  8476. By responding to the prompts appropriately in the subsequent interactive
  8477. session, you can explore the type @code{struct ComplexStruct} in a
  8478. manner similar to how the value @code{cs} was explored in the above
  8479. example.
  8480. The @code{explore} command also has two sub-commands,
  8481. @code{explore value} and @code{explore type}. The former sub-command is
  8482. a way to explicitly specify that value exploration of the argument is
  8483. being invoked, while the latter is a way to explicitly specify that type
  8484. exploration of the argument is being invoked.
  8485. @table @code
  8486. @item explore value @var{expr}
  8487. @cindex explore value
  8488. This sub-command of @code{explore} explores the value of the
  8489. expression @var{expr} (if @var{expr} is an expression valid in the
  8490. current context of the program being debugged). The behavior of this
  8491. command is identical to that of the behavior of the @code{explore}
  8492. command being passed the argument @var{expr}.
  8493. @item explore type @var{arg}
  8494. @cindex explore type
  8495. This sub-command of @code{explore} explores the type of @var{arg} (if
  8496. @var{arg} is a type visible in the current context of program being
  8497. debugged), or the type of the value/expression @var{arg} (if @var{arg}
  8498. is an expression valid in the current context of the program being
  8499. debugged). If @var{arg} is a type, then the behavior of this command is
  8500. identical to that of the @code{explore} command being passed the
  8501. argument @var{arg}. If @var{arg} is an expression, then the behavior of
  8502. this command will be identical to that of the @code{explore} command
  8503. being passed the type of @var{arg} as the argument.
  8504. @end table
  8505. @menu
  8506. * Expressions:: Expressions
  8507. * Ambiguous Expressions:: Ambiguous Expressions
  8508. * Variables:: Program variables
  8509. * Arrays:: Artificial arrays
  8510. * Output Formats:: Output formats
  8511. * Memory:: Examining memory
  8512. * Memory Tagging:: Memory Tagging
  8513. * Auto Display:: Automatic display
  8514. * Print Settings:: Print settings
  8515. * Pretty Printing:: Python pretty printing
  8516. * Value History:: Value history
  8517. * Convenience Vars:: Convenience variables
  8518. * Convenience Funs:: Convenience functions
  8519. * Registers:: Registers
  8520. * Floating Point Hardware:: Floating point hardware
  8521. * Vector Unit:: Vector Unit
  8522. * OS Information:: Auxiliary data provided by operating system
  8523. * Memory Region Attributes:: Memory region attributes
  8524. * Dump/Restore Files:: Copy between memory and a file
  8525. * Core File Generation:: Cause a program dump its core
  8526. * Character Sets:: Debugging programs that use a different
  8527. character set than GDB does
  8528. * Caching Target Data:: Data caching for targets
  8529. * Searching Memory:: Searching memory for a sequence of bytes
  8530. * Value Sizes:: Managing memory allocated for values
  8531. @end menu
  8532. @node Expressions
  8533. @section Expressions
  8534. @cindex expressions
  8535. @code{print} and many other @value{GDBN} commands accept an expression and
  8536. compute its value. Any kind of constant, variable or operator defined
  8537. by the programming language you are using is valid in an expression in
  8538. @value{GDBN}. This includes conditional expressions, function calls,
  8539. casts, and string constants. It also includes preprocessor macros, if
  8540. you compiled your program to include this information; see
  8541. @ref{Compilation}.
  8542. @cindex arrays in expressions
  8543. @value{GDBN} supports array constants in expressions input by
  8544. the user. The syntax is @{@var{element}, @var{element}@dots{}@}. For example,
  8545. you can use the command @code{print @{1, 2, 3@}} to create an array
  8546. of three integers. If you pass an array to a function or assign it
  8547. to a program variable, @value{GDBN} copies the array to memory that
  8548. is @code{malloc}ed in the target program.
  8549. Because C is so widespread, most of the expressions shown in examples in
  8550. this manual are in C. @xref{Languages, , Using @value{GDBN} with Different
  8551. Languages}, for information on how to use expressions in other
  8552. languages.
  8553. In this section, we discuss operators that you can use in @value{GDBN}
  8554. expressions regardless of your programming language.
  8555. @cindex casts, in expressions
  8556. Casts are supported in all languages, not just in C, because it is so
  8557. useful to cast a number into a pointer in order to examine a structure
  8558. at that address in memory.
  8559. @c FIXME: casts supported---Mod2 true?
  8560. @value{GDBN} supports these operators, in addition to those common
  8561. to programming languages:
  8562. @table @code
  8563. @item @@
  8564. @samp{@@} is a binary operator for treating parts of memory as arrays.
  8565. @xref{Arrays, ,Artificial Arrays}, for more information.
  8566. @item ::
  8567. @samp{::} allows you to specify a variable in terms of the file or
  8568. function where it is defined. @xref{Variables, ,Program Variables}.
  8569. @cindex @{@var{type}@}
  8570. @cindex type casting memory
  8571. @cindex memory, viewing as typed object
  8572. @cindex casts, to view memory
  8573. @item @{@var{type}@} @var{addr}
  8574. Refers to an object of type @var{type} stored at address @var{addr} in
  8575. memory. The address @var{addr} may be any expression whose value is
  8576. an integer or pointer (but parentheses are required around binary
  8577. operators, just as in a cast). This construct is allowed regardless
  8578. of what kind of data is normally supposed to reside at @var{addr}.
  8579. @end table
  8580. @node Ambiguous Expressions
  8581. @section Ambiguous Expressions
  8582. @cindex ambiguous expressions
  8583. Expressions can sometimes contain some ambiguous elements. For instance,
  8584. some programming languages (notably Ada, C@t{++} and Objective-C) permit
  8585. a single function name to be defined several times, for application in
  8586. different contexts. This is called @dfn{overloading}. Another example
  8587. involving Ada is generics. A @dfn{generic package} is similar to C@t{++}
  8588. templates and is typically instantiated several times, resulting in
  8589. the same function name being defined in different contexts.
  8590. In some cases and depending on the language, it is possible to adjust
  8591. the expression to remove the ambiguity. For instance in C@t{++}, you
  8592. can specify the signature of the function you want to break on, as in
  8593. @kbd{break @var{function}(@var{types})}. In Ada, using the fully
  8594. qualified name of your function often makes the expression unambiguous
  8595. as well.
  8596. When an ambiguity that needs to be resolved is detected, the debugger
  8597. has the capability to display a menu of numbered choices for each
  8598. possibility, and then waits for the selection with the prompt @samp{>}.
  8599. The first option is always @samp{[0] cancel}, and typing @kbd{0 @key{RET}}
  8600. aborts the current command. If the command in which the expression was
  8601. used allows more than one choice to be selected, the next option in the
  8602. menu is @samp{[1] all}, and typing @kbd{1 @key{RET}} selects all possible
  8603. choices.
  8604. For example, the following session excerpt shows an attempt to set a
  8605. breakpoint at the overloaded symbol @code{String::after}.
  8606. We choose three particular definitions of that function name:
  8607. @c FIXME! This is likely to change to show arg type lists, at least
  8608. @smallexample
  8609. @group
  8610. (@value{GDBP}) b String::after
  8611. [0] cancel
  8612. [1] all
  8613. [2] file:String.cc; line number:867
  8614. [3] file:String.cc; line number:860
  8615. [4] file:String.cc; line number:875
  8616. [5] file:String.cc; line number:853
  8617. [6] file:String.cc; line number:846
  8618. [7] file:String.cc; line number:735
  8619. > 2 4 6
  8620. Breakpoint 1 at 0xb26c: file String.cc, line 867.
  8621. Breakpoint 2 at 0xb344: file String.cc, line 875.
  8622. Breakpoint 3 at 0xafcc: file String.cc, line 846.
  8623. Multiple breakpoints were set.
  8624. Use the "delete" command to delete unwanted
  8625. breakpoints.
  8626. (@value{GDBP})
  8627. @end group
  8628. @end smallexample
  8629. @table @code
  8630. @kindex set multiple-symbols
  8631. @item set multiple-symbols @var{mode}
  8632. @cindex multiple-symbols menu
  8633. This option allows you to adjust the debugger behavior when an expression
  8634. is ambiguous.
  8635. By default, @var{mode} is set to @code{all}. If the command with which
  8636. the expression is used allows more than one choice, then @value{GDBN}
  8637. automatically selects all possible choices. For instance, inserting
  8638. a breakpoint on a function using an ambiguous name results in a breakpoint
  8639. inserted on each possible match. However, if a unique choice must be made,
  8640. then @value{GDBN} uses the menu to help you disambiguate the expression.
  8641. For instance, printing the address of an overloaded function will result
  8642. in the use of the menu.
  8643. When @var{mode} is set to @code{ask}, the debugger always uses the menu
  8644. when an ambiguity is detected.
  8645. Finally, when @var{mode} is set to @code{cancel}, the debugger reports
  8646. an error due to the ambiguity and the command is aborted.
  8647. @kindex show multiple-symbols
  8648. @item show multiple-symbols
  8649. Show the current value of the @code{multiple-symbols} setting.
  8650. @end table
  8651. @node Variables
  8652. @section Program Variables
  8653. The most common kind of expression to use is the name of a variable
  8654. in your program.
  8655. Variables in expressions are understood in the selected stack frame
  8656. (@pxref{Selection, ,Selecting a Frame}); they must be either:
  8657. @itemize @bullet
  8658. @item
  8659. global (or file-static)
  8660. @end itemize
  8661. @noindent or
  8662. @itemize @bullet
  8663. @item
  8664. visible according to the scope rules of the
  8665. programming language from the point of execution in that frame
  8666. @end itemize
  8667. @noindent This means that in the function
  8668. @smallexample
  8669. foo (a)
  8670. int a;
  8671. @{
  8672. bar (a);
  8673. @{
  8674. int b = test ();
  8675. bar (b);
  8676. @}
  8677. @}
  8678. @end smallexample
  8679. @noindent
  8680. you can examine and use the variable @code{a} whenever your program is
  8681. executing within the function @code{foo}, but you can only use or
  8682. examine the variable @code{b} while your program is executing inside
  8683. the block where @code{b} is declared.
  8684. @cindex variable name conflict
  8685. There is an exception: you can refer to a variable or function whose
  8686. scope is a single source file even if the current execution point is not
  8687. in this file. But it is possible to have more than one such variable or
  8688. function with the same name (in different source files). If that
  8689. happens, referring to that name has unpredictable effects. If you wish,
  8690. you can specify a static variable in a particular function or file by
  8691. using the colon-colon (@code{::}) notation:
  8692. @cindex colon-colon, context for variables/functions
  8693. @ifnotinfo
  8694. @c info cannot cope with a :: index entry, but why deprive hard copy readers?
  8695. @cindex @code{::}, context for variables/functions
  8696. @end ifnotinfo
  8697. @smallexample
  8698. @var{file}::@var{variable}
  8699. @var{function}::@var{variable}
  8700. @end smallexample
  8701. @noindent
  8702. Here @var{file} or @var{function} is the name of the context for the
  8703. static @var{variable}. In the case of file names, you can use quotes to
  8704. make sure @value{GDBN} parses the file name as a single word---for example,
  8705. to print a global value of @code{x} defined in @file{f2.c}:
  8706. @smallexample
  8707. (@value{GDBP}) p 'f2.c'::x
  8708. @end smallexample
  8709. The @code{::} notation is normally used for referring to
  8710. static variables, since you typically disambiguate uses of local variables
  8711. in functions by selecting the appropriate frame and using the
  8712. simple name of the variable. However, you may also use this notation
  8713. to refer to local variables in frames enclosing the selected frame:
  8714. @smallexample
  8715. void
  8716. foo (int a)
  8717. @{
  8718. if (a < 10)
  8719. bar (a);
  8720. else
  8721. process (a); /* Stop here */
  8722. @}
  8723. int
  8724. bar (int a)
  8725. @{
  8726. foo (a + 5);
  8727. @}
  8728. @end smallexample
  8729. @noindent
  8730. For example, if there is a breakpoint at the commented line,
  8731. here is what you might see
  8732. when the program stops after executing the call @code{bar(0)}:
  8733. @smallexample
  8734. (@value{GDBP}) p a
  8735. $1 = 10
  8736. (@value{GDBP}) p bar::a
  8737. $2 = 5
  8738. (@value{GDBP}) up 2
  8739. #2 0x080483d0 in foo (a=5) at foobar.c:12
  8740. (@value{GDBP}) p a
  8741. $3 = 5
  8742. (@value{GDBP}) p bar::a
  8743. $4 = 0
  8744. @end smallexample
  8745. @cindex C@t{++} scope resolution
  8746. These uses of @samp{::} are very rarely in conflict with the very
  8747. similar use of the same notation in C@t{++}. When they are in
  8748. conflict, the C@t{++} meaning takes precedence; however, this can be
  8749. overridden by quoting the file or function name with single quotes.
  8750. For example, suppose the program is stopped in a method of a class
  8751. that has a field named @code{includefile}, and there is also an
  8752. include file named @file{includefile} that defines a variable,
  8753. @code{some_global}.
  8754. @smallexample
  8755. (@value{GDBP}) p includefile
  8756. $1 = 23
  8757. (@value{GDBP}) p includefile::some_global
  8758. A syntax error in expression, near `'.
  8759. (@value{GDBP}) p 'includefile'::some_global
  8760. $2 = 27
  8761. @end smallexample
  8762. @cindex wrong values
  8763. @cindex variable values, wrong
  8764. @cindex function entry/exit, wrong values of variables
  8765. @cindex optimized code, wrong values of variables
  8766. @quotation
  8767. @emph{Warning:} Occasionally, a local variable may appear to have the
  8768. wrong value at certain points in a function---just after entry to a new
  8769. scope, and just before exit.
  8770. @end quotation
  8771. You may see this problem when you are stepping by machine instructions.
  8772. This is because, on most machines, it takes more than one instruction to
  8773. set up a stack frame (including local variable definitions); if you are
  8774. stepping by machine instructions, variables may appear to have the wrong
  8775. values until the stack frame is completely built. On exit, it usually
  8776. also takes more than one machine instruction to destroy a stack frame;
  8777. after you begin stepping through that group of instructions, local
  8778. variable definitions may be gone.
  8779. This may also happen when the compiler does significant optimizations.
  8780. To be sure of always seeing accurate values, turn off all optimization
  8781. when compiling.
  8782. @cindex ``No symbol "foo" in current context''
  8783. Another possible effect of compiler optimizations is to optimize
  8784. unused variables out of existence, or assign variables to registers (as
  8785. opposed to memory addresses). Depending on the support for such cases
  8786. offered by the debug info format used by the compiler, @value{GDBN}
  8787. might not be able to display values for such local variables. If that
  8788. happens, @value{GDBN} will print a message like this:
  8789. @smallexample
  8790. No symbol "foo" in current context.
  8791. @end smallexample
  8792. To solve such problems, either recompile without optimizations, or use a
  8793. different debug info format, if the compiler supports several such
  8794. formats. @xref{Compilation}, for more information on choosing compiler
  8795. options. @xref{C, ,C and C@t{++}}, for more information about debug
  8796. info formats that are best suited to C@t{++} programs.
  8797. If you ask to print an object whose contents are unknown to
  8798. @value{GDBN}, e.g., because its data type is not completely specified
  8799. by the debug information, @value{GDBN} will say @samp{<incomplete
  8800. type>}. @xref{Symbols, incomplete type}, for more about this.
  8801. @cindex no debug info variables
  8802. If you try to examine or use the value of a (global) variable for
  8803. which @value{GDBN} has no type information, e.g., because the program
  8804. includes no debug information, @value{GDBN} displays an error message.
  8805. @xref{Symbols, unknown type}, for more about unknown types. If you
  8806. cast the variable to its declared type, @value{GDBN} gets the
  8807. variable's value using the cast-to type as the variable's type. For
  8808. example, in a C program:
  8809. @smallexample
  8810. (@value{GDBP}) p var
  8811. 'var' has unknown type; cast it to its declared type
  8812. (@value{GDBP}) p (float) var
  8813. $1 = 3.14
  8814. @end smallexample
  8815. If you append @kbd{@@entry} string to a function parameter name you get its
  8816. value at the time the function got called. If the value is not available an
  8817. error message is printed. Entry values are available only with some compilers.
  8818. Entry values are normally also printed at the function parameter list according
  8819. to @ref{set print entry-values}.
  8820. @smallexample
  8821. Breakpoint 1, d (i=30) at gdb.base/entry-value.c:29
  8822. 29 i++;
  8823. (gdb) next
  8824. 30 e (i);
  8825. (gdb) print i
  8826. $1 = 31
  8827. (gdb) print i@@entry
  8828. $2 = 30
  8829. @end smallexample
  8830. Strings are identified as arrays of @code{char} values without specified
  8831. signedness. Arrays of either @code{signed char} or @code{unsigned char} get
  8832. printed as arrays of 1 byte sized integers. @code{-fsigned-char} or
  8833. @code{-funsigned-char} @value{NGCC} options have no effect as @value{GDBN}
  8834. defines literal string type @code{"char"} as @code{char} without a sign.
  8835. For program code
  8836. @smallexample
  8837. char var0[] = "A";
  8838. signed char var1[] = "A";
  8839. @end smallexample
  8840. You get during debugging
  8841. @smallexample
  8842. (gdb) print var0
  8843. $1 = "A"
  8844. (gdb) print var1
  8845. $2 = @{65 'A', 0 '\0'@}
  8846. @end smallexample
  8847. @node Arrays
  8848. @section Artificial Arrays
  8849. @cindex artificial array
  8850. @cindex arrays
  8851. @kindex @@@r{, referencing memory as an array}
  8852. It is often useful to print out several successive objects of the
  8853. same type in memory; a section of an array, or an array of
  8854. dynamically determined size for which only a pointer exists in the
  8855. program.
  8856. You can do this by referring to a contiguous span of memory as an
  8857. @dfn{artificial array}, using the binary operator @samp{@@}. The left
  8858. operand of @samp{@@} should be the first element of the desired array
  8859. and be an individual object. The right operand should be the desired length
  8860. of the array. The result is an array value whose elements are all of
  8861. the type of the left argument. The first element is actually the left
  8862. argument; the second element comes from bytes of memory immediately
  8863. following those that hold the first element, and so on. Here is an
  8864. example. If a program says
  8865. @smallexample
  8866. int *array = (int *) malloc (len * sizeof (int));
  8867. @end smallexample
  8868. @noindent
  8869. you can print the contents of @code{array} with
  8870. @smallexample
  8871. p *array@@len
  8872. @end smallexample
  8873. The left operand of @samp{@@} must reside in memory. Array values made
  8874. with @samp{@@} in this way behave just like other arrays in terms of
  8875. subscripting, and are coerced to pointers when used in expressions.
  8876. Artificial arrays most often appear in expressions via the value history
  8877. (@pxref{Value History, ,Value History}), after printing one out.
  8878. Another way to create an artificial array is to use a cast.
  8879. This re-interprets a value as if it were an array.
  8880. The value need not be in memory:
  8881. @smallexample
  8882. (@value{GDBP}) p/x (short[2])0x12345678
  8883. $1 = @{0x1234, 0x5678@}
  8884. @end smallexample
  8885. As a convenience, if you leave the array length out (as in
  8886. @samp{(@var{type}[])@var{value}}) @value{GDBN} calculates the size to fill
  8887. the value (as @samp{sizeof(@var{value})/sizeof(@var{type})}:
  8888. @smallexample
  8889. (@value{GDBP}) p/x (short[])0x12345678
  8890. $2 = @{0x1234, 0x5678@}
  8891. @end smallexample
  8892. Sometimes the artificial array mechanism is not quite enough; in
  8893. moderately complex data structures, the elements of interest may not
  8894. actually be adjacent---for example, if you are interested in the values
  8895. of pointers in an array. One useful work-around in this situation is
  8896. to use a convenience variable (@pxref{Convenience Vars, ,Convenience
  8897. Variables}) as a counter in an expression that prints the first
  8898. interesting value, and then repeat that expression via @key{RET}. For
  8899. instance, suppose you have an array @code{dtab} of pointers to
  8900. structures, and you are interested in the values of a field @code{fv}
  8901. in each structure. Here is an example of what you might type:
  8902. @smallexample
  8903. set $i = 0
  8904. p dtab[$i++]->fv
  8905. @key{RET}
  8906. @key{RET}
  8907. @dots{}
  8908. @end smallexample
  8909. @node Output Formats
  8910. @section Output Formats
  8911. @cindex formatted output
  8912. @cindex output formats
  8913. By default, @value{GDBN} prints a value according to its data type. Sometimes
  8914. this is not what you want. For example, you might want to print a number
  8915. in hex, or a pointer in decimal. Or you might want to view data in memory
  8916. at a certain address as a character string or as an instruction. To do
  8917. these things, specify an @dfn{output format} when you print a value.
  8918. The simplest use of output formats is to say how to print a value
  8919. already computed. This is done by starting the arguments of the
  8920. @code{print} command with a slash and a format letter. The format
  8921. letters supported are:
  8922. @table @code
  8923. @item x
  8924. Print the binary representation of the value in hexadecimal.
  8925. @item d
  8926. Print the binary representation of the value in decimal.
  8927. @item u
  8928. Print the binary representation of the value as an decimal, as if it
  8929. were unsigned.
  8930. @item o
  8931. Print the binary representation of the value in octal.
  8932. @item t
  8933. Print the binary representation of the value in binary. The letter
  8934. @samp{t} stands for ``two''. @footnote{@samp{b} cannot be used
  8935. because these format letters are also used with the @code{x} command,
  8936. where @samp{b} stands for ``byte''; see @ref{Memory,,Examining
  8937. Memory}.}
  8938. @item a
  8939. @cindex unknown address, locating
  8940. @cindex locate address
  8941. Print as an address, both absolute in hexadecimal and as an offset from
  8942. the nearest preceding symbol. You can use this format used to discover
  8943. where (in what function) an unknown address is located:
  8944. @smallexample
  8945. (@value{GDBP}) p/a 0x54320
  8946. $3 = 0x54320 <_initialize_vx+396>
  8947. @end smallexample
  8948. @noindent
  8949. The command @code{info symbol 0x54320} yields similar results.
  8950. @xref{Symbols, info symbol}.
  8951. @item c
  8952. Cast the value to an integer (unlike other formats, this does not just
  8953. reinterpret the underlying bits) and print it as a character constant.
  8954. This prints both the numerical value and its character representation.
  8955. The character representation is replaced with the octal escape
  8956. @samp{\nnn} for characters outside the 7-bit @sc{ascii} range.
  8957. Without this format, @value{GDBN} displays @code{char},
  8958. @w{@code{unsigned char}}, and @w{@code{signed char}} data as character
  8959. constants. Single-byte members of vectors are displayed as integer
  8960. data.
  8961. @item f
  8962. Regard the bits of the value as a floating point number and print
  8963. using typical floating point syntax.
  8964. @item s
  8965. @cindex printing strings
  8966. @cindex printing byte arrays
  8967. Regard as a string, if possible. With this format, pointers to single-byte
  8968. data are displayed as null-terminated strings and arrays of single-byte data
  8969. are displayed as fixed-length strings. Other values are displayed in their
  8970. natural types.
  8971. Without this format, @value{GDBN} displays pointers to and arrays of
  8972. @code{char}, @w{@code{unsigned char}}, and @w{@code{signed char}} as
  8973. strings. Single-byte members of a vector are displayed as an integer
  8974. array.
  8975. @item z
  8976. Like @samp{x} formatting, the value is treated as an integer and
  8977. printed as hexadecimal, but leading zeros are printed to pad the value
  8978. to the size of the integer type.
  8979. @item r
  8980. @cindex raw printing
  8981. Print using the @samp{raw} formatting. By default, @value{GDBN} will
  8982. use a Python-based pretty-printer, if one is available (@pxref{Pretty
  8983. Printing}). This typically results in a higher-level display of the
  8984. value's contents. The @samp{r} format bypasses any Python
  8985. pretty-printer which might exist.
  8986. @end table
  8987. For example, to print the program counter in hex (@pxref{Registers}), type
  8988. @smallexample
  8989. p/x $pc
  8990. @end smallexample
  8991. @noindent
  8992. Note that no space is required before the slash; this is because command
  8993. names in @value{GDBN} cannot contain a slash.
  8994. To reprint the last value in the value history with a different format,
  8995. you can use the @code{print} command with just a format and no
  8996. expression. For example, @samp{p/x} reprints the last value in hex.
  8997. @node Memory
  8998. @section Examining Memory
  8999. You can use the command @code{x} (for ``examine'') to examine memory in
  9000. any of several formats, independently of your program's data types.
  9001. @cindex examining memory
  9002. @table @code
  9003. @kindex x @r{(examine memory)}
  9004. @item x/@var{nfu} @var{addr}
  9005. @itemx x @var{addr}
  9006. @itemx x
  9007. Use the @code{x} command to examine memory.
  9008. @end table
  9009. @var{n}, @var{f}, and @var{u} are all optional parameters that specify how
  9010. much memory to display and how to format it; @var{addr} is an
  9011. expression giving the address where you want to start displaying memory.
  9012. If you use defaults for @var{nfu}, you need not type the slash @samp{/}.
  9013. Several commands set convenient defaults for @var{addr}.
  9014. @table @r
  9015. @item @var{n}, the repeat count
  9016. The repeat count is a decimal integer; the default is 1. It specifies
  9017. how much memory (counting by units @var{u}) to display. If a negative
  9018. number is specified, memory is examined backward from @var{addr}.
  9019. @c This really is **decimal**; unaffected by 'set radix' as of GDB
  9020. @c 4.1.2.
  9021. @item @var{f}, the display format
  9022. The display format is one of the formats used by @code{print}
  9023. (@samp{x}, @samp{d}, @samp{u}, @samp{o}, @samp{t}, @samp{a}, @samp{c},
  9024. @samp{f}, @samp{s}), @samp{i} (for machine instructions) and
  9025. @samp{m} (for displaying memory tags).
  9026. The default is @samp{x} (hexadecimal) initially. The default changes
  9027. each time you use either @code{x} or @code{print}.
  9028. @item @var{u}, the unit size
  9029. The unit size is any of
  9030. @table @code
  9031. @item b
  9032. Bytes.
  9033. @item h
  9034. Halfwords (two bytes).
  9035. @item w
  9036. Words (four bytes). This is the initial default.
  9037. @item g
  9038. Giant words (eight bytes).
  9039. @end table
  9040. Each time you specify a unit size with @code{x}, that size becomes the
  9041. default unit the next time you use @code{x}. For the @samp{i} format,
  9042. the unit size is ignored and is normally not written. For the @samp{s} format,
  9043. the unit size defaults to @samp{b}, unless it is explicitly given.
  9044. Use @kbd{x /hs} to display 16-bit char strings and @kbd{x /ws} to display
  9045. 32-bit strings. The next use of @kbd{x /s} will again display 8-bit strings.
  9046. Note that the results depend on the programming language of the
  9047. current compilation unit. If the language is C, the @samp{s}
  9048. modifier will use the UTF-16 encoding while @samp{w} will use
  9049. UTF-32. The encoding is set by the programming language and cannot
  9050. be altered.
  9051. @item @var{addr}, starting display address
  9052. @var{addr} is the address where you want @value{GDBN} to begin displaying
  9053. memory. The expression need not have a pointer value (though it may);
  9054. it is always interpreted as an integer address of a byte of memory.
  9055. @xref{Expressions, ,Expressions}, for more information on expressions. The default for
  9056. @var{addr} is usually just after the last address examined---but several
  9057. other commands also set the default address: @code{info breakpoints} (to
  9058. the address of the last breakpoint listed), @code{info line} (to the
  9059. starting address of a line), and @code{print} (if you use it to display
  9060. a value from memory).
  9061. @end table
  9062. For example, @samp{x/3uh 0x54320} is a request to display three halfwords
  9063. (@code{h}) of memory, formatted as unsigned decimal integers (@samp{u}),
  9064. starting at address @code{0x54320}. @samp{x/4xw $sp} prints the four
  9065. words (@samp{w}) of memory above the stack pointer (here, @samp{$sp};
  9066. @pxref{Registers, ,Registers}) in hexadecimal (@samp{x}).
  9067. You can also specify a negative repeat count to examine memory backward
  9068. from the given address. For example, @samp{x/-3uh 0x54320} prints three
  9069. halfwords (@code{h}) at @code{0x5431a}, @code{0x5431c}, and @code{0x5431e}.
  9070. Since the letters indicating unit sizes are all distinct from the
  9071. letters specifying output formats, you do not have to remember whether
  9072. unit size or format comes first; either order works. The output
  9073. specifications @samp{4xw} and @samp{4wx} mean exactly the same thing.
  9074. (However, the count @var{n} must come first; @samp{wx4} does not work.)
  9075. Even though the unit size @var{u} is ignored for the formats @samp{s}
  9076. and @samp{i}, you might still want to use a count @var{n}; for example,
  9077. @samp{3i} specifies that you want to see three machine instructions,
  9078. including any operands. For convenience, especially when used with
  9079. the @code{display} command, the @samp{i} format also prints branch delay
  9080. slot instructions, if any, beyond the count specified, which immediately
  9081. follow the last instruction that is within the count. The command
  9082. @code{disassemble} gives an alternative way of inspecting machine
  9083. instructions; see @ref{Machine Code,,Source and Machine Code}.
  9084. If a negative repeat count is specified for the formats @samp{s} or @samp{i},
  9085. the command displays null-terminated strings or instructions before the given
  9086. address as many as the absolute value of the given number. For the @samp{i}
  9087. format, we use line number information in the debug info to accurately locate
  9088. instruction boundaries while disassembling backward. If line info is not
  9089. available, the command stops examining memory with an error message.
  9090. All the defaults for the arguments to @code{x} are designed to make it
  9091. easy to continue scanning memory with minimal specifications each time
  9092. you use @code{x}. For example, after you have inspected three machine
  9093. instructions with @samp{x/3i @var{addr}}, you can inspect the next seven
  9094. with just @samp{x/7}. If you use @key{RET} to repeat the @code{x} command,
  9095. the repeat count @var{n} is used again; the other arguments default as
  9096. for successive uses of @code{x}.
  9097. When examining machine instructions, the instruction at current program
  9098. counter is shown with a @code{=>} marker. For example:
  9099. @smallexample
  9100. (@value{GDBP}) x/5i $pc-6
  9101. 0x804837f <main+11>: mov %esp,%ebp
  9102. 0x8048381 <main+13>: push %ecx
  9103. 0x8048382 <main+14>: sub $0x4,%esp
  9104. => 0x8048385 <main+17>: movl $0x8048460,(%esp)
  9105. 0x804838c <main+24>: call 0x80482d4 <puts@@plt>
  9106. @end smallexample
  9107. If the architecture supports memory tagging, the tags can be displayed by
  9108. using @samp{m}. @xref{Memory Tagging}.
  9109. The information will be displayed once per granule size
  9110. (the amount of bytes a particular memory tag covers). For example, AArch64
  9111. has a granule size of 16 bytes, so it will display a tag every 16 bytes.
  9112. Due to the way @value{GDBN} prints information with the @code{x} command (not
  9113. aligned to a particular boundary), the tag information will refer to the
  9114. initial address displayed on a particular line. If a memory tag boundary
  9115. is crossed in the middle of a line displayed by the @code{x} command, it
  9116. will be displayed on the next line.
  9117. The @samp{m} format doesn't affect any other specified formats that were
  9118. passed to the @code{x} command.
  9119. @cindex @code{$_}, @code{$__}, and value history
  9120. The addresses and contents printed by the @code{x} command are not saved
  9121. in the value history because there is often too much of them and they
  9122. would get in the way. Instead, @value{GDBN} makes these values available for
  9123. subsequent use in expressions as values of the convenience variables
  9124. @code{$_} and @code{$__}. After an @code{x} command, the last address
  9125. examined is available for use in expressions in the convenience variable
  9126. @code{$_}. The contents of that address, as examined, are available in
  9127. the convenience variable @code{$__}.
  9128. If the @code{x} command has a repeat count, the address and contents saved
  9129. are from the last memory unit printed; this is not the same as the last
  9130. address printed if several units were printed on the last line of output.
  9131. @anchor{addressable memory unit}
  9132. @cindex addressable memory unit
  9133. Most targets have an addressable memory unit size of 8 bits. This means
  9134. that to each memory address are associated 8 bits of data. Some
  9135. targets, however, have other addressable memory unit sizes.
  9136. Within @value{GDBN} and this document, the term
  9137. @dfn{addressable memory unit} (or @dfn{memory unit} for short) is used
  9138. when explicitly referring to a chunk of data of that size. The word
  9139. @dfn{byte} is used to refer to a chunk of data of 8 bits, regardless of
  9140. the addressable memory unit size of the target. For most systems,
  9141. addressable memory unit is a synonym of byte.
  9142. @cindex remote memory comparison
  9143. @cindex target memory comparison
  9144. @cindex verify remote memory image
  9145. @cindex verify target memory image
  9146. When you are debugging a program running on a remote target machine
  9147. (@pxref{Remote Debugging}), you may wish to verify the program's image
  9148. in the remote machine's memory against the executable file you
  9149. downloaded to the target. Or, on any target, you may want to check
  9150. whether the program has corrupted its own read-only sections. The
  9151. @code{compare-sections} command is provided for such situations.
  9152. @table @code
  9153. @kindex compare-sections
  9154. @item compare-sections @r{[}@var{section-name}@r{|}@code{-r}@r{]}
  9155. Compare the data of a loadable section @var{section-name} in the
  9156. executable file of the program being debugged with the same section in
  9157. the target machine's memory, and report any mismatches. With no
  9158. arguments, compares all loadable sections. With an argument of
  9159. @code{-r}, compares all loadable read-only sections.
  9160. Note: for remote targets, this command can be accelerated if the
  9161. target supports computing the CRC checksum of a block of memory
  9162. (@pxref{qCRC packet}).
  9163. @end table
  9164. @node Memory Tagging
  9165. @section Memory Tagging
  9166. Memory tagging is a memory protection technology that uses a pair of tags to
  9167. validate memory accesses through pointers. The tags are integer values
  9168. usually comprised of a few bits, depending on the architecture.
  9169. There are two types of tags that are used in this setup: logical and
  9170. allocation. A logical tag is stored in the pointers themselves, usually at the
  9171. higher bits of the pointers. An allocation tag is the tag associated
  9172. with particular ranges of memory in the physical address space, against which
  9173. the logical tags from pointers are compared.
  9174. The pointer tag (logical tag) must match the memory tag (allocation tag)
  9175. for the memory access to be valid. If the logical tag does not match the
  9176. allocation tag, that will raise a memory violation.
  9177. Allocation tags cover multiple contiguous bytes of physical memory. This
  9178. range of bytes is called a memory tag granule and is architecture-specific.
  9179. For example, AArch64 has a tag granule of 16 bytes, meaning each allocation
  9180. tag spans 16 bytes of memory.
  9181. If the underlying architecture supports memory tagging, like AArch64 MTE
  9182. or SPARC ADI do, @value{GDBN} can make use of it to validate pointers
  9183. against memory allocation tags.
  9184. The @code{print} (@pxref{Data}) and @code{x} (@pxref{Memory}) commands will
  9185. display tag information when appropriate, and a command prefix of
  9186. @code{memory-tag} gives access to the various memory tagging commands.
  9187. The @code{memory-tag} commands are the following:
  9188. @table @code
  9189. @kindex memory-tag print-logical-tag
  9190. @item memory-tag print-logical-tag @var{pointer_expression}
  9191. Print the logical tag stored in @var{pointer_expression}.
  9192. @kindex memory-tag with-logical-tag
  9193. @item memory-tag with-logical-tag @var{pointer_expression} @var{tag_bytes}
  9194. Print the pointer given by @var{pointer_expression}, augmented with a logical
  9195. tag of @var{tag_bytes}.
  9196. @kindex memory-tag print-allocation-tag
  9197. @item memory-tag print-allocation-tag @var{address_expression}
  9198. Print the allocation tag associated with the memory address given by
  9199. @var{address_expression}.
  9200. @kindex memory-tag setatag
  9201. @item memory-tag setatag @var{starting_address} @var{length} @var{tag_bytes}
  9202. Set the allocation tag(s) for memory range @r{[}@var{starting_address},
  9203. @var{starting_address} + @var{length}@r{)} to @var{tag_bytes}.
  9204. @kindex memory-tag check
  9205. @item memory-tag check @var{pointer_expression}
  9206. Check if the logical tag in the pointer given by @var{pointer_expression}
  9207. matches the allocation tag for the memory referenced by the pointer.
  9208. This essentially emulates the hardware validation that is done when tagged
  9209. memory is accessed through a pointer, but does not cause a memory fault as
  9210. it would during hardware validation.
  9211. It can be used to inspect potential memory tagging violations in the running
  9212. process, before any faults get triggered.
  9213. @end table
  9214. @node Auto Display
  9215. @section Automatic Display
  9216. @cindex automatic display
  9217. @cindex display of expressions
  9218. If you find that you want to print the value of an expression frequently
  9219. (to see how it changes), you might want to add it to the @dfn{automatic
  9220. display list} so that @value{GDBN} prints its value each time your program stops.
  9221. Each expression added to the list is given a number to identify it;
  9222. to remove an expression from the list, you specify that number.
  9223. The automatic display looks like this:
  9224. @smallexample
  9225. 2: foo = 38
  9226. 3: bar[5] = (struct hack *) 0x3804
  9227. @end smallexample
  9228. @noindent
  9229. This display shows item numbers, expressions and their current values. As with
  9230. displays you request manually using @code{x} or @code{print}, you can
  9231. specify the output format you prefer; in fact, @code{display} decides
  9232. whether to use @code{print} or @code{x} depending your format
  9233. specification---it uses @code{x} if you specify either the @samp{i}
  9234. or @samp{s} format, or a unit size; otherwise it uses @code{print}.
  9235. @table @code
  9236. @kindex display
  9237. @item display @var{expr}
  9238. Add the expression @var{expr} to the list of expressions to display
  9239. each time your program stops. @xref{Expressions, ,Expressions}.
  9240. @code{display} does not repeat if you press @key{RET} again after using it.
  9241. @item display/@var{fmt} @var{expr}
  9242. For @var{fmt} specifying only a display format and not a size or
  9243. count, add the expression @var{expr} to the auto-display list but
  9244. arrange to display it each time in the specified format @var{fmt}.
  9245. @xref{Output Formats,,Output Formats}.
  9246. @item display/@var{fmt} @var{addr}
  9247. For @var{fmt} @samp{i} or @samp{s}, or including a unit-size or a
  9248. number of units, add the expression @var{addr} as a memory address to
  9249. be examined each time your program stops. Examining means in effect
  9250. doing @samp{x/@var{fmt} @var{addr}}. @xref{Memory, ,Examining Memory}.
  9251. @end table
  9252. For example, @samp{display/i $pc} can be helpful, to see the machine
  9253. instruction about to be executed each time execution stops (@samp{$pc}
  9254. is a common name for the program counter; @pxref{Registers, ,Registers}).
  9255. @table @code
  9256. @kindex delete display
  9257. @kindex undisplay
  9258. @item undisplay @var{dnums}@dots{}
  9259. @itemx delete display @var{dnums}@dots{}
  9260. Remove items from the list of expressions to display. Specify the
  9261. numbers of the displays that you want affected with the command
  9262. argument @var{dnums}. It can be a single display number, one of the
  9263. numbers shown in the first field of the @samp{info display} display;
  9264. or it could be a range of display numbers, as in @code{2-4}.
  9265. @code{undisplay} does not repeat if you press @key{RET} after using it.
  9266. (Otherwise you would just get the error @samp{No display number @dots{}}.)
  9267. @kindex disable display
  9268. @item disable display @var{dnums}@dots{}
  9269. Disable the display of item numbers @var{dnums}. A disabled display
  9270. item is not printed automatically, but is not forgotten. It may be
  9271. enabled again later. Specify the numbers of the displays that you
  9272. want affected with the command argument @var{dnums}. It can be a
  9273. single display number, one of the numbers shown in the first field of
  9274. the @samp{info display} display; or it could be a range of display
  9275. numbers, as in @code{2-4}.
  9276. @kindex enable display
  9277. @item enable display @var{dnums}@dots{}
  9278. Enable display of item numbers @var{dnums}. It becomes effective once
  9279. again in auto display of its expression, until you specify otherwise.
  9280. Specify the numbers of the displays that you want affected with the
  9281. command argument @var{dnums}. It can be a single display number, one
  9282. of the numbers shown in the first field of the @samp{info display}
  9283. display; or it could be a range of display numbers, as in @code{2-4}.
  9284. @item display
  9285. Display the current values of the expressions on the list, just as is
  9286. done when your program stops.
  9287. @kindex info display
  9288. @item info display
  9289. Print the list of expressions previously set up to display
  9290. automatically, each one with its item number, but without showing the
  9291. values. This includes disabled expressions, which are marked as such.
  9292. It also includes expressions which would not be displayed right now
  9293. because they refer to automatic variables not currently available.
  9294. @end table
  9295. @cindex display disabled out of scope
  9296. If a display expression refers to local variables, then it does not make
  9297. sense outside the lexical context for which it was set up. Such an
  9298. expression is disabled when execution enters a context where one of its
  9299. variables is not defined. For example, if you give the command
  9300. @code{display last_char} while inside a function with an argument
  9301. @code{last_char}, @value{GDBN} displays this argument while your program
  9302. continues to stop inside that function. When it stops elsewhere---where
  9303. there is no variable @code{last_char}---the display is disabled
  9304. automatically. The next time your program stops where @code{last_char}
  9305. is meaningful, you can enable the display expression once again.
  9306. @node Print Settings
  9307. @section Print Settings
  9308. @cindex format options
  9309. @cindex print settings
  9310. @value{GDBN} provides the following ways to control how arrays, structures,
  9311. and symbols are printed.
  9312. @noindent
  9313. These settings are useful for debugging programs in any language:
  9314. @table @code
  9315. @kindex set print
  9316. @anchor{set print address}
  9317. @item set print address
  9318. @itemx set print address on
  9319. @cindex print/don't print memory addresses
  9320. @value{GDBN} prints memory addresses showing the location of stack
  9321. traces, structure values, pointer values, breakpoints, and so forth,
  9322. even when it also displays the contents of those addresses. The default
  9323. is @code{on}. For example, this is what a stack frame display looks like with
  9324. @code{set print address on}:
  9325. @smallexample
  9326. @group
  9327. (@value{GDBP}) f
  9328. #0 set_quotes (lq=0x34c78 "<<", rq=0x34c88 ">>")
  9329. at input.c:530
  9330. 530 if (lquote != def_lquote)
  9331. @end group
  9332. @end smallexample
  9333. @item set print address off
  9334. Do not print addresses when displaying their contents. For example,
  9335. this is the same stack frame displayed with @code{set print address off}:
  9336. @smallexample
  9337. @group
  9338. (@value{GDBP}) set print addr off
  9339. (@value{GDBP}) f
  9340. #0 set_quotes (lq="<<", rq=">>") at input.c:530
  9341. 530 if (lquote != def_lquote)
  9342. @end group
  9343. @end smallexample
  9344. You can use @samp{set print address off} to eliminate all machine
  9345. dependent displays from the @value{GDBN} interface. For example, with
  9346. @code{print address off}, you should get the same text for backtraces on
  9347. all machines---whether or not they involve pointer arguments.
  9348. @kindex show print
  9349. @item show print address
  9350. Show whether or not addresses are to be printed.
  9351. @end table
  9352. When @value{GDBN} prints a symbolic address, it normally prints the
  9353. closest earlier symbol plus an offset. If that symbol does not uniquely
  9354. identify the address (for example, it is a name whose scope is a single
  9355. source file), you may need to clarify. One way to do this is with
  9356. @code{info line}, for example @samp{info line *0x4537}. Alternately,
  9357. you can set @value{GDBN} to print the source file and line number when
  9358. it prints a symbolic address:
  9359. @table @code
  9360. @item set print symbol-filename on
  9361. @cindex source file and line of a symbol
  9362. @cindex symbol, source file and line
  9363. Tell @value{GDBN} to print the source file name and line number of a
  9364. symbol in the symbolic form of an address.
  9365. @item set print symbol-filename off
  9366. Do not print source file name and line number of a symbol. This is the
  9367. default.
  9368. @item show print symbol-filename
  9369. Show whether or not @value{GDBN} will print the source file name and
  9370. line number of a symbol in the symbolic form of an address.
  9371. @end table
  9372. Another situation where it is helpful to show symbol filenames and line
  9373. numbers is when disassembling code; @value{GDBN} shows you the line
  9374. number and source file that corresponds to each instruction.
  9375. Also, you may wish to see the symbolic form only if the address being
  9376. printed is reasonably close to the closest earlier symbol:
  9377. @table @code
  9378. @item set print max-symbolic-offset @var{max-offset}
  9379. @itemx set print max-symbolic-offset unlimited
  9380. @cindex maximum value for offset of closest symbol
  9381. Tell @value{GDBN} to only display the symbolic form of an address if the
  9382. offset between the closest earlier symbol and the address is less than
  9383. @var{max-offset}. The default is @code{unlimited}, which tells @value{GDBN}
  9384. to always print the symbolic form of an address if any symbol precedes
  9385. it. Zero is equivalent to @code{unlimited}.
  9386. @item show print max-symbolic-offset
  9387. Ask how large the maximum offset is that @value{GDBN} prints in a
  9388. symbolic address.
  9389. @end table
  9390. @cindex wild pointer, interpreting
  9391. @cindex pointer, finding referent
  9392. If you have a pointer and you are not sure where it points, try
  9393. @samp{set print symbol-filename on}. Then you can determine the name
  9394. and source file location of the variable where it points, using
  9395. @samp{p/a @var{pointer}}. This interprets the address in symbolic form.
  9396. For example, here @value{GDBN} shows that a variable @code{ptt} points
  9397. at another variable @code{t}, defined in @file{hi2.c}:
  9398. @smallexample
  9399. (@value{GDBP}) set print symbol-filename on
  9400. (@value{GDBP}) p/a ptt
  9401. $4 = 0xe008 <t in hi2.c>
  9402. @end smallexample
  9403. @quotation
  9404. @emph{Warning:} For pointers that point to a local variable, @samp{p/a}
  9405. does not show the symbol name and filename of the referent, even with
  9406. the appropriate @code{set print} options turned on.
  9407. @end quotation
  9408. You can also enable @samp{/a}-like formatting all the time using
  9409. @samp{set print symbol on}:
  9410. @anchor{set print symbol}
  9411. @table @code
  9412. @item set print symbol on
  9413. Tell @value{GDBN} to print the symbol corresponding to an address, if
  9414. one exists.
  9415. @item set print symbol off
  9416. Tell @value{GDBN} not to print the symbol corresponding to an
  9417. address. In this mode, @value{GDBN} will still print the symbol
  9418. corresponding to pointers to functions. This is the default.
  9419. @item show print symbol
  9420. Show whether @value{GDBN} will display the symbol corresponding to an
  9421. address.
  9422. @end table
  9423. Other settings control how different kinds of objects are printed:
  9424. @table @code
  9425. @anchor{set print array}
  9426. @item set print array
  9427. @itemx set print array on
  9428. @cindex pretty print arrays
  9429. Pretty print arrays. This format is more convenient to read,
  9430. but uses more space. The default is off.
  9431. @item set print array off
  9432. Return to compressed format for arrays.
  9433. @item show print array
  9434. Show whether compressed or pretty format is selected for displaying
  9435. arrays.
  9436. @cindex print array indexes
  9437. @anchor{set print array-indexes}
  9438. @item set print array-indexes
  9439. @itemx set print array-indexes on
  9440. Print the index of each element when displaying arrays. May be more
  9441. convenient to locate a given element in the array or quickly find the
  9442. index of a given element in that printed array. The default is off.
  9443. @item set print array-indexes off
  9444. Stop printing element indexes when displaying arrays.
  9445. @item show print array-indexes
  9446. Show whether the index of each element is printed when displaying
  9447. arrays.
  9448. @anchor{set print elements}
  9449. @item set print elements @var{number-of-elements}
  9450. @itemx set print elements unlimited
  9451. @cindex number of array elements to print
  9452. @cindex limit on number of printed array elements
  9453. Set a limit on how many elements of an array @value{GDBN} will print.
  9454. If @value{GDBN} is printing a large array, it stops printing after it has
  9455. printed the number of elements set by the @code{set print elements} command.
  9456. This limit also applies to the display of strings.
  9457. When @value{GDBN} starts, this limit is set to 200.
  9458. Setting @var{number-of-elements} to @code{unlimited} or zero means
  9459. that the number of elements to print is unlimited.
  9460. @item show print elements
  9461. Display the number of elements of a large array that @value{GDBN} will print.
  9462. @anchor{set print frame-arguments}
  9463. @item set print frame-arguments @var{value}
  9464. @kindex set print frame-arguments
  9465. @cindex printing frame argument values
  9466. @cindex print all frame argument values
  9467. @cindex print frame argument values for scalars only
  9468. @cindex do not print frame arguments
  9469. This command allows to control how the values of arguments are printed
  9470. when the debugger prints a frame (@pxref{Frames}). The possible
  9471. values are:
  9472. @table @code
  9473. @item all
  9474. The values of all arguments are printed.
  9475. @item scalars
  9476. Print the value of an argument only if it is a scalar. The value of more
  9477. complex arguments such as arrays, structures, unions, etc, is replaced
  9478. by @code{@dots{}}. This is the default. Here is an example where
  9479. only scalar arguments are shown:
  9480. @smallexample
  9481. #1 0x08048361 in call_me (i=3, s=@dots{}, ss=0xbf8d508c, u=@dots{}, e=green)
  9482. at frame-args.c:23
  9483. @end smallexample
  9484. @item none
  9485. None of the argument values are printed. Instead, the value of each argument
  9486. is replaced by @code{@dots{}}. In this case, the example above now becomes:
  9487. @smallexample
  9488. #1 0x08048361 in call_me (i=@dots{}, s=@dots{}, ss=@dots{}, u=@dots{}, e=@dots{})
  9489. at frame-args.c:23
  9490. @end smallexample
  9491. @item presence
  9492. Only the presence of arguments is indicated by @code{@dots{}}.
  9493. The @code{@dots{}} are not printed for function without any arguments.
  9494. None of the argument names and values are printed.
  9495. In this case, the example above now becomes:
  9496. @smallexample
  9497. #1 0x08048361 in call_me (@dots{}) at frame-args.c:23
  9498. @end smallexample
  9499. @end table
  9500. By default, only scalar arguments are printed. This command can be used
  9501. to configure the debugger to print the value of all arguments, regardless
  9502. of their type. However, it is often advantageous to not print the value
  9503. of more complex parameters. For instance, it reduces the amount of
  9504. information printed in each frame, making the backtrace more readable.
  9505. Also, it improves performance when displaying Ada frames, because
  9506. the computation of large arguments can sometimes be CPU-intensive,
  9507. especially in large applications. Setting @code{print frame-arguments}
  9508. to @code{scalars} (the default), @code{none} or @code{presence} avoids
  9509. this computation, thus speeding up the display of each Ada frame.
  9510. @item show print frame-arguments
  9511. Show how the value of arguments should be displayed when printing a frame.
  9512. @anchor{set print raw-frame-arguments}
  9513. @item set print raw-frame-arguments on
  9514. Print frame arguments in raw, non pretty-printed, form.
  9515. @item set print raw-frame-arguments off
  9516. Print frame arguments in pretty-printed form, if there is a pretty-printer
  9517. for the value (@pxref{Pretty Printing}),
  9518. otherwise print the value in raw form.
  9519. This is the default.
  9520. @item show print raw-frame-arguments
  9521. Show whether to print frame arguments in raw form.
  9522. @anchor{set print entry-values}
  9523. @item set print entry-values @var{value}
  9524. @kindex set print entry-values
  9525. Set printing of frame argument values at function entry. In some cases
  9526. @value{GDBN} can determine the value of function argument which was passed by
  9527. the function caller, even if the value was modified inside the called function
  9528. and therefore is different. With optimized code, the current value could be
  9529. unavailable, but the entry value may still be known.
  9530. The default value is @code{default} (see below for its description). Older
  9531. @value{GDBN} behaved as with the setting @code{no}. Compilers not supporting
  9532. this feature will behave in the @code{default} setting the same way as with the
  9533. @code{no} setting.
  9534. This functionality is currently supported only by DWARF 2 debugging format and
  9535. the compiler has to produce @samp{DW_TAG_call_site} tags. With
  9536. @value{NGCC}, you need to specify @option{-O -g} during compilation, to get
  9537. this information.
  9538. The @var{value} parameter can be one of the following:
  9539. @table @code
  9540. @item no
  9541. Print only actual parameter values, never print values from function entry
  9542. point.
  9543. @smallexample
  9544. #0 equal (val=5)
  9545. #0 different (val=6)
  9546. #0 lost (val=<optimized out>)
  9547. #0 born (val=10)
  9548. #0 invalid (val=<optimized out>)
  9549. @end smallexample
  9550. @item only
  9551. Print only parameter values from function entry point. The actual parameter
  9552. values are never printed.
  9553. @smallexample
  9554. #0 equal (val@@entry=5)
  9555. #0 different (val@@entry=5)
  9556. #0 lost (val@@entry=5)
  9557. #0 born (val@@entry=<optimized out>)
  9558. #0 invalid (val@@entry=<optimized out>)
  9559. @end smallexample
  9560. @item preferred
  9561. Print only parameter values from function entry point. If value from function
  9562. entry point is not known while the actual value is known, print the actual
  9563. value for such parameter.
  9564. @smallexample
  9565. #0 equal (val@@entry=5)
  9566. #0 different (val@@entry=5)
  9567. #0 lost (val@@entry=5)
  9568. #0 born (val=10)
  9569. #0 invalid (val@@entry=<optimized out>)
  9570. @end smallexample
  9571. @item if-needed
  9572. Print actual parameter values. If actual parameter value is not known while
  9573. value from function entry point is known, print the entry point value for such
  9574. parameter.
  9575. @smallexample
  9576. #0 equal (val=5)
  9577. #0 different (val=6)
  9578. #0 lost (val@@entry=5)
  9579. #0 born (val=10)
  9580. #0 invalid (val=<optimized out>)
  9581. @end smallexample
  9582. @item both
  9583. Always print both the actual parameter value and its value from function entry
  9584. point, even if values of one or both are not available due to compiler
  9585. optimizations.
  9586. @smallexample
  9587. #0 equal (val=5, val@@entry=5)
  9588. #0 different (val=6, val@@entry=5)
  9589. #0 lost (val=<optimized out>, val@@entry=5)
  9590. #0 born (val=10, val@@entry=<optimized out>)
  9591. #0 invalid (val=<optimized out>, val@@entry=<optimized out>)
  9592. @end smallexample
  9593. @item compact
  9594. Print the actual parameter value if it is known and also its value from
  9595. function entry point if it is known. If neither is known, print for the actual
  9596. value @code{<optimized out>}. If not in MI mode (@pxref{GDB/MI}) and if both
  9597. values are known and identical, print the shortened
  9598. @code{param=param@@entry=VALUE} notation.
  9599. @smallexample
  9600. #0 equal (val=val@@entry=5)
  9601. #0 different (val=6, val@@entry=5)
  9602. #0 lost (val@@entry=5)
  9603. #0 born (val=10)
  9604. #0 invalid (val=<optimized out>)
  9605. @end smallexample
  9606. @item default
  9607. Always print the actual parameter value. Print also its value from function
  9608. entry point, but only if it is known. If not in MI mode (@pxref{GDB/MI}) and
  9609. if both values are known and identical, print the shortened
  9610. @code{param=param@@entry=VALUE} notation.
  9611. @smallexample
  9612. #0 equal (val=val@@entry=5)
  9613. #0 different (val=6, val@@entry=5)
  9614. #0 lost (val=<optimized out>, val@@entry=5)
  9615. #0 born (val=10)
  9616. #0 invalid (val=<optimized out>)
  9617. @end smallexample
  9618. @end table
  9619. For analysis messages on possible failures of frame argument values at function
  9620. entry resolution see @ref{set debug entry-values}.
  9621. @item show print entry-values
  9622. Show the method being used for printing of frame argument values at function
  9623. entry.
  9624. @anchor{set print frame-info}
  9625. @item set print frame-info @var{value}
  9626. @kindex set print frame-info
  9627. @cindex printing frame information
  9628. @cindex frame information, printing
  9629. This command allows to control the information printed when
  9630. the debugger prints a frame. See @ref{Frames}, @ref{Backtrace},
  9631. for a general explanation about frames and frame information.
  9632. Note that some other settings (such as @code{set print frame-arguments}
  9633. and @code{set print address}) are also influencing if and how some frame
  9634. information is displayed. In particular, the frame program counter is never
  9635. printed if @code{set print address} is off.
  9636. The possible values for @code{set print frame-info} are:
  9637. @table @code
  9638. @item short-location
  9639. Print the frame level, the program counter (if not at the
  9640. beginning of the location source line), the function, the function
  9641. arguments.
  9642. @item location
  9643. Same as @code{short-location} but also print the source file and source line
  9644. number.
  9645. @item location-and-address
  9646. Same as @code{location} but print the program counter even if located at the
  9647. beginning of the location source line.
  9648. @item source-line
  9649. Print the program counter (if not at the beginning of the location
  9650. source line), the line number and the source line.
  9651. @item source-and-location
  9652. Print what @code{location} and @code{source-line} are printing.
  9653. @item auto
  9654. The information printed for a frame is decided automatically
  9655. by the @value{GDBN} command that prints a frame.
  9656. For example, @code{frame} prints the information printed by
  9657. @code{source-and-location} while @code{stepi} will switch between
  9658. @code{source-line} and @code{source-and-location} depending on the program
  9659. counter.
  9660. The default value is @code{auto}.
  9661. @end table
  9662. @anchor{set print repeats}
  9663. @item set print repeats @var{number-of-repeats}
  9664. @itemx set print repeats unlimited
  9665. @cindex repeated array elements
  9666. Set the threshold for suppressing display of repeated array
  9667. elements. When the number of consecutive identical elements of an
  9668. array exceeds the threshold, @value{GDBN} prints the string
  9669. @code{"<repeats @var{n} times>"}, where @var{n} is the number of
  9670. identical repetitions, instead of displaying the identical elements
  9671. themselves. Setting the threshold to @code{unlimited} or zero will
  9672. cause all elements to be individually printed. The default threshold
  9673. is 10.
  9674. @item show print repeats
  9675. Display the current threshold for printing repeated identical
  9676. elements.
  9677. @anchor{set print max-depth}
  9678. @item set print max-depth @var{depth}
  9679. @item set print max-depth unlimited
  9680. @cindex printing nested structures
  9681. Set the threshold after which nested structures are replaced with
  9682. ellipsis, this can make visualising deeply nested structures easier.
  9683. For example, given this C code
  9684. @smallexample
  9685. typedef struct s1 @{ int a; @} s1;
  9686. typedef struct s2 @{ s1 b; @} s2;
  9687. typedef struct s3 @{ s2 c; @} s3;
  9688. typedef struct s4 @{ s3 d; @} s4;
  9689. s4 var = @{ @{ @{ @{ 3 @} @} @} @};
  9690. @end smallexample
  9691. The following table shows how different values of @var{depth} will
  9692. effect how @code{var} is printed by @value{GDBN}:
  9693. @multitable @columnfractions .3 .7
  9694. @headitem @var{depth} setting @tab Result of @samp{p var}
  9695. @item unlimited
  9696. @tab @code{$1 = @{d = @{c = @{b = @{a = 3@}@}@}@}}
  9697. @item @code{0}
  9698. @tab @code{$1 = @{...@}}
  9699. @item @code{1}
  9700. @tab @code{$1 = @{d = @{...@}@}}
  9701. @item @code{2}
  9702. @tab @code{$1 = @{d = @{c = @{...@}@}@}}
  9703. @item @code{3}
  9704. @tab @code{$1 = @{d = @{c = @{b = @{...@}@}@}@}}
  9705. @item @code{4}
  9706. @tab @code{$1 = @{d = @{c = @{b = @{a = 3@}@}@}@}}
  9707. @end multitable
  9708. To see the contents of structures that have been hidden the user can
  9709. either increase the print max-depth, or they can print the elements of
  9710. the structure that are visible, for example
  9711. @smallexample
  9712. (gdb) set print max-depth 2
  9713. (gdb) p var
  9714. $1 = @{d = @{c = @{...@}@}@}
  9715. (gdb) p var.d
  9716. $2 = @{c = @{b = @{...@}@}@}
  9717. (gdb) p var.d.c
  9718. $3 = @{b = @{a = 3@}@}
  9719. @end smallexample
  9720. The pattern used to replace nested structures varies based on
  9721. language, for most languages @code{@{...@}} is used, but Fortran uses
  9722. @code{(...)}.
  9723. @item show print max-depth
  9724. Display the current threshold after which nested structures are
  9725. replaces with ellipsis.
  9726. @anchor{set print memory-tag-violations}
  9727. @cindex printing memory tag violation information
  9728. @item set print memory-tag-violations
  9729. @itemx set print memory-tag-violations on
  9730. Cause @value{GDBN} to display additional information about memory tag violations
  9731. when printing pointers and addresses.
  9732. @item set print memory-tag-violations off
  9733. Stop printing memory tag violation information.
  9734. @item show print memory-tag-violations
  9735. Show whether memory tag violation information is displayed when printing
  9736. pointers and addresses.
  9737. @anchor{set print null-stop}
  9738. @item set print null-stop
  9739. @cindex @sc{null} elements in arrays
  9740. Cause @value{GDBN} to stop printing the characters of an array when the first
  9741. @sc{null} is encountered. This is useful when large arrays actually
  9742. contain only short strings.
  9743. The default is off.
  9744. @item show print null-stop
  9745. Show whether @value{GDBN} stops printing an array on the first
  9746. @sc{null} character.
  9747. @anchor{set print pretty}
  9748. @item set print pretty on
  9749. @cindex print structures in indented form
  9750. @cindex indentation in structure display
  9751. Cause @value{GDBN} to print structures in an indented format with one member
  9752. per line, like this:
  9753. @smallexample
  9754. @group
  9755. $1 = @{
  9756. next = 0x0,
  9757. flags = @{
  9758. sweet = 1,
  9759. sour = 1
  9760. @},
  9761. meat = 0x54 "Pork"
  9762. @}
  9763. @end group
  9764. @end smallexample
  9765. @item set print pretty off
  9766. Cause @value{GDBN} to print structures in a compact format, like this:
  9767. @smallexample
  9768. @group
  9769. $1 = @{next = 0x0, flags = @{sweet = 1, sour = 1@}, \
  9770. meat = 0x54 "Pork"@}
  9771. @end group
  9772. @end smallexample
  9773. @noindent
  9774. This is the default format.
  9775. @item show print pretty
  9776. Show which format @value{GDBN} is using to print structures.
  9777. @anchor{set print raw-values}
  9778. @item set print raw-values on
  9779. Print values in raw form, without applying the pretty
  9780. printers for the value.
  9781. @item set print raw-values off
  9782. Print values in pretty-printed form, if there is a pretty-printer
  9783. for the value (@pxref{Pretty Printing}),
  9784. otherwise print the value in raw form.
  9785. The default setting is ``off''.
  9786. @item show print raw-values
  9787. Show whether to print values in raw form.
  9788. @item set print sevenbit-strings on
  9789. @cindex eight-bit characters in strings
  9790. @cindex octal escapes in strings
  9791. Print using only seven-bit characters; if this option is set,
  9792. @value{GDBN} displays any eight-bit characters (in strings or
  9793. character values) using the notation @code{\}@var{nnn}. This setting is
  9794. best if you are working in English (@sc{ascii}) and you use the
  9795. high-order bit of characters as a marker or ``meta'' bit.
  9796. @item set print sevenbit-strings off
  9797. Print full eight-bit characters. This allows the use of more
  9798. international character sets, and is the default.
  9799. @item show print sevenbit-strings
  9800. Show whether or not @value{GDBN} is printing only seven-bit characters.
  9801. @anchor{set print union}
  9802. @item set print union on
  9803. @cindex unions in structures, printing
  9804. Tell @value{GDBN} to print unions which are contained in structures
  9805. and other unions. This is the default setting.
  9806. @item set print union off
  9807. Tell @value{GDBN} not to print unions which are contained in
  9808. structures and other unions. @value{GDBN} will print @code{"@{...@}"}
  9809. instead.
  9810. @item show print union
  9811. Ask @value{GDBN} whether or not it will print unions which are contained in
  9812. structures and other unions.
  9813. For example, given the declarations
  9814. @smallexample
  9815. typedef enum @{Tree, Bug@} Species;
  9816. typedef enum @{Big_tree, Acorn, Seedling@} Tree_forms;
  9817. typedef enum @{Caterpillar, Cocoon, Butterfly@}
  9818. Bug_forms;
  9819. struct thing @{
  9820. Species it;
  9821. union @{
  9822. Tree_forms tree;
  9823. Bug_forms bug;
  9824. @} form;
  9825. @};
  9826. struct thing foo = @{Tree, @{Acorn@}@};
  9827. @end smallexample
  9828. @noindent
  9829. with @code{set print union on} in effect @samp{p foo} would print
  9830. @smallexample
  9831. $1 = @{it = Tree, form = @{tree = Acorn, bug = Cocoon@}@}
  9832. @end smallexample
  9833. @noindent
  9834. and with @code{set print union off} in effect it would print
  9835. @smallexample
  9836. $1 = @{it = Tree, form = @{...@}@}
  9837. @end smallexample
  9838. @noindent
  9839. @code{set print union} affects programs written in C-like languages
  9840. and in Pascal.
  9841. @end table
  9842. @need 1000
  9843. @noindent
  9844. These settings are of interest when debugging C@t{++} programs:
  9845. @table @code
  9846. @cindex demangling C@t{++} names
  9847. @item set print demangle
  9848. @itemx set print demangle on
  9849. Print C@t{++} names in their source form rather than in the encoded
  9850. (``mangled'') form passed to the assembler and linker for type-safe
  9851. linkage. The default is on.
  9852. @item show print demangle
  9853. Show whether C@t{++} names are printed in mangled or demangled form.
  9854. @item set print asm-demangle
  9855. @itemx set print asm-demangle on
  9856. Print C@t{++} names in their source form rather than their mangled form, even
  9857. in assembler code printouts such as instruction disassemblies.
  9858. The default is off.
  9859. @item show print asm-demangle
  9860. Show whether C@t{++} names in assembly listings are printed in mangled
  9861. or demangled form.
  9862. @cindex C@t{++} symbol decoding style
  9863. @cindex symbol decoding style, C@t{++}
  9864. @kindex set demangle-style
  9865. @item set demangle-style @var{style}
  9866. Choose among several encoding schemes used by different compilers to represent
  9867. C@t{++} names. If you omit @var{style}, you will see a list of possible
  9868. formats. The default value is @var{auto}, which lets @value{GDBN} choose a
  9869. decoding style by inspecting your program.
  9870. @item show demangle-style
  9871. Display the encoding style currently in use for decoding C@t{++} symbols.
  9872. @anchor{set print object}
  9873. @item set print object
  9874. @itemx set print object on
  9875. @cindex derived type of an object, printing
  9876. @cindex display derived types
  9877. When displaying a pointer to an object, identify the @emph{actual}
  9878. (derived) type of the object rather than the @emph{declared} type, using
  9879. the virtual function table. Note that the virtual function table is
  9880. required---this feature can only work for objects that have run-time
  9881. type identification; a single virtual method in the object's declared
  9882. type is sufficient. Note that this setting is also taken into account when
  9883. working with variable objects via MI (@pxref{GDB/MI}).
  9884. @item set print object off
  9885. Display only the declared type of objects, without reference to the
  9886. virtual function table. This is the default setting.
  9887. @item show print object
  9888. Show whether actual, or declared, object types are displayed.
  9889. @anchor{set print static-members}
  9890. @item set print static-members
  9891. @itemx set print static-members on
  9892. @cindex static members of C@t{++} objects
  9893. Print static members when displaying a C@t{++} object. The default is on.
  9894. @item set print static-members off
  9895. Do not print static members when displaying a C@t{++} object.
  9896. @item show print static-members
  9897. Show whether C@t{++} static members are printed or not.
  9898. @item set print pascal_static-members
  9899. @itemx set print pascal_static-members on
  9900. @cindex static members of Pascal objects
  9901. @cindex Pascal objects, static members display
  9902. Print static members when displaying a Pascal object. The default is on.
  9903. @item set print pascal_static-members off
  9904. Do not print static members when displaying a Pascal object.
  9905. @item show print pascal_static-members
  9906. Show whether Pascal static members are printed or not.
  9907. @c These don't work with HP ANSI C++ yet.
  9908. @anchor{set print vtbl}
  9909. @item set print vtbl
  9910. @itemx set print vtbl on
  9911. @cindex pretty print C@t{++} virtual function tables
  9912. @cindex virtual functions (C@t{++}) display
  9913. @cindex VTBL display
  9914. Pretty print C@t{++} virtual function tables. The default is off.
  9915. (The @code{vtbl} commands do not work on programs compiled with the HP
  9916. ANSI C@t{++} compiler (@code{aCC}).)
  9917. @item set print vtbl off
  9918. Do not pretty print C@t{++} virtual function tables.
  9919. @item show print vtbl
  9920. Show whether C@t{++} virtual function tables are pretty printed, or not.
  9921. @end table
  9922. @node Pretty Printing
  9923. @section Pretty Printing
  9924. @value{GDBN} provides a mechanism to allow pretty-printing of values using
  9925. Python code. It greatly simplifies the display of complex objects. This
  9926. mechanism works for both MI and the CLI.
  9927. @menu
  9928. * Pretty-Printer Introduction:: Introduction to pretty-printers
  9929. * Pretty-Printer Example:: An example pretty-printer
  9930. * Pretty-Printer Commands:: Pretty-printer commands
  9931. @end menu
  9932. @node Pretty-Printer Introduction
  9933. @subsection Pretty-Printer Introduction
  9934. When @value{GDBN} prints a value, it first sees if there is a pretty-printer
  9935. registered for the value. If there is then @value{GDBN} invokes the
  9936. pretty-printer to print the value. Otherwise the value is printed normally.
  9937. Pretty-printers are normally named. This makes them easy to manage.
  9938. The @samp{info pretty-printer} command will list all the installed
  9939. pretty-printers with their names.
  9940. If a pretty-printer can handle multiple data types, then its
  9941. @dfn{subprinters} are the printers for the individual data types.
  9942. Each such subprinter has its own name.
  9943. The format of the name is @var{printer-name};@var{subprinter-name}.
  9944. Pretty-printers are installed by @dfn{registering} them with @value{GDBN}.
  9945. Typically they are automatically loaded and registered when the corresponding
  9946. debug information is loaded, thus making them available without having to
  9947. do anything special.
  9948. There are three places where a pretty-printer can be registered.
  9949. @itemize @bullet
  9950. @item
  9951. Pretty-printers registered globally are available when debugging
  9952. all inferiors.
  9953. @item
  9954. Pretty-printers registered with a program space are available only
  9955. when debugging that program.
  9956. @xref{Progspaces In Python}, for more details on program spaces in Python.
  9957. @item
  9958. Pretty-printers registered with an objfile are loaded and unloaded
  9959. with the corresponding objfile (e.g., shared library).
  9960. @xref{Objfiles In Python}, for more details on objfiles in Python.
  9961. @end itemize
  9962. @xref{Selecting Pretty-Printers}, for further information on how
  9963. pretty-printers are selected,
  9964. @xref{Writing a Pretty-Printer}, for implementing pretty printers
  9965. for new types.
  9966. @node Pretty-Printer Example
  9967. @subsection Pretty-Printer Example
  9968. Here is how a C@t{++} @code{std::string} looks without a pretty-printer:
  9969. @smallexample
  9970. (@value{GDBP}) print s
  9971. $1 = @{
  9972. static npos = 4294967295,
  9973. _M_dataplus = @{
  9974. <std::allocator<char>> = @{
  9975. <__gnu_cxx::new_allocator<char>> = @{
  9976. <No data fields>@}, <No data fields>
  9977. @},
  9978. members of std::basic_string<char, std::char_traits<char>,
  9979. std::allocator<char> >::_Alloc_hider:
  9980. _M_p = 0x804a014 "abcd"
  9981. @}
  9982. @}
  9983. @end smallexample
  9984. With a pretty-printer for @code{std::string} only the contents are printed:
  9985. @smallexample
  9986. (@value{GDBP}) print s
  9987. $2 = "abcd"
  9988. @end smallexample
  9989. @node Pretty-Printer Commands
  9990. @subsection Pretty-Printer Commands
  9991. @cindex pretty-printer commands
  9992. @table @code
  9993. @kindex info pretty-printer
  9994. @item info pretty-printer [@var{object-regexp} [@var{name-regexp}]]
  9995. Print the list of installed pretty-printers.
  9996. This includes disabled pretty-printers, which are marked as such.
  9997. @var{object-regexp} is a regular expression matching the objects
  9998. whose pretty-printers to list.
  9999. Objects can be @code{global}, the program space's file
  10000. (@pxref{Progspaces In Python}),
  10001. and the object files within that program space (@pxref{Objfiles In Python}).
  10002. @xref{Selecting Pretty-Printers}, for details on how @value{GDBN}
  10003. looks up a printer from these three objects.
  10004. @var{name-regexp} is a regular expression matching the name of the printers
  10005. to list.
  10006. @kindex disable pretty-printer
  10007. @item disable pretty-printer [@var{object-regexp} [@var{name-regexp}]]
  10008. Disable pretty-printers matching @var{object-regexp} and @var{name-regexp}.
  10009. A disabled pretty-printer is not forgotten, it may be enabled again later.
  10010. @kindex enable pretty-printer
  10011. @item enable pretty-printer [@var{object-regexp} [@var{name-regexp}]]
  10012. Enable pretty-printers matching @var{object-regexp} and @var{name-regexp}.
  10013. @end table
  10014. Example:
  10015. Suppose we have three pretty-printers installed: one from library1.so
  10016. named @code{foo} that prints objects of type @code{foo}, and
  10017. another from library2.so named @code{bar} that prints two types of objects,
  10018. @code{bar1} and @code{bar2}.
  10019. @smallexample
  10020. (gdb) info pretty-printer
  10021. library1.so:
  10022. foo
  10023. library2.so:
  10024. bar
  10025. bar1
  10026. bar2
  10027. (gdb) info pretty-printer library2
  10028. library2.so:
  10029. bar
  10030. bar1
  10031. bar2
  10032. (gdb) disable pretty-printer library1
  10033. 1 printer disabled
  10034. 2 of 3 printers enabled
  10035. (gdb) info pretty-printer
  10036. library1.so:
  10037. foo [disabled]
  10038. library2.so:
  10039. bar
  10040. bar1
  10041. bar2
  10042. (gdb) disable pretty-printer library2 bar;bar1
  10043. 1 printer disabled
  10044. 1 of 3 printers enabled
  10045. (gdb) info pretty-printer library2
  10046. library1.so:
  10047. foo [disabled]
  10048. library2.so:
  10049. bar
  10050. bar1 [disabled]
  10051. bar2
  10052. (gdb) disable pretty-printer library2 bar
  10053. 1 printer disabled
  10054. 0 of 3 printers enabled
  10055. (gdb) info pretty-printer library2
  10056. library1.so:
  10057. foo [disabled]
  10058. library2.so:
  10059. bar [disabled]
  10060. bar1 [disabled]
  10061. bar2
  10062. @end smallexample
  10063. Note that for @code{bar} the entire printer can be disabled,
  10064. as can each individual subprinter.
  10065. Printing values and frame arguments is done by default using
  10066. the enabled pretty printers.
  10067. The print option @code{-raw-values} and @value{GDBN} setting
  10068. @code{set print raw-values} (@pxref{set print raw-values}) can be
  10069. used to print values without applying the enabled pretty printers.
  10070. Similarly, the backtrace option @code{-raw-frame-arguments} and
  10071. @value{GDBN} setting @code{set print raw-frame-arguments}
  10072. (@pxref{set print raw-frame-arguments}) can be used to ignore the
  10073. enabled pretty printers when printing frame argument values.
  10074. @node Value History
  10075. @section Value History
  10076. @cindex value history
  10077. @cindex history of values printed by @value{GDBN}
  10078. Values printed by the @code{print} command are saved in the @value{GDBN}
  10079. @dfn{value history}. This allows you to refer to them in other expressions.
  10080. Values are kept until the symbol table is re-read or discarded
  10081. (for example with the @code{file} or @code{symbol-file} commands).
  10082. When the symbol table changes, the value history is discarded,
  10083. since the values may contain pointers back to the types defined in the
  10084. symbol table.
  10085. @cindex @code{$}
  10086. @cindex @code{$$}
  10087. @cindex history number
  10088. The values printed are given @dfn{history numbers} by which you can
  10089. refer to them. These are successive integers starting with one.
  10090. @code{print} shows you the history number assigned to a value by
  10091. printing @samp{$@var{num} = } before the value; here @var{num} is the
  10092. history number.
  10093. To refer to any previous value, use @samp{$} followed by the value's
  10094. history number. The way @code{print} labels its output is designed to
  10095. remind you of this. Just @code{$} refers to the most recent value in
  10096. the history, and @code{$$} refers to the value before that.
  10097. @code{$$@var{n}} refers to the @var{n}th value from the end; @code{$$2}
  10098. is the value just prior to @code{$$}, @code{$$1} is equivalent to
  10099. @code{$$}, and @code{$$0} is equivalent to @code{$}.
  10100. For example, suppose you have just printed a pointer to a structure and
  10101. want to see the contents of the structure. It suffices to type
  10102. @smallexample
  10103. p *$
  10104. @end smallexample
  10105. If you have a chain of structures where the component @code{next} points
  10106. to the next one, you can print the contents of the next one with this:
  10107. @smallexample
  10108. p *$.next
  10109. @end smallexample
  10110. @noindent
  10111. You can print successive links in the chain by repeating this
  10112. command---which you can do by just typing @key{RET}.
  10113. Note that the history records values, not expressions. If the value of
  10114. @code{x} is 4 and you type these commands:
  10115. @smallexample
  10116. print x
  10117. set x=5
  10118. @end smallexample
  10119. @noindent
  10120. then the value recorded in the value history by the @code{print} command
  10121. remains 4 even though the value of @code{x} has changed.
  10122. @table @code
  10123. @kindex show values
  10124. @item show values
  10125. Print the last ten values in the value history, with their item numbers.
  10126. This is like @samp{p@ $$9} repeated ten times, except that @code{show
  10127. values} does not change the history.
  10128. @item show values @var{n}
  10129. Print ten history values centered on history item number @var{n}.
  10130. @item show values +
  10131. Print ten history values just after the values last printed. If no more
  10132. values are available, @code{show values +} produces no display.
  10133. @end table
  10134. Pressing @key{RET} to repeat @code{show values @var{n}} has exactly the
  10135. same effect as @samp{show values +}.
  10136. @node Convenience Vars
  10137. @section Convenience Variables
  10138. @cindex convenience variables
  10139. @cindex user-defined variables
  10140. @value{GDBN} provides @dfn{convenience variables} that you can use within
  10141. @value{GDBN} to hold on to a value and refer to it later. These variables
  10142. exist entirely within @value{GDBN}; they are not part of your program, and
  10143. setting a convenience variable has no direct effect on further execution
  10144. of your program. That is why you can use them freely.
  10145. Convenience variables are prefixed with @samp{$}. Any name preceded by
  10146. @samp{$} can be used for a convenience variable, unless it is one of
  10147. the predefined machine-specific register names (@pxref{Registers, ,Registers}).
  10148. (Value history references, in contrast, are @emph{numbers} preceded
  10149. by @samp{$}. @xref{Value History, ,Value History}.)
  10150. You can save a value in a convenience variable with an assignment
  10151. expression, just as you would set a variable in your program.
  10152. For example:
  10153. @smallexample
  10154. set $foo = *object_ptr
  10155. @end smallexample
  10156. @noindent
  10157. would save in @code{$foo} the value contained in the object pointed to by
  10158. @code{object_ptr}.
  10159. Using a convenience variable for the first time creates it, but its
  10160. value is @code{void} until you assign a new value. You can alter the
  10161. value with another assignment at any time.
  10162. Convenience variables have no fixed types. You can assign a convenience
  10163. variable any type of value, including structures and arrays, even if
  10164. that variable already has a value of a different type. The convenience
  10165. variable, when used as an expression, has the type of its current value.
  10166. @table @code
  10167. @kindex show convenience
  10168. @cindex show all user variables and functions
  10169. @item show convenience
  10170. Print a list of convenience variables used so far, and their values,
  10171. as well as a list of the convenience functions.
  10172. Abbreviated @code{show conv}.
  10173. @kindex init-if-undefined
  10174. @cindex convenience variables, initializing
  10175. @item init-if-undefined $@var{variable} = @var{expression}
  10176. Set a convenience variable if it has not already been set. This is useful
  10177. for user-defined commands that keep some state. It is similar, in concept,
  10178. to using local static variables with initializers in C (except that
  10179. convenience variables are global). It can also be used to allow users to
  10180. override default values used in a command script.
  10181. If the variable is already defined then the expression is not evaluated so
  10182. any side-effects do not occur.
  10183. @end table
  10184. One of the ways to use a convenience variable is as a counter to be
  10185. incremented or a pointer to be advanced. For example, to print
  10186. a field from successive elements of an array of structures:
  10187. @smallexample
  10188. set $i = 0
  10189. print bar[$i++]->contents
  10190. @end smallexample
  10191. @noindent
  10192. Repeat that command by typing @key{RET}.
  10193. Some convenience variables are created automatically by @value{GDBN} and given
  10194. values likely to be useful.
  10195. @table @code
  10196. @vindex $_@r{, convenience variable}
  10197. @item $_
  10198. The variable @code{$_} is automatically set by the @code{x} command to
  10199. the last address examined (@pxref{Memory, ,Examining Memory}). Other
  10200. commands which provide a default address for @code{x} to examine also
  10201. set @code{$_} to that address; these commands include @code{info line}
  10202. and @code{info breakpoint}. The type of @code{$_} is @code{void *}
  10203. except when set by the @code{x} command, in which case it is a pointer
  10204. to the type of @code{$__}.
  10205. @vindex $__@r{, convenience variable}
  10206. @item $__
  10207. The variable @code{$__} is automatically set by the @code{x} command
  10208. to the value found in the last address examined. Its type is chosen
  10209. to match the format in which the data was printed.
  10210. @item $_exitcode
  10211. @vindex $_exitcode@r{, convenience variable}
  10212. When the program being debugged terminates normally, @value{GDBN}
  10213. automatically sets this variable to the exit code of the program, and
  10214. resets @code{$_exitsignal} to @code{void}.
  10215. @item $_exitsignal
  10216. @vindex $_exitsignal@r{, convenience variable}
  10217. When the program being debugged dies due to an uncaught signal,
  10218. @value{GDBN} automatically sets this variable to that signal's number,
  10219. and resets @code{$_exitcode} to @code{void}.
  10220. To distinguish between whether the program being debugged has exited
  10221. (i.e., @code{$_exitcode} is not @code{void}) or signalled (i.e.,
  10222. @code{$_exitsignal} is not @code{void}), the convenience function
  10223. @code{$_isvoid} can be used (@pxref{Convenience Funs,, Convenience
  10224. Functions}). For example, considering the following source code:
  10225. @smallexample
  10226. #include <signal.h>
  10227. int
  10228. main (int argc, char *argv[])
  10229. @{
  10230. raise (SIGALRM);
  10231. return 0;
  10232. @}
  10233. @end smallexample
  10234. A valid way of telling whether the program being debugged has exited
  10235. or signalled would be:
  10236. @smallexample
  10237. (@value{GDBP}) define has_exited_or_signalled
  10238. Type commands for definition of ``has_exited_or_signalled''.
  10239. End with a line saying just ``end''.
  10240. >if $_isvoid ($_exitsignal)
  10241. >echo The program has exited\n
  10242. >else
  10243. >echo The program has signalled\n
  10244. >end
  10245. >end
  10246. (@value{GDBP}) run
  10247. Starting program:
  10248. Program terminated with signal SIGALRM, Alarm clock.
  10249. The program no longer exists.
  10250. (@value{GDBP}) has_exited_or_signalled
  10251. The program has signalled
  10252. @end smallexample
  10253. As can be seen, @value{GDBN} correctly informs that the program being
  10254. debugged has signalled, since it calls @code{raise} and raises a
  10255. @code{SIGALRM} signal. If the program being debugged had not called
  10256. @code{raise}, then @value{GDBN} would report a normal exit:
  10257. @smallexample
  10258. (@value{GDBP}) has_exited_or_signalled
  10259. The program has exited
  10260. @end smallexample
  10261. @item $_exception
  10262. The variable @code{$_exception} is set to the exception object being
  10263. thrown at an exception-related catchpoint. @xref{Set Catchpoints}.
  10264. @item $_ada_exception
  10265. The variable @code{$_ada_exception} is set to the address of the
  10266. exception being caught or thrown at an Ada exception-related
  10267. catchpoint. @xref{Set Catchpoints}.
  10268. @item $_probe_argc
  10269. @itemx $_probe_arg0@dots{}$_probe_arg11
  10270. Arguments to a static probe. @xref{Static Probe Points}.
  10271. @item $_sdata
  10272. @vindex $_sdata@r{, inspect, convenience variable}
  10273. The variable @code{$_sdata} contains extra collected static tracepoint
  10274. data. @xref{Tracepoint Actions,,Tracepoint Action Lists}. Note that
  10275. @code{$_sdata} could be empty, if not inspecting a trace buffer, or
  10276. if extra static tracepoint data has not been collected.
  10277. @item $_siginfo
  10278. @vindex $_siginfo@r{, convenience variable}
  10279. The variable @code{$_siginfo} contains extra signal information
  10280. (@pxref{extra signal information}). Note that @code{$_siginfo}
  10281. could be empty, if the application has not yet received any signals.
  10282. For example, it will be empty before you execute the @code{run} command.
  10283. @item $_tlb
  10284. @vindex $_tlb@r{, convenience variable}
  10285. The variable @code{$_tlb} is automatically set when debugging
  10286. applications running on MS-Windows in native mode or connected to
  10287. gdbserver that supports the @code{qGetTIBAddr} request.
  10288. @xref{General Query Packets}.
  10289. This variable contains the address of the thread information block.
  10290. @item $_inferior
  10291. The number of the current inferior. @xref{Inferiors Connections and
  10292. Programs, ,Debugging Multiple Inferiors Connections and Programs}.
  10293. @item $_thread
  10294. The thread number of the current thread. @xref{thread numbers}.
  10295. @item $_gthread
  10296. The global number of the current thread. @xref{global thread numbers}.
  10297. @item $_gdb_major
  10298. @itemx $_gdb_minor
  10299. @vindex $_gdb_major@r{, convenience variable}
  10300. @vindex $_gdb_minor@r{, convenience variable}
  10301. The major and minor version numbers of the running @value{GDBN}.
  10302. Development snapshots and pretest versions have their minor version
  10303. incremented by one; thus, @value{GDBN} pretest 9.11.90 will produce
  10304. the value 12 for @code{$_gdb_minor}. These variables allow you to
  10305. write scripts that work with different versions of @value{GDBN}
  10306. without errors caused by features unavailable in some of those
  10307. versions.
  10308. @item $_shell_exitcode
  10309. @itemx $_shell_exitsignal
  10310. @vindex $_shell_exitcode@r{, convenience variable}
  10311. @vindex $_shell_exitsignal@r{, convenience variable}
  10312. @cindex shell command, exit code
  10313. @cindex shell command, exit signal
  10314. @cindex exit status of shell commands
  10315. @value{GDBN} commands such as @code{shell} and @code{|} are launching
  10316. shell commands. When a launched command terminates, @value{GDBN}
  10317. automatically maintains the variables @code{$_shell_exitcode}
  10318. and @code{$_shell_exitsignal} according to the exit status of the last
  10319. launched command. These variables are set and used similarly to
  10320. the variables @code{$_exitcode} and @code{$_exitsignal}.
  10321. @end table
  10322. @node Convenience Funs
  10323. @section Convenience Functions
  10324. @cindex convenience functions
  10325. @value{GDBN} also supplies some @dfn{convenience functions}. These
  10326. have a syntax similar to convenience variables. A convenience
  10327. function can be used in an expression just like an ordinary function;
  10328. however, a convenience function is implemented internally to
  10329. @value{GDBN}.
  10330. These functions do not require @value{GDBN} to be configured with
  10331. @code{Python} support, which means that they are always available.
  10332. @table @code
  10333. @item $_isvoid (@var{expr})
  10334. @findex $_isvoid@r{, convenience function}
  10335. Return one if the expression @var{expr} is @code{void}. Otherwise it
  10336. returns zero.
  10337. A @code{void} expression is an expression where the type of the result
  10338. is @code{void}. For example, you can examine a convenience variable
  10339. (see @ref{Convenience Vars,, Convenience Variables}) to check whether
  10340. it is @code{void}:
  10341. @smallexample
  10342. (@value{GDBP}) print $_exitcode
  10343. $1 = void
  10344. (@value{GDBP}) print $_isvoid ($_exitcode)
  10345. $2 = 1
  10346. (@value{GDBP}) run
  10347. Starting program: ./a.out
  10348. [Inferior 1 (process 29572) exited normally]
  10349. (@value{GDBP}) print $_exitcode
  10350. $3 = 0
  10351. (@value{GDBP}) print $_isvoid ($_exitcode)
  10352. $4 = 0
  10353. @end smallexample
  10354. In the example above, we used @code{$_isvoid} to check whether
  10355. @code{$_exitcode} is @code{void} before and after the execution of the
  10356. program being debugged. Before the execution there is no exit code to
  10357. be examined, therefore @code{$_exitcode} is @code{void}. After the
  10358. execution the program being debugged returned zero, therefore
  10359. @code{$_exitcode} is zero, which means that it is not @code{void}
  10360. anymore.
  10361. The @code{void} expression can also be a call of a function from the
  10362. program being debugged. For example, given the following function:
  10363. @smallexample
  10364. void
  10365. foo (void)
  10366. @{
  10367. @}
  10368. @end smallexample
  10369. The result of calling it inside @value{GDBN} is @code{void}:
  10370. @smallexample
  10371. (@value{GDBP}) print foo ()
  10372. $1 = void
  10373. (@value{GDBP}) print $_isvoid (foo ())
  10374. $2 = 1
  10375. (@value{GDBP}) set $v = foo ()
  10376. (@value{GDBP}) print $v
  10377. $3 = void
  10378. (@value{GDBP}) print $_isvoid ($v)
  10379. $4 = 1
  10380. @end smallexample
  10381. @item $_gdb_setting_str (@var{setting})
  10382. @findex $_gdb_setting_str@r{, convenience function}
  10383. Return the value of the @value{GDBN} @var{setting} as a string.
  10384. @var{setting} is any setting that can be used in a @code{set} or
  10385. @code{show} command (@pxref{Controlling GDB}).
  10386. @smallexample
  10387. (@value{GDBP}) show print frame-arguments
  10388. Printing of non-scalar frame arguments is "scalars".
  10389. (@value{GDBP}) p $_gdb_setting_str("print frame-arguments")
  10390. $1 = "scalars"
  10391. (@value{GDBP}) p $_gdb_setting_str("height")
  10392. $2 = "30"
  10393. (@value{GDBP})
  10394. @end smallexample
  10395. @item $_gdb_setting (@var{setting})
  10396. @findex $_gdb_setting@r{, convenience function}
  10397. Return the value of the @value{GDBN} @var{setting}.
  10398. The type of the returned value depends on the setting.
  10399. The value type for boolean and auto boolean settings is @code{int}.
  10400. The boolean values @code{off} and @code{on} are converted to
  10401. the integer values @code{0} and @code{1}. The value @code{auto} is
  10402. converted to the value @code{-1}.
  10403. The value type for integer settings is either @code{unsigned int}
  10404. or @code{int}, depending on the setting.
  10405. Some integer settings accept an @code{unlimited} value.
  10406. Depending on the setting, the @code{set} command also accepts
  10407. the value @code{0} or the value @code{@minus{}1} as a synonym for
  10408. @code{unlimited}.
  10409. For example, @code{set height unlimited} is equivalent to
  10410. @code{set height 0}.
  10411. Some other settings that accept the @code{unlimited} value
  10412. use the value @code{0} to literally mean zero.
  10413. For example, @code{set history size 0} indicates to not
  10414. record any @value{GDBN} commands in the command history.
  10415. For such settings, @code{@minus{}1} is the synonym
  10416. for @code{unlimited}.
  10417. See the documentation of the corresponding @code{set} command for
  10418. the numerical value equivalent to @code{unlimited}.
  10419. The @code{$_gdb_setting} function converts the unlimited value
  10420. to a @code{0} or a @code{@minus{}1} value according to what the
  10421. @code{set} command uses.
  10422. @smallexample
  10423. @group
  10424. (@value{GDBP}) p $_gdb_setting_str("height")
  10425. $1 = "30"
  10426. (@value{GDBP}) p $_gdb_setting("height")
  10427. $2 = 30
  10428. (@value{GDBP}) set height unlimited
  10429. (@value{GDBP}) p $_gdb_setting_str("height")
  10430. $3 = "unlimited"
  10431. (@value{GDBP}) p $_gdb_setting("height")
  10432. $4 = 0
  10433. @end group
  10434. @group
  10435. (@value{GDBP}) p $_gdb_setting_str("history size")
  10436. $5 = "unlimited"
  10437. (@value{GDBP}) p $_gdb_setting("history size")
  10438. $6 = -1
  10439. (@value{GDBP}) p $_gdb_setting_str("disassemble-next-line")
  10440. $7 = "auto"
  10441. (@value{GDBP}) p $_gdb_setting("disassemble-next-line")
  10442. $8 = -1
  10443. (@value{GDBP})
  10444. @end group
  10445. @end smallexample
  10446. Other setting types (enum, filename, optional filename, string, string noescape)
  10447. are returned as string values.
  10448. @item $_gdb_maint_setting_str (@var{setting})
  10449. @findex $_gdb_maint_setting_str@r{, convenience function}
  10450. Like the @code{$_gdb_setting_str} function, but works with
  10451. @code{maintenance set} variables.
  10452. @item $_gdb_maint_setting (@var{setting})
  10453. @findex $_gdb_maint_setting@r{, convenience function}
  10454. Like the @code{$_gdb_setting} function, but works with
  10455. @code{maintenance set} variables.
  10456. @end table
  10457. The following functions require @value{GDBN} to be configured with
  10458. @code{Python} support.
  10459. @table @code
  10460. @item $_memeq(@var{buf1}, @var{buf2}, @var{length})
  10461. @findex $_memeq@r{, convenience function}
  10462. Returns one if the @var{length} bytes at the addresses given by
  10463. @var{buf1} and @var{buf2} are equal.
  10464. Otherwise it returns zero.
  10465. @item $_regex(@var{str}, @var{regex})
  10466. @findex $_regex@r{, convenience function}
  10467. Returns one if the string @var{str} matches the regular expression
  10468. @var{regex}. Otherwise it returns zero.
  10469. The syntax of the regular expression is that specified by @code{Python}'s
  10470. regular expression support.
  10471. @item $_streq(@var{str1}, @var{str2})
  10472. @findex $_streq@r{, convenience function}
  10473. Returns one if the strings @var{str1} and @var{str2} are equal.
  10474. Otherwise it returns zero.
  10475. @item $_strlen(@var{str})
  10476. @findex $_strlen@r{, convenience function}
  10477. Returns the length of string @var{str}.
  10478. @item $_caller_is(@var{name}@r{[}, @var{number_of_frames}@r{]})
  10479. @findex $_caller_is@r{, convenience function}
  10480. Returns one if the calling function's name is equal to @var{name}.
  10481. Otherwise it returns zero.
  10482. If the optional argument @var{number_of_frames} is provided,
  10483. it is the number of frames up in the stack to look.
  10484. The default is 1.
  10485. Example:
  10486. @smallexample
  10487. (gdb) backtrace
  10488. #0 bottom_func ()
  10489. at testsuite/gdb.python/py-caller-is.c:21
  10490. #1 0x00000000004005a0 in middle_func ()
  10491. at testsuite/gdb.python/py-caller-is.c:27
  10492. #2 0x00000000004005ab in top_func ()
  10493. at testsuite/gdb.python/py-caller-is.c:33
  10494. #3 0x00000000004005b6 in main ()
  10495. at testsuite/gdb.python/py-caller-is.c:39
  10496. (gdb) print $_caller_is ("middle_func")
  10497. $1 = 1
  10498. (gdb) print $_caller_is ("top_func", 2)
  10499. $1 = 1
  10500. @end smallexample
  10501. @item $_caller_matches(@var{regexp}@r{[}, @var{number_of_frames}@r{]})
  10502. @findex $_caller_matches@r{, convenience function}
  10503. Returns one if the calling function's name matches the regular expression
  10504. @var{regexp}. Otherwise it returns zero.
  10505. If the optional argument @var{number_of_frames} is provided,
  10506. it is the number of frames up in the stack to look.
  10507. The default is 1.
  10508. @item $_any_caller_is(@var{name}@r{[}, @var{number_of_frames}@r{]})
  10509. @findex $_any_caller_is@r{, convenience function}
  10510. Returns one if any calling function's name is equal to @var{name}.
  10511. Otherwise it returns zero.
  10512. If the optional argument @var{number_of_frames} is provided,
  10513. it is the number of frames up in the stack to look.
  10514. The default is 1.
  10515. This function differs from @code{$_caller_is} in that this function
  10516. checks all stack frames from the immediate caller to the frame specified
  10517. by @var{number_of_frames}, whereas @code{$_caller_is} only checks the
  10518. frame specified by @var{number_of_frames}.
  10519. @item $_any_caller_matches(@var{regexp}@r{[}, @var{number_of_frames}@r{]})
  10520. @findex $_any_caller_matches@r{, convenience function}
  10521. Returns one if any calling function's name matches the regular expression
  10522. @var{regexp}. Otherwise it returns zero.
  10523. If the optional argument @var{number_of_frames} is provided,
  10524. it is the number of frames up in the stack to look.
  10525. The default is 1.
  10526. This function differs from @code{$_caller_matches} in that this function
  10527. checks all stack frames from the immediate caller to the frame specified
  10528. by @var{number_of_frames}, whereas @code{$_caller_matches} only checks the
  10529. frame specified by @var{number_of_frames}.
  10530. @item $_as_string(@var{value})
  10531. @findex $_as_string@r{, convenience function}
  10532. Return the string representation of @var{value}.
  10533. This function is useful to obtain the textual label (enumerator) of an
  10534. enumeration value. For example, assuming the variable @var{node} is of
  10535. an enumerated type:
  10536. @smallexample
  10537. (gdb) printf "Visiting node of type %s\n", $_as_string(node)
  10538. Visiting node of type NODE_INTEGER
  10539. @end smallexample
  10540. @item $_cimag(@var{value})
  10541. @itemx $_creal(@var{value})
  10542. @findex $_cimag@r{, convenience function}
  10543. @findex $_creal@r{, convenience function}
  10544. Return the imaginary (@code{$_cimag}) or real (@code{$_creal}) part of
  10545. the complex number @var{value}.
  10546. The type of the imaginary or real part depends on the type of the
  10547. complex number, e.g., using @code{$_cimag} on a @code{float complex}
  10548. will return an imaginary part of type @code{float}.
  10549. @end table
  10550. @value{GDBN} provides the ability to list and get help on
  10551. convenience functions.
  10552. @table @code
  10553. @item help function
  10554. @kindex help function
  10555. @cindex show all convenience functions
  10556. Print a list of all convenience functions.
  10557. @end table
  10558. @node Registers
  10559. @section Registers
  10560. @cindex registers
  10561. You can refer to machine register contents, in expressions, as variables
  10562. with names starting with @samp{$}. The names of registers are different
  10563. for each machine; use @code{info registers} to see the names used on
  10564. your machine.
  10565. @table @code
  10566. @kindex info registers
  10567. @item info registers
  10568. Print the names and values of all registers except floating-point
  10569. and vector registers (in the selected stack frame).
  10570. @kindex info all-registers
  10571. @cindex floating point registers
  10572. @item info all-registers
  10573. Print the names and values of all registers, including floating-point
  10574. and vector registers (in the selected stack frame).
  10575. @anchor{info_registers_reggroup}
  10576. @item info registers @var{reggroup} @dots{}
  10577. Print the name and value of the registers in each of the specified
  10578. @var{reggroup}s. The @var{reggroup} can be any of those returned by
  10579. @code{maint print reggroups} (@pxref{Maintenance Commands}).
  10580. @item info registers @var{regname} @dots{}
  10581. Print the @dfn{relativized} value of each specified register @var{regname}.
  10582. As discussed in detail below, register values are normally relative to
  10583. the selected stack frame. The @var{regname} may be any register name valid on
  10584. the machine you are using, with or without the initial @samp{$}.
  10585. @end table
  10586. @anchor{standard registers}
  10587. @cindex stack pointer register
  10588. @cindex program counter register
  10589. @cindex process status register
  10590. @cindex frame pointer register
  10591. @cindex standard registers
  10592. @value{GDBN} has four ``standard'' register names that are available (in
  10593. expressions) on most machines---whenever they do not conflict with an
  10594. architecture's canonical mnemonics for registers. The register names
  10595. @code{$pc} and @code{$sp} are used for the program counter register and
  10596. the stack pointer. @code{$fp} is used for a register that contains a
  10597. pointer to the current stack frame, and @code{$ps} is used for a
  10598. register that contains the processor status. For example,
  10599. you could print the program counter in hex with
  10600. @smallexample
  10601. p/x $pc
  10602. @end smallexample
  10603. @noindent
  10604. or print the instruction to be executed next with
  10605. @smallexample
  10606. x/i $pc
  10607. @end smallexample
  10608. @noindent
  10609. or add four to the stack pointer@footnote{This is a way of removing
  10610. one word from the stack, on machines where stacks grow downward in
  10611. memory (most machines, nowadays). This assumes that the innermost
  10612. stack frame is selected; setting @code{$sp} is not allowed when other
  10613. stack frames are selected. To pop entire frames off the stack,
  10614. regardless of machine architecture, use @code{return};
  10615. see @ref{Returning, ,Returning from a Function}.} with
  10616. @smallexample
  10617. set $sp += 4
  10618. @end smallexample
  10619. Whenever possible, these four standard register names are available on
  10620. your machine even though the machine has different canonical mnemonics,
  10621. so long as there is no conflict. The @code{info registers} command
  10622. shows the canonical names. For example, on the SPARC, @code{info
  10623. registers} displays the processor status register as @code{$psr} but you
  10624. can also refer to it as @code{$ps}; and on x86-based machines @code{$ps}
  10625. is an alias for the @sc{eflags} register.
  10626. @value{GDBN} always considers the contents of an ordinary register as an
  10627. integer when the register is examined in this way. Some machines have
  10628. special registers which can hold nothing but floating point; these
  10629. registers are considered to have floating point values. There is no way
  10630. to refer to the contents of an ordinary register as floating point value
  10631. (although you can @emph{print} it as a floating point value with
  10632. @samp{print/f $@var{regname}}).
  10633. Some registers have distinct ``raw'' and ``virtual'' data formats. This
  10634. means that the data format in which the register contents are saved by
  10635. the operating system is not the same one that your program normally
  10636. sees. For example, the registers of the 68881 floating point
  10637. coprocessor are always saved in ``extended'' (raw) format, but all C
  10638. programs expect to work with ``double'' (virtual) format. In such
  10639. cases, @value{GDBN} normally works with the virtual format only (the format
  10640. that makes sense for your program), but the @code{info registers} command
  10641. prints the data in both formats.
  10642. @cindex SSE registers (x86)
  10643. @cindex MMX registers (x86)
  10644. Some machines have special registers whose contents can be interpreted
  10645. in several different ways. For example, modern x86-based machines
  10646. have SSE and MMX registers that can hold several values packed
  10647. together in several different formats. @value{GDBN} refers to such
  10648. registers in @code{struct} notation:
  10649. @smallexample
  10650. (@value{GDBP}) print $xmm1
  10651. $1 = @{
  10652. v4_float = @{0, 3.43859137e-038, 1.54142831e-044, 1.821688e-044@},
  10653. v2_double = @{9.92129282474342e-303, 2.7585945287983262e-313@},
  10654. v16_int8 = "\000\000\000\000\3706;\001\v\000\000\000\r\000\000",
  10655. v8_int16 = @{0, 0, 14072, 315, 11, 0, 13, 0@},
  10656. v4_int32 = @{0, 20657912, 11, 13@},
  10657. v2_int64 = @{88725056443645952, 55834574859@},
  10658. uint128 = 0x0000000d0000000b013b36f800000000
  10659. @}
  10660. @end smallexample
  10661. @noindent
  10662. To set values of such registers, you need to tell @value{GDBN} which
  10663. view of the register you wish to change, as if you were assigning
  10664. value to a @code{struct} member:
  10665. @smallexample
  10666. (@value{GDBP}) set $xmm1.uint128 = 0x000000000000000000000000FFFFFFFF
  10667. @end smallexample
  10668. Normally, register values are relative to the selected stack frame
  10669. (@pxref{Selection, ,Selecting a Frame}). This means that you get the
  10670. value that the register would contain if all stack frames farther in
  10671. were exited and their saved registers restored. In order to see the
  10672. true contents of hardware registers, you must select the innermost
  10673. frame (with @samp{frame 0}).
  10674. @cindex caller-saved registers
  10675. @cindex call-clobbered registers
  10676. @cindex volatile registers
  10677. @cindex <not saved> values
  10678. Usually ABIs reserve some registers as not needed to be saved by the
  10679. callee (a.k.a.: ``caller-saved'', ``call-clobbered'' or ``volatile''
  10680. registers). It may therefore not be possible for @value{GDBN} to know
  10681. the value a register had before the call (in other words, in the outer
  10682. frame), if the register value has since been changed by the callee.
  10683. @value{GDBN} tries to deduce where the inner frame saved
  10684. (``callee-saved'') registers, from the debug info, unwind info, or the
  10685. machine code generated by your compiler. If some register is not
  10686. saved, and @value{GDBN} knows the register is ``caller-saved'' (via
  10687. its own knowledge of the ABI, or because the debug/unwind info
  10688. explicitly says the register's value is undefined), @value{GDBN}
  10689. displays @w{@samp{<not saved>}} as the register's value. With targets
  10690. that @value{GDBN} has no knowledge of the register saving convention,
  10691. if a register was not saved by the callee, then its value and location
  10692. in the outer frame are assumed to be the same of the inner frame.
  10693. This is usually harmless, because if the register is call-clobbered,
  10694. the caller either does not care what is in the register after the
  10695. call, or has code to restore the value that it does care about. Note,
  10696. however, that if you change such a register in the outer frame, you
  10697. may also be affecting the inner frame. Also, the more ``outer'' the
  10698. frame is you're looking at, the more likely a call-clobbered
  10699. register's value is to be wrong, in the sense that it doesn't actually
  10700. represent the value the register had just before the call.
  10701. @node Floating Point Hardware
  10702. @section Floating Point Hardware
  10703. @cindex floating point
  10704. Depending on the configuration, @value{GDBN} may be able to give
  10705. you more information about the status of the floating point hardware.
  10706. @table @code
  10707. @kindex info float
  10708. @item info float
  10709. Display hardware-dependent information about the floating
  10710. point unit. The exact contents and layout vary depending on the
  10711. floating point chip. Currently, @samp{info float} is supported on
  10712. the ARM and x86 machines.
  10713. @end table
  10714. @node Vector Unit
  10715. @section Vector Unit
  10716. @cindex vector unit
  10717. Depending on the configuration, @value{GDBN} may be able to give you
  10718. more information about the status of the vector unit.
  10719. @table @code
  10720. @kindex info vector
  10721. @item info vector
  10722. Display information about the vector unit. The exact contents and
  10723. layout vary depending on the hardware.
  10724. @end table
  10725. @node OS Information
  10726. @section Operating System Auxiliary Information
  10727. @cindex OS information
  10728. @value{GDBN} provides interfaces to useful OS facilities that can help
  10729. you debug your program.
  10730. @cindex auxiliary vector
  10731. @cindex vector, auxiliary
  10732. Some operating systems supply an @dfn{auxiliary vector} to programs at
  10733. startup. This is akin to the arguments and environment that you
  10734. specify for a program, but contains a system-dependent variety of
  10735. binary values that tell system libraries important details about the
  10736. hardware, operating system, and process. Each value's purpose is
  10737. identified by an integer tag; the meanings are well-known but system-specific.
  10738. Depending on the configuration and operating system facilities,
  10739. @value{GDBN} may be able to show you this information. For remote
  10740. targets, this functionality may further depend on the remote stub's
  10741. support of the @samp{qXfer:auxv:read} packet, see
  10742. @ref{qXfer auxiliary vector read}.
  10743. @table @code
  10744. @kindex info auxv
  10745. @item info auxv
  10746. Display the auxiliary vector of the inferior, which can be either a
  10747. live process or a core dump file. @value{GDBN} prints each tag value
  10748. numerically, and also shows names and text descriptions for recognized
  10749. tags. Some values in the vector are numbers, some bit masks, and some
  10750. pointers to strings or other data. @value{GDBN} displays each value in the
  10751. most appropriate form for a recognized tag, and in hexadecimal for
  10752. an unrecognized tag.
  10753. @end table
  10754. On some targets, @value{GDBN} can access operating system-specific
  10755. information and show it to you. The types of information available
  10756. will differ depending on the type of operating system running on the
  10757. target. The mechanism used to fetch the data is described in
  10758. @ref{Operating System Information}. For remote targets, this
  10759. functionality depends on the remote stub's support of the
  10760. @samp{qXfer:osdata:read} packet, see @ref{qXfer osdata read}.
  10761. @table @code
  10762. @kindex info os
  10763. @item info os @var{infotype}
  10764. Display OS information of the requested type.
  10765. On @sc{gnu}/Linux, the following values of @var{infotype} are valid:
  10766. @anchor{linux info os infotypes}
  10767. @table @code
  10768. @kindex info os cpus
  10769. @item cpus
  10770. Display the list of all CPUs/cores. For each CPU/core, @value{GDBN} prints
  10771. the available fields from /proc/cpuinfo. For each supported architecture
  10772. different fields are available. Two common entries are processor which gives
  10773. CPU number and bogomips; a system constant that is calculated during
  10774. kernel initialization.
  10775. @kindex info os files
  10776. @item files
  10777. Display the list of open file descriptors on the target. For each
  10778. file descriptor, @value{GDBN} prints the identifier of the process
  10779. owning the descriptor, the command of the owning process, the value
  10780. of the descriptor, and the target of the descriptor.
  10781. @kindex info os modules
  10782. @item modules
  10783. Display the list of all loaded kernel modules on the target. For each
  10784. module, @value{GDBN} prints the module name, the size of the module in
  10785. bytes, the number of times the module is used, the dependencies of the
  10786. module, the status of the module, and the address of the loaded module
  10787. in memory.
  10788. @kindex info os msg
  10789. @item msg
  10790. Display the list of all System V message queues on the target. For each
  10791. message queue, @value{GDBN} prints the message queue key, the message
  10792. queue identifier, the access permissions, the current number of bytes
  10793. on the queue, the current number of messages on the queue, the processes
  10794. that last sent and received a message on the queue, the user and group
  10795. of the owner and creator of the message queue, the times at which a
  10796. message was last sent and received on the queue, and the time at which
  10797. the message queue was last changed.
  10798. @kindex info os processes
  10799. @item processes
  10800. Display the list of processes on the target. For each process,
  10801. @value{GDBN} prints the process identifier, the name of the user, the
  10802. command corresponding to the process, and the list of processor cores
  10803. that the process is currently running on. (To understand what these
  10804. properties mean, for this and the following info types, please consult
  10805. the general @sc{gnu}/Linux documentation.)
  10806. @kindex info os procgroups
  10807. @item procgroups
  10808. Display the list of process groups on the target. For each process,
  10809. @value{GDBN} prints the identifier of the process group that it belongs
  10810. to, the command corresponding to the process group leader, the process
  10811. identifier, and the command line of the process. The list is sorted
  10812. first by the process group identifier, then by the process identifier,
  10813. so that processes belonging to the same process group are grouped together
  10814. and the process group leader is listed first.
  10815. @kindex info os semaphores
  10816. @item semaphores
  10817. Display the list of all System V semaphore sets on the target. For each
  10818. semaphore set, @value{GDBN} prints the semaphore set key, the semaphore
  10819. set identifier, the access permissions, the number of semaphores in the
  10820. set, the user and group of the owner and creator of the semaphore set,
  10821. and the times at which the semaphore set was operated upon and changed.
  10822. @kindex info os shm
  10823. @item shm
  10824. Display the list of all System V shared-memory regions on the target.
  10825. For each shared-memory region, @value{GDBN} prints the region key,
  10826. the shared-memory identifier, the access permissions, the size of the
  10827. region, the process that created the region, the process that last
  10828. attached to or detached from the region, the current number of live
  10829. attaches to the region, and the times at which the region was last
  10830. attached to, detach from, and changed.
  10831. @kindex info os sockets
  10832. @item sockets
  10833. Display the list of Internet-domain sockets on the target. For each
  10834. socket, @value{GDBN} prints the address and port of the local and
  10835. remote endpoints, the current state of the connection, the creator of
  10836. the socket, the IP address family of the socket, and the type of the
  10837. connection.
  10838. @kindex info os threads
  10839. @item threads
  10840. Display the list of threads running on the target. For each thread,
  10841. @value{GDBN} prints the identifier of the process that the thread
  10842. belongs to, the command of the process, the thread identifier, and the
  10843. processor core that it is currently running on. The main thread of a
  10844. process is not listed.
  10845. @end table
  10846. @item info os
  10847. If @var{infotype} is omitted, then list the possible values for
  10848. @var{infotype} and the kind of OS information available for each
  10849. @var{infotype}. If the target does not return a list of possible
  10850. types, this command will report an error.
  10851. @end table
  10852. @node Memory Region Attributes
  10853. @section Memory Region Attributes
  10854. @cindex memory region attributes
  10855. @dfn{Memory region attributes} allow you to describe special handling
  10856. required by regions of your target's memory. @value{GDBN} uses
  10857. attributes to determine whether to allow certain types of memory
  10858. accesses; whether to use specific width accesses; and whether to cache
  10859. target memory. By default the description of memory regions is
  10860. fetched from the target (if the current target supports this), but the
  10861. user can override the fetched regions.
  10862. Defined memory regions can be individually enabled and disabled. When a
  10863. memory region is disabled, @value{GDBN} uses the default attributes when
  10864. accessing memory in that region. Similarly, if no memory regions have
  10865. been defined, @value{GDBN} uses the default attributes when accessing
  10866. all memory.
  10867. When a memory region is defined, it is given a number to identify it;
  10868. to enable, disable, or remove a memory region, you specify that number.
  10869. @table @code
  10870. @kindex mem
  10871. @item mem @var{lower} @var{upper} @var{attributes}@dots{}
  10872. Define a memory region bounded by @var{lower} and @var{upper} with
  10873. attributes @var{attributes}@dots{}, and add it to the list of regions
  10874. monitored by @value{GDBN}. Note that @var{upper} == 0 is a special
  10875. case: it is treated as the target's maximum memory address.
  10876. (0xffff on 16 bit targets, 0xffffffff on 32 bit targets, etc.)
  10877. @item mem auto
  10878. Discard any user changes to the memory regions and use target-supplied
  10879. regions, if available, or no regions if the target does not support.
  10880. @kindex delete mem
  10881. @item delete mem @var{nums}@dots{}
  10882. Remove memory regions @var{nums}@dots{} from the list of regions
  10883. monitored by @value{GDBN}.
  10884. @kindex disable mem
  10885. @item disable mem @var{nums}@dots{}
  10886. Disable monitoring of memory regions @var{nums}@dots{}.
  10887. A disabled memory region is not forgotten.
  10888. It may be enabled again later.
  10889. @kindex enable mem
  10890. @item enable mem @var{nums}@dots{}
  10891. Enable monitoring of memory regions @var{nums}@dots{}.
  10892. @kindex info mem
  10893. @item info mem
  10894. Print a table of all defined memory regions, with the following columns
  10895. for each region:
  10896. @table @emph
  10897. @item Memory Region Number
  10898. @item Enabled or Disabled.
  10899. Enabled memory regions are marked with @samp{y}.
  10900. Disabled memory regions are marked with @samp{n}.
  10901. @item Lo Address
  10902. The address defining the inclusive lower bound of the memory region.
  10903. @item Hi Address
  10904. The address defining the exclusive upper bound of the memory region.
  10905. @item Attributes
  10906. The list of attributes set for this memory region.
  10907. @end table
  10908. @end table
  10909. @subsection Attributes
  10910. @subsubsection Memory Access Mode
  10911. The access mode attributes set whether @value{GDBN} may make read or
  10912. write accesses to a memory region.
  10913. While these attributes prevent @value{GDBN} from performing invalid
  10914. memory accesses, they do nothing to prevent the target system, I/O DMA,
  10915. etc.@: from accessing memory.
  10916. @table @code
  10917. @item ro
  10918. Memory is read only.
  10919. @item wo
  10920. Memory is write only.
  10921. @item rw
  10922. Memory is read/write. This is the default.
  10923. @end table
  10924. @subsubsection Memory Access Size
  10925. The access size attribute tells @value{GDBN} to use specific sized
  10926. accesses in the memory region. Often memory mapped device registers
  10927. require specific sized accesses. If no access size attribute is
  10928. specified, @value{GDBN} may use accesses of any size.
  10929. @table @code
  10930. @item 8
  10931. Use 8 bit memory accesses.
  10932. @item 16
  10933. Use 16 bit memory accesses.
  10934. @item 32
  10935. Use 32 bit memory accesses.
  10936. @item 64
  10937. Use 64 bit memory accesses.
  10938. @end table
  10939. @c @subsubsection Hardware/Software Breakpoints
  10940. @c The hardware/software breakpoint attributes set whether @value{GDBN}
  10941. @c will use hardware or software breakpoints for the internal breakpoints
  10942. @c used by the step, next, finish, until, etc. commands.
  10943. @c
  10944. @c @table @code
  10945. @c @item hwbreak
  10946. @c Always use hardware breakpoints
  10947. @c @item swbreak (default)
  10948. @c @end table
  10949. @subsubsection Data Cache
  10950. The data cache attributes set whether @value{GDBN} will cache target
  10951. memory. While this generally improves performance by reducing debug
  10952. protocol overhead, it can lead to incorrect results because @value{GDBN}
  10953. does not know about volatile variables or memory mapped device
  10954. registers.
  10955. @table @code
  10956. @item cache
  10957. Enable @value{GDBN} to cache target memory.
  10958. @item nocache
  10959. Disable @value{GDBN} from caching target memory. This is the default.
  10960. @end table
  10961. @subsection Memory Access Checking
  10962. @value{GDBN} can be instructed to refuse accesses to memory that is
  10963. not explicitly described. This can be useful if accessing such
  10964. regions has undesired effects for a specific target, or to provide
  10965. better error checking. The following commands control this behaviour.
  10966. @table @code
  10967. @kindex set mem inaccessible-by-default
  10968. @item set mem inaccessible-by-default [on|off]
  10969. If @code{on} is specified, make @value{GDBN} treat memory not
  10970. explicitly described by the memory ranges as non-existent and refuse accesses
  10971. to such memory. The checks are only performed if there's at least one
  10972. memory range defined. If @code{off} is specified, make @value{GDBN}
  10973. treat the memory not explicitly described by the memory ranges as RAM.
  10974. The default value is @code{on}.
  10975. @kindex show mem inaccessible-by-default
  10976. @item show mem inaccessible-by-default
  10977. Show the current handling of accesses to unknown memory.
  10978. @end table
  10979. @c @subsubsection Memory Write Verification
  10980. @c The memory write verification attributes set whether @value{GDBN}
  10981. @c will re-reads data after each write to verify the write was successful.
  10982. @c
  10983. @c @table @code
  10984. @c @item verify
  10985. @c @item noverify (default)
  10986. @c @end table
  10987. @node Dump/Restore Files
  10988. @section Copy Between Memory and a File
  10989. @cindex dump/restore files
  10990. @cindex append data to a file
  10991. @cindex dump data to a file
  10992. @cindex restore data from a file
  10993. You can use the commands @code{dump}, @code{append}, and
  10994. @code{restore} to copy data between target memory and a file. The
  10995. @code{dump} and @code{append} commands write data to a file, and the
  10996. @code{restore} command reads data from a file back into the inferior's
  10997. memory. Files may be in binary, Motorola S-record, Intel hex,
  10998. Tektronix Hex, or Verilog Hex format; however, @value{GDBN} can only
  10999. append to binary files, and cannot read from Verilog Hex files.
  11000. @table @code
  11001. @kindex dump
  11002. @item dump @r{[}@var{format}@r{]} memory @var{filename} @var{start_addr} @var{end_addr}
  11003. @itemx dump @r{[}@var{format}@r{]} value @var{filename} @var{expr}
  11004. Dump the contents of memory from @var{start_addr} to @var{end_addr},
  11005. or the value of @var{expr}, to @var{filename} in the given format.
  11006. The @var{format} parameter may be any one of:
  11007. @table @code
  11008. @item binary
  11009. Raw binary form.
  11010. @item ihex
  11011. Intel hex format.
  11012. @item srec
  11013. Motorola S-record format.
  11014. @item tekhex
  11015. Tektronix Hex format.
  11016. @item verilog
  11017. Verilog Hex format.
  11018. @end table
  11019. @value{GDBN} uses the same definitions of these formats as the
  11020. @sc{gnu} binary utilities, like @samp{objdump} and @samp{objcopy}. If
  11021. @var{format} is omitted, @value{GDBN} dumps the data in raw binary
  11022. form.
  11023. @kindex append
  11024. @item append @r{[}binary@r{]} memory @var{filename} @var{start_addr} @var{end_addr}
  11025. @itemx append @r{[}binary@r{]} value @var{filename} @var{expr}
  11026. Append the contents of memory from @var{start_addr} to @var{end_addr},
  11027. or the value of @var{expr}, to the file @var{filename}, in raw binary form.
  11028. (@value{GDBN} can only append data to files in raw binary form.)
  11029. @kindex restore
  11030. @item restore @var{filename} @r{[}binary@r{]} @var{bias} @var{start} @var{end}
  11031. Restore the contents of file @var{filename} into memory. The
  11032. @code{restore} command can automatically recognize any known @sc{bfd}
  11033. file format, except for raw binary. To restore a raw binary file you
  11034. must specify the optional keyword @code{binary} after the filename.
  11035. If @var{bias} is non-zero, its value will be added to the addresses
  11036. contained in the file. Binary files always start at address zero, so
  11037. they will be restored at address @var{bias}. Other bfd files have
  11038. a built-in location; they will be restored at offset @var{bias}
  11039. from that location.
  11040. If @var{start} and/or @var{end} are non-zero, then only data between
  11041. file offset @var{start} and file offset @var{end} will be restored.
  11042. These offsets are relative to the addresses in the file, before
  11043. the @var{bias} argument is applied.
  11044. @end table
  11045. @node Core File Generation
  11046. @section How to Produce a Core File from Your Program
  11047. @cindex dump core from inferior
  11048. A @dfn{core file} or @dfn{core dump} is a file that records the memory
  11049. image of a running process and its process status (register values
  11050. etc.). Its primary use is post-mortem debugging of a program that
  11051. crashed while it ran outside a debugger. A program that crashes
  11052. automatically produces a core file, unless this feature is disabled by
  11053. the user. @xref{Files}, for information on invoking @value{GDBN} in
  11054. the post-mortem debugging mode.
  11055. Occasionally, you may wish to produce a core file of the program you
  11056. are debugging in order to preserve a snapshot of its state.
  11057. @value{GDBN} has a special command for that.
  11058. @table @code
  11059. @kindex gcore
  11060. @kindex generate-core-file
  11061. @item generate-core-file [@var{file}]
  11062. @itemx gcore [@var{file}]
  11063. Produce a core dump of the inferior process. The optional argument
  11064. @var{file} specifies the file name where to put the core dump. If not
  11065. specified, the file name defaults to @file{core.@var{pid}}, where
  11066. @var{pid} is the inferior process ID.
  11067. Note that this command is implemented only for some systems (as of
  11068. this writing, @sc{gnu}/Linux, FreeBSD, Solaris, and S390).
  11069. On @sc{gnu}/Linux, this command can take into account the value of the
  11070. file @file{/proc/@var{pid}/coredump_filter} when generating the core
  11071. dump (@pxref{set use-coredump-filter}), and by default honors the
  11072. @code{VM_DONTDUMP} flag for mappings where it is present in the file
  11073. @file{/proc/@var{pid}/smaps} (@pxref{set dump-excluded-mappings}).
  11074. @kindex set use-coredump-filter
  11075. @anchor{set use-coredump-filter}
  11076. @item set use-coredump-filter on
  11077. @itemx set use-coredump-filter off
  11078. Enable or disable the use of the file
  11079. @file{/proc/@var{pid}/coredump_filter} when generating core dump
  11080. files. This file is used by the Linux kernel to decide what types of
  11081. memory mappings will be dumped or ignored when generating a core dump
  11082. file. @var{pid} is the process ID of a currently running process.
  11083. To make use of this feature, you have to write in the
  11084. @file{/proc/@var{pid}/coredump_filter} file a value, in hexadecimal,
  11085. which is a bit mask representing the memory mapping types. If a bit
  11086. is set in the bit mask, then the memory mappings of the corresponding
  11087. types will be dumped; otherwise, they will be ignored. This
  11088. configuration is inherited by child processes. For more information
  11089. about the bits that can be set in the
  11090. @file{/proc/@var{pid}/coredump_filter} file, please refer to the
  11091. manpage of @code{core(5)}.
  11092. By default, this option is @code{on}. If this option is turned
  11093. @code{off}, @value{GDBN} does not read the @file{coredump_filter} file
  11094. and instead uses the same default value as the Linux kernel in order
  11095. to decide which pages will be dumped in the core dump file. This
  11096. value is currently @code{0x33}, which means that bits @code{0}
  11097. (anonymous private mappings), @code{1} (anonymous shared mappings),
  11098. @code{4} (ELF headers) and @code{5} (private huge pages) are active.
  11099. This will cause these memory mappings to be dumped automatically.
  11100. @kindex set dump-excluded-mappings
  11101. @anchor{set dump-excluded-mappings}
  11102. @item set dump-excluded-mappings on
  11103. @itemx set dump-excluded-mappings off
  11104. If @code{on} is specified, @value{GDBN} will dump memory mappings
  11105. marked with the @code{VM_DONTDUMP} flag. This flag is represented in
  11106. the file @file{/proc/@var{pid}/smaps} with the acronym @code{dd}.
  11107. The default value is @code{off}.
  11108. @end table
  11109. @node Character Sets
  11110. @section Character Sets
  11111. @cindex character sets
  11112. @cindex charset
  11113. @cindex translating between character sets
  11114. @cindex host character set
  11115. @cindex target character set
  11116. If the program you are debugging uses a different character set to
  11117. represent characters and strings than the one @value{GDBN} uses itself,
  11118. @value{GDBN} can automatically translate between the character sets for
  11119. you. The character set @value{GDBN} uses we call the @dfn{host
  11120. character set}; the one the inferior program uses we call the
  11121. @dfn{target character set}.
  11122. For example, if you are running @value{GDBN} on a @sc{gnu}/Linux system, which
  11123. uses the ISO Latin 1 character set, but you are using @value{GDBN}'s
  11124. remote protocol (@pxref{Remote Debugging}) to debug a program
  11125. running on an IBM mainframe, which uses the @sc{ebcdic} character set,
  11126. then the host character set is Latin-1, and the target character set is
  11127. @sc{ebcdic}. If you give @value{GDBN} the command @code{set
  11128. target-charset EBCDIC-US}, then @value{GDBN} translates between
  11129. @sc{ebcdic} and Latin 1 as you print character or string values, or use
  11130. character and string literals in expressions.
  11131. @value{GDBN} has no way to automatically recognize which character set
  11132. the inferior program uses; you must tell it, using the @code{set
  11133. target-charset} command, described below.
  11134. Here are the commands for controlling @value{GDBN}'s character set
  11135. support:
  11136. @table @code
  11137. @item set target-charset @var{charset}
  11138. @kindex set target-charset
  11139. Set the current target character set to @var{charset}. To display the
  11140. list of supported target character sets, type
  11141. @kbd{@w{set target-charset @key{TAB}@key{TAB}}}.
  11142. @item set host-charset @var{charset}
  11143. @kindex set host-charset
  11144. Set the current host character set to @var{charset}.
  11145. By default, @value{GDBN} uses a host character set appropriate to the
  11146. system it is running on; you can override that default using the
  11147. @code{set host-charset} command. On some systems, @value{GDBN} cannot
  11148. automatically determine the appropriate host character set. In this
  11149. case, @value{GDBN} uses @samp{UTF-8}.
  11150. @value{GDBN} can only use certain character sets as its host character
  11151. set. If you type @kbd{@w{set host-charset @key{TAB}@key{TAB}}},
  11152. @value{GDBN} will list the host character sets it supports.
  11153. @item set charset @var{charset}
  11154. @kindex set charset
  11155. Set the current host and target character sets to @var{charset}. As
  11156. above, if you type @kbd{@w{set charset @key{TAB}@key{TAB}}},
  11157. @value{GDBN} will list the names of the character sets that can be used
  11158. for both host and target.
  11159. @item show charset
  11160. @kindex show charset
  11161. Show the names of the current host and target character sets.
  11162. @item show host-charset
  11163. @kindex show host-charset
  11164. Show the name of the current host character set.
  11165. @item show target-charset
  11166. @kindex show target-charset
  11167. Show the name of the current target character set.
  11168. @item set target-wide-charset @var{charset}
  11169. @kindex set target-wide-charset
  11170. Set the current target's wide character set to @var{charset}. This is
  11171. the character set used by the target's @code{wchar_t} type. To
  11172. display the list of supported wide character sets, type
  11173. @kbd{@w{set target-wide-charset @key{TAB}@key{TAB}}}.
  11174. @item show target-wide-charset
  11175. @kindex show target-wide-charset
  11176. Show the name of the current target's wide character set.
  11177. @end table
  11178. Here is an example of @value{GDBN}'s character set support in action.
  11179. Assume that the following source code has been placed in the file
  11180. @file{charset-test.c}:
  11181. @smallexample
  11182. #include <stdio.h>
  11183. char ascii_hello[]
  11184. = @{72, 101, 108, 108, 111, 44, 32, 119,
  11185. 111, 114, 108, 100, 33, 10, 0@};
  11186. char ibm1047_hello[]
  11187. = @{200, 133, 147, 147, 150, 107, 64, 166,
  11188. 150, 153, 147, 132, 90, 37, 0@};
  11189. main ()
  11190. @{
  11191. printf ("Hello, world!\n");
  11192. @}
  11193. @end smallexample
  11194. In this program, @code{ascii_hello} and @code{ibm1047_hello} are arrays
  11195. containing the string @samp{Hello, world!} followed by a newline,
  11196. encoded in the @sc{ascii} and @sc{ibm1047} character sets.
  11197. We compile the program, and invoke the debugger on it:
  11198. @smallexample
  11199. $ gcc -g charset-test.c -o charset-test
  11200. $ gdb -nw charset-test
  11201. GNU gdb 2001-12-19-cvs
  11202. Copyright 2001 Free Software Foundation, Inc.
  11203. @dots{}
  11204. (@value{GDBP})
  11205. @end smallexample
  11206. We can use the @code{show charset} command to see what character sets
  11207. @value{GDBN} is currently using to interpret and display characters and
  11208. strings:
  11209. @smallexample
  11210. (@value{GDBP}) show charset
  11211. The current host and target character set is `ISO-8859-1'.
  11212. (@value{GDBP})
  11213. @end smallexample
  11214. For the sake of printing this manual, let's use @sc{ascii} as our
  11215. initial character set:
  11216. @smallexample
  11217. (@value{GDBP}) set charset ASCII
  11218. (@value{GDBP}) show charset
  11219. The current host and target character set is `ASCII'.
  11220. (@value{GDBP})
  11221. @end smallexample
  11222. Let's assume that @sc{ascii} is indeed the correct character set for our
  11223. host system --- in other words, let's assume that if @value{GDBN} prints
  11224. characters using the @sc{ascii} character set, our terminal will display
  11225. them properly. Since our current target character set is also
  11226. @sc{ascii}, the contents of @code{ascii_hello} print legibly:
  11227. @smallexample
  11228. (@value{GDBP}) print ascii_hello
  11229. $1 = 0x401698 "Hello, world!\n"
  11230. (@value{GDBP}) print ascii_hello[0]
  11231. $2 = 72 'H'
  11232. (@value{GDBP})
  11233. @end smallexample
  11234. @value{GDBN} uses the target character set for character and string
  11235. literals you use in expressions:
  11236. @smallexample
  11237. (@value{GDBP}) print '+'
  11238. $3 = 43 '+'
  11239. (@value{GDBP})
  11240. @end smallexample
  11241. The @sc{ascii} character set uses the number 43 to encode the @samp{+}
  11242. character.
  11243. @value{GDBN} relies on the user to tell it which character set the
  11244. target program uses. If we print @code{ibm1047_hello} while our target
  11245. character set is still @sc{ascii}, we get jibberish:
  11246. @smallexample
  11247. (@value{GDBP}) print ibm1047_hello
  11248. $4 = 0x4016a8 "\310\205\223\223\226k@@\246\226\231\223\204Z%"
  11249. (@value{GDBP}) print ibm1047_hello[0]
  11250. $5 = 200 '\310'
  11251. (@value{GDBP})
  11252. @end smallexample
  11253. If we invoke the @code{set target-charset} followed by @key{TAB}@key{TAB},
  11254. @value{GDBN} tells us the character sets it supports:
  11255. @smallexample
  11256. (@value{GDBP}) set target-charset
  11257. ASCII EBCDIC-US IBM1047 ISO-8859-1
  11258. (@value{GDBP}) set target-charset
  11259. @end smallexample
  11260. We can select @sc{ibm1047} as our target character set, and examine the
  11261. program's strings again. Now the @sc{ascii} string is wrong, but
  11262. @value{GDBN} translates the contents of @code{ibm1047_hello} from the
  11263. target character set, @sc{ibm1047}, to the host character set,
  11264. @sc{ascii}, and they display correctly:
  11265. @smallexample
  11266. (@value{GDBP}) set target-charset IBM1047
  11267. (@value{GDBP}) show charset
  11268. The current host character set is `ASCII'.
  11269. The current target character set is `IBM1047'.
  11270. (@value{GDBP}) print ascii_hello
  11271. $6 = 0x401698 "\110\145%%?\054\040\167?\162%\144\041\012"
  11272. (@value{GDBP}) print ascii_hello[0]
  11273. $7 = 72 '\110'
  11274. (@value{GDBP}) print ibm1047_hello
  11275. $8 = 0x4016a8 "Hello, world!\n"
  11276. (@value{GDBP}) print ibm1047_hello[0]
  11277. $9 = 200 'H'
  11278. (@value{GDBP})
  11279. @end smallexample
  11280. As above, @value{GDBN} uses the target character set for character and
  11281. string literals you use in expressions:
  11282. @smallexample
  11283. (@value{GDBP}) print '+'
  11284. $10 = 78 '+'
  11285. (@value{GDBP})
  11286. @end smallexample
  11287. The @sc{ibm1047} character set uses the number 78 to encode the @samp{+}
  11288. character.
  11289. @node Caching Target Data
  11290. @section Caching Data of Targets
  11291. @cindex caching data of targets
  11292. @value{GDBN} caches data exchanged between the debugger and a target.
  11293. Each cache is associated with the address space of the inferior.
  11294. @xref{Inferiors Connections and Programs}, about inferior and address space.
  11295. Such caching generally improves performance in remote debugging
  11296. (@pxref{Remote Debugging}), because it reduces the overhead of the
  11297. remote protocol by bundling memory reads and writes into large chunks.
  11298. Unfortunately, simply caching everything would lead to incorrect results,
  11299. since @value{GDBN} does not necessarily know anything about volatile
  11300. values, memory-mapped I/O addresses, etc. Furthermore, in non-stop mode
  11301. (@pxref{Non-Stop Mode}) memory can be changed @emph{while} a gdb command
  11302. is executing.
  11303. Therefore, by default, @value{GDBN} only caches data
  11304. known to be on the stack@footnote{In non-stop mode, it is moderately
  11305. rare for a running thread to modify the stack of a stopped thread
  11306. in a way that would interfere with a backtrace, and caching of
  11307. stack reads provides a significant speed up of remote backtraces.} or
  11308. in the code segment.
  11309. Other regions of memory can be explicitly marked as
  11310. cacheable; @pxref{Memory Region Attributes}.
  11311. @table @code
  11312. @kindex set remotecache
  11313. @item set remotecache on
  11314. @itemx set remotecache off
  11315. This option no longer does anything; it exists for compatibility
  11316. with old scripts.
  11317. @kindex show remotecache
  11318. @item show remotecache
  11319. Show the current state of the obsolete remotecache flag.
  11320. @kindex set stack-cache
  11321. @item set stack-cache on
  11322. @itemx set stack-cache off
  11323. Enable or disable caching of stack accesses. When @code{on}, use
  11324. caching. By default, this option is @code{on}.
  11325. @kindex show stack-cache
  11326. @item show stack-cache
  11327. Show the current state of data caching for memory accesses.
  11328. @kindex set code-cache
  11329. @item set code-cache on
  11330. @itemx set code-cache off
  11331. Enable or disable caching of code segment accesses. When @code{on},
  11332. use caching. By default, this option is @code{on}. This improves
  11333. performance of disassembly in remote debugging.
  11334. @kindex show code-cache
  11335. @item show code-cache
  11336. Show the current state of target memory cache for code segment
  11337. accesses.
  11338. @kindex info dcache
  11339. @item info dcache @r{[}line@r{]}
  11340. Print the information about the performance of data cache of the
  11341. current inferior's address space. The information displayed
  11342. includes the dcache width and depth, and for each cache line, its
  11343. number, address, and how many times it was referenced. This
  11344. command is useful for debugging the data cache operation.
  11345. If a line number is specified, the contents of that line will be
  11346. printed in hex.
  11347. @item set dcache size @var{size}
  11348. @cindex dcache size
  11349. @kindex set dcache size
  11350. Set maximum number of entries in dcache (dcache depth above).
  11351. @item set dcache line-size @var{line-size}
  11352. @cindex dcache line-size
  11353. @kindex set dcache line-size
  11354. Set number of bytes each dcache entry caches (dcache width above).
  11355. Must be a power of 2.
  11356. @item show dcache size
  11357. @kindex show dcache size
  11358. Show maximum number of dcache entries. @xref{Caching Target Data, info dcache}.
  11359. @item show dcache line-size
  11360. @kindex show dcache line-size
  11361. Show default size of dcache lines.
  11362. @item maint flush dcache
  11363. @cindex dcache, flushing
  11364. @kindex maint flush dcache
  11365. Flush the contents (if any) of the dcache. This maintainer command is
  11366. useful when debugging the dcache implementation.
  11367. @end table
  11368. @node Searching Memory
  11369. @section Search Memory
  11370. @cindex searching memory
  11371. Memory can be searched for a particular sequence of bytes with the
  11372. @code{find} command.
  11373. @table @code
  11374. @kindex find
  11375. @item find @r{[}/@var{sn}@r{]} @var{start_addr}, +@var{len}, @var{val1} @r{[}, @var{val2}, @dots{}@r{]}
  11376. @itemx find @r{[}/@var{sn}@r{]} @var{start_addr}, @var{end_addr}, @var{val1} @r{[}, @var{val2}, @dots{}@r{]}
  11377. Search memory for the sequence of bytes specified by @var{val1}, @var{val2},
  11378. etc. The search begins at address @var{start_addr} and continues for either
  11379. @var{len} bytes or through to @var{end_addr} inclusive.
  11380. @end table
  11381. @var{s} and @var{n} are optional parameters.
  11382. They may be specified in either order, apart or together.
  11383. @table @r
  11384. @item @var{s}, search query size
  11385. The size of each search query value.
  11386. @table @code
  11387. @item b
  11388. bytes
  11389. @item h
  11390. halfwords (two bytes)
  11391. @item w
  11392. words (four bytes)
  11393. @item g
  11394. giant words (eight bytes)
  11395. @end table
  11396. All values are interpreted in the current language.
  11397. This means, for example, that if the current source language is C/C@t{++}
  11398. then searching for the string ``hello'' includes the trailing '\0'.
  11399. The null terminator can be removed from searching by using casts,
  11400. e.g.: @samp{@{char[5]@}"hello"}.
  11401. If the value size is not specified, it is taken from the
  11402. value's type in the current language.
  11403. This is useful when one wants to specify the search
  11404. pattern as a mixture of types.
  11405. Note that this means, for example, that in the case of C-like languages
  11406. a search for an untyped 0x42 will search for @samp{(int) 0x42}
  11407. which is typically four bytes.
  11408. @item @var{n}, maximum number of finds
  11409. The maximum number of matches to print. The default is to print all finds.
  11410. @end table
  11411. You can use strings as search values. Quote them with double-quotes
  11412. (@code{"}).
  11413. The string value is copied into the search pattern byte by byte,
  11414. regardless of the endianness of the target and the size specification.
  11415. The address of each match found is printed as well as a count of the
  11416. number of matches found.
  11417. The address of the last value found is stored in convenience variable
  11418. @samp{$_}.
  11419. A count of the number of matches is stored in @samp{$numfound}.
  11420. For example, if stopped at the @code{printf} in this function:
  11421. @smallexample
  11422. void
  11423. hello ()
  11424. @{
  11425. static char hello[] = "hello-hello";
  11426. static struct @{ char c; short s; int i; @}
  11427. __attribute__ ((packed)) mixed
  11428. = @{ 'c', 0x1234, 0x87654321 @};
  11429. printf ("%s\n", hello);
  11430. @}
  11431. @end smallexample
  11432. @noindent
  11433. you get during debugging:
  11434. @smallexample
  11435. (gdb) find &hello[0], +sizeof(hello), "hello"
  11436. 0x804956d <hello.1620+6>
  11437. 1 pattern found
  11438. (gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o'
  11439. 0x8049567 <hello.1620>
  11440. 0x804956d <hello.1620+6>
  11441. 2 patterns found.
  11442. (gdb) find &hello[0], +sizeof(hello), @{char[5]@}"hello"
  11443. 0x8049567 <hello.1620>
  11444. 0x804956d <hello.1620+6>
  11445. 2 patterns found.
  11446. (gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l'
  11447. 0x8049567 <hello.1620>
  11448. 1 pattern found
  11449. (gdb) find &mixed, +sizeof(mixed), (char) 'c', (short) 0x1234, (int) 0x87654321
  11450. 0x8049560 <mixed.1625>
  11451. 1 pattern found
  11452. (gdb) print $numfound
  11453. $1 = 1
  11454. (gdb) print $_
  11455. $2 = (void *) 0x8049560
  11456. @end smallexample
  11457. @node Value Sizes
  11458. @section Value Sizes
  11459. Whenever @value{GDBN} prints a value memory will be allocated within
  11460. @value{GDBN} to hold the contents of the value. It is possible in
  11461. some languages with dynamic typing systems, that an invalid program
  11462. may indicate a value that is incorrectly large, this in turn may cause
  11463. @value{GDBN} to try and allocate an overly large amount of memory.
  11464. @table @code
  11465. @kindex set max-value-size
  11466. @item set max-value-size @var{bytes}
  11467. @itemx set max-value-size unlimited
  11468. Set the maximum size of memory that @value{GDBN} will allocate for the
  11469. contents of a value to @var{bytes}, trying to display a value that
  11470. requires more memory than that will result in an error.
  11471. Setting this variable does not effect values that have already been
  11472. allocated within @value{GDBN}, only future allocations.
  11473. There's a minimum size that @code{max-value-size} can be set to in
  11474. order that @value{GDBN} can still operate correctly, this minimum is
  11475. currently 16 bytes.
  11476. The limit applies to the results of some subexpressions as well as to
  11477. complete expressions. For example, an expression denoting a simple
  11478. integer component, such as @code{x.y.z}, may fail if the size of
  11479. @var{x.y} is dynamic and exceeds @var{bytes}. On the other hand,
  11480. @value{GDBN} is sometimes clever; the expression @code{A[i]}, where
  11481. @var{A} is an array variable with non-constant size, will generally
  11482. succeed regardless of the bounds on @var{A}, as long as the component
  11483. size is less than @var{bytes}.
  11484. The default value of @code{max-value-size} is currently 64k.
  11485. @kindex show max-value-size
  11486. @item show max-value-size
  11487. Show the maximum size of memory, in bytes, that @value{GDBN} will
  11488. allocate for the contents of a value.
  11489. @end table
  11490. @node Optimized Code
  11491. @chapter Debugging Optimized Code
  11492. @cindex optimized code, debugging
  11493. @cindex debugging optimized code
  11494. Almost all compilers support optimization. With optimization
  11495. disabled, the compiler generates assembly code that corresponds
  11496. directly to your source code, in a simplistic way. As the compiler
  11497. applies more powerful optimizations, the generated assembly code
  11498. diverges from your original source code. With help from debugging
  11499. information generated by the compiler, @value{GDBN} can map from
  11500. the running program back to constructs from your original source.
  11501. @value{GDBN} is more accurate with optimization disabled. If you
  11502. can recompile without optimization, it is easier to follow the
  11503. progress of your program during debugging. But, there are many cases
  11504. where you may need to debug an optimized version.
  11505. When you debug a program compiled with @samp{-g -O}, remember that the
  11506. optimizer has rearranged your code; the debugger shows you what is
  11507. really there. Do not be too surprised when the execution path does not
  11508. exactly match your source file! An extreme example: if you define a
  11509. variable, but never use it, @value{GDBN} never sees that
  11510. variable---because the compiler optimizes it out of existence.
  11511. Some things do not work as well with @samp{-g -O} as with just
  11512. @samp{-g}, particularly on machines with instruction scheduling. If in
  11513. doubt, recompile with @samp{-g} alone, and if this fixes the problem,
  11514. please report it to us as a bug (including a test case!).
  11515. @xref{Variables}, for more information about debugging optimized code.
  11516. @menu
  11517. * Inline Functions:: How @value{GDBN} presents inlining
  11518. * Tail Call Frames:: @value{GDBN} analysis of jumps to functions
  11519. @end menu
  11520. @node Inline Functions
  11521. @section Inline Functions
  11522. @cindex inline functions, debugging
  11523. @dfn{Inlining} is an optimization that inserts a copy of the function
  11524. body directly at each call site, instead of jumping to a shared
  11525. routine. @value{GDBN} displays inlined functions just like
  11526. non-inlined functions. They appear in backtraces. You can view their
  11527. arguments and local variables, step into them with @code{step}, skip
  11528. them with @code{next}, and escape from them with @code{finish}.
  11529. You can check whether a function was inlined by using the
  11530. @code{info frame} command.
  11531. For @value{GDBN} to support inlined functions, the compiler must
  11532. record information about inlining in the debug information ---
  11533. @value{NGCC} using the @sc{dwarf 2} format does this, and several
  11534. other compilers do also. @value{GDBN} only supports inlined functions
  11535. when using @sc{dwarf 2}. Versions of @value{NGCC} before 4.1
  11536. do not emit two required attributes (@samp{DW_AT_call_file} and
  11537. @samp{DW_AT_call_line}); @value{GDBN} does not display inlined
  11538. function calls with earlier versions of @value{NGCC}. It instead
  11539. displays the arguments and local variables of inlined functions as
  11540. local variables in the caller.
  11541. The body of an inlined function is directly included at its call site;
  11542. unlike a non-inlined function, there are no instructions devoted to
  11543. the call. @value{GDBN} still pretends that the call site and the
  11544. start of the inlined function are different instructions. Stepping to
  11545. the call site shows the call site, and then stepping again shows
  11546. the first line of the inlined function, even though no additional
  11547. instructions are executed.
  11548. This makes source-level debugging much clearer; you can see both the
  11549. context of the call and then the effect of the call. Only stepping by
  11550. a single instruction using @code{stepi} or @code{nexti} does not do
  11551. this; single instruction steps always show the inlined body.
  11552. There are some ways that @value{GDBN} does not pretend that inlined
  11553. function calls are the same as normal calls:
  11554. @itemize @bullet
  11555. @item
  11556. Setting breakpoints at the call site of an inlined function may not
  11557. work, because the call site does not contain any code. @value{GDBN}
  11558. may incorrectly move the breakpoint to the next line of the enclosing
  11559. function, after the call. This limitation will be removed in a future
  11560. version of @value{GDBN}; until then, set a breakpoint on an earlier line
  11561. or inside the inlined function instead.
  11562. @item
  11563. @value{GDBN} cannot locate the return value of inlined calls after
  11564. using the @code{finish} command. This is a limitation of compiler-generated
  11565. debugging information; after @code{finish}, you can step to the next line
  11566. and print a variable where your program stored the return value.
  11567. @end itemize
  11568. @node Tail Call Frames
  11569. @section Tail Call Frames
  11570. @cindex tail call frames, debugging
  11571. Function @code{B} can call function @code{C} in its very last statement. In
  11572. unoptimized compilation the call of @code{C} is immediately followed by return
  11573. instruction at the end of @code{B} code. Optimizing compiler may replace the
  11574. call and return in function @code{B} into one jump to function @code{C}
  11575. instead. Such use of a jump instruction is called @dfn{tail call}.
  11576. During execution of function @code{C}, there will be no indication in the
  11577. function call stack frames that it was tail-called from @code{B}. If function
  11578. @code{A} regularly calls function @code{B} which tail-calls function @code{C},
  11579. then @value{GDBN} will see @code{A} as the caller of @code{C}. However, in
  11580. some cases @value{GDBN} can determine that @code{C} was tail-called from
  11581. @code{B}, and it will then create fictitious call frame for that, with the
  11582. return address set up as if @code{B} called @code{C} normally.
  11583. This functionality is currently supported only by DWARF 2 debugging format and
  11584. the compiler has to produce @samp{DW_TAG_call_site} tags. With
  11585. @value{NGCC}, you need to specify @option{-O -g} during compilation, to get
  11586. this information.
  11587. @kbd{info frame} command (@pxref{Frame Info}) will indicate the tail call frame
  11588. kind by text @code{tail call frame} such as in this sample @value{GDBN} output:
  11589. @smallexample
  11590. (gdb) x/i $pc - 2
  11591. 0x40066b <b(int, double)+11>: jmp 0x400640 <c(int, double)>
  11592. (gdb) info frame
  11593. Stack level 1, frame at 0x7fffffffda30:
  11594. rip = 0x40066d in b (amd64-entry-value.cc:59); saved rip 0x4004c5
  11595. tail call frame, caller of frame at 0x7fffffffda30
  11596. source language c++.
  11597. Arglist at unknown address.
  11598. Locals at unknown address, Previous frame's sp is 0x7fffffffda30
  11599. @end smallexample
  11600. The detection of all the possible code path executions can find them ambiguous.
  11601. There is no execution history stored (possible @ref{Reverse Execution} is never
  11602. used for this purpose) and the last known caller could have reached the known
  11603. callee by multiple different jump sequences. In such case @value{GDBN} still
  11604. tries to show at least all the unambiguous top tail callers and all the
  11605. unambiguous bottom tail calees, if any.
  11606. @table @code
  11607. @anchor{set debug entry-values}
  11608. @item set debug entry-values
  11609. @kindex set debug entry-values
  11610. When set to on, enables printing of analysis messages for both frame argument
  11611. values at function entry and tail calls. It will show all the possible valid
  11612. tail calls code paths it has considered. It will also print the intersection
  11613. of them with the final unambiguous (possibly partial or even empty) code path
  11614. result.
  11615. @item show debug entry-values
  11616. @kindex show debug entry-values
  11617. Show the current state of analysis messages printing for both frame argument
  11618. values at function entry and tail calls.
  11619. @end table
  11620. The analysis messages for tail calls can for example show why the virtual tail
  11621. call frame for function @code{c} has not been recognized (due to the indirect
  11622. reference by variable @code{x}):
  11623. @smallexample
  11624. static void __attribute__((noinline, noclone)) c (void);
  11625. void (*x) (void) = c;
  11626. static void __attribute__((noinline, noclone)) a (void) @{ x++; @}
  11627. static void __attribute__((noinline, noclone)) c (void) @{ a (); @}
  11628. int main (void) @{ x (); return 0; @}
  11629. Breakpoint 1, DW_OP_entry_value resolving cannot find
  11630. DW_TAG_call_site 0x40039a in main
  11631. a () at t.c:3
  11632. 3 static void __attribute__((noinline, noclone)) a (void) @{ x++; @}
  11633. (gdb) bt
  11634. #0 a () at t.c:3
  11635. #1 0x000000000040039a in main () at t.c:5
  11636. @end smallexample
  11637. Another possibility is an ambiguous virtual tail call frames resolution:
  11638. @smallexample
  11639. int i;
  11640. static void __attribute__((noinline, noclone)) f (void) @{ i++; @}
  11641. static void __attribute__((noinline, noclone)) e (void) @{ f (); @}
  11642. static void __attribute__((noinline, noclone)) d (void) @{ f (); @}
  11643. static void __attribute__((noinline, noclone)) c (void) @{ d (); @}
  11644. static void __attribute__((noinline, noclone)) b (void)
  11645. @{ if (i) c (); else e (); @}
  11646. static void __attribute__((noinline, noclone)) a (void) @{ b (); @}
  11647. int main (void) @{ a (); return 0; @}
  11648. tailcall: initial: 0x4004d2(a) 0x4004ce(b) 0x4004b2(c) 0x4004a2(d)
  11649. tailcall: compare: 0x4004d2(a) 0x4004cc(b) 0x400492(e)
  11650. tailcall: reduced: 0x4004d2(a) |
  11651. (gdb) bt
  11652. #0 f () at t.c:2
  11653. #1 0x00000000004004d2 in a () at t.c:8
  11654. #2 0x0000000000400395 in main () at t.c:9
  11655. @end smallexample
  11656. @set CALLSEQ1A @code{main@value{ARROW}a@value{ARROW}b@value{ARROW}c@value{ARROW}d@value{ARROW}f}
  11657. @set CALLSEQ2A @code{main@value{ARROW}a@value{ARROW}b@value{ARROW}e@value{ARROW}f}
  11658. @c Convert CALLSEQ#A to CALLSEQ#B depending on HAVE_MAKEINFO_CLICK.
  11659. @ifset HAVE_MAKEINFO_CLICK
  11660. @set ARROW @click{}
  11661. @set CALLSEQ1B @clicksequence{@value{CALLSEQ1A}}
  11662. @set CALLSEQ2B @clicksequence{@value{CALLSEQ2A}}
  11663. @end ifset
  11664. @ifclear HAVE_MAKEINFO_CLICK
  11665. @set ARROW ->
  11666. @set CALLSEQ1B @value{CALLSEQ1A}
  11667. @set CALLSEQ2B @value{CALLSEQ2A}
  11668. @end ifclear
  11669. Frames #0 and #2 are real, #1 is a virtual tail call frame.
  11670. The code can have possible execution paths @value{CALLSEQ1B} or
  11671. @value{CALLSEQ2B}, @value{GDBN} cannot find which one from the inferior state.
  11672. @code{initial:} state shows some random possible calling sequence @value{GDBN}
  11673. has found. It then finds another possible calling sequence - that one is
  11674. prefixed by @code{compare:}. The non-ambiguous intersection of these two is
  11675. printed as the @code{reduced:} calling sequence. That one could have many
  11676. further @code{compare:} and @code{reduced:} statements as long as there remain
  11677. any non-ambiguous sequence entries.
  11678. For the frame of function @code{b} in both cases there are different possible
  11679. @code{$pc} values (@code{0x4004cc} or @code{0x4004ce}), therefore this frame is
  11680. also ambiguous. The only non-ambiguous frame is the one for function @code{a},
  11681. therefore this one is displayed to the user while the ambiguous frames are
  11682. omitted.
  11683. There can be also reasons why printing of frame argument values at function
  11684. entry may fail:
  11685. @smallexample
  11686. int v;
  11687. static void __attribute__((noinline, noclone)) c (int i) @{ v++; @}
  11688. static void __attribute__((noinline, noclone)) a (int i);
  11689. static void __attribute__((noinline, noclone)) b (int i) @{ a (i); @}
  11690. static void __attribute__((noinline, noclone)) a (int i)
  11691. @{ if (i) b (i - 1); else c (0); @}
  11692. int main (void) @{ a (5); return 0; @}
  11693. (gdb) bt
  11694. #0 c (i=i@@entry=0) at t.c:2
  11695. #1 0x0000000000400428 in a (DW_OP_entry_value resolving has found
  11696. function "a" at 0x400420 can call itself via tail calls
  11697. i=<optimized out>) at t.c:6
  11698. #2 0x000000000040036e in main () at t.c:7
  11699. @end smallexample
  11700. @value{GDBN} cannot find out from the inferior state if and how many times did
  11701. function @code{a} call itself (via function @code{b}) as these calls would be
  11702. tail calls. Such tail calls would modify the @code{i} variable, therefore
  11703. @value{GDBN} cannot be sure the value it knows would be right - @value{GDBN}
  11704. prints @code{<optimized out>} instead.
  11705. @node Macros
  11706. @chapter C Preprocessor Macros
  11707. Some languages, such as C and C@t{++}, provide a way to define and invoke
  11708. ``preprocessor macros'' which expand into strings of tokens.
  11709. @value{GDBN} can evaluate expressions containing macro invocations, show
  11710. the result of macro expansion, and show a macro's definition, including
  11711. where it was defined.
  11712. You may need to compile your program specially to provide @value{GDBN}
  11713. with information about preprocessor macros. Most compilers do not
  11714. include macros in their debugging information, even when you compile
  11715. with the @option{-g} flag. @xref{Compilation}.
  11716. A program may define a macro at one point, remove that definition later,
  11717. and then provide a different definition after that. Thus, at different
  11718. points in the program, a macro may have different definitions, or have
  11719. no definition at all. If there is a current stack frame, @value{GDBN}
  11720. uses the macros in scope at that frame's source code line. Otherwise,
  11721. @value{GDBN} uses the macros in scope at the current listing location;
  11722. see @ref{List}.
  11723. Whenever @value{GDBN} evaluates an expression, it always expands any
  11724. macro invocations present in the expression. @value{GDBN} also provides
  11725. the following commands for working with macros explicitly.
  11726. @table @code
  11727. @kindex macro expand
  11728. @cindex macro expansion, showing the results of preprocessor
  11729. @cindex preprocessor macro expansion, showing the results of
  11730. @cindex expanding preprocessor macros
  11731. @item macro expand @var{expression}
  11732. @itemx macro exp @var{expression}
  11733. Show the results of expanding all preprocessor macro invocations in
  11734. @var{expression}. Since @value{GDBN} simply expands macros, but does
  11735. not parse the result, @var{expression} need not be a valid expression;
  11736. it can be any string of tokens.
  11737. @kindex macro exp1
  11738. @item macro expand-once @var{expression}
  11739. @itemx macro exp1 @var{expression}
  11740. @cindex expand macro once
  11741. @i{(This command is not yet implemented.)} Show the results of
  11742. expanding those preprocessor macro invocations that appear explicitly in
  11743. @var{expression}. Macro invocations appearing in that expansion are
  11744. left unchanged. This command allows you to see the effect of a
  11745. particular macro more clearly, without being confused by further
  11746. expansions. Since @value{GDBN} simply expands macros, but does not
  11747. parse the result, @var{expression} need not be a valid expression; it
  11748. can be any string of tokens.
  11749. @kindex info macro
  11750. @cindex macro definition, showing
  11751. @cindex definition of a macro, showing
  11752. @cindex macros, from debug info
  11753. @item info macro [-a|-all] [--] @var{macro}
  11754. Show the current definition or all definitions of the named @var{macro},
  11755. and describe the source location or compiler command-line where that
  11756. definition was established. The optional double dash is to signify the end of
  11757. argument processing and the beginning of @var{macro} for non C-like macros where
  11758. the macro may begin with a hyphen.
  11759. @kindex info macros
  11760. @item info macros @var{location}
  11761. Show all macro definitions that are in effect at the location specified
  11762. by @var{location}, and describe the source location or compiler
  11763. command-line where those definitions were established.
  11764. @kindex macro define
  11765. @cindex user-defined macros
  11766. @cindex defining macros interactively
  11767. @cindex macros, user-defined
  11768. @item macro define @var{macro} @var{replacement-list}
  11769. @itemx macro define @var{macro}(@var{arglist}) @var{replacement-list}
  11770. Introduce a definition for a preprocessor macro named @var{macro},
  11771. invocations of which are replaced by the tokens given in
  11772. @var{replacement-list}. The first form of this command defines an
  11773. ``object-like'' macro, which takes no arguments; the second form
  11774. defines a ``function-like'' macro, which takes the arguments given in
  11775. @var{arglist}.
  11776. A definition introduced by this command is in scope in every
  11777. expression evaluated in @value{GDBN}, until it is removed with the
  11778. @code{macro undef} command, described below. The definition overrides
  11779. all definitions for @var{macro} present in the program being debugged,
  11780. as well as any previous user-supplied definition.
  11781. @kindex macro undef
  11782. @item macro undef @var{macro}
  11783. Remove any user-supplied definition for the macro named @var{macro}.
  11784. This command only affects definitions provided with the @code{macro
  11785. define} command, described above; it cannot remove definitions present
  11786. in the program being debugged.
  11787. @kindex macro list
  11788. @item macro list
  11789. List all the macros defined using the @code{macro define} command.
  11790. @end table
  11791. @cindex macros, example of debugging with
  11792. Here is a transcript showing the above commands in action. First, we
  11793. show our source files:
  11794. @smallexample
  11795. $ cat sample.c
  11796. #include <stdio.h>
  11797. #include "sample.h"
  11798. #define M 42
  11799. #define ADD(x) (M + x)
  11800. main ()
  11801. @{
  11802. #define N 28
  11803. printf ("Hello, world!\n");
  11804. #undef N
  11805. printf ("We're so creative.\n");
  11806. #define N 1729
  11807. printf ("Goodbye, world!\n");
  11808. @}
  11809. $ cat sample.h
  11810. #define Q <
  11811. $
  11812. @end smallexample
  11813. Now, we compile the program using the @sc{gnu} C compiler,
  11814. @value{NGCC}. We pass the @option{-gdwarf-2}@footnote{This is the
  11815. minimum. Recent versions of @value{NGCC} support @option{-gdwarf-3}
  11816. and @option{-gdwarf-4}; we recommend always choosing the most recent
  11817. version of DWARF.} @emph{and} @option{-g3} flags to ensure the compiler
  11818. includes information about preprocessor macros in the debugging
  11819. information.
  11820. @smallexample
  11821. $ gcc -gdwarf-2 -g3 sample.c -o sample
  11822. $
  11823. @end smallexample
  11824. Now, we start @value{GDBN} on our sample program:
  11825. @smallexample
  11826. $ gdb -nw sample
  11827. GNU gdb 2002-05-06-cvs
  11828. Copyright 2002 Free Software Foundation, Inc.
  11829. GDB is free software, @dots{}
  11830. (@value{GDBP})
  11831. @end smallexample
  11832. We can expand macros and examine their definitions, even when the
  11833. program is not running. @value{GDBN} uses the current listing position
  11834. to decide which macro definitions are in scope:
  11835. @smallexample
  11836. (@value{GDBP}) list main
  11837. 3
  11838. 4 #define M 42
  11839. 5 #define ADD(x) (M + x)
  11840. 6
  11841. 7 main ()
  11842. 8 @{
  11843. 9 #define N 28
  11844. 10 printf ("Hello, world!\n");
  11845. 11 #undef N
  11846. 12 printf ("We're so creative.\n");
  11847. (@value{GDBP}) info macro ADD
  11848. Defined at /home/jimb/gdb/macros/play/sample.c:5
  11849. #define ADD(x) (M + x)
  11850. (@value{GDBP}) info macro Q
  11851. Defined at /home/jimb/gdb/macros/play/sample.h:1
  11852. included at /home/jimb/gdb/macros/play/sample.c:2
  11853. #define Q <
  11854. (@value{GDBP}) macro expand ADD(1)
  11855. expands to: (42 + 1)
  11856. (@value{GDBP}) macro expand-once ADD(1)
  11857. expands to: once (M + 1)
  11858. (@value{GDBP})
  11859. @end smallexample
  11860. In the example above, note that @code{macro expand-once} expands only
  11861. the macro invocation explicit in the original text --- the invocation of
  11862. @code{ADD} --- but does not expand the invocation of the macro @code{M},
  11863. which was introduced by @code{ADD}.
  11864. Once the program is running, @value{GDBN} uses the macro definitions in
  11865. force at the source line of the current stack frame:
  11866. @smallexample
  11867. (@value{GDBP}) break main
  11868. Breakpoint 1 at 0x8048370: file sample.c, line 10.
  11869. (@value{GDBP}) run
  11870. Starting program: /home/jimb/gdb/macros/play/sample
  11871. Breakpoint 1, main () at sample.c:10
  11872. 10 printf ("Hello, world!\n");
  11873. (@value{GDBP})
  11874. @end smallexample
  11875. At line 10, the definition of the macro @code{N} at line 9 is in force:
  11876. @smallexample
  11877. (@value{GDBP}) info macro N
  11878. Defined at /home/jimb/gdb/macros/play/sample.c:9
  11879. #define N 28
  11880. (@value{GDBP}) macro expand N Q M
  11881. expands to: 28 < 42
  11882. (@value{GDBP}) print N Q M
  11883. $1 = 1
  11884. (@value{GDBP})
  11885. @end smallexample
  11886. As we step over directives that remove @code{N}'s definition, and then
  11887. give it a new definition, @value{GDBN} finds the definition (or lack
  11888. thereof) in force at each point:
  11889. @smallexample
  11890. (@value{GDBP}) next
  11891. Hello, world!
  11892. 12 printf ("We're so creative.\n");
  11893. (@value{GDBP}) info macro N
  11894. The symbol `N' has no definition as a C/C++ preprocessor macro
  11895. at /home/jimb/gdb/macros/play/sample.c:12
  11896. (@value{GDBP}) next
  11897. We're so creative.
  11898. 14 printf ("Goodbye, world!\n");
  11899. (@value{GDBP}) info macro N
  11900. Defined at /home/jimb/gdb/macros/play/sample.c:13
  11901. #define N 1729
  11902. (@value{GDBP}) macro expand N Q M
  11903. expands to: 1729 < 42
  11904. (@value{GDBP}) print N Q M
  11905. $2 = 0
  11906. (@value{GDBP})
  11907. @end smallexample
  11908. In addition to source files, macros can be defined on the compilation command
  11909. line using the @option{-D@var{name}=@var{value}} syntax. For macros defined in
  11910. such a way, @value{GDBN} displays the location of their definition as line zero
  11911. of the source file submitted to the compiler.
  11912. @smallexample
  11913. (@value{GDBP}) info macro __STDC__
  11914. Defined at /home/jimb/gdb/macros/play/sample.c:0
  11915. -D__STDC__=1
  11916. (@value{GDBP})
  11917. @end smallexample
  11918. @node Tracepoints
  11919. @chapter Tracepoints
  11920. @c This chapter is based on the documentation written by Michael
  11921. @c Snyder, David Taylor, Jim Blandy, and Elena Zannoni.
  11922. @cindex tracepoints
  11923. In some applications, it is not feasible for the debugger to interrupt
  11924. the program's execution long enough for the developer to learn
  11925. anything helpful about its behavior. If the program's correctness
  11926. depends on its real-time behavior, delays introduced by a debugger
  11927. might cause the program to change its behavior drastically, or perhaps
  11928. fail, even when the code itself is correct. It is useful to be able
  11929. to observe the program's behavior without interrupting it.
  11930. Using @value{GDBN}'s @code{trace} and @code{collect} commands, you can
  11931. specify locations in the program, called @dfn{tracepoints}, and
  11932. arbitrary expressions to evaluate when those tracepoints are reached.
  11933. Later, using the @code{tfind} command, you can examine the values
  11934. those expressions had when the program hit the tracepoints. The
  11935. expressions may also denote objects in memory---structures or arrays,
  11936. for example---whose values @value{GDBN} should record; while visiting
  11937. a particular tracepoint, you may inspect those objects as if they were
  11938. in memory at that moment. However, because @value{GDBN} records these
  11939. values without interacting with you, it can do so quickly and
  11940. unobtrusively, hopefully not disturbing the program's behavior.
  11941. The tracepoint facility is currently available only for remote
  11942. targets. @xref{Targets}. In addition, your remote target must know
  11943. how to collect trace data. This functionality is implemented in the
  11944. remote stub; however, none of the stubs distributed with @value{GDBN}
  11945. support tracepoints as of this writing. The format of the remote
  11946. packets used to implement tracepoints are described in @ref{Tracepoint
  11947. Packets}.
  11948. It is also possible to get trace data from a file, in a manner reminiscent
  11949. of corefiles; you specify the filename, and use @code{tfind} to search
  11950. through the file. @xref{Trace Files}, for more details.
  11951. This chapter describes the tracepoint commands and features.
  11952. @menu
  11953. * Set Tracepoints::
  11954. * Analyze Collected Data::
  11955. * Tracepoint Variables::
  11956. * Trace Files::
  11957. @end menu
  11958. @node Set Tracepoints
  11959. @section Commands to Set Tracepoints
  11960. Before running such a @dfn{trace experiment}, an arbitrary number of
  11961. tracepoints can be set. A tracepoint is actually a special type of
  11962. breakpoint (@pxref{Set Breaks}), so you can manipulate it using
  11963. standard breakpoint commands. For instance, as with breakpoints,
  11964. tracepoint numbers are successive integers starting from one, and many
  11965. of the commands associated with tracepoints take the tracepoint number
  11966. as their argument, to identify which tracepoint to work on.
  11967. For each tracepoint, you can specify, in advance, some arbitrary set
  11968. of data that you want the target to collect in the trace buffer when
  11969. it hits that tracepoint. The collected data can include registers,
  11970. local variables, or global data. Later, you can use @value{GDBN}
  11971. commands to examine the values these data had at the time the
  11972. tracepoint was hit.
  11973. Tracepoints do not support every breakpoint feature. Ignore counts on
  11974. tracepoints have no effect, and tracepoints cannot run @value{GDBN}
  11975. commands when they are hit. Tracepoints may not be thread-specific
  11976. either.
  11977. @cindex fast tracepoints
  11978. Some targets may support @dfn{fast tracepoints}, which are inserted in
  11979. a different way (such as with a jump instead of a trap), that is
  11980. faster but possibly restricted in where they may be installed.
  11981. @cindex static tracepoints
  11982. @cindex markers, static tracepoints
  11983. @cindex probing markers, static tracepoints
  11984. Regular and fast tracepoints are dynamic tracing facilities, meaning
  11985. that they can be used to insert tracepoints at (almost) any location
  11986. in the target. Some targets may also support controlling @dfn{static
  11987. tracepoints} from @value{GDBN}. With static tracing, a set of
  11988. instrumentation points, also known as @dfn{markers}, are embedded in
  11989. the target program, and can be activated or deactivated by name or
  11990. address. These are usually placed at locations which facilitate
  11991. investigating what the target is actually doing. @value{GDBN}'s
  11992. support for static tracing includes being able to list instrumentation
  11993. points, and attach them with @value{GDBN} defined high level
  11994. tracepoints that expose the whole range of convenience of
  11995. @value{GDBN}'s tracepoints support. Namely, support for collecting
  11996. registers values and values of global or local (to the instrumentation
  11997. point) variables; tracepoint conditions and trace state variables.
  11998. The act of installing a @value{GDBN} static tracepoint on an
  11999. instrumentation point, or marker, is referred to as @dfn{probing} a
  12000. static tracepoint marker.
  12001. @code{gdbserver} supports tracepoints on some target systems.
  12002. @xref{Server,,Tracepoints support in @code{gdbserver}}.
  12003. This section describes commands to set tracepoints and associated
  12004. conditions and actions.
  12005. @menu
  12006. * Create and Delete Tracepoints::
  12007. * Enable and Disable Tracepoints::
  12008. * Tracepoint Passcounts::
  12009. * Tracepoint Conditions::
  12010. * Trace State Variables::
  12011. * Tracepoint Actions::
  12012. * Listing Tracepoints::
  12013. * Listing Static Tracepoint Markers::
  12014. * Starting and Stopping Trace Experiments::
  12015. * Tracepoint Restrictions::
  12016. @end menu
  12017. @node Create and Delete Tracepoints
  12018. @subsection Create and Delete Tracepoints
  12019. @table @code
  12020. @cindex set tracepoint
  12021. @kindex trace
  12022. @item trace @var{location}
  12023. The @code{trace} command is very similar to the @code{break} command.
  12024. Its argument @var{location} can be any valid location.
  12025. @xref{Specify Location}. The @code{trace} command defines a tracepoint,
  12026. which is a point in the target program where the debugger will briefly stop,
  12027. collect some data, and then allow the program to continue. Setting a tracepoint
  12028. or changing its actions takes effect immediately if the remote stub
  12029. supports the @samp{InstallInTrace} feature (@pxref{install tracepoint
  12030. in tracing}).
  12031. If remote stub doesn't support the @samp{InstallInTrace} feature, all
  12032. these changes don't take effect until the next @code{tstart}
  12033. command, and once a trace experiment is running, further changes will
  12034. not have any effect until the next trace experiment starts. In addition,
  12035. @value{GDBN} supports @dfn{pending tracepoints}---tracepoints whose
  12036. address is not yet resolved. (This is similar to pending breakpoints.)
  12037. Pending tracepoints are not downloaded to the target and not installed
  12038. until they are resolved. The resolution of pending tracepoints requires
  12039. @value{GDBN} support---when debugging with the remote target, and
  12040. @value{GDBN} disconnects from the remote stub (@pxref{disconnected
  12041. tracing}), pending tracepoints can not be resolved (and downloaded to
  12042. the remote stub) while @value{GDBN} is disconnected.
  12043. Here are some examples of using the @code{trace} command:
  12044. @smallexample
  12045. (@value{GDBP}) @b{trace foo.c:121} // a source file and line number
  12046. (@value{GDBP}) @b{trace +2} // 2 lines forward
  12047. (@value{GDBP}) @b{trace my_function} // first source line of function
  12048. (@value{GDBP}) @b{trace *my_function} // EXACT start address of function
  12049. (@value{GDBP}) @b{trace *0x2117c4} // an address
  12050. @end smallexample
  12051. @noindent
  12052. You can abbreviate @code{trace} as @code{tr}.
  12053. @item trace @var{location} if @var{cond}
  12054. Set a tracepoint with condition @var{cond}; evaluate the expression
  12055. @var{cond} each time the tracepoint is reached, and collect data only
  12056. if the value is nonzero---that is, if @var{cond} evaluates as true.
  12057. @xref{Tracepoint Conditions, ,Tracepoint Conditions}, for more
  12058. information on tracepoint conditions.
  12059. @item ftrace @var{location} [ if @var{cond} ]
  12060. @cindex set fast tracepoint
  12061. @cindex fast tracepoints, setting
  12062. @kindex ftrace
  12063. The @code{ftrace} command sets a fast tracepoint. For targets that
  12064. support them, fast tracepoints will use a more efficient but possibly
  12065. less general technique to trigger data collection, such as a jump
  12066. instruction instead of a trap, or some sort of hardware support. It
  12067. may not be possible to create a fast tracepoint at the desired
  12068. location, in which case the command will exit with an explanatory
  12069. message.
  12070. @value{GDBN} handles arguments to @code{ftrace} exactly as for
  12071. @code{trace}.
  12072. On 32-bit x86-architecture systems, fast tracepoints normally need to
  12073. be placed at an instruction that is 5 bytes or longer, but can be
  12074. placed at 4-byte instructions if the low 64K of memory of the target
  12075. program is available to install trampolines. Some Unix-type systems,
  12076. such as @sc{gnu}/Linux, exclude low addresses from the program's
  12077. address space; but for instance with the Linux kernel it is possible
  12078. to let @value{GDBN} use this area by doing a @command{sysctl} command
  12079. to set the @code{mmap_min_addr} kernel parameter, as in
  12080. @example
  12081. sudo sysctl -w vm.mmap_min_addr=32768
  12082. @end example
  12083. @noindent
  12084. which sets the low address to 32K, which leaves plenty of room for
  12085. trampolines. The minimum address should be set to a page boundary.
  12086. @item strace @var{location} [ if @var{cond} ]
  12087. @cindex set static tracepoint
  12088. @cindex static tracepoints, setting
  12089. @cindex probe static tracepoint marker
  12090. @kindex strace
  12091. The @code{strace} command sets a static tracepoint. For targets that
  12092. support it, setting a static tracepoint probes a static
  12093. instrumentation point, or marker, found at @var{location}. It may not
  12094. be possible to set a static tracepoint at the desired location, in
  12095. which case the command will exit with an explanatory message.
  12096. @value{GDBN} handles arguments to @code{strace} exactly as for
  12097. @code{trace}, with the addition that the user can also specify
  12098. @code{-m @var{marker}} as @var{location}. This probes the marker
  12099. identified by the @var{marker} string identifier. This identifier
  12100. depends on the static tracepoint backend library your program is
  12101. using. You can find all the marker identifiers in the @samp{ID} field
  12102. of the @code{info static-tracepoint-markers} command output.
  12103. @xref{Listing Static Tracepoint Markers,,Listing Static Tracepoint
  12104. Markers}. For example, in the following small program using the UST
  12105. tracing engine:
  12106. @smallexample
  12107. main ()
  12108. @{
  12109. trace_mark(ust, bar33, "str %s", "FOOBAZ");
  12110. @}
  12111. @end smallexample
  12112. @noindent
  12113. the marker id is composed of joining the first two arguments to the
  12114. @code{trace_mark} call with a slash, which translates to:
  12115. @smallexample
  12116. (@value{GDBP}) info static-tracepoint-markers
  12117. Cnt Enb ID Address What
  12118. 1 n ust/bar33 0x0000000000400ddc in main at stexample.c:22
  12119. Data: "str %s"
  12120. [etc...]
  12121. @end smallexample
  12122. @noindent
  12123. so you may probe the marker above with:
  12124. @smallexample
  12125. (@value{GDBP}) strace -m ust/bar33
  12126. @end smallexample
  12127. Static tracepoints accept an extra collect action --- @code{collect
  12128. $_sdata}. This collects arbitrary user data passed in the probe point
  12129. call to the tracing library. In the UST example above, you'll see
  12130. that the third argument to @code{trace_mark} is a printf-like format
  12131. string. The user data is then the result of running that formatting
  12132. string against the following arguments. Note that @code{info
  12133. static-tracepoint-markers} command output lists that format string in
  12134. the @samp{Data:} field.
  12135. You can inspect this data when analyzing the trace buffer, by printing
  12136. the $_sdata variable like any other variable available to
  12137. @value{GDBN}. @xref{Tracepoint Actions,,Tracepoint Action Lists}.
  12138. @vindex $tpnum
  12139. @cindex last tracepoint number
  12140. @cindex recent tracepoint number
  12141. @cindex tracepoint number
  12142. The convenience variable @code{$tpnum} records the tracepoint number
  12143. of the most recently set tracepoint.
  12144. @kindex delete tracepoint
  12145. @cindex tracepoint deletion
  12146. @item delete tracepoint @r{[}@var{num}@r{]}
  12147. Permanently delete one or more tracepoints. With no argument, the
  12148. default is to delete all tracepoints. Note that the regular
  12149. @code{delete} command can remove tracepoints also.
  12150. Examples:
  12151. @smallexample
  12152. (@value{GDBP}) @b{delete trace 1 2 3} // remove three tracepoints
  12153. (@value{GDBP}) @b{delete trace} // remove all tracepoints
  12154. @end smallexample
  12155. @noindent
  12156. You can abbreviate this command as @code{del tr}.
  12157. @end table
  12158. @node Enable and Disable Tracepoints
  12159. @subsection Enable and Disable Tracepoints
  12160. These commands are deprecated; they are equivalent to plain @code{disable} and @code{enable}.
  12161. @table @code
  12162. @kindex disable tracepoint
  12163. @item disable tracepoint @r{[}@var{num}@r{]}
  12164. Disable tracepoint @var{num}, or all tracepoints if no argument
  12165. @var{num} is given. A disabled tracepoint will have no effect during
  12166. a trace experiment, but it is not forgotten. You can re-enable
  12167. a disabled tracepoint using the @code{enable tracepoint} command.
  12168. If the command is issued during a trace experiment and the debug target
  12169. has support for disabling tracepoints during a trace experiment, then the
  12170. change will be effective immediately. Otherwise, it will be applied to the
  12171. next trace experiment.
  12172. @kindex enable tracepoint
  12173. @item enable tracepoint @r{[}@var{num}@r{]}
  12174. Enable tracepoint @var{num}, or all tracepoints. If this command is
  12175. issued during a trace experiment and the debug target supports enabling
  12176. tracepoints during a trace experiment, then the enabled tracepoints will
  12177. become effective immediately. Otherwise, they will become effective the
  12178. next time a trace experiment is run.
  12179. @end table
  12180. @node Tracepoint Passcounts
  12181. @subsection Tracepoint Passcounts
  12182. @table @code
  12183. @kindex passcount
  12184. @cindex tracepoint pass count
  12185. @item passcount @r{[}@var{n} @r{[}@var{num}@r{]]}
  12186. Set the @dfn{passcount} of a tracepoint. The passcount is a way to
  12187. automatically stop a trace experiment. If a tracepoint's passcount is
  12188. @var{n}, then the trace experiment will be automatically stopped on
  12189. the @var{n}'th time that tracepoint is hit. If the tracepoint number
  12190. @var{num} is not specified, the @code{passcount} command sets the
  12191. passcount of the most recently defined tracepoint. If no passcount is
  12192. given, the trace experiment will run until stopped explicitly by the
  12193. user.
  12194. Examples:
  12195. @smallexample
  12196. (@value{GDBP}) @b{passcount 5 2} // Stop on the 5th execution of
  12197. @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// tracepoint 2}
  12198. (@value{GDBP}) @b{passcount 12} // Stop on the 12th execution of the
  12199. @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// most recently defined tracepoint.}
  12200. (@value{GDBP}) @b{trace foo}
  12201. (@value{GDBP}) @b{pass 3}
  12202. (@value{GDBP}) @b{trace bar}
  12203. (@value{GDBP}) @b{pass 2}
  12204. (@value{GDBP}) @b{trace baz}
  12205. (@value{GDBP}) @b{pass 1} // Stop tracing when foo has been
  12206. @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// executed 3 times OR when bar has}
  12207. @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// been executed 2 times}
  12208. @exdent @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @code{// OR when baz has been executed 1 time.}
  12209. @end smallexample
  12210. @end table
  12211. @node Tracepoint Conditions
  12212. @subsection Tracepoint Conditions
  12213. @cindex conditional tracepoints
  12214. @cindex tracepoint conditions
  12215. The simplest sort of tracepoint collects data every time your program
  12216. reaches a specified place. You can also specify a @dfn{condition} for
  12217. a tracepoint. A condition is just a Boolean expression in your
  12218. programming language (@pxref{Expressions, ,Expressions}). A
  12219. tracepoint with a condition evaluates the expression each time your
  12220. program reaches it, and data collection happens only if the condition
  12221. is true.
  12222. Tracepoint conditions can be specified when a tracepoint is set, by
  12223. using @samp{if} in the arguments to the @code{trace} command.
  12224. @xref{Create and Delete Tracepoints, ,Setting Tracepoints}. They can
  12225. also be set or changed at any time with the @code{condition} command,
  12226. just as with breakpoints.
  12227. Unlike breakpoint conditions, @value{GDBN} does not actually evaluate
  12228. the conditional expression itself. Instead, @value{GDBN} encodes the
  12229. expression into an agent expression (@pxref{Agent Expressions})
  12230. suitable for execution on the target, independently of @value{GDBN}.
  12231. Global variables become raw memory locations, locals become stack
  12232. accesses, and so forth.
  12233. For instance, suppose you have a function that is usually called
  12234. frequently, but should not be called after an error has occurred. You
  12235. could use the following tracepoint command to collect data about calls
  12236. of that function that happen while the error code is propagating
  12237. through the program; an unconditional tracepoint could end up
  12238. collecting thousands of useless trace frames that you would have to
  12239. search through.
  12240. @smallexample
  12241. (@value{GDBP}) @kbd{trace normal_operation if errcode > 0}
  12242. @end smallexample
  12243. @node Trace State Variables
  12244. @subsection Trace State Variables
  12245. @cindex trace state variables
  12246. A @dfn{trace state variable} is a special type of variable that is
  12247. created and managed by target-side code. The syntax is the same as
  12248. that for GDB's convenience variables (a string prefixed with ``$''),
  12249. but they are stored on the target. They must be created explicitly,
  12250. using a @code{tvariable} command. They are always 64-bit signed
  12251. integers.
  12252. Trace state variables are remembered by @value{GDBN}, and downloaded
  12253. to the target along with tracepoint information when the trace
  12254. experiment starts. There are no intrinsic limits on the number of
  12255. trace state variables, beyond memory limitations of the target.
  12256. @cindex convenience variables, and trace state variables
  12257. Although trace state variables are managed by the target, you can use
  12258. them in print commands and expressions as if they were convenience
  12259. variables; @value{GDBN} will get the current value from the target
  12260. while the trace experiment is running. Trace state variables share
  12261. the same namespace as other ``$'' variables, which means that you
  12262. cannot have trace state variables with names like @code{$23} or
  12263. @code{$pc}, nor can you have a trace state variable and a convenience
  12264. variable with the same name.
  12265. @table @code
  12266. @item tvariable $@var{name} [ = @var{expression} ]
  12267. @kindex tvariable
  12268. The @code{tvariable} command creates a new trace state variable named
  12269. @code{$@var{name}}, and optionally gives it an initial value of
  12270. @var{expression}. The @var{expression} is evaluated when this command is
  12271. entered; the result will be converted to an integer if possible,
  12272. otherwise @value{GDBN} will report an error. A subsequent
  12273. @code{tvariable} command specifying the same name does not create a
  12274. variable, but instead assigns the supplied initial value to the
  12275. existing variable of that name, overwriting any previous initial
  12276. value. The default initial value is 0.
  12277. @item info tvariables
  12278. @kindex info tvariables
  12279. List all the trace state variables along with their initial values.
  12280. Their current values may also be displayed, if the trace experiment is
  12281. currently running.
  12282. @item delete tvariable @r{[} $@var{name} @dots{} @r{]}
  12283. @kindex delete tvariable
  12284. Delete the given trace state variables, or all of them if no arguments
  12285. are specified.
  12286. @end table
  12287. @node Tracepoint Actions
  12288. @subsection Tracepoint Action Lists
  12289. @table @code
  12290. @kindex actions
  12291. @cindex tracepoint actions
  12292. @item actions @r{[}@var{num}@r{]}
  12293. This command will prompt for a list of actions to be taken when the
  12294. tracepoint is hit. If the tracepoint number @var{num} is not
  12295. specified, this command sets the actions for the one that was most
  12296. recently defined (so that you can define a tracepoint and then say
  12297. @code{actions} without bothering about its number). You specify the
  12298. actions themselves on the following lines, one action at a time, and
  12299. terminate the actions list with a line containing just @code{end}. So
  12300. far, the only defined actions are @code{collect}, @code{teval}, and
  12301. @code{while-stepping}.
  12302. @code{actions} is actually equivalent to @code{commands} (@pxref{Break
  12303. Commands, ,Breakpoint Command Lists}), except that only the defined
  12304. actions are allowed; any other @value{GDBN} command is rejected.
  12305. @cindex remove actions from a tracepoint
  12306. To remove all actions from a tracepoint, type @samp{actions @var{num}}
  12307. and follow it immediately with @samp{end}.
  12308. @smallexample
  12309. (@value{GDBP}) @b{collect @var{data}} // collect some data
  12310. (@value{GDBP}) @b{while-stepping 5} // single-step 5 times, collect data
  12311. (@value{GDBP}) @b{end} // signals the end of actions.
  12312. @end smallexample
  12313. In the following example, the action list begins with @code{collect}
  12314. commands indicating the things to be collected when the tracepoint is
  12315. hit. Then, in order to single-step and collect additional data
  12316. following the tracepoint, a @code{while-stepping} command is used,
  12317. followed by the list of things to be collected after each step in a
  12318. sequence of single steps. The @code{while-stepping} command is
  12319. terminated by its own separate @code{end} command. Lastly, the action
  12320. list is terminated by an @code{end} command.
  12321. @smallexample
  12322. (@value{GDBP}) @b{trace foo}
  12323. (@value{GDBP}) @b{actions}
  12324. Enter actions for tracepoint 1, one per line:
  12325. > collect bar,baz
  12326. > collect $regs
  12327. > while-stepping 12
  12328. > collect $pc, arr[i]
  12329. > end
  12330. end
  12331. @end smallexample
  12332. @kindex collect @r{(tracepoints)}
  12333. @item collect@r{[}/@var{mods}@r{]} @var{expr1}, @var{expr2}, @dots{}
  12334. Collect values of the given expressions when the tracepoint is hit.
  12335. This command accepts a comma-separated list of any valid expressions.
  12336. In addition to global, static, or local variables, the following
  12337. special arguments are supported:
  12338. @table @code
  12339. @item $regs
  12340. Collect all registers.
  12341. @item $args
  12342. Collect all function arguments.
  12343. @item $locals
  12344. Collect all local variables.
  12345. @item $_ret
  12346. Collect the return address. This is helpful if you want to see more
  12347. of a backtrace.
  12348. @emph{Note:} The return address location can not always be reliably
  12349. determined up front, and the wrong address / registers may end up
  12350. collected instead. On some architectures the reliability is higher
  12351. for tracepoints at function entry, while on others it's the opposite.
  12352. When this happens, backtracing will stop because the return address is
  12353. found unavailable (unless another collect rule happened to match it).
  12354. @item $_probe_argc
  12355. Collects the number of arguments from the static probe at which the
  12356. tracepoint is located.
  12357. @xref{Static Probe Points}.
  12358. @item $_probe_arg@var{n}
  12359. @var{n} is an integer between 0 and 11. Collects the @var{n}th argument
  12360. from the static probe at which the tracepoint is located.
  12361. @xref{Static Probe Points}.
  12362. @item $_sdata
  12363. @vindex $_sdata@r{, collect}
  12364. Collect static tracepoint marker specific data. Only available for
  12365. static tracepoints. @xref{Tracepoint Actions,,Tracepoint Action
  12366. Lists}. On the UST static tracepoints library backend, an
  12367. instrumentation point resembles a @code{printf} function call. The
  12368. tracing library is able to collect user specified data formatted to a
  12369. character string using the format provided by the programmer that
  12370. instrumented the program. Other backends have similar mechanisms.
  12371. Here's an example of a UST marker call:
  12372. @smallexample
  12373. const char master_name[] = "$your_name";
  12374. trace_mark(channel1, marker1, "hello %s", master_name)
  12375. @end smallexample
  12376. In this case, collecting @code{$_sdata} collects the string
  12377. @samp{hello $yourname}. When analyzing the trace buffer, you can
  12378. inspect @samp{$_sdata} like any other variable available to
  12379. @value{GDBN}.
  12380. @end table
  12381. You can give several consecutive @code{collect} commands, each one
  12382. with a single argument, or one @code{collect} command with several
  12383. arguments separated by commas; the effect is the same.
  12384. The optional @var{mods} changes the usual handling of the arguments.
  12385. @code{s} requests that pointers to chars be handled as strings, in
  12386. particular collecting the contents of the memory being pointed at, up
  12387. to the first zero. The upper bound is by default the value of the
  12388. @code{print elements} variable; if @code{s} is followed by a decimal
  12389. number, that is the upper bound instead. So for instance
  12390. @samp{collect/s25 mystr} collects as many as 25 characters at
  12391. @samp{mystr}.
  12392. The command @code{info scope} (@pxref{Symbols, info scope}) is
  12393. particularly useful for figuring out what data to collect.
  12394. @kindex teval @r{(tracepoints)}
  12395. @item teval @var{expr1}, @var{expr2}, @dots{}
  12396. Evaluate the given expressions when the tracepoint is hit. This
  12397. command accepts a comma-separated list of expressions. The results
  12398. are discarded, so this is mainly useful for assigning values to trace
  12399. state variables (@pxref{Trace State Variables}) without adding those
  12400. values to the trace buffer, as would be the case if the @code{collect}
  12401. action were used.
  12402. @kindex while-stepping @r{(tracepoints)}
  12403. @item while-stepping @var{n}
  12404. Perform @var{n} single-step instruction traces after the tracepoint,
  12405. collecting new data after each step. The @code{while-stepping}
  12406. command is followed by the list of what to collect while stepping
  12407. (followed by its own @code{end} command):
  12408. @smallexample
  12409. > while-stepping 12
  12410. > collect $regs, myglobal
  12411. > end
  12412. >
  12413. @end smallexample
  12414. @noindent
  12415. Note that @code{$pc} is not automatically collected by
  12416. @code{while-stepping}; you need to explicitly collect that register if
  12417. you need it. You may abbreviate @code{while-stepping} as @code{ws} or
  12418. @code{stepping}.
  12419. @item set default-collect @var{expr1}, @var{expr2}, @dots{}
  12420. @kindex set default-collect
  12421. @cindex default collection action
  12422. This variable is a list of expressions to collect at each tracepoint
  12423. hit. It is effectively an additional @code{collect} action prepended
  12424. to every tracepoint action list. The expressions are parsed
  12425. individually for each tracepoint, so for instance a variable named
  12426. @code{xyz} may be interpreted as a global for one tracepoint, and a
  12427. local for another, as appropriate to the tracepoint's location.
  12428. @item show default-collect
  12429. @kindex show default-collect
  12430. Show the list of expressions that are collected by default at each
  12431. tracepoint hit.
  12432. @end table
  12433. @node Listing Tracepoints
  12434. @subsection Listing Tracepoints
  12435. @table @code
  12436. @kindex info tracepoints @r{[}@var{n}@dots{}@r{]}
  12437. @kindex info tp @r{[}@var{n}@dots{}@r{]}
  12438. @cindex information about tracepoints
  12439. @item info tracepoints @r{[}@var{num}@dots{}@r{]}
  12440. Display information about the tracepoint @var{num}. If you don't
  12441. specify a tracepoint number, displays information about all the
  12442. tracepoints defined so far. The format is similar to that used for
  12443. @code{info breakpoints}; in fact, @code{info tracepoints} is the same
  12444. command, simply restricting itself to tracepoints.
  12445. A tracepoint's listing may include additional information specific to
  12446. tracing:
  12447. @itemize @bullet
  12448. @item
  12449. its passcount as given by the @code{passcount @var{n}} command
  12450. @item
  12451. the state about installed on target of each location
  12452. @end itemize
  12453. @smallexample
  12454. (@value{GDBP}) @b{info trace}
  12455. Num Type Disp Enb Address What
  12456. 1 tracepoint keep y 0x0804ab57 in foo() at main.cxx:7
  12457. while-stepping 20
  12458. collect globfoo, $regs
  12459. end
  12460. collect globfoo2
  12461. end
  12462. pass count 1200
  12463. 2 tracepoint keep y <MULTIPLE>
  12464. collect $eip
  12465. 2.1 y 0x0804859c in func4 at change-loc.h:35
  12466. installed on target
  12467. 2.2 y 0xb7ffc480 in func4 at change-loc.h:35
  12468. installed on target
  12469. 2.3 y <PENDING> set_tracepoint
  12470. 3 tracepoint keep y 0x080485b1 in foo at change-loc.c:29
  12471. not installed on target
  12472. (@value{GDBP})
  12473. @end smallexample
  12474. @noindent
  12475. This command can be abbreviated @code{info tp}.
  12476. @end table
  12477. @node Listing Static Tracepoint Markers
  12478. @subsection Listing Static Tracepoint Markers
  12479. @table @code
  12480. @kindex info static-tracepoint-markers
  12481. @cindex information about static tracepoint markers
  12482. @item info static-tracepoint-markers
  12483. Display information about all static tracepoint markers defined in the
  12484. program.
  12485. For each marker, the following columns are printed:
  12486. @table @emph
  12487. @item Count
  12488. An incrementing counter, output to help readability. This is not a
  12489. stable identifier.
  12490. @item ID
  12491. The marker ID, as reported by the target.
  12492. @item Enabled or Disabled
  12493. Probed markers are tagged with @samp{y}. @samp{n} identifies marks
  12494. that are not enabled.
  12495. @item Address
  12496. Where the marker is in your program, as a memory address.
  12497. @item What
  12498. Where the marker is in the source for your program, as a file and line
  12499. number. If the debug information included in the program does not
  12500. allow @value{GDBN} to locate the source of the marker, this column
  12501. will be left blank.
  12502. @end table
  12503. @noindent
  12504. In addition, the following information may be printed for each marker:
  12505. @table @emph
  12506. @item Data
  12507. User data passed to the tracing library by the marker call. In the
  12508. UST backend, this is the format string passed as argument to the
  12509. marker call.
  12510. @item Static tracepoints probing the marker
  12511. The list of static tracepoints attached to the marker.
  12512. @end table
  12513. @smallexample
  12514. (@value{GDBP}) info static-tracepoint-markers
  12515. Cnt ID Enb Address What
  12516. 1 ust/bar2 y 0x0000000000400e1a in main at stexample.c:25
  12517. Data: number1 %d number2 %d
  12518. Probed by static tracepoints: #2
  12519. 2 ust/bar33 n 0x0000000000400c87 in main at stexample.c:24
  12520. Data: str %s
  12521. (@value{GDBP})
  12522. @end smallexample
  12523. @end table
  12524. @node Starting and Stopping Trace Experiments
  12525. @subsection Starting and Stopping Trace Experiments
  12526. @table @code
  12527. @kindex tstart [ @var{notes} ]
  12528. @cindex start a new trace experiment
  12529. @cindex collected data discarded
  12530. @item tstart
  12531. This command starts the trace experiment, and begins collecting data.
  12532. It has the side effect of discarding all the data collected in the
  12533. trace buffer during the previous trace experiment. If any arguments
  12534. are supplied, they are taken as a note and stored with the trace
  12535. experiment's state. The notes may be arbitrary text, and are
  12536. especially useful with disconnected tracing in a multi-user context;
  12537. the notes can explain what the trace is doing, supply user contact
  12538. information, and so forth.
  12539. @kindex tstop [ @var{notes} ]
  12540. @cindex stop a running trace experiment
  12541. @item tstop
  12542. This command stops the trace experiment. If any arguments are
  12543. supplied, they are recorded with the experiment as a note. This is
  12544. useful if you are stopping a trace started by someone else, for
  12545. instance if the trace is interfering with the system's behavior and
  12546. needs to be stopped quickly.
  12547. @strong{Note}: a trace experiment and data collection may stop
  12548. automatically if any tracepoint's passcount is reached
  12549. (@pxref{Tracepoint Passcounts}), or if the trace buffer becomes full.
  12550. @kindex tstatus
  12551. @cindex status of trace data collection
  12552. @cindex trace experiment, status of
  12553. @item tstatus
  12554. This command displays the status of the current trace data
  12555. collection.
  12556. @end table
  12557. Here is an example of the commands we described so far:
  12558. @smallexample
  12559. (@value{GDBP}) @b{trace gdb_c_test}
  12560. (@value{GDBP}) @b{actions}
  12561. Enter actions for tracepoint #1, one per line.
  12562. > collect $regs,$locals,$args
  12563. > while-stepping 11
  12564. > collect $regs
  12565. > end
  12566. > end
  12567. (@value{GDBP}) @b{tstart}
  12568. [time passes @dots{}]
  12569. (@value{GDBP}) @b{tstop}
  12570. @end smallexample
  12571. @anchor{disconnected tracing}
  12572. @cindex disconnected tracing
  12573. You can choose to continue running the trace experiment even if
  12574. @value{GDBN} disconnects from the target, voluntarily or
  12575. involuntarily. For commands such as @code{detach}, the debugger will
  12576. ask what you want to do with the trace. But for unexpected
  12577. terminations (@value{GDBN} crash, network outage), it would be
  12578. unfortunate to lose hard-won trace data, so the variable
  12579. @code{disconnected-tracing} lets you decide whether the trace should
  12580. continue running without @value{GDBN}.
  12581. @table @code
  12582. @item set disconnected-tracing on
  12583. @itemx set disconnected-tracing off
  12584. @kindex set disconnected-tracing
  12585. Choose whether a tracing run should continue to run if @value{GDBN}
  12586. has disconnected from the target. Note that @code{detach} or
  12587. @code{quit} will ask you directly what to do about a running trace no
  12588. matter what this variable's setting, so the variable is mainly useful
  12589. for handling unexpected situations, such as loss of the network.
  12590. @item show disconnected-tracing
  12591. @kindex show disconnected-tracing
  12592. Show the current choice for disconnected tracing.
  12593. @end table
  12594. When you reconnect to the target, the trace experiment may or may not
  12595. still be running; it might have filled the trace buffer in the
  12596. meantime, or stopped for one of the other reasons. If it is running,
  12597. it will continue after reconnection.
  12598. Upon reconnection, the target will upload information about the
  12599. tracepoints in effect. @value{GDBN} will then compare that
  12600. information to the set of tracepoints currently defined, and attempt
  12601. to match them up, allowing for the possibility that the numbers may
  12602. have changed due to creation and deletion in the meantime. If one of
  12603. the target's tracepoints does not match any in @value{GDBN}, the
  12604. debugger will create a new tracepoint, so that you have a number with
  12605. which to specify that tracepoint. This matching-up process is
  12606. necessarily heuristic, and it may result in useless tracepoints being
  12607. created; you may simply delete them if they are of no use.
  12608. @cindex circular trace buffer
  12609. If your target agent supports a @dfn{circular trace buffer}, then you
  12610. can run a trace experiment indefinitely without filling the trace
  12611. buffer; when space runs out, the agent deletes already-collected trace
  12612. frames, oldest first, until there is enough room to continue
  12613. collecting. This is especially useful if your tracepoints are being
  12614. hit too often, and your trace gets terminated prematurely because the
  12615. buffer is full. To ask for a circular trace buffer, simply set
  12616. @samp{circular-trace-buffer} to on. You can set this at any time,
  12617. including during tracing; if the agent can do it, it will change
  12618. buffer handling on the fly, otherwise it will not take effect until
  12619. the next run.
  12620. @table @code
  12621. @item set circular-trace-buffer on
  12622. @itemx set circular-trace-buffer off
  12623. @kindex set circular-trace-buffer
  12624. Choose whether a tracing run should use a linear or circular buffer
  12625. for trace data. A linear buffer will not lose any trace data, but may
  12626. fill up prematurely, while a circular buffer will discard old trace
  12627. data, but it will have always room for the latest tracepoint hits.
  12628. @item show circular-trace-buffer
  12629. @kindex show circular-trace-buffer
  12630. Show the current choice for the trace buffer. Note that this may not
  12631. match the agent's current buffer handling, nor is it guaranteed to
  12632. match the setting that might have been in effect during a past run,
  12633. for instance if you are looking at frames from a trace file.
  12634. @end table
  12635. @table @code
  12636. @item set trace-buffer-size @var{n}
  12637. @itemx set trace-buffer-size unlimited
  12638. @kindex set trace-buffer-size
  12639. Request that the target use a trace buffer of @var{n} bytes. Not all
  12640. targets will honor the request; they may have a compiled-in size for
  12641. the trace buffer, or some other limitation. Set to a value of
  12642. @code{unlimited} or @code{-1} to let the target use whatever size it
  12643. likes. This is also the default.
  12644. @item show trace-buffer-size
  12645. @kindex show trace-buffer-size
  12646. Show the current requested size for the trace buffer. Note that this
  12647. will only match the actual size if the target supports size-setting,
  12648. and was able to handle the requested size. For instance, if the
  12649. target can only change buffer size between runs, this variable will
  12650. not reflect the change until the next run starts. Use @code{tstatus}
  12651. to get a report of the actual buffer size.
  12652. @end table
  12653. @table @code
  12654. @item set trace-user @var{text}
  12655. @kindex set trace-user
  12656. @item show trace-user
  12657. @kindex show trace-user
  12658. @item set trace-notes @var{text}
  12659. @kindex set trace-notes
  12660. Set the trace run's notes.
  12661. @item show trace-notes
  12662. @kindex show trace-notes
  12663. Show the trace run's notes.
  12664. @item set trace-stop-notes @var{text}
  12665. @kindex set trace-stop-notes
  12666. Set the trace run's stop notes. The handling of the note is as for
  12667. @code{tstop} arguments; the set command is convenient way to fix a
  12668. stop note that is mistaken or incomplete.
  12669. @item show trace-stop-notes
  12670. @kindex show trace-stop-notes
  12671. Show the trace run's stop notes.
  12672. @end table
  12673. @node Tracepoint Restrictions
  12674. @subsection Tracepoint Restrictions
  12675. @cindex tracepoint restrictions
  12676. There are a number of restrictions on the use of tracepoints. As
  12677. described above, tracepoint data gathering occurs on the target
  12678. without interaction from @value{GDBN}. Thus the full capabilities of
  12679. the debugger are not available during data gathering, and then at data
  12680. examination time, you will be limited by only having what was
  12681. collected. The following items describe some common problems, but it
  12682. is not exhaustive, and you may run into additional difficulties not
  12683. mentioned here.
  12684. @itemize @bullet
  12685. @item
  12686. Tracepoint expressions are intended to gather objects (lvalues). Thus
  12687. the full flexibility of GDB's expression evaluator is not available.
  12688. You cannot call functions, cast objects to aggregate types, access
  12689. convenience variables or modify values (except by assignment to trace
  12690. state variables). Some language features may implicitly call
  12691. functions (for instance Objective-C fields with accessors), and therefore
  12692. cannot be collected either.
  12693. @item
  12694. Collection of local variables, either individually or in bulk with
  12695. @code{$locals} or @code{$args}, during @code{while-stepping} may
  12696. behave erratically. The stepping action may enter a new scope (for
  12697. instance by stepping into a function), or the location of the variable
  12698. may change (for instance it is loaded into a register). The
  12699. tracepoint data recorded uses the location information for the
  12700. variables that is correct for the tracepoint location. When the
  12701. tracepoint is created, it is not possible, in general, to determine
  12702. where the steps of a @code{while-stepping} sequence will advance the
  12703. program---particularly if a conditional branch is stepped.
  12704. @item
  12705. Collection of an incompletely-initialized or partially-destroyed object
  12706. may result in something that @value{GDBN} cannot display, or displays
  12707. in a misleading way.
  12708. @item
  12709. When @value{GDBN} displays a pointer to character it automatically
  12710. dereferences the pointer to also display characters of the string
  12711. being pointed to. However, collecting the pointer during tracing does
  12712. not automatically collect the string. You need to explicitly
  12713. dereference the pointer and provide size information if you want to
  12714. collect not only the pointer, but the memory pointed to. For example,
  12715. @code{*ptr@@50} can be used to collect the 50 element array pointed to
  12716. by @code{ptr}.
  12717. @item
  12718. It is not possible to collect a complete stack backtrace at a
  12719. tracepoint. Instead, you may collect the registers and a few hundred
  12720. bytes from the stack pointer with something like @code{*(unsigned char *)$esp@@300}
  12721. (adjust to use the name of the actual stack pointer register on your
  12722. target architecture, and the amount of stack you wish to capture).
  12723. Then the @code{backtrace} command will show a partial backtrace when
  12724. using a trace frame. The number of stack frames that can be examined
  12725. depends on the sizes of the frames in the collected stack. Note that
  12726. if you ask for a block so large that it goes past the bottom of the
  12727. stack, the target agent may report an error trying to read from an
  12728. invalid address.
  12729. @item
  12730. If you do not collect registers at a tracepoint, @value{GDBN} can
  12731. infer that the value of @code{$pc} must be the same as the address of
  12732. the tracepoint and use that when you are looking at a trace frame
  12733. for that tracepoint. However, this cannot work if the tracepoint has
  12734. multiple locations (for instance if it was set in a function that was
  12735. inlined), or if it has a @code{while-stepping} loop. In those cases
  12736. @value{GDBN} will warn you that it can't infer @code{$pc}, and default
  12737. it to zero.
  12738. @end itemize
  12739. @node Analyze Collected Data
  12740. @section Using the Collected Data
  12741. After the tracepoint experiment ends, you use @value{GDBN} commands
  12742. for examining the trace data. The basic idea is that each tracepoint
  12743. collects a trace @dfn{snapshot} every time it is hit and another
  12744. snapshot every time it single-steps. All these snapshots are
  12745. consecutively numbered from zero and go into a buffer, and you can
  12746. examine them later. The way you examine them is to @dfn{focus} on a
  12747. specific trace snapshot. When the remote stub is focused on a trace
  12748. snapshot, it will respond to all @value{GDBN} requests for memory and
  12749. registers by reading from the buffer which belongs to that snapshot,
  12750. rather than from @emph{real} memory or registers of the program being
  12751. debugged. This means that @strong{all} @value{GDBN} commands
  12752. (@code{print}, @code{info registers}, @code{backtrace}, etc.) will
  12753. behave as if we were currently debugging the program state as it was
  12754. when the tracepoint occurred. Any requests for data that are not in
  12755. the buffer will fail.
  12756. @menu
  12757. * tfind:: How to select a trace snapshot
  12758. * tdump:: How to display all data for a snapshot
  12759. * save tracepoints:: How to save tracepoints for a future run
  12760. @end menu
  12761. @node tfind
  12762. @subsection @code{tfind @var{n}}
  12763. @kindex tfind
  12764. @cindex select trace snapshot
  12765. @cindex find trace snapshot
  12766. The basic command for selecting a trace snapshot from the buffer is
  12767. @code{tfind @var{n}}, which finds trace snapshot number @var{n},
  12768. counting from zero. If no argument @var{n} is given, the next
  12769. snapshot is selected.
  12770. Here are the various forms of using the @code{tfind} command.
  12771. @table @code
  12772. @item tfind start
  12773. Find the first snapshot in the buffer. This is a synonym for
  12774. @code{tfind 0} (since 0 is the number of the first snapshot).
  12775. @item tfind none
  12776. Stop debugging trace snapshots, resume @emph{live} debugging.
  12777. @item tfind end
  12778. Same as @samp{tfind none}.
  12779. @item tfind
  12780. No argument means find the next trace snapshot or find the first
  12781. one if no trace snapshot is selected.
  12782. @item tfind -
  12783. Find the previous trace snapshot before the current one. This permits
  12784. retracing earlier steps.
  12785. @item tfind tracepoint @var{num}
  12786. Find the next snapshot associated with tracepoint @var{num}. Search
  12787. proceeds forward from the last examined trace snapshot. If no
  12788. argument @var{num} is given, it means find the next snapshot collected
  12789. for the same tracepoint as the current snapshot.
  12790. @item tfind pc @var{addr}
  12791. Find the next snapshot associated with the value @var{addr} of the
  12792. program counter. Search proceeds forward from the last examined trace
  12793. snapshot. If no argument @var{addr} is given, it means find the next
  12794. snapshot with the same value of PC as the current snapshot.
  12795. @item tfind outside @var{addr1}, @var{addr2}
  12796. Find the next snapshot whose PC is outside the given range of
  12797. addresses (exclusive).
  12798. @item tfind range @var{addr1}, @var{addr2}
  12799. Find the next snapshot whose PC is between @var{addr1} and
  12800. @var{addr2} (inclusive).
  12801. @item tfind line @r{[}@var{file}:@r{]}@var{n}
  12802. Find the next snapshot associated with the source line @var{n}. If
  12803. the optional argument @var{file} is given, refer to line @var{n} in
  12804. that source file. Search proceeds forward from the last examined
  12805. trace snapshot. If no argument @var{n} is given, it means find the
  12806. next line other than the one currently being examined; thus saying
  12807. @code{tfind line} repeatedly can appear to have the same effect as
  12808. stepping from line to line in a @emph{live} debugging session.
  12809. @end table
  12810. The default arguments for the @code{tfind} commands are specifically
  12811. designed to make it easy to scan through the trace buffer. For
  12812. instance, @code{tfind} with no argument selects the next trace
  12813. snapshot, and @code{tfind -} with no argument selects the previous
  12814. trace snapshot. So, by giving one @code{tfind} command, and then
  12815. simply hitting @key{RET} repeatedly you can examine all the trace
  12816. snapshots in order. Or, by saying @code{tfind -} and then hitting
  12817. @key{RET} repeatedly you can examine the snapshots in reverse order.
  12818. The @code{tfind line} command with no argument selects the snapshot
  12819. for the next source line executed. The @code{tfind pc} command with
  12820. no argument selects the next snapshot with the same program counter
  12821. (PC) as the current frame. The @code{tfind tracepoint} command with
  12822. no argument selects the next trace snapshot collected by the same
  12823. tracepoint as the current one.
  12824. In addition to letting you scan through the trace buffer manually,
  12825. these commands make it easy to construct @value{GDBN} scripts that
  12826. scan through the trace buffer and print out whatever collected data
  12827. you are interested in. Thus, if we want to examine the PC, FP, and SP
  12828. registers from each trace frame in the buffer, we can say this:
  12829. @smallexample
  12830. (@value{GDBP}) @b{tfind start}
  12831. (@value{GDBP}) @b{while ($trace_frame != -1)}
  12832. > printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \
  12833. $trace_frame, $pc, $sp, $fp
  12834. > tfind
  12835. > end
  12836. Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44
  12837. Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44
  12838. Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44
  12839. Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44
  12840. Frame 4, PC = 0020DC78, SP = 0030BF2C, FP = 0030BF44
  12841. Frame 5, PC = 0020DC7C, SP = 0030BF28, FP = 0030BF44
  12842. Frame 6, PC = 0020DC80, SP = 0030BF24, FP = 0030BF44
  12843. Frame 7, PC = 0020DC84, SP = 0030BF20, FP = 0030BF44
  12844. Frame 8, PC = 0020DC88, SP = 0030BF1C, FP = 0030BF44
  12845. Frame 9, PC = 0020DC8E, SP = 0030BF18, FP = 0030BF44
  12846. Frame 10, PC = 00203F6C, SP = 0030BE3C, FP = 0030BF14
  12847. @end smallexample
  12848. Or, if we want to examine the variable @code{X} at each source line in
  12849. the buffer:
  12850. @smallexample
  12851. (@value{GDBP}) @b{tfind start}
  12852. (@value{GDBP}) @b{while ($trace_frame != -1)}
  12853. > printf "Frame %d, X == %d\n", $trace_frame, X
  12854. > tfind line
  12855. > end
  12856. Frame 0, X = 1
  12857. Frame 7, X = 2
  12858. Frame 13, X = 255
  12859. @end smallexample
  12860. @node tdump
  12861. @subsection @code{tdump}
  12862. @kindex tdump
  12863. @cindex dump all data collected at tracepoint
  12864. @cindex tracepoint data, display
  12865. This command takes no arguments. It prints all the data collected at
  12866. the current trace snapshot.
  12867. @smallexample
  12868. (@value{GDBP}) @b{trace 444}
  12869. (@value{GDBP}) @b{actions}
  12870. Enter actions for tracepoint #2, one per line:
  12871. > collect $regs, $locals, $args, gdb_long_test
  12872. > end
  12873. (@value{GDBP}) @b{tstart}
  12874. (@value{GDBP}) @b{tfind line 444}
  12875. #0 gdb_test (p1=0x11, p2=0x22, p3=0x33, p4=0x44, p5=0x55, p6=0x66)
  12876. at gdb_test.c:444
  12877. 444 printp( "%s: arguments = 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n", )
  12878. (@value{GDBP}) @b{tdump}
  12879. Data collected at tracepoint 2, trace frame 1:
  12880. d0 0xc4aa0085 -995491707
  12881. d1 0x18 24
  12882. d2 0x80 128
  12883. d3 0x33 51
  12884. d4 0x71aea3d 119204413
  12885. d5 0x22 34
  12886. d6 0xe0 224
  12887. d7 0x380035 3670069
  12888. a0 0x19e24a 1696330
  12889. a1 0x3000668 50333288
  12890. a2 0x100 256
  12891. a3 0x322000 3284992
  12892. a4 0x3000698 50333336
  12893. a5 0x1ad3cc 1758156
  12894. fp 0x30bf3c 0x30bf3c
  12895. sp 0x30bf34 0x30bf34
  12896. ps 0x0 0
  12897. pc 0x20b2c8 0x20b2c8
  12898. fpcontrol 0x0 0
  12899. fpstatus 0x0 0
  12900. fpiaddr 0x0 0
  12901. p = 0x20e5b4 "gdb-test"
  12902. p1 = (void *) 0x11
  12903. p2 = (void *) 0x22
  12904. p3 = (void *) 0x33
  12905. p4 = (void *) 0x44
  12906. p5 = (void *) 0x55
  12907. p6 = (void *) 0x66
  12908. gdb_long_test = 17 '\021'
  12909. (@value{GDBP})
  12910. @end smallexample
  12911. @code{tdump} works by scanning the tracepoint's current collection
  12912. actions and printing the value of each expression listed. So
  12913. @code{tdump} can fail, if after a run, you change the tracepoint's
  12914. actions to mention variables that were not collected during the run.
  12915. Also, for tracepoints with @code{while-stepping} loops, @code{tdump}
  12916. uses the collected value of @code{$pc} to distinguish between trace
  12917. frames that were collected at the tracepoint hit, and frames that were
  12918. collected while stepping. This allows it to correctly choose whether
  12919. to display the basic list of collections, or the collections from the
  12920. body of the while-stepping loop. However, if @code{$pc} was not collected,
  12921. then @code{tdump} will always attempt to dump using the basic collection
  12922. list, and may fail if a while-stepping frame does not include all the
  12923. same data that is collected at the tracepoint hit.
  12924. @c This is getting pretty arcane, example would be good.
  12925. @node save tracepoints
  12926. @subsection @code{save tracepoints @var{filename}}
  12927. @kindex save tracepoints
  12928. @kindex save-tracepoints
  12929. @cindex save tracepoints for future sessions
  12930. This command saves all current tracepoint definitions together with
  12931. their actions and passcounts, into a file @file{@var{filename}}
  12932. suitable for use in a later debugging session. To read the saved
  12933. tracepoint definitions, use the @code{source} command (@pxref{Command
  12934. Files}). The @w{@code{save-tracepoints}} command is a deprecated
  12935. alias for @w{@code{save tracepoints}}
  12936. @node Tracepoint Variables
  12937. @section Convenience Variables for Tracepoints
  12938. @cindex tracepoint variables
  12939. @cindex convenience variables for tracepoints
  12940. @table @code
  12941. @vindex $trace_frame
  12942. @item (int) $trace_frame
  12943. The current trace snapshot (a.k.a.@: @dfn{frame}) number, or -1 if no
  12944. snapshot is selected.
  12945. @vindex $tracepoint
  12946. @item (int) $tracepoint
  12947. The tracepoint for the current trace snapshot.
  12948. @vindex $trace_line
  12949. @item (int) $trace_line
  12950. The line number for the current trace snapshot.
  12951. @vindex $trace_file
  12952. @item (char []) $trace_file
  12953. The source file for the current trace snapshot.
  12954. @vindex $trace_func
  12955. @item (char []) $trace_func
  12956. The name of the function containing @code{$tracepoint}.
  12957. @end table
  12958. Note: @code{$trace_file} is not suitable for use in @code{printf},
  12959. use @code{output} instead.
  12960. Here's a simple example of using these convenience variables for
  12961. stepping through all the trace snapshots and printing some of their
  12962. data. Note that these are not the same as trace state variables,
  12963. which are managed by the target.
  12964. @smallexample
  12965. (@value{GDBP}) @b{tfind start}
  12966. (@value{GDBP}) @b{while $trace_frame != -1}
  12967. > output $trace_file
  12968. > printf ", line %d (tracepoint #%d)\n", $trace_line, $tracepoint
  12969. > tfind
  12970. > end
  12971. @end smallexample
  12972. @node Trace Files
  12973. @section Using Trace Files
  12974. @cindex trace files
  12975. In some situations, the target running a trace experiment may no
  12976. longer be available; perhaps it crashed, or the hardware was needed
  12977. for a different activity. To handle these cases, you can arrange to
  12978. dump the trace data into a file, and later use that file as a source
  12979. of trace data, via the @code{target tfile} command.
  12980. @table @code
  12981. @kindex tsave
  12982. @item tsave [ -r ] @var{filename}
  12983. @itemx tsave [-ctf] @var{dirname}
  12984. Save the trace data to @var{filename}. By default, this command
  12985. assumes that @var{filename} refers to the host filesystem, so if
  12986. necessary @value{GDBN} will copy raw trace data up from the target and
  12987. then save it. If the target supports it, you can also supply the
  12988. optional argument @code{-r} (``remote'') to direct the target to save
  12989. the data directly into @var{filename} in its own filesystem, which may be
  12990. more efficient if the trace buffer is very large. (Note, however, that
  12991. @code{target tfile} can only read from files accessible to the host.)
  12992. By default, this command will save trace frame in tfile format.
  12993. You can supply the optional argument @code{-ctf} to save data in CTF
  12994. format. The @dfn{Common Trace Format} (CTF) is proposed as a trace format
  12995. that can be shared by multiple debugging and tracing tools. Please go to
  12996. @indicateurl{http://www.efficios.com/ctf} to get more information.
  12997. @kindex target tfile
  12998. @kindex tfile
  12999. @kindex target ctf
  13000. @kindex ctf
  13001. @item target tfile @var{filename}
  13002. @itemx target ctf @var{dirname}
  13003. Use the file named @var{filename} or directory named @var{dirname} as
  13004. a source of trace data. Commands that examine data work as they do with
  13005. a live target, but it is not possible to run any new trace experiments.
  13006. @code{tstatus} will report the state of the trace run at the moment
  13007. the data was saved, as well as the current trace frame you are examining.
  13008. Both @var{filename} and @var{dirname} must be on a filesystem accessible to
  13009. the host.
  13010. @smallexample
  13011. (@value{GDBP}) target ctf ctf.ctf
  13012. (@value{GDBP}) tfind
  13013. Found trace frame 0, tracepoint 2
  13014. 39 ++a; /* set tracepoint 1 here */
  13015. (@value{GDBP}) tdump
  13016. Data collected at tracepoint 2, trace frame 0:
  13017. i = 0
  13018. a = 0
  13019. b = 1 '\001'
  13020. c = @{"123", "456", "789", "123", "456", "789"@}
  13021. d = @{@{@{a = 1, b = 2@}, @{a = 3, b = 4@}@}, @{@{a = 5, b = 6@}, @{a = 7, b = 8@}@}@}
  13022. (@value{GDBP}) p b
  13023. $1 = 1
  13024. @end smallexample
  13025. @end table
  13026. @node Overlays
  13027. @chapter Debugging Programs That Use Overlays
  13028. @cindex overlays
  13029. If your program is too large to fit completely in your target system's
  13030. memory, you can sometimes use @dfn{overlays} to work around this
  13031. problem. @value{GDBN} provides some support for debugging programs that
  13032. use overlays.
  13033. @menu
  13034. * How Overlays Work:: A general explanation of overlays.
  13035. * Overlay Commands:: Managing overlays in @value{GDBN}.
  13036. * Automatic Overlay Debugging:: @value{GDBN} can find out which overlays are
  13037. mapped by asking the inferior.
  13038. * Overlay Sample Program:: A sample program using overlays.
  13039. @end menu
  13040. @node How Overlays Work
  13041. @section How Overlays Work
  13042. @cindex mapped overlays
  13043. @cindex unmapped overlays
  13044. @cindex load address, overlay's
  13045. @cindex mapped address
  13046. @cindex overlay area
  13047. Suppose you have a computer whose instruction address space is only 64
  13048. kilobytes long, but which has much more memory which can be accessed by
  13049. other means: special instructions, segment registers, or memory
  13050. management hardware, for example. Suppose further that you want to
  13051. adapt a program which is larger than 64 kilobytes to run on this system.
  13052. One solution is to identify modules of your program which are relatively
  13053. independent, and need not call each other directly; call these modules
  13054. @dfn{overlays}. Separate the overlays from the main program, and place
  13055. their machine code in the larger memory. Place your main program in
  13056. instruction memory, but leave at least enough space there to hold the
  13057. largest overlay as well.
  13058. Now, to call a function located in an overlay, you must first copy that
  13059. overlay's machine code from the large memory into the space set aside
  13060. for it in the instruction memory, and then jump to its entry point
  13061. there.
  13062. @c NB: In the below the mapped area's size is greater or equal to the
  13063. @c size of all overlays. This is intentional to remind the developer
  13064. @c that overlays don't necessarily need to be the same size.
  13065. @smallexample
  13066. @group
  13067. Data Instruction Larger
  13068. Address Space Address Space Address Space
  13069. +-----------+ +-----------+ +-----------+
  13070. | | | | | |
  13071. +-----------+ +-----------+ +-----------+<-- overlay 1
  13072. | program | | main | .----| overlay 1 | load address
  13073. | variables | | program | | +-----------+
  13074. | and heap | | | | | |
  13075. +-----------+ | | | +-----------+<-- overlay 2
  13076. | | +-----------+ | | | load address
  13077. +-----------+ | | | .-| overlay 2 |
  13078. | | | | | |
  13079. mapped --->+-----------+ | | +-----------+
  13080. address | | | | | |
  13081. | overlay | <-' | | |
  13082. | area | <---' +-----------+<-- overlay 3
  13083. | | <---. | | load address
  13084. +-----------+ `--| overlay 3 |
  13085. | | | |
  13086. +-----------+ | |
  13087. +-----------+
  13088. | |
  13089. +-----------+
  13090. @anchor{A code overlay}A code overlay
  13091. @end group
  13092. @end smallexample
  13093. The diagram (@pxref{A code overlay}) shows a system with separate data
  13094. and instruction address spaces. To map an overlay, the program copies
  13095. its code from the larger address space to the instruction address space.
  13096. Since the overlays shown here all use the same mapped address, only one
  13097. may be mapped at a time. For a system with a single address space for
  13098. data and instructions, the diagram would be similar, except that the
  13099. program variables and heap would share an address space with the main
  13100. program and the overlay area.
  13101. An overlay loaded into instruction memory and ready for use is called a
  13102. @dfn{mapped} overlay; its @dfn{mapped address} is its address in the
  13103. instruction memory. An overlay not present (or only partially present)
  13104. in instruction memory is called @dfn{unmapped}; its @dfn{load address}
  13105. is its address in the larger memory. The mapped address is also called
  13106. the @dfn{virtual memory address}, or @dfn{VMA}; the load address is also
  13107. called the @dfn{load memory address}, or @dfn{LMA}.
  13108. Unfortunately, overlays are not a completely transparent way to adapt a
  13109. program to limited instruction memory. They introduce a new set of
  13110. global constraints you must keep in mind as you design your program:
  13111. @itemize @bullet
  13112. @item
  13113. Before calling or returning to a function in an overlay, your program
  13114. must make sure that overlay is actually mapped. Otherwise, the call or
  13115. return will transfer control to the right address, but in the wrong
  13116. overlay, and your program will probably crash.
  13117. @item
  13118. If the process of mapping an overlay is expensive on your system, you
  13119. will need to choose your overlays carefully to minimize their effect on
  13120. your program's performance.
  13121. @item
  13122. The executable file you load onto your system must contain each
  13123. overlay's instructions, appearing at the overlay's load address, not its
  13124. mapped address. However, each overlay's instructions must be relocated
  13125. and its symbols defined as if the overlay were at its mapped address.
  13126. You can use GNU linker scripts to specify different load and relocation
  13127. addresses for pieces of your program; see @ref{Overlay Description,,,
  13128. ld.info, Using ld: the GNU linker}.
  13129. @item
  13130. The procedure for loading executable files onto your system must be able
  13131. to load their contents into the larger address space as well as the
  13132. instruction and data spaces.
  13133. @end itemize
  13134. The overlay system described above is rather simple, and could be
  13135. improved in many ways:
  13136. @itemize @bullet
  13137. @item
  13138. If your system has suitable bank switch registers or memory management
  13139. hardware, you could use those facilities to make an overlay's load area
  13140. contents simply appear at their mapped address in instruction space.
  13141. This would probably be faster than copying the overlay to its mapped
  13142. area in the usual way.
  13143. @item
  13144. If your overlays are small enough, you could set aside more than one
  13145. overlay area, and have more than one overlay mapped at a time.
  13146. @item
  13147. You can use overlays to manage data, as well as instructions. In
  13148. general, data overlays are even less transparent to your design than
  13149. code overlays: whereas code overlays only require care when you call or
  13150. return to functions, data overlays require care every time you access
  13151. the data. Also, if you change the contents of a data overlay, you
  13152. must copy its contents back out to its load address before you can copy a
  13153. different data overlay into the same mapped area.
  13154. @end itemize
  13155. @node Overlay Commands
  13156. @section Overlay Commands
  13157. To use @value{GDBN}'s overlay support, each overlay in your program must
  13158. correspond to a separate section of the executable file. The section's
  13159. virtual memory address and load memory address must be the overlay's
  13160. mapped and load addresses. Identifying overlays with sections allows
  13161. @value{GDBN} to determine the appropriate address of a function or
  13162. variable, depending on whether the overlay is mapped or not.
  13163. @value{GDBN}'s overlay commands all start with the word @code{overlay};
  13164. you can abbreviate this as @code{ov} or @code{ovly}. The commands are:
  13165. @table @code
  13166. @item overlay off
  13167. @kindex overlay
  13168. Disable @value{GDBN}'s overlay support. When overlay support is
  13169. disabled, @value{GDBN} assumes that all functions and variables are
  13170. always present at their mapped addresses. By default, @value{GDBN}'s
  13171. overlay support is disabled.
  13172. @item overlay manual
  13173. @cindex manual overlay debugging
  13174. Enable @dfn{manual} overlay debugging. In this mode, @value{GDBN}
  13175. relies on you to tell it which overlays are mapped, and which are not,
  13176. using the @code{overlay map-overlay} and @code{overlay unmap-overlay}
  13177. commands described below.
  13178. @item overlay map-overlay @var{overlay}
  13179. @itemx overlay map @var{overlay}
  13180. @cindex map an overlay
  13181. Tell @value{GDBN} that @var{overlay} is now mapped; @var{overlay} must
  13182. be the name of the object file section containing the overlay. When an
  13183. overlay is mapped, @value{GDBN} assumes it can find the overlay's
  13184. functions and variables at their mapped addresses. @value{GDBN} assumes
  13185. that any other overlays whose mapped ranges overlap that of
  13186. @var{overlay} are now unmapped.
  13187. @item overlay unmap-overlay @var{overlay}
  13188. @itemx overlay unmap @var{overlay}
  13189. @cindex unmap an overlay
  13190. Tell @value{GDBN} that @var{overlay} is no longer mapped; @var{overlay}
  13191. must be the name of the object file section containing the overlay.
  13192. When an overlay is unmapped, @value{GDBN} assumes it can find the
  13193. overlay's functions and variables at their load addresses.
  13194. @item overlay auto
  13195. Enable @dfn{automatic} overlay debugging. In this mode, @value{GDBN}
  13196. consults a data structure the overlay manager maintains in the inferior
  13197. to see which overlays are mapped. For details, see @ref{Automatic
  13198. Overlay Debugging}.
  13199. @item overlay load-target
  13200. @itemx overlay load
  13201. @cindex reloading the overlay table
  13202. Re-read the overlay table from the inferior. Normally, @value{GDBN}
  13203. re-reads the table @value{GDBN} automatically each time the inferior
  13204. stops, so this command should only be necessary if you have changed the
  13205. overlay mapping yourself using @value{GDBN}. This command is only
  13206. useful when using automatic overlay debugging.
  13207. @item overlay list-overlays
  13208. @itemx overlay list
  13209. @cindex listing mapped overlays
  13210. Display a list of the overlays currently mapped, along with their mapped
  13211. addresses, load addresses, and sizes.
  13212. @end table
  13213. Normally, when @value{GDBN} prints a code address, it includes the name
  13214. of the function the address falls in:
  13215. @smallexample
  13216. (@value{GDBP}) print main
  13217. $3 = @{int ()@} 0x11a0 <main>
  13218. @end smallexample
  13219. @noindent
  13220. When overlay debugging is enabled, @value{GDBN} recognizes code in
  13221. unmapped overlays, and prints the names of unmapped functions with
  13222. asterisks around them. For example, if @code{foo} is a function in an
  13223. unmapped overlay, @value{GDBN} prints it this way:
  13224. @smallexample
  13225. (@value{GDBP}) overlay list
  13226. No sections are mapped.
  13227. (@value{GDBP}) print foo
  13228. $5 = @{int (int)@} 0x100000 <*foo*>
  13229. @end smallexample
  13230. @noindent
  13231. When @code{foo}'s overlay is mapped, @value{GDBN} prints the function's
  13232. name normally:
  13233. @smallexample
  13234. (@value{GDBP}) overlay list
  13235. Section .ov.foo.text, loaded at 0x100000 - 0x100034,
  13236. mapped at 0x1016 - 0x104a
  13237. (@value{GDBP}) print foo
  13238. $6 = @{int (int)@} 0x1016 <foo>
  13239. @end smallexample
  13240. When overlay debugging is enabled, @value{GDBN} can find the correct
  13241. address for functions and variables in an overlay, whether or not the
  13242. overlay is mapped. This allows most @value{GDBN} commands, like
  13243. @code{break} and @code{disassemble}, to work normally, even on unmapped
  13244. code. However, @value{GDBN}'s breakpoint support has some limitations:
  13245. @itemize @bullet
  13246. @item
  13247. @cindex breakpoints in overlays
  13248. @cindex overlays, setting breakpoints in
  13249. You can set breakpoints in functions in unmapped overlays, as long as
  13250. @value{GDBN} can write to the overlay at its load address.
  13251. @item
  13252. @value{GDBN} can not set hardware or simulator-based breakpoints in
  13253. unmapped overlays. However, if you set a breakpoint at the end of your
  13254. overlay manager (and tell @value{GDBN} which overlays are now mapped, if
  13255. you are using manual overlay management), @value{GDBN} will re-set its
  13256. breakpoints properly.
  13257. @end itemize
  13258. @node Automatic Overlay Debugging
  13259. @section Automatic Overlay Debugging
  13260. @cindex automatic overlay debugging
  13261. @value{GDBN} can automatically track which overlays are mapped and which
  13262. are not, given some simple co-operation from the overlay manager in the
  13263. inferior. If you enable automatic overlay debugging with the
  13264. @code{overlay auto} command (@pxref{Overlay Commands}), @value{GDBN}
  13265. looks in the inferior's memory for certain variables describing the
  13266. current state of the overlays.
  13267. Here are the variables your overlay manager must define to support
  13268. @value{GDBN}'s automatic overlay debugging:
  13269. @table @asis
  13270. @item @code{_ovly_table}:
  13271. This variable must be an array of the following structures:
  13272. @smallexample
  13273. struct
  13274. @{
  13275. /* The overlay's mapped address. */
  13276. unsigned long vma;
  13277. /* The size of the overlay, in bytes. */
  13278. unsigned long size;
  13279. /* The overlay's load address. */
  13280. unsigned long lma;
  13281. /* Non-zero if the overlay is currently mapped;
  13282. zero otherwise. */
  13283. unsigned long mapped;
  13284. @}
  13285. @end smallexample
  13286. @item @code{_novlys}:
  13287. This variable must be a four-byte signed integer, holding the total
  13288. number of elements in @code{_ovly_table}.
  13289. @end table
  13290. To decide whether a particular overlay is mapped or not, @value{GDBN}
  13291. looks for an entry in @w{@code{_ovly_table}} whose @code{vma} and
  13292. @code{lma} members equal the VMA and LMA of the overlay's section in the
  13293. executable file. When @value{GDBN} finds a matching entry, it consults
  13294. the entry's @code{mapped} member to determine whether the overlay is
  13295. currently mapped.
  13296. In addition, your overlay manager may define a function called
  13297. @code{_ovly_debug_event}. If this function is defined, @value{GDBN}
  13298. will silently set a breakpoint there. If the overlay manager then
  13299. calls this function whenever it has changed the overlay table, this
  13300. will enable @value{GDBN} to accurately keep track of which overlays
  13301. are in program memory, and update any breakpoints that may be set
  13302. in overlays. This will allow breakpoints to work even if the
  13303. overlays are kept in ROM or other non-writable memory while they
  13304. are not being executed.
  13305. @node Overlay Sample Program
  13306. @section Overlay Sample Program
  13307. @cindex overlay example program
  13308. When linking a program which uses overlays, you must place the overlays
  13309. at their load addresses, while relocating them to run at their mapped
  13310. addresses. To do this, you must write a linker script (@pxref{Overlay
  13311. Description,,, ld.info, Using ld: the GNU linker}). Unfortunately,
  13312. since linker scripts are specific to a particular host system, target
  13313. architecture, and target memory layout, this manual cannot provide
  13314. portable sample code demonstrating @value{GDBN}'s overlay support.
  13315. However, the @value{GDBN} source distribution does contain an overlaid
  13316. program, with linker scripts for a few systems, as part of its test
  13317. suite. The program consists of the following files from
  13318. @file{gdb/testsuite/gdb.base}:
  13319. @table @file
  13320. @item overlays.c
  13321. The main program file.
  13322. @item ovlymgr.c
  13323. A simple overlay manager, used by @file{overlays.c}.
  13324. @item foo.c
  13325. @itemx bar.c
  13326. @itemx baz.c
  13327. @itemx grbx.c
  13328. Overlay modules, loaded and used by @file{overlays.c}.
  13329. @item d10v.ld
  13330. @itemx m32r.ld
  13331. Linker scripts for linking the test program on the @code{d10v-elf}
  13332. and @code{m32r-elf} targets.
  13333. @end table
  13334. You can build the test program using the @code{d10v-elf} GCC
  13335. cross-compiler like this:
  13336. @smallexample
  13337. $ d10v-elf-gcc -g -c overlays.c
  13338. $ d10v-elf-gcc -g -c ovlymgr.c
  13339. $ d10v-elf-gcc -g -c foo.c
  13340. $ d10v-elf-gcc -g -c bar.c
  13341. $ d10v-elf-gcc -g -c baz.c
  13342. $ d10v-elf-gcc -g -c grbx.c
  13343. $ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
  13344. baz.o grbx.o -Wl,-Td10v.ld -o overlays
  13345. @end smallexample
  13346. The build process is identical for any other architecture, except that
  13347. you must substitute the appropriate compiler and linker script for the
  13348. target system for @code{d10v-elf-gcc} and @code{d10v.ld}.
  13349. @node Languages
  13350. @chapter Using @value{GDBN} with Different Languages
  13351. @cindex languages
  13352. Although programming languages generally have common aspects, they are
  13353. rarely expressed in the same manner. For instance, in ANSI C,
  13354. dereferencing a pointer @code{p} is accomplished by @code{*p}, but in
  13355. Modula-2, it is accomplished by @code{p^}. Values can also be
  13356. represented (and displayed) differently. Hex numbers in C appear as
  13357. @samp{0x1ae}, while in Modula-2 they appear as @samp{1AEH}.
  13358. @cindex working language
  13359. Language-specific information is built into @value{GDBN} for some languages,
  13360. allowing you to express operations like the above in your program's
  13361. native language, and allowing @value{GDBN} to output values in a manner
  13362. consistent with the syntax of your program's native language. The
  13363. language you use to build expressions is called the @dfn{working
  13364. language}.
  13365. @menu
  13366. * Setting:: Switching between source languages
  13367. * Show:: Displaying the language
  13368. * Checks:: Type and range checks
  13369. * Supported Languages:: Supported languages
  13370. * Unsupported Languages:: Unsupported languages
  13371. @end menu
  13372. @node Setting
  13373. @section Switching Between Source Languages
  13374. There are two ways to control the working language---either have @value{GDBN}
  13375. set it automatically, or select it manually yourself. You can use the
  13376. @code{set language} command for either purpose. On startup, @value{GDBN}
  13377. defaults to setting the language automatically. The working language is
  13378. used to determine how expressions you type are interpreted, how values
  13379. are printed, etc.
  13380. In addition to the working language, every source file that
  13381. @value{GDBN} knows about has its own working language. For some object
  13382. file formats, the compiler might indicate which language a particular
  13383. source file is in. However, most of the time @value{GDBN} infers the
  13384. language from the name of the file. The language of a source file
  13385. controls whether C@t{++} names are demangled---this way @code{backtrace} can
  13386. show each frame appropriately for its own language. There is no way to
  13387. set the language of a source file from within @value{GDBN}, but you can
  13388. set the language associated with a filename extension. @xref{Show, ,
  13389. Displaying the Language}.
  13390. This is most commonly a problem when you use a program, such
  13391. as @code{cfront} or @code{f2c}, that generates C but is written in
  13392. another language. In that case, make the
  13393. program use @code{#line} directives in its C output; that way
  13394. @value{GDBN} will know the correct language of the source code of the original
  13395. program, and will display that source code, not the generated C code.
  13396. @menu
  13397. * Filenames:: Filename extensions and languages.
  13398. * Manually:: Setting the working language manually
  13399. * Automatically:: Having @value{GDBN} infer the source language
  13400. @end menu
  13401. @node Filenames
  13402. @subsection List of Filename Extensions and Languages
  13403. If a source file name ends in one of the following extensions, then
  13404. @value{GDBN} infers that its language is the one indicated.
  13405. @table @file
  13406. @item .ada
  13407. @itemx .ads
  13408. @itemx .adb
  13409. @itemx .a
  13410. Ada source file.
  13411. @item .c
  13412. C source file
  13413. @item .C
  13414. @itemx .cc
  13415. @itemx .cp
  13416. @itemx .cpp
  13417. @itemx .cxx
  13418. @itemx .c++
  13419. C@t{++} source file
  13420. @item .d
  13421. D source file
  13422. @item .m
  13423. Objective-C source file
  13424. @item .f
  13425. @itemx .F
  13426. Fortran source file
  13427. @item .mod
  13428. Modula-2 source file
  13429. @item .s
  13430. @itemx .S
  13431. Assembler source file. This actually behaves almost like C, but
  13432. @value{GDBN} does not skip over function prologues when stepping.
  13433. @end table
  13434. In addition, you may set the language associated with a filename
  13435. extension. @xref{Show, , Displaying the Language}.
  13436. @node Manually
  13437. @subsection Setting the Working Language
  13438. If you allow @value{GDBN} to set the language automatically,
  13439. expressions are interpreted the same way in your debugging session and
  13440. your program.
  13441. @kindex set language
  13442. If you wish, you may set the language manually. To do this, issue the
  13443. command @samp{set language @var{lang}}, where @var{lang} is the name of
  13444. a language, such as
  13445. @code{c} or @code{modula-2}.
  13446. For a list of the supported languages, type @samp{set language}.
  13447. Setting the language manually prevents @value{GDBN} from updating the working
  13448. language automatically. This can lead to confusion if you try
  13449. to debug a program when the working language is not the same as the
  13450. source language, when an expression is acceptable to both
  13451. languages---but means different things. For instance, if the current
  13452. source file were written in C, and @value{GDBN} was parsing Modula-2, a
  13453. command such as:
  13454. @smallexample
  13455. print a = b + c
  13456. @end smallexample
  13457. @noindent
  13458. might not have the effect you intended. In C, this means to add
  13459. @code{b} and @code{c} and place the result in @code{a}. The result
  13460. printed would be the value of @code{a}. In Modula-2, this means to compare
  13461. @code{a} to the result of @code{b+c}, yielding a @code{BOOLEAN} value.
  13462. @node Automatically
  13463. @subsection Having @value{GDBN} Infer the Source Language
  13464. To have @value{GDBN} set the working language automatically, use
  13465. @samp{set language local} or @samp{set language auto}. @value{GDBN}
  13466. then infers the working language. That is, when your program stops in a
  13467. frame (usually by encountering a breakpoint), @value{GDBN} sets the
  13468. working language to the language recorded for the function in that
  13469. frame. If the language for a frame is unknown (that is, if the function
  13470. or block corresponding to the frame was defined in a source file that
  13471. does not have a recognized extension), the current working language is
  13472. not changed, and @value{GDBN} issues a warning.
  13473. This may not seem necessary for most programs, which are written
  13474. entirely in one source language. However, program modules and libraries
  13475. written in one source language can be used by a main program written in
  13476. a different source language. Using @samp{set language auto} in this
  13477. case frees you from having to set the working language manually.
  13478. @node Show
  13479. @section Displaying the Language
  13480. The following commands help you find out which language is the
  13481. working language, and also what language source files were written in.
  13482. @table @code
  13483. @item show language
  13484. @anchor{show language}
  13485. @kindex show language
  13486. Display the current working language. This is the
  13487. language you can use with commands such as @code{print} to
  13488. build and compute expressions that may involve variables in your program.
  13489. @item info frame
  13490. @kindex info frame@r{, show the source language}
  13491. Display the source language for this frame. This language becomes the
  13492. working language if you use an identifier from this frame.
  13493. @xref{Frame Info, ,Information about a Frame}, to identify the other
  13494. information listed here.
  13495. @item info source
  13496. @kindex info source@r{, show the source language}
  13497. Display the source language of this source file.
  13498. @xref{Symbols, ,Examining the Symbol Table}, to identify the other
  13499. information listed here.
  13500. @end table
  13501. In unusual circumstances, you may have source files with extensions
  13502. not in the standard list. You can then set the extension associated
  13503. with a language explicitly:
  13504. @table @code
  13505. @item set extension-language @var{ext} @var{language}
  13506. @kindex set extension-language
  13507. Tell @value{GDBN} that source files with extension @var{ext} are to be
  13508. assumed as written in the source language @var{language}.
  13509. @item info extensions
  13510. @kindex info extensions
  13511. List all the filename extensions and the associated languages.
  13512. @end table
  13513. @node Checks
  13514. @section Type and Range Checking
  13515. Some languages are designed to guard you against making seemingly common
  13516. errors through a series of compile- and run-time checks. These include
  13517. checking the type of arguments to functions and operators and making
  13518. sure mathematical overflows are caught at run time. Checks such as
  13519. these help to ensure a program's correctness once it has been compiled
  13520. by eliminating type mismatches and providing active checks for range
  13521. errors when your program is running.
  13522. By default @value{GDBN} checks for these errors according to the
  13523. rules of the current source language. Although @value{GDBN} does not check
  13524. the statements in your program, it can check expressions entered directly
  13525. into @value{GDBN} for evaluation via the @code{print} command, for example.
  13526. @menu
  13527. * Type Checking:: An overview of type checking
  13528. * Range Checking:: An overview of range checking
  13529. @end menu
  13530. @cindex type checking
  13531. @cindex checks, type
  13532. @node Type Checking
  13533. @subsection An Overview of Type Checking
  13534. Some languages, such as C and C@t{++}, are strongly typed, meaning that the
  13535. arguments to operators and functions have to be of the correct type,
  13536. otherwise an error occurs. These checks prevent type mismatch
  13537. errors from ever causing any run-time problems. For example,
  13538. @smallexample
  13539. int klass::my_method(char *b) @{ return b ? 1 : 2; @}
  13540. (@value{GDBP}) print obj.my_method (0)
  13541. $1 = 2
  13542. @exdent but
  13543. (@value{GDBP}) print obj.my_method (0x1234)
  13544. Cannot resolve method klass::my_method to any overloaded instance
  13545. @end smallexample
  13546. The second example fails because in C@t{++} the integer constant
  13547. @samp{0x1234} is not type-compatible with the pointer parameter type.
  13548. For the expressions you use in @value{GDBN} commands, you can tell
  13549. @value{GDBN} to not enforce strict type checking or
  13550. to treat any mismatches as errors and abandon the expression;
  13551. When type checking is disabled, @value{GDBN} successfully evaluates
  13552. expressions like the second example above.
  13553. Even if type checking is off, there may be other reasons
  13554. related to type that prevent @value{GDBN} from evaluating an expression.
  13555. For instance, @value{GDBN} does not know how to add an @code{int} and
  13556. a @code{struct foo}. These particular type errors have nothing to do
  13557. with the language in use and usually arise from expressions which make
  13558. little sense to evaluate anyway.
  13559. @value{GDBN} provides some additional commands for controlling type checking:
  13560. @kindex set check type
  13561. @kindex show check type
  13562. @table @code
  13563. @item set check type on
  13564. @itemx set check type off
  13565. Set strict type checking on or off. If any type mismatches occur in
  13566. evaluating an expression while type checking is on, @value{GDBN} prints a
  13567. message and aborts evaluation of the expression.
  13568. @item show check type
  13569. Show the current setting of type checking and whether @value{GDBN}
  13570. is enforcing strict type checking rules.
  13571. @end table
  13572. @cindex range checking
  13573. @cindex checks, range
  13574. @node Range Checking
  13575. @subsection An Overview of Range Checking
  13576. In some languages (such as Modula-2), it is an error to exceed the
  13577. bounds of a type; this is enforced with run-time checks. Such range
  13578. checking is meant to ensure program correctness by making sure
  13579. computations do not overflow, or indices on an array element access do
  13580. not exceed the bounds of the array.
  13581. For expressions you use in @value{GDBN} commands, you can tell
  13582. @value{GDBN} to treat range errors in one of three ways: ignore them,
  13583. always treat them as errors and abandon the expression, or issue
  13584. warnings but evaluate the expression anyway.
  13585. A range error can result from numerical overflow, from exceeding an
  13586. array index bound, or when you type a constant that is not a member
  13587. of any type. Some languages, however, do not treat overflows as an
  13588. error. In many implementations of C, mathematical overflow causes the
  13589. result to ``wrap around'' to lower values---for example, if @var{m} is
  13590. the largest integer value, and @var{s} is the smallest, then
  13591. @smallexample
  13592. @var{m} + 1 @result{} @var{s}
  13593. @end smallexample
  13594. This, too, is specific to individual languages, and in some cases
  13595. specific to individual compilers or machines. @xref{Supported Languages, ,
  13596. Supported Languages}, for further details on specific languages.
  13597. @value{GDBN} provides some additional commands for controlling the range checker:
  13598. @kindex set check range
  13599. @kindex show check range
  13600. @table @code
  13601. @item set check range auto
  13602. Set range checking on or off based on the current working language.
  13603. @xref{Supported Languages, ,Supported Languages}, for the default settings for
  13604. each language.
  13605. @item set check range on
  13606. @itemx set check range off
  13607. Set range checking on or off, overriding the default setting for the
  13608. current working language. A warning is issued if the setting does not
  13609. match the language default. If a range error occurs and range checking is on,
  13610. then a message is printed and evaluation of the expression is aborted.
  13611. @item set check range warn
  13612. Output messages when the @value{GDBN} range checker detects a range error,
  13613. but attempt to evaluate the expression anyway. Evaluating the
  13614. expression may still be impossible for other reasons, such as accessing
  13615. memory that the process does not own (a typical example from many Unix
  13616. systems).
  13617. @item show check range
  13618. Show the current setting of the range checker, and whether or not it is
  13619. being set automatically by @value{GDBN}.
  13620. @end table
  13621. @node Supported Languages
  13622. @section Supported Languages
  13623. @value{GDBN} supports C, C@t{++}, D, Go, Objective-C, Fortran,
  13624. OpenCL C, Pascal, Rust, assembly, Modula-2, and Ada.
  13625. @c This is false ...
  13626. Some @value{GDBN} features may be used in expressions regardless of the
  13627. language you use: the @value{GDBN} @code{@@} and @code{::} operators,
  13628. and the @samp{@{type@}addr} construct (@pxref{Expressions,
  13629. ,Expressions}) can be used with the constructs of any supported
  13630. language.
  13631. The following sections detail to what degree each source language is
  13632. supported by @value{GDBN}. These sections are not meant to be language
  13633. tutorials or references, but serve only as a reference guide to what the
  13634. @value{GDBN} expression parser accepts, and what input and output
  13635. formats should look like for different languages. There are many good
  13636. books written on each of these languages; please look to these for a
  13637. language reference or tutorial.
  13638. @menu
  13639. * C:: C and C@t{++}
  13640. * D:: D
  13641. * Go:: Go
  13642. * Objective-C:: Objective-C
  13643. * OpenCL C:: OpenCL C
  13644. * Fortran:: Fortran
  13645. * Pascal:: Pascal
  13646. * Rust:: Rust
  13647. * Modula-2:: Modula-2
  13648. * Ada:: Ada
  13649. @end menu
  13650. @node C
  13651. @subsection C and C@t{++}
  13652. @cindex C and C@t{++}
  13653. @cindex expressions in C or C@t{++}
  13654. Since C and C@t{++} are so closely related, many features of @value{GDBN} apply
  13655. to both languages. Whenever this is the case, we discuss those languages
  13656. together.
  13657. @cindex C@t{++}
  13658. @cindex @code{g++}, @sc{gnu} C@t{++} compiler
  13659. @cindex @sc{gnu} C@t{++}
  13660. The C@t{++} debugging facilities are jointly implemented by the C@t{++}
  13661. compiler and @value{GDBN}. Therefore, to debug your C@t{++} code
  13662. effectively, you must compile your C@t{++} programs with a supported
  13663. C@t{++} compiler, such as @sc{gnu} @code{g++}, or the HP ANSI C@t{++}
  13664. compiler (@code{aCC}).
  13665. @menu
  13666. * C Operators:: C and C@t{++} operators
  13667. * C Constants:: C and C@t{++} constants
  13668. * C Plus Plus Expressions:: C@t{++} expressions
  13669. * C Defaults:: Default settings for C and C@t{++}
  13670. * C Checks:: C and C@t{++} type and range checks
  13671. * Debugging C:: @value{GDBN} and C
  13672. * Debugging C Plus Plus:: @value{GDBN} features for C@t{++}
  13673. * Decimal Floating Point:: Numbers in Decimal Floating Point format
  13674. @end menu
  13675. @node C Operators
  13676. @subsubsection C and C@t{++} Operators
  13677. @cindex C and C@t{++} operators
  13678. Operators must be defined on values of specific types. For instance,
  13679. @code{+} is defined on numbers, but not on structures. Operators are
  13680. often defined on groups of types.
  13681. For the purposes of C and C@t{++}, the following definitions hold:
  13682. @itemize @bullet
  13683. @item
  13684. @emph{Integral types} include @code{int} with any of its storage-class
  13685. specifiers; @code{char}; @code{enum}; and, for C@t{++}, @code{bool}.
  13686. @item
  13687. @emph{Floating-point types} include @code{float}, @code{double}, and
  13688. @code{long double} (if supported by the target platform).
  13689. @item
  13690. @emph{Pointer types} include all types defined as @code{(@var{type} *)}.
  13691. @item
  13692. @emph{Scalar types} include all of the above.
  13693. @end itemize
  13694. @noindent
  13695. The following operators are supported. They are listed here
  13696. in order of increasing precedence:
  13697. @table @code
  13698. @item ,
  13699. The comma or sequencing operator. Expressions in a comma-separated list
  13700. are evaluated from left to right, with the result of the entire
  13701. expression being the last expression evaluated.
  13702. @item =
  13703. Assignment. The value of an assignment expression is the value
  13704. assigned. Defined on scalar types.
  13705. @item @var{op}=
  13706. Used in an expression of the form @w{@code{@var{a} @var{op}= @var{b}}},
  13707. and translated to @w{@code{@var{a} = @var{a op b}}}.
  13708. @w{@code{@var{op}=}} and @code{=} have the same precedence. The operator
  13709. @var{op} is any one of the operators @code{|}, @code{^}, @code{&},
  13710. @code{<<}, @code{>>}, @code{+}, @code{-}, @code{*}, @code{/}, @code{%}.
  13711. @item ?:
  13712. The ternary operator. @code{@var{a} ? @var{b} : @var{c}} can be thought
  13713. of as: if @var{a} then @var{b} else @var{c}. The argument @var{a}
  13714. should be of an integral type.
  13715. @item ||
  13716. Logical @sc{or}. Defined on integral types.
  13717. @item &&
  13718. Logical @sc{and}. Defined on integral types.
  13719. @item |
  13720. Bitwise @sc{or}. Defined on integral types.
  13721. @item ^
  13722. Bitwise exclusive-@sc{or}. Defined on integral types.
  13723. @item &
  13724. Bitwise @sc{and}. Defined on integral types.
  13725. @item ==@r{, }!=
  13726. Equality and inequality. Defined on scalar types. The value of these
  13727. expressions is 0 for false and non-zero for true.
  13728. @item <@r{, }>@r{, }<=@r{, }>=
  13729. Less than, greater than, less than or equal, greater than or equal.
  13730. Defined on scalar types. The value of these expressions is 0 for false
  13731. and non-zero for true.
  13732. @item <<@r{, }>>
  13733. left shift, and right shift. Defined on integral types.
  13734. @item @@
  13735. The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
  13736. @item +@r{, }-
  13737. Addition and subtraction. Defined on integral types, floating-point types and
  13738. pointer types.
  13739. @item *@r{, }/@r{, }%
  13740. Multiplication, division, and modulus. Multiplication and division are
  13741. defined on integral and floating-point types. Modulus is defined on
  13742. integral types.
  13743. @item ++@r{, }--
  13744. Increment and decrement. When appearing before a variable, the
  13745. operation is performed before the variable is used in an expression;
  13746. when appearing after it, the variable's value is used before the
  13747. operation takes place.
  13748. @item *
  13749. Pointer dereferencing. Defined on pointer types. Same precedence as
  13750. @code{++}.
  13751. @item &
  13752. Address operator. Defined on variables. Same precedence as @code{++}.
  13753. For debugging C@t{++}, @value{GDBN} implements a use of @samp{&} beyond what is
  13754. allowed in the C@t{++} language itself: you can use @samp{&(&@var{ref})}
  13755. to examine the address
  13756. where a C@t{++} reference variable (declared with @samp{&@var{ref}}) is
  13757. stored.
  13758. @item -
  13759. Negative. Defined on integral and floating-point types. Same
  13760. precedence as @code{++}.
  13761. @item !
  13762. Logical negation. Defined on integral types. Same precedence as
  13763. @code{++}.
  13764. @item ~
  13765. Bitwise complement operator. Defined on integral types. Same precedence as
  13766. @code{++}.
  13767. @item .@r{, }->
  13768. Structure member, and pointer-to-structure member. For convenience,
  13769. @value{GDBN} regards the two as equivalent, choosing whether to dereference a
  13770. pointer based on the stored type information.
  13771. Defined on @code{struct} and @code{union} data.
  13772. @item .*@r{, }->*
  13773. Dereferences of pointers to members.
  13774. @item []
  13775. Array indexing. @code{@var{a}[@var{i}]} is defined as
  13776. @code{*(@var{a}+@var{i})}. Same precedence as @code{->}.
  13777. @item ()
  13778. Function parameter list. Same precedence as @code{->}.
  13779. @item ::
  13780. C@t{++} scope resolution operator. Defined on @code{struct}, @code{union},
  13781. and @code{class} types.
  13782. @item ::
  13783. Doubled colons also represent the @value{GDBN} scope operator
  13784. (@pxref{Expressions, ,Expressions}). Same precedence as @code{::},
  13785. above.
  13786. @end table
  13787. If an operator is redefined in the user code, @value{GDBN} usually
  13788. attempts to invoke the redefined version instead of using the operator's
  13789. predefined meaning.
  13790. @node C Constants
  13791. @subsubsection C and C@t{++} Constants
  13792. @cindex C and C@t{++} constants
  13793. @value{GDBN} allows you to express the constants of C and C@t{++} in the
  13794. following ways:
  13795. @itemize @bullet
  13796. @item
  13797. Integer constants are a sequence of digits. Octal constants are
  13798. specified by a leading @samp{0} (i.e.@: zero), and hexadecimal constants
  13799. by a leading @samp{0x} or @samp{0X}. Constants may also end with a letter
  13800. @samp{l}, specifying that the constant should be treated as a
  13801. @code{long} value.
  13802. @item
  13803. Floating point constants are a sequence of digits, followed by a decimal
  13804. point, followed by a sequence of digits, and optionally followed by an
  13805. exponent. An exponent is of the form:
  13806. @samp{@w{e@r{[[}+@r{]|}-@r{]}@var{nnn}}}, where @var{nnn} is another
  13807. sequence of digits. The @samp{+} is optional for positive exponents.
  13808. A floating-point constant may also end with a letter @samp{f} or
  13809. @samp{F}, specifying that the constant should be treated as being of
  13810. the @code{float} (as opposed to the default @code{double}) type; or with
  13811. a letter @samp{l} or @samp{L}, which specifies a @code{long double}
  13812. constant.
  13813. @item
  13814. Enumerated constants consist of enumerated identifiers, or their
  13815. integral equivalents.
  13816. @item
  13817. Character constants are a single character surrounded by single quotes
  13818. (@code{'}), or a number---the ordinal value of the corresponding character
  13819. (usually its @sc{ascii} value). Within quotes, the single character may
  13820. be represented by a letter or by @dfn{escape sequences}, which are of
  13821. the form @samp{\@var{nnn}}, where @var{nnn} is the octal representation
  13822. of the character's ordinal value; or of the form @samp{\@var{x}}, where
  13823. @samp{@var{x}} is a predefined special character---for example,
  13824. @samp{\n} for newline.
  13825. Wide character constants can be written by prefixing a character
  13826. constant with @samp{L}, as in C. For example, @samp{L'x'} is the wide
  13827. form of @samp{x}. The target wide character set is used when
  13828. computing the value of this constant (@pxref{Character Sets}).
  13829. @item
  13830. String constants are a sequence of character constants surrounded by
  13831. double quotes (@code{"}). Any valid character constant (as described
  13832. above) may appear. Double quotes within the string must be preceded by
  13833. a backslash, so for instance @samp{"a\"b'c"} is a string of five
  13834. characters.
  13835. Wide string constants can be written by prefixing a string constant
  13836. with @samp{L}, as in C. The target wide character set is used when
  13837. computing the value of this constant (@pxref{Character Sets}).
  13838. @item
  13839. Pointer constants are an integral value. You can also write pointers
  13840. to constants using the C operator @samp{&}.
  13841. @item
  13842. Array constants are comma-separated lists surrounded by braces @samp{@{}
  13843. and @samp{@}}; for example, @samp{@{1,2,3@}} is a three-element array of
  13844. integers, @samp{@{@{1,2@}, @{3,4@}, @{5,6@}@}} is a three-by-two array,
  13845. and @samp{@{&"hi", &"there", &"fred"@}} is a three-element array of pointers.
  13846. @end itemize
  13847. @node C Plus Plus Expressions
  13848. @subsubsection C@t{++} Expressions
  13849. @cindex expressions in C@t{++}
  13850. @value{GDBN} expression handling can interpret most C@t{++} expressions.
  13851. @cindex debugging C@t{++} programs
  13852. @cindex C@t{++} compilers
  13853. @cindex debug formats and C@t{++}
  13854. @cindex @value{NGCC} and C@t{++}
  13855. @quotation
  13856. @emph{Warning:} @value{GDBN} can only debug C@t{++} code if you use
  13857. the proper compiler and the proper debug format. Currently,
  13858. @value{GDBN} works best when debugging C@t{++} code that is compiled
  13859. with the most recent version of @value{NGCC} possible. The DWARF
  13860. debugging format is preferred; @value{NGCC} defaults to this on most
  13861. popular platforms. Other compilers and/or debug formats are likely to
  13862. work badly or not at all when using @value{GDBN} to debug C@t{++}
  13863. code. @xref{Compilation}.
  13864. @end quotation
  13865. @enumerate
  13866. @cindex member functions
  13867. @item
  13868. Member function calls are allowed; you can use expressions like
  13869. @smallexample
  13870. count = aml->GetOriginal(x, y)
  13871. @end smallexample
  13872. @vindex this@r{, inside C@t{++} member functions}
  13873. @cindex namespace in C@t{++}
  13874. @item
  13875. While a member function is active (in the selected stack frame), your
  13876. expressions have the same namespace available as the member function;
  13877. that is, @value{GDBN} allows implicit references to the class instance
  13878. pointer @code{this} following the same rules as C@t{++}. @code{using}
  13879. declarations in the current scope are also respected by @value{GDBN}.
  13880. @cindex call overloaded functions
  13881. @cindex overloaded functions, calling
  13882. @cindex type conversions in C@t{++}
  13883. @item
  13884. You can call overloaded functions; @value{GDBN} resolves the function
  13885. call to the right definition, with some restrictions. @value{GDBN} does not
  13886. perform overload resolution involving user-defined type conversions,
  13887. calls to constructors, or instantiations of templates that do not exist
  13888. in the program. It also cannot handle ellipsis argument lists or
  13889. default arguments.
  13890. It does perform integral conversions and promotions, floating-point
  13891. promotions, arithmetic conversions, pointer conversions, conversions of
  13892. class objects to base classes, and standard conversions such as those of
  13893. functions or arrays to pointers; it requires an exact match on the
  13894. number of function arguments.
  13895. Overload resolution is always performed, unless you have specified
  13896. @code{set overload-resolution off}. @xref{Debugging C Plus Plus,
  13897. ,@value{GDBN} Features for C@t{++}}.
  13898. You must specify @code{set overload-resolution off} in order to use an
  13899. explicit function signature to call an overloaded function, as in
  13900. @smallexample
  13901. p 'foo(char,int)'('x', 13)
  13902. @end smallexample
  13903. The @value{GDBN} command-completion facility can simplify this;
  13904. see @ref{Completion, ,Command Completion}.
  13905. @cindex reference declarations
  13906. @item
  13907. @value{GDBN} understands variables declared as C@t{++} lvalue or rvalue
  13908. references; you can use them in expressions just as you do in C@t{++}
  13909. source---they are automatically dereferenced.
  13910. In the parameter list shown when @value{GDBN} displays a frame, the values of
  13911. reference variables are not displayed (unlike other variables); this
  13912. avoids clutter, since references are often used for large structures.
  13913. The @emph{address} of a reference variable is always shown, unless
  13914. you have specified @samp{set print address off}.
  13915. @item
  13916. @value{GDBN} supports the C@t{++} name resolution operator @code{::}---your
  13917. expressions can use it just as expressions in your program do. Since
  13918. one scope may be defined in another, you can use @code{::} repeatedly if
  13919. necessary, for example in an expression like
  13920. @samp{@var{scope1}::@var{scope2}::@var{name}}. @value{GDBN} also allows
  13921. resolving name scope by reference to source files, in both C and C@t{++}
  13922. debugging (@pxref{Variables, ,Program Variables}).
  13923. @item
  13924. @value{GDBN} performs argument-dependent lookup, following the C@t{++}
  13925. specification.
  13926. @end enumerate
  13927. @node C Defaults
  13928. @subsubsection C and C@t{++} Defaults
  13929. @cindex C and C@t{++} defaults
  13930. If you allow @value{GDBN} to set range checking automatically, it
  13931. defaults to @code{off} whenever the working language changes to
  13932. C or C@t{++}. This happens regardless of whether you or @value{GDBN}
  13933. selects the working language.
  13934. If you allow @value{GDBN} to set the language automatically, it
  13935. recognizes source files whose names end with @file{.c}, @file{.C}, or
  13936. @file{.cc}, etc, and when @value{GDBN} enters code compiled from one of
  13937. these files, it sets the working language to C or C@t{++}.
  13938. @xref{Automatically, ,Having @value{GDBN} Infer the Source Language},
  13939. for further details.
  13940. @node C Checks
  13941. @subsubsection C and C@t{++} Type and Range Checks
  13942. @cindex C and C@t{++} checks
  13943. By default, when @value{GDBN} parses C or C@t{++} expressions, strict type
  13944. checking is used. However, if you turn type checking off, @value{GDBN}
  13945. will allow certain non-standard conversions, such as promoting integer
  13946. constants to pointers.
  13947. Range checking, if turned on, is done on mathematical operations. Array
  13948. indices are not checked, since they are often used to index a pointer
  13949. that is not itself an array.
  13950. @node Debugging C
  13951. @subsubsection @value{GDBN} and C
  13952. The @code{set print union} and @code{show print union} commands apply to
  13953. the @code{union} type. When set to @samp{on}, any @code{union} that is
  13954. inside a @code{struct} or @code{class} is also printed. Otherwise, it
  13955. appears as @samp{@{...@}}.
  13956. The @code{@@} operator aids in the debugging of dynamic arrays, formed
  13957. with pointers and a memory allocation function. @xref{Expressions,
  13958. ,Expressions}.
  13959. @node Debugging C Plus Plus
  13960. @subsubsection @value{GDBN} Features for C@t{++}
  13961. @cindex commands for C@t{++}
  13962. Some @value{GDBN} commands are particularly useful with C@t{++}, and some are
  13963. designed specifically for use with C@t{++}. Here is a summary:
  13964. @table @code
  13965. @cindex break in overloaded functions
  13966. @item @r{breakpoint menus}
  13967. When you want a breakpoint in a function whose name is overloaded,
  13968. @value{GDBN} has the capability to display a menu of possible breakpoint
  13969. locations to help you specify which function definition you want.
  13970. @xref{Ambiguous Expressions,,Ambiguous Expressions}.
  13971. @cindex overloading in C@t{++}
  13972. @item rbreak @var{regex}
  13973. Setting breakpoints using regular expressions is helpful for setting
  13974. breakpoints on overloaded functions that are not members of any special
  13975. classes.
  13976. @xref{Set Breaks, ,Setting Breakpoints}.
  13977. @cindex C@t{++} exception handling
  13978. @item catch throw
  13979. @itemx catch rethrow
  13980. @itemx catch catch
  13981. Debug C@t{++} exception handling using these commands. @xref{Set
  13982. Catchpoints, , Setting Catchpoints}.
  13983. @cindex inheritance
  13984. @item ptype @var{typename}
  13985. Print inheritance relationships as well as other information for type
  13986. @var{typename}.
  13987. @xref{Symbols, ,Examining the Symbol Table}.
  13988. @item info vtbl @var{expression}.
  13989. The @code{info vtbl} command can be used to display the virtual
  13990. method tables of the object computed by @var{expression}. This shows
  13991. one entry per virtual table; there may be multiple virtual tables when
  13992. multiple inheritance is in use.
  13993. @cindex C@t{++} demangling
  13994. @item demangle @var{name}
  13995. Demangle @var{name}.
  13996. @xref{Symbols}, for a more complete description of the @code{demangle} command.
  13997. @cindex C@t{++} symbol display
  13998. @item set print demangle
  13999. @itemx show print demangle
  14000. @itemx set print asm-demangle
  14001. @itemx show print asm-demangle
  14002. Control whether C@t{++} symbols display in their source form, both when
  14003. displaying code as C@t{++} source and when displaying disassemblies.
  14004. @xref{Print Settings, ,Print Settings}.
  14005. @item set print object
  14006. @itemx show print object
  14007. Choose whether to print derived (actual) or declared types of objects.
  14008. @xref{Print Settings, ,Print Settings}.
  14009. @item set print vtbl
  14010. @itemx show print vtbl
  14011. Control the format for printing virtual function tables.
  14012. @xref{Print Settings, ,Print Settings}.
  14013. (The @code{vtbl} commands do not work on programs compiled with the HP
  14014. ANSI C@t{++} compiler (@code{aCC}).)
  14015. @kindex set overload-resolution
  14016. @cindex overloaded functions, overload resolution
  14017. @item set overload-resolution on
  14018. Enable overload resolution for C@t{++} expression evaluation. The default
  14019. is on. For overloaded functions, @value{GDBN} evaluates the arguments
  14020. and searches for a function whose signature matches the argument types,
  14021. using the standard C@t{++} conversion rules (see @ref{C Plus Plus
  14022. Expressions, ,C@t{++} Expressions}, for details).
  14023. If it cannot find a match, it emits a message.
  14024. @item set overload-resolution off
  14025. Disable overload resolution for C@t{++} expression evaluation. For
  14026. overloaded functions that are not class member functions, @value{GDBN}
  14027. chooses the first function of the specified name that it finds in the
  14028. symbol table, whether or not its arguments are of the correct type. For
  14029. overloaded functions that are class member functions, @value{GDBN}
  14030. searches for a function whose signature @emph{exactly} matches the
  14031. argument types.
  14032. @kindex show overload-resolution
  14033. @item show overload-resolution
  14034. Show the current setting of overload resolution.
  14035. @item @r{Overloaded symbol names}
  14036. You can specify a particular definition of an overloaded symbol, using
  14037. the same notation that is used to declare such symbols in C@t{++}: type
  14038. @code{@var{symbol}(@var{types})} rather than just @var{symbol}. You can
  14039. also use the @value{GDBN} command-line word completion facilities to list the
  14040. available choices, or to finish the type list for you.
  14041. @xref{Completion,, Command Completion}, for details on how to do this.
  14042. @item @r{Breakpoints in template functions}
  14043. Similar to how overloaded symbols are handled, @value{GDBN} will ignore
  14044. template parameter lists when it encounters a symbol which includes a
  14045. C@t{++} template. This permits setting breakpoints on families of template functions
  14046. or functions whose parameters include template types.
  14047. The @kbd{-qualified} flag may be used to override this behavior, causing
  14048. @value{GDBN} to search for a specific function or type.
  14049. The @value{GDBN} command-line word completion facility also understands
  14050. template parameters and may be used to list available choices or finish
  14051. template parameter lists for you. @xref{Completion,, Command Completion}, for
  14052. details on how to do this.
  14053. @item @r{Breakpoints in functions with ABI tags}
  14054. The GNU C@t{++} compiler introduced the notion of ABI ``tags'', which
  14055. correspond to changes in the ABI of a type, function, or variable that
  14056. would not otherwise be reflected in a mangled name. See
  14057. @url{https://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/}
  14058. for more detail.
  14059. The ABI tags are visible in C@t{++} demangled names. For example, a
  14060. function that returns a std::string:
  14061. @smallexample
  14062. std::string function(int);
  14063. @end smallexample
  14064. @noindent
  14065. when compiled for the C++11 ABI is marked with the @code{cxx11} ABI
  14066. tag, and @value{GDBN} displays the symbol like this:
  14067. @smallexample
  14068. function[abi:cxx11](int)
  14069. @end smallexample
  14070. You can set a breakpoint on such functions simply as if they had no
  14071. tag. For example:
  14072. @smallexample
  14073. (gdb) b function(int)
  14074. Breakpoint 2 at 0x40060d: file main.cc, line 10.
  14075. (gdb) info breakpoints
  14076. Num Type Disp Enb Address What
  14077. 1 breakpoint keep y 0x0040060d in function[abi:cxx11](int)
  14078. at main.cc:10
  14079. @end smallexample
  14080. On the rare occasion you need to disambiguate between different ABI
  14081. tags, you can do so by simply including the ABI tag in the function
  14082. name, like:
  14083. @smallexample
  14084. (@value{GDBP}) b ambiguous[abi:other_tag](int)
  14085. @end smallexample
  14086. @end table
  14087. @node Decimal Floating Point
  14088. @subsubsection Decimal Floating Point format
  14089. @cindex decimal floating point format
  14090. @value{GDBN} can examine, set and perform computations with numbers in
  14091. decimal floating point format, which in the C language correspond to the
  14092. @code{_Decimal32}, @code{_Decimal64} and @code{_Decimal128} types as
  14093. specified by the extension to support decimal floating-point arithmetic.
  14094. There are two encodings in use, depending on the architecture: BID (Binary
  14095. Integer Decimal) for x86 and x86-64, and DPD (Densely Packed Decimal) for
  14096. PowerPC and S/390. @value{GDBN} will use the appropriate encoding for the
  14097. configured target.
  14098. Because of a limitation in @file{libdecnumber}, the library used by @value{GDBN}
  14099. to manipulate decimal floating point numbers, it is not possible to convert
  14100. (using a cast, for example) integers wider than 32-bit to decimal float.
  14101. In addition, in order to imitate @value{GDBN}'s behaviour with binary floating
  14102. point computations, error checking in decimal float operations ignores
  14103. underflow, overflow and divide by zero exceptions.
  14104. In the PowerPC architecture, @value{GDBN} provides a set of pseudo-registers
  14105. to inspect @code{_Decimal128} values stored in floating point registers.
  14106. See @ref{PowerPC,,PowerPC} for more details.
  14107. @node D
  14108. @subsection D
  14109. @cindex D
  14110. @value{GDBN} can be used to debug programs written in D and compiled with
  14111. GDC, LDC or DMD compilers. Currently @value{GDBN} supports only one D
  14112. specific feature --- dynamic arrays.
  14113. @node Go
  14114. @subsection Go
  14115. @cindex Go (programming language)
  14116. @value{GDBN} can be used to debug programs written in Go and compiled with
  14117. @file{gccgo} or @file{6g} compilers.
  14118. Here is a summary of the Go-specific features and restrictions:
  14119. @table @code
  14120. @cindex current Go package
  14121. @item The current Go package
  14122. The name of the current package does not need to be specified when
  14123. specifying global variables and functions.
  14124. For example, given the program:
  14125. @example
  14126. package main
  14127. var myglob = "Shall we?"
  14128. func main () @{
  14129. // ...
  14130. @}
  14131. @end example
  14132. When stopped inside @code{main} either of these work:
  14133. @example
  14134. (gdb) p myglob
  14135. (gdb) p main.myglob
  14136. @end example
  14137. @cindex builtin Go types
  14138. @item Builtin Go types
  14139. The @code{string} type is recognized by @value{GDBN} and is printed
  14140. as a string.
  14141. @cindex builtin Go functions
  14142. @item Builtin Go functions
  14143. The @value{GDBN} expression parser recognizes the @code{unsafe.Sizeof}
  14144. function and handles it internally.
  14145. @cindex restrictions on Go expressions
  14146. @item Restrictions on Go expressions
  14147. All Go operators are supported except @code{&^}.
  14148. The Go @code{_} ``blank identifier'' is not supported.
  14149. Automatic dereferencing of pointers is not supported.
  14150. @end table
  14151. @node Objective-C
  14152. @subsection Objective-C
  14153. @cindex Objective-C
  14154. This section provides information about some commands and command
  14155. options that are useful for debugging Objective-C code. See also
  14156. @ref{Symbols, info classes}, and @ref{Symbols, info selectors}, for a
  14157. few more commands specific to Objective-C support.
  14158. @menu
  14159. * Method Names in Commands::
  14160. * The Print Command with Objective-C::
  14161. @end menu
  14162. @node Method Names in Commands
  14163. @subsubsection Method Names in Commands
  14164. The following commands have been extended to accept Objective-C method
  14165. names as line specifications:
  14166. @kindex clear@r{, and Objective-C}
  14167. @kindex break@r{, and Objective-C}
  14168. @kindex info line@r{, and Objective-C}
  14169. @kindex jump@r{, and Objective-C}
  14170. @kindex list@r{, and Objective-C}
  14171. @itemize
  14172. @item @code{clear}
  14173. @item @code{break}
  14174. @item @code{info line}
  14175. @item @code{jump}
  14176. @item @code{list}
  14177. @end itemize
  14178. A fully qualified Objective-C method name is specified as
  14179. @smallexample
  14180. -[@var{Class} @var{methodName}]
  14181. @end smallexample
  14182. where the minus sign is used to indicate an instance method and a
  14183. plus sign (not shown) is used to indicate a class method. The class
  14184. name @var{Class} and method name @var{methodName} are enclosed in
  14185. brackets, similar to the way messages are specified in Objective-C
  14186. source code. For example, to set a breakpoint at the @code{create}
  14187. instance method of class @code{Fruit} in the program currently being
  14188. debugged, enter:
  14189. @smallexample
  14190. break -[Fruit create]
  14191. @end smallexample
  14192. To list ten program lines around the @code{initialize} class method,
  14193. enter:
  14194. @smallexample
  14195. list +[NSText initialize]
  14196. @end smallexample
  14197. In the current version of @value{GDBN}, the plus or minus sign is
  14198. required. In future versions of @value{GDBN}, the plus or minus
  14199. sign will be optional, but you can use it to narrow the search. It
  14200. is also possible to specify just a method name:
  14201. @smallexample
  14202. break create
  14203. @end smallexample
  14204. You must specify the complete method name, including any colons. If
  14205. your program's source files contain more than one @code{create} method,
  14206. you'll be presented with a numbered list of classes that implement that
  14207. method. Indicate your choice by number, or type @samp{0} to exit if
  14208. none apply.
  14209. As another example, to clear a breakpoint established at the
  14210. @code{makeKeyAndOrderFront:} method of the @code{NSWindow} class, enter:
  14211. @smallexample
  14212. clear -[NSWindow makeKeyAndOrderFront:]
  14213. @end smallexample
  14214. @node The Print Command with Objective-C
  14215. @subsubsection The Print Command With Objective-C
  14216. @cindex Objective-C, print objects
  14217. @kindex print-object
  14218. @kindex po @r{(@code{print-object})}
  14219. The print command has also been extended to accept methods. For example:
  14220. @smallexample
  14221. print -[@var{object} hash]
  14222. @end smallexample
  14223. @cindex print an Objective-C object description
  14224. @cindex @code{_NSPrintForDebugger}, and printing Objective-C objects
  14225. @noindent
  14226. will tell @value{GDBN} to send the @code{hash} message to @var{object}
  14227. and print the result. Also, an additional command has been added,
  14228. @code{print-object} or @code{po} for short, which is meant to print
  14229. the description of an object. However, this command may only work
  14230. with certain Objective-C libraries that have a particular hook
  14231. function, @code{_NSPrintForDebugger}, defined.
  14232. @node OpenCL C
  14233. @subsection OpenCL C
  14234. @cindex OpenCL C
  14235. This section provides information about @value{GDBN}s OpenCL C support.
  14236. @menu
  14237. * OpenCL C Datatypes::
  14238. * OpenCL C Expressions::
  14239. * OpenCL C Operators::
  14240. @end menu
  14241. @node OpenCL C Datatypes
  14242. @subsubsection OpenCL C Datatypes
  14243. @cindex OpenCL C Datatypes
  14244. @value{GDBN} supports the builtin scalar and vector datatypes specified
  14245. by OpenCL 1.1. In addition the half- and double-precision floating point
  14246. data types of the @code{cl_khr_fp16} and @code{cl_khr_fp64} OpenCL
  14247. extensions are also known to @value{GDBN}.
  14248. @node OpenCL C Expressions
  14249. @subsubsection OpenCL C Expressions
  14250. @cindex OpenCL C Expressions
  14251. @value{GDBN} supports accesses to vector components including the access as
  14252. lvalue where possible. Since OpenCL C is based on C99 most C expressions
  14253. supported by @value{GDBN} can be used as well.
  14254. @node OpenCL C Operators
  14255. @subsubsection OpenCL C Operators
  14256. @cindex OpenCL C Operators
  14257. @value{GDBN} supports the operators specified by OpenCL 1.1 for scalar and
  14258. vector data types.
  14259. @node Fortran
  14260. @subsection Fortran
  14261. @cindex Fortran-specific support in @value{GDBN}
  14262. @value{GDBN} can be used to debug programs written in Fortran, but it
  14263. currently supports only the features of Fortran 77 language.
  14264. @cindex trailing underscore, in Fortran symbols
  14265. Some Fortran compilers (@sc{gnu} Fortran 77 and Fortran 95 compilers
  14266. among them) append an underscore to the names of variables and
  14267. functions. When you debug programs compiled by those compilers, you
  14268. will need to refer to variables and functions with a trailing
  14269. underscore.
  14270. @menu
  14271. * Fortran Operators:: Fortran operators and expressions
  14272. * Fortran Defaults:: Default settings for Fortran
  14273. * Special Fortran Commands:: Special @value{GDBN} commands for Fortran
  14274. @end menu
  14275. @node Fortran Operators
  14276. @subsubsection Fortran Operators and Expressions
  14277. @cindex Fortran operators and expressions
  14278. Operators must be defined on values of specific types. For instance,
  14279. @code{+} is defined on numbers, but not on characters or other non-
  14280. arithmetic types. Operators are often defined on groups of types.
  14281. @table @code
  14282. @item **
  14283. The exponentiation operator. It raises the first operand to the power
  14284. of the second one.
  14285. @item :
  14286. The range operator. Normally used in the form of array(low:high) to
  14287. represent a section of array.
  14288. @item %
  14289. The access component operator. Normally used to access elements in derived
  14290. types. Also suitable for unions. As unions aren't part of regular Fortran,
  14291. this can only happen when accessing a register that uses a gdbarch-defined
  14292. union type.
  14293. @item ::
  14294. The scope operator. Normally used to access variables in modules or
  14295. to set breakpoints on subroutines nested in modules or in other
  14296. subroutines (internal subroutines).
  14297. @end table
  14298. @node Fortran Defaults
  14299. @subsubsection Fortran Defaults
  14300. @cindex Fortran Defaults
  14301. Fortran symbols are usually case-insensitive, so @value{GDBN} by
  14302. default uses case-insensitive matches for Fortran symbols. You can
  14303. change that with the @samp{set case-insensitive} command, see
  14304. @ref{Symbols}, for the details.
  14305. @node Special Fortran Commands
  14306. @subsubsection Special Fortran Commands
  14307. @cindex Special Fortran commands
  14308. @value{GDBN} has some commands to support Fortran-specific features,
  14309. such as displaying common blocks.
  14310. @table @code
  14311. @cindex @code{COMMON} blocks, Fortran
  14312. @kindex info common
  14313. @item info common @r{[}@var{common-name}@r{]}
  14314. This command prints the values contained in the Fortran @code{COMMON}
  14315. block whose name is @var{common-name}. With no argument, the names of
  14316. all @code{COMMON} blocks visible at the current program location are
  14317. printed.
  14318. @cindex arrays slices (Fortran)
  14319. @kindex set fortran repack-array-slices
  14320. @kindex show fortran repack-array-slices
  14321. @item set fortran repack-array-slices [on|off]
  14322. @item show fortran repack-array-slices
  14323. When taking a slice from an array, a Fortran compiler can choose to
  14324. either produce an array descriptor that describes the slice in place,
  14325. or it may repack the slice, copying the elements of the slice into a
  14326. new region of memory.
  14327. When this setting is on, then @value{GDBN} will also repack array
  14328. slices in some situations. When this setting is off, then
  14329. @value{GDBN} will create array descriptors for slices that reference
  14330. the original data in place.
  14331. @value{GDBN} will never repack an array slice if the data for the
  14332. slice is contiguous within the original array.
  14333. @value{GDBN} will always repack string slices if the data for the
  14334. slice is non-contiguous within the original string as @value{GDBN}
  14335. does not support printing non-contiguous strings.
  14336. The default for this setting is @code{off}.
  14337. @end table
  14338. @node Pascal
  14339. @subsection Pascal
  14340. @cindex Pascal support in @value{GDBN}, limitations
  14341. Debugging Pascal programs which use sets, subranges, file variables, or
  14342. nested functions does not currently work. @value{GDBN} does not support
  14343. entering expressions, printing values, or similar features using Pascal
  14344. syntax.
  14345. The Pascal-specific command @code{set print pascal_static-members}
  14346. controls whether static members of Pascal objects are displayed.
  14347. @xref{Print Settings, pascal_static-members}.
  14348. @node Rust
  14349. @subsection Rust
  14350. @value{GDBN} supports the @url{https://www.rust-lang.org/, Rust
  14351. Programming Language}. Type- and value-printing, and expression
  14352. parsing, are reasonably complete. However, there are a few
  14353. peculiarities and holes to be aware of.
  14354. @itemize @bullet
  14355. @item
  14356. Linespecs (@pxref{Specify Location}) are never relative to the current
  14357. crate. Instead, they act as if there were a global namespace of
  14358. crates, somewhat similar to the way @code{extern crate} behaves.
  14359. That is, if @value{GDBN} is stopped at a breakpoint in a function in
  14360. crate @samp{A}, module @samp{B}, then @code{break B::f} will attempt
  14361. to set a breakpoint in a function named @samp{f} in a crate named
  14362. @samp{B}.
  14363. As a consequence of this approach, linespecs also cannot refer to
  14364. items using @samp{self::} or @samp{super::}.
  14365. @item
  14366. Because @value{GDBN} implements Rust name-lookup semantics in
  14367. expressions, it will sometimes prepend the current crate to a name.
  14368. For example, if @value{GDBN} is stopped at a breakpoint in the crate
  14369. @samp{K}, then @code{print ::x::y} will try to find the symbol
  14370. @samp{K::x::y}.
  14371. However, since it is useful to be able to refer to other crates when
  14372. debugging, @value{GDBN} provides the @code{extern} extension to
  14373. circumvent this. To use the extension, just put @code{extern} before
  14374. a path expression to refer to the otherwise unavailable ``global''
  14375. scope.
  14376. In the above example, if you wanted to refer to the symbol @samp{y} in
  14377. the crate @samp{x}, you would use @code{print extern x::y}.
  14378. @item
  14379. The Rust expression evaluator does not support ``statement-like''
  14380. expressions such as @code{if} or @code{match}, or lambda expressions.
  14381. @item
  14382. Tuple expressions are not implemented.
  14383. @item
  14384. The Rust expression evaluator does not currently implement the
  14385. @code{Drop} trait. Objects that may be created by the evaluator will
  14386. never be destroyed.
  14387. @item
  14388. @value{GDBN} does not implement type inference for generics. In order
  14389. to call generic functions or otherwise refer to generic items, you
  14390. will have to specify the type parameters manually.
  14391. @item
  14392. @value{GDBN} currently uses the C@t{++} demangler for Rust. In most
  14393. cases this does not cause any problems. However, in an expression
  14394. context, completing a generic function name will give syntactically
  14395. invalid results. This happens because Rust requires the @samp{::}
  14396. operator between the function name and its generic arguments. For
  14397. example, @value{GDBN} might provide a completion like
  14398. @code{crate::f<u32>}, where the parser would require
  14399. @code{crate::f::<u32>}.
  14400. @item
  14401. As of this writing, the Rust compiler (version 1.8) has a few holes in
  14402. the debugging information it generates. These holes prevent certain
  14403. features from being implemented by @value{GDBN}:
  14404. @itemize @bullet
  14405. @item
  14406. Method calls cannot be made via traits.
  14407. @item
  14408. Operator overloading is not implemented.
  14409. @item
  14410. When debugging in a monomorphized function, you cannot use the generic
  14411. type names.
  14412. @item
  14413. The type @code{Self} is not available.
  14414. @item
  14415. @code{use} statements are not available, so some names may not be
  14416. available in the crate.
  14417. @end itemize
  14418. @end itemize
  14419. @node Modula-2
  14420. @subsection Modula-2
  14421. @cindex Modula-2, @value{GDBN} support
  14422. The extensions made to @value{GDBN} to support Modula-2 only support
  14423. output from the @sc{gnu} Modula-2 compiler (which is currently being
  14424. developed). Other Modula-2 compilers are not currently supported, and
  14425. attempting to debug executables produced by them is most likely
  14426. to give an error as @value{GDBN} reads in the executable's symbol
  14427. table.
  14428. @cindex expressions in Modula-2
  14429. @menu
  14430. * M2 Operators:: Built-in operators
  14431. * Built-In Func/Proc:: Built-in functions and procedures
  14432. * M2 Constants:: Modula-2 constants
  14433. * M2 Types:: Modula-2 types
  14434. * M2 Defaults:: Default settings for Modula-2
  14435. * Deviations:: Deviations from standard Modula-2
  14436. * M2 Checks:: Modula-2 type and range checks
  14437. * M2 Scope:: The scope operators @code{::} and @code{.}
  14438. * GDB/M2:: @value{GDBN} and Modula-2
  14439. @end menu
  14440. @node M2 Operators
  14441. @subsubsection Operators
  14442. @cindex Modula-2 operators
  14443. Operators must be defined on values of specific types. For instance,
  14444. @code{+} is defined on numbers, but not on structures. Operators are
  14445. often defined on groups of types. For the purposes of Modula-2, the
  14446. following definitions hold:
  14447. @itemize @bullet
  14448. @item
  14449. @emph{Integral types} consist of @code{INTEGER}, @code{CARDINAL}, and
  14450. their subranges.
  14451. @item
  14452. @emph{Character types} consist of @code{CHAR} and its subranges.
  14453. @item
  14454. @emph{Floating-point types} consist of @code{REAL}.
  14455. @item
  14456. @emph{Pointer types} consist of anything declared as @code{POINTER TO
  14457. @var{type}}.
  14458. @item
  14459. @emph{Scalar types} consist of all of the above.
  14460. @item
  14461. @emph{Set types} consist of @code{SET} and @code{BITSET} types.
  14462. @item
  14463. @emph{Boolean types} consist of @code{BOOLEAN}.
  14464. @end itemize
  14465. @noindent
  14466. The following operators are supported, and appear in order of
  14467. increasing precedence:
  14468. @table @code
  14469. @item ,
  14470. Function argument or array index separator.
  14471. @item :=
  14472. Assignment. The value of @var{var} @code{:=} @var{value} is
  14473. @var{value}.
  14474. @item <@r{, }>
  14475. Less than, greater than on integral, floating-point, or enumerated
  14476. types.
  14477. @item <=@r{, }>=
  14478. Less than or equal to, greater than or equal to
  14479. on integral, floating-point and enumerated types, or set inclusion on
  14480. set types. Same precedence as @code{<}.
  14481. @item =@r{, }<>@r{, }#
  14482. Equality and two ways of expressing inequality, valid on scalar types.
  14483. Same precedence as @code{<}. In @value{GDBN} scripts, only @code{<>} is
  14484. available for inequality, since @code{#} conflicts with the script
  14485. comment character.
  14486. @item IN
  14487. Set membership. Defined on set types and the types of their members.
  14488. Same precedence as @code{<}.
  14489. @item OR
  14490. Boolean disjunction. Defined on boolean types.
  14491. @item AND@r{, }&
  14492. Boolean conjunction. Defined on boolean types.
  14493. @item @@
  14494. The @value{GDBN} ``artificial array'' operator (@pxref{Expressions, ,Expressions}).
  14495. @item +@r{, }-
  14496. Addition and subtraction on integral and floating-point types, or union
  14497. and difference on set types.
  14498. @item *
  14499. Multiplication on integral and floating-point types, or set intersection
  14500. on set types.
  14501. @item /
  14502. Division on floating-point types, or symmetric set difference on set
  14503. types. Same precedence as @code{*}.
  14504. @item DIV@r{, }MOD
  14505. Integer division and remainder. Defined on integral types. Same
  14506. precedence as @code{*}.
  14507. @item -
  14508. Negative. Defined on @code{INTEGER} and @code{REAL} data.
  14509. @item ^
  14510. Pointer dereferencing. Defined on pointer types.
  14511. @item NOT
  14512. Boolean negation. Defined on boolean types. Same precedence as
  14513. @code{^}.
  14514. @item .
  14515. @code{RECORD} field selector. Defined on @code{RECORD} data. Same
  14516. precedence as @code{^}.
  14517. @item []
  14518. Array indexing. Defined on @code{ARRAY} data. Same precedence as @code{^}.
  14519. @item ()
  14520. Procedure argument list. Defined on @code{PROCEDURE} objects. Same precedence
  14521. as @code{^}.
  14522. @item ::@r{, }.
  14523. @value{GDBN} and Modula-2 scope operators.
  14524. @end table
  14525. @quotation
  14526. @emph{Warning:} Set expressions and their operations are not yet supported, so @value{GDBN}
  14527. treats the use of the operator @code{IN}, or the use of operators
  14528. @code{+}, @code{-}, @code{*}, @code{/}, @code{=}, , @code{<>}, @code{#},
  14529. @code{<=}, and @code{>=} on sets as an error.
  14530. @end quotation
  14531. @node Built-In Func/Proc
  14532. @subsubsection Built-in Functions and Procedures
  14533. @cindex Modula-2 built-ins
  14534. Modula-2 also makes available several built-in procedures and functions.
  14535. In describing these, the following metavariables are used:
  14536. @table @var
  14537. @item a
  14538. represents an @code{ARRAY} variable.
  14539. @item c
  14540. represents a @code{CHAR} constant or variable.
  14541. @item i
  14542. represents a variable or constant of integral type.
  14543. @item m
  14544. represents an identifier that belongs to a set. Generally used in the
  14545. same function with the metavariable @var{s}. The type of @var{s} should
  14546. be @code{SET OF @var{mtype}} (where @var{mtype} is the type of @var{m}).
  14547. @item n
  14548. represents a variable or constant of integral or floating-point type.
  14549. @item r
  14550. represents a variable or constant of floating-point type.
  14551. @item t
  14552. represents a type.
  14553. @item v
  14554. represents a variable.
  14555. @item x
  14556. represents a variable or constant of one of many types. See the
  14557. explanation of the function for details.
  14558. @end table
  14559. All Modula-2 built-in procedures also return a result, described below.
  14560. @table @code
  14561. @item ABS(@var{n})
  14562. Returns the absolute value of @var{n}.
  14563. @item CAP(@var{c})
  14564. If @var{c} is a lower case letter, it returns its upper case
  14565. equivalent, otherwise it returns its argument.
  14566. @item CHR(@var{i})
  14567. Returns the character whose ordinal value is @var{i}.
  14568. @item DEC(@var{v})
  14569. Decrements the value in the variable @var{v} by one. Returns the new value.
  14570. @item DEC(@var{v},@var{i})
  14571. Decrements the value in the variable @var{v} by @var{i}. Returns the
  14572. new value.
  14573. @item EXCL(@var{m},@var{s})
  14574. Removes the element @var{m} from the set @var{s}. Returns the new
  14575. set.
  14576. @item FLOAT(@var{i})
  14577. Returns the floating point equivalent of the integer @var{i}.
  14578. @item HIGH(@var{a})
  14579. Returns the index of the last member of @var{a}.
  14580. @item INC(@var{v})
  14581. Increments the value in the variable @var{v} by one. Returns the new value.
  14582. @item INC(@var{v},@var{i})
  14583. Increments the value in the variable @var{v} by @var{i}. Returns the
  14584. new value.
  14585. @item INCL(@var{m},@var{s})
  14586. Adds the element @var{m} to the set @var{s} if it is not already
  14587. there. Returns the new set.
  14588. @item MAX(@var{t})
  14589. Returns the maximum value of the type @var{t}.
  14590. @item MIN(@var{t})
  14591. Returns the minimum value of the type @var{t}.
  14592. @item ODD(@var{i})
  14593. Returns boolean TRUE if @var{i} is an odd number.
  14594. @item ORD(@var{x})
  14595. Returns the ordinal value of its argument. For example, the ordinal
  14596. value of a character is its @sc{ascii} value (on machines supporting
  14597. the @sc{ascii} character set). The argument @var{x} must be of an
  14598. ordered type, which include integral, character and enumerated types.
  14599. @item SIZE(@var{x})
  14600. Returns the size of its argument. The argument @var{x} can be a
  14601. variable or a type.
  14602. @item TRUNC(@var{r})
  14603. Returns the integral part of @var{r}.
  14604. @item TSIZE(@var{x})
  14605. Returns the size of its argument. The argument @var{x} can be a
  14606. variable or a type.
  14607. @item VAL(@var{t},@var{i})
  14608. Returns the member of the type @var{t} whose ordinal value is @var{i}.
  14609. @end table
  14610. @quotation
  14611. @emph{Warning:} Sets and their operations are not yet supported, so
  14612. @value{GDBN} treats the use of procedures @code{INCL} and @code{EXCL} as
  14613. an error.
  14614. @end quotation
  14615. @cindex Modula-2 constants
  14616. @node M2 Constants
  14617. @subsubsection Constants
  14618. @value{GDBN} allows you to express the constants of Modula-2 in the following
  14619. ways:
  14620. @itemize @bullet
  14621. @item
  14622. Integer constants are simply a sequence of digits. When used in an
  14623. expression, a constant is interpreted to be type-compatible with the
  14624. rest of the expression. Hexadecimal integers are specified by a
  14625. trailing @samp{H}, and octal integers by a trailing @samp{B}.
  14626. @item
  14627. Floating point constants appear as a sequence of digits, followed by a
  14628. decimal point and another sequence of digits. An optional exponent can
  14629. then be specified, in the form @samp{E@r{[}+@r{|}-@r{]}@var{nnn}}, where
  14630. @samp{@r{[}+@r{|}-@r{]}@var{nnn}} is the desired exponent. All of the
  14631. digits of the floating point constant must be valid decimal (base 10)
  14632. digits.
  14633. @item
  14634. Character constants consist of a single character enclosed by a pair of
  14635. like quotes, either single (@code{'}) or double (@code{"}). They may
  14636. also be expressed by their ordinal value (their @sc{ascii} value, usually)
  14637. followed by a @samp{C}.
  14638. @item
  14639. String constants consist of a sequence of characters enclosed by a
  14640. pair of like quotes, either single (@code{'}) or double (@code{"}).
  14641. Escape sequences in the style of C are also allowed. @xref{C
  14642. Constants, ,C and C@t{++} Constants}, for a brief explanation of escape
  14643. sequences.
  14644. @item
  14645. Enumerated constants consist of an enumerated identifier.
  14646. @item
  14647. Boolean constants consist of the identifiers @code{TRUE} and
  14648. @code{FALSE}.
  14649. @item
  14650. Pointer constants consist of integral values only.
  14651. @item
  14652. Set constants are not yet supported.
  14653. @end itemize
  14654. @node M2 Types
  14655. @subsubsection Modula-2 Types
  14656. @cindex Modula-2 types
  14657. Currently @value{GDBN} can print the following data types in Modula-2
  14658. syntax: array types, record types, set types, pointer types, procedure
  14659. types, enumerated types, subrange types and base types. You can also
  14660. print the contents of variables declared using these type.
  14661. This section gives a number of simple source code examples together with
  14662. sample @value{GDBN} sessions.
  14663. The first example contains the following section of code:
  14664. @smallexample
  14665. VAR
  14666. s: SET OF CHAR ;
  14667. r: [20..40] ;
  14668. @end smallexample
  14669. @noindent
  14670. and you can request @value{GDBN} to interrogate the type and value of
  14671. @code{r} and @code{s}.
  14672. @smallexample
  14673. (@value{GDBP}) print s
  14674. @{'A'..'C', 'Z'@}
  14675. (@value{GDBP}) ptype s
  14676. SET OF CHAR
  14677. (@value{GDBP}) print r
  14678. 21
  14679. (@value{GDBP}) ptype r
  14680. [20..40]
  14681. @end smallexample
  14682. @noindent
  14683. Likewise if your source code declares @code{s} as:
  14684. @smallexample
  14685. VAR
  14686. s: SET ['A'..'Z'] ;
  14687. @end smallexample
  14688. @noindent
  14689. then you may query the type of @code{s} by:
  14690. @smallexample
  14691. (@value{GDBP}) ptype s
  14692. type = SET ['A'..'Z']
  14693. @end smallexample
  14694. @noindent
  14695. Note that at present you cannot interactively manipulate set
  14696. expressions using the debugger.
  14697. The following example shows how you might declare an array in Modula-2
  14698. and how you can interact with @value{GDBN} to print its type and contents:
  14699. @smallexample
  14700. VAR
  14701. s: ARRAY [-10..10] OF CHAR ;
  14702. @end smallexample
  14703. @smallexample
  14704. (@value{GDBP}) ptype s
  14705. ARRAY [-10..10] OF CHAR
  14706. @end smallexample
  14707. Note that the array handling is not yet complete and although the type
  14708. is printed correctly, expression handling still assumes that all
  14709. arrays have a lower bound of zero and not @code{-10} as in the example
  14710. above.
  14711. Here are some more type related Modula-2 examples:
  14712. @smallexample
  14713. TYPE
  14714. colour = (blue, red, yellow, green) ;
  14715. t = [blue..yellow] ;
  14716. VAR
  14717. s: t ;
  14718. BEGIN
  14719. s := blue ;
  14720. @end smallexample
  14721. @noindent
  14722. The @value{GDBN} interaction shows how you can query the data type
  14723. and value of a variable.
  14724. @smallexample
  14725. (@value{GDBP}) print s
  14726. $1 = blue
  14727. (@value{GDBP}) ptype t
  14728. type = [blue..yellow]
  14729. @end smallexample
  14730. @noindent
  14731. In this example a Modula-2 array is declared and its contents
  14732. displayed. Observe that the contents are written in the same way as
  14733. their @code{C} counterparts.
  14734. @smallexample
  14735. VAR
  14736. s: ARRAY [1..5] OF CARDINAL ;
  14737. BEGIN
  14738. s[1] := 1 ;
  14739. @end smallexample
  14740. @smallexample
  14741. (@value{GDBP}) print s
  14742. $1 = @{1, 0, 0, 0, 0@}
  14743. (@value{GDBP}) ptype s
  14744. type = ARRAY [1..5] OF CARDINAL
  14745. @end smallexample
  14746. The Modula-2 language interface to @value{GDBN} also understands
  14747. pointer types as shown in this example:
  14748. @smallexample
  14749. VAR
  14750. s: POINTER TO ARRAY [1..5] OF CARDINAL ;
  14751. BEGIN
  14752. NEW(s) ;
  14753. s^[1] := 1 ;
  14754. @end smallexample
  14755. @noindent
  14756. and you can request that @value{GDBN} describes the type of @code{s}.
  14757. @smallexample
  14758. (@value{GDBP}) ptype s
  14759. type = POINTER TO ARRAY [1..5] OF CARDINAL
  14760. @end smallexample
  14761. @value{GDBN} handles compound types as we can see in this example.
  14762. Here we combine array types, record types, pointer types and subrange
  14763. types:
  14764. @smallexample
  14765. TYPE
  14766. foo = RECORD
  14767. f1: CARDINAL ;
  14768. f2: CHAR ;
  14769. f3: myarray ;
  14770. END ;
  14771. myarray = ARRAY myrange OF CARDINAL ;
  14772. myrange = [-2..2] ;
  14773. VAR
  14774. s: POINTER TO ARRAY myrange OF foo ;
  14775. @end smallexample
  14776. @noindent
  14777. and you can ask @value{GDBN} to describe the type of @code{s} as shown
  14778. below.
  14779. @smallexample
  14780. (@value{GDBP}) ptype s
  14781. type = POINTER TO ARRAY [-2..2] OF foo = RECORD
  14782. f1 : CARDINAL;
  14783. f2 : CHAR;
  14784. f3 : ARRAY [-2..2] OF CARDINAL;
  14785. END
  14786. @end smallexample
  14787. @node M2 Defaults
  14788. @subsubsection Modula-2 Defaults
  14789. @cindex Modula-2 defaults
  14790. If type and range checking are set automatically by @value{GDBN}, they
  14791. both default to @code{on} whenever the working language changes to
  14792. Modula-2. This happens regardless of whether you or @value{GDBN}
  14793. selected the working language.
  14794. If you allow @value{GDBN} to set the language automatically, then entering
  14795. code compiled from a file whose name ends with @file{.mod} sets the
  14796. working language to Modula-2. @xref{Automatically, ,Having @value{GDBN}
  14797. Infer the Source Language}, for further details.
  14798. @node Deviations
  14799. @subsubsection Deviations from Standard Modula-2
  14800. @cindex Modula-2, deviations from
  14801. A few changes have been made to make Modula-2 programs easier to debug.
  14802. This is done primarily via loosening its type strictness:
  14803. @itemize @bullet
  14804. @item
  14805. Unlike in standard Modula-2, pointer constants can be formed by
  14806. integers. This allows you to modify pointer variables during
  14807. debugging. (In standard Modula-2, the actual address contained in a
  14808. pointer variable is hidden from you; it can only be modified
  14809. through direct assignment to another pointer variable or expression that
  14810. returned a pointer.)
  14811. @item
  14812. C escape sequences can be used in strings and characters to represent
  14813. non-printable characters. @value{GDBN} prints out strings with these
  14814. escape sequences embedded. Single non-printable characters are
  14815. printed using the @samp{CHR(@var{nnn})} format.
  14816. @item
  14817. The assignment operator (@code{:=}) returns the value of its right-hand
  14818. argument.
  14819. @item
  14820. All built-in procedures both modify @emph{and} return their argument.
  14821. @end itemize
  14822. @node M2 Checks
  14823. @subsubsection Modula-2 Type and Range Checks
  14824. @cindex Modula-2 checks
  14825. @quotation
  14826. @emph{Warning:} in this release, @value{GDBN} does not yet perform type or
  14827. range checking.
  14828. @end quotation
  14829. @c FIXME remove warning when type/range checks added
  14830. @value{GDBN} considers two Modula-2 variables type equivalent if:
  14831. @itemize @bullet
  14832. @item
  14833. They are of types that have been declared equivalent via a @code{TYPE
  14834. @var{t1} = @var{t2}} statement
  14835. @item
  14836. They have been declared on the same line. (Note: This is true of the
  14837. @sc{gnu} Modula-2 compiler, but it may not be true of other compilers.)
  14838. @end itemize
  14839. As long as type checking is enabled, any attempt to combine variables
  14840. whose types are not equivalent is an error.
  14841. Range checking is done on all mathematical operations, assignment, array
  14842. index bounds, and all built-in functions and procedures.
  14843. @node M2 Scope
  14844. @subsubsection The Scope Operators @code{::} and @code{.}
  14845. @cindex scope
  14846. @cindex @code{.}, Modula-2 scope operator
  14847. @cindex colon, doubled as scope operator
  14848. @ifinfo
  14849. @vindex colon-colon@r{, in Modula-2}
  14850. @c Info cannot handle :: but TeX can.
  14851. @end ifinfo
  14852. @ifnotinfo
  14853. @vindex ::@r{, in Modula-2}
  14854. @end ifnotinfo
  14855. There are a few subtle differences between the Modula-2 scope operator
  14856. (@code{.}) and the @value{GDBN} scope operator (@code{::}). The two have
  14857. similar syntax:
  14858. @smallexample
  14859. @var{module} . @var{id}
  14860. @var{scope} :: @var{id}
  14861. @end smallexample
  14862. @noindent
  14863. where @var{scope} is the name of a module or a procedure,
  14864. @var{module} the name of a module, and @var{id} is any declared
  14865. identifier within your program, except another module.
  14866. Using the @code{::} operator makes @value{GDBN} search the scope
  14867. specified by @var{scope} for the identifier @var{id}. If it is not
  14868. found in the specified scope, then @value{GDBN} searches all scopes
  14869. enclosing the one specified by @var{scope}.
  14870. Using the @code{.} operator makes @value{GDBN} search the current scope for
  14871. the identifier specified by @var{id} that was imported from the
  14872. definition module specified by @var{module}. With this operator, it is
  14873. an error if the identifier @var{id} was not imported from definition
  14874. module @var{module}, or if @var{id} is not an identifier in
  14875. @var{module}.
  14876. @node GDB/M2
  14877. @subsubsection @value{GDBN} and Modula-2
  14878. Some @value{GDBN} commands have little use when debugging Modula-2 programs.
  14879. Five subcommands of @code{set print} and @code{show print} apply
  14880. specifically to C and C@t{++}: @samp{vtbl}, @samp{demangle},
  14881. @samp{asm-demangle}, @samp{object}, and @samp{union}. The first four
  14882. apply to C@t{++}, and the last to the C @code{union} type, which has no direct
  14883. analogue in Modula-2.
  14884. The @code{@@} operator (@pxref{Expressions, ,Expressions}), while available
  14885. with any language, is not useful with Modula-2. Its
  14886. intent is to aid the debugging of @dfn{dynamic arrays}, which cannot be
  14887. created in Modula-2 as they can in C or C@t{++}. However, because an
  14888. address can be specified by an integral constant, the construct
  14889. @samp{@{@var{type}@}@var{adrexp}} is still useful.
  14890. @cindex @code{#} in Modula-2
  14891. In @value{GDBN} scripts, the Modula-2 inequality operator @code{#} is
  14892. interpreted as the beginning of a comment. Use @code{<>} instead.
  14893. @node Ada
  14894. @subsection Ada
  14895. @cindex Ada
  14896. The extensions made to @value{GDBN} for Ada only support
  14897. output from the @sc{gnu} Ada (GNAT) compiler.
  14898. Other Ada compilers are not currently supported, and
  14899. attempting to debug executables produced by them is most likely
  14900. to be difficult.
  14901. @cindex expressions in Ada
  14902. @menu
  14903. * Ada Mode Intro:: General remarks on the Ada syntax
  14904. and semantics supported by Ada mode
  14905. in @value{GDBN}.
  14906. * Omissions from Ada:: Restrictions on the Ada expression syntax.
  14907. * Additions to Ada:: Extensions of the Ada expression syntax.
  14908. * Overloading support for Ada:: Support for expressions involving overloaded
  14909. subprograms.
  14910. * Stopping Before Main Program:: Debugging the program during elaboration.
  14911. * Ada Exceptions:: Ada Exceptions
  14912. * Ada Tasks:: Listing and setting breakpoints in tasks.
  14913. * Ada Tasks and Core Files:: Tasking Support when Debugging Core Files
  14914. * Ravenscar Profile:: Tasking Support when using the Ravenscar
  14915. Profile
  14916. * Ada Settings:: New settable GDB parameters for Ada.
  14917. * Ada Source Character Set:: Character set of Ada source files.
  14918. * Ada Glitches:: Known peculiarities of Ada mode.
  14919. @end menu
  14920. @node Ada Mode Intro
  14921. @subsubsection Introduction
  14922. @cindex Ada mode, general
  14923. The Ada mode of @value{GDBN} supports a fairly large subset of Ada expression
  14924. syntax, with some extensions.
  14925. The philosophy behind the design of this subset is
  14926. @itemize @bullet
  14927. @item
  14928. That @value{GDBN} should provide basic literals and access to operations for
  14929. arithmetic, dereferencing, field selection, indexing, and subprogram calls,
  14930. leaving more sophisticated computations to subprograms written into the
  14931. program (which therefore may be called from @value{GDBN}).
  14932. @item
  14933. That type safety and strict adherence to Ada language restrictions
  14934. are not particularly important to the @value{GDBN} user.
  14935. @item
  14936. That brevity is important to the @value{GDBN} user.
  14937. @end itemize
  14938. Thus, for brevity, the debugger acts as if all names declared in
  14939. user-written packages are directly visible, even if they are not visible
  14940. according to Ada rules, thus making it unnecessary to fully qualify most
  14941. names with their packages, regardless of context. Where this causes
  14942. ambiguity, @value{GDBN} asks the user's intent.
  14943. The debugger will start in Ada mode if it detects an Ada main program.
  14944. As for other languages, it will enter Ada mode when stopped in a program that
  14945. was translated from an Ada source file.
  14946. While in Ada mode, you may use `@t{--}' for comments. This is useful
  14947. mostly for documenting command files. The standard @value{GDBN} comment
  14948. (@samp{#}) still works at the beginning of a line in Ada mode, but not in the
  14949. middle (to allow based literals).
  14950. @node Omissions from Ada
  14951. @subsubsection Omissions from Ada
  14952. @cindex Ada, omissions from
  14953. Here are the notable omissions from the subset:
  14954. @itemize @bullet
  14955. @item
  14956. Only a subset of the attributes are supported:
  14957. @itemize @minus
  14958. @item
  14959. @t{'First}, @t{'Last}, and @t{'Length}
  14960. on array objects (not on types and subtypes).
  14961. @item
  14962. @t{'Min} and @t{'Max}.
  14963. @item
  14964. @t{'Pos} and @t{'Val}.
  14965. @item
  14966. @t{'Tag}.
  14967. @item
  14968. @t{'Range} on array objects (not subtypes), but only as the right
  14969. operand of the membership (@code{in}) operator.
  14970. @item
  14971. @t{'Access}, @t{'Unchecked_Access}, and
  14972. @t{'Unrestricted_Access} (a GNAT extension).
  14973. @item
  14974. @t{'Address}.
  14975. @end itemize
  14976. @item
  14977. The names in @code{Characters.Latin_1} are not available.
  14978. @item
  14979. Equality tests (@samp{=} and @samp{/=}) on arrays test for bitwise
  14980. equality of representations. They will generally work correctly
  14981. for strings and arrays whose elements have integer or enumeration types.
  14982. They may not work correctly for arrays whose element
  14983. types have user-defined equality, for arrays of real values
  14984. (in particular, IEEE-conformant floating point, because of negative
  14985. zeroes and NaNs), and for arrays whose elements contain unused bits with
  14986. indeterminate values.
  14987. @item
  14988. The other component-by-component array operations (@code{and}, @code{or},
  14989. @code{xor}, @code{not}, and relational tests other than equality)
  14990. are not implemented.
  14991. @item
  14992. @cindex array aggregates (Ada)
  14993. @cindex record aggregates (Ada)
  14994. @cindex aggregates (Ada)
  14995. There is limited support for array and record aggregates. They are
  14996. permitted only on the right sides of assignments, as in these examples:
  14997. @smallexample
  14998. (@value{GDBP}) set An_Array := (1, 2, 3, 4, 5, 6)
  14999. (@value{GDBP}) set An_Array := (1, others => 0)
  15000. (@value{GDBP}) set An_Array := (0|4 => 1, 1..3 => 2, 5 => 6)
  15001. (@value{GDBP}) set A_2D_Array := ((1, 2, 3), (4, 5, 6), (7, 8, 9))
  15002. (@value{GDBP}) set A_Record := (1, "Peter", True);
  15003. (@value{GDBP}) set A_Record := (Name => "Peter", Id => 1, Alive => True)
  15004. @end smallexample
  15005. Changing a
  15006. discriminant's value by assigning an aggregate has an
  15007. undefined effect if that discriminant is used within the record.
  15008. However, you can first modify discriminants by directly assigning to
  15009. them (which normally would not be allowed in Ada), and then performing an
  15010. aggregate assignment. For example, given a variable @code{A_Rec}
  15011. declared to have a type such as:
  15012. @smallexample
  15013. type Rec (Len : Small_Integer := 0) is record
  15014. Id : Integer;
  15015. Vals : IntArray (1 .. Len);
  15016. end record;
  15017. @end smallexample
  15018. you can assign a value with a different size of @code{Vals} with two
  15019. assignments:
  15020. @smallexample
  15021. (@value{GDBP}) set A_Rec.Len := 4
  15022. (@value{GDBP}) set A_Rec := (Id => 42, Vals => (1, 2, 3, 4))
  15023. @end smallexample
  15024. As this example also illustrates, @value{GDBN} is very loose about the usual
  15025. rules concerning aggregates. You may leave out some of the
  15026. components of an array or record aggregate (such as the @code{Len}
  15027. component in the assignment to @code{A_Rec} above); they will retain their
  15028. original values upon assignment. You may freely use dynamic values as
  15029. indices in component associations. You may even use overlapping or
  15030. redundant component associations, although which component values are
  15031. assigned in such cases is not defined.
  15032. @item
  15033. Calls to dispatching subprograms are not implemented.
  15034. @item
  15035. The overloading algorithm is much more limited (i.e., less selective)
  15036. than that of real Ada. It makes only limited use of the context in
  15037. which a subexpression appears to resolve its meaning, and it is much
  15038. looser in its rules for allowing type matches. As a result, some
  15039. function calls will be ambiguous, and the user will be asked to choose
  15040. the proper resolution.
  15041. @item
  15042. The @code{new} operator is not implemented.
  15043. @item
  15044. Entry calls are not implemented.
  15045. @item
  15046. Aside from printing, arithmetic operations on the native VAX floating-point
  15047. formats are not supported.
  15048. @item
  15049. It is not possible to slice a packed array.
  15050. @item
  15051. The names @code{True} and @code{False}, when not part of a qualified name,
  15052. are interpreted as if implicitly prefixed by @code{Standard}, regardless of
  15053. context.
  15054. Should your program
  15055. redefine these names in a package or procedure (at best a dubious practice),
  15056. you will have to use fully qualified names to access their new definitions.
  15057. @item
  15058. Based real literals are not implemented.
  15059. @end itemize
  15060. @node Additions to Ada
  15061. @subsubsection Additions to Ada
  15062. @cindex Ada, deviations from
  15063. As it does for other languages, @value{GDBN} makes certain generic
  15064. extensions to Ada (@pxref{Expressions}):
  15065. @itemize @bullet
  15066. @item
  15067. If the expression @var{E} is a variable residing in memory (typically
  15068. a local variable or array element) and @var{N} is a positive integer,
  15069. then @code{@var{E}@@@var{N}} displays the values of @var{E} and the
  15070. @var{N}-1 adjacent variables following it in memory as an array. In
  15071. Ada, this operator is generally not necessary, since its prime use is
  15072. in displaying parts of an array, and slicing will usually do this in
  15073. Ada. However, there are occasional uses when debugging programs in
  15074. which certain debugging information has been optimized away.
  15075. @item
  15076. @code{@var{B}::@var{var}} means ``the variable named @var{var} that
  15077. appears in function or file @var{B}.'' When @var{B} is a file name,
  15078. you must typically surround it in single quotes.
  15079. @item
  15080. The expression @code{@{@var{type}@} @var{addr}} means ``the variable of type
  15081. @var{type} that appears at address @var{addr}.''
  15082. @item
  15083. A name starting with @samp{$} is a convenience variable
  15084. (@pxref{Convenience Vars}) or a machine register (@pxref{Registers}).
  15085. @end itemize
  15086. In addition, @value{GDBN} provides a few other shortcuts and outright
  15087. additions specific to Ada:
  15088. @itemize @bullet
  15089. @item
  15090. The assignment statement is allowed as an expression, returning
  15091. its right-hand operand as its value. Thus, you may enter
  15092. @smallexample
  15093. (@value{GDBP}) set x := y + 3
  15094. (@value{GDBP}) print A(tmp := y + 1)
  15095. @end smallexample
  15096. @item
  15097. The semicolon is allowed as an ``operator,'' returning as its value
  15098. the value of its right-hand operand.
  15099. This allows, for example,
  15100. complex conditional breaks:
  15101. @smallexample
  15102. (@value{GDBP}) break f
  15103. (@value{GDBP}) condition 1 (report(i); k += 1; A(k) > 100)
  15104. @end smallexample
  15105. @item
  15106. An extension to based literals can be used to specify the exact byte
  15107. contents of a floating-point literal. After the base, you can use
  15108. from zero to two @samp{l} characters, followed by an @samp{f}. The
  15109. number of @samp{l} characters controls the width of the resulting real
  15110. constant: zero means @code{Float} is used, one means
  15111. @code{Long_Float}, and two means @code{Long_Long_Float}.
  15112. @smallexample
  15113. (@value{GDBP}) print 16f#41b80000#
  15114. $1 = 23.0
  15115. @end smallexample
  15116. @item
  15117. Rather than use catenation and symbolic character names to introduce special
  15118. characters into strings, one may instead use a special bracket notation,
  15119. which is also used to print strings. A sequence of characters of the form
  15120. @samp{["@var{XX}"]} within a string or character literal denotes the
  15121. (single) character whose numeric encoding is @var{XX} in hexadecimal. The
  15122. sequence of characters @samp{["""]} also denotes a single quotation mark
  15123. in strings. For example,
  15124. @smallexample
  15125. "One line.["0a"]Next line.["0a"]"
  15126. @end smallexample
  15127. @noindent
  15128. contains an ASCII newline character (@code{Ada.Characters.Latin_1.LF})
  15129. after each period.
  15130. @item
  15131. The subtype used as a prefix for the attributes @t{'Pos}, @t{'Min}, and
  15132. @t{'Max} is optional (and is ignored in any case). For example, it is valid
  15133. to write
  15134. @smallexample
  15135. (@value{GDBP}) print 'max(x, y)
  15136. @end smallexample
  15137. @item
  15138. When printing arrays, @value{GDBN} uses positional notation when the
  15139. array has a lower bound of 1, and uses a modified named notation otherwise.
  15140. For example, a one-dimensional array of three integers with a lower bound
  15141. of 3 might print as
  15142. @smallexample
  15143. (3 => 10, 17, 1)
  15144. @end smallexample
  15145. @noindent
  15146. That is, in contrast to valid Ada, only the first component has a @code{=>}
  15147. clause.
  15148. @item
  15149. You may abbreviate attributes in expressions with any unique,
  15150. multi-character subsequence of
  15151. their names (an exact match gets preference).
  15152. For example, you may use @t{a'len}, @t{a'gth}, or @t{a'lh}
  15153. in place of @t{a'length}.
  15154. @item
  15155. @cindex quoting Ada internal identifiers
  15156. Since Ada is case-insensitive, the debugger normally maps identifiers you type
  15157. to lower case. The GNAT compiler uses upper-case characters for
  15158. some of its internal identifiers, which are normally of no interest to users.
  15159. For the rare occasions when you actually have to look at them,
  15160. enclose them in angle brackets to avoid the lower-case mapping.
  15161. For example,
  15162. @smallexample
  15163. (@value{GDBP}) print <JMPBUF_SAVE>[0]
  15164. @end smallexample
  15165. @item
  15166. Printing an object of class-wide type or dereferencing an
  15167. access-to-class-wide value will display all the components of the object's
  15168. specific type (as indicated by its run-time tag). Likewise, component
  15169. selection on such a value will operate on the specific type of the
  15170. object.
  15171. @end itemize
  15172. @node Overloading support for Ada
  15173. @subsubsection Overloading support for Ada
  15174. @cindex overloading, Ada
  15175. The debugger supports limited overloading. Given a subprogram call in which
  15176. the function symbol has multiple definitions, it will use the number of
  15177. actual parameters and some information about their types to attempt to narrow
  15178. the set of definitions. It also makes very limited use of context, preferring
  15179. procedures to functions in the context of the @code{call} command, and
  15180. functions to procedures elsewhere.
  15181. If, after narrowing, the set of matching definitions still contains more than
  15182. one definition, @value{GDBN} will display a menu to query which one it should
  15183. use, for instance:
  15184. @smallexample
  15185. (@value{GDBP}) print f(1)
  15186. Multiple matches for f
  15187. [0] cancel
  15188. [1] foo.f (integer) return boolean at foo.adb:23
  15189. [2] foo.f (foo.new_integer) return boolean at foo.adb:28
  15190. >
  15191. @end smallexample
  15192. In this case, just select one menu entry either to cancel expression evaluation
  15193. (type @kbd{0} and press @key{RET}) or to continue evaluation with a specific
  15194. instance (type the corresponding number and press @key{RET}).
  15195. Here are a couple of commands to customize @value{GDBN}'s behavior in this
  15196. case:
  15197. @table @code
  15198. @kindex set ada print-signatures
  15199. @item set ada print-signatures
  15200. Control whether parameter types and return types are displayed in overloads
  15201. selection menus. It is @code{on} by default.
  15202. @xref{Overloading support for Ada}.
  15203. @kindex show ada print-signatures
  15204. @item show ada print-signatures
  15205. Show the current setting for displaying parameter types and return types in
  15206. overloads selection menu.
  15207. @xref{Overloading support for Ada}.
  15208. @end table
  15209. @node Stopping Before Main Program
  15210. @subsubsection Stopping at the Very Beginning
  15211. @cindex breakpointing Ada elaboration code
  15212. It is sometimes necessary to debug the program during elaboration, and
  15213. before reaching the main procedure.
  15214. As defined in the Ada Reference
  15215. Manual, the elaboration code is invoked from a procedure called
  15216. @code{adainit}. To run your program up to the beginning of
  15217. elaboration, simply use the following two commands:
  15218. @code{tbreak adainit} and @code{run}.
  15219. @node Ada Exceptions
  15220. @subsubsection Ada Exceptions
  15221. A command is provided to list all Ada exceptions:
  15222. @table @code
  15223. @kindex info exceptions
  15224. @item info exceptions
  15225. @itemx info exceptions @var{regexp}
  15226. The @code{info exceptions} command allows you to list all Ada exceptions
  15227. defined within the program being debugged, as well as their addresses.
  15228. With a regular expression, @var{regexp}, as argument, only those exceptions
  15229. whose names match @var{regexp} are listed.
  15230. @end table
  15231. Below is a small example, showing how the command can be used, first
  15232. without argument, and next with a regular expression passed as an
  15233. argument.
  15234. @smallexample
  15235. (@value{GDBP}) info exceptions
  15236. All defined Ada exceptions:
  15237. constraint_error: 0x613da0
  15238. program_error: 0x613d20
  15239. storage_error: 0x613ce0
  15240. tasking_error: 0x613ca0
  15241. const.aint_global_e: 0x613b00
  15242. (@value{GDBP}) info exceptions const.aint
  15243. All Ada exceptions matching regular expression "const.aint":
  15244. constraint_error: 0x613da0
  15245. const.aint_global_e: 0x613b00
  15246. @end smallexample
  15247. It is also possible to ask @value{GDBN} to stop your program's execution
  15248. when an exception is raised. For more details, see @ref{Set Catchpoints}.
  15249. @node Ada Tasks
  15250. @subsubsection Extensions for Ada Tasks
  15251. @cindex Ada, tasking
  15252. Support for Ada tasks is analogous to that for threads (@pxref{Threads}).
  15253. @value{GDBN} provides the following task-related commands:
  15254. @table @code
  15255. @kindex info tasks
  15256. @item info tasks
  15257. This command shows a list of current Ada tasks, as in the following example:
  15258. @smallexample
  15259. @iftex
  15260. @leftskip=0.5cm
  15261. @end iftex
  15262. (@value{GDBP}) info tasks
  15263. ID TID P-ID Pri State Name
  15264. 1 8088000 0 15 Child Activation Wait main_task
  15265. 2 80a4000 1 15 Accept Statement b
  15266. 3 809a800 1 15 Child Activation Wait a
  15267. * 4 80ae800 3 15 Runnable c
  15268. @end smallexample
  15269. @noindent
  15270. In this listing, the asterisk before the last task indicates it to be the
  15271. task currently being inspected.
  15272. @table @asis
  15273. @item ID
  15274. Represents @value{GDBN}'s internal task number.
  15275. @item TID
  15276. The Ada task ID.
  15277. @item P-ID
  15278. The parent's task ID (@value{GDBN}'s internal task number).
  15279. @item Pri
  15280. The base priority of the task.
  15281. @item State
  15282. Current state of the task.
  15283. @table @code
  15284. @item Unactivated
  15285. The task has been created but has not been activated. It cannot be
  15286. executing.
  15287. @item Runnable
  15288. The task is not blocked for any reason known to Ada. (It may be waiting
  15289. for a mutex, though.) It is conceptually "executing" in normal mode.
  15290. @item Terminated
  15291. The task is terminated, in the sense of ARM 9.3 (5). Any dependents
  15292. that were waiting on terminate alternatives have been awakened and have
  15293. terminated themselves.
  15294. @item Child Activation Wait
  15295. The task is waiting for created tasks to complete activation.
  15296. @item Accept Statement
  15297. The task is waiting on an accept or selective wait statement.
  15298. @item Waiting on entry call
  15299. The task is waiting on an entry call.
  15300. @item Async Select Wait
  15301. The task is waiting to start the abortable part of an asynchronous
  15302. select statement.
  15303. @item Delay Sleep
  15304. The task is waiting on a select statement with only a delay
  15305. alternative open.
  15306. @item Child Termination Wait
  15307. The task is sleeping having completed a master within itself, and is
  15308. waiting for the tasks dependent on that master to become terminated or
  15309. waiting on a terminate Phase.
  15310. @item Wait Child in Term Alt
  15311. The task is sleeping waiting for tasks on terminate alternatives to
  15312. finish terminating.
  15313. @item Accepting RV with @var{taskno}
  15314. The task is accepting a rendez-vous with the task @var{taskno}.
  15315. @end table
  15316. @item Name
  15317. Name of the task in the program.
  15318. @end table
  15319. @kindex info task @var{taskno}
  15320. @item info task @var{taskno}
  15321. This command shows detailed informations on the specified task, as in
  15322. the following example:
  15323. @smallexample
  15324. @iftex
  15325. @leftskip=0.5cm
  15326. @end iftex
  15327. (@value{GDBP}) info tasks
  15328. ID TID P-ID Pri State Name
  15329. 1 8077880 0 15 Child Activation Wait main_task
  15330. * 2 807c468 1 15 Runnable task_1
  15331. (@value{GDBP}) info task 2
  15332. Ada Task: 0x807c468
  15333. Name: "task_1"
  15334. Thread: 0
  15335. LWP: 0x1fac
  15336. Parent: 1 ("main_task")
  15337. Base Priority: 15
  15338. State: Runnable
  15339. @end smallexample
  15340. @item task
  15341. @kindex task@r{ (Ada)}
  15342. @cindex current Ada task ID
  15343. This command prints the ID and name of the current task.
  15344. @smallexample
  15345. @iftex
  15346. @leftskip=0.5cm
  15347. @end iftex
  15348. (@value{GDBP}) info tasks
  15349. ID TID P-ID Pri State Name
  15350. 1 8077870 0 15 Child Activation Wait main_task
  15351. * 2 807c458 1 15 Runnable some_task
  15352. (@value{GDBP}) task
  15353. [Current task is 2 "some_task"]
  15354. @end smallexample
  15355. @item task @var{taskno}
  15356. @cindex Ada task switching
  15357. This command is like the @code{thread @var{thread-id}}
  15358. command (@pxref{Threads}). It switches the context of debugging
  15359. from the current task to the given task.
  15360. @smallexample
  15361. @iftex
  15362. @leftskip=0.5cm
  15363. @end iftex
  15364. (@value{GDBP}) info tasks
  15365. ID TID P-ID Pri State Name
  15366. 1 8077870 0 15 Child Activation Wait main_task
  15367. * 2 807c458 1 15 Runnable some_task
  15368. (@value{GDBP}) task 1
  15369. [Switching to task 1 "main_task"]
  15370. #0 0x8067726 in pthread_cond_wait ()
  15371. (@value{GDBP}) bt
  15372. #0 0x8067726 in pthread_cond_wait ()
  15373. #1 0x8056714 in system.os_interface.pthread_cond_wait ()
  15374. #2 0x805cb63 in system.task_primitives.operations.sleep ()
  15375. #3 0x806153e in system.tasking.stages.activate_tasks ()
  15376. #4 0x804aacc in un () at un.adb:5
  15377. @end smallexample
  15378. @item task apply [@var{task-id-list} | all] [@var{flag}]@dots{} @var{command}
  15379. The @code{task apply} command is the Ada tasking analogue of
  15380. @code{thread apply} (@pxref{Threads}). It allows you to apply the
  15381. named @var{command} to one or more tasks. Specify the tasks that you
  15382. want affected using a list of task IDs, or specify @code{all} to apply
  15383. to all tasks.
  15384. The @var{flag} arguments control what output to produce and how to
  15385. handle errors raised when applying @var{command} to a task.
  15386. @var{flag} must start with a @code{-} directly followed by one letter
  15387. in @code{qcs}. If several flags are provided, they must be given
  15388. individually, such as @code{-c -q}.
  15389. By default, @value{GDBN} displays some task information before the
  15390. output produced by @var{command}, and an error raised during the
  15391. execution of a @var{command} will abort @code{task apply}. The
  15392. following flags can be used to fine-tune this behavior:
  15393. @table @code
  15394. @item -c
  15395. The flag @code{-c}, which stands for @samp{continue}, causes any
  15396. errors in @var{command} to be displayed, and the execution of
  15397. @code{task apply} then continues.
  15398. @item -s
  15399. The flag @code{-s}, which stands for @samp{silent}, causes any errors
  15400. or empty output produced by a @var{command} to be silently ignored.
  15401. That is, the execution continues, but the task information and errors
  15402. are not printed.
  15403. @item -q
  15404. The flag @code{-q} (@samp{quiet}) disables printing the task
  15405. information.
  15406. @end table
  15407. Flags @code{-c} and @code{-s} cannot be used together.
  15408. @item break @var{location} task @var{taskno}
  15409. @itemx break @var{location} task @var{taskno} if @dots{}
  15410. @cindex breakpoints and tasks, in Ada
  15411. @cindex task breakpoints, in Ada
  15412. @kindex break @dots{} task @var{taskno}@r{ (Ada)}
  15413. These commands are like the @code{break @dots{} thread @dots{}}
  15414. command (@pxref{Thread Stops}). The
  15415. @var{location} argument specifies source lines, as described
  15416. in @ref{Specify Location}.
  15417. Use the qualifier @samp{task @var{taskno}} with a breakpoint command
  15418. to specify that you only want @value{GDBN} to stop the program when a
  15419. particular Ada task reaches this breakpoint. The @var{taskno} is one of the
  15420. numeric task identifiers assigned by @value{GDBN}, shown in the first
  15421. column of the @samp{info tasks} display.
  15422. If you do not specify @samp{task @var{taskno}} when you set a
  15423. breakpoint, the breakpoint applies to @emph{all} tasks of your
  15424. program.
  15425. You can use the @code{task} qualifier on conditional breakpoints as
  15426. well; in this case, place @samp{task @var{taskno}} before the
  15427. breakpoint condition (before the @code{if}).
  15428. For example,
  15429. @smallexample
  15430. @iftex
  15431. @leftskip=0.5cm
  15432. @end iftex
  15433. (@value{GDBP}) info tasks
  15434. ID TID P-ID Pri State Name
  15435. 1 140022020 0 15 Child Activation Wait main_task
  15436. 2 140045060 1 15 Accept/Select Wait t2
  15437. 3 140044840 1 15 Runnable t1
  15438. * 4 140056040 1 15 Runnable t3
  15439. (@value{GDBP}) b 15 task 2
  15440. Breakpoint 5 at 0x120044cb0: file test_task_debug.adb, line 15.
  15441. (@value{GDBP}) cont
  15442. Continuing.
  15443. task # 1 running
  15444. task # 2 running
  15445. Breakpoint 5, test_task_debug () at test_task_debug.adb:15
  15446. 15 flush;
  15447. (@value{GDBP}) info tasks
  15448. ID TID P-ID Pri State Name
  15449. 1 140022020 0 15 Child Activation Wait main_task
  15450. * 2 140045060 1 15 Runnable t2
  15451. 3 140044840 1 15 Runnable t1
  15452. 4 140056040 1 15 Delay Sleep t3
  15453. @end smallexample
  15454. @end table
  15455. @node Ada Tasks and Core Files
  15456. @subsubsection Tasking Support when Debugging Core Files
  15457. @cindex Ada tasking and core file debugging
  15458. When inspecting a core file, as opposed to debugging a live program,
  15459. tasking support may be limited or even unavailable, depending on
  15460. the platform being used.
  15461. For instance, on x86-linux, the list of tasks is available, but task
  15462. switching is not supported.
  15463. On certain platforms, the debugger needs to perform some
  15464. memory writes in order to provide Ada tasking support. When inspecting
  15465. a core file, this means that the core file must be opened with read-write
  15466. privileges, using the command @samp{"set write on"} (@pxref{Patching}).
  15467. Under these circumstances, you should make a backup copy of the core
  15468. file before inspecting it with @value{GDBN}.
  15469. @node Ravenscar Profile
  15470. @subsubsection Tasking Support when using the Ravenscar Profile
  15471. @cindex Ravenscar Profile
  15472. The @dfn{Ravenscar Profile} is a subset of the Ada tasking features,
  15473. specifically designed for systems with safety-critical real-time
  15474. requirements.
  15475. @table @code
  15476. @kindex set ravenscar task-switching on
  15477. @cindex task switching with program using Ravenscar Profile
  15478. @item set ravenscar task-switching on
  15479. Allows task switching when debugging a program that uses the Ravenscar
  15480. Profile. This is the default.
  15481. @kindex set ravenscar task-switching off
  15482. @item set ravenscar task-switching off
  15483. Turn off task switching when debugging a program that uses the Ravenscar
  15484. Profile. This is mostly intended to disable the code that adds support
  15485. for the Ravenscar Profile, in case a bug in either @value{GDBN} or in
  15486. the Ravenscar runtime is preventing @value{GDBN} from working properly.
  15487. To be effective, this command should be run before the program is started.
  15488. @kindex show ravenscar task-switching
  15489. @item show ravenscar task-switching
  15490. Show whether it is possible to switch from task to task in a program
  15491. using the Ravenscar Profile.
  15492. @end table
  15493. @cindex Ravenscar thread
  15494. When Ravenscar task-switching is enabled, Ravenscar tasks are
  15495. announced by @value{GDBN} as if they were threads:
  15496. @smallexample
  15497. (gdb) continue
  15498. [New Ravenscar Thread 0x2b8f0]
  15499. @end smallexample
  15500. Both Ravenscar tasks and the underlying CPU threads will show up in
  15501. the output of @code{info threads}:
  15502. @smallexample
  15503. (gdb) info threads
  15504. Id Target Id Frame
  15505. 1 Thread 1 (CPU#0 [running]) simple () at simple.adb:10
  15506. 2 Thread 2 (CPU#1 [running]) 0x0000000000003d34 in __gnat_initialize_cpu_devices ()
  15507. 3 Thread 3 (CPU#2 [running]) 0x0000000000003d28 in __gnat_initialize_cpu_devices ()
  15508. 4 Thread 4 (CPU#3 [halted ]) 0x000000000000c6ec in system.task_primitives.operations.idle ()
  15509. * 5 Ravenscar Thread 0x2b8f0 simple () at simple.adb:10
  15510. 6 Ravenscar Thread 0x2f150 0x000000000000c6ec in system.task_primitives.operations.idle ()
  15511. @end smallexample
  15512. One known limitation of the Ravenscar support in @value{GDBN} is that
  15513. it isn't currently possible to single-step through the runtime
  15514. initialization sequence. If you need to debug this code, you should
  15515. use @code{set ravenscar task-switching off}.
  15516. @node Ada Settings
  15517. @subsubsection Ada Settings
  15518. @cindex Ada settings
  15519. @table @code
  15520. @kindex set varsize-limit
  15521. @item set varsize-limit @var{size}
  15522. Prevent @value{GDBN} from attempting to evaluate objects whose size
  15523. is above the given limit (@var{size}) when those sizes are computed
  15524. from run-time quantities. This is typically the case when the object
  15525. has a variable size, such as an array whose bounds are not known at
  15526. compile time for example. Setting @var{size} to @code{unlimited}
  15527. removes the size limitation. By default, the limit is about 65KB.
  15528. The purpose of having such a limit is to prevent @value{GDBN} from
  15529. trying to grab enormous chunks of virtual memory when asked to evaluate
  15530. a quantity whose bounds have been corrupted or have not yet been fully
  15531. initialized. The limit applies to the results of some subexpressions
  15532. as well as to complete expressions. For example, an expression denoting
  15533. a simple integer component, such as @code{x.y.z}, may fail if the size of
  15534. @code{x.y} is variable and exceeds @code{size}. On the other hand,
  15535. @value{GDBN} is sometimes clever; the expression @code{A(i)}, where
  15536. @code{A} is an array variable with non-constant size, will generally
  15537. succeed regardless of the bounds on @code{A}, as long as the component
  15538. size is less than @var{size}.
  15539. @kindex show varsize-limit
  15540. @item show varsize-limit
  15541. Show the limit on types whose size is determined by run-time quantities.
  15542. @end table
  15543. @node Ada Source Character Set
  15544. @subsubsection Ada Source Character Set
  15545. @cindex Ada, source character set
  15546. The GNAT compiler supports a number of character sets for source
  15547. files. @xref{Character Set Control, , Character Set Control,
  15548. gnat_ugn}. @value{GDBN} includes support for this as well.
  15549. @table @code
  15550. @item set ada source-charset @var{charset}
  15551. @kindex set ada source-charset
  15552. Set the source character set for Ada. The character set must be
  15553. supported by GNAT. Because this setting affects the decoding of
  15554. symbols coming from the debug information in your program, the setting
  15555. should be set as early as possible. The default is @code{ISO-8859-1},
  15556. because that is also GNAT's default.
  15557. @item show ada source-charset
  15558. @kindex show ada source-charset
  15559. Show the current source character set for Ada.
  15560. @end table
  15561. @node Ada Glitches
  15562. @subsubsection Known Peculiarities of Ada Mode
  15563. @cindex Ada, problems
  15564. Besides the omissions listed previously (@pxref{Omissions from Ada}),
  15565. we know of several problems with and limitations of Ada mode in
  15566. @value{GDBN},
  15567. some of which will be fixed with planned future releases of the debugger
  15568. and the GNU Ada compiler.
  15569. @itemize @bullet
  15570. @item
  15571. Static constants that the compiler chooses not to materialize as objects in
  15572. storage are invisible to the debugger.
  15573. @item
  15574. Named parameter associations in function argument lists are ignored (the
  15575. argument lists are treated as positional).
  15576. @item
  15577. Many useful library packages are currently invisible to the debugger.
  15578. @item
  15579. Fixed-point arithmetic, conversions, input, and output is carried out using
  15580. floating-point arithmetic, and may give results that only approximate those on
  15581. the host machine.
  15582. @item
  15583. The GNAT compiler never generates the prefix @code{Standard} for any of
  15584. the standard symbols defined by the Ada language. @value{GDBN} knows about
  15585. this: it will strip the prefix from names when you use it, and will never
  15586. look for a name you have so qualified among local symbols, nor match against
  15587. symbols in other packages or subprograms. If you have
  15588. defined entities anywhere in your program other than parameters and
  15589. local variables whose simple names match names in @code{Standard},
  15590. GNAT's lack of qualification here can cause confusion. When this happens,
  15591. you can usually resolve the confusion
  15592. by qualifying the problematic names with package
  15593. @code{Standard} explicitly.
  15594. @end itemize
  15595. Older versions of the compiler sometimes generate erroneous debugging
  15596. information, resulting in the debugger incorrectly printing the value
  15597. of affected entities. In some cases, the debugger is able to work
  15598. around an issue automatically. In other cases, the debugger is able
  15599. to work around the issue, but the work-around has to be specifically
  15600. enabled.
  15601. @kindex set ada trust-PAD-over-XVS
  15602. @kindex show ada trust-PAD-over-XVS
  15603. @table @code
  15604. @item set ada trust-PAD-over-XVS on
  15605. Configure GDB to strictly follow the GNAT encoding when computing the
  15606. value of Ada entities, particularly when @code{PAD} and @code{PAD___XVS}
  15607. types are involved (see @code{ada/exp_dbug.ads} in the GCC sources for
  15608. a complete description of the encoding used by the GNAT compiler).
  15609. This is the default.
  15610. @item set ada trust-PAD-over-XVS off
  15611. This is related to the encoding using by the GNAT compiler. If @value{GDBN}
  15612. sometimes prints the wrong value for certain entities, changing @code{ada
  15613. trust-PAD-over-XVS} to @code{off} activates a work-around which may fix
  15614. the issue. It is always safe to set @code{ada trust-PAD-over-XVS} to
  15615. @code{off}, but this incurs a slight performance penalty, so it is
  15616. recommended to leave this setting to @code{on} unless necessary.
  15617. @end table
  15618. @cindex GNAT descriptive types
  15619. @cindex GNAT encoding
  15620. Internally, the debugger also relies on the compiler following a number
  15621. of conventions known as the @samp{GNAT Encoding}, all documented in
  15622. @file{gcc/ada/exp_dbug.ads} in the GCC sources. This encoding describes
  15623. how the debugging information should be generated for certain types.
  15624. In particular, this convention makes use of @dfn{descriptive types},
  15625. which are artificial types generated purely to help the debugger.
  15626. These encodings were defined at a time when the debugging information
  15627. format used was not powerful enough to describe some of the more complex
  15628. types available in Ada. Since DWARF allows us to express nearly all
  15629. Ada features, the long-term goal is to slowly replace these descriptive
  15630. types by their pure DWARF equivalent. To facilitate that transition,
  15631. a new maintenance option is available to force the debugger to ignore
  15632. those descriptive types. It allows the user to quickly evaluate how
  15633. well @value{GDBN} works without them.
  15634. @table @code
  15635. @kindex maint ada set ignore-descriptive-types
  15636. @item maintenance ada set ignore-descriptive-types [on|off]
  15637. Control whether the debugger should ignore descriptive types.
  15638. The default is not to ignore descriptives types (@code{off}).
  15639. @kindex maint ada show ignore-descriptive-types
  15640. @item maintenance ada show ignore-descriptive-types
  15641. Show if descriptive types are ignored by @value{GDBN}.
  15642. @end table
  15643. @node Unsupported Languages
  15644. @section Unsupported Languages
  15645. @cindex unsupported languages
  15646. @cindex minimal language
  15647. In addition to the other fully-supported programming languages,
  15648. @value{GDBN} also provides a pseudo-language, called @code{minimal}.
  15649. It does not represent a real programming language, but provides a set
  15650. of capabilities close to what the C or assembly languages provide.
  15651. This should allow most simple operations to be performed while debugging
  15652. an application that uses a language currently not supported by @value{GDBN}.
  15653. If the language is set to @code{auto}, @value{GDBN} will automatically
  15654. select this language if the current frame corresponds to an unsupported
  15655. language.
  15656. @node Symbols
  15657. @chapter Examining the Symbol Table
  15658. The commands described in this chapter allow you to inquire about the
  15659. symbols (names of variables, functions and types) defined in your
  15660. program. This information is inherent in the text of your program and
  15661. does not change as your program executes. @value{GDBN} finds it in your
  15662. program's symbol table, in the file indicated when you started @value{GDBN}
  15663. (@pxref{File Options, ,Choosing Files}), or by one of the
  15664. file-management commands (@pxref{Files, ,Commands to Specify Files}).
  15665. @cindex symbol names
  15666. @cindex names of symbols
  15667. @cindex quoting names
  15668. @anchor{quoting names}
  15669. Occasionally, you may need to refer to symbols that contain unusual
  15670. characters, which @value{GDBN} ordinarily treats as word delimiters. The
  15671. most frequent case is in referring to static variables in other
  15672. source files (@pxref{Variables,,Program Variables}). File names
  15673. are recorded in object files as debugging symbols, but @value{GDBN} would
  15674. ordinarily parse a typical file name, like @file{foo.c}, as the three words
  15675. @samp{foo} @samp{.} @samp{c}. To allow @value{GDBN} to recognize
  15676. @samp{foo.c} as a single symbol, enclose it in single quotes; for example,
  15677. @smallexample
  15678. p 'foo.c'::x
  15679. @end smallexample
  15680. @noindent
  15681. looks up the value of @code{x} in the scope of the file @file{foo.c}.
  15682. @table @code
  15683. @cindex case-insensitive symbol names
  15684. @cindex case sensitivity in symbol names
  15685. @kindex set case-sensitive
  15686. @item set case-sensitive on
  15687. @itemx set case-sensitive off
  15688. @itemx set case-sensitive auto
  15689. Normally, when @value{GDBN} looks up symbols, it matches their names
  15690. with case sensitivity determined by the current source language.
  15691. Occasionally, you may wish to control that. The command @code{set
  15692. case-sensitive} lets you do that by specifying @code{on} for
  15693. case-sensitive matches or @code{off} for case-insensitive ones. If
  15694. you specify @code{auto}, case sensitivity is reset to the default
  15695. suitable for the source language. The default is case-sensitive
  15696. matches for all languages except for Fortran, for which the default is
  15697. case-insensitive matches.
  15698. @kindex show case-sensitive
  15699. @item show case-sensitive
  15700. This command shows the current setting of case sensitivity for symbols
  15701. lookups.
  15702. @kindex set print type methods
  15703. @item set print type methods
  15704. @itemx set print type methods on
  15705. @itemx set print type methods off
  15706. Normally, when @value{GDBN} prints a class, it displays any methods
  15707. declared in that class. You can control this behavior either by
  15708. passing the appropriate flag to @code{ptype}, or using @command{set
  15709. print type methods}. Specifying @code{on} will cause @value{GDBN} to
  15710. display the methods; this is the default. Specifying @code{off} will
  15711. cause @value{GDBN} to omit the methods.
  15712. @kindex show print type methods
  15713. @item show print type methods
  15714. This command shows the current setting of method display when printing
  15715. classes.
  15716. @kindex set print type nested-type-limit
  15717. @item set print type nested-type-limit @var{limit}
  15718. @itemx set print type nested-type-limit unlimited
  15719. Set the limit of displayed nested types that the type printer will
  15720. show. A @var{limit} of @code{unlimited} or @code{-1} will show all
  15721. nested definitions. By default, the type printer will not show any nested
  15722. types defined in classes.
  15723. @kindex show print type nested-type-limit
  15724. @item show print type nested-type-limit
  15725. This command shows the current display limit of nested types when
  15726. printing classes.
  15727. @kindex set print type typedefs
  15728. @item set print type typedefs
  15729. @itemx set print type typedefs on
  15730. @itemx set print type typedefs off
  15731. Normally, when @value{GDBN} prints a class, it displays any typedefs
  15732. defined in that class. You can control this behavior either by
  15733. passing the appropriate flag to @code{ptype}, or using @command{set
  15734. print type typedefs}. Specifying @code{on} will cause @value{GDBN} to
  15735. display the typedef definitions; this is the default. Specifying
  15736. @code{off} will cause @value{GDBN} to omit the typedef definitions.
  15737. Note that this controls whether the typedef definition itself is
  15738. printed, not whether typedef names are substituted when printing other
  15739. types.
  15740. @kindex show print type typedefs
  15741. @item show print type typedefs
  15742. This command shows the current setting of typedef display when
  15743. printing classes.
  15744. @kindex set print type hex
  15745. @item set print type hex
  15746. @itemx set print type hex on
  15747. @itemx set print type hex off
  15748. When @value{GDBN} prints sizes and offsets of struct members, it can use
  15749. either the decimal or hexadecimal notation. You can select one or the
  15750. other either by passing the appropriate flag to @code{ptype}, or by using
  15751. the @command{set print type hex} command.
  15752. @kindex show print type hex
  15753. @item show print type hex
  15754. This command shows whether the sizes and offsets of struct members are
  15755. printed in decimal or hexadecimal notation.
  15756. @kindex info address
  15757. @cindex address of a symbol
  15758. @item info address @var{symbol}
  15759. Describe where the data for @var{symbol} is stored. For a register
  15760. variable, this says which register it is kept in. For a non-register
  15761. local variable, this prints the stack-frame offset at which the variable
  15762. is always stored.
  15763. Note the contrast with @samp{print &@var{symbol}}, which does not work
  15764. at all for a register variable, and for a stack local variable prints
  15765. the exact address of the current instantiation of the variable.
  15766. @kindex info symbol
  15767. @cindex symbol from address
  15768. @cindex closest symbol and offset for an address
  15769. @item info symbol @var{addr}
  15770. Print the name of a symbol which is stored at the address @var{addr}.
  15771. If no symbol is stored exactly at @var{addr}, @value{GDBN} prints the
  15772. nearest symbol and an offset from it:
  15773. @smallexample
  15774. (@value{GDBP}) info symbol 0x54320
  15775. _initialize_vx + 396 in section .text
  15776. @end smallexample
  15777. @noindent
  15778. This is the opposite of the @code{info address} command. You can use
  15779. it to find out the name of a variable or a function given its address.
  15780. For dynamically linked executables, the name of executable or shared
  15781. library containing the symbol is also printed:
  15782. @smallexample
  15783. (@value{GDBP}) info symbol 0x400225
  15784. _start + 5 in section .text of /tmp/a.out
  15785. (@value{GDBP}) info symbol 0x2aaaac2811cf
  15786. __read_nocancel + 6 in section .text of /usr/lib64/libc.so.6
  15787. @end smallexample
  15788. @kindex demangle
  15789. @cindex demangle
  15790. @item demangle @r{[}-l @var{language}@r{]} @r{[}@var{--}@r{]} @var{name}
  15791. Demangle @var{name}.
  15792. If @var{language} is provided it is the name of the language to demangle
  15793. @var{name} in. Otherwise @var{name} is demangled in the current language.
  15794. The @samp{--} option specifies the end of options,
  15795. and is useful when @var{name} begins with a dash.
  15796. The parameter @code{demangle-style} specifies how to interpret the kind
  15797. of mangling used. @xref{Print Settings}.
  15798. @kindex whatis
  15799. @item whatis[/@var{flags}] [@var{arg}]
  15800. Print the data type of @var{arg}, which can be either an expression
  15801. or a name of a data type. With no argument, print the data type of
  15802. @code{$}, the last value in the value history.
  15803. If @var{arg} is an expression (@pxref{Expressions, ,Expressions}), it
  15804. is not actually evaluated, and any side-effecting operations (such as
  15805. assignments or function calls) inside it do not take place.
  15806. If @var{arg} is a variable or an expression, @code{whatis} prints its
  15807. literal type as it is used in the source code. If the type was
  15808. defined using a @code{typedef}, @code{whatis} will @emph{not} print
  15809. the data type underlying the @code{typedef}. If the type of the
  15810. variable or the expression is a compound data type, such as
  15811. @code{struct} or @code{class}, @code{whatis} never prints their
  15812. fields or methods. It just prints the @code{struct}/@code{class}
  15813. name (a.k.a.@: its @dfn{tag}). If you want to see the members of
  15814. such a compound data type, use @code{ptype}.
  15815. If @var{arg} is a type name that was defined using @code{typedef},
  15816. @code{whatis} @dfn{unrolls} only one level of that @code{typedef}.
  15817. Unrolling means that @code{whatis} will show the underlying type used
  15818. in the @code{typedef} declaration of @var{arg}. However, if that
  15819. underlying type is also a @code{typedef}, @code{whatis} will not
  15820. unroll it.
  15821. For C code, the type names may also have the form @samp{class
  15822. @var{class-name}}, @samp{struct @var{struct-tag}}, @samp{union
  15823. @var{union-tag}} or @samp{enum @var{enum-tag}}.
  15824. @var{flags} can be used to modify how the type is displayed.
  15825. Available flags are:
  15826. @table @code
  15827. @item r
  15828. Display in ``raw'' form. Normally, @value{GDBN} substitutes template
  15829. parameters and typedefs defined in a class when printing the class'
  15830. members. The @code{/r} flag disables this.
  15831. @item m
  15832. Do not print methods defined in the class.
  15833. @item M
  15834. Print methods defined in the class. This is the default, but the flag
  15835. exists in case you change the default with @command{set print type methods}.
  15836. @item t
  15837. Do not print typedefs defined in the class. Note that this controls
  15838. whether the typedef definition itself is printed, not whether typedef
  15839. names are substituted when printing other types.
  15840. @item T
  15841. Print typedefs defined in the class. This is the default, but the flag
  15842. exists in case you change the default with @command{set print type typedefs}.
  15843. @item o
  15844. Print the offsets and sizes of fields in a struct, similar to what the
  15845. @command{pahole} tool does. This option implies the @code{/tm} flags.
  15846. @item x
  15847. Use hexadecimal notation when printing offsets and sizes of fields in a
  15848. struct.
  15849. @item d
  15850. Use decimal notation when printing offsets and sizes of fields in a
  15851. struct.
  15852. For example, given the following declarations:
  15853. @smallexample
  15854. struct tuv
  15855. @{
  15856. int a1;
  15857. char *a2;
  15858. int a3;
  15859. @};
  15860. struct xyz
  15861. @{
  15862. int f1;
  15863. char f2;
  15864. void *f3;
  15865. struct tuv f4;
  15866. @};
  15867. union qwe
  15868. @{
  15869. struct tuv fff1;
  15870. struct xyz fff2;
  15871. @};
  15872. struct tyu
  15873. @{
  15874. int a1 : 1;
  15875. int a2 : 3;
  15876. int a3 : 23;
  15877. char a4 : 2;
  15878. int64_t a5;
  15879. int a6 : 5;
  15880. int64_t a7 : 3;
  15881. @};
  15882. @end smallexample
  15883. Issuing a @kbd{ptype /o struct tuv} command would print:
  15884. @smallexample
  15885. (@value{GDBP}) ptype /o struct tuv
  15886. /* offset | size */ type = struct tuv @{
  15887. /* 0 | 4 */ int a1;
  15888. /* XXX 4-byte hole */
  15889. /* 8 | 8 */ char *a2;
  15890. /* 16 | 4 */ int a3;
  15891. /* total size (bytes): 24 */
  15892. @}
  15893. @end smallexample
  15894. Notice the format of the first column of comments. There, you can
  15895. find two parts separated by the @samp{|} character: the @emph{offset},
  15896. which indicates where the field is located inside the struct, in
  15897. bytes, and the @emph{size} of the field. Another interesting line is
  15898. the marker of a @emph{hole} in the struct, indicating that it may be
  15899. possible to pack the struct and make it use less space by reorganizing
  15900. its fields.
  15901. It is also possible to print offsets inside an union:
  15902. @smallexample
  15903. (@value{GDBP}) ptype /o union qwe
  15904. /* offset | size */ type = union qwe @{
  15905. /* 24 */ struct tuv @{
  15906. /* 0 | 4 */ int a1;
  15907. /* XXX 4-byte hole */
  15908. /* 8 | 8 */ char *a2;
  15909. /* 16 | 4 */ int a3;
  15910. /* total size (bytes): 24 */
  15911. @} fff1;
  15912. /* 40 */ struct xyz @{
  15913. /* 0 | 4 */ int f1;
  15914. /* 4 | 1 */ char f2;
  15915. /* XXX 3-byte hole */
  15916. /* 8 | 8 */ void *f3;
  15917. /* 16 | 24 */ struct tuv @{
  15918. /* 16 | 4 */ int a1;
  15919. /* XXX 4-byte hole */
  15920. /* 24 | 8 */ char *a2;
  15921. /* 32 | 4 */ int a3;
  15922. /* total size (bytes): 24 */
  15923. @} f4;
  15924. /* total size (bytes): 40 */
  15925. @} fff2;
  15926. /* total size (bytes): 40 */
  15927. @}
  15928. @end smallexample
  15929. In this case, since @code{struct tuv} and @code{struct xyz} occupy the
  15930. same space (because we are dealing with an union), the offset is not
  15931. printed for them. However, you can still examine the offset of each
  15932. of these structures' fields.
  15933. Another useful scenario is printing the offsets of a struct containing
  15934. bitfields:
  15935. @smallexample
  15936. (@value{GDBP}) ptype /o struct tyu
  15937. /* offset | size */ type = struct tyu @{
  15938. /* 0:31 | 4 */ int a1 : 1;
  15939. /* 0:28 | 4 */ int a2 : 3;
  15940. /* 0: 5 | 4 */ int a3 : 23;
  15941. /* 3: 3 | 1 */ signed char a4 : 2;
  15942. /* XXX 3-bit hole */
  15943. /* XXX 4-byte hole */
  15944. /* 8 | 8 */ int64_t a5;
  15945. /* 16: 0 | 4 */ int a6 : 5;
  15946. /* 16: 5 | 8 */ int64_t a7 : 3;
  15947. /* XXX 7-byte padding */
  15948. /* total size (bytes): 24 */
  15949. @}
  15950. @end smallexample
  15951. Note how the offset information is now extended to also include the
  15952. first bit of the bitfield.
  15953. @end table
  15954. @kindex ptype
  15955. @item ptype[/@var{flags}] [@var{arg}]
  15956. @code{ptype} accepts the same arguments as @code{whatis}, but prints a
  15957. detailed description of the type, instead of just the name of the type.
  15958. @xref{Expressions, ,Expressions}.
  15959. Contrary to @code{whatis}, @code{ptype} always unrolls any
  15960. @code{typedef}s in its argument declaration, whether the argument is
  15961. a variable, expression, or a data type. This means that @code{ptype}
  15962. of a variable or an expression will not print literally its type as
  15963. present in the source code---use @code{whatis} for that. @code{typedef}s at
  15964. the pointer or reference targets are also unrolled. Only @code{typedef}s of
  15965. fields, methods and inner @code{class typedef}s of @code{struct}s,
  15966. @code{class}es and @code{union}s are not unrolled even with @code{ptype}.
  15967. For example, for this variable declaration:
  15968. @smallexample
  15969. typedef double real_t;
  15970. struct complex @{ real_t real; double imag; @};
  15971. typedef struct complex complex_t;
  15972. complex_t var;
  15973. real_t *real_pointer_var;
  15974. @end smallexample
  15975. @noindent
  15976. the two commands give this output:
  15977. @smallexample
  15978. @group
  15979. (@value{GDBP}) whatis var
  15980. type = complex_t
  15981. (@value{GDBP}) ptype var
  15982. type = struct complex @{
  15983. real_t real;
  15984. double imag;
  15985. @}
  15986. (@value{GDBP}) whatis complex_t
  15987. type = struct complex
  15988. (@value{GDBP}) whatis struct complex
  15989. type = struct complex
  15990. (@value{GDBP}) ptype struct complex
  15991. type = struct complex @{
  15992. real_t real;
  15993. double imag;
  15994. @}
  15995. (@value{GDBP}) whatis real_pointer_var
  15996. type = real_t *
  15997. (@value{GDBP}) ptype real_pointer_var
  15998. type = double *
  15999. @end group
  16000. @end smallexample
  16001. @noindent
  16002. As with @code{whatis}, using @code{ptype} without an argument refers to
  16003. the type of @code{$}, the last value in the value history.
  16004. @cindex incomplete type
  16005. Sometimes, programs use opaque data types or incomplete specifications
  16006. of complex data structure. If the debug information included in the
  16007. program does not allow @value{GDBN} to display a full declaration of
  16008. the data type, it will say @samp{<incomplete type>}. For example,
  16009. given these declarations:
  16010. @smallexample
  16011. struct foo;
  16012. struct foo *fooptr;
  16013. @end smallexample
  16014. @noindent
  16015. but no definition for @code{struct foo} itself, @value{GDBN} will say:
  16016. @smallexample
  16017. (@value{GDBP}) ptype foo
  16018. $1 = <incomplete type>
  16019. @end smallexample
  16020. @noindent
  16021. ``Incomplete type'' is C terminology for data types that are not
  16022. completely specified.
  16023. @cindex unknown type
  16024. Othertimes, information about a variable's type is completely absent
  16025. from the debug information included in the program. This most often
  16026. happens when the program or library where the variable is defined
  16027. includes no debug information at all. @value{GDBN} knows the variable
  16028. exists from inspecting the linker/loader symbol table (e.g., the ELF
  16029. dynamic symbol table), but such symbols do not contain type
  16030. information. Inspecting the type of a (global) variable for which
  16031. @value{GDBN} has no type information shows:
  16032. @smallexample
  16033. (@value{GDBP}) ptype var
  16034. type = <data variable, no debug info>
  16035. @end smallexample
  16036. @xref{Variables, no debug info variables}, for how to print the values
  16037. of such variables.
  16038. @kindex info types
  16039. @item info types [-q] [@var{regexp}]
  16040. Print a brief description of all types whose names match the regular
  16041. expression @var{regexp} (or all types in your program, if you supply
  16042. no argument). Each complete typename is matched as though it were a
  16043. complete line; thus, @samp{i type value} gives information on all
  16044. types in your program whose names include the string @code{value}, but
  16045. @samp{i type ^value$} gives information only on types whose complete
  16046. name is @code{value}.
  16047. In programs using different languages, @value{GDBN} chooses the syntax
  16048. to print the type description according to the
  16049. @samp{set language} value: using @samp{set language auto}
  16050. (see @ref{Automatically, ,Set Language Automatically}) means to use the
  16051. language of the type, other values mean to use
  16052. the manually specified language (see @ref{Manually, ,Set Language Manually}).
  16053. This command differs from @code{ptype} in two ways: first, like
  16054. @code{whatis}, it does not print a detailed description; second, it
  16055. lists all source files and line numbers where a type is defined.
  16056. The output from @samp{into types} is proceeded with a header line
  16057. describing what types are being listed. The optional flag @samp{-q},
  16058. which stands for @samp{quiet}, disables printing this header
  16059. information.
  16060. @kindex info type-printers
  16061. @item info type-printers
  16062. Versions of @value{GDBN} that ship with Python scripting enabled may
  16063. have ``type printers'' available. When using @command{ptype} or
  16064. @command{whatis}, these printers are consulted when the name of a type
  16065. is needed. @xref{Type Printing API}, for more information on writing
  16066. type printers.
  16067. @code{info type-printers} displays all the available type printers.
  16068. @kindex enable type-printer
  16069. @kindex disable type-printer
  16070. @item enable type-printer @var{name}@dots{}
  16071. @item disable type-printer @var{name}@dots{}
  16072. These commands can be used to enable or disable type printers.
  16073. @kindex info scope
  16074. @cindex local variables
  16075. @item info scope @var{location}
  16076. List all the variables local to a particular scope. This command
  16077. accepts a @var{location} argument---a function name, a source line, or
  16078. an address preceded by a @samp{*}, and prints all the variables local
  16079. to the scope defined by that location. (@xref{Specify Location}, for
  16080. details about supported forms of @var{location}.) For example:
  16081. @smallexample
  16082. (@value{GDBP}) @b{info scope command_line_handler}
  16083. Scope for command_line_handler:
  16084. Symbol rl is an argument at stack/frame offset 8, length 4.
  16085. Symbol linebuffer is in static storage at address 0x150a18, length 4.
  16086. Symbol linelength is in static storage at address 0x150a1c, length 4.
  16087. Symbol p is a local variable in register $esi, length 4.
  16088. Symbol p1 is a local variable in register $ebx, length 4.
  16089. Symbol nline is a local variable in register $edx, length 4.
  16090. Symbol repeat is a local variable at frame offset -8, length 4.
  16091. @end smallexample
  16092. @noindent
  16093. This command is especially useful for determining what data to collect
  16094. during a @dfn{trace experiment}, see @ref{Tracepoint Actions,
  16095. collect}.
  16096. @kindex info source
  16097. @item info source
  16098. Show information about the current source file---that is, the source file for
  16099. the function containing the current point of execution:
  16100. @itemize @bullet
  16101. @item
  16102. the name of the source file, and the directory containing it,
  16103. @item
  16104. the directory it was compiled in,
  16105. @item
  16106. its length, in lines,
  16107. @item
  16108. which programming language it is written in,
  16109. @item
  16110. if the debug information provides it, the program that compiled the file
  16111. (which may include, e.g., the compiler version and command line arguments),
  16112. @item
  16113. whether the executable includes debugging information for that file, and
  16114. if so, what format the information is in (e.g., STABS, Dwarf 2, etc.), and
  16115. @item
  16116. whether the debugging information includes information about
  16117. preprocessor macros.
  16118. @end itemize
  16119. @kindex info sources
  16120. @item info sources @r{[}-dirname | -basename@r{]} @r{[}--@r{]} @r{[}@var{regexp}@r{]}
  16121. With no options @samp{info sources} prints the names of all source
  16122. files in your program for which there is debugging information. The
  16123. source files are presented based on a list of object files
  16124. (executables and libraries) currently loaded into @value{GDBN}. For
  16125. each object file all of the associated source files are listed.
  16126. Each source file will only be printed once for each object file, but a
  16127. single source file can be repeated in the output if it is part of
  16128. multiple object files.
  16129. If the optional @var{regexp} is provided, then only source files that
  16130. match the regular expression will be printed. The matching is
  16131. case-sensitive, except on operating systems that have case-insensitive
  16132. filesystem (e.g., MS-Windows). @samp{--} can be used before
  16133. @var{regexp} to prevent @value{GDBN} interpreting @var{regexp} as a
  16134. command option (e.g. if @var{regexp} starts with @samp{-}).
  16135. By default, the @var{regexp} is used to match anywhere in the
  16136. filename. If @code{-dirname}, only files having a dirname matching
  16137. @var{regexp} are shown. If @code{-basename}, only files having a
  16138. basename matching @var{regexp} are shown.
  16139. It is possible that an object file may be printed in the list with no
  16140. associated source files. This can happen when either no source files
  16141. match @var{regexp}, or, the object file was compiled without debug
  16142. information and so @value{GDBN} is unable to find any source file
  16143. names.
  16144. @kindex info functions
  16145. @item info functions [-q] [-n]
  16146. Print the names and data types of all defined functions.
  16147. Similarly to @samp{info types}, this command groups its output by source
  16148. files and annotates each function definition with its source line
  16149. number.
  16150. In programs using different languages, @value{GDBN} chooses the syntax
  16151. to print the function name and type according to the
  16152. @samp{set language} value: using @samp{set language auto}
  16153. (see @ref{Automatically, ,Set Language Automatically}) means to use the
  16154. language of the function, other values mean to use
  16155. the manually specified language (see @ref{Manually, ,Set Language Manually}).
  16156. The @samp{-n} flag excludes @dfn{non-debugging symbols} from the
  16157. results. A non-debugging symbol is a symbol that comes from the
  16158. executable's symbol table, not from the debug information (for
  16159. example, DWARF) associated with the executable.
  16160. The optional flag @samp{-q}, which stands for @samp{quiet}, disables
  16161. printing header information and messages explaining why no functions
  16162. have been printed.
  16163. @item info functions [-q] [-n] [-t @var{type_regexp}] [@var{regexp}]
  16164. Like @samp{info functions}, but only print the names and data types
  16165. of the functions selected with the provided regexp(s).
  16166. If @var{regexp} is provided, print only the functions whose names
  16167. match the regular expression @var{regexp}.
  16168. Thus, @samp{info fun step} finds all functions whose
  16169. names include @code{step}; @samp{info fun ^step} finds those whose names
  16170. start with @code{step}. If a function name contains characters that
  16171. conflict with the regular expression language (e.g.@:
  16172. @samp{operator*()}), they may be quoted with a backslash.
  16173. If @var{type_regexp} is provided, print only the functions whose
  16174. types, as printed by the @code{whatis} command, match
  16175. the regular expression @var{type_regexp}.
  16176. If @var{type_regexp} contains space(s), it should be enclosed in
  16177. quote characters. If needed, use backslash to escape the meaning
  16178. of special characters or quotes.
  16179. Thus, @samp{info fun -t '^int ('} finds the functions that return
  16180. an integer; @samp{info fun -t '(.*int.*'} finds the functions that
  16181. have an argument type containing int; @samp{info fun -t '^int (' ^step}
  16182. finds the functions whose names start with @code{step} and that return
  16183. int.
  16184. If both @var{regexp} and @var{type_regexp} are provided, a function
  16185. is printed only if its name matches @var{regexp} and its type matches
  16186. @var{type_regexp}.
  16187. @kindex info variables
  16188. @item info variables [-q] [-n]
  16189. Print the names and data types of all variables that are defined
  16190. outside of functions (i.e.@: excluding local variables).
  16191. The printed variables are grouped by source files and annotated with
  16192. their respective source line numbers.
  16193. In programs using different languages, @value{GDBN} chooses the syntax
  16194. to print the variable name and type according to the
  16195. @samp{set language} value: using @samp{set language auto}
  16196. (see @ref{Automatically, ,Set Language Automatically}) means to use the
  16197. language of the variable, other values mean to use
  16198. the manually specified language (see @ref{Manually, ,Set Language Manually}).
  16199. The @samp{-n} flag excludes non-debugging symbols from the results.
  16200. The optional flag @samp{-q}, which stands for @samp{quiet}, disables
  16201. printing header information and messages explaining why no variables
  16202. have been printed.
  16203. @item info variables [-q] [-n] [-t @var{type_regexp}] [@var{regexp}]
  16204. Like @kbd{info variables}, but only print the variables selected
  16205. with the provided regexp(s).
  16206. If @var{regexp} is provided, print only the variables whose names
  16207. match the regular expression @var{regexp}.
  16208. If @var{type_regexp} is provided, print only the variables whose
  16209. types, as printed by the @code{whatis} command, match
  16210. the regular expression @var{type_regexp}.
  16211. If @var{type_regexp} contains space(s), it should be enclosed in
  16212. quote characters. If needed, use backslash to escape the meaning
  16213. of special characters or quotes.
  16214. If both @var{regexp} and @var{type_regexp} are provided, an argument
  16215. is printed only if its name matches @var{regexp} and its type matches
  16216. @var{type_regexp}.
  16217. @kindex info modules
  16218. @cindex modules
  16219. @item info modules @r{[}-q@r{]} @r{[}@var{regexp}@r{]}
  16220. List all Fortran modules in the program, or all modules matching the
  16221. optional regular expression @var{regexp}.
  16222. The optional flag @samp{-q}, which stands for @samp{quiet}, disables
  16223. printing header information and messages explaining why no modules
  16224. have been printed.
  16225. @kindex info module
  16226. @cindex Fortran modules, information about
  16227. @cindex functions and variables by Fortran module
  16228. @cindex module functions and variables
  16229. @item info module functions @r{[}-q@r{]} @r{[}-m @var{module-regexp}@r{]} @r{[}-t @var{type-regexp}@r{]} @r{[}@var{regexp}@r{]}
  16230. @itemx info module variables @r{[}-q@r{]} @r{[}-m @var{module-regexp}@r{]} @r{[}-t @var{type-regexp}@r{]} @r{[}@var{regexp}@r{]}
  16231. List all functions or variables within all Fortran modules. The set
  16232. of functions or variables listed can be limited by providing some or
  16233. all of the optional regular expressions. If @var{module-regexp} is
  16234. provided, then only Fortran modules matching @var{module-regexp} will
  16235. be searched. Only functions or variables whose type matches the
  16236. optional regular expression @var{type-regexp} will be listed. And
  16237. only functions or variables whose name matches the optional regular
  16238. expression @var{regexp} will be listed.
  16239. The optional flag @samp{-q}, which stands for @samp{quiet}, disables
  16240. printing header information and messages explaining why no functions
  16241. or variables have been printed.
  16242. @kindex info classes
  16243. @cindex Objective-C, classes and selectors
  16244. @item info classes
  16245. @itemx info classes @var{regexp}
  16246. Display all Objective-C classes in your program, or
  16247. (with the @var{regexp} argument) all those matching a particular regular
  16248. expression.
  16249. @kindex info selectors
  16250. @item info selectors
  16251. @itemx info selectors @var{regexp}
  16252. Display all Objective-C selectors in your program, or
  16253. (with the @var{regexp} argument) all those matching a particular regular
  16254. expression.
  16255. @ignore
  16256. This was never implemented.
  16257. @kindex info methods
  16258. @item info methods
  16259. @itemx info methods @var{regexp}
  16260. The @code{info methods} command permits the user to examine all defined
  16261. methods within C@t{++} program, or (with the @var{regexp} argument) a
  16262. specific set of methods found in the various C@t{++} classes. Many
  16263. C@t{++} classes provide a large number of methods. Thus, the output
  16264. from the @code{ptype} command can be overwhelming and hard to use. The
  16265. @code{info-methods} command filters the methods, printing only those
  16266. which match the regular-expression @var{regexp}.
  16267. @end ignore
  16268. @cindex opaque data types
  16269. @kindex set opaque-type-resolution
  16270. @item set opaque-type-resolution on
  16271. Tell @value{GDBN} to resolve opaque types. An opaque type is a type
  16272. declared as a pointer to a @code{struct}, @code{class}, or
  16273. @code{union}---for example, @code{struct MyType *}---that is used in one
  16274. source file although the full declaration of @code{struct MyType} is in
  16275. another source file. The default is on.
  16276. A change in the setting of this subcommand will not take effect until
  16277. the next time symbols for a file are loaded.
  16278. @item set opaque-type-resolution off
  16279. Tell @value{GDBN} not to resolve opaque types. In this case, the type
  16280. is printed as follows:
  16281. @smallexample
  16282. @{<no data fields>@}
  16283. @end smallexample
  16284. @kindex show opaque-type-resolution
  16285. @item show opaque-type-resolution
  16286. Show whether opaque types are resolved or not.
  16287. @kindex set print symbol-loading
  16288. @cindex print messages when symbols are loaded
  16289. @item set print symbol-loading
  16290. @itemx set print symbol-loading full
  16291. @itemx set print symbol-loading brief
  16292. @itemx set print symbol-loading off
  16293. The @code{set print symbol-loading} command allows you to control the
  16294. printing of messages when @value{GDBN} loads symbol information.
  16295. By default a message is printed for the executable and one for each
  16296. shared library, and normally this is what you want. However, when
  16297. debugging apps with large numbers of shared libraries these messages
  16298. can be annoying.
  16299. When set to @code{brief} a message is printed for each executable,
  16300. and when @value{GDBN} loads a collection of shared libraries at once
  16301. it will only print one message regardless of the number of shared
  16302. libraries. When set to @code{off} no messages are printed.
  16303. @kindex show print symbol-loading
  16304. @item show print symbol-loading
  16305. Show whether messages will be printed when a @value{GDBN} command
  16306. entered from the keyboard causes symbol information to be loaded.
  16307. @kindex maint print symbols
  16308. @cindex symbol dump
  16309. @kindex maint print psymbols
  16310. @cindex partial symbol dump
  16311. @kindex maint print msymbols
  16312. @cindex minimal symbol dump
  16313. @item maint print symbols @r{[}-pc @var{address}@r{]} @r{[}@var{filename}@r{]}
  16314. @itemx maint print symbols @r{[}-objfile @var{objfile}@r{]} @r{[}-source @var{source}@r{]} @r{[}--@r{]} @r{[}@var{filename}@r{]}
  16315. @itemx maint print psymbols @r{[}-objfile @var{objfile}@r{]} @r{[}-pc @var{address}@r{]} @r{[}--@r{]} @r{[}@var{filename}@r{]}
  16316. @itemx maint print psymbols @r{[}-objfile @var{objfile}@r{]} @r{[}-source @var{source}@r{]} @r{[}--@r{]} @r{[}@var{filename}@r{]}
  16317. @itemx maint print msymbols @r{[}-objfile @var{objfile}@r{]} @r{[}--@r{]} @r{[}@var{filename}@r{]}
  16318. Write a dump of debugging symbol data into the file @var{filename} or
  16319. the terminal if @var{filename} is unspecified.
  16320. If @code{-objfile @var{objfile}} is specified, only dump symbols for
  16321. that objfile.
  16322. If @code{-pc @var{address}} is specified, only dump symbols for the file
  16323. with code at that address. Note that @var{address} may be a symbol like
  16324. @code{main}.
  16325. If @code{-source @var{source}} is specified, only dump symbols for that
  16326. source file.
  16327. These commands are used to debug the @value{GDBN} symbol-reading code.
  16328. These commands do not modify internal @value{GDBN} state, therefore
  16329. @samp{maint print symbols} will only print symbols for already expanded symbol
  16330. tables.
  16331. You can use the command @code{info sources} to find out which files these are.
  16332. If you use @samp{maint print psymbols} instead, the dump shows information
  16333. about symbols that @value{GDBN} only knows partially---that is, symbols
  16334. defined in files that @value{GDBN} has skimmed, but not yet read completely.
  16335. Finally, @samp{maint print msymbols} just dumps ``minimal symbols'', e.g.,
  16336. ``ELF symbols''.
  16337. @xref{Files, ,Commands to Specify Files}, for a discussion of how
  16338. @value{GDBN} reads symbols (in the description of @code{symbol-file}).
  16339. @kindex maint info symtabs
  16340. @kindex maint info psymtabs
  16341. @cindex listing @value{GDBN}'s internal symbol tables
  16342. @cindex symbol tables, listing @value{GDBN}'s internal
  16343. @cindex full symbol tables, listing @value{GDBN}'s internal
  16344. @cindex partial symbol tables, listing @value{GDBN}'s internal
  16345. @item maint info symtabs @r{[} @var{regexp} @r{]}
  16346. @itemx maint info psymtabs @r{[} @var{regexp} @r{]}
  16347. List the @code{struct symtab} or @code{struct partial_symtab}
  16348. structures whose names match @var{regexp}. If @var{regexp} is not
  16349. given, list them all. The output includes expressions which you can
  16350. copy into a @value{GDBN} debugging this one to examine a particular
  16351. structure in more detail. For example:
  16352. @smallexample
  16353. (@value{GDBP}) maint info psymtabs dwarf2read
  16354. @{ objfile /home/gnu/build/gdb/gdb
  16355. ((struct objfile *) 0x82e69d0)
  16356. @{ psymtab /home/gnu/src/gdb/dwarf2read.c
  16357. ((struct partial_symtab *) 0x8474b10)
  16358. readin no
  16359. fullname (null)
  16360. text addresses 0x814d3c8 -- 0x8158074
  16361. globals (* (struct partial_symbol **) 0x8507a08 @@ 9)
  16362. statics (* (struct partial_symbol **) 0x40e95b78 @@ 2882)
  16363. dependencies (none)
  16364. @}
  16365. @}
  16366. (@value{GDBP}) maint info symtabs
  16367. (@value{GDBP})
  16368. @end smallexample
  16369. @noindent
  16370. We see that there is one partial symbol table whose filename contains
  16371. the string @samp{dwarf2read}, belonging to the @samp{gdb} executable;
  16372. and we see that @value{GDBN} has not read in any symtabs yet at all.
  16373. If we set a breakpoint on a function, that will cause @value{GDBN} to
  16374. read the symtab for the compilation unit containing that function:
  16375. @smallexample
  16376. (@value{GDBP}) break dwarf2_psymtab_to_symtab
  16377. Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
  16378. line 1574.
  16379. (@value{GDBP}) maint info symtabs
  16380. @{ objfile /home/gnu/build/gdb/gdb
  16381. ((struct objfile *) 0x82e69d0)
  16382. @{ symtab /home/gnu/src/gdb/dwarf2read.c
  16383. ((struct symtab *) 0x86c1f38)
  16384. dirname (null)
  16385. fullname (null)
  16386. blockvector ((struct blockvector *) 0x86c1bd0) (primary)
  16387. linetable ((struct linetable *) 0x8370fa0)
  16388. debugformat DWARF 2
  16389. @}
  16390. @}
  16391. (@value{GDBP})
  16392. @end smallexample
  16393. @kindex maint info line-table
  16394. @cindex listing @value{GDBN}'s internal line tables
  16395. @cindex line tables, listing @value{GDBN}'s internal
  16396. @item maint info line-table @r{[} @var{regexp} @r{]}
  16397. List the @code{struct linetable} from all @code{struct symtab}
  16398. instances whose name matches @var{regexp}. If @var{regexp} is not
  16399. given, list the @code{struct linetable} from all @code{struct symtab}.
  16400. For example:
  16401. @smallexample
  16402. (@value{GDBP}) maint info line-table
  16403. objfile: /home/gnu/build/a.out ((struct objfile *) 0x6120000e0d40)
  16404. compunit_symtab: simple.cpp ((struct compunit_symtab *) 0x6210000ff450)
  16405. symtab: /home/gnu/src/simple.cpp ((struct symtab *) 0x6210000ff4d0)
  16406. linetable: ((struct linetable *) 0x62100012b760):
  16407. INDEX LINE ADDRESS IS-STMT PROLOGUE-END
  16408. 0 3 0x0000000000401110 Y
  16409. 1 4 0x0000000000401114 Y Y
  16410. 2 9 0x0000000000401120 Y
  16411. 3 10 0x0000000000401124 Y Y
  16412. 4 10 0x0000000000401129
  16413. 5 15 0x0000000000401130 Y
  16414. 6 16 0x0000000000401134 Y Y
  16415. 7 16 0x0000000000401139
  16416. 8 21 0x0000000000401140 Y
  16417. 9 22 0x000000000040114f Y Y
  16418. 10 22 0x0000000000401154
  16419. 11 END 0x000000000040115a Y
  16420. @end smallexample
  16421. @noindent
  16422. The @samp{IS-STMT} column indicates if the address is a recommended breakpoint
  16423. location to represent a line or a statement. The @samp{PROLOGUE-END} column
  16424. indicates that a given address is an adequate place to set a breakpoint at the
  16425. first instruction following a function prologue.
  16426. @kindex maint set symbol-cache-size
  16427. @cindex symbol cache size
  16428. @item maint set symbol-cache-size @var{size}
  16429. Set the size of the symbol cache to @var{size}.
  16430. The default size is intended to be good enough for debugging
  16431. most applications. This option exists to allow for experimenting
  16432. with different sizes.
  16433. @kindex maint show symbol-cache-size
  16434. @item maint show symbol-cache-size
  16435. Show the size of the symbol cache.
  16436. @kindex maint print symbol-cache
  16437. @cindex symbol cache, printing its contents
  16438. @item maint print symbol-cache
  16439. Print the contents of the symbol cache.
  16440. This is useful when debugging symbol cache issues.
  16441. @kindex maint print symbol-cache-statistics
  16442. @cindex symbol cache, printing usage statistics
  16443. @item maint print symbol-cache-statistics
  16444. Print symbol cache usage statistics.
  16445. This helps determine how well the cache is being utilized.
  16446. @kindex maint flush symbol-cache
  16447. @kindex maint flush-symbol-cache
  16448. @cindex symbol cache, flushing
  16449. @item maint flush symbol-cache
  16450. @itemx maint flush-symbol-cache
  16451. Flush the contents of the symbol cache, all entries are removed. This
  16452. command is useful when debugging the symbol cache. It is also useful
  16453. when collecting performance data. The command @code{maint
  16454. flush-symbol-cache} is deprecated in favor of @code{maint flush
  16455. symbol-cache}..
  16456. @kindex maint set ignore-prologue-end-flag
  16457. @cindex prologue-end
  16458. @item maint set ignore-prologue-end-flag [on|off]
  16459. Enable or disable the use of the @samp{PROLOGUE-END} flag from the line-table.
  16460. When @samp{off} (the default), @value{GDBN} uses the @samp{PROLOGUE-END} flag
  16461. to place breakpoints past the end of a function prologue. When @samp{on},
  16462. @value{GDBN} ignores the flag and relies on prologue analyzers to skip function
  16463. prologues.
  16464. @kindex maint show ignore-prologue-end-flag
  16465. @item maint show ignore-prologue-end-flag
  16466. Show whether @value{GDBN} will ignore the @samp{PROLOGUE-END} flag.
  16467. @end table
  16468. @node Altering
  16469. @chapter Altering Execution
  16470. Once you think you have found an error in your program, you might want to
  16471. find out for certain whether correcting the apparent error would lead to
  16472. correct results in the rest of the run. You can find the answer by
  16473. experiment, using the @value{GDBN} features for altering execution of the
  16474. program.
  16475. For example, you can store new values into variables or memory
  16476. locations, give your program a signal, restart it at a different
  16477. address, or even return prematurely from a function.
  16478. @menu
  16479. * Assignment:: Assignment to variables
  16480. * Jumping:: Continuing at a different address
  16481. * Signaling:: Giving your program a signal
  16482. * Returning:: Returning from a function
  16483. * Calling:: Calling your program's functions
  16484. * Patching:: Patching your program
  16485. * Compiling and Injecting Code:: Compiling and injecting code in @value{GDBN}
  16486. @end menu
  16487. @node Assignment
  16488. @section Assignment to Variables
  16489. @cindex assignment
  16490. @cindex setting variables
  16491. To alter the value of a variable, evaluate an assignment expression.
  16492. @xref{Expressions, ,Expressions}. For example,
  16493. @smallexample
  16494. print x=4
  16495. @end smallexample
  16496. @noindent
  16497. stores the value 4 into the variable @code{x}, and then prints the
  16498. value of the assignment expression (which is 4).
  16499. @xref{Languages, ,Using @value{GDBN} with Different Languages}, for more
  16500. information on operators in supported languages.
  16501. @kindex set variable
  16502. @cindex variables, setting
  16503. If you are not interested in seeing the value of the assignment, use the
  16504. @code{set} command instead of the @code{print} command. @code{set} is
  16505. really the same as @code{print} except that the expression's value is
  16506. not printed and is not put in the value history (@pxref{Value History,
  16507. ,Value History}). The expression is evaluated only for its effects.
  16508. If the beginning of the argument string of the @code{set} command
  16509. appears identical to a @code{set} subcommand, use the @code{set
  16510. variable} command instead of just @code{set}. This command is identical
  16511. to @code{set} except for its lack of subcommands. For example, if your
  16512. program has a variable @code{width}, you get an error if you try to set
  16513. a new value with just @samp{set width=13}, because @value{GDBN} has the
  16514. command @code{set width}:
  16515. @smallexample
  16516. (@value{GDBP}) whatis width
  16517. type = double
  16518. (@value{GDBP}) p width
  16519. $4 = 13
  16520. (@value{GDBP}) set width=47
  16521. Invalid syntax in expression.
  16522. @end smallexample
  16523. @noindent
  16524. The invalid expression, of course, is @samp{=47}. In
  16525. order to actually set the program's variable @code{width}, use
  16526. @smallexample
  16527. (@value{GDBP}) set var width=47
  16528. @end smallexample
  16529. Because the @code{set} command has many subcommands that can conflict
  16530. with the names of program variables, it is a good idea to use the
  16531. @code{set variable} command instead of just @code{set}. For example, if
  16532. your program has a variable @code{g}, you run into problems if you try
  16533. to set a new value with just @samp{set g=4}, because @value{GDBN} has
  16534. the command @code{set gnutarget}, abbreviated @code{set g}:
  16535. @smallexample
  16536. @group
  16537. (@value{GDBP}) whatis g
  16538. type = double
  16539. (@value{GDBP}) p g
  16540. $1 = 1
  16541. (@value{GDBP}) set g=4
  16542. (@value{GDBP}) p g
  16543. $2 = 1
  16544. (@value{GDBP}) r
  16545. The program being debugged has been started already.
  16546. Start it from the beginning? (y or n) y
  16547. Starting program: /home/smith/cc_progs/a.out
  16548. "/home/smith/cc_progs/a.out": can't open to read symbols:
  16549. Invalid bfd target.
  16550. (@value{GDBP}) show g
  16551. The current BFD target is "=4".
  16552. @end group
  16553. @end smallexample
  16554. @noindent
  16555. The program variable @code{g} did not change, and you silently set the
  16556. @code{gnutarget} to an invalid value. In order to set the variable
  16557. @code{g}, use
  16558. @smallexample
  16559. (@value{GDBP}) set var g=4
  16560. @end smallexample
  16561. @value{GDBN} allows more implicit conversions in assignments than C; you can
  16562. freely store an integer value into a pointer variable or vice versa,
  16563. and you can convert any structure to any other structure that is the
  16564. same length or shorter.
  16565. @comment FIXME: how do structs align/pad in these conversions?
  16566. @comment /doc@cygnus.com 18dec1990
  16567. To store values into arbitrary places in memory, use the @samp{@{@dots{}@}}
  16568. construct to generate a value of specified type at a specified address
  16569. (@pxref{Expressions, ,Expressions}). For example, @code{@{int@}0x83040} refers
  16570. to memory location @code{0x83040} as an integer (which implies a certain size
  16571. and representation in memory), and
  16572. @smallexample
  16573. set @{int@}0x83040 = 4
  16574. @end smallexample
  16575. @noindent
  16576. stores the value 4 into that memory location.
  16577. @node Jumping
  16578. @section Continuing at a Different Address
  16579. Ordinarily, when you continue your program, you do so at the place where
  16580. it stopped, with the @code{continue} command. You can instead continue at
  16581. an address of your own choosing, with the following commands:
  16582. @table @code
  16583. @kindex jump
  16584. @kindex j @r{(@code{jump})}
  16585. @item jump @var{location}
  16586. @itemx j @var{location}
  16587. Resume execution at @var{location}. Execution stops again immediately
  16588. if there is a breakpoint there. @xref{Specify Location}, for a description
  16589. of the different forms of @var{location}. It is common
  16590. practice to use the @code{tbreak} command in conjunction with
  16591. @code{jump}. @xref{Set Breaks, ,Setting Breakpoints}.
  16592. The @code{jump} command does not change the current stack frame, or
  16593. the stack pointer, or the contents of any memory location or any
  16594. register other than the program counter. If @var{location} is in
  16595. a different function from the one currently executing, the results may
  16596. be bizarre if the two functions expect different patterns of arguments or
  16597. of local variables. For this reason, the @code{jump} command requests
  16598. confirmation if the specified line is not in the function currently
  16599. executing. However, even bizarre results are predictable if you are
  16600. well acquainted with the machine-language code of your program.
  16601. @end table
  16602. On many systems, you can get much the same effect as the @code{jump}
  16603. command by storing a new value into the register @code{$pc}. The
  16604. difference is that this does not start your program running; it only
  16605. changes the address of where it @emph{will} run when you continue. For
  16606. example,
  16607. @smallexample
  16608. set $pc = 0x485
  16609. @end smallexample
  16610. @noindent
  16611. makes the next @code{continue} command or stepping command execute at
  16612. address @code{0x485}, rather than at the address where your program stopped.
  16613. @xref{Continuing and Stepping, ,Continuing and Stepping}.
  16614. The most common occasion to use the @code{jump} command is to back
  16615. up---perhaps with more breakpoints set---over a portion of a program
  16616. that has already executed, in order to examine its execution in more
  16617. detail.
  16618. @c @group
  16619. @node Signaling
  16620. @section Giving your Program a Signal
  16621. @cindex deliver a signal to a program
  16622. @table @code
  16623. @kindex signal
  16624. @item signal @var{signal}
  16625. Resume execution where your program is stopped, but immediately give it the
  16626. signal @var{signal}. The @var{signal} can be the name or the number of a
  16627. signal. For example, on many systems @code{signal 2} and @code{signal
  16628. SIGINT} are both ways of sending an interrupt signal.
  16629. Alternatively, if @var{signal} is zero, continue execution without
  16630. giving a signal. This is useful when your program stopped on account of
  16631. a signal and would ordinarily see the signal when resumed with the
  16632. @code{continue} command; @samp{signal 0} causes it to resume without a
  16633. signal.
  16634. @emph{Note:} When resuming a multi-threaded program, @var{signal} is
  16635. delivered to the currently selected thread, not the thread that last
  16636. reported a stop. This includes the situation where a thread was
  16637. stopped due to a signal. So if you want to continue execution
  16638. suppressing the signal that stopped a thread, you should select that
  16639. same thread before issuing the @samp{signal 0} command. If you issue
  16640. the @samp{signal 0} command with another thread as the selected one,
  16641. @value{GDBN} detects that and asks for confirmation.
  16642. Invoking the @code{signal} command is not the same as invoking the
  16643. @code{kill} utility from the shell. Sending a signal with @code{kill}
  16644. causes @value{GDBN} to decide what to do with the signal depending on
  16645. the signal handling tables (@pxref{Signals}). The @code{signal} command
  16646. passes the signal directly to your program.
  16647. @code{signal} does not repeat when you press @key{RET} a second time
  16648. after executing the command.
  16649. @kindex queue-signal
  16650. @item queue-signal @var{signal}
  16651. Queue @var{signal} to be delivered immediately to the current thread
  16652. when execution of the thread resumes. The @var{signal} can be the name or
  16653. the number of a signal. For example, on many systems @code{signal 2} and
  16654. @code{signal SIGINT} are both ways of sending an interrupt signal.
  16655. The handling of the signal must be set to pass the signal to the program,
  16656. otherwise @value{GDBN} will report an error.
  16657. You can control the handling of signals from @value{GDBN} with the
  16658. @code{handle} command (@pxref{Signals}).
  16659. Alternatively, if @var{signal} is zero, any currently queued signal
  16660. for the current thread is discarded and when execution resumes no signal
  16661. will be delivered. This is useful when your program stopped on account
  16662. of a signal and would ordinarily see the signal when resumed with the
  16663. @code{continue} command.
  16664. This command differs from the @code{signal} command in that the signal
  16665. is just queued, execution is not resumed. And @code{queue-signal} cannot
  16666. be used to pass a signal whose handling state has been set to @code{nopass}
  16667. (@pxref{Signals}).
  16668. @end table
  16669. @c @end group
  16670. @xref{stepping into signal handlers}, for information on how stepping
  16671. commands behave when the thread has a signal queued.
  16672. @node Returning
  16673. @section Returning from a Function
  16674. @table @code
  16675. @cindex returning from a function
  16676. @kindex return
  16677. @item return
  16678. @itemx return @var{expression}
  16679. You can cancel execution of a function call with the @code{return}
  16680. command. If you give an
  16681. @var{expression} argument, its value is used as the function's return
  16682. value.
  16683. @end table
  16684. When you use @code{return}, @value{GDBN} discards the selected stack frame
  16685. (and all frames within it). You can think of this as making the
  16686. discarded frame return prematurely. If you wish to specify a value to
  16687. be returned, give that value as the argument to @code{return}.
  16688. This pops the selected stack frame (@pxref{Selection, ,Selecting a
  16689. Frame}), and any other frames inside of it, leaving its caller as the
  16690. innermost remaining frame. That frame becomes selected. The
  16691. specified value is stored in the registers used for returning values
  16692. of functions.
  16693. The @code{return} command does not resume execution; it leaves the
  16694. program stopped in the state that would exist if the function had just
  16695. returned. In contrast, the @code{finish} command (@pxref{Continuing
  16696. and Stepping, ,Continuing and Stepping}) resumes execution until the
  16697. selected stack frame returns naturally.
  16698. @value{GDBN} needs to know how the @var{expression} argument should be set for
  16699. the inferior. The concrete registers assignment depends on the OS ABI and the
  16700. type being returned by the selected stack frame. For example it is common for
  16701. OS ABI to return floating point values in FPU registers while integer values in
  16702. CPU registers. Still some ABIs return even floating point values in CPU
  16703. registers. Larger integer widths (such as @code{long long int}) also have
  16704. specific placement rules. @value{GDBN} already knows the OS ABI from its
  16705. current target so it needs to find out also the type being returned to make the
  16706. assignment into the right register(s).
  16707. Normally, the selected stack frame has debug info. @value{GDBN} will always
  16708. use the debug info instead of the implicit type of @var{expression} when the
  16709. debug info is available. For example, if you type @kbd{return -1}, and the
  16710. function in the current stack frame is declared to return a @code{long long
  16711. int}, @value{GDBN} transparently converts the implicit @code{int} value of -1
  16712. into a @code{long long int}:
  16713. @smallexample
  16714. Breakpoint 1, func () at gdb.base/return-nodebug.c:29
  16715. 29 return 31;
  16716. (@value{GDBP}) return -1
  16717. Make func return now? (y or n) y
  16718. #0 0x004004f6 in main () at gdb.base/return-nodebug.c:43
  16719. 43 printf ("result=%lld\n", func ());
  16720. (@value{GDBP})
  16721. @end smallexample
  16722. However, if the selected stack frame does not have a debug info, e.g., if the
  16723. function was compiled without debug info, @value{GDBN} has to find out the type
  16724. to return from user. Specifying a different type by mistake may set the value
  16725. in different inferior registers than the caller code expects. For example,
  16726. typing @kbd{return -1} with its implicit type @code{int} would set only a part
  16727. of a @code{long long int} result for a debug info less function (on 32-bit
  16728. architectures). Therefore the user is required to specify the return type by
  16729. an appropriate cast explicitly:
  16730. @smallexample
  16731. Breakpoint 2, 0x0040050b in func ()
  16732. (@value{GDBP}) return -1
  16733. Return value type not available for selected stack frame.
  16734. Please use an explicit cast of the value to return.
  16735. (@value{GDBP}) return (long long int) -1
  16736. Make selected stack frame return now? (y or n) y
  16737. #0 0x00400526 in main ()
  16738. (@value{GDBP})
  16739. @end smallexample
  16740. @node Calling
  16741. @section Calling Program Functions
  16742. @table @code
  16743. @cindex calling functions
  16744. @cindex inferior functions, calling
  16745. @item print @var{expr}
  16746. Evaluate the expression @var{expr} and display the resulting value.
  16747. The expression may include calls to functions in the program being
  16748. debugged.
  16749. @kindex call
  16750. @item call @var{expr}
  16751. Evaluate the expression @var{expr} without displaying @code{void}
  16752. returned values.
  16753. You can use this variant of the @code{print} command if you want to
  16754. execute a function from your program that does not return anything
  16755. (a.k.a.@: @dfn{a void function}), but without cluttering the output
  16756. with @code{void} returned values that @value{GDBN} will otherwise
  16757. print. If the result is not void, it is printed and saved in the
  16758. value history.
  16759. @end table
  16760. It is possible for the function you call via the @code{print} or
  16761. @code{call} command to generate a signal (e.g., if there's a bug in
  16762. the function, or if you passed it incorrect arguments). What happens
  16763. in that case is controlled by the @code{set unwindonsignal} command.
  16764. Similarly, with a C@t{++} program it is possible for the function you
  16765. call via the @code{print} or @code{call} command to generate an
  16766. exception that is not handled due to the constraints of the dummy
  16767. frame. In this case, any exception that is raised in the frame, but has
  16768. an out-of-frame exception handler will not be found. GDB builds a
  16769. dummy-frame for the inferior function call, and the unwinder cannot
  16770. seek for exception handlers outside of this dummy-frame. What happens
  16771. in that case is controlled by the
  16772. @code{set unwind-on-terminating-exception} command.
  16773. @table @code
  16774. @item set unwindonsignal
  16775. @kindex set unwindonsignal
  16776. @cindex unwind stack in called functions
  16777. @cindex call dummy stack unwinding
  16778. Set unwinding of the stack if a signal is received while in a function
  16779. that @value{GDBN} called in the program being debugged. If set to on,
  16780. @value{GDBN} unwinds the stack it created for the call and restores
  16781. the context to what it was before the call. If set to off (the
  16782. default), @value{GDBN} stops in the frame where the signal was
  16783. received.
  16784. @item show unwindonsignal
  16785. @kindex show unwindonsignal
  16786. Show the current setting of stack unwinding in the functions called by
  16787. @value{GDBN}.
  16788. @item set unwind-on-terminating-exception
  16789. @kindex set unwind-on-terminating-exception
  16790. @cindex unwind stack in called functions with unhandled exceptions
  16791. @cindex call dummy stack unwinding on unhandled exception.
  16792. Set unwinding of the stack if a C@t{++} exception is raised, but left
  16793. unhandled while in a function that @value{GDBN} called in the program being
  16794. debugged. If set to on (the default), @value{GDBN} unwinds the stack
  16795. it created for the call and restores the context to what it was before
  16796. the call. If set to off, @value{GDBN} the exception is delivered to
  16797. the default C@t{++} exception handler and the inferior terminated.
  16798. @item show unwind-on-terminating-exception
  16799. @kindex show unwind-on-terminating-exception
  16800. Show the current setting of stack unwinding in the functions called by
  16801. @value{GDBN}.
  16802. @item set may-call-functions
  16803. @kindex set may-call-functions
  16804. @cindex disabling calling functions in the program
  16805. @cindex calling functions in the program, disabling
  16806. Set permission to call functions in the program.
  16807. This controls whether @value{GDBN} will attempt to call functions in
  16808. the program, such as with expressions in the @code{print} command. It
  16809. defaults to @code{on}.
  16810. To call a function in the program, @value{GDBN} has to temporarily
  16811. modify the state of the inferior. This has potentially undesired side
  16812. effects. Also, having @value{GDBN} call nested functions is likely to
  16813. be erroneous and may even crash the program being debugged. You can
  16814. avoid such hazards by forbidding @value{GDBN} from calling functions
  16815. in the program being debugged. If calling functions in the program
  16816. is forbidden, GDB will throw an error when a command (such as printing
  16817. an expression) starts a function call in the program.
  16818. @item show may-call-functions
  16819. @kindex show may-call-functions
  16820. Show permission to call functions in the program.
  16821. @end table
  16822. @subsection Calling functions with no debug info
  16823. @cindex no debug info functions
  16824. Sometimes, a function you wish to call is missing debug information.
  16825. In such case, @value{GDBN} does not know the type of the function,
  16826. including the types of the function's parameters. To avoid calling
  16827. the inferior function incorrectly, which could result in the called
  16828. function functioning erroneously and even crash, @value{GDBN} refuses
  16829. to call the function unless you tell it the type of the function.
  16830. For prototyped (i.e.@: ANSI/ISO style) functions, there are two ways
  16831. to do that. The simplest is to cast the call to the function's
  16832. declared return type. For example:
  16833. @smallexample
  16834. (@value{GDBP}) p getenv ("PATH")
  16835. 'getenv' has unknown return type; cast the call to its declared return type
  16836. (@value{GDBP}) p (char *) getenv ("PATH")
  16837. $1 = 0x7fffffffe7ba "/usr/local/bin:/"...
  16838. @end smallexample
  16839. Casting the return type of a no-debug function is equivalent to
  16840. casting the function to a pointer to a prototyped function that has a
  16841. prototype that matches the types of the passed-in arguments, and
  16842. calling that. I.e., the call above is equivalent to:
  16843. @smallexample
  16844. (@value{GDBP}) p ((char * (*) (const char *)) getenv) ("PATH")
  16845. @end smallexample
  16846. @noindent
  16847. and given this prototyped C or C++ function with float parameters:
  16848. @smallexample
  16849. float multiply (float v1, float v2) @{ return v1 * v2; @}
  16850. @end smallexample
  16851. @noindent
  16852. these calls are equivalent:
  16853. @smallexample
  16854. (@value{GDBP}) p (float) multiply (2.0f, 3.0f)
  16855. (@value{GDBP}) p ((float (*) (float, float)) multiply) (2.0f, 3.0f)
  16856. @end smallexample
  16857. If the function you wish to call is declared as unprototyped (i.e.@:
  16858. old K&R style), you must use the cast-to-function-pointer syntax, so
  16859. that @value{GDBN} knows that it needs to apply default argument
  16860. promotions (promote float arguments to double). @xref{ABI, float
  16861. promotion}. For example, given this unprototyped C function with
  16862. float parameters, and no debug info:
  16863. @smallexample
  16864. float
  16865. multiply_noproto (v1, v2)
  16866. float v1, v2;
  16867. @{
  16868. return v1 * v2;
  16869. @}
  16870. @end smallexample
  16871. @noindent
  16872. you call it like this:
  16873. @smallexample
  16874. (@value{GDBP}) p ((float (*) ()) multiply_noproto) (2.0f, 3.0f)
  16875. @end smallexample
  16876. @node Patching
  16877. @section Patching Programs
  16878. @cindex patching binaries
  16879. @cindex writing into executables
  16880. @cindex writing into corefiles
  16881. By default, @value{GDBN} opens the file containing your program's
  16882. executable code (or the corefile) read-only. This prevents accidental
  16883. alterations to machine code; but it also prevents you from intentionally
  16884. patching your program's binary.
  16885. If you'd like to be able to patch the binary, you can specify that
  16886. explicitly with the @code{set write} command. For example, you might
  16887. want to turn on internal debugging flags, or even to make emergency
  16888. repairs.
  16889. @table @code
  16890. @kindex set write
  16891. @item set write on
  16892. @itemx set write off
  16893. If you specify @samp{set write on}, @value{GDBN} opens executable and
  16894. core files for both reading and writing; if you specify @kbd{set write
  16895. off} (the default), @value{GDBN} opens them read-only.
  16896. If you have already loaded a file, you must load it again (using the
  16897. @code{exec-file} or @code{core-file} command) after changing @code{set
  16898. write}, for your new setting to take effect.
  16899. @item show write
  16900. @kindex show write
  16901. Display whether executable files and core files are opened for writing
  16902. as well as reading.
  16903. @end table
  16904. @node Compiling and Injecting Code
  16905. @section Compiling and injecting code in @value{GDBN}
  16906. @cindex injecting code
  16907. @cindex writing into executables
  16908. @cindex compiling code
  16909. @value{GDBN} supports on-demand compilation and code injection into
  16910. programs running under @value{GDBN}. GCC 5.0 or higher built with
  16911. @file{libcc1.so} must be installed for this functionality to be enabled.
  16912. This functionality is implemented with the following commands.
  16913. @table @code
  16914. @kindex compile code
  16915. @item compile code @var{source-code}
  16916. @itemx compile code -raw @var{--} @var{source-code}
  16917. Compile @var{source-code} with the compiler language found as the current
  16918. language in @value{GDBN} (@pxref{Languages}). If compilation and
  16919. injection is not supported with the current language specified in
  16920. @value{GDBN}, or the compiler does not support this feature, an error
  16921. message will be printed. If @var{source-code} compiles and links
  16922. successfully, @value{GDBN} will load the object-code emitted,
  16923. and execute it within the context of the currently selected inferior.
  16924. It is important to note that the compiled code is executed immediately.
  16925. After execution, the compiled code is removed from @value{GDBN} and any
  16926. new types or variables you have defined will be deleted.
  16927. The command allows you to specify @var{source-code} in two ways.
  16928. The simplest method is to provide a single line of code to the command.
  16929. E.g.:
  16930. @smallexample
  16931. compile code printf ("hello world\n");
  16932. @end smallexample
  16933. If you specify options on the command line as well as source code, they
  16934. may conflict. The @samp{--} delimiter can be used to separate options
  16935. from actual source code. E.g.:
  16936. @smallexample
  16937. compile code -r -- printf ("hello world\n");
  16938. @end smallexample
  16939. Alternatively you can enter source code as multiple lines of text. To
  16940. enter this mode, invoke the @samp{compile code} command without any text
  16941. following the command. This will start the multiple-line editor and
  16942. allow you to type as many lines of source code as required. When you
  16943. have completed typing, enter @samp{end} on its own line to exit the
  16944. editor.
  16945. @smallexample
  16946. compile code
  16947. >printf ("hello\n");
  16948. >printf ("world\n");
  16949. >end
  16950. @end smallexample
  16951. Specifying @samp{-raw}, prohibits @value{GDBN} from wrapping the
  16952. provided @var{source-code} in a callable scope. In this case, you must
  16953. specify the entry point of the code by defining a function named
  16954. @code{_gdb_expr_}. The @samp{-raw} code cannot access variables of the
  16955. inferior. Using @samp{-raw} option may be needed for example when
  16956. @var{source-code} requires @samp{#include} lines which may conflict with
  16957. inferior symbols otherwise.
  16958. @kindex compile file
  16959. @item compile file @var{filename}
  16960. @itemx compile file -raw @var{filename}
  16961. Like @code{compile code}, but take the source code from @var{filename}.
  16962. @smallexample
  16963. compile file /home/user/example.c
  16964. @end smallexample
  16965. @end table
  16966. @table @code
  16967. @item compile print [[@var{options}] --] @var{expr}
  16968. @itemx compile print [[@var{options}] --] /@var{f} @var{expr}
  16969. Compile and execute @var{expr} with the compiler language found as the
  16970. current language in @value{GDBN} (@pxref{Languages}). By default the
  16971. value of @var{expr} is printed in a format appropriate to its data type;
  16972. you can choose a different format by specifying @samp{/@var{f}}, where
  16973. @var{f} is a letter specifying the format; see @ref{Output Formats,,Output
  16974. Formats}. The @code{compile print} command accepts the same options
  16975. as the @code{print} command; see @ref{print options}.
  16976. @item compile print [[@var{options}] --]
  16977. @itemx compile print [[@var{options}] --] /@var{f}
  16978. @cindex reprint the last value
  16979. Alternatively you can enter the expression (source code producing it) as
  16980. multiple lines of text. To enter this mode, invoke the @samp{compile print}
  16981. command without any text following the command. This will start the
  16982. multiple-line editor.
  16983. @end table
  16984. @noindent
  16985. The process of compiling and injecting the code can be inspected using:
  16986. @table @code
  16987. @anchor{set debug compile}
  16988. @item set debug compile
  16989. @cindex compile command debugging info
  16990. Turns on or off display of @value{GDBN} process of compiling and
  16991. injecting the code. The default is off.
  16992. @item show debug compile
  16993. Displays the current state of displaying @value{GDBN} process of
  16994. compiling and injecting the code.
  16995. @anchor{set debug compile-cplus-types}
  16996. @item set debug compile-cplus-types
  16997. @cindex compile C@t{++} type conversion
  16998. Turns on or off the display of C@t{++} type conversion debugging information.
  16999. The default is off.
  17000. @item show debug compile-cplus-types
  17001. Displays the current state of displaying debugging information for
  17002. C@t{++} type conversion.
  17003. @end table
  17004. @subsection Compilation options for the @code{compile} command
  17005. @value{GDBN} needs to specify the right compilation options for the code
  17006. to be injected, in part to make its ABI compatible with the inferior
  17007. and in part to make the injected code compatible with @value{GDBN}'s
  17008. injecting process.
  17009. @noindent
  17010. The options used, in increasing precedence:
  17011. @table @asis
  17012. @item target architecture and OS options (@code{gdbarch})
  17013. These options depend on target processor type and target operating
  17014. system, usually they specify at least 32-bit (@code{-m32}) or 64-bit
  17015. (@code{-m64}) compilation option.
  17016. @item compilation options recorded in the target
  17017. @value{NGCC} (since version 4.7) stores the options used for compilation
  17018. into @code{DW_AT_producer} part of DWARF debugging information according
  17019. to the @value{NGCC} option @code{-grecord-gcc-switches}. One has to
  17020. explicitly specify @code{-g} during inferior compilation otherwise
  17021. @value{NGCC} produces no DWARF. This feature is only relevant for
  17022. platforms where @code{-g} produces DWARF by default, otherwise one may
  17023. try to enforce DWARF by using @code{-gdwarf-4}.
  17024. @item compilation options set by @code{set compile-args}
  17025. @end table
  17026. @noindent
  17027. You can override compilation options using the following command:
  17028. @table @code
  17029. @item set compile-args
  17030. @cindex compile command options override
  17031. Set compilation options used for compiling and injecting code with the
  17032. @code{compile} commands. These options override any conflicting ones
  17033. from the target architecture and/or options stored during inferior
  17034. compilation.
  17035. @item show compile-args
  17036. Displays the current state of compilation options override.
  17037. This does not show all the options actually used during compilation,
  17038. use @ref{set debug compile} for that.
  17039. @end table
  17040. @subsection Caveats when using the @code{compile} command
  17041. There are a few caveats to keep in mind when using the @code{compile}
  17042. command. As the caveats are different per language, the table below
  17043. highlights specific issues on a per language basis.
  17044. @table @asis
  17045. @item C code examples and caveats
  17046. When the language in @value{GDBN} is set to @samp{C}, the compiler will
  17047. attempt to compile the source code with a @samp{C} compiler. The source
  17048. code provided to the @code{compile} command will have much the same
  17049. access to variables and types as it normally would if it were part of
  17050. the program currently being debugged in @value{GDBN}.
  17051. Below is a sample program that forms the basis of the examples that
  17052. follow. This program has been compiled and loaded into @value{GDBN},
  17053. much like any other normal debugging session.
  17054. @smallexample
  17055. void function1 (void)
  17056. @{
  17057. int i = 42;
  17058. printf ("function 1\n");
  17059. @}
  17060. void function2 (void)
  17061. @{
  17062. int j = 12;
  17063. function1 ();
  17064. @}
  17065. int main(void)
  17066. @{
  17067. int k = 6;
  17068. int *p;
  17069. function2 ();
  17070. return 0;
  17071. @}
  17072. @end smallexample
  17073. For the purposes of the examples in this section, the program above has
  17074. been compiled, loaded into @value{GDBN}, stopped at the function
  17075. @code{main}, and @value{GDBN} is awaiting input from the user.
  17076. To access variables and types for any program in @value{GDBN}, the
  17077. program must be compiled and packaged with debug information. The
  17078. @code{compile} command is not an exception to this rule. Without debug
  17079. information, you can still use the @code{compile} command, but you will
  17080. be very limited in what variables and types you can access.
  17081. So with that in mind, the example above has been compiled with debug
  17082. information enabled. The @code{compile} command will have access to
  17083. all variables and types (except those that may have been optimized
  17084. out). Currently, as @value{GDBN} has stopped the program in the
  17085. @code{main} function, the @code{compile} command would have access to
  17086. the variable @code{k}. You could invoke the @code{compile} command
  17087. and type some source code to set the value of @code{k}. You can also
  17088. read it, or do anything with that variable you would normally do in
  17089. @code{C}. Be aware that changes to inferior variables in the
  17090. @code{compile} command are persistent. In the following example:
  17091. @smallexample
  17092. compile code k = 3;
  17093. @end smallexample
  17094. @noindent
  17095. the variable @code{k} is now 3. It will retain that value until
  17096. something else in the example program changes it, or another
  17097. @code{compile} command changes it.
  17098. Normal scope and access rules apply to source code compiled and
  17099. injected by the @code{compile} command. In the example, the variables
  17100. @code{j} and @code{k} are not accessible yet, because the program is
  17101. currently stopped in the @code{main} function, where these variables
  17102. are not in scope. Therefore, the following command
  17103. @smallexample
  17104. compile code j = 3;
  17105. @end smallexample
  17106. @noindent
  17107. will result in a compilation error message.
  17108. Once the program is continued, execution will bring these variables in
  17109. scope, and they will become accessible; then the code you specify via
  17110. the @code{compile} command will be able to access them.
  17111. You can create variables and types with the @code{compile} command as
  17112. part of your source code. Variables and types that are created as part
  17113. of the @code{compile} command are not visible to the rest of the program for
  17114. the duration of its run. This example is valid:
  17115. @smallexample
  17116. compile code int ff = 5; printf ("ff is %d\n", ff);
  17117. @end smallexample
  17118. However, if you were to type the following into @value{GDBN} after that
  17119. command has completed:
  17120. @smallexample
  17121. compile code printf ("ff is %d\n'', ff);
  17122. @end smallexample
  17123. @noindent
  17124. a compiler error would be raised as the variable @code{ff} no longer
  17125. exists. Object code generated and injected by the @code{compile}
  17126. command is removed when its execution ends. Caution is advised
  17127. when assigning to program variables values of variables created by the
  17128. code submitted to the @code{compile} command. This example is valid:
  17129. @smallexample
  17130. compile code int ff = 5; k = ff;
  17131. @end smallexample
  17132. The value of the variable @code{ff} is assigned to @code{k}. The variable
  17133. @code{k} does not require the existence of @code{ff} to maintain the value
  17134. it has been assigned. However, pointers require particular care in
  17135. assignment. If the source code compiled with the @code{compile} command
  17136. changed the address of a pointer in the example program, perhaps to a
  17137. variable created in the @code{compile} command, that pointer would point
  17138. to an invalid location when the command exits. The following example
  17139. would likely cause issues with your debugged program:
  17140. @smallexample
  17141. compile code int ff = 5; p = &ff;
  17142. @end smallexample
  17143. In this example, @code{p} would point to @code{ff} when the
  17144. @code{compile} command is executing the source code provided to it.
  17145. However, as variables in the (example) program persist with their
  17146. assigned values, the variable @code{p} would point to an invalid
  17147. location when the command exists. A general rule should be followed
  17148. in that you should either assign @code{NULL} to any assigned pointers,
  17149. or restore a valid location to the pointer before the command exits.
  17150. Similar caution must be exercised with any structs, unions, and typedefs
  17151. defined in @code{compile} command. Types defined in the @code{compile}
  17152. command will no longer be available in the next @code{compile} command.
  17153. Therefore, if you cast a variable to a type defined in the
  17154. @code{compile} command, care must be taken to ensure that any future
  17155. need to resolve the type can be achieved.
  17156. @smallexample
  17157. (gdb) compile code static struct a @{ int a; @} v = @{ 42 @}; argv = &v;
  17158. (gdb) compile code printf ("%d\n", ((struct a *) argv)->a);
  17159. gdb command line:1:36: error: dereferencing pointer to incomplete type ‘struct a’
  17160. Compilation failed.
  17161. (gdb) compile code struct a @{ int a; @}; printf ("%d\n", ((struct a *) argv)->a);
  17162. 42
  17163. @end smallexample
  17164. Variables that have been optimized away by the compiler are not
  17165. accessible to the code submitted to the @code{compile} command.
  17166. Access to those variables will generate a compiler error which @value{GDBN}
  17167. will print to the console.
  17168. @end table
  17169. @subsection Compiler search for the @code{compile} command
  17170. @value{GDBN} needs to find @value{NGCC} for the inferior being debugged
  17171. which may not be obvious for remote targets of different architecture
  17172. than where @value{GDBN} is running. Environment variable @env{PATH} on
  17173. @value{GDBN} host is searched for @value{NGCC} binary matching the
  17174. target architecture and operating system. This search can be overriden
  17175. by @code{set compile-gcc} @value{GDBN} command below. @env{PATH} is
  17176. taken from shell that executed @value{GDBN}, it is not the value set by
  17177. @value{GDBN} command @code{set environment}). @xref{Environment}.
  17178. Specifically @env{PATH} is searched for binaries matching regular expression
  17179. @code{@var{arch}(-[^-]*)?-@var{os}-gcc} according to the inferior target being
  17180. debugged. @var{arch} is processor name --- multiarch is supported, so for
  17181. example both @code{i386} and @code{x86_64} targets look for pattern
  17182. @code{(x86_64|i.86)} and both @code{s390} and @code{s390x} targets look
  17183. for pattern @code{s390x?}. @var{os} is currently supported only for
  17184. pattern @code{linux(-gnu)?}.
  17185. On Posix hosts the compiler driver @value{GDBN} needs to find also
  17186. shared library @file{libcc1.so} from the compiler. It is searched in
  17187. default shared library search path (overridable with usual environment
  17188. variable @env{LD_LIBRARY_PATH}), unrelated to @env{PATH} or @code{set
  17189. compile-gcc} settings. Contrary to it @file{libcc1plugin.so} is found
  17190. according to the installation of the found compiler --- as possibly
  17191. specified by the @code{set compile-gcc} command.
  17192. @table @code
  17193. @item set compile-gcc
  17194. @cindex compile command driver filename override
  17195. Set compilation command used for compiling and injecting code with the
  17196. @code{compile} commands. If this option is not set (it is set to
  17197. an empty string), the search described above will occur --- that is the
  17198. default.
  17199. @item show compile-gcc
  17200. Displays the current compile command @value{NGCC} driver filename.
  17201. If set, it is the main command @command{gcc}, found usually for example
  17202. under name @file{x86_64-linux-gnu-gcc}.
  17203. @end table
  17204. @node GDB Files
  17205. @chapter @value{GDBN} Files
  17206. @value{GDBN} needs to know the file name of the program to be debugged,
  17207. both in order to read its symbol table and in order to start your
  17208. program. To debug a core dump of a previous run, you must also tell
  17209. @value{GDBN} the name of the core dump file.
  17210. @menu
  17211. * Files:: Commands to specify files
  17212. * File Caching:: Information about @value{GDBN}'s file caching
  17213. * Separate Debug Files:: Debugging information in separate files
  17214. * MiniDebugInfo:: Debugging information in a special section
  17215. * Index Files:: Index files speed up GDB
  17216. * Symbol Errors:: Errors reading symbol files
  17217. * Data Files:: GDB data files
  17218. @end menu
  17219. @node Files
  17220. @section Commands to Specify Files
  17221. @cindex symbol table
  17222. @cindex core dump file
  17223. You may want to specify executable and core dump file names. The usual
  17224. way to do this is at start-up time, using the arguments to
  17225. @value{GDBN}'s start-up commands (@pxref{Invocation, , Getting In and
  17226. Out of @value{GDBN}}).
  17227. Occasionally it is necessary to change to a different file during a
  17228. @value{GDBN} session. Or you may run @value{GDBN} and forget to
  17229. specify a file you want to use. Or you are debugging a remote target
  17230. via @code{gdbserver} (@pxref{Server, file, Using the @code{gdbserver}
  17231. Program}). In these situations the @value{GDBN} commands to specify
  17232. new files are useful.
  17233. @table @code
  17234. @cindex executable file
  17235. @kindex file
  17236. @item file @var{filename}
  17237. Use @var{filename} as the program to be debugged. It is read for its
  17238. symbols and for the contents of pure memory. It is also the program
  17239. executed when you use the @code{run} command. If you do not specify a
  17240. directory and the file is not found in the @value{GDBN} working directory,
  17241. @value{GDBN} uses the environment variable @env{PATH} as a list of
  17242. directories to search, just as the shell does when looking for a program
  17243. to run. You can change the value of this variable, for both @value{GDBN}
  17244. and your program, using the @code{path} command.
  17245. @cindex unlinked object files
  17246. @cindex patching object files
  17247. You can load unlinked object @file{.o} files into @value{GDBN} using
  17248. the @code{file} command. You will not be able to ``run'' an object
  17249. file, but you can disassemble functions and inspect variables. Also,
  17250. if the underlying BFD functionality supports it, you could use
  17251. @kbd{gdb -write} to patch object files using this technique. Note
  17252. that @value{GDBN} can neither interpret nor modify relocations in this
  17253. case, so branches and some initialized variables will appear to go to
  17254. the wrong place. But this feature is still handy from time to time.
  17255. @item file
  17256. @code{file} with no argument makes @value{GDBN} discard any information it
  17257. has on both executable file and the symbol table.
  17258. @kindex exec-file
  17259. @item exec-file @r{[} @var{filename} @r{]}
  17260. Specify that the program to be run (but not the symbol table) is found
  17261. in @var{filename}. @value{GDBN} searches the environment variable @env{PATH}
  17262. if necessary to locate your program. Omitting @var{filename} means to
  17263. discard information on the executable file.
  17264. @kindex symbol-file
  17265. @item symbol-file @r{[} @var{filename} @r{[} -o @var{offset} @r{]]}
  17266. Read symbol table information from file @var{filename}. @env{PATH} is
  17267. searched when necessary. Use the @code{file} command to get both symbol
  17268. table and program to run from the same file.
  17269. If an optional @var{offset} is specified, it is added to the start
  17270. address of each section in the symbol file. This is useful if the
  17271. program is relocated at runtime, such as the Linux kernel with kASLR
  17272. enabled.
  17273. @code{symbol-file} with no argument clears out @value{GDBN} information on your
  17274. program's symbol table.
  17275. The @code{symbol-file} command causes @value{GDBN} to forget the contents of
  17276. some breakpoints and auto-display expressions. This is because they may
  17277. contain pointers to the internal data recording symbols and data types,
  17278. which are part of the old symbol table data being discarded inside
  17279. @value{GDBN}.
  17280. @code{symbol-file} does not repeat if you press @key{RET} again after
  17281. executing it once.
  17282. When @value{GDBN} is configured for a particular environment, it
  17283. understands debugging information in whatever format is the standard
  17284. generated for that environment; you may use either a @sc{gnu} compiler, or
  17285. other compilers that adhere to the local conventions.
  17286. Best results are usually obtained from @sc{gnu} compilers; for example,
  17287. using @code{@value{NGCC}} you can generate debugging information for
  17288. optimized code.
  17289. For most kinds of object files, with the exception of old SVR3 systems
  17290. using COFF, the @code{symbol-file} command does not normally read the
  17291. symbol table in full right away. Instead, it scans the symbol table
  17292. quickly to find which source files and which symbols are present. The
  17293. details are read later, one source file at a time, as they are needed.
  17294. The purpose of this two-stage reading strategy is to make @value{GDBN}
  17295. start up faster. For the most part, it is invisible except for
  17296. occasional pauses while the symbol table details for a particular source
  17297. file are being read. (The @code{set verbose} command can turn these
  17298. pauses into messages if desired. @xref{Messages/Warnings, ,Optional
  17299. Warnings and Messages}.)
  17300. We have not implemented the two-stage strategy for COFF yet. When the
  17301. symbol table is stored in COFF format, @code{symbol-file} reads the
  17302. symbol table data in full right away. Note that ``stabs-in-COFF''
  17303. still does the two-stage strategy, since the debug info is actually
  17304. in stabs format.
  17305. @kindex readnow
  17306. @cindex reading symbols immediately
  17307. @cindex symbols, reading immediately
  17308. @item symbol-file @r{[} -readnow @r{]} @var{filename}
  17309. @itemx file @r{[} -readnow @r{]} @var{filename}
  17310. You can override the @value{GDBN} two-stage strategy for reading symbol
  17311. tables by using the @samp{-readnow} option with any of the commands that
  17312. load symbol table information, if you want to be sure @value{GDBN} has the
  17313. entire symbol table available.
  17314. @cindex @code{-readnever}, option for symbol-file command
  17315. @cindex never read symbols
  17316. @cindex symbols, never read
  17317. @item symbol-file @r{[} -readnever @r{]} @var{filename}
  17318. @itemx file @r{[} -readnever @r{]} @var{filename}
  17319. You can instruct @value{GDBN} to never read the symbolic information
  17320. contained in @var{filename} by using the @samp{-readnever} option.
  17321. @xref{--readnever}.
  17322. @c FIXME: for now no mention of directories, since this seems to be in
  17323. @c flux. 13mar1992 status is that in theory GDB would look either in
  17324. @c current dir or in same dir as myprog; but issues like competing
  17325. @c GDB's, or clutter in system dirs, mean that in practice right now
  17326. @c only current dir is used. FFish says maybe a special GDB hierarchy
  17327. @c (eg rooted in val of env var GDBSYMS) could exist for mappable symbol
  17328. @c files.
  17329. @kindex core-file
  17330. @item core-file @r{[}@var{filename}@r{]}
  17331. @itemx core
  17332. Specify the whereabouts of a core dump file to be used as the ``contents
  17333. of memory''. Traditionally, core files contain only some parts of the
  17334. address space of the process that generated them; @value{GDBN} can access the
  17335. executable file itself for other parts.
  17336. @code{core-file} with no argument specifies that no core file is
  17337. to be used.
  17338. Note that the core file is ignored when your program is actually running
  17339. under @value{GDBN}. So, if you have been running your program and you
  17340. wish to debug a core file instead, you must kill the subprocess in which
  17341. the program is running. To do this, use the @code{kill} command
  17342. (@pxref{Kill Process, ,Killing the Child Process}).
  17343. @kindex add-symbol-file
  17344. @cindex dynamic linking
  17345. @item add-symbol-file @var{filename} @r{[} -readnow @r{|} -readnever @r{]} @r{[} -o @var{offset} @r{]} @r{[} @var{textaddress} @r{]} @r{[} -s @var{section} @var{address} @dots{} @r{]}
  17346. The @code{add-symbol-file} command reads additional symbol table
  17347. information from the file @var{filename}. You would use this command
  17348. when @var{filename} has been dynamically loaded (by some other means)
  17349. into the program that is running. The @var{textaddress} parameter gives
  17350. the memory address at which the file's text section has been loaded.
  17351. You can additionally specify the base address of other sections using
  17352. an arbitrary number of @samp{-s @var{section} @var{address}} pairs.
  17353. If a section is omitted, @value{GDBN} will use its default addresses
  17354. as found in @var{filename}. Any @var{address} or @var{textaddress}
  17355. can be given as an expression.
  17356. If an optional @var{offset} is specified, it is added to the start
  17357. address of each section, except those for which the address was
  17358. specified explicitly.
  17359. The symbol table of the file @var{filename} is added to the symbol table
  17360. originally read with the @code{symbol-file} command. You can use the
  17361. @code{add-symbol-file} command any number of times; the new symbol data
  17362. thus read is kept in addition to the old.
  17363. Changes can be reverted using the command @code{remove-symbol-file}.
  17364. @cindex relocatable object files, reading symbols from
  17365. @cindex object files, relocatable, reading symbols from
  17366. @cindex reading symbols from relocatable object files
  17367. @cindex symbols, reading from relocatable object files
  17368. @cindex @file{.o} files, reading symbols from
  17369. Although @var{filename} is typically a shared library file, an
  17370. executable file, or some other object file which has been fully
  17371. relocated for loading into a process, you can also load symbolic
  17372. information from relocatable @file{.o} files, as long as:
  17373. @itemize @bullet
  17374. @item
  17375. the file's symbolic information refers only to linker symbols defined in
  17376. that file, not to symbols defined by other object files,
  17377. @item
  17378. every section the file's symbolic information refers to has actually
  17379. been loaded into the inferior, as it appears in the file, and
  17380. @item
  17381. you can determine the address at which every section was loaded, and
  17382. provide these to the @code{add-symbol-file} command.
  17383. @end itemize
  17384. @noindent
  17385. Some embedded operating systems, like Sun Chorus and VxWorks, can load
  17386. relocatable files into an already running program; such systems
  17387. typically make the requirements above easy to meet. However, it's
  17388. important to recognize that many native systems use complex link
  17389. procedures (@code{.linkonce} section factoring and C@t{++} constructor table
  17390. assembly, for example) that make the requirements difficult to meet. In
  17391. general, one cannot assume that using @code{add-symbol-file} to read a
  17392. relocatable object file's symbolic information will have the same effect
  17393. as linking the relocatable object file into the program in the normal
  17394. way.
  17395. @code{add-symbol-file} does not repeat if you press @key{RET} after using it.
  17396. @kindex remove-symbol-file
  17397. @item remove-symbol-file @var{filename}
  17398. @item remove-symbol-file -a @var{address}
  17399. Remove a symbol file added via the @code{add-symbol-file} command. The
  17400. file to remove can be identified by its @var{filename} or by an @var{address}
  17401. that lies within the boundaries of this symbol file in memory. Example:
  17402. @smallexample
  17403. (gdb) add-symbol-file /home/user/gdb/mylib.so 0x7ffff7ff9480
  17404. add symbol table from file "/home/user/gdb/mylib.so" at
  17405. .text_addr = 0x7ffff7ff9480
  17406. (y or n) y
  17407. Reading symbols from /home/user/gdb/mylib.so...
  17408. (gdb) remove-symbol-file -a 0x7ffff7ff9480
  17409. Remove symbol table from file "/home/user/gdb/mylib.so"? (y or n) y
  17410. (gdb)
  17411. @end smallexample
  17412. @code{remove-symbol-file} does not repeat if you press @key{RET} after using it.
  17413. @kindex add-symbol-file-from-memory
  17414. @cindex @code{syscall DSO}
  17415. @cindex load symbols from memory
  17416. @item add-symbol-file-from-memory @var{address}
  17417. Load symbols from the given @var{address} in a dynamically loaded
  17418. object file whose image is mapped directly into the inferior's memory.
  17419. For example, the Linux kernel maps a @code{syscall DSO} into each
  17420. process's address space; this DSO provides kernel-specific code for
  17421. some system calls. The argument can be any expression whose
  17422. evaluation yields the address of the file's shared object file header.
  17423. For this command to work, you must have used @code{symbol-file} or
  17424. @code{exec-file} commands in advance.
  17425. @kindex section
  17426. @item section @var{section} @var{addr}
  17427. The @code{section} command changes the base address of the named
  17428. @var{section} of the exec file to @var{addr}. This can be used if the
  17429. exec file does not contain section addresses, (such as in the
  17430. @code{a.out} format), or when the addresses specified in the file
  17431. itself are wrong. Each section must be changed separately. The
  17432. @code{info files} command, described below, lists all the sections and
  17433. their addresses.
  17434. @kindex info files
  17435. @kindex info target
  17436. @item info files
  17437. @itemx info target
  17438. @code{info files} and @code{info target} are synonymous; both print the
  17439. current target (@pxref{Targets, ,Specifying a Debugging Target}),
  17440. including the names of the executable and core dump files currently in
  17441. use by @value{GDBN}, and the files from which symbols were loaded. The
  17442. command @code{help target} lists all possible targets rather than
  17443. current ones.
  17444. @kindex maint info sections
  17445. @item maint info sections @r{[}-all-objects@r{]} @r{[}@var{filter-list}@r{]}
  17446. Another command that can give you extra information about program sections
  17447. is @code{maint info sections}. In addition to the section information
  17448. displayed by @code{info files}, this command displays the flags and file
  17449. offset of each section in the executable and core dump files.
  17450. When @samp{-all-objects} is passed then sections from all loaded object
  17451. files, including shared libraries, are printed.
  17452. The optional @var{filter-list} is a space separated list of filter
  17453. keywords. Sections that match any one of the filter criteria will be
  17454. printed. There are two types of filter:
  17455. @table @code
  17456. @item @var{section-name}
  17457. Display information about any section named @var{section-name}.
  17458. @item @var{section-flag}
  17459. Display information for any section with @var{section-flag}. The
  17460. section flags that @value{GDBN} currently knows about are:
  17461. @table @code
  17462. @item ALLOC
  17463. Section will have space allocated in the process when loaded.
  17464. Set for all sections except those containing debug information.
  17465. @item LOAD
  17466. Section will be loaded from the file into the child process memory.
  17467. Set for pre-initialized code and data, clear for @code{.bss} sections.
  17468. @item RELOC
  17469. Section needs to be relocated before loading.
  17470. @item READONLY
  17471. Section cannot be modified by the child process.
  17472. @item CODE
  17473. Section contains executable code only.
  17474. @item DATA
  17475. Section contains data only (no executable code).
  17476. @item ROM
  17477. Section will reside in ROM.
  17478. @item CONSTRUCTOR
  17479. Section contains data for constructor/destructor lists.
  17480. @item HAS_CONTENTS
  17481. Section is not empty.
  17482. @item NEVER_LOAD
  17483. An instruction to the linker to not output the section.
  17484. @item COFF_SHARED_LIBRARY
  17485. A notification to the linker that the section contains
  17486. COFF shared library information.
  17487. @item IS_COMMON
  17488. Section contains common symbols.
  17489. @end table
  17490. @end table
  17491. @kindex maint info target-sections
  17492. @item maint info target-sections
  17493. This command prints @value{GDBN}'s internal section table. For each
  17494. target @value{GDBN} maintains a table containing the allocatable
  17495. sections from all currently mapped objects, along with information
  17496. about where the section is mapped.
  17497. @kindex set trust-readonly-sections
  17498. @cindex read-only sections
  17499. @item set trust-readonly-sections on
  17500. Tell @value{GDBN} that readonly sections in your object file
  17501. really are read-only (i.e.@: that their contents will not change).
  17502. In that case, @value{GDBN} can fetch values from these sections
  17503. out of the object file, rather than from the target program.
  17504. For some targets (notably embedded ones), this can be a significant
  17505. enhancement to debugging performance.
  17506. The default is off.
  17507. @item set trust-readonly-sections off
  17508. Tell @value{GDBN} not to trust readonly sections. This means that
  17509. the contents of the section might change while the program is running,
  17510. and must therefore be fetched from the target when needed.
  17511. @item show trust-readonly-sections
  17512. Show the current setting of trusting readonly sections.
  17513. @end table
  17514. All file-specifying commands allow both absolute and relative file names
  17515. as arguments. @value{GDBN} always converts the file name to an absolute file
  17516. name and remembers it that way.
  17517. @cindex shared libraries
  17518. @anchor{Shared Libraries}
  17519. @value{GDBN} supports @sc{gnu}/Linux, MS-Windows, SunOS,
  17520. Darwin/Mach-O, SVr4, IBM RS/6000 AIX, QNX Neutrino, FDPIC (FR-V), and
  17521. DSBT (TIC6X) shared libraries.
  17522. On MS-Windows @value{GDBN} must be linked with the Expat library to support
  17523. shared libraries. @xref{Expat}.
  17524. @value{GDBN} automatically loads symbol definitions from shared libraries
  17525. when you use the @code{run} command, or when you examine a core file.
  17526. (Before you issue the @code{run} command, @value{GDBN} does not understand
  17527. references to a function in a shared library, however---unless you are
  17528. debugging a core file).
  17529. @c FIXME: some @value{GDBN} release may permit some refs to undef
  17530. @c FIXME...symbols---eg in a break cmd---assuming they are from a shared
  17531. @c FIXME...lib; check this from time to time when updating manual
  17532. There are times, however, when you may wish to not automatically load
  17533. symbol definitions from shared libraries, such as when they are
  17534. particularly large or there are many of them.
  17535. To control the automatic loading of shared library symbols, use the
  17536. commands:
  17537. @table @code
  17538. @kindex set auto-solib-add
  17539. @item set auto-solib-add @var{mode}
  17540. If @var{mode} is @code{on}, symbols from all shared object libraries
  17541. will be loaded automatically when the inferior begins execution, you
  17542. attach to an independently started inferior, or when the dynamic linker
  17543. informs @value{GDBN} that a new library has been loaded. If @var{mode}
  17544. is @code{off}, symbols must be loaded manually, using the
  17545. @code{sharedlibrary} command. The default value is @code{on}.
  17546. @cindex memory used for symbol tables
  17547. If your program uses lots of shared libraries with debug info that
  17548. takes large amounts of memory, you can decrease the @value{GDBN}
  17549. memory footprint by preventing it from automatically loading the
  17550. symbols from shared libraries. To that end, type @kbd{set
  17551. auto-solib-add off} before running the inferior, then load each
  17552. library whose debug symbols you do need with @kbd{sharedlibrary
  17553. @var{regexp}}, where @var{regexp} is a regular expression that matches
  17554. the libraries whose symbols you want to be loaded.
  17555. @kindex show auto-solib-add
  17556. @item show auto-solib-add
  17557. Display the current autoloading mode.
  17558. @end table
  17559. @cindex load shared library
  17560. To explicitly load shared library symbols, use the @code{sharedlibrary}
  17561. command:
  17562. @table @code
  17563. @kindex info sharedlibrary
  17564. @kindex info share
  17565. @item info share @var{regex}
  17566. @itemx info sharedlibrary @var{regex}
  17567. Print the names of the shared libraries which are currently loaded
  17568. that match @var{regex}. If @var{regex} is omitted then print
  17569. all shared libraries that are loaded.
  17570. @kindex info dll
  17571. @item info dll @var{regex}
  17572. This is an alias of @code{info sharedlibrary}.
  17573. @kindex sharedlibrary
  17574. @kindex share
  17575. @item sharedlibrary @var{regex}
  17576. @itemx share @var{regex}
  17577. Load shared object library symbols for files matching a
  17578. Unix regular expression.
  17579. As with files loaded automatically, it only loads shared libraries
  17580. required by your program for a core file or after typing @code{run}. If
  17581. @var{regex} is omitted all shared libraries required by your program are
  17582. loaded.
  17583. @item nosharedlibrary
  17584. @kindex nosharedlibrary
  17585. @cindex unload symbols from shared libraries
  17586. Unload all shared object library symbols. This discards all symbols
  17587. that have been loaded from all shared libraries. Symbols from shared
  17588. libraries that were loaded by explicit user requests are not
  17589. discarded.
  17590. @end table
  17591. Sometimes you may wish that @value{GDBN} stops and gives you control
  17592. when any of shared library events happen. The best way to do this is
  17593. to use @code{catch load} and @code{catch unload} (@pxref{Set
  17594. Catchpoints}).
  17595. @value{GDBN} also supports the @code{set stop-on-solib-events}
  17596. command for this. This command exists for historical reasons. It is
  17597. less useful than setting a catchpoint, because it does not allow for
  17598. conditions or commands as a catchpoint does.
  17599. @table @code
  17600. @item set stop-on-solib-events
  17601. @kindex set stop-on-solib-events
  17602. This command controls whether @value{GDBN} should give you control
  17603. when the dynamic linker notifies it about some shared library event.
  17604. The most common event of interest is loading or unloading of a new
  17605. shared library.
  17606. @item show stop-on-solib-events
  17607. @kindex show stop-on-solib-events
  17608. Show whether @value{GDBN} stops and gives you control when shared
  17609. library events happen.
  17610. @end table
  17611. Shared libraries are also supported in many cross or remote debugging
  17612. configurations. @value{GDBN} needs to have access to the target's libraries;
  17613. this can be accomplished either by providing copies of the libraries
  17614. on the host system, or by asking @value{GDBN} to automatically retrieve the
  17615. libraries from the target. If copies of the target libraries are
  17616. provided, they need to be the same as the target libraries, although the
  17617. copies on the target can be stripped as long as the copies on the host are
  17618. not.
  17619. @cindex where to look for shared libraries
  17620. For remote debugging, you need to tell @value{GDBN} where the target
  17621. libraries are, so that it can load the correct copies---otherwise, it
  17622. may try to load the host's libraries. @value{GDBN} has two variables
  17623. to specify the search directories for target libraries.
  17624. @table @code
  17625. @cindex prefix for executable and shared library file names
  17626. @cindex system root, alternate
  17627. @kindex set solib-absolute-prefix
  17628. @kindex set sysroot
  17629. @item set sysroot @var{path}
  17630. Use @var{path} as the system root for the program being debugged. Any
  17631. absolute shared library paths will be prefixed with @var{path}; many
  17632. runtime loaders store the absolute paths to the shared library in the
  17633. target program's memory. When starting processes remotely, and when
  17634. attaching to already-running processes (local or remote), their
  17635. executable filenames will be prefixed with @var{path} if reported to
  17636. @value{GDBN} as absolute by the operating system. If you use
  17637. @code{set sysroot} to find executables and shared libraries, they need
  17638. to be laid out in the same way that they are on the target, with
  17639. e.g.@: a @file{/bin}, @file{/lib} and @file{/usr/lib} hierarchy under
  17640. @var{path}.
  17641. If @var{path} starts with the sequence @file{target:} and the target
  17642. system is remote then @value{GDBN} will retrieve the target binaries
  17643. from the remote system. This is only supported when using a remote
  17644. target that supports the @code{remote get} command (@pxref{File
  17645. Transfer,,Sending files to a remote system}). The part of @var{path}
  17646. following the initial @file{target:} (if present) is used as system
  17647. root prefix on the remote file system. If @var{path} starts with the
  17648. sequence @file{remote:} this is converted to the sequence
  17649. @file{target:} by @code{set sysroot}@footnote{Historically the
  17650. functionality to retrieve binaries from the remote system was
  17651. provided by prefixing @var{path} with @file{remote:}}. If you want
  17652. to specify a local system root using a directory that happens to be
  17653. named @file{target:} or @file{remote:}, you need to use some
  17654. equivalent variant of the name like @file{./target:}.
  17655. For targets with an MS-DOS based filesystem, such as MS-Windows,
  17656. @value{GDBN} tries prefixing a few variants of the target
  17657. absolute file name with @var{path}. But first, on Unix hosts,
  17658. @value{GDBN} converts all backslash directory separators into forward
  17659. slashes, because the backslash is not a directory separator on Unix:
  17660. @smallexample
  17661. c:\foo\bar.dll @result{} c:/foo/bar.dll
  17662. @end smallexample
  17663. Then, @value{GDBN} attempts prefixing the target file name with
  17664. @var{path}, and looks for the resulting file name in the host file
  17665. system:
  17666. @smallexample
  17667. c:/foo/bar.dll @result{} /path/to/sysroot/c:/foo/bar.dll
  17668. @end smallexample
  17669. If that does not find the binary, @value{GDBN} tries removing
  17670. the @samp{:} character from the drive spec, both for convenience, and,
  17671. for the case of the host file system not supporting file names with
  17672. colons:
  17673. @smallexample
  17674. c:/foo/bar.dll @result{} /path/to/sysroot/c/foo/bar.dll
  17675. @end smallexample
  17676. This makes it possible to have a system root that mirrors a target
  17677. with more than one drive. E.g., you may want to setup your local
  17678. copies of the target system shared libraries like so (note @samp{c} vs
  17679. @samp{z}):
  17680. @smallexample
  17681. @file{/path/to/sysroot/c/sys/bin/foo.dll}
  17682. @file{/path/to/sysroot/c/sys/bin/bar.dll}
  17683. @file{/path/to/sysroot/z/sys/bin/bar.dll}
  17684. @end smallexample
  17685. @noindent
  17686. and point the system root at @file{/path/to/sysroot}, so that
  17687. @value{GDBN} can find the correct copies of both
  17688. @file{c:\sys\bin\foo.dll}, and @file{z:\sys\bin\bar.dll}.
  17689. If that still does not find the binary, @value{GDBN} tries
  17690. removing the whole drive spec from the target file name:
  17691. @smallexample
  17692. c:/foo/bar.dll @result{} /path/to/sysroot/foo/bar.dll
  17693. @end smallexample
  17694. This last lookup makes it possible to not care about the drive name,
  17695. if you don't want or need to.
  17696. The @code{set solib-absolute-prefix} command is an alias for @code{set
  17697. sysroot}.
  17698. @cindex default system root
  17699. @cindex @samp{--with-sysroot}
  17700. You can set the default system root by using the configure-time
  17701. @samp{--with-sysroot} option. If the system root is inside
  17702. @value{GDBN}'s configured binary prefix (set with @samp{--prefix} or
  17703. @samp{--exec-prefix}), then the default system root will be updated
  17704. automatically if the installed @value{GDBN} is moved to a new
  17705. location.
  17706. @kindex show sysroot
  17707. @item show sysroot
  17708. Display the current executable and shared library prefix.
  17709. @kindex set solib-search-path
  17710. @item set solib-search-path @var{path}
  17711. If this variable is set, @var{path} is a colon-separated list of
  17712. directories to search for shared libraries. @samp{solib-search-path}
  17713. is used after @samp{sysroot} fails to locate the library, or if the
  17714. path to the library is relative instead of absolute. If you want to
  17715. use @samp{solib-search-path} instead of @samp{sysroot}, be sure to set
  17716. @samp{sysroot} to a nonexistent directory to prevent @value{GDBN} from
  17717. finding your host's libraries. @samp{sysroot} is preferred; setting
  17718. it to a nonexistent directory may interfere with automatic loading
  17719. of shared library symbols.
  17720. @kindex show solib-search-path
  17721. @item show solib-search-path
  17722. Display the current shared library search path.
  17723. @cindex DOS file-name semantics of file names.
  17724. @kindex set target-file-system-kind (unix|dos-based|auto)
  17725. @kindex show target-file-system-kind
  17726. @item set target-file-system-kind @var{kind}
  17727. Set assumed file system kind for target reported file names.
  17728. Shared library file names as reported by the target system may not
  17729. make sense as is on the system @value{GDBN} is running on. For
  17730. example, when remote debugging a target that has MS-DOS based file
  17731. system semantics, from a Unix host, the target may be reporting to
  17732. @value{GDBN} a list of loaded shared libraries with file names such as
  17733. @file{c:\Windows\kernel32.dll}. On Unix hosts, there's no concept of
  17734. drive letters, so the @samp{c:\} prefix is not normally understood as
  17735. indicating an absolute file name, and neither is the backslash
  17736. normally considered a directory separator character. In that case,
  17737. the native file system would interpret this whole absolute file name
  17738. as a relative file name with no directory components. This would make
  17739. it impossible to point @value{GDBN} at a copy of the remote target's
  17740. shared libraries on the host using @code{set sysroot}, and impractical
  17741. with @code{set solib-search-path}. Setting
  17742. @code{target-file-system-kind} to @code{dos-based} tells @value{GDBN}
  17743. to interpret such file names similarly to how the target would, and to
  17744. map them to file names valid on @value{GDBN}'s native file system
  17745. semantics. The value of @var{kind} can be @code{"auto"}, in addition
  17746. to one of the supported file system kinds. In that case, @value{GDBN}
  17747. tries to determine the appropriate file system variant based on the
  17748. current target's operating system (@pxref{ABI, ,Configuring the
  17749. Current ABI}). The supported file system settings are:
  17750. @table @code
  17751. @item unix
  17752. Instruct @value{GDBN} to assume the target file system is of Unix
  17753. kind. Only file names starting the forward slash (@samp{/}) character
  17754. are considered absolute, and the directory separator character is also
  17755. the forward slash.
  17756. @item dos-based
  17757. Instruct @value{GDBN} to assume the target file system is DOS based.
  17758. File names starting with either a forward slash, or a drive letter
  17759. followed by a colon (e.g., @samp{c:}), are considered absolute, and
  17760. both the slash (@samp{/}) and the backslash (@samp{\\}) characters are
  17761. considered directory separators.
  17762. @item auto
  17763. Instruct @value{GDBN} to use the file system kind associated with the
  17764. target operating system (@pxref{ABI, ,Configuring the Current ABI}).
  17765. This is the default.
  17766. @end table
  17767. @end table
  17768. @cindex file name canonicalization
  17769. @cindex base name differences
  17770. When processing file names provided by the user, @value{GDBN}
  17771. frequently needs to compare them to the file names recorded in the
  17772. program's debug info. Normally, @value{GDBN} compares just the
  17773. @dfn{base names} of the files as strings, which is reasonably fast
  17774. even for very large programs. (The base name of a file is the last
  17775. portion of its name, after stripping all the leading directories.)
  17776. This shortcut in comparison is based upon the assumption that files
  17777. cannot have more than one base name. This is usually true, but
  17778. references to files that use symlinks or similar filesystem
  17779. facilities violate that assumption. If your program records files
  17780. using such facilities, or if you provide file names to @value{GDBN}
  17781. using symlinks etc., you can set @code{basenames-may-differ} to
  17782. @code{true} to instruct @value{GDBN} to completely canonicalize each
  17783. pair of file names it needs to compare. This will make file-name
  17784. comparisons accurate, but at a price of a significant slowdown.
  17785. @table @code
  17786. @item set basenames-may-differ
  17787. @kindex set basenames-may-differ
  17788. Set whether a source file may have multiple base names.
  17789. @item show basenames-may-differ
  17790. @kindex show basenames-may-differ
  17791. Show whether a source file may have multiple base names.
  17792. @end table
  17793. @node File Caching
  17794. @section File Caching
  17795. @cindex caching of opened files
  17796. @cindex caching of bfd objects
  17797. To speed up file loading, and reduce memory usage, @value{GDBN} will
  17798. reuse the @code{bfd} objects used to track open files. @xref{Top, ,
  17799. BFD, bfd, The Binary File Descriptor Library}. The following commands
  17800. allow visibility and control of the caching behavior.
  17801. @table @code
  17802. @kindex maint info bfds
  17803. @item maint info bfds
  17804. This prints information about each @code{bfd} object that is known to
  17805. @value{GDBN}.
  17806. @kindex maint set bfd-sharing
  17807. @kindex maint show bfd-sharing
  17808. @kindex bfd caching
  17809. @item maint set bfd-sharing
  17810. @item maint show bfd-sharing
  17811. Control whether @code{bfd} objects can be shared. When sharing is
  17812. enabled @value{GDBN} reuses already open @code{bfd} objects rather
  17813. than reopening the same file. Turning sharing off does not cause
  17814. already shared @code{bfd} objects to be unshared, but all future files
  17815. that are opened will create a new @code{bfd} object. Similarly,
  17816. re-enabling sharing does not cause multiple existing @code{bfd}
  17817. objects to be collapsed into a single shared @code{bfd} object.
  17818. @kindex set debug bfd-cache @var{level}
  17819. @kindex bfd caching
  17820. @item set debug bfd-cache @var{level}
  17821. Turns on debugging of the bfd cache, setting the level to @var{level}.
  17822. @kindex show debug bfd-cache
  17823. @kindex bfd caching
  17824. @item show debug bfd-cache
  17825. Show the current debugging level of the bfd cache.
  17826. @end table
  17827. @node Separate Debug Files
  17828. @section Debugging Information in Separate Files
  17829. @cindex separate debugging information files
  17830. @cindex debugging information in separate files
  17831. @cindex @file{.debug} subdirectories
  17832. @cindex debugging information directory, global
  17833. @cindex global debugging information directories
  17834. @cindex build ID, and separate debugging files
  17835. @cindex @file{.build-id} directory
  17836. @value{GDBN} allows you to put a program's debugging information in a
  17837. file separate from the executable itself, in a way that allows
  17838. @value{GDBN} to find and load the debugging information automatically.
  17839. Since debugging information can be very large---sometimes larger
  17840. than the executable code itself---some systems distribute debugging
  17841. information for their executables in separate files, which users can
  17842. install only when they need to debug a problem.
  17843. @value{GDBN} supports two ways of specifying the separate debug info
  17844. file:
  17845. @itemize @bullet
  17846. @item
  17847. The executable contains a @dfn{debug link} that specifies the name of
  17848. the separate debug info file. The separate debug file's name is
  17849. usually @file{@var{executable}.debug}, where @var{executable} is the
  17850. name of the corresponding executable file without leading directories
  17851. (e.g., @file{ls.debug} for @file{/usr/bin/ls}). In addition, the
  17852. debug link specifies a 32-bit @dfn{Cyclic Redundancy Check} (CRC)
  17853. checksum for the debug file, which @value{GDBN} uses to validate that
  17854. the executable and the debug file came from the same build.
  17855. @item
  17856. @anchor{build ID}
  17857. The executable contains a @dfn{build ID}, a unique bit string that is
  17858. also present in the corresponding debug info file. (This is supported
  17859. only on some operating systems, when using the ELF or PE file formats
  17860. for binary files and the @sc{gnu} Binutils.) For more details about
  17861. this feature, see the description of the @option{--build-id}
  17862. command-line option in @ref{Options, , Command Line Options, ld,
  17863. The GNU Linker}. The debug info file's name is not specified
  17864. explicitly by the build ID, but can be computed from the build ID, see
  17865. below.
  17866. @end itemize
  17867. Depending on the way the debug info file is specified, @value{GDBN}
  17868. uses two different methods of looking for the debug file:
  17869. @itemize @bullet
  17870. @item
  17871. For the ``debug link'' method, @value{GDBN} looks up the named file in
  17872. the directory of the executable file, then in a subdirectory of that
  17873. directory named @file{.debug}, and finally under each one of the
  17874. global debug directories, in a subdirectory whose name is identical to
  17875. the leading directories of the executable's absolute file name. (On
  17876. MS-Windows/MS-DOS, the drive letter of the executable's leading
  17877. directories is converted to a one-letter subdirectory, i.e.@:
  17878. @file{d:/usr/bin/} is converted to @file{/d/usr/bin/}, because Windows
  17879. filesystems disallow colons in file names.)
  17880. @item
  17881. For the ``build ID'' method, @value{GDBN} looks in the
  17882. @file{.build-id} subdirectory of each one of the global debug directories for
  17883. a file named @file{@var{nn}/@var{nnnnnnnn}.debug}, where @var{nn} are the
  17884. first 2 hex characters of the build ID bit string, and @var{nnnnnnnn}
  17885. are the rest of the bit string. (Real build ID strings are 32 or more
  17886. hex characters, not 10.) @value{GDBN} can automatically query
  17887. @code{debuginfod} servers using build IDs in order to download separate debug
  17888. files that cannot be found locally. For more information see @ref{Debuginfod}.
  17889. @end itemize
  17890. So, for example, suppose you ask @value{GDBN} to debug
  17891. @file{/usr/bin/ls}, which has a debug link that specifies the
  17892. file @file{ls.debug}, and a build ID whose value in hex is
  17893. @code{abcdef1234}. If the list of the global debug directories includes
  17894. @file{/usr/lib/debug}, then @value{GDBN} will look for the following
  17895. debug information files, in the indicated order:
  17896. @itemize @minus
  17897. @item
  17898. @file{/usr/lib/debug/.build-id/ab/cdef1234.debug}
  17899. @item
  17900. @file{/usr/bin/ls.debug}
  17901. @item
  17902. @file{/usr/bin/.debug/ls.debug}
  17903. @item
  17904. @file{/usr/lib/debug/usr/bin/ls.debug}.
  17905. @end itemize
  17906. If the debug file still has not been found and @code{debuginfod}
  17907. (@pxref{Debuginfod}) is enabled, @value{GDBN} will attempt to download the
  17908. file from @code{debuginfod} servers.
  17909. @anchor{debug-file-directory}
  17910. Global debugging info directories default to what is set by @value{GDBN}
  17911. configure option @option{--with-separate-debug-dir}. During @value{GDBN} run
  17912. you can also set the global debugging info directories, and view the list
  17913. @value{GDBN} is currently using.
  17914. @table @code
  17915. @kindex set debug-file-directory
  17916. @item set debug-file-directory @var{directories}
  17917. Set the directories which @value{GDBN} searches for separate debugging
  17918. information files to @var{directory}. Multiple path components can be set
  17919. concatenating them by a path separator.
  17920. @kindex show debug-file-directory
  17921. @item show debug-file-directory
  17922. Show the directories @value{GDBN} searches for separate debugging
  17923. information files.
  17924. @end table
  17925. @cindex @code{.gnu_debuglink} sections
  17926. @cindex debug link sections
  17927. A debug link is a special section of the executable file named
  17928. @code{.gnu_debuglink}. The section must contain:
  17929. @itemize
  17930. @item
  17931. A filename, with any leading directory components removed, followed by
  17932. a zero byte,
  17933. @item
  17934. zero to three bytes of padding, as needed to reach the next four-byte
  17935. boundary within the section, and
  17936. @item
  17937. a four-byte CRC checksum, stored in the same endianness used for the
  17938. executable file itself. The checksum is computed on the debugging
  17939. information file's full contents by the function given below, passing
  17940. zero as the @var{crc} argument.
  17941. @end itemize
  17942. Any executable file format can carry a debug link, as long as it can
  17943. contain a section named @code{.gnu_debuglink} with the contents
  17944. described above.
  17945. @cindex @code{.note.gnu.build-id} sections
  17946. @cindex build ID sections
  17947. The build ID is a special section in the executable file (and in other
  17948. ELF binary files that @value{GDBN} may consider). This section is
  17949. often named @code{.note.gnu.build-id}, but that name is not mandatory.
  17950. It contains unique identification for the built files---the ID remains
  17951. the same across multiple builds of the same build tree. The default
  17952. algorithm SHA1 produces 160 bits (40 hexadecimal characters) of the
  17953. content for the build ID string. The same section with an identical
  17954. value is present in the original built binary with symbols, in its
  17955. stripped variant, and in the separate debugging information file.
  17956. The debugging information file itself should be an ordinary
  17957. executable, containing a full set of linker symbols, sections, and
  17958. debugging information. The sections of the debugging information file
  17959. should have the same names, addresses, and sizes as the original file,
  17960. but they need not contain any data---much like a @code{.bss} section
  17961. in an ordinary executable.
  17962. The @sc{gnu} binary utilities (Binutils) package includes the
  17963. @samp{objcopy} utility that can produce
  17964. the separated executable / debugging information file pairs using the
  17965. following commands:
  17966. @smallexample
  17967. @kbd{objcopy --only-keep-debug foo foo.debug}
  17968. @kbd{strip -g foo}
  17969. @end smallexample
  17970. @noindent
  17971. These commands remove the debugging
  17972. information from the executable file @file{foo} and place it in the file
  17973. @file{foo.debug}. You can use the first, second or both methods to link the
  17974. two files:
  17975. @itemize @bullet
  17976. @item
  17977. The debug link method needs the following additional command to also leave
  17978. behind a debug link in @file{foo}:
  17979. @smallexample
  17980. @kbd{objcopy --add-gnu-debuglink=foo.debug foo}
  17981. @end smallexample
  17982. Ulrich Drepper's @file{elfutils} package, starting with version 0.53, contains
  17983. a version of the @code{strip} command such that the command @kbd{strip foo -f
  17984. foo.debug} has the same functionality as the two @code{objcopy} commands and
  17985. the @code{ln -s} command above, together.
  17986. @item
  17987. Build ID gets embedded into the main executable using @code{ld --build-id} or
  17988. the @value{NGCC} counterpart @code{gcc -Wl,--build-id}. Build ID support plus
  17989. compatibility fixes for debug files separation are present in @sc{gnu} binary
  17990. utilities (Binutils) package since version 2.18.
  17991. @end itemize
  17992. @noindent
  17993. @cindex CRC algorithm definition
  17994. The CRC used in @code{.gnu_debuglink} is the CRC-32 defined in
  17995. IEEE 802.3 using the polynomial:
  17996. @c TexInfo requires naked braces for multi-digit exponents for Tex
  17997. @c output, but this causes HTML output to barf. HTML has to be set using
  17998. @c raw commands. So we end up having to specify this equation in 2
  17999. @c different ways!
  18000. @ifhtml
  18001. @display
  18002. @html
  18003. <em>x</em><sup>32</sup> + <em>x</em><sup>26</sup> + <em>x</em><sup>23</sup> + <em>x</em><sup>22</sup> + <em>x</em><sup>16</sup> + <em>x</em><sup>12</sup> + <em>x</em><sup>11</sup>
  18004. + <em>x</em><sup>10</sup> + <em>x</em><sup>8</sup> + <em>x</em><sup>7</sup> + <em>x</em><sup>5</sup> + <em>x</em><sup>4</sup> + <em>x</em><sup>2</sup> + <em>x</em> + 1
  18005. @end html
  18006. @end display
  18007. @end ifhtml
  18008. @ifnothtml
  18009. @display
  18010. @math{x^{32} + x^{26} + x^{23} + x^{22} + x^{16} + x^{12} + x^{11}}
  18011. @math{+ x^{10} + x^8 + x^7 + x^5 + x^4 + x^2 + x + 1}
  18012. @end display
  18013. @end ifnothtml
  18014. The function is computed byte at a time, taking the least
  18015. significant bit of each byte first. The initial pattern
  18016. @code{0xffffffff} is used, to ensure leading zeros affect the CRC and
  18017. the final result is inverted to ensure trailing zeros also affect the
  18018. CRC.
  18019. @emph{Note:} This is the same CRC polynomial as used in handling the
  18020. @dfn{Remote Serial Protocol} @code{qCRC} packet (@pxref{qCRC packet}).
  18021. However in the case of the Remote Serial Protocol, the CRC is computed
  18022. @emph{most} significant bit first, and the result is not inverted, so
  18023. trailing zeros have no effect on the CRC value.
  18024. To complete the description, we show below the code of the function
  18025. which produces the CRC used in @code{.gnu_debuglink}. Inverting the
  18026. initially supplied @code{crc} argument means that an initial call to
  18027. this function passing in zero will start computing the CRC using
  18028. @code{0xffffffff}.
  18029. @kindex gnu_debuglink_crc32
  18030. @smallexample
  18031. unsigned long
  18032. gnu_debuglink_crc32 (unsigned long crc,
  18033. unsigned char *buf, size_t len)
  18034. @{
  18035. static const unsigned long crc32_table[256] =
  18036. @{
  18037. 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
  18038. 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
  18039. 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
  18040. 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
  18041. 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
  18042. 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
  18043. 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
  18044. 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
  18045. 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
  18046. 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
  18047. 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
  18048. 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
  18049. 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
  18050. 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
  18051. 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
  18052. 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
  18053. 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
  18054. 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
  18055. 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
  18056. 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
  18057. 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
  18058. 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
  18059. 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
  18060. 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
  18061. 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
  18062. 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
  18063. 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
  18064. 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
  18065. 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
  18066. 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
  18067. 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
  18068. 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
  18069. 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
  18070. 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
  18071. 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
  18072. 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
  18073. 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
  18074. 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
  18075. 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
  18076. 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
  18077. 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
  18078. 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
  18079. 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
  18080. 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
  18081. 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
  18082. 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
  18083. 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
  18084. 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
  18085. 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
  18086. 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
  18087. 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
  18088. 0x2d02ef8d
  18089. @};
  18090. unsigned char *end;
  18091. crc = ~crc & 0xffffffff;
  18092. for (end = buf + len; buf < end; ++buf)
  18093. crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
  18094. return ~crc & 0xffffffff;
  18095. @}
  18096. @end smallexample
  18097. @noindent
  18098. This computation does not apply to the ``build ID'' method.
  18099. @node MiniDebugInfo
  18100. @section Debugging information in a special section
  18101. @cindex separate debug sections
  18102. @cindex @samp{.gnu_debugdata} section
  18103. Some systems ship pre-built executables and libraries that have a
  18104. special @samp{.gnu_debugdata} section. This feature is called
  18105. @dfn{MiniDebugInfo}. This section holds an LZMA-compressed object and
  18106. is used to supply extra symbols for backtraces.
  18107. The intent of this section is to provide extra minimal debugging
  18108. information for use in simple backtraces. It is not intended to be a
  18109. replacement for full separate debugging information (@pxref{Separate
  18110. Debug Files}). The example below shows the intended use; however,
  18111. @value{GDBN} does not currently put restrictions on what sort of
  18112. debugging information might be included in the section.
  18113. @value{GDBN} has support for this extension. If the section exists,
  18114. then it is used provided that no other source of debugging information
  18115. can be found, and that @value{GDBN} was configured with LZMA support.
  18116. This section can be easily created using @command{objcopy} and other
  18117. standard utilities:
  18118. @smallexample
  18119. # Extract the dynamic symbols from the main binary, there is no need
  18120. # to also have these in the normal symbol table.
  18121. nm -D @var{binary} --format=posix --defined-only \
  18122. | awk '@{ print $1 @}' | sort > dynsyms
  18123. # Extract all the text (i.e. function) symbols from the debuginfo.
  18124. # (Note that we actually also accept "D" symbols, for the benefit
  18125. # of platforms like PowerPC64 that use function descriptors.)
  18126. nm @var{binary} --format=posix --defined-only \
  18127. | awk '@{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 @}' \
  18128. | sort > funcsyms
  18129. # Keep all the function symbols not already in the dynamic symbol
  18130. # table.
  18131. comm -13 dynsyms funcsyms > keep_symbols
  18132. # Separate full debug info into debug binary.
  18133. objcopy --only-keep-debug @var{binary} debug
  18134. # Copy the full debuginfo, keeping only a minimal set of symbols and
  18135. # removing some unnecessary sections.
  18136. objcopy -S --remove-section .gdb_index --remove-section .comment \
  18137. --keep-symbols=keep_symbols debug mini_debuginfo
  18138. # Drop the full debug info from the original binary.
  18139. strip --strip-all -R .comment @var{binary}
  18140. # Inject the compressed data into the .gnu_debugdata section of the
  18141. # original binary.
  18142. xz mini_debuginfo
  18143. objcopy --add-section .gnu_debugdata=mini_debuginfo.xz @var{binary}
  18144. @end smallexample
  18145. @node Index Files
  18146. @section Index Files Speed Up @value{GDBN}
  18147. @cindex index files
  18148. @cindex @samp{.gdb_index} section
  18149. When @value{GDBN} finds a symbol file, it scans the symbols in the
  18150. file in order to construct an internal symbol table. This lets most
  18151. @value{GDBN} operations work quickly---at the cost of a delay early
  18152. on. For large programs, this delay can be quite lengthy, so
  18153. @value{GDBN} provides a way to build an index, which speeds up
  18154. startup.
  18155. For convenience, @value{GDBN} comes with a program,
  18156. @command{gdb-add-index}, which can be used to add the index to a
  18157. symbol file. It takes the symbol file as its only argument:
  18158. @smallexample
  18159. $ gdb-add-index symfile
  18160. @end smallexample
  18161. @xref{gdb-add-index}.
  18162. It is also possible to do the work manually. Here is what
  18163. @command{gdb-add-index} does behind the curtains.
  18164. The index is stored as a section in the symbol file. @value{GDBN} can
  18165. write the index to a file, then you can put it into the symbol file
  18166. using @command{objcopy}.
  18167. To create an index file, use the @code{save gdb-index} command:
  18168. @table @code
  18169. @item save gdb-index [-dwarf-5] @var{directory}
  18170. @kindex save gdb-index
  18171. Create index files for all symbol files currently known by
  18172. @value{GDBN}. For each known @var{symbol-file}, this command by
  18173. default creates it produces a single file
  18174. @file{@var{symbol-file}.gdb-index}. If you invoke this command with
  18175. the @option{-dwarf-5} option, it produces 2 files:
  18176. @file{@var{symbol-file}.debug_names} and
  18177. @file{@var{symbol-file}.debug_str}. The files are created in the
  18178. given @var{directory}.
  18179. @end table
  18180. Once you have created an index file you can merge it into your symbol
  18181. file, here named @file{symfile}, using @command{objcopy}:
  18182. @smallexample
  18183. $ objcopy --add-section .gdb_index=symfile.gdb-index \
  18184. --set-section-flags .gdb_index=readonly symfile symfile
  18185. @end smallexample
  18186. Or for @code{-dwarf-5}:
  18187. @smallexample
  18188. $ objcopy --dump-section .debug_str=symfile.debug_str.new symfile
  18189. $ cat symfile.debug_str >>symfile.debug_str.new
  18190. $ objcopy --add-section .debug_names=symfile.gdb-index \
  18191. --set-section-flags .debug_names=readonly \
  18192. --update-section .debug_str=symfile.debug_str.new symfile symfile
  18193. @end smallexample
  18194. @value{GDBN} will normally ignore older versions of @file{.gdb_index}
  18195. sections that have been deprecated. Usually they are deprecated because
  18196. they are missing a new feature or have performance issues.
  18197. To tell @value{GDBN} to use a deprecated index section anyway
  18198. specify @code{set use-deprecated-index-sections on}.
  18199. The default is @code{off}.
  18200. This can speed up startup, but may result in some functionality being lost.
  18201. @xref{Index Section Format}.
  18202. @emph{Warning:} Setting @code{use-deprecated-index-sections} to @code{on}
  18203. must be done before gdb reads the file. The following will not work:
  18204. @smallexample
  18205. $ gdb -ex "set use-deprecated-index-sections on" <program>
  18206. @end smallexample
  18207. Instead you must do, for example,
  18208. @smallexample
  18209. $ gdb -iex "set use-deprecated-index-sections on" <program>
  18210. @end smallexample
  18211. Indices only work when using DWARF debugging information, not stabs.
  18212. @subsection Automatic symbol index cache
  18213. @cindex automatic symbol index cache
  18214. It is possible for @value{GDBN} to automatically save a copy of this index in a
  18215. cache on disk and retrieve it from there when loading the same binary in the
  18216. future. This feature can be turned on with @kbd{set index-cache enabled on}.
  18217. The following commands can be used to tweak the behavior of the index cache.
  18218. @table @code
  18219. @kindex set index-cache
  18220. @item set index-cache enabled on
  18221. @itemx set index-cache enabled off
  18222. Enable or disable the use of the symbol index cache.
  18223. @item set index-cache directory @var{directory}
  18224. @kindex show index-cache
  18225. @itemx show index-cache directory
  18226. Set/show the directory where index files will be saved.
  18227. The default value for this directory depends on the host platform. On
  18228. most systems, the index is cached in the @file{gdb} subdirectory of
  18229. the directory pointed to by the @env{XDG_CACHE_HOME} environment
  18230. variable, if it is defined, else in the @file{.cache/gdb} subdirectory
  18231. of your home directory. However, on some systems, the default may
  18232. differ according to local convention.
  18233. There is no limit on the disk space used by index cache. It is perfectly safe
  18234. to delete the content of that directory to free up disk space.
  18235. @item show index-cache stats
  18236. Print the number of cache hits and misses since the launch of @value{GDBN}.
  18237. @end table
  18238. @node Symbol Errors
  18239. @section Errors Reading Symbol Files
  18240. While reading a symbol file, @value{GDBN} occasionally encounters problems,
  18241. such as symbol types it does not recognize, or known bugs in compiler
  18242. output. By default, @value{GDBN} does not notify you of such problems, since
  18243. they are relatively common and primarily of interest to people
  18244. debugging compilers. If you are interested in seeing information
  18245. about ill-constructed symbol tables, you can either ask @value{GDBN} to print
  18246. only one message about each such type of problem, no matter how many
  18247. times the problem occurs; or you can ask @value{GDBN} to print more messages,
  18248. to see how many times the problems occur, with the @code{set
  18249. complaints} command (@pxref{Messages/Warnings, ,Optional Warnings and
  18250. Messages}).
  18251. The messages currently printed, and their meanings, include:
  18252. @table @code
  18253. @item inner block not inside outer block in @var{symbol}
  18254. The symbol information shows where symbol scopes begin and end
  18255. (such as at the start of a function or a block of statements). This
  18256. error indicates that an inner scope block is not fully contained
  18257. in its outer scope blocks.
  18258. @value{GDBN} circumvents the problem by treating the inner block as if it had
  18259. the same scope as the outer block. In the error message, @var{symbol}
  18260. may be shown as ``@code{(don't know)}'' if the outer block is not a
  18261. function.
  18262. @item block at @var{address} out of order
  18263. The symbol information for symbol scope blocks should occur in
  18264. order of increasing addresses. This error indicates that it does not
  18265. do so.
  18266. @value{GDBN} does not circumvent this problem, and has trouble
  18267. locating symbols in the source file whose symbols it is reading. (You
  18268. can often determine what source file is affected by specifying
  18269. @code{set verbose on}. @xref{Messages/Warnings, ,Optional Warnings and
  18270. Messages}.)
  18271. @item bad block start address patched
  18272. The symbol information for a symbol scope block has a start address
  18273. smaller than the address of the preceding source line. This is known
  18274. to occur in the SunOS 4.1.1 (and earlier) C compiler.
  18275. @value{GDBN} circumvents the problem by treating the symbol scope block as
  18276. starting on the previous source line.
  18277. @item bad string table offset in symbol @var{n}
  18278. @cindex foo
  18279. Symbol number @var{n} contains a pointer into the string table which is
  18280. larger than the size of the string table.
  18281. @value{GDBN} circumvents the problem by considering the symbol to have the
  18282. name @code{foo}, which may cause other problems if many symbols end up
  18283. with this name.
  18284. @item unknown symbol type @code{0x@var{nn}}
  18285. The symbol information contains new data types that @value{GDBN} does
  18286. not yet know how to read. @code{0x@var{nn}} is the symbol type of the
  18287. uncomprehended information, in hexadecimal.
  18288. @value{GDBN} circumvents the error by ignoring this symbol information.
  18289. This usually allows you to debug your program, though certain symbols
  18290. are not accessible. If you encounter such a problem and feel like
  18291. debugging it, you can debug @code{@value{GDBP}} with itself, breakpoint
  18292. on @code{complain}, then go up to the function @code{read_dbx_symtab}
  18293. and examine @code{*bufp} to see the symbol.
  18294. @item stub type has NULL name
  18295. @value{GDBN} could not find the full definition for a struct or class.
  18296. @item const/volatile indicator missing (ok if using g++ v1.x), got@dots{}
  18297. The symbol information for a C@t{++} member function is missing some
  18298. information that recent versions of the compiler should have output for
  18299. it.
  18300. @item info mismatch between compiler and debugger
  18301. @value{GDBN} could not parse a type specification output by the compiler.
  18302. @end table
  18303. @node Data Files
  18304. @section GDB Data Files
  18305. @cindex prefix for data files
  18306. @value{GDBN} will sometimes read an auxiliary data file. These files
  18307. are kept in a directory known as the @dfn{data directory}.
  18308. You can set the data directory's name, and view the name @value{GDBN}
  18309. is currently using.
  18310. @table @code
  18311. @kindex set data-directory
  18312. @item set data-directory @var{directory}
  18313. Set the directory which @value{GDBN} searches for auxiliary data files
  18314. to @var{directory}.
  18315. @kindex show data-directory
  18316. @item show data-directory
  18317. Show the directory @value{GDBN} searches for auxiliary data files.
  18318. @end table
  18319. @cindex default data directory
  18320. @cindex @samp{--with-gdb-datadir}
  18321. You can set the default data directory by using the configure-time
  18322. @samp{--with-gdb-datadir} option. If the data directory is inside
  18323. @value{GDBN}'s configured binary prefix (set with @samp{--prefix} or
  18324. @samp{--exec-prefix}), then the default data directory will be updated
  18325. automatically if the installed @value{GDBN} is moved to a new
  18326. location.
  18327. The data directory may also be specified with the
  18328. @code{--data-directory} command line option.
  18329. @xref{Mode Options}.
  18330. @node Targets
  18331. @chapter Specifying a Debugging Target
  18332. @cindex debugging target
  18333. A @dfn{target} is the execution environment occupied by your program.
  18334. Often, @value{GDBN} runs in the same host environment as your program;
  18335. in that case, the debugging target is specified as a side effect when
  18336. you use the @code{file} or @code{core} commands. When you need more
  18337. flexibility---for example, running @value{GDBN} on a physically separate
  18338. host, or controlling a standalone system over a serial port or a
  18339. realtime system over a TCP/IP connection---you can use the @code{target}
  18340. command to specify one of the target types configured for @value{GDBN}
  18341. (@pxref{Target Commands, ,Commands for Managing Targets}).
  18342. @cindex target architecture
  18343. It is possible to build @value{GDBN} for several different @dfn{target
  18344. architectures}. When @value{GDBN} is built like that, you can choose
  18345. one of the available architectures with the @kbd{set architecture}
  18346. command.
  18347. @table @code
  18348. @kindex set architecture
  18349. @kindex show architecture
  18350. @item set architecture @var{arch}
  18351. This command sets the current target architecture to @var{arch}. The
  18352. value of @var{arch} can be @code{"auto"}, in addition to one of the
  18353. supported architectures.
  18354. @item show architecture
  18355. Show the current target architecture.
  18356. @item set processor
  18357. @itemx processor
  18358. @kindex set processor
  18359. @kindex show processor
  18360. These are alias commands for, respectively, @code{set architecture}
  18361. and @code{show architecture}.
  18362. @end table
  18363. @menu
  18364. * Active Targets:: Active targets
  18365. * Target Commands:: Commands for managing targets
  18366. * Byte Order:: Choosing target byte order
  18367. @end menu
  18368. @node Active Targets
  18369. @section Active Targets
  18370. @cindex stacking targets
  18371. @cindex active targets
  18372. @cindex multiple targets
  18373. There are multiple classes of targets such as: processes, executable files or
  18374. recording sessions. Core files belong to the process class, making core file
  18375. and process mutually exclusive. Otherwise, @value{GDBN} can work concurrently
  18376. on multiple active targets, one in each class. This allows you to (for
  18377. example) start a process and inspect its activity, while still having access to
  18378. the executable file after the process finishes. Or if you start process
  18379. recording (@pxref{Reverse Execution}) and @code{reverse-step} there, you are
  18380. presented a virtual layer of the recording target, while the process target
  18381. remains stopped at the chronologically last point of the process execution.
  18382. Use the @code{core-file} and @code{exec-file} commands to select a new core
  18383. file or executable target (@pxref{Files, ,Commands to Specify Files}). To
  18384. specify as a target a process that is already running, use the @code{attach}
  18385. command (@pxref{Attach, ,Debugging an Already-running Process}).
  18386. @node Target Commands
  18387. @section Commands for Managing Targets
  18388. @table @code
  18389. @item target @var{type} @var{parameters}
  18390. Connects the @value{GDBN} host environment to a target machine or
  18391. process. A target is typically a protocol for talking to debugging
  18392. facilities. You use the argument @var{type} to specify the type or
  18393. protocol of the target machine.
  18394. Further @var{parameters} are interpreted by the target protocol, but
  18395. typically include things like device names or host names to connect
  18396. with, process numbers, and baud rates.
  18397. The @code{target} command does not repeat if you press @key{RET} again
  18398. after executing the command.
  18399. @kindex help target
  18400. @item help target
  18401. Displays the names of all targets available. To display targets
  18402. currently selected, use either @code{info target} or @code{info files}
  18403. (@pxref{Files, ,Commands to Specify Files}).
  18404. @item help target @var{name}
  18405. Describe a particular target, including any parameters necessary to
  18406. select it.
  18407. @kindex set gnutarget
  18408. @item set gnutarget @var{args}
  18409. @value{GDBN} uses its own library BFD to read your files. @value{GDBN}
  18410. knows whether it is reading an @dfn{executable},
  18411. a @dfn{core}, or a @dfn{.o} file; however, you can specify the file format
  18412. with the @code{set gnutarget} command. Unlike most @code{target} commands,
  18413. with @code{gnutarget} the @code{target} refers to a program, not a machine.
  18414. @quotation
  18415. @emph{Warning:} To specify a file format with @code{set gnutarget},
  18416. you must know the actual BFD name.
  18417. @end quotation
  18418. @noindent
  18419. @xref{Files, , Commands to Specify Files}.
  18420. @kindex show gnutarget
  18421. @item show gnutarget
  18422. Use the @code{show gnutarget} command to display what file format
  18423. @code{gnutarget} is set to read. If you have not set @code{gnutarget},
  18424. @value{GDBN} will determine the file format for each file automatically,
  18425. and @code{show gnutarget} displays @samp{The current BFD target is "auto"}.
  18426. @end table
  18427. @cindex common targets
  18428. Here are some common targets (available, or not, depending on the GDB
  18429. configuration):
  18430. @table @code
  18431. @kindex target
  18432. @item target exec @var{program}
  18433. @cindex executable file target
  18434. An executable file. @samp{target exec @var{program}} is the same as
  18435. @samp{exec-file @var{program}}.
  18436. @item target core @var{filename}
  18437. @cindex core dump file target
  18438. A core dump file. @samp{target core @var{filename}} is the same as
  18439. @samp{core-file @var{filename}}.
  18440. @item target remote @var{medium}
  18441. @cindex remote target
  18442. A remote system connected to @value{GDBN} via a serial line or network
  18443. connection. This command tells @value{GDBN} to use its own remote
  18444. protocol over @var{medium} for debugging. @xref{Remote Debugging}.
  18445. For example, if you have a board connected to @file{/dev/ttya} on the
  18446. machine running @value{GDBN}, you could say:
  18447. @smallexample
  18448. target remote /dev/ttya
  18449. @end smallexample
  18450. @code{target remote} supports the @code{load} command. This is only
  18451. useful if you have some other way of getting the stub to the target
  18452. system, and you can put it somewhere in memory where it won't get
  18453. clobbered by the download.
  18454. @item target sim @r{[}@var{simargs}@r{]} @dots{}
  18455. @cindex built-in simulator target
  18456. Builtin CPU simulator. @value{GDBN} includes simulators for most architectures.
  18457. In general,
  18458. @smallexample
  18459. target sim
  18460. load
  18461. run
  18462. @end smallexample
  18463. @noindent
  18464. works; however, you cannot assume that a specific memory map, device
  18465. drivers, or even basic I/O is available, although some simulators do
  18466. provide these. For info about any processor-specific simulator details,
  18467. see the appropriate section in @ref{Embedded Processors, ,Embedded
  18468. Processors}.
  18469. @item target native
  18470. @cindex native target
  18471. Setup for local/native process debugging. Useful to make the
  18472. @code{run} command spawn native processes (likewise @code{attach},
  18473. etc.@:) even when @code{set auto-connect-native-target} is @code{off}
  18474. (@pxref{set auto-connect-native-target}).
  18475. @end table
  18476. Different targets are available on different configurations of @value{GDBN};
  18477. your configuration may have more or fewer targets.
  18478. Many remote targets require you to download the executable's code once
  18479. you've successfully established a connection. You may wish to control
  18480. various aspects of this process.
  18481. @table @code
  18482. @item set hash
  18483. @kindex set hash@r{, for remote monitors}
  18484. @cindex hash mark while downloading
  18485. This command controls whether a hash mark @samp{#} is displayed while
  18486. downloading a file to the remote monitor. If on, a hash mark is
  18487. displayed after each S-record is successfully downloaded to the
  18488. monitor.
  18489. @item show hash
  18490. @kindex show hash@r{, for remote monitors}
  18491. Show the current status of displaying the hash mark.
  18492. @item set debug monitor
  18493. @kindex set debug monitor
  18494. @cindex display remote monitor communications
  18495. Enable or disable display of communications messages between
  18496. @value{GDBN} and the remote monitor.
  18497. @item show debug monitor
  18498. @kindex show debug monitor
  18499. Show the current status of displaying communications between
  18500. @value{GDBN} and the remote monitor.
  18501. @end table
  18502. @table @code
  18503. @kindex load @var{filename} @var{offset}
  18504. @item load @var{filename} @var{offset}
  18505. @anchor{load}
  18506. Depending on what remote debugging facilities are configured into
  18507. @value{GDBN}, the @code{load} command may be available. Where it exists, it
  18508. is meant to make @var{filename} (an executable) available for debugging
  18509. on the remote system---by downloading, or dynamic linking, for example.
  18510. @code{load} also records the @var{filename} symbol table in @value{GDBN}, like
  18511. the @code{add-symbol-file} command.
  18512. If your @value{GDBN} does not have a @code{load} command, attempting to
  18513. execute it gets the error message ``@code{You can't do that when your
  18514. target is @dots{}}''
  18515. The file is loaded at whatever address is specified in the executable.
  18516. For some object file formats, you can specify the load address when you
  18517. link the program; for other formats, like a.out, the object file format
  18518. specifies a fixed address.
  18519. @c FIXME! This would be a good place for an xref to the GNU linker doc.
  18520. It is also possible to tell @value{GDBN} to load the executable file at a
  18521. specific offset described by the optional argument @var{offset}. When
  18522. @var{offset} is provided, @var{filename} must also be provided.
  18523. Depending on the remote side capabilities, @value{GDBN} may be able to
  18524. load programs into flash memory.
  18525. @code{load} does not repeat if you press @key{RET} again after using it.
  18526. @end table
  18527. @table @code
  18528. @kindex flash-erase
  18529. @item flash-erase
  18530. @anchor{flash-erase}
  18531. Erases all known flash memory regions on the target.
  18532. @end table
  18533. @node Byte Order
  18534. @section Choosing Target Byte Order
  18535. @cindex choosing target byte order
  18536. @cindex target byte order
  18537. Some types of processors, such as the @acronym{MIPS}, PowerPC, and Renesas SH,
  18538. offer the ability to run either big-endian or little-endian byte
  18539. orders. Usually the executable or symbol will include a bit to
  18540. designate the endian-ness, and you will not need to worry about
  18541. which to use. However, you may still find it useful to adjust
  18542. @value{GDBN}'s idea of processor endian-ness manually.
  18543. @table @code
  18544. @kindex set endian
  18545. @item set endian big
  18546. Instruct @value{GDBN} to assume the target is big-endian.
  18547. @item set endian little
  18548. Instruct @value{GDBN} to assume the target is little-endian.
  18549. @item set endian auto
  18550. Instruct @value{GDBN} to use the byte order associated with the
  18551. executable.
  18552. @item show endian
  18553. Display @value{GDBN}'s current idea of the target byte order.
  18554. @end table
  18555. If the @code{set endian auto} mode is in effect and no executable has
  18556. been selected, then the endianness used is the last one chosen either
  18557. by one of the @code{set endian big} and @code{set endian little}
  18558. commands or by inferring from the last executable used. If no
  18559. endianness has been previously chosen, then the default for this mode
  18560. is inferred from the target @value{GDBN} has been built for, and is
  18561. @code{little} if the name of the target CPU has an @code{el} suffix
  18562. and @code{big} otherwise.
  18563. Note that these commands merely adjust interpretation of symbolic
  18564. data on the host, and that they have absolutely no effect on the
  18565. target system.
  18566. @node Remote Debugging
  18567. @chapter Debugging Remote Programs
  18568. @cindex remote debugging
  18569. If you are trying to debug a program running on a machine that cannot run
  18570. @value{GDBN} in the usual way, it is often useful to use remote debugging.
  18571. For example, you might use remote debugging on an operating system kernel,
  18572. or on a small system which does not have a general purpose operating system
  18573. powerful enough to run a full-featured debugger.
  18574. Some configurations of @value{GDBN} have special serial or TCP/IP interfaces
  18575. to make this work with particular debugging targets. In addition,
  18576. @value{GDBN} comes with a generic serial protocol (specific to @value{GDBN},
  18577. but not specific to any particular target system) which you can use if you
  18578. write the remote stubs---the code that runs on the remote system to
  18579. communicate with @value{GDBN}.
  18580. Other remote targets may be available in your
  18581. configuration of @value{GDBN}; use @code{help target} to list them.
  18582. @menu
  18583. * Connecting:: Connecting to a remote target
  18584. * File Transfer:: Sending files to a remote system
  18585. * Server:: Using the gdbserver program
  18586. * Remote Configuration:: Remote configuration
  18587. * Remote Stub:: Implementing a remote stub
  18588. @end menu
  18589. @node Connecting
  18590. @section Connecting to a Remote Target
  18591. @cindex remote debugging, connecting
  18592. @cindex @code{gdbserver}, connecting
  18593. @cindex remote debugging, types of connections
  18594. @cindex @code{gdbserver}, types of connections
  18595. @cindex @code{gdbserver}, @code{target remote} mode
  18596. @cindex @code{gdbserver}, @code{target extended-remote} mode
  18597. This section describes how to connect to a remote target, including the
  18598. types of connections and their differences, how to set up executable and
  18599. symbol files on the host and target, and the commands used for
  18600. connecting to and disconnecting from the remote target.
  18601. @subsection Types of Remote Connections
  18602. @value{GDBN} supports two types of remote connections, @code{target remote}
  18603. mode and @code{target extended-remote} mode. Note that many remote targets
  18604. support only @code{target remote} mode. There are several major
  18605. differences between the two types of connections, enumerated here:
  18606. @table @asis
  18607. @cindex remote debugging, detach and program exit
  18608. @item Result of detach or program exit
  18609. @strong{With target remote mode:} When the debugged program exits or you
  18610. detach from it, @value{GDBN} disconnects from the target. When using
  18611. @code{gdbserver}, @code{gdbserver} will exit.
  18612. @strong{With target extended-remote mode:} When the debugged program exits or
  18613. you detach from it, @value{GDBN} remains connected to the target, even
  18614. though no program is running. You can rerun the program, attach to a
  18615. running program, or use @code{monitor} commands specific to the target.
  18616. When using @code{gdbserver} in this case, it does not exit unless it was
  18617. invoked using the @option{--once} option. If the @option{--once} option
  18618. was not used, you can ask @code{gdbserver} to exit using the
  18619. @code{monitor exit} command (@pxref{Monitor Commands for gdbserver}).
  18620. @item Specifying the program to debug
  18621. For both connection types you use the @code{file} command to specify the
  18622. program on the host system. If you are using @code{gdbserver} there are
  18623. some differences in how to specify the location of the program on the
  18624. target.
  18625. @strong{With target remote mode:} You must either specify the program to debug
  18626. on the @code{gdbserver} command line or use the @option{--attach} option
  18627. (@pxref{Attaching to a program,,Attaching to a Running Program}).
  18628. @cindex @option{--multi}, @code{gdbserver} option
  18629. @strong{With target extended-remote mode:} You may specify the program to debug
  18630. on the @code{gdbserver} command line, or you can load the program or attach
  18631. to it using @value{GDBN} commands after connecting to @code{gdbserver}.
  18632. @anchor{--multi Option in Types of Remote Connnections}
  18633. You can start @code{gdbserver} without supplying an initial command to run
  18634. or process ID to attach. To do this, use the @option{--multi} command line
  18635. option. Then you can connect using @code{target extended-remote} and start
  18636. the program you want to debug (see below for details on using the
  18637. @code{run} command in this scenario). Note that the conditions under which
  18638. @code{gdbserver} terminates depend on how @value{GDBN} connects to it
  18639. (@code{target remote} or @code{target extended-remote}). The
  18640. @option{--multi} option to @code{gdbserver} has no influence on that.
  18641. @item The @code{run} command
  18642. @strong{With target remote mode:} The @code{run} command is not
  18643. supported. Once a connection has been established, you can use all
  18644. the usual @value{GDBN} commands to examine and change data. The
  18645. remote program is already running, so you can use commands like
  18646. @kbd{step} and @kbd{continue}.
  18647. @strong{With target extended-remote mode:} The @code{run} command is
  18648. supported. The @code{run} command uses the value set by
  18649. @code{set remote exec-file} (@pxref{set remote exec-file}) to select
  18650. the program to run. Command line arguments are supported, except for
  18651. wildcard expansion and I/O redirection (@pxref{Arguments}).
  18652. If you specify the program to debug on the command line, then the
  18653. @code{run} command is not required to start execution, and you can
  18654. resume using commands like @kbd{step} and @kbd{continue} as with
  18655. @code{target remote} mode.
  18656. @anchor{Attaching in Types of Remote Connections}
  18657. @item Attaching
  18658. @strong{With target remote mode:} The @value{GDBN} command @code{attach} is
  18659. not supported. To attach to a running program using @code{gdbserver}, you
  18660. must use the @option{--attach} option (@pxref{Running gdbserver}).
  18661. @strong{With target extended-remote mode:} To attach to a running program,
  18662. you may use the @code{attach} command after the connection has been
  18663. established. If you are using @code{gdbserver}, you may also invoke
  18664. @code{gdbserver} using the @option{--attach} option
  18665. (@pxref{Running gdbserver}).
  18666. Some remote targets allow @value{GDBN} to determine the executable file running
  18667. in the process the debugger is attaching to. In such a case, @value{GDBN}
  18668. uses the value of @code{exec-file-mismatch} to handle a possible mismatch
  18669. between the executable file name running in the process and the name of the
  18670. current exec-file loaded by @value{GDBN} (@pxref{set exec-file-mismatch}).
  18671. @end table
  18672. @anchor{Host and target files}
  18673. @subsection Host and Target Files
  18674. @cindex remote debugging, symbol files
  18675. @cindex symbol files, remote debugging
  18676. @value{GDBN}, running on the host, needs access to symbol and debugging
  18677. information for your program running on the target. This requires
  18678. access to an unstripped copy of your program, and possibly any associated
  18679. symbol files. Note that this section applies equally to both @code{target
  18680. remote} mode and @code{target extended-remote} mode.
  18681. Some remote targets (@pxref{qXfer executable filename read}, and
  18682. @pxref{Host I/O Packets}) allow @value{GDBN} to access program files over
  18683. the same connection used to communicate with @value{GDBN}. With such a
  18684. target, if the remote program is unstripped, the only command you need is
  18685. @code{target remote} (or @code{target extended-remote}).
  18686. If the remote program is stripped, or the target does not support remote
  18687. program file access, start up @value{GDBN} using the name of the local
  18688. unstripped copy of your program as the first argument, or use the
  18689. @code{file} command. Use @code{set sysroot} to specify the location (on
  18690. the host) of target libraries (unless your @value{GDBN} was compiled with
  18691. the correct sysroot using @code{--with-sysroot}). Alternatively, you
  18692. may use @code{set solib-search-path} to specify how @value{GDBN} locates
  18693. target libraries.
  18694. The symbol file and target libraries must exactly match the executable
  18695. and libraries on the target, with one exception: the files on the host
  18696. system should not be stripped, even if the files on the target system
  18697. are. Mismatched or missing files will lead to confusing results
  18698. during debugging. On @sc{gnu}/Linux targets, mismatched or missing
  18699. files may also prevent @code{gdbserver} from debugging multi-threaded
  18700. programs.
  18701. @subsection Remote Connection Commands
  18702. @cindex remote connection commands
  18703. @value{GDBN} can communicate with the target over a serial line, a
  18704. local Unix domain socket, or
  18705. over an @acronym{IP} network using @acronym{TCP} or @acronym{UDP}. In
  18706. each case, @value{GDBN} uses the same protocol for debugging your
  18707. program; only the medium carrying the debugging packets varies. The
  18708. @code{target remote} and @code{target extended-remote} commands
  18709. establish a connection to the target. Both commands accept the same
  18710. arguments, which indicate the medium to use:
  18711. @table @code
  18712. @item target remote @var{serial-device}
  18713. @itemx target extended-remote @var{serial-device}
  18714. @cindex serial line, @code{target remote}
  18715. Use @var{serial-device} to communicate with the target. For example,
  18716. to use a serial line connected to the device named @file{/dev/ttyb}:
  18717. @smallexample
  18718. target remote /dev/ttyb
  18719. @end smallexample
  18720. If you're using a serial line, you may want to give @value{GDBN} the
  18721. @samp{--baud} option, or use the @code{set serial baud} command
  18722. (@pxref{Remote Configuration, set serial baud}) before the
  18723. @code{target} command.
  18724. @item target remote @var{local-socket}
  18725. @itemx target extended-remote @var{local-socket}
  18726. @cindex local socket, @code{target remote}
  18727. @cindex Unix domain socket
  18728. Use @var{local-socket} to communicate with the target. For example,
  18729. to use a local Unix domain socket bound to the file system entry @file{/tmp/gdb-socket0}:
  18730. @smallexample
  18731. target remote /tmp/gdb-socket0
  18732. @end smallexample
  18733. Note that this command has the same form as the command to connect
  18734. to a serial line. @value{GDBN} will automatically determine which
  18735. kind of file you have specified and will make the appropriate kind
  18736. of connection.
  18737. This feature is not available if the host system does not support
  18738. Unix domain sockets.
  18739. @item target remote @code{@var{host}:@var{port}}
  18740. @itemx target remote @code{[@var{host}]:@var{port}}
  18741. @itemx target remote @code{tcp:@var{host}:@var{port}}
  18742. @itemx target remote @code{tcp:[@var{host}]:@var{port}}
  18743. @itemx target remote @code{tcp4:@var{host}:@var{port}}
  18744. @itemx target remote @code{tcp6:@var{host}:@var{port}}
  18745. @itemx target remote @code{tcp6:[@var{host}]:@var{port}}
  18746. @itemx target extended-remote @code{@var{host}:@var{port}}
  18747. @itemx target extended-remote @code{[@var{host}]:@var{port}}
  18748. @itemx target extended-remote @code{tcp:@var{host}:@var{port}}
  18749. @itemx target extended-remote @code{tcp:[@var{host}]:@var{port}}
  18750. @itemx target extended-remote @code{tcp4:@var{host}:@var{port}}
  18751. @itemx target extended-remote @code{tcp6:@var{host}:@var{port}}
  18752. @itemx target extended-remote @code{tcp6:[@var{host}]:@var{port}}
  18753. @cindex @acronym{TCP} port, @code{target remote}
  18754. Debug using a @acronym{TCP} connection to @var{port} on @var{host}.
  18755. The @var{host} may be either a host name, a numeric @acronym{IPv4}
  18756. address, or a numeric @acronym{IPv6} address (with or without the
  18757. square brackets to separate the address from the port); @var{port}
  18758. must be a decimal number. The @var{host} could be the target machine
  18759. itself, if it is directly connected to the net, or it might be a
  18760. terminal server which in turn has a serial line to the target.
  18761. For example, to connect to port 2828 on a terminal server named
  18762. @code{manyfarms}:
  18763. @smallexample
  18764. target remote manyfarms:2828
  18765. @end smallexample
  18766. To connect to port 2828 on a terminal server whose address is
  18767. @code{2001:0db8:85a3:0000:0000:8a2e:0370:7334}, you can either use the
  18768. square bracket syntax:
  18769. @smallexample
  18770. target remote [2001:0db8:85a3:0000:0000:8a2e:0370:7334]:2828
  18771. @end smallexample
  18772. @noindent
  18773. or explicitly specify the @acronym{IPv6} protocol:
  18774. @smallexample
  18775. target remote tcp6:2001:0db8:85a3:0000:0000:8a2e:0370:7334:2828
  18776. @end smallexample
  18777. This last example may be confusing to the reader, because there is no
  18778. visible separation between the hostname and the port number.
  18779. Therefore, we recommend the user to provide @acronym{IPv6} addresses
  18780. using square brackets for clarity. However, it is important to
  18781. mention that for @value{GDBN} there is no ambiguity: the number after
  18782. the last colon is considered to be the port number.
  18783. If your remote target is actually running on the same machine as your
  18784. debugger session (e.g.@: a simulator for your target running on the
  18785. same host), you can omit the hostname. For example, to connect to
  18786. port 1234 on your local machine:
  18787. @smallexample
  18788. target remote :1234
  18789. @end smallexample
  18790. @noindent
  18791. Note that the colon is still required here.
  18792. @item target remote @code{udp:@var{host}:@var{port}}
  18793. @itemx target remote @code{udp:[@var{host}]:@var{port}}
  18794. @itemx target remote @code{udp4:@var{host}:@var{port}}
  18795. @itemx target remote @code{udp6:[@var{host}]:@var{port}}
  18796. @itemx target extended-remote @code{udp:@var{host}:@var{port}}
  18797. @itemx target extended-remote @code{udp:@var{host}:@var{port}}
  18798. @itemx target extended-remote @code{udp:[@var{host}]:@var{port}}
  18799. @itemx target extended-remote @code{udp4:@var{host}:@var{port}}
  18800. @itemx target extended-remote @code{udp6:@var{host}:@var{port}}
  18801. @itemx target extended-remote @code{udp6:[@var{host}]:@var{port}}
  18802. @cindex @acronym{UDP} port, @code{target remote}
  18803. Debug using @acronym{UDP} packets to @var{port} on @var{host}. For example, to
  18804. connect to @acronym{UDP} port 2828 on a terminal server named @code{manyfarms}:
  18805. @smallexample
  18806. target remote udp:manyfarms:2828
  18807. @end smallexample
  18808. When using a @acronym{UDP} connection for remote debugging, you should
  18809. keep in mind that the `U' stands for ``Unreliable''. @acronym{UDP}
  18810. can silently drop packets on busy or unreliable networks, which will
  18811. cause havoc with your debugging session.
  18812. @item target remote | @var{command}
  18813. @itemx target extended-remote | @var{command}
  18814. @cindex pipe, @code{target remote} to
  18815. Run @var{command} in the background and communicate with it using a
  18816. pipe. The @var{command} is a shell command, to be parsed and expanded
  18817. by the system's command shell, @code{/bin/sh}; it should expect remote
  18818. protocol packets on its standard input, and send replies on its
  18819. standard output. You could use this to run a stand-alone simulator
  18820. that speaks the remote debugging protocol, to make net connections
  18821. using programs like @code{ssh}, or for other similar tricks.
  18822. If @var{command} closes its standard output (perhaps by exiting),
  18823. @value{GDBN} will try to send it a @code{SIGTERM} signal. (If the
  18824. program has already exited, this will have no effect.)
  18825. @end table
  18826. @cindex interrupting remote programs
  18827. @cindex remote programs, interrupting
  18828. Whenever @value{GDBN} is waiting for the remote program, if you type the
  18829. interrupt character (often @kbd{Ctrl-c}), @value{GDBN} attempts to stop the
  18830. program. This may or may not succeed, depending in part on the hardware
  18831. and the serial drivers the remote system uses. If you type the
  18832. interrupt character once again, @value{GDBN} displays this prompt:
  18833. @smallexample
  18834. Interrupted while waiting for the program.
  18835. Give up (and stop debugging it)? (y or n)
  18836. @end smallexample
  18837. In @code{target remote} mode, if you type @kbd{y}, @value{GDBN} abandons
  18838. the remote debugging session. (If you decide you want to try again later,
  18839. you can use @kbd{target remote} again to connect once more.) If you type
  18840. @kbd{n}, @value{GDBN} goes back to waiting.
  18841. In @code{target extended-remote} mode, typing @kbd{n} will leave
  18842. @value{GDBN} connected to the target.
  18843. @table @code
  18844. @kindex detach (remote)
  18845. @item detach
  18846. When you have finished debugging the remote program, you can use the
  18847. @code{detach} command to release it from @value{GDBN} control.
  18848. Detaching from the target normally resumes its execution, but the results
  18849. will depend on your particular remote stub. After the @code{detach}
  18850. command in @code{target remote} mode, @value{GDBN} is free to connect to
  18851. another target. In @code{target extended-remote} mode, @value{GDBN} is
  18852. still connected to the target.
  18853. @kindex disconnect
  18854. @item disconnect
  18855. The @code{disconnect} command closes the connection to the target, and
  18856. the target is generally not resumed. It will wait for @value{GDBN}
  18857. (this instance or another one) to connect and continue debugging. After
  18858. the @code{disconnect} command, @value{GDBN} is again free to connect to
  18859. another target.
  18860. @cindex send command to remote monitor
  18861. @cindex extend @value{GDBN} for remote targets
  18862. @cindex add new commands for external monitor
  18863. @kindex monitor
  18864. @item monitor @var{cmd}
  18865. This command allows you to send arbitrary commands directly to the
  18866. remote monitor. Since @value{GDBN} doesn't care about the commands it
  18867. sends like this, this command is the way to extend @value{GDBN}---you
  18868. can add new commands that only the external monitor will understand
  18869. and implement.
  18870. @end table
  18871. @node File Transfer
  18872. @section Sending files to a remote system
  18873. @cindex remote target, file transfer
  18874. @cindex file transfer
  18875. @cindex sending files to remote systems
  18876. Some remote targets offer the ability to transfer files over the same
  18877. connection used to communicate with @value{GDBN}. This is convenient
  18878. for targets accessible through other means, e.g.@: @sc{gnu}/Linux systems
  18879. running @code{gdbserver} over a network interface. For other targets,
  18880. e.g.@: embedded devices with only a single serial port, this may be
  18881. the only way to upload or download files.
  18882. Not all remote targets support these commands.
  18883. @table @code
  18884. @kindex remote put
  18885. @item remote put @var{hostfile} @var{targetfile}
  18886. Copy file @var{hostfile} from the host system (the machine running
  18887. @value{GDBN}) to @var{targetfile} on the target system.
  18888. @kindex remote get
  18889. @item remote get @var{targetfile} @var{hostfile}
  18890. Copy file @var{targetfile} from the target system to @var{hostfile}
  18891. on the host system.
  18892. @kindex remote delete
  18893. @item remote delete @var{targetfile}
  18894. Delete @var{targetfile} from the target system.
  18895. @end table
  18896. @node Server
  18897. @section Using the @code{gdbserver} Program
  18898. @kindex gdbserver
  18899. @cindex remote connection without stubs
  18900. @code{gdbserver} is a control program for Unix-like systems, which
  18901. allows you to connect your program with a remote @value{GDBN} via
  18902. @code{target remote} or @code{target extended-remote}---but without
  18903. linking in the usual debugging stub.
  18904. @code{gdbserver} is not a complete replacement for the debugging stubs,
  18905. because it requires essentially the same operating-system facilities
  18906. that @value{GDBN} itself does. In fact, a system that can run
  18907. @code{gdbserver} to connect to a remote @value{GDBN} could also run
  18908. @value{GDBN} locally! @code{gdbserver} is sometimes useful nevertheless,
  18909. because it is a much smaller program than @value{GDBN} itself. It is
  18910. also easier to port than all of @value{GDBN}, so you may be able to get
  18911. started more quickly on a new system by using @code{gdbserver}.
  18912. Finally, if you develop code for real-time systems, you may find that
  18913. the tradeoffs involved in real-time operation make it more convenient to
  18914. do as much development work as possible on another system, for example
  18915. by cross-compiling. You can use @code{gdbserver} to make a similar
  18916. choice for debugging.
  18917. @value{GDBN} and @code{gdbserver} communicate via either a serial line
  18918. or a TCP connection, using the standard @value{GDBN} remote serial
  18919. protocol.
  18920. @quotation
  18921. @emph{Warning:} @code{gdbserver} does not have any built-in security.
  18922. Do not run @code{gdbserver} connected to any public network; a
  18923. @value{GDBN} connection to @code{gdbserver} provides access to the
  18924. target system with the same privileges as the user running
  18925. @code{gdbserver}.
  18926. @end quotation
  18927. @anchor{Running gdbserver}
  18928. @subsection Running @code{gdbserver}
  18929. @cindex arguments, to @code{gdbserver}
  18930. @cindex @code{gdbserver}, command-line arguments
  18931. Run @code{gdbserver} on the target system. You need a copy of the
  18932. program you want to debug, including any libraries it requires.
  18933. @code{gdbserver} does not need your program's symbol table, so you can
  18934. strip the program if necessary to save space. @value{GDBN} on the host
  18935. system does all the symbol handling.
  18936. To use the server, you must tell it how to communicate with @value{GDBN};
  18937. the name of your program; and the arguments for your program. The usual
  18938. syntax is:
  18939. @smallexample
  18940. target> gdbserver @var{comm} @var{program} [ @var{args} @dots{} ]
  18941. @end smallexample
  18942. @var{comm} is either a device name (to use a serial line), or a TCP
  18943. hostname and portnumber, or @code{-} or @code{stdio} to use
  18944. stdin/stdout of @code{gdbserver}.
  18945. For example, to debug Emacs with the argument
  18946. @samp{foo.txt} and communicate with @value{GDBN} over the serial port
  18947. @file{/dev/com1}:
  18948. @smallexample
  18949. target> gdbserver /dev/com1 emacs foo.txt
  18950. @end smallexample
  18951. @code{gdbserver} waits passively for the host @value{GDBN} to communicate
  18952. with it.
  18953. To use a TCP connection instead of a serial line:
  18954. @smallexample
  18955. target> gdbserver host:2345 emacs foo.txt
  18956. @end smallexample
  18957. The only difference from the previous example is the first argument,
  18958. specifying that you are communicating with the host @value{GDBN} via
  18959. TCP. The @samp{host:2345} argument means that @code{gdbserver} is to
  18960. expect a TCP connection from machine @samp{host} to local TCP port 2345.
  18961. (Currently, the @samp{host} part is ignored.) You can choose any number
  18962. you want for the port number as long as it does not conflict with any
  18963. TCP ports already in use on the target system (for example, @code{23} is
  18964. reserved for @code{telnet}).@footnote{If you choose a port number that
  18965. conflicts with another service, @code{gdbserver} prints an error message
  18966. and exits.} You must use the same port number with the host @value{GDBN}
  18967. @code{target remote} command.
  18968. The @code{stdio} connection is useful when starting @code{gdbserver}
  18969. with ssh:
  18970. @smallexample
  18971. (gdb) target remote | ssh -T hostname gdbserver - hello
  18972. @end smallexample
  18973. The @samp{-T} option to ssh is provided because we don't need a remote pty,
  18974. and we don't want escape-character handling. Ssh does this by default when
  18975. a command is provided, the flag is provided to make it explicit.
  18976. You could elide it if you want to.
  18977. Programs started with stdio-connected gdbserver have @file{/dev/null} for
  18978. @code{stdin}, and @code{stdout},@code{stderr} are sent back to gdb for
  18979. display through a pipe connected to gdbserver.
  18980. Both @code{stdout} and @code{stderr} use the same pipe.
  18981. @anchor{Attaching to a program}
  18982. @subsubsection Attaching to a Running Program
  18983. @cindex attach to a program, @code{gdbserver}
  18984. @cindex @option{--attach}, @code{gdbserver} option
  18985. On some targets, @code{gdbserver} can also attach to running programs.
  18986. This is accomplished via the @code{--attach} argument. The syntax is:
  18987. @smallexample
  18988. target> gdbserver --attach @var{comm} @var{pid}
  18989. @end smallexample
  18990. @var{pid} is the process ID of a currently running process. It isn't
  18991. necessary to point @code{gdbserver} at a binary for the running process.
  18992. In @code{target extended-remote} mode, you can also attach using the
  18993. @value{GDBN} attach command
  18994. (@pxref{Attaching in Types of Remote Connections}).
  18995. @pindex pidof
  18996. You can debug processes by name instead of process ID if your target has the
  18997. @code{pidof} utility:
  18998. @smallexample
  18999. target> gdbserver --attach @var{comm} `pidof @var{program}`
  19000. @end smallexample
  19001. In case more than one copy of @var{program} is running, or @var{program}
  19002. has multiple threads, most versions of @code{pidof} support the
  19003. @code{-s} option to only return the first process ID.
  19004. @subsubsection TCP port allocation lifecycle of @code{gdbserver}
  19005. This section applies only when @code{gdbserver} is run to listen on a TCP
  19006. port.
  19007. @code{gdbserver} normally terminates after all of its debugged processes have
  19008. terminated in @kbd{target remote} mode. On the other hand, for @kbd{target
  19009. extended-remote}, @code{gdbserver} stays running even with no processes left.
  19010. @value{GDBN} normally terminates the spawned debugged process on its exit,
  19011. which normally also terminates @code{gdbserver} in the @kbd{target remote}
  19012. mode. Therefore, when the connection drops unexpectedly, and @value{GDBN}
  19013. cannot ask @code{gdbserver} to kill its debugged processes, @code{gdbserver}
  19014. stays running even in the @kbd{target remote} mode.
  19015. When @code{gdbserver} stays running, @value{GDBN} can connect to it again later.
  19016. Such reconnecting is useful for features like @ref{disconnected tracing}. For
  19017. completeness, at most one @value{GDBN} can be connected at a time.
  19018. @cindex @option{--once}, @code{gdbserver} option
  19019. By default, @code{gdbserver} keeps the listening TCP port open, so that
  19020. subsequent connections are possible. However, if you start @code{gdbserver}
  19021. with the @option{--once} option, it will stop listening for any further
  19022. connection attempts after connecting to the first @value{GDBN} session. This
  19023. means no further connections to @code{gdbserver} will be possible after the
  19024. first one. It also means @code{gdbserver} will terminate after the first
  19025. connection with remote @value{GDBN} has closed, even for unexpectedly closed
  19026. connections and even in the @kbd{target extended-remote} mode. The
  19027. @option{--once} option allows reusing the same port number for connecting to
  19028. multiple instances of @code{gdbserver} running on the same host, since each
  19029. instance closes its port after the first connection.
  19030. @anchor{Other Command-Line Arguments for gdbserver}
  19031. @subsubsection Other Command-Line Arguments for @code{gdbserver}
  19032. You can use the @option{--multi} option to start @code{gdbserver} without
  19033. specifying a program to debug or a process to attach to. Then you can
  19034. attach in @code{target extended-remote} mode and run or attach to a
  19035. program. For more information,
  19036. @pxref{--multi Option in Types of Remote Connnections}.
  19037. @cindex @option{--debug}, @code{gdbserver} option
  19038. The @option{--debug} option tells @code{gdbserver} to display extra
  19039. status information about the debugging process.
  19040. @cindex @option{--remote-debug}, @code{gdbserver} option
  19041. The @option{--remote-debug} option tells @code{gdbserver} to display
  19042. remote protocol debug output.
  19043. @cindex @option{--debug-file}, @code{gdbserver} option
  19044. @cindex @code{gdbserver}, send all debug output to a single file
  19045. The @option{--debug-file=@var{filename}} option tells @code{gdbserver} to
  19046. write any debug output to the given @var{filename}. These options are intended
  19047. for @code{gdbserver} development and for bug reports to the developers.
  19048. @cindex @option{--debug-format}, @code{gdbserver} option
  19049. The @option{--debug-format=option1[,option2,...]} option tells
  19050. @code{gdbserver} to include additional information in each output.
  19051. Possible options are:
  19052. @table @code
  19053. @item none
  19054. Turn off all extra information in debugging output.
  19055. @item all
  19056. Turn on all extra information in debugging output.
  19057. @item timestamps
  19058. Include a timestamp in each line of debugging output.
  19059. @end table
  19060. Options are processed in order. Thus, for example, if @option{none}
  19061. appears last then no additional information is added to debugging output.
  19062. @cindex @option{--wrapper}, @code{gdbserver} option
  19063. The @option{--wrapper} option specifies a wrapper to launch programs
  19064. for debugging. The option should be followed by the name of the
  19065. wrapper, then any command-line arguments to pass to the wrapper, then
  19066. @kbd{--} indicating the end of the wrapper arguments.
  19067. @code{gdbserver} runs the specified wrapper program with a combined
  19068. command line including the wrapper arguments, then the name of the
  19069. program to debug, then any arguments to the program. The wrapper
  19070. runs until it executes your program, and then @value{GDBN} gains control.
  19071. You can use any program that eventually calls @code{execve} with
  19072. its arguments as a wrapper. Several standard Unix utilities do
  19073. this, e.g.@: @code{env} and @code{nohup}. Any Unix shell script ending
  19074. with @code{exec "$@@"} will also work.
  19075. For example, you can use @code{env} to pass an environment variable to
  19076. the debugged program, without setting the variable in @code{gdbserver}'s
  19077. environment:
  19078. @smallexample
  19079. $ gdbserver --wrapper env LD_PRELOAD=libtest.so -- :2222 ./testprog
  19080. @end smallexample
  19081. @cindex @option{--selftest}
  19082. The @option{--selftest} option runs the self tests in @code{gdbserver}:
  19083. @smallexample
  19084. $ gdbserver --selftest
  19085. Ran 2 unit tests, 0 failed
  19086. @end smallexample
  19087. These tests are disabled in release.
  19088. @subsection Connecting to @code{gdbserver}
  19089. The basic procedure for connecting to the remote target is:
  19090. @itemize
  19091. @item
  19092. Run @value{GDBN} on the host system.
  19093. @item
  19094. Make sure you have the necessary symbol files
  19095. (@pxref{Host and target files}).
  19096. Load symbols for your application using the @code{file} command before you
  19097. connect. Use @code{set sysroot} to locate target libraries (unless your
  19098. @value{GDBN} was compiled with the correct sysroot using
  19099. @code{--with-sysroot}).
  19100. @item
  19101. Connect to your target (@pxref{Connecting,,Connecting to a Remote Target}).
  19102. For TCP connections, you must start up @code{gdbserver} prior to using
  19103. the @code{target} command. Otherwise you may get an error whose
  19104. text depends on the host system, but which usually looks something like
  19105. @samp{Connection refused}. Don't use the @code{load}
  19106. command in @value{GDBN} when using @code{target remote} mode, since the
  19107. program is already on the target.
  19108. @end itemize
  19109. @anchor{Monitor Commands for gdbserver}
  19110. @subsection Monitor Commands for @code{gdbserver}
  19111. @cindex monitor commands, for @code{gdbserver}
  19112. During a @value{GDBN} session using @code{gdbserver}, you can use the
  19113. @code{monitor} command to send special requests to @code{gdbserver}.
  19114. Here are the available commands.
  19115. @table @code
  19116. @item monitor help
  19117. List the available monitor commands.
  19118. @item monitor set debug 0
  19119. @itemx monitor set debug 1
  19120. Disable or enable general debugging messages.
  19121. @item monitor set remote-debug 0
  19122. @itemx monitor set remote-debug 1
  19123. Disable or enable specific debugging messages associated with the remote
  19124. protocol (@pxref{Remote Protocol}).
  19125. @item monitor set debug-file filename
  19126. @itemx monitor set debug-file
  19127. Send any debug output to the given file, or to stderr.
  19128. @item monitor set debug-format option1@r{[},option2,...@r{]}
  19129. Specify additional text to add to debugging messages.
  19130. Possible options are:
  19131. @table @code
  19132. @item none
  19133. Turn off all extra information in debugging output.
  19134. @item all
  19135. Turn on all extra information in debugging output.
  19136. @item timestamps
  19137. Include a timestamp in each line of debugging output.
  19138. @end table
  19139. Options are processed in order. Thus, for example, if @option{none}
  19140. appears last then no additional information is added to debugging output.
  19141. @item monitor set libthread-db-search-path [PATH]
  19142. @cindex gdbserver, search path for @code{libthread_db}
  19143. When this command is issued, @var{path} is a colon-separated list of
  19144. directories to search for @code{libthread_db} (@pxref{Threads,,set
  19145. libthread-db-search-path}). If you omit @var{path},
  19146. @samp{libthread-db-search-path} will be reset to its default value.
  19147. The special entry @samp{$pdir} for @samp{libthread-db-search-path} is
  19148. not supported in @code{gdbserver}.
  19149. @item monitor exit
  19150. Tell gdbserver to exit immediately. This command should be followed by
  19151. @code{disconnect} to close the debugging session. @code{gdbserver} will
  19152. detach from any attached processes and kill any processes it created.
  19153. Use @code{monitor exit} to terminate @code{gdbserver} at the end
  19154. of a multi-process mode debug session.
  19155. @end table
  19156. @subsection Tracepoints support in @code{gdbserver}
  19157. @cindex tracepoints support in @code{gdbserver}
  19158. On some targets, @code{gdbserver} supports tracepoints, fast
  19159. tracepoints and static tracepoints.
  19160. For fast or static tracepoints to work, a special library called the
  19161. @dfn{in-process agent} (IPA), must be loaded in the inferior process.
  19162. This library is built and distributed as an integral part of
  19163. @code{gdbserver}. In addition, support for static tracepoints
  19164. requires building the in-process agent library with static tracepoints
  19165. support. At present, the UST (LTTng Userspace Tracer,
  19166. @url{http://lttng.org/ust}) tracing engine is supported. This support
  19167. is automatically available if UST development headers are found in the
  19168. standard include path when @code{gdbserver} is built, or if
  19169. @code{gdbserver} was explicitly configured using @option{--with-ust}
  19170. to point at such headers. You can explicitly disable the support
  19171. using @option{--with-ust=no}.
  19172. There are several ways to load the in-process agent in your program:
  19173. @table @code
  19174. @item Specifying it as dependency at link time
  19175. You can link your program dynamically with the in-process agent
  19176. library. On most systems, this is accomplished by adding
  19177. @code{-linproctrace} to the link command.
  19178. @item Using the system's preloading mechanisms
  19179. You can force loading the in-process agent at startup time by using
  19180. your system's support for preloading shared libraries. Many Unixes
  19181. support the concept of preloading user defined libraries. In most
  19182. cases, you do that by specifying @code{LD_PRELOAD=libinproctrace.so}
  19183. in the environment. See also the description of @code{gdbserver}'s
  19184. @option{--wrapper} command line option.
  19185. @item Using @value{GDBN} to force loading the agent at run time
  19186. On some systems, you can force the inferior to load a shared library,
  19187. by calling a dynamic loader function in the inferior that takes care
  19188. of dynamically looking up and loading a shared library. On most Unix
  19189. systems, the function is @code{dlopen}. You'll use the @code{call}
  19190. command for that. For example:
  19191. @smallexample
  19192. (@value{GDBP}) call dlopen ("libinproctrace.so", ...)
  19193. @end smallexample
  19194. Note that on most Unix systems, for the @code{dlopen} function to be
  19195. available, the program needs to be linked with @code{-ldl}.
  19196. @end table
  19197. On systems that have a userspace dynamic loader, like most Unix
  19198. systems, when you connect to @code{gdbserver} using @code{target
  19199. remote}, you'll find that the program is stopped at the dynamic
  19200. loader's entry point, and no shared library has been loaded in the
  19201. program's address space yet, including the in-process agent. In that
  19202. case, before being able to use any of the fast or static tracepoints
  19203. features, you need to let the loader run and load the shared
  19204. libraries. The simplest way to do that is to run the program to the
  19205. main procedure. E.g., if debugging a C or C@t{++} program, start
  19206. @code{gdbserver} like so:
  19207. @smallexample
  19208. $ gdbserver :9999 myprogram
  19209. @end smallexample
  19210. Start GDB and connect to @code{gdbserver} like so, and run to main:
  19211. @smallexample
  19212. $ gdb myprogram
  19213. (@value{GDBP}) target remote myhost:9999
  19214. 0x00007f215893ba60 in ?? () from /lib64/ld-linux-x86-64.so.2
  19215. (@value{GDBP}) b main
  19216. (@value{GDBP}) continue
  19217. @end smallexample
  19218. The in-process tracing agent library should now be loaded into the
  19219. process; you can confirm it with the @code{info sharedlibrary}
  19220. command, which will list @file{libinproctrace.so} as loaded in the
  19221. process. You are now ready to install fast tracepoints, list static
  19222. tracepoint markers, probe static tracepoints markers, and start
  19223. tracing.
  19224. @node Remote Configuration
  19225. @section Remote Configuration
  19226. @kindex set remote
  19227. @kindex show remote
  19228. This section documents the configuration options available when
  19229. debugging remote programs. For the options related to the File I/O
  19230. extensions of the remote protocol, see @ref{system,
  19231. system-call-allowed}.
  19232. @table @code
  19233. @item set remoteaddresssize @var{bits}
  19234. @cindex address size for remote targets
  19235. @cindex bits in remote address
  19236. Set the maximum size of address in a memory packet to the specified
  19237. number of bits. @value{GDBN} will mask off the address bits above
  19238. that number, when it passes addresses to the remote target. The
  19239. default value is the number of bits in the target's address.
  19240. @item show remoteaddresssize
  19241. Show the current value of remote address size in bits.
  19242. @item set serial baud @var{n}
  19243. @cindex baud rate for remote targets
  19244. Set the baud rate for the remote serial I/O to @var{n} baud. The
  19245. value is used to set the speed of the serial port used for debugging
  19246. remote targets.
  19247. @item show serial baud
  19248. Show the current speed of the remote connection.
  19249. @item set serial parity @var{parity}
  19250. Set the parity for the remote serial I/O. Supported values of @var{parity} are:
  19251. @code{even}, @code{none}, and @code{odd}. The default is @code{none}.
  19252. @item show serial parity
  19253. Show the current parity of the serial port.
  19254. @item set remotebreak
  19255. @cindex interrupt remote programs
  19256. @cindex BREAK signal instead of Ctrl-C
  19257. @anchor{set remotebreak}
  19258. If set to on, @value{GDBN} sends a @code{BREAK} signal to the remote
  19259. when you type @kbd{Ctrl-c} to interrupt the program running
  19260. on the remote. If set to off, @value{GDBN} sends the @samp{Ctrl-C}
  19261. character instead. The default is off, since most remote systems
  19262. expect to see @samp{Ctrl-C} as the interrupt signal.
  19263. @item show remotebreak
  19264. Show whether @value{GDBN} sends @code{BREAK} or @samp{Ctrl-C} to
  19265. interrupt the remote program.
  19266. @item set remoteflow on
  19267. @itemx set remoteflow off
  19268. @kindex set remoteflow
  19269. Enable or disable hardware flow control (@code{RTS}/@code{CTS})
  19270. on the serial port used to communicate to the remote target.
  19271. @item show remoteflow
  19272. @kindex show remoteflow
  19273. Show the current setting of hardware flow control.
  19274. @item set remotelogbase @var{base}
  19275. Set the base (a.k.a.@: radix) of logging serial protocol
  19276. communications to @var{base}. Supported values of @var{base} are:
  19277. @code{ascii}, @code{octal}, and @code{hex}. The default is
  19278. @code{ascii}.
  19279. @item show remotelogbase
  19280. Show the current setting of the radix for logging remote serial
  19281. protocol.
  19282. @item set remotelogfile @var{file}
  19283. @cindex record serial communications on file
  19284. Record remote serial communications on the named @var{file}. The
  19285. default is not to record at all.
  19286. @item show remotelogfile
  19287. Show the current setting of the file name on which to record the
  19288. serial communications.
  19289. @item set remotetimeout @var{num}
  19290. @cindex timeout for serial communications
  19291. @cindex remote timeout
  19292. Set the timeout limit to wait for the remote target to respond to
  19293. @var{num} seconds. The default is 2 seconds.
  19294. @item show remotetimeout
  19295. Show the current number of seconds to wait for the remote target
  19296. responses.
  19297. @cindex limit hardware breakpoints and watchpoints
  19298. @cindex remote target, limit break- and watchpoints
  19299. @anchor{set remote hardware-watchpoint-limit}
  19300. @anchor{set remote hardware-breakpoint-limit}
  19301. @item set remote hardware-watchpoint-limit @var{limit}
  19302. @itemx set remote hardware-breakpoint-limit @var{limit}
  19303. Restrict @value{GDBN} to using @var{limit} remote hardware watchpoints
  19304. or breakpoints. The @var{limit} can be set to 0 to disable hardware
  19305. watchpoints or breakpoints, and @code{unlimited} for unlimited
  19306. watchpoints or breakpoints.
  19307. @item show remote hardware-watchpoint-limit
  19308. @itemx show remote hardware-breakpoint-limit
  19309. Show the current limit for the number of hardware watchpoints or
  19310. breakpoints that @value{GDBN} can use.
  19311. @cindex limit hardware watchpoints length
  19312. @cindex remote target, limit watchpoints length
  19313. @anchor{set remote hardware-watchpoint-length-limit}
  19314. @item set remote hardware-watchpoint-length-limit @var{limit}
  19315. Restrict @value{GDBN} to using @var{limit} bytes for the maximum
  19316. length of a remote hardware watchpoint. A @var{limit} of 0 disables
  19317. hardware watchpoints and @code{unlimited} allows watchpoints of any
  19318. length.
  19319. @item show remote hardware-watchpoint-length-limit
  19320. Show the current limit (in bytes) of the maximum length of
  19321. a remote hardware watchpoint.
  19322. @item set remote exec-file @var{filename}
  19323. @itemx show remote exec-file
  19324. @anchor{set remote exec-file}
  19325. @cindex executable file, for remote target
  19326. Select the file used for @code{run} with @code{target
  19327. extended-remote}. This should be set to a filename valid on the
  19328. target system. If it is not set, the target will use a default
  19329. filename (e.g.@: the last program run).
  19330. @item set remote interrupt-sequence
  19331. @cindex interrupt remote programs
  19332. @cindex select Ctrl-C, BREAK or BREAK-g
  19333. Allow the user to select one of @samp{Ctrl-C}, a @code{BREAK} or
  19334. @samp{BREAK-g} as the
  19335. sequence to the remote target in order to interrupt the execution.
  19336. @samp{Ctrl-C} is a default. Some system prefers @code{BREAK} which
  19337. is high level of serial line for some certain time.
  19338. Linux kernel prefers @samp{BREAK-g}, a.k.a Magic SysRq g.
  19339. It is @code{BREAK} signal followed by character @code{g}.
  19340. @item show remote interrupt-sequence
  19341. Show which of @samp{Ctrl-C}, @code{BREAK} or @code{BREAK-g}
  19342. is sent by @value{GDBN} to interrupt the remote program.
  19343. @code{BREAK-g} is BREAK signal followed by @code{g} and
  19344. also known as Magic SysRq g.
  19345. @item set remote interrupt-on-connect
  19346. @cindex send interrupt-sequence on start
  19347. Specify whether interrupt-sequence is sent to remote target when
  19348. @value{GDBN} connects to it. This is mostly needed when you debug
  19349. Linux kernel. Linux kernel expects @code{BREAK} followed by @code{g}
  19350. which is known as Magic SysRq g in order to connect @value{GDBN}.
  19351. @item show remote interrupt-on-connect
  19352. Show whether interrupt-sequence is sent
  19353. to remote target when @value{GDBN} connects to it.
  19354. @kindex set tcp
  19355. @kindex show tcp
  19356. @item set tcp auto-retry on
  19357. @cindex auto-retry, for remote TCP target
  19358. Enable auto-retry for remote TCP connections. This is useful if the remote
  19359. debugging agent is launched in parallel with @value{GDBN}; there is a race
  19360. condition because the agent may not become ready to accept the connection
  19361. before @value{GDBN} attempts to connect. When auto-retry is
  19362. enabled, if the initial attempt to connect fails, @value{GDBN} reattempts
  19363. to establish the connection using the timeout specified by
  19364. @code{set tcp connect-timeout}.
  19365. @item set tcp auto-retry off
  19366. Do not auto-retry failed TCP connections.
  19367. @item show tcp auto-retry
  19368. Show the current auto-retry setting.
  19369. @item set tcp connect-timeout @var{seconds}
  19370. @itemx set tcp connect-timeout unlimited
  19371. @cindex connection timeout, for remote TCP target
  19372. @cindex timeout, for remote target connection
  19373. Set the timeout for establishing a TCP connection to the remote target to
  19374. @var{seconds}. The timeout affects both polling to retry failed connections
  19375. (enabled by @code{set tcp auto-retry on}) and waiting for connections
  19376. that are merely slow to complete, and represents an approximate cumulative
  19377. value. If @var{seconds} is @code{unlimited}, there is no timeout and
  19378. @value{GDBN} will keep attempting to establish a connection forever,
  19379. unless interrupted with @kbd{Ctrl-c}. The default is 15 seconds.
  19380. @item show tcp connect-timeout
  19381. Show the current connection timeout setting.
  19382. @end table
  19383. @cindex remote packets, enabling and disabling
  19384. The @value{GDBN} remote protocol autodetects the packets supported by
  19385. your debugging stub. If you need to override the autodetection, you
  19386. can use these commands to enable or disable individual packets. Each
  19387. packet can be set to @samp{on} (the remote target supports this
  19388. packet), @samp{off} (the remote target does not support this packet),
  19389. or @samp{auto} (detect remote target support for this packet). They
  19390. all default to @samp{auto}. For more information about each packet,
  19391. see @ref{Remote Protocol}.
  19392. During normal use, you should not have to use any of these commands.
  19393. If you do, that may be a bug in your remote debugging stub, or a bug
  19394. in @value{GDBN}. You may want to report the problem to the
  19395. @value{GDBN} developers.
  19396. For each packet @var{name}, the command to enable or disable the
  19397. packet is @code{set remote @var{name}-packet}. The available settings
  19398. are:
  19399. @multitable @columnfractions 0.28 0.32 0.25
  19400. @item Command Name
  19401. @tab Remote Packet
  19402. @tab Related Features
  19403. @item @code{fetch-register}
  19404. @tab @code{p}
  19405. @tab @code{info registers}
  19406. @item @code{set-register}
  19407. @tab @code{P}
  19408. @tab @code{set}
  19409. @item @code{binary-download}
  19410. @tab @code{X}
  19411. @tab @code{load}, @code{set}
  19412. @item @code{read-aux-vector}
  19413. @tab @code{qXfer:auxv:read}
  19414. @tab @code{info auxv}
  19415. @item @code{symbol-lookup}
  19416. @tab @code{qSymbol}
  19417. @tab Detecting multiple threads
  19418. @item @code{attach}
  19419. @tab @code{vAttach}
  19420. @tab @code{attach}
  19421. @item @code{verbose-resume}
  19422. @tab @code{vCont}
  19423. @tab Stepping or resuming multiple threads
  19424. @item @code{run}
  19425. @tab @code{vRun}
  19426. @tab @code{run}
  19427. @item @code{software-breakpoint}
  19428. @tab @code{Z0}
  19429. @tab @code{break}
  19430. @item @code{hardware-breakpoint}
  19431. @tab @code{Z1}
  19432. @tab @code{hbreak}
  19433. @item @code{write-watchpoint}
  19434. @tab @code{Z2}
  19435. @tab @code{watch}
  19436. @item @code{read-watchpoint}
  19437. @tab @code{Z3}
  19438. @tab @code{rwatch}
  19439. @item @code{access-watchpoint}
  19440. @tab @code{Z4}
  19441. @tab @code{awatch}
  19442. @item @code{pid-to-exec-file}
  19443. @tab @code{qXfer:exec-file:read}
  19444. @tab @code{attach}, @code{run}
  19445. @item @code{target-features}
  19446. @tab @code{qXfer:features:read}
  19447. @tab @code{set architecture}
  19448. @item @code{library-info}
  19449. @tab @code{qXfer:libraries:read}
  19450. @tab @code{info sharedlibrary}
  19451. @item @code{memory-map}
  19452. @tab @code{qXfer:memory-map:read}
  19453. @tab @code{info mem}
  19454. @item @code{read-sdata-object}
  19455. @tab @code{qXfer:sdata:read}
  19456. @tab @code{print $_sdata}
  19457. @item @code{read-siginfo-object}
  19458. @tab @code{qXfer:siginfo:read}
  19459. @tab @code{print $_siginfo}
  19460. @item @code{write-siginfo-object}
  19461. @tab @code{qXfer:siginfo:write}
  19462. @tab @code{set $_siginfo}
  19463. @item @code{threads}
  19464. @tab @code{qXfer:threads:read}
  19465. @tab @code{info threads}
  19466. @item @code{get-thread-local-@*storage-address}
  19467. @tab @code{qGetTLSAddr}
  19468. @tab Displaying @code{__thread} variables
  19469. @item @code{get-thread-information-block-address}
  19470. @tab @code{qGetTIBAddr}
  19471. @tab Display MS-Windows Thread Information Block.
  19472. @item @code{search-memory}
  19473. @tab @code{qSearch:memory}
  19474. @tab @code{find}
  19475. @item @code{supported-packets}
  19476. @tab @code{qSupported}
  19477. @tab Remote communications parameters
  19478. @item @code{catch-syscalls}
  19479. @tab @code{QCatchSyscalls}
  19480. @tab @code{catch syscall}
  19481. @item @code{pass-signals}
  19482. @tab @code{QPassSignals}
  19483. @tab @code{handle @var{signal}}
  19484. @item @code{program-signals}
  19485. @tab @code{QProgramSignals}
  19486. @tab @code{handle @var{signal}}
  19487. @item @code{hostio-close-packet}
  19488. @tab @code{vFile:close}
  19489. @tab @code{remote get}, @code{remote put}
  19490. @item @code{hostio-open-packet}
  19491. @tab @code{vFile:open}
  19492. @tab @code{remote get}, @code{remote put}
  19493. @item @code{hostio-pread-packet}
  19494. @tab @code{vFile:pread}
  19495. @tab @code{remote get}, @code{remote put}
  19496. @item @code{hostio-pwrite-packet}
  19497. @tab @code{vFile:pwrite}
  19498. @tab @code{remote get}, @code{remote put}
  19499. @item @code{hostio-unlink-packet}
  19500. @tab @code{vFile:unlink}
  19501. @tab @code{remote delete}
  19502. @item @code{hostio-readlink-packet}
  19503. @tab @code{vFile:readlink}
  19504. @tab Host I/O
  19505. @item @code{hostio-fstat-packet}
  19506. @tab @code{vFile:fstat}
  19507. @tab Host I/O
  19508. @item @code{hostio-setfs-packet}
  19509. @tab @code{vFile:setfs}
  19510. @tab Host I/O
  19511. @item @code{noack-packet}
  19512. @tab @code{QStartNoAckMode}
  19513. @tab Packet acknowledgment
  19514. @item @code{osdata}
  19515. @tab @code{qXfer:osdata:read}
  19516. @tab @code{info os}
  19517. @item @code{query-attached}
  19518. @tab @code{qAttached}
  19519. @tab Querying remote process attach state.
  19520. @item @code{trace-buffer-size}
  19521. @tab @code{QTBuffer:size}
  19522. @tab @code{set trace-buffer-size}
  19523. @item @code{trace-status}
  19524. @tab @code{qTStatus}
  19525. @tab @code{tstatus}
  19526. @item @code{traceframe-info}
  19527. @tab @code{qXfer:traceframe-info:read}
  19528. @tab Traceframe info
  19529. @item @code{install-in-trace}
  19530. @tab @code{InstallInTrace}
  19531. @tab Install tracepoint in tracing
  19532. @item @code{disable-randomization}
  19533. @tab @code{QDisableRandomization}
  19534. @tab @code{set disable-randomization}
  19535. @item @code{startup-with-shell}
  19536. @tab @code{QStartupWithShell}
  19537. @tab @code{set startup-with-shell}
  19538. @item @code{environment-hex-encoded}
  19539. @tab @code{QEnvironmentHexEncoded}
  19540. @tab @code{set environment}
  19541. @item @code{environment-unset}
  19542. @tab @code{QEnvironmentUnset}
  19543. @tab @code{unset environment}
  19544. @item @code{environment-reset}
  19545. @tab @code{QEnvironmentReset}
  19546. @tab @code{Reset the inferior environment (i.e., unset user-set variables)}
  19547. @item @code{set-working-dir}
  19548. @tab @code{QSetWorkingDir}
  19549. @tab @code{set cwd}
  19550. @item @code{conditional-breakpoints-packet}
  19551. @tab @code{Z0 and Z1}
  19552. @tab @code{Support for target-side breakpoint condition evaluation}
  19553. @item @code{multiprocess-extensions}
  19554. @tab @code{multiprocess extensions}
  19555. @tab Debug multiple processes and remote process PID awareness
  19556. @item @code{swbreak-feature}
  19557. @tab @code{swbreak stop reason}
  19558. @tab @code{break}
  19559. @item @code{hwbreak-feature}
  19560. @tab @code{hwbreak stop reason}
  19561. @tab @code{hbreak}
  19562. @item @code{fork-event-feature}
  19563. @tab @code{fork stop reason}
  19564. @tab @code{fork}
  19565. @item @code{vfork-event-feature}
  19566. @tab @code{vfork stop reason}
  19567. @tab @code{vfork}
  19568. @item @code{exec-event-feature}
  19569. @tab @code{exec stop reason}
  19570. @tab @code{exec}
  19571. @item @code{thread-events}
  19572. @tab @code{QThreadEvents}
  19573. @tab Tracking thread lifetime.
  19574. @item @code{no-resumed-stop-reply}
  19575. @tab @code{no resumed thread left stop reply}
  19576. @tab Tracking thread lifetime.
  19577. @end multitable
  19578. @node Remote Stub
  19579. @section Implementing a Remote Stub
  19580. @cindex debugging stub, example
  19581. @cindex remote stub, example
  19582. @cindex stub example, remote debugging
  19583. The stub files provided with @value{GDBN} implement the target side of the
  19584. communication protocol, and the @value{GDBN} side is implemented in the
  19585. @value{GDBN} source file @file{remote.c}. Normally, you can simply allow
  19586. these subroutines to communicate, and ignore the details. (If you're
  19587. implementing your own stub file, you can still ignore the details: start
  19588. with one of the existing stub files. @file{sparc-stub.c} is the best
  19589. organized, and therefore the easiest to read.)
  19590. @cindex remote serial debugging, overview
  19591. To debug a program running on another machine (the debugging
  19592. @dfn{target} machine), you must first arrange for all the usual
  19593. prerequisites for the program to run by itself. For example, for a C
  19594. program, you need:
  19595. @enumerate
  19596. @item
  19597. A startup routine to set up the C runtime environment; these usually
  19598. have a name like @file{crt0}. The startup routine may be supplied by
  19599. your hardware supplier, or you may have to write your own.
  19600. @item
  19601. A C subroutine library to support your program's
  19602. subroutine calls, notably managing input and output.
  19603. @item
  19604. A way of getting your program to the other machine---for example, a
  19605. download program. These are often supplied by the hardware
  19606. manufacturer, but you may have to write your own from hardware
  19607. documentation.
  19608. @end enumerate
  19609. The next step is to arrange for your program to use a serial port to
  19610. communicate with the machine where @value{GDBN} is running (the @dfn{host}
  19611. machine). In general terms, the scheme looks like this:
  19612. @table @emph
  19613. @item On the host,
  19614. @value{GDBN} already understands how to use this protocol; when everything
  19615. else is set up, you can simply use the @samp{target remote} command
  19616. (@pxref{Targets,,Specifying a Debugging Target}).
  19617. @item On the target,
  19618. you must link with your program a few special-purpose subroutines that
  19619. implement the @value{GDBN} remote serial protocol. The file containing these
  19620. subroutines is called a @dfn{debugging stub}.
  19621. On certain remote targets, you can use an auxiliary program
  19622. @code{gdbserver} instead of linking a stub into your program.
  19623. @xref{Server,,Using the @code{gdbserver} Program}, for details.
  19624. @end table
  19625. The debugging stub is specific to the architecture of the remote
  19626. machine; for example, use @file{sparc-stub.c} to debug programs on
  19627. @sc{sparc} boards.
  19628. @cindex remote serial stub list
  19629. These working remote stubs are distributed with @value{GDBN}:
  19630. @table @code
  19631. @item i386-stub.c
  19632. @cindex @file{i386-stub.c}
  19633. @cindex Intel
  19634. @cindex i386
  19635. For Intel 386 and compatible architectures.
  19636. @item m68k-stub.c
  19637. @cindex @file{m68k-stub.c}
  19638. @cindex Motorola 680x0
  19639. @cindex m680x0
  19640. For Motorola 680x0 architectures.
  19641. @item sh-stub.c
  19642. @cindex @file{sh-stub.c}
  19643. @cindex Renesas
  19644. @cindex SH
  19645. For Renesas SH architectures.
  19646. @item sparc-stub.c
  19647. @cindex @file{sparc-stub.c}
  19648. @cindex Sparc
  19649. For @sc{sparc} architectures.
  19650. @item sparcl-stub.c
  19651. @cindex @file{sparcl-stub.c}
  19652. @cindex Fujitsu
  19653. @cindex SparcLite
  19654. For Fujitsu @sc{sparclite} architectures.
  19655. @end table
  19656. The @file{README} file in the @value{GDBN} distribution may list other
  19657. recently added stubs.
  19658. @menu
  19659. * Stub Contents:: What the stub can do for you
  19660. * Bootstrapping:: What you must do for the stub
  19661. * Debug Session:: Putting it all together
  19662. @end menu
  19663. @node Stub Contents
  19664. @subsection What the Stub Can Do for You
  19665. @cindex remote serial stub
  19666. The debugging stub for your architecture supplies these three
  19667. subroutines:
  19668. @table @code
  19669. @item set_debug_traps
  19670. @findex set_debug_traps
  19671. @cindex remote serial stub, initialization
  19672. This routine arranges for @code{handle_exception} to run when your
  19673. program stops. You must call this subroutine explicitly in your
  19674. program's startup code.
  19675. @item handle_exception
  19676. @findex handle_exception
  19677. @cindex remote serial stub, main routine
  19678. This is the central workhorse, but your program never calls it
  19679. explicitly---the setup code arranges for @code{handle_exception} to
  19680. run when a trap is triggered.
  19681. @code{handle_exception} takes control when your program stops during
  19682. execution (for example, on a breakpoint), and mediates communications
  19683. with @value{GDBN} on the host machine. This is where the communications
  19684. protocol is implemented; @code{handle_exception} acts as the @value{GDBN}
  19685. representative on the target machine. It begins by sending summary
  19686. information on the state of your program, then continues to execute,
  19687. retrieving and transmitting any information @value{GDBN} needs, until you
  19688. execute a @value{GDBN} command that makes your program resume; at that point,
  19689. @code{handle_exception} returns control to your own code on the target
  19690. machine.
  19691. @item breakpoint
  19692. @cindex @code{breakpoint} subroutine, remote
  19693. Use this auxiliary subroutine to make your program contain a
  19694. breakpoint. Depending on the particular situation, this may be the only
  19695. way for @value{GDBN} to get control. For instance, if your target
  19696. machine has some sort of interrupt button, you won't need to call this;
  19697. pressing the interrupt button transfers control to
  19698. @code{handle_exception}---in effect, to @value{GDBN}. On some machines,
  19699. simply receiving characters on the serial port may also trigger a trap;
  19700. again, in that situation, you don't need to call @code{breakpoint} from
  19701. your own program---simply running @samp{target remote} from the host
  19702. @value{GDBN} session gets control.
  19703. Call @code{breakpoint} if none of these is true, or if you simply want
  19704. to make certain your program stops at a predetermined point for the
  19705. start of your debugging session.
  19706. @end table
  19707. @node Bootstrapping
  19708. @subsection What You Must Do for the Stub
  19709. @cindex remote stub, support routines
  19710. The debugging stubs that come with @value{GDBN} are set up for a particular
  19711. chip architecture, but they have no information about the rest of your
  19712. debugging target machine.
  19713. First of all you need to tell the stub how to communicate with the
  19714. serial port.
  19715. @table @code
  19716. @item int getDebugChar()
  19717. @findex getDebugChar
  19718. Write this subroutine to read a single character from the serial port.
  19719. It may be identical to @code{getchar} for your target system; a
  19720. different name is used to allow you to distinguish the two if you wish.
  19721. @item void putDebugChar(int)
  19722. @findex putDebugChar
  19723. Write this subroutine to write a single character to the serial port.
  19724. It may be identical to @code{putchar} for your target system; a
  19725. different name is used to allow you to distinguish the two if you wish.
  19726. @end table
  19727. @cindex control C, and remote debugging
  19728. @cindex interrupting remote targets
  19729. If you want @value{GDBN} to be able to stop your program while it is
  19730. running, you need to use an interrupt-driven serial driver, and arrange
  19731. for it to stop when it receives a @code{^C} (@samp{\003}, the control-C
  19732. character). That is the character which @value{GDBN} uses to tell the
  19733. remote system to stop.
  19734. Getting the debugging target to return the proper status to @value{GDBN}
  19735. probably requires changes to the standard stub; one quick and dirty way
  19736. is to just execute a breakpoint instruction (the ``dirty'' part is that
  19737. @value{GDBN} reports a @code{SIGTRAP} instead of a @code{SIGINT}).
  19738. Other routines you need to supply are:
  19739. @table @code
  19740. @item void exceptionHandler (int @var{exception_number}, void *@var{exception_address})
  19741. @findex exceptionHandler
  19742. Write this function to install @var{exception_address} in the exception
  19743. handling tables. You need to do this because the stub does not have any
  19744. way of knowing what the exception handling tables on your target system
  19745. are like (for example, the processor's table might be in @sc{rom},
  19746. containing entries which point to a table in @sc{ram}).
  19747. The @var{exception_number} specifies the exception which should be changed;
  19748. its meaning is architecture-dependent (for example, different numbers
  19749. might represent divide by zero, misaligned access, etc). When this
  19750. exception occurs, control should be transferred directly to
  19751. @var{exception_address}, and the processor state (stack, registers,
  19752. and so on) should be just as it is when a processor exception occurs. So if
  19753. you want to use a jump instruction to reach @var{exception_address}, it
  19754. should be a simple jump, not a jump to subroutine.
  19755. For the 386, @var{exception_address} should be installed as an interrupt
  19756. gate so that interrupts are masked while the handler runs. The gate
  19757. should be at privilege level 0 (the most privileged level). The
  19758. @sc{sparc} and 68k stubs are able to mask interrupts themselves without
  19759. help from @code{exceptionHandler}.
  19760. @item void flush_i_cache()
  19761. @findex flush_i_cache
  19762. On @sc{sparc} and @sc{sparclite} only, write this subroutine to flush the
  19763. instruction cache, if any, on your target machine. If there is no
  19764. instruction cache, this subroutine may be a no-op.
  19765. On target machines that have instruction caches, @value{GDBN} requires this
  19766. function to make certain that the state of your program is stable.
  19767. @end table
  19768. @noindent
  19769. You must also make sure this library routine is available:
  19770. @table @code
  19771. @item void *memset(void *, int, int)
  19772. @findex memset
  19773. This is the standard library function @code{memset} that sets an area of
  19774. memory to a known value. If you have one of the free versions of
  19775. @code{libc.a}, @code{memset} can be found there; otherwise, you must
  19776. either obtain it from your hardware manufacturer, or write your own.
  19777. @end table
  19778. If you do not use the GNU C compiler, you may need other standard
  19779. library subroutines as well; this varies from one stub to another,
  19780. but in general the stubs are likely to use any of the common library
  19781. subroutines which @code{@value{NGCC}} generates as inline code.
  19782. @node Debug Session
  19783. @subsection Putting it All Together
  19784. @cindex remote serial debugging summary
  19785. In summary, when your program is ready to debug, you must follow these
  19786. steps.
  19787. @enumerate
  19788. @item
  19789. Make sure you have defined the supporting low-level routines
  19790. (@pxref{Bootstrapping,,What You Must Do for the Stub}):
  19791. @display
  19792. @code{getDebugChar}, @code{putDebugChar},
  19793. @code{flush_i_cache}, @code{memset}, @code{exceptionHandler}.
  19794. @end display
  19795. @item
  19796. Insert these lines in your program's startup code, before the main
  19797. procedure is called:
  19798. @smallexample
  19799. set_debug_traps();
  19800. breakpoint();
  19801. @end smallexample
  19802. On some machines, when a breakpoint trap is raised, the hardware
  19803. automatically makes the PC point to the instruction after the
  19804. breakpoint. If your machine doesn't do that, you may need to adjust
  19805. @code{handle_exception} to arrange for it to return to the instruction
  19806. after the breakpoint on this first invocation, so that your program
  19807. doesn't keep hitting the initial breakpoint instead of making
  19808. progress.
  19809. @item
  19810. For the 680x0 stub only, you need to provide a variable called
  19811. @code{exceptionHook}. Normally you just use:
  19812. @smallexample
  19813. void (*exceptionHook)() = 0;
  19814. @end smallexample
  19815. @noindent
  19816. but if before calling @code{set_debug_traps}, you set it to point to a
  19817. function in your program, that function is called when
  19818. @code{@value{GDBN}} continues after stopping on a trap (for example, bus
  19819. error). The function indicated by @code{exceptionHook} is called with
  19820. one parameter: an @code{int} which is the exception number.
  19821. @item
  19822. Compile and link together: your program, the @value{GDBN} debugging stub for
  19823. your target architecture, and the supporting subroutines.
  19824. @item
  19825. Make sure you have a serial connection between your target machine and
  19826. the @value{GDBN} host, and identify the serial port on the host.
  19827. @item
  19828. @c The "remote" target now provides a `load' command, so we should
  19829. @c document that. FIXME.
  19830. Download your program to your target machine (or get it there by
  19831. whatever means the manufacturer provides), and start it.
  19832. @item
  19833. Start @value{GDBN} on the host, and connect to the target
  19834. (@pxref{Connecting,,Connecting to a Remote Target}).
  19835. @end enumerate
  19836. @node Configurations
  19837. @chapter Configuration-Specific Information
  19838. While nearly all @value{GDBN} commands are available for all native and
  19839. cross versions of the debugger, there are some exceptions. This chapter
  19840. describes things that are only available in certain configurations.
  19841. There are three major categories of configurations: native
  19842. configurations, where the host and target are the same, embedded
  19843. operating system configurations, which are usually the same for several
  19844. different processor architectures, and bare embedded processors, which
  19845. are quite different from each other.
  19846. @menu
  19847. * Native::
  19848. * Embedded OS::
  19849. * Embedded Processors::
  19850. * Architectures::
  19851. @end menu
  19852. @node Native
  19853. @section Native
  19854. This section describes details specific to particular native
  19855. configurations.
  19856. @menu
  19857. * BSD libkvm Interface:: Debugging BSD kernel memory images
  19858. * Process Information:: Process information
  19859. * DJGPP Native:: Features specific to the DJGPP port
  19860. * Cygwin Native:: Features specific to the Cygwin port
  19861. * Hurd Native:: Features specific to @sc{gnu} Hurd
  19862. * Darwin:: Features specific to Darwin
  19863. * FreeBSD:: Features specific to FreeBSD
  19864. @end menu
  19865. @node BSD libkvm Interface
  19866. @subsection BSD libkvm Interface
  19867. @cindex libkvm
  19868. @cindex kernel memory image
  19869. @cindex kernel crash dump
  19870. BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory
  19871. interface that provides a uniform interface for accessing kernel virtual
  19872. memory images, including live systems and crash dumps. @value{GDBN}
  19873. uses this interface to allow you to debug live kernels and kernel crash
  19874. dumps on many native BSD configurations. This is implemented as a
  19875. special @code{kvm} debugging target. For debugging a live system, load
  19876. the currently running kernel into @value{GDBN} and connect to the
  19877. @code{kvm} target:
  19878. @smallexample
  19879. (@value{GDBP}) @b{target kvm}
  19880. @end smallexample
  19881. For debugging crash dumps, provide the file name of the crash dump as an
  19882. argument:
  19883. @smallexample
  19884. (@value{GDBP}) @b{target kvm /var/crash/bsd.0}
  19885. @end smallexample
  19886. Once connected to the @code{kvm} target, the following commands are
  19887. available:
  19888. @table @code
  19889. @kindex kvm
  19890. @item kvm pcb
  19891. Set current context from the @dfn{Process Control Block} (PCB) address.
  19892. @item kvm proc
  19893. Set current context from proc address. This command isn't available on
  19894. modern FreeBSD systems.
  19895. @end table
  19896. @node Process Information
  19897. @subsection Process Information
  19898. @cindex /proc
  19899. @cindex examine process image
  19900. @cindex process info via @file{/proc}
  19901. Some operating systems provide interfaces to fetch additional
  19902. information about running processes beyond memory and per-thread
  19903. register state. If @value{GDBN} is configured for an operating system
  19904. with a supported interface, the command @code{info proc} is available
  19905. to report information about the process running your program, or about
  19906. any process running on your system.
  19907. One supported interface is a facility called @samp{/proc} that can be
  19908. used to examine the image of a running process using file-system
  19909. subroutines. This facility is supported on @sc{gnu}/Linux and Solaris
  19910. systems.
  19911. On FreeBSD and NetBSD systems, system control nodes are used to query
  19912. process information.
  19913. In addition, some systems may provide additional process information
  19914. in core files. Note that a core file may include a subset of the
  19915. information available from a live process. Process information is
  19916. currently available from cores created on @sc{gnu}/Linux and FreeBSD
  19917. systems.
  19918. @table @code
  19919. @kindex info proc
  19920. @cindex process ID
  19921. @item info proc
  19922. @itemx info proc @var{process-id}
  19923. Summarize available information about a process. If a
  19924. process ID is specified by @var{process-id}, display information about
  19925. that process; otherwise display information about the program being
  19926. debugged. The summary includes the debugged process ID, the command
  19927. line used to invoke it, its current working directory, and its
  19928. executable file's absolute file name.
  19929. On some systems, @var{process-id} can be of the form
  19930. @samp{[@var{pid}]/@var{tid}} which specifies a certain thread ID
  19931. within a process. If the optional @var{pid} part is missing, it means
  19932. a thread from the process being debugged (the leading @samp{/} still
  19933. needs to be present, or else @value{GDBN} will interpret the number as
  19934. a process ID rather than a thread ID).
  19935. @item info proc cmdline
  19936. @cindex info proc cmdline
  19937. Show the original command line of the process. This command is
  19938. supported on @sc{gnu}/Linux, FreeBSD and NetBSD.
  19939. @item info proc cwd
  19940. @cindex info proc cwd
  19941. Show the current working directory of the process. This command is
  19942. supported on @sc{gnu}/Linux, FreeBSD and NetBSD.
  19943. @item info proc exe
  19944. @cindex info proc exe
  19945. Show the name of executable of the process. This command is supported
  19946. on @sc{gnu}/Linux, FreeBSD and NetBSD.
  19947. @item info proc files
  19948. @cindex info proc files
  19949. Show the file descriptors open by the process. For each open file
  19950. descriptor, @value{GDBN} shows its number, type (file, directory,
  19951. character device, socket), file pointer offset, and the name of the
  19952. resource open on the descriptor. The resource name can be a file name
  19953. (for files, directories, and devices) or a protocol followed by socket
  19954. address (for network connections). This command is supported on
  19955. FreeBSD.
  19956. This example shows the open file descriptors for a process using a
  19957. tty for standard input and output as well as two network sockets:
  19958. @smallexample
  19959. (gdb) info proc files 22136
  19960. process 22136
  19961. Open files:
  19962. FD Type Offset Flags Name
  19963. text file - r-------- /usr/bin/ssh
  19964. ctty chr - rw------- /dev/pts/20
  19965. cwd dir - r-------- /usr/home/john
  19966. root dir - r-------- /
  19967. 0 chr 0x32933a4 rw------- /dev/pts/20
  19968. 1 chr 0x32933a4 rw------- /dev/pts/20
  19969. 2 chr 0x32933a4 rw------- /dev/pts/20
  19970. 3 socket 0x0 rw----n-- tcp4 10.0.1.2:53014 -> 10.0.1.10:22
  19971. 4 socket 0x0 rw------- unix stream:/tmp/ssh-FIt89oAzOn5f/agent.2456
  19972. @end smallexample
  19973. @item info proc mappings
  19974. @cindex memory address space mappings
  19975. Report the memory address space ranges accessible in a process. On
  19976. Solaris, FreeBSD and NetBSD systems, each memory range includes information
  19977. on whether the process has read, write, or execute access rights to each
  19978. range. On @sc{gnu}/Linux, FreeBSD and NetBSD systems, each memory range
  19979. includes the object file which is mapped to that range.
  19980. @item info proc stat
  19981. @itemx info proc status
  19982. @cindex process detailed status information
  19983. Show additional process-related information, including the user ID and
  19984. group ID; virtual memory usage; the signals that are pending, blocked,
  19985. and ignored; its TTY; its consumption of system and user time; its
  19986. stack size; its @samp{nice} value; etc. These commands are supported
  19987. on @sc{gnu}/Linux, FreeBSD and NetBSD.
  19988. For @sc{gnu}/Linux systems, see the @samp{proc} man page for more
  19989. information (type @kbd{man 5 proc} from your shell prompt).
  19990. For FreeBSD and NetBSD systems, @code{info proc stat} is an alias for
  19991. @code{info proc status}.
  19992. @item info proc all
  19993. Show all the information about the process described under all of the
  19994. above @code{info proc} subcommands.
  19995. @ignore
  19996. @comment These sub-options of 'info proc' were not included when
  19997. @comment procfs.c was re-written. Keep their descriptions around
  19998. @comment against the day when someone finds the time to put them back in.
  19999. @kindex info proc times
  20000. @item info proc times
  20001. Starting time, user CPU time, and system CPU time for your program and
  20002. its children.
  20003. @kindex info proc id
  20004. @item info proc id
  20005. Report on the process IDs related to your program: its own process ID,
  20006. the ID of its parent, the process group ID, and the session ID.
  20007. @end ignore
  20008. @item set procfs-trace
  20009. @kindex set procfs-trace
  20010. @cindex @code{procfs} API calls
  20011. This command enables and disables tracing of @code{procfs} API calls.
  20012. @item show procfs-trace
  20013. @kindex show procfs-trace
  20014. Show the current state of @code{procfs} API call tracing.
  20015. @item set procfs-file @var{file}
  20016. @kindex set procfs-file
  20017. Tell @value{GDBN} to write @code{procfs} API trace to the named
  20018. @var{file}. @value{GDBN} appends the trace info to the previous
  20019. contents of the file. The default is to display the trace on the
  20020. standard output.
  20021. @item show procfs-file
  20022. @kindex show procfs-file
  20023. Show the file to which @code{procfs} API trace is written.
  20024. @item proc-trace-entry
  20025. @itemx proc-trace-exit
  20026. @itemx proc-untrace-entry
  20027. @itemx proc-untrace-exit
  20028. @kindex proc-trace-entry
  20029. @kindex proc-trace-exit
  20030. @kindex proc-untrace-entry
  20031. @kindex proc-untrace-exit
  20032. These commands enable and disable tracing of entries into and exits
  20033. from the @code{syscall} interface.
  20034. @item info pidlist
  20035. @kindex info pidlist
  20036. @cindex process list, QNX Neutrino
  20037. For QNX Neutrino only, this command displays the list of all the
  20038. processes and all the threads within each process.
  20039. @item info meminfo
  20040. @kindex info meminfo
  20041. @cindex mapinfo list, QNX Neutrino
  20042. For QNX Neutrino only, this command displays the list of all mapinfos.
  20043. @end table
  20044. @node DJGPP Native
  20045. @subsection Features for Debugging @sc{djgpp} Programs
  20046. @cindex @sc{djgpp} debugging
  20047. @cindex native @sc{djgpp} debugging
  20048. @cindex MS-DOS-specific commands
  20049. @cindex DPMI
  20050. @sc{djgpp} is a port of the @sc{gnu} development tools to MS-DOS and
  20051. MS-Windows. @sc{djgpp} programs are 32-bit protected-mode programs
  20052. that use the @dfn{DPMI} (DOS Protected-Mode Interface) API to run on
  20053. top of real-mode DOS systems and their emulations.
  20054. @value{GDBN} supports native debugging of @sc{djgpp} programs, and
  20055. defines a few commands specific to the @sc{djgpp} port. This
  20056. subsection describes those commands.
  20057. @table @code
  20058. @kindex info dos
  20059. @item info dos
  20060. This is a prefix of @sc{djgpp}-specific commands which print
  20061. information about the target system and important OS structures.
  20062. @kindex sysinfo
  20063. @cindex MS-DOS system info
  20064. @cindex free memory information (MS-DOS)
  20065. @item info dos sysinfo
  20066. This command displays assorted information about the underlying
  20067. platform: the CPU type and features, the OS version and flavor, the
  20068. DPMI version, and the available conventional and DPMI memory.
  20069. @cindex GDT
  20070. @cindex LDT
  20071. @cindex IDT
  20072. @cindex segment descriptor tables
  20073. @cindex descriptor tables display
  20074. @item info dos gdt
  20075. @itemx info dos ldt
  20076. @itemx info dos idt
  20077. These 3 commands display entries from, respectively, Global, Local,
  20078. and Interrupt Descriptor Tables (GDT, LDT, and IDT). The descriptor
  20079. tables are data structures which store a descriptor for each segment
  20080. that is currently in use. The segment's selector is an index into a
  20081. descriptor table; the table entry for that index holds the
  20082. descriptor's base address and limit, and its attributes and access
  20083. rights.
  20084. A typical @sc{djgpp} program uses 3 segments: a code segment, a data
  20085. segment (used for both data and the stack), and a DOS segment (which
  20086. allows access to DOS/BIOS data structures and absolute addresses in
  20087. conventional memory). However, the DPMI host will usually define
  20088. additional segments in order to support the DPMI environment.
  20089. @cindex garbled pointers
  20090. These commands allow to display entries from the descriptor tables.
  20091. Without an argument, all entries from the specified table are
  20092. displayed. An argument, which should be an integer expression, means
  20093. display a single entry whose index is given by the argument. For
  20094. example, here's a convenient way to display information about the
  20095. debugged program's data segment:
  20096. @smallexample
  20097. @exdent @code{(@value{GDBP}) info dos ldt $ds}
  20098. @exdent @code{0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)}
  20099. @end smallexample
  20100. @noindent
  20101. This comes in handy when you want to see whether a pointer is outside
  20102. the data segment's limit (i.e.@: @dfn{garbled}).
  20103. @cindex page tables display (MS-DOS)
  20104. @item info dos pde
  20105. @itemx info dos pte
  20106. These two commands display entries from, respectively, the Page
  20107. Directory and the Page Tables. Page Directories and Page Tables are
  20108. data structures which control how virtual memory addresses are mapped
  20109. into physical addresses. A Page Table includes an entry for every
  20110. page of memory that is mapped into the program's address space; there
  20111. may be several Page Tables, each one holding up to 4096 entries. A
  20112. Page Directory has up to 4096 entries, one each for every Page Table
  20113. that is currently in use.
  20114. Without an argument, @kbd{info dos pde} displays the entire Page
  20115. Directory, and @kbd{info dos pte} displays all the entries in all of
  20116. the Page Tables. An argument, an integer expression, given to the
  20117. @kbd{info dos pde} command means display only that entry from the Page
  20118. Directory table. An argument given to the @kbd{info dos pte} command
  20119. means display entries from a single Page Table, the one pointed to by
  20120. the specified entry in the Page Directory.
  20121. @cindex direct memory access (DMA) on MS-DOS
  20122. These commands are useful when your program uses @dfn{DMA} (Direct
  20123. Memory Access), which needs physical addresses to program the DMA
  20124. controller.
  20125. These commands are supported only with some DPMI servers.
  20126. @cindex physical address from linear address
  20127. @item info dos address-pte @var{addr}
  20128. This command displays the Page Table entry for a specified linear
  20129. address. The argument @var{addr} is a linear address which should
  20130. already have the appropriate segment's base address added to it,
  20131. because this command accepts addresses which may belong to @emph{any}
  20132. segment. For example, here's how to display the Page Table entry for
  20133. the page where a variable @code{i} is stored:
  20134. @smallexample
  20135. @exdent @code{(@value{GDBP}) info dos address-pte __djgpp_base_address + (char *)&i}
  20136. @exdent @code{Page Table entry for address 0x11a00d30:}
  20137. @exdent @code{Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30}
  20138. @end smallexample
  20139. @noindent
  20140. This says that @code{i} is stored at offset @code{0xd30} from the page
  20141. whose physical base address is @code{0x02698000}, and shows all the
  20142. attributes of that page.
  20143. Note that you must cast the addresses of variables to a @code{char *},
  20144. since otherwise the value of @code{__djgpp_base_address}, the base
  20145. address of all variables and functions in a @sc{djgpp} program, will
  20146. be added using the rules of C pointer arithmetics: if @code{i} is
  20147. declared an @code{int}, @value{GDBN} will add 4 times the value of
  20148. @code{__djgpp_base_address} to the address of @code{i}.
  20149. Here's another example, it displays the Page Table entry for the
  20150. transfer buffer:
  20151. @smallexample
  20152. @exdent @code{(@value{GDBP}) info dos address-pte *((unsigned *)&_go32_info_block + 3)}
  20153. @exdent @code{Page Table entry for address 0x29110:}
  20154. @exdent @code{Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110}
  20155. @end smallexample
  20156. @noindent
  20157. (The @code{+ 3} offset is because the transfer buffer's address is the
  20158. 3rd member of the @code{_go32_info_block} structure.) The output
  20159. clearly shows that this DPMI server maps the addresses in conventional
  20160. memory 1:1, i.e.@: the physical (@code{0x00029000} + @code{0x110}) and
  20161. linear (@code{0x29110}) addresses are identical.
  20162. This command is supported only with some DPMI servers.
  20163. @end table
  20164. @cindex DOS serial data link, remote debugging
  20165. In addition to native debugging, the DJGPP port supports remote
  20166. debugging via a serial data link. The following commands are specific
  20167. to remote serial debugging in the DJGPP port of @value{GDBN}.
  20168. @table @code
  20169. @kindex set com1base
  20170. @kindex set com1irq
  20171. @kindex set com2base
  20172. @kindex set com2irq
  20173. @kindex set com3base
  20174. @kindex set com3irq
  20175. @kindex set com4base
  20176. @kindex set com4irq
  20177. @item set com1base @var{addr}
  20178. This command sets the base I/O port address of the @file{COM1} serial
  20179. port.
  20180. @item set com1irq @var{irq}
  20181. This command sets the @dfn{Interrupt Request} (@code{IRQ}) line to use
  20182. for the @file{COM1} serial port.
  20183. There are similar commands @samp{set com2base}, @samp{set com3irq},
  20184. etc.@: for setting the port address and the @code{IRQ} lines for the
  20185. other 3 COM ports.
  20186. @kindex show com1base
  20187. @kindex show com1irq
  20188. @kindex show com2base
  20189. @kindex show com2irq
  20190. @kindex show com3base
  20191. @kindex show com3irq
  20192. @kindex show com4base
  20193. @kindex show com4irq
  20194. The related commands @samp{show com1base}, @samp{show com1irq} etc.@:
  20195. display the current settings of the base address and the @code{IRQ}
  20196. lines used by the COM ports.
  20197. @item info serial
  20198. @kindex info serial
  20199. @cindex DOS serial port status
  20200. This command prints the status of the 4 DOS serial ports. For each
  20201. port, it prints whether it's active or not, its I/O base address and
  20202. IRQ number, whether it uses a 16550-style FIFO, its baudrate, and the
  20203. counts of various errors encountered so far.
  20204. @end table
  20205. @node Cygwin Native
  20206. @subsection Features for Debugging MS Windows PE Executables
  20207. @cindex MS Windows debugging
  20208. @cindex native Cygwin debugging
  20209. @cindex Cygwin-specific commands
  20210. @value{GDBN} supports native debugging of MS Windows programs, including
  20211. DLLs with and without symbolic debugging information.
  20212. @cindex Ctrl-BREAK, MS-Windows
  20213. @cindex interrupt debuggee on MS-Windows
  20214. MS-Windows programs that call @code{SetConsoleMode} to switch off the
  20215. special meaning of the @samp{Ctrl-C} keystroke cannot be interrupted
  20216. by typing @kbd{C-c}. For this reason, @value{GDBN} on MS-Windows
  20217. supports @kbd{C-@key{BREAK}} as an alternative interrupt key
  20218. sequence, which can be used to interrupt the debuggee even if it
  20219. ignores @kbd{C-c}.
  20220. There are various additional Cygwin-specific commands, described in
  20221. this section. Working with DLLs that have no debugging symbols is
  20222. described in @ref{Non-debug DLL Symbols}.
  20223. @table @code
  20224. @kindex info w32
  20225. @item info w32
  20226. This is a prefix of MS Windows-specific commands which print
  20227. information about the target system and important OS structures.
  20228. @item info w32 selector
  20229. This command displays information returned by
  20230. the Win32 API @code{GetThreadSelectorEntry} function.
  20231. It takes an optional argument that is evaluated to
  20232. a long value to give the information about this given selector.
  20233. Without argument, this command displays information
  20234. about the six segment registers.
  20235. @item info w32 thread-information-block
  20236. This command displays thread specific information stored in the
  20237. Thread Information Block (readable on the X86 CPU family using @code{$fs}
  20238. selector for 32-bit programs and @code{$gs} for 64-bit programs).
  20239. @kindex signal-event
  20240. @item signal-event @var{id}
  20241. This command signals an event with user-provided @var{id}. Used to resume
  20242. crashing process when attached to it using MS-Windows JIT debugging (AeDebug).
  20243. To use it, create or edit the following keys in
  20244. @code{HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug} and/or
  20245. @code{HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug}
  20246. (for x86_64 versions):
  20247. @itemize @minus
  20248. @item
  20249. @code{Debugger} (REG_SZ) --- a command to launch the debugger.
  20250. Suggested command is: @code{@var{fully-qualified-path-to-gdb.exe} -ex
  20251. "attach %ld" -ex "signal-event %ld" -ex "continue"}.
  20252. The first @code{%ld} will be replaced by the process ID of the
  20253. crashing process, the second @code{%ld} will be replaced by the ID of
  20254. the event that blocks the crashing process, waiting for @value{GDBN}
  20255. to attach.
  20256. @item
  20257. @code{Auto} (REG_SZ) --- either @code{1} or @code{0}. @code{1} will
  20258. make the system run debugger specified by the Debugger key
  20259. automatically, @code{0} will cause a dialog box with ``OK'' and
  20260. ``Cancel'' buttons to appear, which allows the user to either
  20261. terminate the crashing process (OK) or debug it (Cancel).
  20262. @end itemize
  20263. @kindex set cygwin-exceptions
  20264. @cindex debugging the Cygwin DLL
  20265. @cindex Cygwin DLL, debugging
  20266. @item set cygwin-exceptions @var{mode}
  20267. If @var{mode} is @code{on}, @value{GDBN} will break on exceptions that
  20268. happen inside the Cygwin DLL. If @var{mode} is @code{off},
  20269. @value{GDBN} will delay recognition of exceptions, and may ignore some
  20270. exceptions which seem to be caused by internal Cygwin DLL
  20271. ``bookkeeping''. This option is meant primarily for debugging the
  20272. Cygwin DLL itself; the default value is @code{off} to avoid annoying
  20273. @value{GDBN} users with false @code{SIGSEGV} signals.
  20274. @kindex show cygwin-exceptions
  20275. @item show cygwin-exceptions
  20276. Displays whether @value{GDBN} will break on exceptions that happen
  20277. inside the Cygwin DLL itself.
  20278. @kindex set new-console
  20279. @item set new-console @var{mode}
  20280. If @var{mode} is @code{on} the debuggee will
  20281. be started in a new console on next start.
  20282. If @var{mode} is @code{off}, the debuggee will
  20283. be started in the same console as the debugger.
  20284. @kindex show new-console
  20285. @item show new-console
  20286. Displays whether a new console is used
  20287. when the debuggee is started.
  20288. @kindex set new-group
  20289. @item set new-group @var{mode}
  20290. This boolean value controls whether the debuggee should
  20291. start a new group or stay in the same group as the debugger.
  20292. This affects the way the Windows OS handles
  20293. @samp{Ctrl-C}.
  20294. @kindex show new-group
  20295. @item show new-group
  20296. Displays current value of new-group boolean.
  20297. @kindex set debugevents
  20298. @item set debugevents
  20299. This boolean value adds debug output concerning kernel events related
  20300. to the debuggee seen by the debugger. This includes events that
  20301. signal thread and process creation and exit, DLL loading and
  20302. unloading, console interrupts, and debugging messages produced by the
  20303. Windows @code{OutputDebugString} API call.
  20304. @kindex set debugexec
  20305. @item set debugexec
  20306. This boolean value adds debug output concerning execute events
  20307. (such as resume thread) seen by the debugger.
  20308. @kindex set debugexceptions
  20309. @item set debugexceptions
  20310. This boolean value adds debug output concerning exceptions in the
  20311. debuggee seen by the debugger.
  20312. @kindex set debugmemory
  20313. @item set debugmemory
  20314. This boolean value adds debug output concerning debuggee memory reads
  20315. and writes by the debugger.
  20316. @kindex set shell
  20317. @item set shell
  20318. This boolean values specifies whether the debuggee is called
  20319. via a shell or directly (default value is on).
  20320. @kindex show shell
  20321. @item show shell
  20322. Displays if the debuggee will be started with a shell.
  20323. @end table
  20324. @menu
  20325. * Non-debug DLL Symbols:: Support for DLLs without debugging symbols
  20326. @end menu
  20327. @node Non-debug DLL Symbols
  20328. @subsubsection Support for DLLs without Debugging Symbols
  20329. @cindex DLLs with no debugging symbols
  20330. @cindex Minimal symbols and DLLs
  20331. Very often on windows, some of the DLLs that your program relies on do
  20332. not include symbolic debugging information (for example,
  20333. @file{kernel32.dll}). When @value{GDBN} doesn't recognize any debugging
  20334. symbols in a DLL, it relies on the minimal amount of symbolic
  20335. information contained in the DLL's export table. This section
  20336. describes working with such symbols, known internally to @value{GDBN} as
  20337. ``minimal symbols''.
  20338. Note that before the debugged program has started execution, no DLLs
  20339. will have been loaded. The easiest way around this problem is simply to
  20340. start the program --- either by setting a breakpoint or letting the
  20341. program run once to completion.
  20342. @subsubsection DLL Name Prefixes
  20343. In keeping with the naming conventions used by the Microsoft debugging
  20344. tools, DLL export symbols are made available with a prefix based on the
  20345. DLL name, for instance @code{KERNEL32!CreateFileA}. The plain name is
  20346. also entered into the symbol table, so @code{CreateFileA} is often
  20347. sufficient. In some cases there will be name clashes within a program
  20348. (particularly if the executable itself includes full debugging symbols)
  20349. necessitating the use of the fully qualified name when referring to the
  20350. contents of the DLL. Use single-quotes around the name to avoid the
  20351. exclamation mark (``!'') being interpreted as a language operator.
  20352. Note that the internal name of the DLL may be all upper-case, even
  20353. though the file name of the DLL is lower-case, or vice-versa. Since
  20354. symbols within @value{GDBN} are @emph{case-sensitive} this may cause
  20355. some confusion. If in doubt, try the @code{info functions} and
  20356. @code{info variables} commands or even @code{maint print msymbols}
  20357. (@pxref{Symbols}). Here's an example:
  20358. @smallexample
  20359. (@value{GDBP}) info function CreateFileA
  20360. All functions matching regular expression "CreateFileA":
  20361. Non-debugging symbols:
  20362. 0x77e885f4 CreateFileA
  20363. 0x77e885f4 KERNEL32!CreateFileA
  20364. @end smallexample
  20365. @smallexample
  20366. (@value{GDBP}) info function !
  20367. All functions matching regular expression "!":
  20368. Non-debugging symbols:
  20369. 0x6100114c cygwin1!__assert
  20370. 0x61004034 cygwin1!_dll_crt0@@0
  20371. 0x61004240 cygwin1!dll_crt0(per_process *)
  20372. [etc...]
  20373. @end smallexample
  20374. @subsubsection Working with Minimal Symbols
  20375. Symbols extracted from a DLL's export table do not contain very much
  20376. type information. All that @value{GDBN} can do is guess whether a symbol
  20377. refers to a function or variable depending on the linker section that
  20378. contains the symbol. Also note that the actual contents of the memory
  20379. contained in a DLL are not available unless the program is running. This
  20380. means that you cannot examine the contents of a variable or disassemble
  20381. a function within a DLL without a running program.
  20382. Variables are generally treated as pointers and dereferenced
  20383. automatically. For this reason, it is often necessary to prefix a
  20384. variable name with the address-of operator (``&'') and provide explicit
  20385. type information in the command. Here's an example of the type of
  20386. problem:
  20387. @smallexample
  20388. (@value{GDBP}) print 'cygwin1!__argv'
  20389. 'cygwin1!__argv' has unknown type; cast it to its declared type
  20390. @end smallexample
  20391. @smallexample
  20392. (@value{GDBP}) x 'cygwin1!__argv'
  20393. 'cygwin1!__argv' has unknown type; cast it to its declared type
  20394. @end smallexample
  20395. And two possible solutions:
  20396. @smallexample
  20397. (@value{GDBP}) print ((char **)'cygwin1!__argv')[0]
  20398. $2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram"
  20399. @end smallexample
  20400. @smallexample
  20401. (@value{GDBP}) x/2x &'cygwin1!__argv'
  20402. 0x610c0aa8 <cygwin1!__argv>: 0x10021608 0x00000000
  20403. (@value{GDBP}) x/x 0x10021608
  20404. 0x10021608: 0x0022fd98
  20405. (@value{GDBP}) x/s 0x0022fd98
  20406. 0x22fd98: "/cygdrive/c/mydirectory/myprogram"
  20407. @end smallexample
  20408. Setting a break point within a DLL is possible even before the program
  20409. starts execution. However, under these circumstances, @value{GDBN} can't
  20410. examine the initial instructions of the function in order to skip the
  20411. function's frame set-up code. You can work around this by using ``*&''
  20412. to set the breakpoint at a raw memory address:
  20413. @smallexample
  20414. (@value{GDBP}) break *&'python22!PyOS_Readline'
  20415. Breakpoint 1 at 0x1e04eff0
  20416. @end smallexample
  20417. The author of these extensions is not entirely convinced that setting a
  20418. break point within a shared DLL like @file{kernel32.dll} is completely
  20419. safe.
  20420. @node Hurd Native
  20421. @subsection Commands Specific to @sc{gnu} Hurd Systems
  20422. @cindex @sc{gnu} Hurd debugging
  20423. This subsection describes @value{GDBN} commands specific to the
  20424. @sc{gnu} Hurd native debugging.
  20425. @table @code
  20426. @item set signals
  20427. @itemx set sigs
  20428. @kindex set signals@r{, Hurd command}
  20429. @kindex set sigs@r{, Hurd command}
  20430. This command toggles the state of inferior signal interception by
  20431. @value{GDBN}. Mach exceptions, such as breakpoint traps, are not
  20432. affected by this command. @code{sigs} is a shorthand alias for
  20433. @code{signals}.
  20434. @item show signals
  20435. @itemx show sigs
  20436. @kindex show signals@r{, Hurd command}
  20437. @kindex show sigs@r{, Hurd command}
  20438. Show the current state of intercepting inferior's signals.
  20439. @item set signal-thread
  20440. @itemx set sigthread
  20441. @kindex set signal-thread
  20442. @kindex set sigthread
  20443. This command tells @value{GDBN} which thread is the @code{libc} signal
  20444. thread. That thread is run when a signal is delivered to a running
  20445. process. @code{set sigthread} is the shorthand alias of @code{set
  20446. signal-thread}.
  20447. @item show signal-thread
  20448. @itemx show sigthread
  20449. @kindex show signal-thread
  20450. @kindex show sigthread
  20451. These two commands show which thread will run when the inferior is
  20452. delivered a signal.
  20453. @item set stopped
  20454. @kindex set stopped@r{, Hurd command}
  20455. This commands tells @value{GDBN} that the inferior process is stopped,
  20456. as with the @code{SIGSTOP} signal. The stopped process can be
  20457. continued by delivering a signal to it.
  20458. @item show stopped
  20459. @kindex show stopped@r{, Hurd command}
  20460. This command shows whether @value{GDBN} thinks the debuggee is
  20461. stopped.
  20462. @item set exceptions
  20463. @kindex set exceptions@r{, Hurd command}
  20464. Use this command to turn off trapping of exceptions in the inferior.
  20465. When exception trapping is off, neither breakpoints nor
  20466. single-stepping will work. To restore the default, set exception
  20467. trapping on.
  20468. @item show exceptions
  20469. @kindex show exceptions@r{, Hurd command}
  20470. Show the current state of trapping exceptions in the inferior.
  20471. @item set task pause
  20472. @kindex set task@r{, Hurd commands}
  20473. @cindex task attributes (@sc{gnu} Hurd)
  20474. @cindex pause current task (@sc{gnu} Hurd)
  20475. This command toggles task suspension when @value{GDBN} has control.
  20476. Setting it to on takes effect immediately, and the task is suspended
  20477. whenever @value{GDBN} gets control. Setting it to off will take
  20478. effect the next time the inferior is continued. If this option is set
  20479. to off, you can use @code{set thread default pause on} or @code{set
  20480. thread pause on} (see below) to pause individual threads.
  20481. @item show task pause
  20482. @kindex show task@r{, Hurd commands}
  20483. Show the current state of task suspension.
  20484. @item set task detach-suspend-count
  20485. @cindex task suspend count
  20486. @cindex detach from task, @sc{gnu} Hurd
  20487. This command sets the suspend count the task will be left with when
  20488. @value{GDBN} detaches from it.
  20489. @item show task detach-suspend-count
  20490. Show the suspend count the task will be left with when detaching.
  20491. @item set task exception-port
  20492. @itemx set task excp
  20493. @cindex task exception port, @sc{gnu} Hurd
  20494. This command sets the task exception port to which @value{GDBN} will
  20495. forward exceptions. The argument should be the value of the @dfn{send
  20496. rights} of the task. @code{set task excp} is a shorthand alias.
  20497. @item set noninvasive
  20498. @cindex noninvasive task options
  20499. This command switches @value{GDBN} to a mode that is the least
  20500. invasive as far as interfering with the inferior is concerned. This
  20501. is the same as using @code{set task pause}, @code{set exceptions}, and
  20502. @code{set signals} to values opposite to the defaults.
  20503. @item info send-rights
  20504. @itemx info receive-rights
  20505. @itemx info port-rights
  20506. @itemx info port-sets
  20507. @itemx info dead-names
  20508. @itemx info ports
  20509. @itemx info psets
  20510. @cindex send rights, @sc{gnu} Hurd
  20511. @cindex receive rights, @sc{gnu} Hurd
  20512. @cindex port rights, @sc{gnu} Hurd
  20513. @cindex port sets, @sc{gnu} Hurd
  20514. @cindex dead names, @sc{gnu} Hurd
  20515. These commands display information about, respectively, send rights,
  20516. receive rights, port rights, port sets, and dead names of a task.
  20517. There are also shorthand aliases: @code{info ports} for @code{info
  20518. port-rights} and @code{info psets} for @code{info port-sets}.
  20519. @item set thread pause
  20520. @kindex set thread@r{, Hurd command}
  20521. @cindex thread properties, @sc{gnu} Hurd
  20522. @cindex pause current thread (@sc{gnu} Hurd)
  20523. This command toggles current thread suspension when @value{GDBN} has
  20524. control. Setting it to on takes effect immediately, and the current
  20525. thread is suspended whenever @value{GDBN} gets control. Setting it to
  20526. off will take effect the next time the inferior is continued.
  20527. Normally, this command has no effect, since when @value{GDBN} has
  20528. control, the whole task is suspended. However, if you used @code{set
  20529. task pause off} (see above), this command comes in handy to suspend
  20530. only the current thread.
  20531. @item show thread pause
  20532. @kindex show thread@r{, Hurd command}
  20533. This command shows the state of current thread suspension.
  20534. @item set thread run
  20535. This command sets whether the current thread is allowed to run.
  20536. @item show thread run
  20537. Show whether the current thread is allowed to run.
  20538. @item set thread detach-suspend-count
  20539. @cindex thread suspend count, @sc{gnu} Hurd
  20540. @cindex detach from thread, @sc{gnu} Hurd
  20541. This command sets the suspend count @value{GDBN} will leave on a
  20542. thread when detaching. This number is relative to the suspend count
  20543. found by @value{GDBN} when it notices the thread; use @code{set thread
  20544. takeover-suspend-count} to force it to an absolute value.
  20545. @item show thread detach-suspend-count
  20546. Show the suspend count @value{GDBN} will leave on the thread when
  20547. detaching.
  20548. @item set thread exception-port
  20549. @itemx set thread excp
  20550. Set the thread exception port to which to forward exceptions. This
  20551. overrides the port set by @code{set task exception-port} (see above).
  20552. @code{set thread excp} is the shorthand alias.
  20553. @item set thread takeover-suspend-count
  20554. Normally, @value{GDBN}'s thread suspend counts are relative to the
  20555. value @value{GDBN} finds when it notices each thread. This command
  20556. changes the suspend counts to be absolute instead.
  20557. @item set thread default
  20558. @itemx show thread default
  20559. @cindex thread default settings, @sc{gnu} Hurd
  20560. Each of the above @code{set thread} commands has a @code{set thread
  20561. default} counterpart (e.g., @code{set thread default pause}, @code{set
  20562. thread default exception-port}, etc.). The @code{thread default}
  20563. variety of commands sets the default thread properties for all
  20564. threads; you can then change the properties of individual threads with
  20565. the non-default commands.
  20566. @end table
  20567. @node Darwin
  20568. @subsection Darwin
  20569. @cindex Darwin
  20570. @value{GDBN} provides the following commands specific to the Darwin target:
  20571. @table @code
  20572. @item set debug darwin @var{num}
  20573. @kindex set debug darwin
  20574. When set to a non zero value, enables debugging messages specific to
  20575. the Darwin support. Higher values produce more verbose output.
  20576. @item show debug darwin
  20577. @kindex show debug darwin
  20578. Show the current state of Darwin messages.
  20579. @item set debug mach-o @var{num}
  20580. @kindex set debug mach-o
  20581. When set to a non zero value, enables debugging messages while
  20582. @value{GDBN} is reading Darwin object files. (@dfn{Mach-O} is the
  20583. file format used on Darwin for object and executable files.) Higher
  20584. values produce more verbose output. This is a command to diagnose
  20585. problems internal to @value{GDBN} and should not be needed in normal
  20586. usage.
  20587. @item show debug mach-o
  20588. @kindex show debug mach-o
  20589. Show the current state of Mach-O file messages.
  20590. @item set mach-exceptions on
  20591. @itemx set mach-exceptions off
  20592. @kindex set mach-exceptions
  20593. On Darwin, faults are first reported as a Mach exception and are then
  20594. mapped to a Posix signal. Use this command to turn on trapping of
  20595. Mach exceptions in the inferior. This might be sometimes useful to
  20596. better understand the cause of a fault. The default is off.
  20597. @item show mach-exceptions
  20598. @kindex show mach-exceptions
  20599. Show the current state of exceptions trapping.
  20600. @end table
  20601. @node FreeBSD
  20602. @subsection FreeBSD
  20603. @cindex FreeBSD
  20604. When the ABI of a system call is changed in the FreeBSD kernel, this
  20605. is implemented by leaving a compatibility system call using the old
  20606. ABI at the existing number and allocating a new system call number for
  20607. the version using the new ABI. As a convenience, when a system call
  20608. is caught by name (@pxref{catch syscall}), compatibility system calls
  20609. are also caught.
  20610. For example, FreeBSD 12 introduced a new variant of the @code{kevent}
  20611. system call and catching the @code{kevent} system call by name catches
  20612. both variants:
  20613. @smallexample
  20614. (@value{GDBP}) catch syscall kevent
  20615. Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560])
  20616. (@value{GDBP})
  20617. @end smallexample
  20618. @node Embedded OS
  20619. @section Embedded Operating Systems
  20620. This section describes configurations involving the debugging of
  20621. embedded operating systems that are available for several different
  20622. architectures.
  20623. @value{GDBN} includes the ability to debug programs running on
  20624. various real-time operating systems.
  20625. @node Embedded Processors
  20626. @section Embedded Processors
  20627. This section goes into details specific to particular embedded
  20628. configurations.
  20629. @cindex send command to simulator
  20630. Whenever a specific embedded processor has a simulator, @value{GDBN}
  20631. allows to send an arbitrary command to the simulator.
  20632. @table @code
  20633. @item sim @var{command}
  20634. @kindex sim@r{, a command}
  20635. Send an arbitrary @var{command} string to the simulator. Consult the
  20636. documentation for the specific simulator in use for information about
  20637. acceptable commands.
  20638. @end table
  20639. @menu
  20640. * ARC:: Synopsys ARC
  20641. * ARM:: ARM
  20642. * BPF:: eBPF
  20643. * M68K:: Motorola M68K
  20644. * MicroBlaze:: Xilinx MicroBlaze
  20645. * MIPS Embedded:: MIPS Embedded
  20646. * OpenRISC 1000:: OpenRISC 1000 (or1k)
  20647. * PowerPC Embedded:: PowerPC Embedded
  20648. * AVR:: Atmel AVR
  20649. * CRIS:: CRIS
  20650. * Super-H:: Renesas Super-H
  20651. @end menu
  20652. @node ARC
  20653. @subsection Synopsys ARC
  20654. @cindex Synopsys ARC
  20655. @cindex ARC specific commands
  20656. @cindex ARC600
  20657. @cindex ARC700
  20658. @cindex ARC EM
  20659. @cindex ARC HS
  20660. @value{GDBN} provides the following ARC-specific commands:
  20661. @table @code
  20662. @item set debug arc
  20663. @kindex set debug arc
  20664. Control the level of ARC specific debug messages. Use 0 for no messages (the
  20665. default), 1 for debug messages, and 2 for even more debug messages.
  20666. @item show debug arc
  20667. @kindex show debug arc
  20668. Show the level of ARC specific debugging in operation.
  20669. @item maint print arc arc-instruction @var{address}
  20670. @kindex maint print arc arc-instruction
  20671. Print internal disassembler information about instruction at a given address.
  20672. @end table
  20673. @node ARM
  20674. @subsection ARM
  20675. @value{GDBN} provides the following ARM-specific commands:
  20676. @table @code
  20677. @item set arm disassembler
  20678. @kindex set arm
  20679. This commands selects from a list of disassembly styles. The
  20680. @code{"std"} style is the standard style.
  20681. @item show arm disassembler
  20682. @kindex show arm
  20683. Show the current disassembly style.
  20684. @item set arm apcs32
  20685. @cindex ARM 32-bit mode
  20686. This command toggles ARM operation mode between 32-bit and 26-bit.
  20687. @item show arm apcs32
  20688. Display the current usage of the ARM 32-bit mode.
  20689. @item set arm fpu @var{fputype}
  20690. This command sets the ARM floating-point unit (FPU) type. The
  20691. argument @var{fputype} can be one of these:
  20692. @table @code
  20693. @item auto
  20694. Determine the FPU type by querying the OS ABI.
  20695. @item softfpa
  20696. Software FPU, with mixed-endian doubles on little-endian ARM
  20697. processors.
  20698. @item fpa
  20699. GCC-compiled FPA co-processor.
  20700. @item softvfp
  20701. Software FPU with pure-endian doubles.
  20702. @item vfp
  20703. VFP co-processor.
  20704. @end table
  20705. @item show arm fpu
  20706. Show the current type of the FPU.
  20707. @item set arm abi
  20708. This command forces @value{GDBN} to use the specified ABI.
  20709. @item show arm abi
  20710. Show the currently used ABI.
  20711. @item set arm fallback-mode (arm|thumb|auto)
  20712. @value{GDBN} uses the symbol table, when available, to determine
  20713. whether instructions are ARM or Thumb. This command controls
  20714. @value{GDBN}'s default behavior when the symbol table is not
  20715. available. The default is @samp{auto}, which causes @value{GDBN} to
  20716. use the current execution mode (from the @code{T} bit in the @code{CPSR}
  20717. register).
  20718. @item show arm fallback-mode
  20719. Show the current fallback instruction mode.
  20720. @item set arm force-mode (arm|thumb|auto)
  20721. This command overrides use of the symbol table to determine whether
  20722. instructions are ARM or Thumb. The default is @samp{auto}, which
  20723. causes @value{GDBN} to use the symbol table and then the setting
  20724. of @samp{set arm fallback-mode}.
  20725. @item show arm force-mode
  20726. Show the current forced instruction mode.
  20727. @item set debug arm
  20728. Toggle whether to display ARM-specific debugging messages from the ARM
  20729. target support subsystem.
  20730. @item show debug arm
  20731. Show whether ARM-specific debugging messages are enabled.
  20732. @end table
  20733. @table @code
  20734. @item target sim @r{[}@var{simargs}@r{]} @dots{}
  20735. The @value{GDBN} ARM simulator accepts the following optional arguments.
  20736. @table @code
  20737. @item --swi-support=@var{type}
  20738. Tell the simulator which SWI interfaces to support. The argument
  20739. @var{type} may be a comma separated list of the following values.
  20740. The default value is @code{all}.
  20741. @table @code
  20742. @item none
  20743. @item demon
  20744. @item angel
  20745. @item redboot
  20746. @item all
  20747. @end table
  20748. @end table
  20749. @end table
  20750. @node BPF
  20751. @subsection BPF
  20752. @table @code
  20753. @item target sim @r{[}@var{simargs}@r{]} @dots{}
  20754. The @value{GDBN} BPF simulator accepts the following optional arguments.
  20755. @table @code
  20756. @item --skb-data-offset=@var{offset}
  20757. Tell the simulator the offset, measured in bytes, of the
  20758. @code{skb_data} field in the kernel @code{struct sk_buff} structure.
  20759. This offset is used by some BPF specific-purpose load/store
  20760. instructions. Defaults to 0.
  20761. @end table
  20762. @end table
  20763. @node M68K
  20764. @subsection M68k
  20765. The Motorola m68k configuration includes ColdFire support.
  20766. @node MicroBlaze
  20767. @subsection MicroBlaze
  20768. @cindex Xilinx MicroBlaze
  20769. @cindex XMD, Xilinx Microprocessor Debugger
  20770. The MicroBlaze is a soft-core processor supported on various Xilinx
  20771. FPGAs, such as Spartan or Virtex series. Boards with these processors
  20772. usually have JTAG ports which connect to a host system running the Xilinx
  20773. Embedded Development Kit (EDK) or Software Development Kit (SDK).
  20774. This host system is used to download the configuration bitstream to
  20775. the target FPGA. The Xilinx Microprocessor Debugger (XMD) program
  20776. communicates with the target board using the JTAG interface and
  20777. presents a @code{gdbserver} interface to the board. By default
  20778. @code{xmd} uses port @code{1234}. (While it is possible to change
  20779. this default port, it requires the use of undocumented @code{xmd}
  20780. commands. Contact Xilinx support if you need to do this.)
  20781. Use these GDB commands to connect to the MicroBlaze target processor.
  20782. @table @code
  20783. @item target remote :1234
  20784. Use this command to connect to the target if you are running @value{GDBN}
  20785. on the same system as @code{xmd}.
  20786. @item target remote @var{xmd-host}:1234
  20787. Use this command to connect to the target if it is connected to @code{xmd}
  20788. running on a different system named @var{xmd-host}.
  20789. @item load
  20790. Use this command to download a program to the MicroBlaze target.
  20791. @item set debug microblaze @var{n}
  20792. Enable MicroBlaze-specific debugging messages if non-zero.
  20793. @item show debug microblaze @var{n}
  20794. Show MicroBlaze-specific debugging level.
  20795. @end table
  20796. @node MIPS Embedded
  20797. @subsection @acronym{MIPS} Embedded
  20798. @noindent
  20799. @value{GDBN} supports these special commands for @acronym{MIPS} targets:
  20800. @table @code
  20801. @item set mipsfpu double
  20802. @itemx set mipsfpu single
  20803. @itemx set mipsfpu none
  20804. @itemx set mipsfpu auto
  20805. @itemx show mipsfpu
  20806. @kindex set mipsfpu
  20807. @kindex show mipsfpu
  20808. @cindex @acronym{MIPS} remote floating point
  20809. @cindex floating point, @acronym{MIPS} remote
  20810. If your target board does not support the @acronym{MIPS} floating point
  20811. coprocessor, you should use the command @samp{set mipsfpu none} (if you
  20812. need this, you may wish to put the command in your @value{GDBN} init
  20813. file). This tells @value{GDBN} how to find the return value of
  20814. functions which return floating point values. It also allows
  20815. @value{GDBN} to avoid saving the floating point registers when calling
  20816. functions on the board. If you are using a floating point coprocessor
  20817. with only single precision floating point support, as on the @sc{r4650}
  20818. processor, use the command @samp{set mipsfpu single}. The default
  20819. double precision floating point coprocessor may be selected using
  20820. @samp{set mipsfpu double}.
  20821. In previous versions the only choices were double precision or no
  20822. floating point, so @samp{set mipsfpu on} will select double precision
  20823. and @samp{set mipsfpu off} will select no floating point.
  20824. As usual, you can inquire about the @code{mipsfpu} variable with
  20825. @samp{show mipsfpu}.
  20826. @end table
  20827. @node OpenRISC 1000
  20828. @subsection OpenRISC 1000
  20829. @cindex OpenRISC 1000
  20830. @noindent
  20831. The OpenRISC 1000 provides a free RISC instruction set architecture. It is
  20832. mainly provided as a soft-core which can run on Xilinx, Altera and other
  20833. FPGA's.
  20834. @value{GDBN} for OpenRISC supports the below commands when connecting to
  20835. a target:
  20836. @table @code
  20837. @kindex target sim
  20838. @item target sim
  20839. Runs the builtin CPU simulator which can run very basic
  20840. programs but does not support most hardware functions like MMU.
  20841. For more complex use cases the user is advised to run an external
  20842. target, and connect using @samp{target remote}.
  20843. Example: @code{target sim}
  20844. @item set debug or1k
  20845. Toggle whether to display OpenRISC-specific debugging messages from the
  20846. OpenRISC target support subsystem.
  20847. @item show debug or1k
  20848. Show whether OpenRISC-specific debugging messages are enabled.
  20849. @end table
  20850. @node PowerPC Embedded
  20851. @subsection PowerPC Embedded
  20852. @cindex DVC register
  20853. @value{GDBN} supports using the DVC (Data Value Compare) register to
  20854. implement in hardware simple hardware watchpoint conditions of the form:
  20855. @smallexample
  20856. (@value{GDBP}) watch @var{address|variable} \
  20857. if @var{address|variable} == @var{constant expression}
  20858. @end smallexample
  20859. The DVC register will be automatically used when @value{GDBN} detects
  20860. such pattern in a condition expression, and the created watchpoint uses one
  20861. debug register (either the @code{exact-watchpoints} option is on and the
  20862. variable is scalar, or the variable has a length of one byte). This feature
  20863. is available in native @value{GDBN} running on a Linux kernel version 2.6.34
  20864. or newer.
  20865. When running on PowerPC embedded processors, @value{GDBN} automatically uses
  20866. ranged hardware watchpoints, unless the @code{exact-watchpoints} option is on,
  20867. in which case watchpoints using only one debug register are created when
  20868. watching variables of scalar types.
  20869. You can create an artificial array to watch an arbitrary memory
  20870. region using one of the following commands (@pxref{Expressions}):
  20871. @smallexample
  20872. (@value{GDBP}) watch *((char *) @var{address})@@@var{length}
  20873. (@value{GDBP}) watch @{char[@var{length}]@} @var{address}
  20874. @end smallexample
  20875. PowerPC embedded processors support masked watchpoints. See the discussion
  20876. about the @code{mask} argument in @ref{Set Watchpoints}.
  20877. @cindex ranged breakpoint
  20878. PowerPC embedded processors support hardware accelerated
  20879. @dfn{ranged breakpoints}. A ranged breakpoint stops execution of
  20880. the inferior whenever it executes an instruction at any address within
  20881. the range it specifies. To set a ranged breakpoint in @value{GDBN},
  20882. use the @code{break-range} command.
  20883. @value{GDBN} provides the following PowerPC-specific commands:
  20884. @table @code
  20885. @kindex break-range
  20886. @item break-range @var{start-location}, @var{end-location}
  20887. Set a breakpoint for an address range given by
  20888. @var{start-location} and @var{end-location}, which can specify a function name,
  20889. a line number, an offset of lines from the current line or from the start
  20890. location, or an address of an instruction (see @ref{Specify Location},
  20891. for a list of all the possible ways to specify a @var{location}.)
  20892. The breakpoint will stop execution of the inferior whenever it
  20893. executes an instruction at any address within the specified range,
  20894. (including @var{start-location} and @var{end-location}.)
  20895. @kindex set powerpc
  20896. @item set powerpc soft-float
  20897. @itemx show powerpc soft-float
  20898. Force @value{GDBN} to use (or not use) a software floating point calling
  20899. convention. By default, @value{GDBN} selects the calling convention based
  20900. on the selected architecture and the provided executable file.
  20901. @item set powerpc vector-abi
  20902. @itemx show powerpc vector-abi
  20903. Force @value{GDBN} to use the specified calling convention for vector
  20904. arguments and return values. The valid options are @samp{auto};
  20905. @samp{generic}, to avoid vector registers even if they are present;
  20906. @samp{altivec}, to use AltiVec registers; and @samp{spe} to use SPE
  20907. registers. By default, @value{GDBN} selects the calling convention
  20908. based on the selected architecture and the provided executable file.
  20909. @item set powerpc exact-watchpoints
  20910. @itemx show powerpc exact-watchpoints
  20911. Allow @value{GDBN} to use only one debug register when watching a variable
  20912. of scalar type, thus assuming that the variable is accessed through the
  20913. address of its first byte.
  20914. @end table
  20915. @node AVR
  20916. @subsection Atmel AVR
  20917. @cindex AVR
  20918. When configured for debugging the Atmel AVR, @value{GDBN} supports the
  20919. following AVR-specific commands:
  20920. @table @code
  20921. @item info io_registers
  20922. @kindex info io_registers@r{, AVR}
  20923. @cindex I/O registers (Atmel AVR)
  20924. This command displays information about the AVR I/O registers. For
  20925. each register, @value{GDBN} prints its number and value.
  20926. @end table
  20927. @node CRIS
  20928. @subsection CRIS
  20929. @cindex CRIS
  20930. When configured for debugging CRIS, @value{GDBN} provides the
  20931. following CRIS-specific commands:
  20932. @table @code
  20933. @item set cris-version @var{ver}
  20934. @cindex CRIS version
  20935. Set the current CRIS version to @var{ver}, either @samp{10} or @samp{32}.
  20936. The CRIS version affects register names and sizes. This command is useful in
  20937. case autodetection of the CRIS version fails.
  20938. @item show cris-version
  20939. Show the current CRIS version.
  20940. @item set cris-dwarf2-cfi
  20941. @cindex DWARF-2 CFI and CRIS
  20942. Set the usage of DWARF-2 CFI for CRIS debugging. The default is @samp{on}.
  20943. Change to @samp{off} when using @code{gcc-cris} whose version is below
  20944. @code{R59}.
  20945. @item show cris-dwarf2-cfi
  20946. Show the current state of using DWARF-2 CFI.
  20947. @item set cris-mode @var{mode}
  20948. @cindex CRIS mode
  20949. Set the current CRIS mode to @var{mode}. It should only be changed when
  20950. debugging in guru mode, in which case it should be set to
  20951. @samp{guru} (the default is @samp{normal}).
  20952. @item show cris-mode
  20953. Show the current CRIS mode.
  20954. @end table
  20955. @node Super-H
  20956. @subsection Renesas Super-H
  20957. @cindex Super-H
  20958. For the Renesas Super-H processor, @value{GDBN} provides these
  20959. commands:
  20960. @table @code
  20961. @item set sh calling-convention @var{convention}
  20962. @kindex set sh calling-convention
  20963. Set the calling-convention used when calling functions from @value{GDBN}.
  20964. Allowed values are @samp{gcc}, which is the default setting, and @samp{renesas}.
  20965. With the @samp{gcc} setting, functions are called using the @value{NGCC} calling
  20966. convention. If the DWARF-2 information of the called function specifies
  20967. that the function follows the Renesas calling convention, the function
  20968. is called using the Renesas calling convention. If the calling convention
  20969. is set to @samp{renesas}, the Renesas calling convention is always used,
  20970. regardless of the DWARF-2 information. This can be used to override the
  20971. default of @samp{gcc} if debug information is missing, or the compiler
  20972. does not emit the DWARF-2 calling convention entry for a function.
  20973. @item show sh calling-convention
  20974. @kindex show sh calling-convention
  20975. Show the current calling convention setting.
  20976. @end table
  20977. @node Architectures
  20978. @section Architectures
  20979. This section describes characteristics of architectures that affect
  20980. all uses of @value{GDBN} with the architecture, both native and cross.
  20981. @menu
  20982. * AArch64::
  20983. * i386::
  20984. * Alpha::
  20985. * MIPS::
  20986. * HPPA:: HP PA architecture
  20987. * PowerPC::
  20988. * Nios II::
  20989. * Sparc64::
  20990. * S12Z::
  20991. @end menu
  20992. @node AArch64
  20993. @subsection AArch64
  20994. @cindex AArch64 support
  20995. When @value{GDBN} is debugging the AArch64 architecture, it provides the
  20996. following special commands:
  20997. @table @code
  20998. @item set debug aarch64
  20999. @kindex set debug aarch64
  21000. This command determines whether AArch64 architecture-specific debugging
  21001. messages are to be displayed.
  21002. @item show debug aarch64
  21003. Show whether AArch64 debugging messages are displayed.
  21004. @end table
  21005. @subsubsection AArch64 SVE.
  21006. @cindex AArch64 SVE.
  21007. When @value{GDBN} is debugging the AArch64 architecture, if the Scalable Vector
  21008. Extension (SVE) is present, then @value{GDBN} will provide the vector registers
  21009. @code{$z0} through @code{$z31}, vector predicate registers @code{$p0} through
  21010. @code{$p15}, and the @code{$ffr} register. In addition, the pseudo register
  21011. @code{$vg} will be provided. This is the vector granule for the current thread
  21012. and represents the number of 64-bit chunks in an SVE @code{z} register.
  21013. If the vector length changes, then the @code{$vg} register will be updated,
  21014. but the lengths of the @code{z} and @code{p} registers will not change. This
  21015. is a known limitation of @value{GDBN} and does not affect the execution of the
  21016. target process.
  21017. @subsubsection AArch64 Pointer Authentication.
  21018. @cindex AArch64 Pointer Authentication.
  21019. @anchor{AArch64 PAC}
  21020. When @value{GDBN} is debugging the AArch64 architecture, and the program is
  21021. using the v8.3-A feature Pointer Authentication (PAC), then whenever the link
  21022. register @code{$lr} is pointing to an PAC function its value will be masked.
  21023. When GDB prints a backtrace, any addresses that required unmasking will be
  21024. postfixed with the marker [PAC]. When using the MI, this is printed as part
  21025. of the @code{addr_flags} field.
  21026. @subsubsection AArch64 Memory Tagging Extension.
  21027. @cindex AArch64 Memory Tagging Extension.
  21028. When @value{GDBN} is debugging the AArch64 architecture, the program is
  21029. using the v8.5-A feature Memory Tagging Extension (MTE) and there is support
  21030. in the kernel for MTE, @value{GDBN} will make memory tagging functionality
  21031. available for inspection and editing of logical and allocation tags.
  21032. @xref{Memory Tagging}.
  21033. To aid debugging, @value{GDBN} will output additional information when SIGSEGV
  21034. signals are generated as a result of memory tag failures.
  21035. If the tag violation is synchronous, the following will be shown:
  21036. @smallexample
  21037. Program received signal SIGSEGV, Segmentation fault
  21038. Memory tag violation while accessing address 0x0500fffff7ff8000
  21039. Allocation tag 0x1
  21040. Logical tag 0x5.
  21041. @end smallexample
  21042. If the tag violation is asynchronous, the fault address is not available.
  21043. In this case @value{GDBN} will show the following:
  21044. @smallexample
  21045. Program received signal SIGSEGV, Segmentation fault
  21046. Memory tag violation
  21047. Fault address unavailable.
  21048. @end smallexample
  21049. A special register, @code{tag_ctl}, is made available through the
  21050. @code{org.gnu.gdb.aarch64.mte} feature. This register exposes some
  21051. options that can be controlled at runtime and emulates the @code{prctl}
  21052. option @code{PR_SET_TAGGED_ADDR_CTRL}. For further information, see the
  21053. documentation in the Linux kernel.
  21054. @node i386
  21055. @subsection x86 Architecture-specific Issues
  21056. @table @code
  21057. @item set struct-convention @var{mode}
  21058. @kindex set struct-convention
  21059. @cindex struct return convention
  21060. @cindex struct/union returned in registers
  21061. Set the convention used by the inferior to return @code{struct}s and
  21062. @code{union}s from functions to @var{mode}. Possible values of
  21063. @var{mode} are @code{"pcc"}, @code{"reg"}, and @code{"default"} (the
  21064. default). @code{"default"} or @code{"pcc"} means that @code{struct}s
  21065. are returned on the stack, while @code{"reg"} means that a
  21066. @code{struct} or a @code{union} whose size is 1, 2, 4, or 8 bytes will
  21067. be returned in a register.
  21068. @item show struct-convention
  21069. @kindex show struct-convention
  21070. Show the current setting of the convention to return @code{struct}s
  21071. from functions.
  21072. @end table
  21073. @subsubsection Intel @dfn{Memory Protection Extensions} (MPX).
  21074. @cindex Intel Memory Protection Extensions (MPX).
  21075. Memory Protection Extension (MPX) adds the bound registers @samp{BND0}
  21076. @footnote{The register named with capital letters represent the architecture
  21077. registers.} through @samp{BND3}. Bound registers store a pair of 64-bit values
  21078. which are the lower bound and upper bound. Bounds are effective addresses or
  21079. memory locations. The upper bounds are architecturally represented in 1's
  21080. complement form. A bound having lower bound = 0, and upper bound = 0
  21081. (1's complement of all bits set) will allow access to the entire address space.
  21082. @samp{BND0} through @samp{BND3} are represented in @value{GDBN} as @samp{bnd0raw}
  21083. through @samp{bnd3raw}. Pseudo registers @samp{bnd0} through @samp{bnd3}
  21084. display the upper bound performing the complement of one operation on the
  21085. upper bound value, i.e.@ when upper bound in @samp{bnd0raw} is 0 in the
  21086. @value{GDBN} @samp{bnd0} it will be @code{0xfff@dots{}}. In this sense it
  21087. can also be noted that the upper bounds are inclusive.
  21088. As an example, assume that the register BND0 holds bounds for a pointer having
  21089. access allowed for the range between 0x32 and 0x71. The values present on
  21090. bnd0raw and bnd registers are presented as follows:
  21091. @smallexample
  21092. bnd0raw = @{0x32, 0xffffffff8e@}
  21093. bnd0 = @{lbound = 0x32, ubound = 0x71@} : size 64
  21094. @end smallexample
  21095. This way the raw value can be accessed via bnd0raw@dots{}bnd3raw. Any
  21096. change on bnd0@dots{}bnd3 or bnd0raw@dots{}bnd3raw is reflect on its
  21097. counterpart. When the bnd0@dots{}bnd3 registers are displayed via
  21098. Python, the display includes the memory size, in bits, accessible to
  21099. the pointer.
  21100. Bounds can also be stored in bounds tables, which are stored in
  21101. application memory. These tables store bounds for pointers by specifying
  21102. the bounds pointer's value along with its bounds. Evaluating and changing
  21103. bounds located in bound tables is therefore interesting while investigating
  21104. bugs on MPX context. @value{GDBN} provides commands for this purpose:
  21105. @table @code
  21106. @item show mpx bound @var{pointer}
  21107. @kindex show mpx bound
  21108. Display bounds of the given @var{pointer}.
  21109. @item set mpx bound @var{pointer}, @var{lbound}, @var{ubound}
  21110. @kindex set mpx bound
  21111. Set the bounds of a pointer in the bound table.
  21112. This command takes three parameters: @var{pointer} is the pointers
  21113. whose bounds are to be changed, @var{lbound} and @var{ubound} are new values
  21114. for lower and upper bounds respectively.
  21115. @end table
  21116. When you call an inferior function on an Intel MPX enabled program,
  21117. GDB sets the inferior's bound registers to the init (disabled) state
  21118. before calling the function. As a consequence, bounds checks for the
  21119. pointer arguments passed to the function will always pass.
  21120. This is necessary because when you call an inferior function, the
  21121. program is usually in the middle of the execution of other function.
  21122. Since at that point bound registers are in an arbitrary state, not
  21123. clearing them would lead to random bound violations in the called
  21124. function.
  21125. You can still examine the influence of the bound registers on the
  21126. execution of the called function by stopping the execution of the
  21127. called function at its prologue, setting bound registers, and
  21128. continuing the execution. For example:
  21129. @smallexample
  21130. $ break *upper
  21131. Breakpoint 2 at 0x4009de: file i386-mpx-call.c, line 47.
  21132. $ print upper (a, b, c, d, 1)
  21133. Breakpoint 2, upper (a=0x0, b=0x6e0000005b, c=0x0, d=0x0, len=48)....
  21134. $ print $bnd0
  21135. @{lbound = 0x0, ubound = ffffffff@} : size -1
  21136. @end smallexample
  21137. At this last step the value of bnd0 can be changed for investigation of bound
  21138. violations caused along the execution of the call. In order to know how to
  21139. set the bound registers or bound table for the call consult the ABI.
  21140. @node Alpha
  21141. @subsection Alpha
  21142. See the following section.
  21143. @node MIPS
  21144. @subsection @acronym{MIPS}
  21145. @cindex stack on Alpha
  21146. @cindex stack on @acronym{MIPS}
  21147. @cindex Alpha stack
  21148. @cindex @acronym{MIPS} stack
  21149. Alpha- and @acronym{MIPS}-based computers use an unusual stack frame, which
  21150. sometimes requires @value{GDBN} to search backward in the object code to
  21151. find the beginning of a function.
  21152. @cindex response time, @acronym{MIPS} debugging
  21153. To improve response time (especially for embedded applications, where
  21154. @value{GDBN} may be restricted to a slow serial line for this search)
  21155. you may want to limit the size of this search, using one of these
  21156. commands:
  21157. @table @code
  21158. @cindex @code{heuristic-fence-post} (Alpha, @acronym{MIPS})
  21159. @item set heuristic-fence-post @var{limit}
  21160. Restrict @value{GDBN} to examining at most @var{limit} bytes in its
  21161. search for the beginning of a function. A value of @var{0} (the
  21162. default) means there is no limit. However, except for @var{0}, the
  21163. larger the limit the more bytes @code{heuristic-fence-post} must search
  21164. and therefore the longer it takes to run. You should only need to use
  21165. this command when debugging a stripped executable.
  21166. @item show heuristic-fence-post
  21167. Display the current limit.
  21168. @end table
  21169. @noindent
  21170. These commands are available @emph{only} when @value{GDBN} is configured
  21171. for debugging programs on Alpha or @acronym{MIPS} processors.
  21172. Several @acronym{MIPS}-specific commands are available when debugging @acronym{MIPS}
  21173. programs:
  21174. @table @code
  21175. @item set mips abi @var{arg}
  21176. @kindex set mips abi
  21177. @cindex set ABI for @acronym{MIPS}
  21178. Tell @value{GDBN} which @acronym{MIPS} ABI is used by the inferior. Possible
  21179. values of @var{arg} are:
  21180. @table @samp
  21181. @item auto
  21182. The default ABI associated with the current binary (this is the
  21183. default).
  21184. @item o32
  21185. @item o64
  21186. @item n32
  21187. @item n64
  21188. @item eabi32
  21189. @item eabi64
  21190. @end table
  21191. @item show mips abi
  21192. @kindex show mips abi
  21193. Show the @acronym{MIPS} ABI used by @value{GDBN} to debug the inferior.
  21194. @item set mips compression @var{arg}
  21195. @kindex set mips compression
  21196. @cindex code compression, @acronym{MIPS}
  21197. Tell @value{GDBN} which @acronym{MIPS} compressed
  21198. @acronym{ISA, Instruction Set Architecture} encoding is used by the
  21199. inferior. @value{GDBN} uses this for code disassembly and other
  21200. internal interpretation purposes. This setting is only referred to
  21201. when no executable has been associated with the debugging session or
  21202. the executable does not provide information about the encoding it uses.
  21203. Otherwise this setting is automatically updated from information
  21204. provided by the executable.
  21205. Possible values of @var{arg} are @samp{mips16} and @samp{micromips}.
  21206. The default compressed @acronym{ISA} encoding is @samp{mips16}, as
  21207. executables containing @acronym{MIPS16} code frequently are not
  21208. identified as such.
  21209. This setting is ``sticky''; that is, it retains its value across
  21210. debugging sessions until reset either explicitly with this command or
  21211. implicitly from an executable.
  21212. The compiler and/or assembler typically add symbol table annotations to
  21213. identify functions compiled for the @acronym{MIPS16} or
  21214. @acronym{microMIPS} @acronym{ISA}s. If these function-scope annotations
  21215. are present, @value{GDBN} uses them in preference to the global
  21216. compressed @acronym{ISA} encoding setting.
  21217. @item show mips compression
  21218. @kindex show mips compression
  21219. Show the @acronym{MIPS} compressed @acronym{ISA} encoding used by
  21220. @value{GDBN} to debug the inferior.
  21221. @item set mipsfpu
  21222. @itemx show mipsfpu
  21223. @xref{MIPS Embedded, set mipsfpu}.
  21224. @item set mips mask-address @var{arg}
  21225. @kindex set mips mask-address
  21226. @cindex @acronym{MIPS} addresses, masking
  21227. This command determines whether the most-significant 32 bits of 64-bit
  21228. @acronym{MIPS} addresses are masked off. The argument @var{arg} can be
  21229. @samp{on}, @samp{off}, or @samp{auto}. The latter is the default
  21230. setting, which lets @value{GDBN} determine the correct value.
  21231. @item show mips mask-address
  21232. @kindex show mips mask-address
  21233. Show whether the upper 32 bits of @acronym{MIPS} addresses are masked off or
  21234. not.
  21235. @item set remote-mips64-transfers-32bit-regs
  21236. @kindex set remote-mips64-transfers-32bit-regs
  21237. This command controls compatibility with 64-bit @acronym{MIPS} targets that
  21238. transfer data in 32-bit quantities. If you have an old @acronym{MIPS} 64 target
  21239. that transfers 32 bits for some registers, like @sc{sr} and @sc{fsr},
  21240. and 64 bits for other registers, set this option to @samp{on}.
  21241. @item show remote-mips64-transfers-32bit-regs
  21242. @kindex show remote-mips64-transfers-32bit-regs
  21243. Show the current setting of compatibility with older @acronym{MIPS} 64 targets.
  21244. @item set debug mips
  21245. @kindex set debug mips
  21246. This command turns on and off debugging messages for the @acronym{MIPS}-specific
  21247. target code in @value{GDBN}.
  21248. @item show debug mips
  21249. @kindex show debug mips
  21250. Show the current setting of @acronym{MIPS} debugging messages.
  21251. @end table
  21252. @node HPPA
  21253. @subsection HPPA
  21254. @cindex HPPA support
  21255. When @value{GDBN} is debugging the HP PA architecture, it provides the
  21256. following special commands:
  21257. @table @code
  21258. @item set debug hppa
  21259. @kindex set debug hppa
  21260. This command determines whether HPPA architecture-specific debugging
  21261. messages are to be displayed.
  21262. @item show debug hppa
  21263. Show whether HPPA debugging messages are displayed.
  21264. @item maint print unwind @var{address}
  21265. @kindex maint print unwind@r{, HPPA}
  21266. This command displays the contents of the unwind table entry at the
  21267. given @var{address}.
  21268. @end table
  21269. @node PowerPC
  21270. @subsection PowerPC
  21271. @cindex PowerPC architecture
  21272. When @value{GDBN} is debugging the PowerPC architecture, it provides a set of
  21273. pseudo-registers to enable inspection of 128-bit wide Decimal Floating Point
  21274. numbers stored in the floating point registers. These values must be stored
  21275. in two consecutive registers, always starting at an even register like
  21276. @code{f0} or @code{f2}.
  21277. The pseudo-registers go from @code{$dl0} through @code{$dl15}, and are formed
  21278. by joining the even/odd register pairs @code{f0} and @code{f1} for @code{$dl0},
  21279. @code{f2} and @code{f3} for @code{$dl1} and so on.
  21280. For POWER7 processors, @value{GDBN} provides a set of pseudo-registers, the 64-bit
  21281. wide Extended Floating Point Registers (@samp{f32} through @samp{f63}).
  21282. @node Nios II
  21283. @subsection Nios II
  21284. @cindex Nios II architecture
  21285. When @value{GDBN} is debugging the Nios II architecture,
  21286. it provides the following special commands:
  21287. @table @code
  21288. @item set debug nios2
  21289. @kindex set debug nios2
  21290. This command turns on and off debugging messages for the Nios II
  21291. target code in @value{GDBN}.
  21292. @item show debug nios2
  21293. @kindex show debug nios2
  21294. Show the current setting of Nios II debugging messages.
  21295. @end table
  21296. @node Sparc64
  21297. @subsection Sparc64
  21298. @cindex Sparc64 support
  21299. @cindex Application Data Integrity
  21300. @subsubsection ADI Support
  21301. The M7 processor supports an Application Data Integrity (ADI) feature that
  21302. detects invalid data accesses. When software allocates memory and enables
  21303. ADI on the allocated memory, it chooses a 4-bit version number, sets the
  21304. version in the upper 4 bits of the 64-bit pointer to that data, and stores
  21305. the 4-bit version in every cacheline of that data. Hardware saves the latter
  21306. in spare bits in the cache and memory hierarchy. On each load and store,
  21307. the processor compares the upper 4 VA (virtual address) bits to the
  21308. cacheline's version. If there is a mismatch, the processor generates a
  21309. version mismatch trap which can be either precise or disrupting. The trap
  21310. is an error condition which the kernel delivers to the process as a SIGSEGV
  21311. signal.
  21312. Note that only 64-bit applications can use ADI and need to be built with
  21313. ADI-enabled.
  21314. Values of the ADI version tags, which are in granularity of a
  21315. cacheline (64 bytes), can be viewed or modified.
  21316. @table @code
  21317. @kindex adi examine
  21318. @item adi (examine | x) [ / @var{n} ] @var{addr}
  21319. The @code{adi examine} command displays the value of one ADI version tag per
  21320. cacheline.
  21321. @var{n} is a decimal integer specifying the number in bytes; the default
  21322. is 1. It specifies how much ADI version information, at the ratio of 1:ADI
  21323. block size, to display.
  21324. @var{addr} is the address in user address space where you want @value{GDBN}
  21325. to begin displaying the ADI version tags.
  21326. Below is an example of displaying ADI versions of variable "shmaddr".
  21327. @smallexample
  21328. (@value{GDBP}) adi x/100 shmaddr
  21329. 0xfff800010002c000: 0 0
  21330. @end smallexample
  21331. @kindex adi assign
  21332. @item adi (assign | a) [ / @var{n} ] @var{addr} = @var{tag}
  21333. The @code{adi assign} command is used to assign new ADI version tag
  21334. to an address.
  21335. @var{n} is a decimal integer specifying the number in bytes;
  21336. the default is 1. It specifies how much ADI version information, at the
  21337. ratio of 1:ADI block size, to modify.
  21338. @var{addr} is the address in user address space where you want @value{GDBN}
  21339. to begin modifying the ADI version tags.
  21340. @var{tag} is the new ADI version tag.
  21341. For example, do the following to modify then verify ADI versions of
  21342. variable "shmaddr":
  21343. @smallexample
  21344. (@value{GDBP}) adi a/100 shmaddr = 7
  21345. (@value{GDBP}) adi x/100 shmaddr
  21346. 0xfff800010002c000: 7 7
  21347. @end smallexample
  21348. @end table
  21349. @node S12Z
  21350. @subsection S12Z
  21351. @cindex S12Z support
  21352. When @value{GDBN} is debugging the S12Z architecture,
  21353. it provides the following special command:
  21354. @table @code
  21355. @item maint info bdccsr
  21356. @kindex maint info bdccsr@r{, S12Z}
  21357. This command displays the current value of the microprocessor's
  21358. BDCCSR register.
  21359. @end table
  21360. @node Controlling GDB
  21361. @chapter Controlling @value{GDBN}
  21362. You can alter the way @value{GDBN} interacts with you by using the
  21363. @code{set} command. For commands controlling how @value{GDBN} displays
  21364. data, see @ref{Print Settings, ,Print Settings}. Other settings are
  21365. described here.
  21366. @menu
  21367. * Prompt:: Prompt
  21368. * Editing:: Command editing
  21369. * Command History:: Command history
  21370. * Screen Size:: Screen size
  21371. * Output Styling:: Output styling
  21372. * Numbers:: Numbers
  21373. * ABI:: Configuring the current ABI
  21374. * Auto-loading:: Automatically loading associated files
  21375. * Messages/Warnings:: Optional warnings and messages
  21376. * Debugging Output:: Optional messages about internal happenings
  21377. * Other Misc Settings:: Other Miscellaneous Settings
  21378. @end menu
  21379. @node Prompt
  21380. @section Prompt
  21381. @cindex prompt
  21382. @value{GDBN} indicates its readiness to read a command by printing a string
  21383. called the @dfn{prompt}. This string is normally @samp{(@value{GDBP})}. You
  21384. can change the prompt string with the @code{set prompt} command. For
  21385. instance, when debugging @value{GDBN} with @value{GDBN}, it is useful to change
  21386. the prompt in one of the @value{GDBN} sessions so that you can always tell
  21387. which one you are talking to.
  21388. @emph{Note:} @code{set prompt} does not add a space for you after the
  21389. prompt you set. This allows you to set a prompt which ends in a space
  21390. or a prompt that does not.
  21391. @table @code
  21392. @kindex set prompt
  21393. @item set prompt @var{newprompt}
  21394. Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth.
  21395. @kindex show prompt
  21396. @item show prompt
  21397. Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}}
  21398. @end table
  21399. Versions of @value{GDBN} that ship with Python scripting enabled have
  21400. prompt extensions. The commands for interacting with these extensions
  21401. are:
  21402. @table @code
  21403. @kindex set extended-prompt
  21404. @item set extended-prompt @var{prompt}
  21405. Set an extended prompt that allows for substitutions.
  21406. @xref{gdb.prompt}, for a list of escape sequences that can be used for
  21407. substitution. Any escape sequences specified as part of the prompt
  21408. string are replaced with the corresponding strings each time the prompt
  21409. is displayed.
  21410. For example:
  21411. @smallexample
  21412. set extended-prompt Current working directory: \w (gdb)
  21413. @end smallexample
  21414. Note that when an extended-prompt is set, it takes control of the
  21415. @var{prompt_hook} hook. @xref{prompt_hook}, for further information.
  21416. @kindex show extended-prompt
  21417. @item show extended-prompt
  21418. Prints the extended prompt. Any escape sequences specified as part of
  21419. the prompt string with @code{set extended-prompt}, are replaced with the
  21420. corresponding strings each time the prompt is displayed.
  21421. @end table
  21422. @node Editing
  21423. @section Command Editing
  21424. @cindex readline
  21425. @cindex command line editing
  21426. @value{GDBN} reads its input commands via the @dfn{Readline} interface. This
  21427. @sc{gnu} library provides consistent behavior for programs which provide a
  21428. command line interface to the user. Advantages are @sc{gnu} Emacs-style
  21429. or @dfn{vi}-style inline editing of commands, @code{csh}-like history
  21430. substitution, and a storage and recall of command history across
  21431. debugging sessions.
  21432. You may control the behavior of command line editing in @value{GDBN} with the
  21433. command @code{set}.
  21434. @table @code
  21435. @kindex set editing
  21436. @cindex editing
  21437. @item set editing
  21438. @itemx set editing on
  21439. Enable command line editing (enabled by default).
  21440. @item set editing off
  21441. Disable command line editing.
  21442. @kindex show editing
  21443. @item show editing
  21444. Show whether command line editing is enabled.
  21445. @end table
  21446. @ifset SYSTEM_READLINE
  21447. @xref{Command Line Editing, , , rluserman, GNU Readline Library},
  21448. @end ifset
  21449. @ifclear SYSTEM_READLINE
  21450. @xref{Command Line Editing},
  21451. @end ifclear
  21452. for more details about the Readline
  21453. interface. Users unfamiliar with @sc{gnu} Emacs or @code{vi} are
  21454. encouraged to read that chapter.
  21455. @cindex Readline application name
  21456. @value{GDBN} sets the Readline application name to @samp{gdb}. This
  21457. is useful for conditions in @file{.inputrc}.
  21458. @cindex operate-and-get-next
  21459. @value{GDBN} defines a bindable Readline command,
  21460. @code{operate-and-get-next}. This is bound to @kbd{C-o} by default.
  21461. This command accepts the current line for execution and fetches the
  21462. next line relative to the current line from the history for editing.
  21463. Any argument is ignored.
  21464. @node Command History
  21465. @section Command History
  21466. @cindex command history
  21467. @value{GDBN} can keep track of the commands you type during your
  21468. debugging sessions, so that you can be certain of precisely what
  21469. happened. Use these commands to manage the @value{GDBN} command
  21470. history facility.
  21471. @value{GDBN} uses the @sc{gnu} History library, a part of the Readline
  21472. package, to provide the history facility.
  21473. @ifset SYSTEM_READLINE
  21474. @xref{Using History Interactively, , , history, GNU History Library},
  21475. @end ifset
  21476. @ifclear SYSTEM_READLINE
  21477. @xref{Using History Interactively},
  21478. @end ifclear
  21479. for the detailed description of the History library.
  21480. To issue a command to @value{GDBN} without affecting certain aspects of
  21481. the state which is seen by users, prefix it with @samp{server }
  21482. (@pxref{Server Prefix}). This
  21483. means that this command will not affect the command history, nor will it
  21484. affect @value{GDBN}'s notion of which command to repeat if @key{RET} is
  21485. pressed on a line by itself.
  21486. @cindex @code{server}, command prefix
  21487. The server prefix does not affect the recording of values into the value
  21488. history; to print a value without recording it into the value history,
  21489. use the @code{output} command instead of the @code{print} command.
  21490. Here is the description of @value{GDBN} commands related to command
  21491. history.
  21492. @table @code
  21493. @cindex history substitution
  21494. @cindex history file
  21495. @kindex set history filename
  21496. @cindex @env{GDBHISTFILE}, environment variable
  21497. @item set history filename @r{[}@var{fname}@r{]}
  21498. Set the name of the @value{GDBN} command history file to @var{fname}.
  21499. This is the file where @value{GDBN} reads an initial command history
  21500. list, and where it writes the command history from this session when it
  21501. exits. You can access this list through history expansion or through
  21502. the history command editing characters listed below. This file defaults
  21503. to the value of the environment variable @env{GDBHISTFILE}, or to
  21504. @file{./.gdb_history} (@file{./_gdb_history} on MS-DOS) if this variable
  21505. is not set.
  21506. The @env{GDBHISTFILE} environment variable is read after processing
  21507. any @value{GDBN} initialization files (@pxref{Startup}) and after
  21508. processing any commands passed using command line options (for
  21509. example, @code{-ex}).
  21510. If the @var{fname} argument is not given, or if the @env{GDBHISTFILE}
  21511. is the empty string then @value{GDBN} will neither try to load an
  21512. existing history file, nor will it try to save the history on exit.
  21513. @cindex save command history
  21514. @kindex set history save
  21515. @item set history save
  21516. @itemx set history save on
  21517. Record command history in a file, whose name may be specified with the
  21518. @code{set history filename} command. By default, this option is
  21519. disabled. The command history will be recorded when @value{GDBN}
  21520. exits. If @code{set history filename} is set to the empty string then
  21521. history saving is disabled, even when @code{set history save} is
  21522. @code{on}.
  21523. @item set history save off
  21524. Don't record the command history into the file specified by @code{set
  21525. history filename} when @value{GDBN} exits.
  21526. @cindex history size
  21527. @kindex set history size
  21528. @cindex @env{GDBHISTSIZE}, environment variable
  21529. @item set history size @var{size}
  21530. @itemx set history size unlimited
  21531. Set the number of commands which @value{GDBN} keeps in its history list.
  21532. This defaults to the value of the environment variable @env{GDBHISTSIZE}, or
  21533. to 256 if this variable is not set. Non-numeric values of @env{GDBHISTSIZE}
  21534. are ignored. If @var{size} is @code{unlimited} or if @env{GDBHISTSIZE} is
  21535. either a negative number or the empty string, then the number of commands
  21536. @value{GDBN} keeps in the history list is unlimited.
  21537. The @env{GDBHISTSIZE} environment variable is read after processing
  21538. any @value{GDBN} initialization files (@pxref{Startup}) and after
  21539. processing any commands passed using command line options (for
  21540. example, @code{-ex}).
  21541. @cindex remove duplicate history
  21542. @kindex set history remove-duplicates
  21543. @item set history remove-duplicates @var{count}
  21544. @itemx set history remove-duplicates unlimited
  21545. Control the removal of duplicate history entries in the command history list.
  21546. If @var{count} is non-zero, @value{GDBN} will look back at the last @var{count}
  21547. history entries and remove the first entry that is a duplicate of the current
  21548. entry being added to the command history list. If @var{count} is
  21549. @code{unlimited} then this lookbehind is unbounded. If @var{count} is 0, then
  21550. removal of duplicate history entries is disabled.
  21551. Only history entries added during the current session are considered for
  21552. removal. This option is set to 0 by default.
  21553. @end table
  21554. History expansion assigns special meaning to the character @kbd{!}.
  21555. @ifset SYSTEM_READLINE
  21556. @xref{Event Designators, , , history, GNU History Library},
  21557. @end ifset
  21558. @ifclear SYSTEM_READLINE
  21559. @xref{Event Designators},
  21560. @end ifclear
  21561. for more details.
  21562. @cindex history expansion, turn on/off
  21563. Since @kbd{!} is also the logical not operator in C, history expansion
  21564. is off by default. If you decide to enable history expansion with the
  21565. @code{set history expansion on} command, you may sometimes need to
  21566. follow @kbd{!} (when it is used as logical not, in an expression) with
  21567. a space or a tab to prevent it from being expanded. The readline
  21568. history facilities do not attempt substitution on the strings
  21569. @kbd{!=} and @kbd{!(}, even when history expansion is enabled.
  21570. The commands to control history expansion are:
  21571. @table @code
  21572. @item set history expansion on
  21573. @itemx set history expansion
  21574. @kindex set history expansion
  21575. Enable history expansion. History expansion is off by default.
  21576. @item set history expansion off
  21577. Disable history expansion.
  21578. @c @group
  21579. @kindex show history
  21580. @item show history
  21581. @itemx show history filename
  21582. @itemx show history save
  21583. @itemx show history size
  21584. @itemx show history expansion
  21585. These commands display the state of the @value{GDBN} history parameters.
  21586. @code{show history} by itself displays all four states.
  21587. @c @end group
  21588. @end table
  21589. @table @code
  21590. @kindex show commands
  21591. @cindex show last commands
  21592. @cindex display command history
  21593. @item show commands
  21594. Display the last ten commands in the command history.
  21595. @item show commands @var{n}
  21596. Print ten commands centered on command number @var{n}.
  21597. @item show commands +
  21598. Print ten commands just after the commands last printed.
  21599. @end table
  21600. @node Screen Size
  21601. @section Screen Size
  21602. @cindex size of screen
  21603. @cindex screen size
  21604. @cindex pagination
  21605. @cindex page size
  21606. @cindex pauses in output
  21607. Certain commands to @value{GDBN} may produce large amounts of
  21608. information output to the screen. To help you read all of it,
  21609. @value{GDBN} pauses and asks you for input at the end of each page of
  21610. output. Type @key{RET} when you want to see one more page of output,
  21611. @kbd{q} to discard the remaining output, or @kbd{c} to continue
  21612. without paging for the rest of the current command. Also, the screen
  21613. width setting determines when to wrap lines of output. Depending on
  21614. what is being printed, @value{GDBN} tries to break the line at a
  21615. readable place, rather than simply letting it overflow onto the
  21616. following line.
  21617. Normally @value{GDBN} knows the size of the screen from the terminal
  21618. driver software. For example, on Unix @value{GDBN} uses the termcap data base
  21619. together with the value of the @env{TERM} environment variable and the
  21620. @code{stty rows} and @code{stty cols} settings. If this is not correct,
  21621. you can override it with the @code{set height} and @code{set
  21622. width} commands:
  21623. @table @code
  21624. @kindex set height
  21625. @kindex set width
  21626. @kindex show width
  21627. @kindex show height
  21628. @item set height @var{lpp}
  21629. @itemx set height unlimited
  21630. @itemx show height
  21631. @itemx set width @var{cpl}
  21632. @itemx set width unlimited
  21633. @itemx show width
  21634. These @code{set} commands specify a screen height of @var{lpp} lines and
  21635. a screen width of @var{cpl} characters. The associated @code{show}
  21636. commands display the current settings.
  21637. If you specify a height of either @code{unlimited} or zero lines,
  21638. @value{GDBN} does not pause during output no matter how long the
  21639. output is. This is useful if output is to a file or to an editor
  21640. buffer.
  21641. Likewise, you can specify @samp{set width unlimited} or @samp{set
  21642. width 0} to prevent @value{GDBN} from wrapping its output.
  21643. @item set pagination on
  21644. @itemx set pagination off
  21645. @kindex set pagination
  21646. Turn the output pagination on or off; the default is on. Turning
  21647. pagination off is the alternative to @code{set height unlimited}. Note that
  21648. running @value{GDBN} with the @option{--batch} option (@pxref{Mode
  21649. Options, -batch}) also automatically disables pagination.
  21650. @item show pagination
  21651. @kindex show pagination
  21652. Show the current pagination mode.
  21653. @end table
  21654. @node Output Styling
  21655. @section Output Styling
  21656. @cindex styling
  21657. @cindex colors
  21658. @kindex set style
  21659. @kindex show style
  21660. @value{GDBN} can style its output on a capable terminal. This is
  21661. enabled by default on most systems, but disabled by default when in
  21662. batch mode (@pxref{Mode Options}). Various style settings are available;
  21663. and styles can also be disabled entirely.
  21664. @table @code
  21665. @item set style enabled @samp{on|off}
  21666. Enable or disable all styling. The default is host-dependent, with
  21667. most hosts defaulting to @samp{on}.
  21668. @item show style enabled
  21669. Show the current state of styling.
  21670. @item set style sources @samp{on|off}
  21671. Enable or disable source code styling. This affects whether source
  21672. code, such as the output of the @code{list} command, is styled. The
  21673. default is @samp{on}. Note that source styling only works if styling
  21674. in general is enabled, and if a source highlighting library is
  21675. available to @value{GDBN}.
  21676. There are two ways that highlighting can be done. First, if
  21677. @value{GDBN} was linked with the GNU Source Highlight library, then it
  21678. is used. Otherwise, if @value{GDBN} was configured with Python
  21679. scripting support, and if the Python Pygments package is available,
  21680. then it will be used.
  21681. @item show style sources
  21682. Show the current state of source code styling.
  21683. @item set style disassembler enabled @samp{on|off}
  21684. Enable or disable disassembler styling. This affects whether
  21685. disassembler output, such as the output of the @code{disassemble}
  21686. command, is styled. Disassembler styling only works if styling in
  21687. general is enabled (with @code{set style enabled on}), and if a source
  21688. highlighting library is available to @value{GDBN}.
  21689. To highlight disassembler output, @value{GDBN} must be compiled with
  21690. Python support, and the Python Pygments package must be available. If
  21691. these requirements are not met then @value{GDBN} will not highlight
  21692. disassembler output, even when this option is @samp{on}.
  21693. @item show style disassembler enabled
  21694. Show the current state of disassembler styling.
  21695. @end table
  21696. Subcommands of @code{set style} control specific forms of styling.
  21697. These subcommands all follow the same pattern: each style-able object
  21698. can be styled with a foreground color, a background color, and an
  21699. intensity.
  21700. For example, the style of file names can be controlled using the
  21701. @code{set style filename} group of commands:
  21702. @table @code
  21703. @item set style filename background @var{color}
  21704. Set the background to @var{color}. Valid colors are @samp{none}
  21705. (meaning the terminal's default color), @samp{black}, @samp{red},
  21706. @samp{green}, @samp{yellow}, @samp{blue}, @samp{magenta}, @samp{cyan},
  21707. and@samp{white}.
  21708. @item set style filename foreground @var{color}
  21709. Set the foreground to @var{color}. Valid colors are @samp{none}
  21710. (meaning the terminal's default color), @samp{black}, @samp{red},
  21711. @samp{green}, @samp{yellow}, @samp{blue}, @samp{magenta}, @samp{cyan},
  21712. and@samp{white}.
  21713. @item set style filename intensity @var{value}
  21714. Set the intensity to @var{value}. Valid intensities are @samp{normal}
  21715. (the default), @samp{bold}, and @samp{dim}.
  21716. @end table
  21717. The @code{show style} command and its subcommands are styling
  21718. a style name in their output using its own style.
  21719. So, use @command{show style} to see the complete list of styles,
  21720. their characteristics and the visual aspect of each style.
  21721. The style-able objects are:
  21722. @table @code
  21723. @item filename
  21724. Control the styling of file names and URLs. By default, this style's
  21725. foreground color is green.
  21726. @item function
  21727. Control the styling of function names. These are managed with the
  21728. @code{set style function} family of commands. By default, this
  21729. style's foreground color is yellow.
  21730. @item variable
  21731. Control the styling of variable names. These are managed with the
  21732. @code{set style variable} family of commands. By default, this style's
  21733. foreground color is cyan.
  21734. @item address
  21735. Control the styling of addresses. These are managed with the
  21736. @code{set style address} family of commands. By default, this style's
  21737. foreground color is blue.
  21738. @item version
  21739. Control the styling of @value{GDBN}'s version number text. By
  21740. default, this style's foreground color is magenta and it has bold
  21741. intensity. The version number is displayed in two places, the output
  21742. of @command{show version}, and when @value{GDBN} starts up.
  21743. In order to control how @value{GDBN} styles the version number at
  21744. startup, add the @code{set style version} family of commands to the
  21745. early initialization command file (@pxref{Initialization
  21746. Files}).
  21747. @item title
  21748. Control the styling of titles. These are managed with the
  21749. @code{set style title} family of commands. By default, this style's
  21750. intensity is bold. Commands are using the title style to improve
  21751. the readability of large output. For example, the commands
  21752. @command{apropos} and @command{help} are using the title style
  21753. for the command names.
  21754. @item highlight
  21755. Control the styling of highlightings. These are managed with the
  21756. @code{set style highlight} family of commands. By default, this style's
  21757. foreground color is red. Commands are using the highlight style to draw
  21758. the user attention to some specific parts of their output. For example,
  21759. the command @command{apropos -v REGEXP} uses the highlight style to
  21760. mark the documentation parts matching @var{regexp}.
  21761. @item tui-border
  21762. Control the styling of the TUI border. Note that, unlike other
  21763. styling options, only the color of the border can be controlled via
  21764. @code{set style}. This was done for compatibility reasons, as TUI
  21765. controls to set the border's intensity predated the addition of
  21766. general styling to @value{GDBN}. @xref{TUI Configuration}.
  21767. @item tui-active-border
  21768. Control the styling of the active TUI border; that is, the TUI window
  21769. that has the focus.
  21770. @end table
  21771. @node Numbers
  21772. @section Numbers
  21773. @cindex number representation
  21774. @cindex entering numbers
  21775. You can always enter numbers in octal, decimal, or hexadecimal in
  21776. @value{GDBN} by the usual conventions: octal numbers begin with
  21777. @samp{0}, decimal numbers end with @samp{.}, and hexadecimal numbers
  21778. begin with @samp{0x}. Numbers that neither begin with @samp{0} or
  21779. @samp{0x}, nor end with a @samp{.} are, by default, entered in base
  21780. 10; likewise, the default display for numbers---when no particular
  21781. format is specified---is base 10. You can change the default base for
  21782. both input and output with the commands described below.
  21783. @table @code
  21784. @kindex set input-radix
  21785. @item set input-radix @var{base}
  21786. Set the default base for numeric input. Supported choices
  21787. for @var{base} are decimal 8, 10, or 16. The base must itself be
  21788. specified either unambiguously or using the current input radix; for
  21789. example, any of
  21790. @smallexample
  21791. set input-radix 012
  21792. set input-radix 10.
  21793. set input-radix 0xa
  21794. @end smallexample
  21795. @noindent
  21796. sets the input base to decimal. On the other hand, @samp{set input-radix 10}
  21797. leaves the input radix unchanged, no matter what it was, since
  21798. @samp{10}, being without any leading or trailing signs of its base, is
  21799. interpreted in the current radix. Thus, if the current radix is 16,
  21800. @samp{10} is interpreted in hex, i.e.@: as 16 decimal, which doesn't
  21801. change the radix.
  21802. @kindex set output-radix
  21803. @item set output-radix @var{base}
  21804. Set the default base for numeric display. Supported choices
  21805. for @var{base} are decimal 8, 10, or 16. The base must itself be
  21806. specified either unambiguously or using the current input radix.
  21807. @kindex show input-radix
  21808. @item show input-radix
  21809. Display the current default base for numeric input.
  21810. @kindex show output-radix
  21811. @item show output-radix
  21812. Display the current default base for numeric display.
  21813. @item set radix @r{[}@var{base}@r{]}
  21814. @itemx show radix
  21815. @kindex set radix
  21816. @kindex show radix
  21817. These commands set and show the default base for both input and output
  21818. of numbers. @code{set radix} sets the radix of input and output to
  21819. the same base; without an argument, it resets the radix back to its
  21820. default value of 10.
  21821. @end table
  21822. @node ABI
  21823. @section Configuring the Current ABI
  21824. @value{GDBN} can determine the @dfn{ABI} (Application Binary Interface) of your
  21825. application automatically. However, sometimes you need to override its
  21826. conclusions. Use these commands to manage @value{GDBN}'s view of the
  21827. current ABI.
  21828. @cindex OS ABI
  21829. @kindex set osabi
  21830. @kindex show osabi
  21831. @cindex Newlib OS ABI and its influence on the longjmp handling
  21832. One @value{GDBN} configuration can debug binaries for multiple operating
  21833. system targets, either via remote debugging or native emulation.
  21834. @value{GDBN} will autodetect the @dfn{OS ABI} (Operating System ABI) in use,
  21835. but you can override its conclusion using the @code{set osabi} command.
  21836. One example where this is useful is in debugging of binaries which use
  21837. an alternate C library (e.g.@: @sc{uClibc} for @sc{gnu}/Linux) which does
  21838. not have the same identifying marks that the standard C library for your
  21839. platform provides.
  21840. When @value{GDBN} is debugging the AArch64 architecture, it provides a
  21841. ``Newlib'' OS ABI. This is useful for handling @code{setjmp} and
  21842. @code{longjmp} when debugging binaries that use the @sc{newlib} C library.
  21843. The ``Newlib'' OS ABI can be selected by @code{set osabi Newlib}.
  21844. @table @code
  21845. @item show osabi
  21846. Show the OS ABI currently in use.
  21847. @item set osabi
  21848. With no argument, show the list of registered available OS ABI's.
  21849. @item set osabi @var{abi}
  21850. Set the current OS ABI to @var{abi}.
  21851. @end table
  21852. @cindex float promotion
  21853. Generally, the way that an argument of type @code{float} is passed to a
  21854. function depends on whether the function is prototyped. For a prototyped
  21855. (i.e.@: ANSI/ISO style) function, @code{float} arguments are passed unchanged,
  21856. according to the architecture's convention for @code{float}. For unprototyped
  21857. (i.e.@: K&R style) functions, @code{float} arguments are first promoted to type
  21858. @code{double} and then passed.
  21859. Unfortunately, some forms of debug information do not reliably indicate whether
  21860. a function is prototyped. If @value{GDBN} calls a function that is not marked
  21861. as prototyped, it consults @kbd{set coerce-float-to-double}.
  21862. @table @code
  21863. @kindex set coerce-float-to-double
  21864. @item set coerce-float-to-double
  21865. @itemx set coerce-float-to-double on
  21866. Arguments of type @code{float} will be promoted to @code{double} when passed
  21867. to an unprototyped function. This is the default setting.
  21868. @item set coerce-float-to-double off
  21869. Arguments of type @code{float} will be passed directly to unprototyped
  21870. functions.
  21871. @kindex show coerce-float-to-double
  21872. @item show coerce-float-to-double
  21873. Show the current setting of promoting @code{float} to @code{double}.
  21874. @end table
  21875. @kindex set cp-abi
  21876. @kindex show cp-abi
  21877. @value{GDBN} needs to know the ABI used for your program's C@t{++}
  21878. objects. The correct C@t{++} ABI depends on which C@t{++} compiler was
  21879. used to build your application. @value{GDBN} only fully supports
  21880. programs with a single C@t{++} ABI; if your program contains code using
  21881. multiple C@t{++} ABI's or if @value{GDBN} can not identify your
  21882. program's ABI correctly, you can tell @value{GDBN} which ABI to use.
  21883. Currently supported ABI's include ``gnu-v2'', for @code{g++} versions
  21884. before 3.0, ``gnu-v3'', for @code{g++} versions 3.0 and later, and
  21885. ``hpaCC'' for the HP ANSI C@t{++} compiler. Other C@t{++} compilers may
  21886. use the ``gnu-v2'' or ``gnu-v3'' ABI's as well. The default setting is
  21887. ``auto''.
  21888. @table @code
  21889. @item show cp-abi
  21890. Show the C@t{++} ABI currently in use.
  21891. @item set cp-abi
  21892. With no argument, show the list of supported C@t{++} ABI's.
  21893. @item set cp-abi @var{abi}
  21894. @itemx set cp-abi auto
  21895. Set the current C@t{++} ABI to @var{abi}, or return to automatic detection.
  21896. @end table
  21897. @node Auto-loading
  21898. @section Automatically loading associated files
  21899. @cindex auto-loading
  21900. @value{GDBN} sometimes reads files with commands and settings automatically,
  21901. without being explicitly told so by the user. We call this feature
  21902. @dfn{auto-loading}. While auto-loading is useful for automatically adapting
  21903. @value{GDBN} to the needs of your project, it can sometimes produce unexpected
  21904. results or introduce security risks (e.g., if the file comes from untrusted
  21905. sources).
  21906. There are various kinds of files @value{GDBN} can automatically load.
  21907. In addition to these files, @value{GDBN} supports auto-loading code written
  21908. in various extension languages. @xref{Auto-loading extensions}.
  21909. Note that loading of these associated files (including the local @file{.gdbinit}
  21910. file) requires accordingly configured @code{auto-load safe-path}
  21911. (@pxref{Auto-loading safe path}).
  21912. For these reasons, @value{GDBN} includes commands and options to let you
  21913. control when to auto-load files and which files should be auto-loaded.
  21914. @table @code
  21915. @anchor{set auto-load off}
  21916. @kindex set auto-load off
  21917. @item set auto-load off
  21918. Globally disable loading of all auto-loaded files.
  21919. You may want to use this command with the @samp{-iex} option
  21920. (@pxref{Option -init-eval-command}) such as:
  21921. @smallexample
  21922. $ @kbd{gdb -iex "set auto-load off" untrusted-executable corefile}
  21923. @end smallexample
  21924. Be aware that system init file (@pxref{System-wide configuration})
  21925. and init files from your home directory (@pxref{Home Directory Init File})
  21926. still get read (as they come from generally trusted directories).
  21927. To prevent @value{GDBN} from auto-loading even those init files, use the
  21928. @option{-nx} option (@pxref{Mode Options}), in addition to
  21929. @code{set auto-load no}.
  21930. @anchor{show auto-load}
  21931. @kindex show auto-load
  21932. @item show auto-load
  21933. Show whether auto-loading of each specific @samp{auto-load} file(s) is enabled
  21934. or disabled.
  21935. @smallexample
  21936. (gdb) show auto-load
  21937. gdb-scripts: Auto-loading of canned sequences of commands scripts is on.
  21938. libthread-db: Auto-loading of inferior specific libthread_db is on.
  21939. local-gdbinit: Auto-loading of .gdbinit script from current directory
  21940. is on.
  21941. python-scripts: Auto-loading of Python scripts is on.
  21942. safe-path: List of directories from which it is safe to auto-load files
  21943. is $debugdir:$datadir/auto-load.
  21944. scripts-directory: List of directories from which to load auto-loaded scripts
  21945. is $debugdir:$datadir/auto-load.
  21946. @end smallexample
  21947. @anchor{info auto-load}
  21948. @kindex info auto-load
  21949. @item info auto-load
  21950. Print whether each specific @samp{auto-load} file(s) have been auto-loaded or
  21951. not.
  21952. @smallexample
  21953. (gdb) info auto-load
  21954. gdb-scripts:
  21955. Loaded Script
  21956. Yes /home/user/gdb/gdb-gdb.gdb
  21957. libthread-db: No auto-loaded libthread-db.
  21958. local-gdbinit: Local .gdbinit file "/home/user/gdb/.gdbinit" has been
  21959. loaded.
  21960. python-scripts:
  21961. Loaded Script
  21962. Yes /home/user/gdb/gdb-gdb.py
  21963. @end smallexample
  21964. @end table
  21965. These are @value{GDBN} control commands for the auto-loading:
  21966. @multitable @columnfractions .5 .5
  21967. @item @xref{set auto-load off}.
  21968. @tab Disable auto-loading globally.
  21969. @item @xref{show auto-load}.
  21970. @tab Show setting of all kinds of files.
  21971. @item @xref{info auto-load}.
  21972. @tab Show state of all kinds of files.
  21973. @item @xref{set auto-load gdb-scripts}.
  21974. @tab Control for @value{GDBN} command scripts.
  21975. @item @xref{show auto-load gdb-scripts}.
  21976. @tab Show setting of @value{GDBN} command scripts.
  21977. @item @xref{info auto-load gdb-scripts}.
  21978. @tab Show state of @value{GDBN} command scripts.
  21979. @item @xref{set auto-load python-scripts}.
  21980. @tab Control for @value{GDBN} Python scripts.
  21981. @item @xref{show auto-load python-scripts}.
  21982. @tab Show setting of @value{GDBN} Python scripts.
  21983. @item @xref{info auto-load python-scripts}.
  21984. @tab Show state of @value{GDBN} Python scripts.
  21985. @item @xref{set auto-load guile-scripts}.
  21986. @tab Control for @value{GDBN} Guile scripts.
  21987. @item @xref{show auto-load guile-scripts}.
  21988. @tab Show setting of @value{GDBN} Guile scripts.
  21989. @item @xref{info auto-load guile-scripts}.
  21990. @tab Show state of @value{GDBN} Guile scripts.
  21991. @item @xref{set auto-load scripts-directory}.
  21992. @tab Control for @value{GDBN} auto-loaded scripts location.
  21993. @item @xref{show auto-load scripts-directory}.
  21994. @tab Show @value{GDBN} auto-loaded scripts location.
  21995. @item @xref{add-auto-load-scripts-directory}.
  21996. @tab Add directory for auto-loaded scripts location list.
  21997. @item @xref{set auto-load local-gdbinit}.
  21998. @tab Control for init file in the current directory.
  21999. @item @xref{show auto-load local-gdbinit}.
  22000. @tab Show setting of init file in the current directory.
  22001. @item @xref{info auto-load local-gdbinit}.
  22002. @tab Show state of init file in the current directory.
  22003. @item @xref{set auto-load libthread-db}.
  22004. @tab Control for thread debugging library.
  22005. @item @xref{show auto-load libthread-db}.
  22006. @tab Show setting of thread debugging library.
  22007. @item @xref{info auto-load libthread-db}.
  22008. @tab Show state of thread debugging library.
  22009. @item @xref{set auto-load safe-path}.
  22010. @tab Control directories trusted for automatic loading.
  22011. @item @xref{show auto-load safe-path}.
  22012. @tab Show directories trusted for automatic loading.
  22013. @item @xref{add-auto-load-safe-path}.
  22014. @tab Add directory trusted for automatic loading.
  22015. @end multitable
  22016. @menu
  22017. * Init File in the Current Directory:: @samp{set/show/info auto-load local-gdbinit}
  22018. * libthread_db.so.1 file:: @samp{set/show/info auto-load libthread-db}
  22019. * Auto-loading safe path:: @samp{set/show/info auto-load safe-path}
  22020. * Auto-loading verbose mode:: @samp{set/show debug auto-load}
  22021. @end menu
  22022. @node Init File in the Current Directory
  22023. @subsection Automatically loading init file in the current directory
  22024. @cindex auto-loading init file in the current directory
  22025. By default, @value{GDBN} reads and executes the canned sequences of commands
  22026. from init file (if any) in the current working directory,
  22027. see @ref{Init File in the Current Directory during Startup}.
  22028. Note that loading of this local @file{.gdbinit} file also requires accordingly
  22029. configured @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
  22030. @table @code
  22031. @anchor{set auto-load local-gdbinit}
  22032. @kindex set auto-load local-gdbinit
  22033. @item set auto-load local-gdbinit [on|off]
  22034. Enable or disable the auto-loading of canned sequences of commands
  22035. (@pxref{Sequences}) found in init file in the current directory.
  22036. @anchor{show auto-load local-gdbinit}
  22037. @kindex show auto-load local-gdbinit
  22038. @item show auto-load local-gdbinit
  22039. Show whether auto-loading of canned sequences of commands from init file in the
  22040. current directory is enabled or disabled.
  22041. @anchor{info auto-load local-gdbinit}
  22042. @kindex info auto-load local-gdbinit
  22043. @item info auto-load local-gdbinit
  22044. Print whether canned sequences of commands from init file in the
  22045. current directory have been auto-loaded.
  22046. @end table
  22047. @node libthread_db.so.1 file
  22048. @subsection Automatically loading thread debugging library
  22049. @cindex auto-loading libthread_db.so.1
  22050. This feature is currently present only on @sc{gnu}/Linux native hosts.
  22051. @value{GDBN} reads in some cases thread debugging library from places specific
  22052. to the inferior (@pxref{set libthread-db-search-path}).
  22053. The special @samp{libthread-db-search-path} entry @samp{$sdir} is processed
  22054. without checking this @samp{set auto-load libthread-db} switch as system
  22055. libraries have to be trusted in general. In all other cases of
  22056. @samp{libthread-db-search-path} entries @value{GDBN} checks first if @samp{set
  22057. auto-load libthread-db} is enabled before trying to open such thread debugging
  22058. library.
  22059. Note that loading of this debugging library also requires accordingly configured
  22060. @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
  22061. @table @code
  22062. @anchor{set auto-load libthread-db}
  22063. @kindex set auto-load libthread-db
  22064. @item set auto-load libthread-db [on|off]
  22065. Enable or disable the auto-loading of inferior specific thread debugging library.
  22066. @anchor{show auto-load libthread-db}
  22067. @kindex show auto-load libthread-db
  22068. @item show auto-load libthread-db
  22069. Show whether auto-loading of inferior specific thread debugging library is
  22070. enabled or disabled.
  22071. @anchor{info auto-load libthread-db}
  22072. @kindex info auto-load libthread-db
  22073. @item info auto-load libthread-db
  22074. Print the list of all loaded inferior specific thread debugging libraries and
  22075. for each such library print list of inferior @var{pid}s using it.
  22076. @end table
  22077. @node Auto-loading safe path
  22078. @subsection Security restriction for auto-loading
  22079. @cindex auto-loading safe-path
  22080. As the files of inferior can come from untrusted source (such as submitted by
  22081. an application user) @value{GDBN} does not always load any files automatically.
  22082. @value{GDBN} provides the @samp{set auto-load safe-path} setting to list
  22083. directories trusted for loading files not explicitly requested by user.
  22084. Each directory can also be a shell wildcard pattern.
  22085. If the path is not set properly you will see a warning and the file will not
  22086. get loaded:
  22087. @smallexample
  22088. $ ./gdb -q ./gdb
  22089. Reading symbols from /home/user/gdb/gdb...
  22090. warning: File "/home/user/gdb/gdb-gdb.gdb" auto-loading has been
  22091. declined by your `auto-load safe-path' set
  22092. to "$debugdir:$datadir/auto-load".
  22093. warning: File "/home/user/gdb/gdb-gdb.py" auto-loading has been
  22094. declined by your `auto-load safe-path' set
  22095. to "$debugdir:$datadir/auto-load".
  22096. @end smallexample
  22097. @noindent
  22098. To instruct @value{GDBN} to go ahead and use the init files anyway,
  22099. invoke @value{GDBN} like this:
  22100. @smallexample
  22101. $ gdb -q -iex "set auto-load safe-path /home/user/gdb" ./gdb
  22102. @end smallexample
  22103. The list of trusted directories is controlled by the following commands:
  22104. @table @code
  22105. @anchor{set auto-load safe-path}
  22106. @kindex set auto-load safe-path
  22107. @item set auto-load safe-path @r{[}@var{directories}@r{]}
  22108. Set the list of directories (and their subdirectories) trusted for automatic
  22109. loading and execution of scripts. You can also enter a specific trusted file.
  22110. Each directory can also be a shell wildcard pattern; wildcards do not match
  22111. directory separator - see @code{FNM_PATHNAME} for system function @code{fnmatch}
  22112. (@pxref{Wildcard Matching, fnmatch, , libc, GNU C Library Reference Manual}).
  22113. If you omit @var{directories}, @samp{auto-load safe-path} will be reset to
  22114. its default value as specified during @value{GDBN} compilation.
  22115. The list of directories uses path separator (@samp{:} on GNU and Unix
  22116. systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly
  22117. to the @env{PATH} environment variable.
  22118. @anchor{show auto-load safe-path}
  22119. @kindex show auto-load safe-path
  22120. @item show auto-load safe-path
  22121. Show the list of directories trusted for automatic loading and execution of
  22122. scripts.
  22123. @anchor{add-auto-load-safe-path}
  22124. @kindex add-auto-load-safe-path
  22125. @item add-auto-load-safe-path
  22126. Add an entry (or list of entries) to the list of directories trusted for
  22127. automatic loading and execution of scripts. Multiple entries may be delimited
  22128. by the host platform path separator in use.
  22129. @end table
  22130. This variable defaults to what @code{--with-auto-load-dir} has been configured
  22131. to (@pxref{with-auto-load-dir}). @file{$debugdir} and @file{$datadir}
  22132. substitution applies the same as for @ref{set auto-load scripts-directory}.
  22133. The default @code{set auto-load safe-path} value can be also overriden by
  22134. @value{GDBN} configuration option @option{--with-auto-load-safe-path}.
  22135. Setting this variable to @file{/} disables this security protection,
  22136. corresponding @value{GDBN} configuration option is
  22137. @option{--without-auto-load-safe-path}.
  22138. This variable is supposed to be set to the system directories writable by the
  22139. system superuser only. Users can add their source directories in init files in
  22140. their home directories (@pxref{Home Directory Init File}). See also deprecated
  22141. init file in the current directory
  22142. (@pxref{Init File in the Current Directory during Startup}).
  22143. To force @value{GDBN} to load the files it declined to load in the previous
  22144. example, you could use one of the following ways:
  22145. @table @asis
  22146. @item @file{~/.gdbinit}: @samp{add-auto-load-safe-path ~/src/gdb}
  22147. Specify this trusted directory (or a file) as additional component of the list.
  22148. You have to specify also any existing directories displayed by
  22149. by @samp{show auto-load safe-path} (such as @samp{/usr:/bin} in this example).
  22150. @item @kbd{gdb -iex "set auto-load safe-path /usr:/bin:~/src/gdb" @dots{}}
  22151. Specify this directory as in the previous case but just for a single
  22152. @value{GDBN} session.
  22153. @item @kbd{gdb -iex "set auto-load safe-path /" @dots{}}
  22154. Disable auto-loading safety for a single @value{GDBN} session.
  22155. This assumes all the files you debug during this @value{GDBN} session will come
  22156. from trusted sources.
  22157. @item @kbd{./configure --without-auto-load-safe-path}
  22158. During compilation of @value{GDBN} you may disable any auto-loading safety.
  22159. This assumes all the files you will ever debug with this @value{GDBN} come from
  22160. trusted sources.
  22161. @end table
  22162. On the other hand you can also explicitly forbid automatic files loading which
  22163. also suppresses any such warning messages:
  22164. @table @asis
  22165. @item @kbd{gdb -iex "set auto-load no" @dots{}}
  22166. You can use @value{GDBN} command-line option for a single @value{GDBN} session.
  22167. @item @file{~/.gdbinit}: @samp{set auto-load no}
  22168. Disable auto-loading globally for the user
  22169. (@pxref{Home Directory Init File}). While it is improbable, you could also
  22170. use system init file instead (@pxref{System-wide configuration}).
  22171. @end table
  22172. This setting applies to the file names as entered by user. If no entry matches
  22173. @value{GDBN} tries as a last resort to also resolve all the file names into
  22174. their canonical form (typically resolving symbolic links) and compare the
  22175. entries again. @value{GDBN} already canonicalizes most of the filenames on its
  22176. own before starting the comparison so a canonical form of directories is
  22177. recommended to be entered.
  22178. @node Auto-loading verbose mode
  22179. @subsection Displaying files tried for auto-load
  22180. @cindex auto-loading verbose mode
  22181. For better visibility of all the file locations where you can place scripts to
  22182. be auto-loaded with inferior --- or to protect yourself against accidental
  22183. execution of untrusted scripts --- @value{GDBN} provides a feature for printing
  22184. all the files attempted to be loaded. Both existing and non-existing files may
  22185. be printed.
  22186. For example the list of directories from which it is safe to auto-load files
  22187. (@pxref{Auto-loading safe path}) applies also to canonicalized filenames which
  22188. may not be too obvious while setting it up.
  22189. @smallexample
  22190. (gdb) set debug auto-load on
  22191. (gdb) file ~/src/t/true
  22192. auto-load: Loading canned sequences of commands script "/tmp/true-gdb.gdb"
  22193. for objfile "/tmp/true".
  22194. auto-load: Updating directories of "/usr:/opt".
  22195. auto-load: Using directory "/usr".
  22196. auto-load: Using directory "/opt".
  22197. warning: File "/tmp/true-gdb.gdb" auto-loading has been declined
  22198. by your `auto-load safe-path' set to "/usr:/opt".
  22199. @end smallexample
  22200. @table @code
  22201. @anchor{set debug auto-load}
  22202. @kindex set debug auto-load
  22203. @item set debug auto-load [on|off]
  22204. Set whether to print the filenames attempted to be auto-loaded.
  22205. @anchor{show debug auto-load}
  22206. @kindex show debug auto-load
  22207. @item show debug auto-load
  22208. Show whether printing of the filenames attempted to be auto-loaded is turned
  22209. on or off.
  22210. @end table
  22211. @node Messages/Warnings
  22212. @section Optional Warnings and Messages
  22213. @cindex verbose operation
  22214. @cindex optional warnings
  22215. By default, @value{GDBN} is silent about its inner workings. If you are
  22216. running on a slow machine, you may want to use the @code{set verbose}
  22217. command. This makes @value{GDBN} tell you when it does a lengthy
  22218. internal operation, so you will not think it has crashed.
  22219. Currently, the messages controlled by @code{set verbose} are those
  22220. which announce that the symbol table for a source file is being read;
  22221. see @code{symbol-file} in @ref{Files, ,Commands to Specify Files}.
  22222. @table @code
  22223. @kindex set verbose
  22224. @item set verbose on
  22225. Enables @value{GDBN} output of certain informational messages.
  22226. @item set verbose off
  22227. Disables @value{GDBN} output of certain informational messages.
  22228. @kindex show verbose
  22229. @item show verbose
  22230. Displays whether @code{set verbose} is on or off.
  22231. @end table
  22232. By default, if @value{GDBN} encounters bugs in the symbol table of an
  22233. object file, it is silent; but if you are debugging a compiler, you may
  22234. find this information useful (@pxref{Symbol Errors, ,Errors Reading
  22235. Symbol Files}).
  22236. @table @code
  22237. @kindex set complaints
  22238. @item set complaints @var{limit}
  22239. Permits @value{GDBN} to output @var{limit} complaints about each type of
  22240. unusual symbols before becoming silent about the problem. Set
  22241. @var{limit} to zero to suppress all complaints; set it to a large number
  22242. to prevent complaints from being suppressed.
  22243. @kindex show complaints
  22244. @item show complaints
  22245. Displays how many symbol complaints @value{GDBN} is permitted to produce.
  22246. @end table
  22247. @anchor{confirmation requests}
  22248. By default, @value{GDBN} is cautious, and asks what sometimes seems to be a
  22249. lot of stupid questions to confirm certain commands. For example, if
  22250. you try to run a program which is already running:
  22251. @smallexample
  22252. (@value{GDBP}) run
  22253. The program being debugged has been started already.
  22254. Start it from the beginning? (y or n)
  22255. @end smallexample
  22256. If you are willing to unflinchingly face the consequences of your own
  22257. commands, you can disable this ``feature'':
  22258. @table @code
  22259. @kindex set confirm
  22260. @cindex flinching
  22261. @cindex confirmation
  22262. @cindex stupid questions
  22263. @item set confirm off
  22264. Disables confirmation requests. Note that running @value{GDBN} with
  22265. the @option{--batch} option (@pxref{Mode Options, -batch}) also
  22266. automatically disables confirmation requests.
  22267. @item set confirm on
  22268. Enables confirmation requests (the default).
  22269. @kindex show confirm
  22270. @item show confirm
  22271. Displays state of confirmation requests.
  22272. @end table
  22273. @cindex command tracing
  22274. If you need to debug user-defined commands or sourced files you may find it
  22275. useful to enable @dfn{command tracing}. In this mode each command will be
  22276. printed as it is executed, prefixed with one or more @samp{+} symbols, the
  22277. quantity denoting the call depth of each command.
  22278. @table @code
  22279. @kindex set trace-commands
  22280. @cindex command scripts, debugging
  22281. @item set trace-commands on
  22282. Enable command tracing.
  22283. @item set trace-commands off
  22284. Disable command tracing.
  22285. @item show trace-commands
  22286. Display the current state of command tracing.
  22287. @end table
  22288. @node Debugging Output
  22289. @section Optional Messages about Internal Happenings
  22290. @cindex optional debugging messages
  22291. @value{GDBN} has commands that enable optional debugging messages from
  22292. various @value{GDBN} subsystems; normally these commands are of
  22293. interest to @value{GDBN} maintainers, or when reporting a bug. This
  22294. section documents those commands.
  22295. @table @code
  22296. @kindex set exec-done-display
  22297. @item set exec-done-display
  22298. Turns on or off the notification of asynchronous commands'
  22299. completion. When on, @value{GDBN} will print a message when an
  22300. asynchronous command finishes its execution. The default is off.
  22301. @kindex show exec-done-display
  22302. @item show exec-done-display
  22303. Displays the current setting of asynchronous command completion
  22304. notification.
  22305. @kindex set debug
  22306. @cindex ARM AArch64
  22307. @item set debug aarch64
  22308. Turns on or off display of debugging messages related to ARM AArch64.
  22309. The default is off.
  22310. @kindex show debug
  22311. @item show debug aarch64
  22312. Displays the current state of displaying debugging messages related to
  22313. ARM AArch64.
  22314. @cindex gdbarch debugging info
  22315. @cindex architecture debugging info
  22316. @item set debug arch
  22317. Turns on or off display of gdbarch debugging info. The default is off
  22318. @item show debug arch
  22319. Displays the current state of displaying gdbarch debugging info.
  22320. @item set debug aix-solib
  22321. @cindex AIX shared library debugging
  22322. Control display of debugging messages from the AIX shared library
  22323. support module. The default is off.
  22324. @item show debug aix-solib
  22325. Show the current state of displaying AIX shared library debugging messages.
  22326. @item set debug aix-thread
  22327. @cindex AIX threads
  22328. Display debugging messages about inner workings of the AIX thread
  22329. module.
  22330. @item show debug aix-thread
  22331. Show the current state of AIX thread debugging info display.
  22332. @item set debug check-physname
  22333. @cindex physname
  22334. Check the results of the ``physname'' computation. When reading DWARF
  22335. debugging information for C@t{++}, @value{GDBN} attempts to compute
  22336. each entity's name. @value{GDBN} can do this computation in two
  22337. different ways, depending on exactly what information is present.
  22338. When enabled, this setting causes @value{GDBN} to compute the names
  22339. both ways and display any discrepancies.
  22340. @item show debug check-physname
  22341. Show the current state of ``physname'' checking.
  22342. @item set debug coff-pe-read
  22343. @cindex COFF/PE exported symbols
  22344. Control display of debugging messages related to reading of COFF/PE
  22345. exported symbols. The default is off.
  22346. @item show debug coff-pe-read
  22347. Displays the current state of displaying debugging messages related to
  22348. reading of COFF/PE exported symbols.
  22349. @item set debug dwarf-die
  22350. @cindex DWARF DIEs
  22351. Dump DWARF DIEs after they are read in.
  22352. The value is the number of nesting levels to print.
  22353. A value of zero turns off the display.
  22354. @item show debug dwarf-die
  22355. Show the current state of DWARF DIE debugging.
  22356. @item set debug dwarf-line
  22357. @cindex DWARF Line Tables
  22358. Turns on or off display of debugging messages related to reading
  22359. DWARF line tables. The default is 0 (off).
  22360. A value of 1 provides basic information.
  22361. A value greater than 1 provides more verbose information.
  22362. @item show debug dwarf-line
  22363. Show the current state of DWARF line table debugging.
  22364. @item set debug dwarf-read
  22365. @cindex DWARF Reading
  22366. Turns on or off display of debugging messages related to reading
  22367. DWARF debug info. The default is 0 (off).
  22368. A value of 1 provides basic information.
  22369. A value greater than 1 provides more verbose information.
  22370. @item show debug dwarf-read
  22371. Show the current state of DWARF reader debugging.
  22372. @item set debug displaced
  22373. @cindex displaced stepping debugging info
  22374. Turns on or off display of @value{GDBN} debugging info for the
  22375. displaced stepping support. The default is off.
  22376. @item show debug displaced
  22377. Displays the current state of displaying @value{GDBN} debugging info
  22378. related to displaced stepping.
  22379. @item set debug event
  22380. @cindex event debugging info
  22381. Turns on or off display of @value{GDBN} event debugging info. The
  22382. default is off.
  22383. @item show debug event
  22384. Displays the current state of displaying @value{GDBN} event debugging
  22385. info.
  22386. @item set debug event-loop
  22387. @cindex event-loop debugging
  22388. Controls output of debugging info about the event loop. The possible
  22389. values are @samp{off}, @samp{all} (shows all debugging info) and
  22390. @samp{all-except-ui} (shows all debugging info except those about
  22391. UI-related events).
  22392. @item show debug event-loop
  22393. Shows the current state of displaying debugging info about the event
  22394. loop.
  22395. @item set debug expression
  22396. @cindex expression debugging info
  22397. Turns on or off display of debugging info about @value{GDBN}
  22398. expression parsing. The default is off.
  22399. @item show debug expression
  22400. Displays the current state of displaying debugging info about
  22401. @value{GDBN} expression parsing.
  22402. @item set debug fbsd-lwp
  22403. @cindex FreeBSD LWP debug messages
  22404. Turns on or off debugging messages from the FreeBSD LWP debug support.
  22405. @item show debug fbsd-lwp
  22406. Show the current state of FreeBSD LWP debugging messages.
  22407. @item set debug fbsd-nat
  22408. @cindex FreeBSD native target debug messages
  22409. Turns on or off debugging messages from the FreeBSD native target.
  22410. @item show debug fbsd-nat
  22411. Show the current state of FreeBSD native target debugging messages.
  22412. @item set debug fortran-array-slicing
  22413. @cindex fortran array slicing debugging info
  22414. Turns on or off display of @value{GDBN} Fortran array slicing
  22415. debugging info. The default is off.
  22416. @item show debug fortran-array-slicing
  22417. Displays the current state of displaying @value{GDBN} Fortran array
  22418. slicing debugging info.
  22419. @item set debug frame
  22420. @cindex frame debugging info
  22421. Turns on or off display of @value{GDBN} frame debugging info. The
  22422. default is off.
  22423. @item show debug frame
  22424. Displays the current state of displaying @value{GDBN} frame debugging
  22425. info.
  22426. @item set debug gnu-nat
  22427. @cindex @sc{gnu}/Hurd debug messages
  22428. Turn on or off debugging messages from the @sc{gnu}/Hurd debug support.
  22429. @item show debug gnu-nat
  22430. Show the current state of @sc{gnu}/Hurd debugging messages.
  22431. @item set debug infrun
  22432. @cindex inferior debugging info
  22433. Turns on or off display of @value{GDBN} debugging info for running the inferior.
  22434. The default is off. @file{infrun.c} contains GDB's runtime state machine used
  22435. for implementing operations such as single-stepping the inferior.
  22436. @item show debug infrun
  22437. Displays the current state of @value{GDBN} inferior debugging.
  22438. @item set debug jit
  22439. @cindex just-in-time compilation, debugging messages
  22440. Turn on or off debugging messages from JIT debug support.
  22441. @item show debug jit
  22442. Displays the current state of @value{GDBN} JIT debugging.
  22443. @item set debug linux-nat @r{[}on@r{|}off@r{]}
  22444. @cindex @sc{gnu}/Linux native target debug messages
  22445. @cindex Linux native targets
  22446. Turn on or off debugging messages from the Linux native target debug support.
  22447. @item show debug linux-nat
  22448. Show the current state of Linux native target debugging messages.
  22449. @item set debug linux-namespaces
  22450. @cindex @sc{gnu}/Linux namespaces debug messages
  22451. Turn on or off debugging messages from the Linux namespaces debug support.
  22452. @item show debug linux-namespaces
  22453. Show the current state of Linux namespaces debugging messages.
  22454. @item set debug mach-o
  22455. @cindex Mach-O symbols processing
  22456. Control display of debugging messages related to Mach-O symbols
  22457. processing. The default is off.
  22458. @item show debug mach-o
  22459. Displays the current state of displaying debugging messages related to
  22460. reading of COFF/PE exported symbols.
  22461. @item set debug notification
  22462. @cindex remote async notification debugging info
  22463. Turn on or off debugging messages about remote async notification.
  22464. The default is off.
  22465. @item show debug notification
  22466. Displays the current state of remote async notification debugging messages.
  22467. @item set debug observer
  22468. @cindex observer debugging info
  22469. Turns on or off display of @value{GDBN} observer debugging. This
  22470. includes info such as the notification of observable events.
  22471. @item show debug observer
  22472. Displays the current state of observer debugging.
  22473. @item set debug overload
  22474. @cindex C@t{++} overload debugging info
  22475. Turns on or off display of @value{GDBN} C@t{++} overload debugging
  22476. info. This includes info such as ranking of functions, etc. The default
  22477. is off.
  22478. @item show debug overload
  22479. Displays the current state of displaying @value{GDBN} C@t{++} overload
  22480. debugging info.
  22481. @cindex expression parser, debugging info
  22482. @cindex debug expression parser
  22483. @item set debug parser
  22484. Turns on or off the display of expression parser debugging output.
  22485. Internally, this sets the @code{yydebug} variable in the expression
  22486. parser. @xref{Tracing, , Tracing Your Parser, bison, Bison}, for
  22487. details. The default is off.
  22488. @item show debug parser
  22489. Show the current state of expression parser debugging.
  22490. @cindex packets, reporting on stdout
  22491. @cindex serial connections, debugging
  22492. @cindex debug remote protocol
  22493. @cindex remote protocol debugging
  22494. @cindex display remote packets
  22495. @item set debug remote
  22496. Turns on or off display of reports on all packets sent back and forth across
  22497. the serial line to the remote machine. The info is printed on the
  22498. @value{GDBN} standard output stream. The default is off.
  22499. @item show debug remote
  22500. Displays the state of display of remote packets.
  22501. @item set debug remote-packet-max-chars
  22502. Sets the maximum number of characters to display for each remote packet when
  22503. @code{set debug remote} is on. This is useful to prevent @value{GDBN} from
  22504. displaying lengthy remote packets and polluting the console.
  22505. The default value is @code{512}, which means @value{GDBN} will truncate each
  22506. remote packet after 512 bytes.
  22507. Setting this option to @code{unlimited} will disable truncation and will output
  22508. the full length of the remote packets.
  22509. @item show debug remote-packet-max-chars
  22510. Displays the number of bytes to output for remote packet debugging.
  22511. @item set debug separate-debug-file
  22512. Turns on or off display of debug output about separate debug file search.
  22513. @item show debug separate-debug-file
  22514. Displays the state of separate debug file search debug output.
  22515. @item set debug serial
  22516. Turns on or off display of @value{GDBN} serial debugging info. The
  22517. default is off.
  22518. @item show debug serial
  22519. Displays the current state of displaying @value{GDBN} serial debugging
  22520. info.
  22521. @item set debug solib-frv
  22522. @cindex FR-V shared-library debugging
  22523. Turn on or off debugging messages for FR-V shared-library code.
  22524. @item show debug solib-frv
  22525. Display the current state of FR-V shared-library code debugging
  22526. messages.
  22527. @item set debug symbol-lookup
  22528. @cindex symbol lookup
  22529. Turns on or off display of debugging messages related to symbol lookup.
  22530. The default is 0 (off).
  22531. A value of 1 provides basic information.
  22532. A value greater than 1 provides more verbose information.
  22533. @item show debug symbol-lookup
  22534. Show the current state of symbol lookup debugging messages.
  22535. @item set debug symfile
  22536. @cindex symbol file functions
  22537. Turns on or off display of debugging messages related to symbol file functions.
  22538. The default is off. @xref{Files}.
  22539. @item show debug symfile
  22540. Show the current state of symbol file debugging messages.
  22541. @item set debug symtab-create
  22542. @cindex symbol table creation
  22543. Turns on or off display of debugging messages related to symbol table creation.
  22544. The default is 0 (off).
  22545. A value of 1 provides basic information.
  22546. A value greater than 1 provides more verbose information.
  22547. @item show debug symtab-create
  22548. Show the current state of symbol table creation debugging.
  22549. @item set debug target
  22550. @cindex target debugging info
  22551. Turns on or off display of @value{GDBN} target debugging info. This info
  22552. includes what is going on at the target level of GDB, as it happens. The
  22553. default is 0. Set it to 1 to track events, and to 2 to also track the
  22554. value of large memory transfers.
  22555. @item show debug target
  22556. Displays the current state of displaying @value{GDBN} target debugging
  22557. info.
  22558. @item set debug timestamp
  22559. @cindex timestamping debugging info
  22560. Turns on or off display of timestamps with @value{GDBN} debugging info.
  22561. When enabled, seconds and microseconds are displayed before each debugging
  22562. message.
  22563. @item show debug timestamp
  22564. Displays the current state of displaying timestamps with @value{GDBN}
  22565. debugging info.
  22566. @item set debug varobj
  22567. @cindex variable object debugging info
  22568. Turns on or off display of @value{GDBN} variable object debugging
  22569. info. The default is off.
  22570. @item show debug varobj
  22571. Displays the current state of displaying @value{GDBN} variable object
  22572. debugging info.
  22573. @item set debug xml
  22574. @cindex XML parser debugging
  22575. Turn on or off debugging messages for built-in XML parsers.
  22576. @item show debug xml
  22577. Displays the current state of XML debugging messages.
  22578. @end table
  22579. @node Other Misc Settings
  22580. @section Other Miscellaneous Settings
  22581. @cindex miscellaneous settings
  22582. @table @code
  22583. @kindex set interactive-mode
  22584. @item set interactive-mode
  22585. If @code{on}, forces @value{GDBN} to assume that GDB was started
  22586. in a terminal. In practice, this means that @value{GDBN} should wait
  22587. for the user to answer queries generated by commands entered at
  22588. the command prompt. If @code{off}, forces @value{GDBN} to operate
  22589. in the opposite mode, and it uses the default answers to all queries.
  22590. If @code{auto} (the default), @value{GDBN} tries to determine whether
  22591. its standard input is a terminal, and works in interactive-mode if it
  22592. is, non-interactively otherwise.
  22593. In the vast majority of cases, the debugger should be able to guess
  22594. correctly which mode should be used. But this setting can be useful
  22595. in certain specific cases, such as running a MinGW @value{GDBN}
  22596. inside a cygwin window.
  22597. @kindex show interactive-mode
  22598. @item show interactive-mode
  22599. Displays whether the debugger is operating in interactive mode or not.
  22600. @end table
  22601. @table @code
  22602. @kindex set suppress-cli-notifications
  22603. @item set suppress-cli-notifications
  22604. If @code{on}, command-line-interface (CLI) notifications that are
  22605. printed by @value{GDBN} are suppressed. If @code{off}, the
  22606. notifications are printed as usual. The default value is @code{off}.
  22607. CLI notifications occur when you change the selected context or when
  22608. the program being debugged stops, as detailed below.
  22609. @table @emph
  22610. @item User-selected context changes:
  22611. When you change the selected context (i.e.@: the current inferior,
  22612. thread and/or the frame), @value{GDBN} prints information about the
  22613. new context. For example, the default behavior is below:
  22614. @smallexample
  22615. (gdb) inferior 1
  22616. [Switching to inferior 1 [process 634] (/tmp/test)]
  22617. [Switching to thread 1 (process 634)]
  22618. #0 main () at test.c:3
  22619. 3 return 0;
  22620. (gdb)
  22621. @end smallexample
  22622. When the notifications are suppressed, the new context is not printed:
  22623. @smallexample
  22624. (gdb) set suppress-cli-notifications on
  22625. (gdb) inferior 1
  22626. (gdb)
  22627. @end smallexample
  22628. @item The program being debugged stops:
  22629. When the program you are debugging stops (e.g.@: because of hitting a
  22630. breakpoint, completing source-stepping, an interrupt, etc.),
  22631. @value{GDBN} prints information about the stop event. For example,
  22632. below is a breakpoint hit:
  22633. @smallexample
  22634. (gdb) break test.c:3
  22635. Breakpoint 2 at 0x555555555155: file test.c, line 3.
  22636. (gdb) continue
  22637. Continuing.
  22638. Breakpoint 2, main () at test.c:3
  22639. 3 return 0;
  22640. (gdb)
  22641. @end smallexample
  22642. When the notifications are suppressed, the output becomes:
  22643. @smallexample
  22644. (gdb) break test.c:3
  22645. Breakpoint 2 at 0x555555555155: file test.c, line 3.
  22646. (gdb) set suppress-cli-notifications on
  22647. (gdb) continue
  22648. Continuing.
  22649. (gdb)
  22650. @end smallexample
  22651. Suppressing CLI notifications may be useful in scripts to obtain a
  22652. reduced output from a list of commands.
  22653. @end table
  22654. @kindex show suppress-cli-notifications
  22655. @item show suppress-cli-notifications
  22656. Displays whether printing CLI notifications is suppressed or not.
  22657. @end table
  22658. @node Extending GDB
  22659. @chapter Extending @value{GDBN}
  22660. @cindex extending GDB
  22661. @value{GDBN} provides several mechanisms for extension.
  22662. @value{GDBN} also provides the ability to automatically load
  22663. extensions when it reads a file for debugging. This allows the
  22664. user to automatically customize @value{GDBN} for the program
  22665. being debugged.
  22666. To facilitate the use of extension languages, @value{GDBN} is capable
  22667. of evaluating the contents of a file. When doing so, @value{GDBN}
  22668. can recognize which extension language is being used by looking at
  22669. the filename extension. Files with an unrecognized filename extension
  22670. are always treated as a @value{GDBN} Command Files.
  22671. @xref{Command Files,, Command files}.
  22672. You can control how @value{GDBN} evaluates these files with the following
  22673. setting:
  22674. @table @code
  22675. @kindex set script-extension
  22676. @kindex show script-extension
  22677. @item set script-extension off
  22678. All scripts are always evaluated as @value{GDBN} Command Files.
  22679. @item set script-extension soft
  22680. The debugger determines the scripting language based on filename
  22681. extension. If this scripting language is supported, @value{GDBN}
  22682. evaluates the script using that language. Otherwise, it evaluates
  22683. the file as a @value{GDBN} Command File.
  22684. @item set script-extension strict
  22685. The debugger determines the scripting language based on filename
  22686. extension, and evaluates the script using that language. If the
  22687. language is not supported, then the evaluation fails.
  22688. @item show script-extension
  22689. Display the current value of the @code{script-extension} option.
  22690. @end table
  22691. @ifset SYSTEM_GDBINIT_DIR
  22692. This setting is not used for files in the system-wide gdbinit directory.
  22693. Files in that directory must have an extension matching their language,
  22694. or have a @file{.gdb} extension to be interpreted as regular @value{GDBN}
  22695. commands. @xref{Startup}.
  22696. @end ifset
  22697. @menu
  22698. * Sequences:: Canned Sequences of @value{GDBN} Commands
  22699. * Aliases:: Command Aliases
  22700. * Python:: Extending @value{GDBN} using Python
  22701. * Guile:: Extending @value{GDBN} using Guile
  22702. * Auto-loading extensions:: Automatically loading extensions
  22703. * Multiple Extension Languages:: Working with multiple extension languages
  22704. @end menu
  22705. @node Sequences
  22706. @section Canned Sequences of Commands
  22707. Aside from breakpoint commands (@pxref{Break Commands, ,Breakpoint
  22708. Command Lists}), @value{GDBN} provides two ways to store sequences of
  22709. commands for execution as a unit: user-defined commands and command
  22710. files.
  22711. @menu
  22712. * Define:: How to define your own commands
  22713. * Hooks:: Hooks for user-defined commands
  22714. * Command Files:: How to write scripts of commands to be stored in a file
  22715. * Output:: Commands for controlled output
  22716. * Auto-loading sequences:: Controlling auto-loaded command files
  22717. @end menu
  22718. @node Define
  22719. @subsection User-defined Commands
  22720. @cindex user-defined command
  22721. @cindex arguments, to user-defined commands
  22722. A @dfn{user-defined command} is a sequence of @value{GDBN} commands to
  22723. which you assign a new name as a command. This is done with the
  22724. @code{define} command. User commands may accept an unlimited number of arguments
  22725. separated by whitespace. Arguments are accessed within the user command
  22726. via @code{$arg0@dots{}$argN}. A trivial example:
  22727. @smallexample
  22728. define adder
  22729. print $arg0 + $arg1 + $arg2
  22730. end
  22731. @end smallexample
  22732. @noindent
  22733. To execute the command use:
  22734. @smallexample
  22735. adder 1 2 3
  22736. @end smallexample
  22737. @noindent
  22738. This defines the command @code{adder}, which prints the sum of
  22739. its three arguments. Note the arguments are text substitutions, so they may
  22740. reference variables, use complex expressions, or even perform inferior
  22741. functions calls.
  22742. @cindex argument count in user-defined commands
  22743. @cindex how many arguments (user-defined commands)
  22744. In addition, @code{$argc} may be used to find out how many arguments have
  22745. been passed.
  22746. @smallexample
  22747. define adder
  22748. if $argc == 2
  22749. print $arg0 + $arg1
  22750. end
  22751. if $argc == 3
  22752. print $arg0 + $arg1 + $arg2
  22753. end
  22754. end
  22755. @end smallexample
  22756. Combining with the @code{eval} command (@pxref{eval}) makes it easier
  22757. to process a variable number of arguments:
  22758. @smallexample
  22759. define adder
  22760. set $i = 0
  22761. set $sum = 0
  22762. while $i < $argc
  22763. eval "set $sum = $sum + $arg%d", $i
  22764. set $i = $i + 1
  22765. end
  22766. print $sum
  22767. end
  22768. @end smallexample
  22769. @table @code
  22770. @kindex define
  22771. @item define @var{commandname}
  22772. Define a command named @var{commandname}. If there is already a command
  22773. by that name, you are asked to confirm that you want to redefine it.
  22774. The argument @var{commandname} may be a bare command name consisting of letters,
  22775. numbers, dashes, dots, and underscores. It may also start with any
  22776. predefined or user-defined prefix command.
  22777. For example, @samp{define target my-target} creates
  22778. a user-defined @samp{target my-target} command.
  22779. The definition of the command is made up of other @value{GDBN} command lines,
  22780. which are given following the @code{define} command. The end of these
  22781. commands is marked by a line containing @code{end}.
  22782. @kindex document
  22783. @kindex end@r{ (user-defined commands)}
  22784. @item document @var{commandname}
  22785. Document the user-defined command @var{commandname}, so that it can be
  22786. accessed by @code{help}. The command @var{commandname} must already be
  22787. defined. This command reads lines of documentation just as @code{define}
  22788. reads the lines of the command definition, ending with @code{end}.
  22789. After the @code{document} command is finished, @code{help} on command
  22790. @var{commandname} displays the documentation you have written.
  22791. You may use the @code{document} command again to change the
  22792. documentation of a command. Redefining the command with @code{define}
  22793. does not change the documentation.
  22794. @kindex define-prefix
  22795. @item define-prefix @var{commandname}
  22796. Define or mark the command @var{commandname} as a user-defined prefix
  22797. command. Once marked, @var{commandname} can be used as prefix command
  22798. by the @code{define} command.
  22799. Note that @code{define-prefix} can be used with a not yet defined
  22800. @var{commandname}. In such a case, @var{commandname} is defined as
  22801. an empty user-defined command.
  22802. In case you redefine a command that was marked as a user-defined
  22803. prefix command, the subcommands of the redefined command are kept
  22804. (and @value{GDBN} indicates so to the user).
  22805. Example:
  22806. @example
  22807. (gdb) define-prefix abc
  22808. (gdb) define-prefix abc def
  22809. (gdb) define abc def
  22810. Type commands for definition of "abc def".
  22811. End with a line saying just "end".
  22812. >echo command initial def\n
  22813. >end
  22814. (gdb) define abc def ghi
  22815. Type commands for definition of "abc def ghi".
  22816. End with a line saying just "end".
  22817. >echo command ghi\n
  22818. >end
  22819. (gdb) define abc def
  22820. Keeping subcommands of prefix command "def".
  22821. Redefine command "def"? (y or n) y
  22822. Type commands for definition of "abc def".
  22823. End with a line saying just "end".
  22824. >echo command def\n
  22825. >end
  22826. (gdb) abc def ghi
  22827. command ghi
  22828. (gdb) abc def
  22829. command def
  22830. (gdb)
  22831. @end example
  22832. @kindex dont-repeat
  22833. @cindex don't repeat command
  22834. @item dont-repeat
  22835. Used inside a user-defined command, this tells @value{GDBN} that this
  22836. command should not be repeated when the user hits @key{RET}
  22837. (@pxref{Command Syntax, repeat last command}).
  22838. @kindex help user-defined
  22839. @item help user-defined
  22840. List all user-defined commands and all python commands defined in class
  22841. COMMAND_USER. The first line of the documentation or docstring is
  22842. included (if any).
  22843. @kindex show user
  22844. @item show user
  22845. @itemx show user @var{commandname}
  22846. Display the @value{GDBN} commands used to define @var{commandname} (but
  22847. not its documentation). If no @var{commandname} is given, display the
  22848. definitions for all user-defined commands.
  22849. This does not work for user-defined python commands.
  22850. @cindex infinite recursion in user-defined commands
  22851. @kindex show max-user-call-depth
  22852. @kindex set max-user-call-depth
  22853. @item show max-user-call-depth
  22854. @itemx set max-user-call-depth
  22855. The value of @code{max-user-call-depth} controls how many recursion
  22856. levels are allowed in user-defined commands before @value{GDBN} suspects an
  22857. infinite recursion and aborts the command.
  22858. This does not apply to user-defined python commands.
  22859. @end table
  22860. In addition to the above commands, user-defined commands frequently
  22861. use control flow commands, described in @ref{Command Files}.
  22862. When user-defined commands are executed, the
  22863. commands of the definition are not printed. An error in any command
  22864. stops execution of the user-defined command.
  22865. If used interactively, commands that would ask for confirmation proceed
  22866. without asking when used inside a user-defined command. Many @value{GDBN}
  22867. commands that normally print messages to say what they are doing omit the
  22868. messages when used in a user-defined command.
  22869. @node Hooks
  22870. @subsection User-defined Command Hooks
  22871. @cindex command hooks
  22872. @cindex hooks, for commands
  22873. @cindex hooks, pre-command
  22874. @kindex hook
  22875. You may define @dfn{hooks}, which are a special kind of user-defined
  22876. command. Whenever you run the command @samp{foo}, if the user-defined
  22877. command @samp{hook-foo} exists, it is executed (with no arguments)
  22878. before that command.
  22879. @cindex hooks, post-command
  22880. @kindex hookpost
  22881. A hook may also be defined which is run after the command you executed.
  22882. Whenever you run the command @samp{foo}, if the user-defined command
  22883. @samp{hookpost-foo} exists, it is executed (with no arguments) after
  22884. that command. Post-execution hooks may exist simultaneously with
  22885. pre-execution hooks, for the same command.
  22886. It is valid for a hook to call the command which it hooks. If this
  22887. occurs, the hook is not re-executed, thereby avoiding infinite recursion.
  22888. @c It would be nice if hookpost could be passed a parameter indicating
  22889. @c if the command it hooks executed properly or not. FIXME!
  22890. @kindex stop@r{, a pseudo-command}
  22891. In addition, a pseudo-command, @samp{stop} exists. Defining
  22892. (@samp{hook-stop}) makes the associated commands execute every time
  22893. execution stops in your program: before breakpoint commands are run,
  22894. displays are printed, or the stack frame is printed.
  22895. For example, to ignore @code{SIGALRM} signals while
  22896. single-stepping, but treat them normally during normal execution,
  22897. you could define:
  22898. @smallexample
  22899. define hook-stop
  22900. handle SIGALRM nopass
  22901. end
  22902. define hook-run
  22903. handle SIGALRM pass
  22904. end
  22905. define hook-continue
  22906. handle SIGALRM pass
  22907. end
  22908. @end smallexample
  22909. As a further example, to hook at the beginning and end of the @code{echo}
  22910. command, and to add extra text to the beginning and end of the message,
  22911. you could define:
  22912. @smallexample
  22913. define hook-echo
  22914. echo <<<---
  22915. end
  22916. define hookpost-echo
  22917. echo --->>>\n
  22918. end
  22919. (@value{GDBP}) echo Hello World
  22920. <<<---Hello World--->>>
  22921. (@value{GDBP})
  22922. @end smallexample
  22923. You can define a hook for any single-word command in @value{GDBN}, but
  22924. not for command aliases; you should define a hook for the basic command
  22925. name, e.g.@: @code{backtrace} rather than @code{bt}.
  22926. @c FIXME! So how does Joe User discover whether a command is an alias
  22927. @c or not?
  22928. You can hook a multi-word command by adding @code{hook-} or
  22929. @code{hookpost-} to the last word of the command, e.g.@:
  22930. @samp{define target hook-remote} to add a hook to @samp{target remote}.
  22931. If an error occurs during the execution of your hook, execution of
  22932. @value{GDBN} commands stops and @value{GDBN} issues a prompt
  22933. (before the command that you actually typed had a chance to run).
  22934. If you try to define a hook which does not match any known command, you
  22935. get a warning from the @code{define} command.
  22936. @node Command Files
  22937. @subsection Command Files
  22938. @cindex command files
  22939. @cindex scripting commands
  22940. A command file for @value{GDBN} is a text file made of lines that are
  22941. @value{GDBN} commands. Comments (lines starting with @kbd{#}) may
  22942. also be included. An empty line in a command file does nothing; it
  22943. does not mean to repeat the last command, as it would from the
  22944. terminal.
  22945. You can request the execution of a command file with the @code{source}
  22946. command. Note that the @code{source} command is also used to evaluate
  22947. scripts that are not Command Files. The exact behavior can be configured
  22948. using the @code{script-extension} setting.
  22949. @xref{Extending GDB,, Extending GDB}.
  22950. @table @code
  22951. @kindex source
  22952. @cindex execute commands from a file
  22953. @item source [-s] [-v] @var{filename}
  22954. Execute the command file @var{filename}.
  22955. @end table
  22956. The lines in a command file are generally executed sequentially,
  22957. unless the order of execution is changed by one of the
  22958. @emph{flow-control commands} described below. The commands are not
  22959. printed as they are executed. An error in any command terminates
  22960. execution of the command file and control is returned to the console.
  22961. @value{GDBN} first searches for @var{filename} in the current directory.
  22962. If the file is not found there, and @var{filename} does not specify a
  22963. directory, then @value{GDBN} also looks for the file on the source search path
  22964. (specified with the @samp{directory} command);
  22965. except that @file{$cdir} is not searched because the compilation directory
  22966. is not relevant to scripts.
  22967. If @code{-s} is specified, then @value{GDBN} searches for @var{filename}
  22968. on the search path even if @var{filename} specifies a directory.
  22969. The search is done by appending @var{filename} to each element of the
  22970. search path. So, for example, if @var{filename} is @file{mylib/myscript}
  22971. and the search path contains @file{/home/user} then @value{GDBN} will
  22972. look for the script @file{/home/user/mylib/myscript}.
  22973. The search is also done if @var{filename} is an absolute path.
  22974. For example, if @var{filename} is @file{/tmp/myscript} and
  22975. the search path contains @file{/home/user} then @value{GDBN} will
  22976. look for the script @file{/home/user/tmp/myscript}.
  22977. For DOS-like systems, if @var{filename} contains a drive specification,
  22978. it is stripped before concatenation. For example, if @var{filename} is
  22979. @file{d:myscript} and the search path contains @file{c:/tmp} then @value{GDBN}
  22980. will look for the script @file{c:/tmp/myscript}.
  22981. If @code{-v}, for verbose mode, is given then @value{GDBN} displays
  22982. each command as it is executed. The option must be given before
  22983. @var{filename}, and is interpreted as part of the filename anywhere else.
  22984. Commands that would ask for confirmation if used interactively proceed
  22985. without asking when used in a command file. Many @value{GDBN} commands that
  22986. normally print messages to say what they are doing omit the messages
  22987. when called from command files.
  22988. @value{GDBN} also accepts command input from standard input. In this
  22989. mode, normal output goes to standard output and error output goes to
  22990. standard error. Errors in a command file supplied on standard input do
  22991. not terminate execution of the command file---execution continues with
  22992. the next command.
  22993. @smallexample
  22994. gdb < cmds > log 2>&1
  22995. @end smallexample
  22996. (The syntax above will vary depending on the shell used.) This example
  22997. will execute commands from the file @file{cmds}. All output and errors
  22998. would be directed to @file{log}.
  22999. Since commands stored on command files tend to be more general than
  23000. commands typed interactively, they frequently need to deal with
  23001. complicated situations, such as different or unexpected values of
  23002. variables and symbols, changes in how the program being debugged is
  23003. built, etc. @value{GDBN} provides a set of flow-control commands to
  23004. deal with these complexities. Using these commands, you can write
  23005. complex scripts that loop over data structures, execute commands
  23006. conditionally, etc.
  23007. @table @code
  23008. @kindex if
  23009. @kindex else
  23010. @item if
  23011. @itemx else
  23012. This command allows to include in your script conditionally executed
  23013. commands. The @code{if} command takes a single argument, which is an
  23014. expression to evaluate. It is followed by a series of commands that
  23015. are executed only if the expression is true (its value is nonzero).
  23016. There can then optionally be an @code{else} line, followed by a series
  23017. of commands that are only executed if the expression was false. The
  23018. end of the list is marked by a line containing @code{end}.
  23019. @kindex while
  23020. @item while
  23021. This command allows to write loops. Its syntax is similar to
  23022. @code{if}: the command takes a single argument, which is an expression
  23023. to evaluate, and must be followed by the commands to execute, one per
  23024. line, terminated by an @code{end}. These commands are called the
  23025. @dfn{body} of the loop. The commands in the body of @code{while} are
  23026. executed repeatedly as long as the expression evaluates to true.
  23027. @kindex loop_break
  23028. @item loop_break
  23029. This command exits the @code{while} loop in whose body it is included.
  23030. Execution of the script continues after that @code{while}s @code{end}
  23031. line.
  23032. @kindex loop_continue
  23033. @item loop_continue
  23034. This command skips the execution of the rest of the body of commands
  23035. in the @code{while} loop in whose body it is included. Execution
  23036. branches to the beginning of the @code{while} loop, where it evaluates
  23037. the controlling expression.
  23038. @kindex end@r{ (if/else/while commands)}
  23039. @item end
  23040. Terminate the block of commands that are the body of @code{if},
  23041. @code{else}, or @code{while} flow-control commands.
  23042. @end table
  23043. @node Output
  23044. @subsection Commands for Controlled Output
  23045. During the execution of a command file or a user-defined command, normal
  23046. @value{GDBN} output is suppressed; the only output that appears is what is
  23047. explicitly printed by the commands in the definition. This section
  23048. describes three commands useful for generating exactly the output you
  23049. want.
  23050. @table @code
  23051. @kindex echo
  23052. @item echo @var{text}
  23053. @c I do not consider backslash-space a standard C escape sequence
  23054. @c because it is not in ANSI.
  23055. Print @var{text}. Nonprinting characters can be included in
  23056. @var{text} using C escape sequences, such as @samp{\n} to print a
  23057. newline. @strong{No newline is printed unless you specify one.}
  23058. In addition to the standard C escape sequences, a backslash followed
  23059. by a space stands for a space. This is useful for displaying a
  23060. string with spaces at the beginning or the end, since leading and
  23061. trailing spaces are otherwise trimmed from all arguments.
  23062. To print @samp{@w{ }and foo =@w{ }}, use the command
  23063. @samp{echo \@w{ }and foo = \@w{ }}.
  23064. A backslash at the end of @var{text} can be used, as in C, to continue
  23065. the command onto subsequent lines. For example,
  23066. @smallexample
  23067. echo This is some text\n\
  23068. which is continued\n\
  23069. onto several lines.\n
  23070. @end smallexample
  23071. produces the same output as
  23072. @smallexample
  23073. echo This is some text\n
  23074. echo which is continued\n
  23075. echo onto several lines.\n
  23076. @end smallexample
  23077. @kindex output
  23078. @item output @var{expression}
  23079. Print the value of @var{expression} and nothing but that value: no
  23080. newlines, no @samp{$@var{nn} = }. The value is not entered in the
  23081. value history either. @xref{Expressions, ,Expressions}, for more information
  23082. on expressions.
  23083. @item output/@var{fmt} @var{expression}
  23084. Print the value of @var{expression} in format @var{fmt}. You can use
  23085. the same formats as for @code{print}. @xref{Output Formats,,Output
  23086. Formats}, for more information.
  23087. @kindex printf
  23088. @item printf @var{template}, @var{expressions}@dots{}
  23089. Print the values of one or more @var{expressions} under the control of
  23090. the string @var{template}. To print several values, make
  23091. @var{expressions} be a comma-separated list of individual expressions,
  23092. which may be either numbers or pointers. Their values are printed as
  23093. specified by @var{template}, exactly as a C program would do by
  23094. executing the code below:
  23095. @smallexample
  23096. printf (@var{template}, @var{expressions}@dots{});
  23097. @end smallexample
  23098. As in @code{C} @code{printf}, ordinary characters in @var{template}
  23099. are printed verbatim, while @dfn{conversion specification} introduced
  23100. by the @samp{%} character cause subsequent @var{expressions} to be
  23101. evaluated, their values converted and formatted according to type and
  23102. style information encoded in the conversion specifications, and then
  23103. printed.
  23104. For example, you can print two values in hex like this:
  23105. @smallexample
  23106. printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
  23107. @end smallexample
  23108. @code{printf} supports all the standard @code{C} conversion
  23109. specifications, including the flags and modifiers between the @samp{%}
  23110. character and the conversion letter, with the following exceptions:
  23111. @itemize @bullet
  23112. @item
  23113. The argument-ordering modifiers, such as @samp{2$}, are not supported.
  23114. @item
  23115. The modifier @samp{*} is not supported for specifying precision or
  23116. width.
  23117. @item
  23118. The @samp{'} flag (for separation of digits into groups according to
  23119. @code{LC_NUMERIC'}) is not supported.
  23120. @item
  23121. The type modifiers @samp{hh}, @samp{j}, @samp{t}, and @samp{z} are not
  23122. supported.
  23123. @item
  23124. The conversion letter @samp{n} (as in @samp{%n}) is not supported.
  23125. @item
  23126. The conversion letters @samp{a} and @samp{A} are not supported.
  23127. @end itemize
  23128. @noindent
  23129. Note that the @samp{ll} type modifier is supported only if the
  23130. underlying @code{C} implementation used to build @value{GDBN} supports
  23131. the @code{long long int} type, and the @samp{L} type modifier is
  23132. supported only if @code{long double} type is available.
  23133. As in @code{C}, @code{printf} supports simple backslash-escape
  23134. sequences, such as @code{\n}, @samp{\t}, @samp{\\}, @samp{\"},
  23135. @samp{\a}, and @samp{\f}, that consist of backslash followed by a
  23136. single character. Octal and hexadecimal escape sequences are not
  23137. supported.
  23138. Additionally, @code{printf} supports conversion specifications for DFP
  23139. (@dfn{Decimal Floating Point}) types using the following length modifiers
  23140. together with a floating point specifier.
  23141. letters:
  23142. @itemize @bullet
  23143. @item
  23144. @samp{H} for printing @code{Decimal32} types.
  23145. @item
  23146. @samp{D} for printing @code{Decimal64} types.
  23147. @item
  23148. @samp{DD} for printing @code{Decimal128} types.
  23149. @end itemize
  23150. If the underlying @code{C} implementation used to build @value{GDBN} has
  23151. support for the three length modifiers for DFP types, other modifiers
  23152. such as width and precision will also be available for @value{GDBN} to use.
  23153. In case there is no such @code{C} support, no additional modifiers will be
  23154. available and the value will be printed in the standard way.
  23155. Here's an example of printing DFP types using the above conversion letters:
  23156. @smallexample
  23157. printf "D32: %Hf - D64: %Df - D128: %DDf\n",1.2345df,1.2E10dd,1.2E1dl
  23158. @end smallexample
  23159. @anchor{eval}
  23160. @kindex eval
  23161. @item eval @var{template}, @var{expressions}@dots{}
  23162. Convert the values of one or more @var{expressions} under the control of
  23163. the string @var{template} to a command line, and call it.
  23164. @end table
  23165. @node Auto-loading sequences
  23166. @subsection Controlling auto-loading native @value{GDBN} scripts
  23167. @cindex native script auto-loading
  23168. When a new object file is read (for example, due to the @code{file}
  23169. command, or because the inferior has loaded a shared library),
  23170. @value{GDBN} will look for the command file @file{@var{objfile}-gdb.gdb}.
  23171. @xref{Auto-loading extensions}.
  23172. Auto-loading can be enabled or disabled,
  23173. and the list of auto-loaded scripts can be printed.
  23174. @table @code
  23175. @anchor{set auto-load gdb-scripts}
  23176. @kindex set auto-load gdb-scripts
  23177. @item set auto-load gdb-scripts [on|off]
  23178. Enable or disable the auto-loading of canned sequences of commands scripts.
  23179. @anchor{show auto-load gdb-scripts}
  23180. @kindex show auto-load gdb-scripts
  23181. @item show auto-load gdb-scripts
  23182. Show whether auto-loading of canned sequences of commands scripts is enabled or
  23183. disabled.
  23184. @anchor{info auto-load gdb-scripts}
  23185. @kindex info auto-load gdb-scripts
  23186. @cindex print list of auto-loaded canned sequences of commands scripts
  23187. @item info auto-load gdb-scripts [@var{regexp}]
  23188. Print the list of all canned sequences of commands scripts that @value{GDBN}
  23189. auto-loaded.
  23190. @end table
  23191. If @var{regexp} is supplied only canned sequences of commands scripts with
  23192. matching names are printed.
  23193. @node Aliases
  23194. @section Command Aliases
  23195. @cindex aliases for commands
  23196. Aliases allow you to define alternate spellings for existing commands.
  23197. For example, if a new @value{GDBN} command defined in Python
  23198. (@pxref{Python}) has a long name, it is handy to have an abbreviated
  23199. version of it that involves less typing.
  23200. @value{GDBN} itself uses aliases. For example @samp{s} is an alias
  23201. of the @samp{step} command even though it is otherwise an ambiguous
  23202. abbreviation of other commands like @samp{set} and @samp{show}.
  23203. Aliases are also used to provide shortened or more common versions
  23204. of multi-word commands. For example, @value{GDBN} provides the
  23205. @samp{tty} alias of the @samp{set inferior-tty} command.
  23206. You can define a new alias with the @samp{alias} command.
  23207. @table @code
  23208. @kindex alias
  23209. @item alias [-a] [--] @var{alias} = @var{command} [@var{default-args}]
  23210. @end table
  23211. @var{alias} specifies the name of the new alias. Each word of
  23212. @var{alias} must consist of letters, numbers, dashes and underscores.
  23213. @var{command} specifies the name of an existing command
  23214. that is being aliased.
  23215. @var{command} can also be the name of an existing alias. In this
  23216. case, @var{command} cannot be an alias that has default arguments.
  23217. The @samp{-a} option specifies that the new alias is an abbreviation
  23218. of the command. Abbreviations are not used in command completion.
  23219. The @samp{--} option specifies the end of options,
  23220. and is useful when @var{alias} begins with a dash.
  23221. You can specify @var{default-args} for your alias. These
  23222. @var{default-args} will be automatically added before the alias
  23223. arguments typed explicitly on the command line.
  23224. For example, the below defines an alias @code{btfullall} that shows all local
  23225. variables and all frame arguments:
  23226. @smallexample
  23227. (@value{GDBP}) alias btfullall = backtrace -full -frame-arguments all
  23228. @end smallexample
  23229. For more information about @var{default-args}, see @ref{Command
  23230. aliases default args, ,Default Arguments}.
  23231. Here is a simple example showing how to make an abbreviation of a
  23232. command so that there is less to type. Suppose you were tired of
  23233. typing @samp{disas}, the current shortest unambiguous abbreviation of
  23234. the @samp{disassemble} command and you wanted an even shorter version
  23235. named @samp{di}. The following will accomplish this.
  23236. @smallexample
  23237. (gdb) alias -a di = disas
  23238. @end smallexample
  23239. Note that aliases are different from user-defined commands. With a
  23240. user-defined command, you also need to write documentation for it with
  23241. the @samp{document} command. An alias automatically picks up the
  23242. documentation of the existing command.
  23243. Here is an example where we make @samp{elms} an abbreviation of
  23244. @samp{elements} in the @samp{set print elements} command.
  23245. This is to show that you can make an abbreviation of any part
  23246. of a command.
  23247. @smallexample
  23248. (gdb) alias -a set print elms = set print elements
  23249. (gdb) alias -a show print elms = show print elements
  23250. (gdb) set p elms 200
  23251. (gdb) show p elms
  23252. Limit on string chars or array elements to print is 200.
  23253. @end smallexample
  23254. Note that if you are defining an alias of a @samp{set} command,
  23255. and you want to have an alias for the corresponding @samp{show}
  23256. command, then you need to define the latter separately.
  23257. Unambiguously abbreviated commands are allowed in @var{command} and
  23258. @var{alias}, just as they are normally.
  23259. @smallexample
  23260. (gdb) alias -a set pr elms = set p ele
  23261. @end smallexample
  23262. Finally, here is an example showing the creation of a one word
  23263. alias for a more complex command.
  23264. This creates alias @samp{spe} of the command @samp{set print elements}.
  23265. @smallexample
  23266. (gdb) alias spe = set print elements
  23267. (gdb) spe 20
  23268. @end smallexample
  23269. @menu
  23270. * Command aliases default args:: Default arguments for aliases
  23271. @end menu
  23272. @node Command aliases default args
  23273. @subsection Default Arguments
  23274. @cindex aliases for commands, default arguments
  23275. You can tell @value{GDBN} to always prepend some default arguments to
  23276. the list of arguments provided explicitly by the user when using a
  23277. user-defined alias.
  23278. If you repeatedly use the same arguments or options for a command, you
  23279. can define an alias for this command and tell @value{GDBN} to
  23280. automatically prepend these arguments or options to the list of
  23281. arguments you type explicitly when using the alias@footnote{@value{GDBN}
  23282. could easily accept default arguments for pre-defined commands and aliases,
  23283. but it was deemed this would be confusing, and so is not allowed.}.
  23284. For example, if you often use the command @code{thread apply all}
  23285. specifying to work on the threads in ascending order and to continue in case it
  23286. encounters an error, you can tell @value{GDBN} to automatically preprend
  23287. the @code{-ascending} and @code{-c} options by using:
  23288. @smallexample
  23289. (@value{GDBP}) alias thread apply asc-all = thread apply all -ascending -c
  23290. @end smallexample
  23291. Once you have defined this alias with its default args, any time you type
  23292. the @code{thread apply asc-all} followed by @code{some arguments},
  23293. @value{GDBN} will execute @code{thread apply all -ascending -c some arguments}.
  23294. To have even less to type, you can also define a one word alias:
  23295. @smallexample
  23296. (@value{GDBP}) alias t_a_c = thread apply all -ascending -c
  23297. @end smallexample
  23298. As usual, unambiguous abbreviations can be used for @var{alias}
  23299. and @var{default-args}.
  23300. The different aliases of a command do not share their default args.
  23301. For example, you define a new alias @code{bt_ALL} showing all possible
  23302. information and another alias @code{bt_SMALL} showing very limited information
  23303. using:
  23304. @smallexample
  23305. (@value{GDBP}) alias bt_ALL = backtrace -entry-values both -frame-arg all \
  23306. -past-main -past-entry -full
  23307. (@value{GDBP}) alias bt_SMALL = backtrace -entry-values no -frame-arg none \
  23308. -past-main off -past-entry off
  23309. @end smallexample
  23310. (For more on using the @code{alias} command, see @ref{Aliases}.)
  23311. Default args are not limited to the arguments and options of @var{command},
  23312. but can specify nested commands if @var{command} accepts such a nested command
  23313. as argument.
  23314. For example, the below defines @code{faalocalsoftype} that lists the
  23315. frames having locals of a certain type, together with the matching
  23316. local vars:
  23317. @smallexample
  23318. (@value{GDBP}) alias faalocalsoftype = frame apply all info locals -q -t
  23319. (@value{GDBP}) faalocalsoftype int
  23320. #1 0x55554f5e in sleeper_or_burner (v=0xdf50) at sleepers.c:86
  23321. i = 0
  23322. ret = 21845
  23323. @end smallexample
  23324. This is also very useful to define an alias for a set of nested @code{with}
  23325. commands to have a particular combination of temporary settings. For example,
  23326. the below defines the alias @code{pp10} that pretty prints an expression
  23327. argument, with a maximum of 10 elements if the expression is a string or
  23328. an array:
  23329. @smallexample
  23330. (@value{GDBP}) alias pp10 = with print pretty -- with print elements 10 -- print
  23331. @end smallexample
  23332. This defines the alias @code{pp10} as being a sequence of 3 commands.
  23333. The first part @code{with print pretty --} temporarily activates the setting
  23334. @code{set print pretty}, then launches the command that follows the separator
  23335. @code{--}.
  23336. The command following the first part is also a @code{with} command that
  23337. temporarily changes the setting @code{set print elements} to 10, then
  23338. launches the command that follows the second separator @code{--}.
  23339. The third part @code{print} is the command the @code{pp10} alias will launch,
  23340. using the temporary values of the settings and the arguments explicitly given
  23341. by the user.
  23342. For more information about the @code{with} command usage,
  23343. see @ref{Command Settings}.
  23344. @c Python docs live in a separate file.
  23345. @include python.texi
  23346. @c Guile docs live in a separate file.
  23347. @include guile.texi
  23348. @node Auto-loading extensions
  23349. @section Auto-loading extensions
  23350. @cindex auto-loading extensions
  23351. @value{GDBN} provides two mechanisms for automatically loading
  23352. extensions when a new object file is read (for example, due to the
  23353. @code{file} command, or because the inferior has loaded a shared
  23354. library): @file{@var{objfile}-gdb.@var{ext}} (@pxref{objfile-gdbdotext
  23355. file,,The @file{@var{objfile}-gdb.@var{ext}} file}) and the
  23356. @code{.debug_gdb_scripts} section of modern file formats like ELF
  23357. (@pxref{dotdebug_gdb_scripts section,,The @code{.debug_gdb_scripts}
  23358. section}). For a discussion of the differences between these two
  23359. approaches see @ref{Which flavor to choose?}.
  23360. The auto-loading feature is useful for supplying application-specific
  23361. debugging commands and features.
  23362. Auto-loading can be enabled or disabled,
  23363. and the list of auto-loaded scripts can be printed.
  23364. See the @samp{auto-loading} section of each extension language
  23365. for more information.
  23366. For @value{GDBN} command files see @ref{Auto-loading sequences}.
  23367. For Python files see @ref{Python Auto-loading}.
  23368. Note that loading of this script file also requires accordingly configured
  23369. @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
  23370. @menu
  23371. * objfile-gdbdotext file:: The @file{@var{objfile}-gdb.@var{ext}} file
  23372. * dotdebug_gdb_scripts section:: The @code{.debug_gdb_scripts} section
  23373. * Which flavor to choose?:: Choosing between these approaches
  23374. @end menu
  23375. @node objfile-gdbdotext file
  23376. @subsection The @file{@var{objfile}-gdb.@var{ext}} file
  23377. @cindex @file{@var{objfile}-gdb.gdb}
  23378. @cindex @file{@var{objfile}-gdb.py}
  23379. @cindex @file{@var{objfile}-gdb.scm}
  23380. When a new object file is read, @value{GDBN} looks for a file named
  23381. @file{@var{objfile}-gdb.@var{ext}} (we call it @var{script-name} below),
  23382. where @var{objfile} is the object file's name and
  23383. where @var{ext} is the file extension for the extension language:
  23384. @table @code
  23385. @item @file{@var{objfile}-gdb.gdb}
  23386. GDB's own command language
  23387. @item @file{@var{objfile}-gdb.py}
  23388. Python
  23389. @item @file{@var{objfile}-gdb.scm}
  23390. Guile
  23391. @end table
  23392. @var{script-name} is formed by ensuring that the file name of @var{objfile}
  23393. is absolute, following all symlinks, and resolving @code{.} and @code{..}
  23394. components, and appending the @file{-gdb.@var{ext}} suffix.
  23395. If this file exists and is readable, @value{GDBN} will evaluate it as a
  23396. script in the specified extension language.
  23397. If this file does not exist, then @value{GDBN} will look for
  23398. @var{script-name} file in all of the directories as specified below.
  23399. (On MS-Windows/MS-DOS, the drive letter of the executable's leading
  23400. directories is converted to a one-letter subdirectory, i.e.@:
  23401. @file{d:/usr/bin/} is converted to @file{/d/usr/bin/}, because Windows
  23402. filesystems disallow colons in file names.)
  23403. Note that loading of these files requires an accordingly configured
  23404. @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
  23405. For object files using @file{.exe} suffix @value{GDBN} tries to load first the
  23406. scripts normally according to its @file{.exe} filename. But if no scripts are
  23407. found @value{GDBN} also tries script filenames matching the object file without
  23408. its @file{.exe} suffix. This @file{.exe} stripping is case insensitive and it
  23409. is attempted on any platform. This makes the script filenames compatible
  23410. between Unix and MS-Windows hosts.
  23411. @table @code
  23412. @anchor{set auto-load scripts-directory}
  23413. @kindex set auto-load scripts-directory
  23414. @item set auto-load scripts-directory @r{[}@var{directories}@r{]}
  23415. Control @value{GDBN} auto-loaded scripts location. Multiple directory entries
  23416. may be delimited by the host platform path separator in use
  23417. (@samp{:} on Unix, @samp{;} on MS-Windows and MS-DOS).
  23418. Each entry here needs to be covered also by the security setting
  23419. @code{set auto-load safe-path} (@pxref{set auto-load safe-path}).
  23420. @anchor{with-auto-load-dir}
  23421. This variable defaults to @file{$debugdir:$datadir/auto-load}. The default
  23422. @code{set auto-load safe-path} value can be also overriden by @value{GDBN}
  23423. configuration option @option{--with-auto-load-dir}.
  23424. Any reference to @file{$debugdir} will get replaced by
  23425. @var{debug-file-directory} value (@pxref{Separate Debug Files}) and any
  23426. reference to @file{$datadir} will get replaced by @var{data-directory} which is
  23427. determined at @value{GDBN} startup (@pxref{Data Files}). @file{$debugdir} and
  23428. @file{$datadir} must be placed as a directory component --- either alone or
  23429. delimited by @file{/} or @file{\} directory separators, depending on the host
  23430. platform.
  23431. The list of directories uses path separator (@samp{:} on GNU and Unix
  23432. systems, @samp{;} on MS-Windows and MS-DOS) to separate directories, similarly
  23433. to the @env{PATH} environment variable.
  23434. @anchor{show auto-load scripts-directory}
  23435. @kindex show auto-load scripts-directory
  23436. @item show auto-load scripts-directory
  23437. Show @value{GDBN} auto-loaded scripts location.
  23438. @anchor{add-auto-load-scripts-directory}
  23439. @kindex add-auto-load-scripts-directory
  23440. @item add-auto-load-scripts-directory @r{[}@var{directories}@dots{}@r{]}
  23441. Add an entry (or list of entries) to the list of auto-loaded scripts locations.
  23442. Multiple entries may be delimited by the host platform path separator in use.
  23443. @end table
  23444. @value{GDBN} does not track which files it has already auto-loaded this way.
  23445. @value{GDBN} will load the associated script every time the corresponding
  23446. @var{objfile} is opened.
  23447. So your @file{-gdb.@var{ext}} file should be careful to avoid errors if it
  23448. is evaluated more than once.
  23449. @node dotdebug_gdb_scripts section
  23450. @subsection The @code{.debug_gdb_scripts} section
  23451. @cindex @code{.debug_gdb_scripts} section
  23452. For systems using file formats like ELF and COFF,
  23453. when @value{GDBN} loads a new object file
  23454. it will look for a special section named @code{.debug_gdb_scripts}.
  23455. If this section exists, its contents is a list of null-terminated entries
  23456. specifying scripts to load. Each entry begins with a non-null prefix byte that
  23457. specifies the kind of entry, typically the extension language and whether the
  23458. script is in a file or inlined in @code{.debug_gdb_scripts}.
  23459. The following entries are supported:
  23460. @table @code
  23461. @item SECTION_SCRIPT_ID_PYTHON_FILE = 1
  23462. @item SECTION_SCRIPT_ID_SCHEME_FILE = 3
  23463. @item SECTION_SCRIPT_ID_PYTHON_TEXT = 4
  23464. @item SECTION_SCRIPT_ID_SCHEME_TEXT = 6
  23465. @end table
  23466. @subsubsection Script File Entries
  23467. If the entry specifies a file, @value{GDBN} will look for the file first
  23468. in the current directory and then along the source search path
  23469. (@pxref{Source Path, ,Specifying Source Directories}),
  23470. except that @file{$cdir} is not searched, since the compilation
  23471. directory is not relevant to scripts.
  23472. File entries can be placed in section @code{.debug_gdb_scripts} with,
  23473. for example, this GCC macro for Python scripts.
  23474. @example
  23475. /* Note: The "MS" section flags are to remove duplicates. */
  23476. #define DEFINE_GDB_PY_SCRIPT(script_name) \
  23477. asm("\
  23478. .pushsection \".debug_gdb_scripts\", \"MS\",@@progbits,1\n\
  23479. .byte 1 /* Python */\n\
  23480. .asciz \"" script_name "\"\n\
  23481. .popsection \n\
  23482. ");
  23483. @end example
  23484. @noindent
  23485. For Guile scripts, replace @code{.byte 1} with @code{.byte 3}.
  23486. Then one can reference the macro in a header or source file like this:
  23487. @example
  23488. DEFINE_GDB_PY_SCRIPT ("my-app-scripts.py")
  23489. @end example
  23490. The script name may include directories if desired.
  23491. Note that loading of this script file also requires accordingly configured
  23492. @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
  23493. If the macro invocation is put in a header, any application or library
  23494. using this header will get a reference to the specified script,
  23495. and with the use of @code{"MS"} attributes on the section, the linker
  23496. will remove duplicates.
  23497. @subsubsection Script Text Entries
  23498. Script text entries allow to put the executable script in the entry
  23499. itself instead of loading it from a file.
  23500. The first line of the entry, everything after the prefix byte and up to
  23501. the first newline (@code{0xa}) character, is the script name, and must not
  23502. contain any kind of space character, e.g., spaces or tabs.
  23503. The rest of the entry, up to the trailing null byte, is the script to
  23504. execute in the specified language. The name needs to be unique among
  23505. all script names, as @value{GDBN} executes each script only once based
  23506. on its name.
  23507. Here is an example from file @file{py-section-script.c} in the @value{GDBN}
  23508. testsuite.
  23509. @example
  23510. #include "symcat.h"
  23511. #include "gdb/section-scripts.h"
  23512. asm(
  23513. ".pushsection \".debug_gdb_scripts\", \"MS\",@@progbits,1\n"
  23514. ".byte " XSTRING (SECTION_SCRIPT_ID_PYTHON_TEXT) "\n"
  23515. ".ascii \"gdb.inlined-script\\n\"\n"
  23516. ".ascii \"class test_cmd (gdb.Command):\\n\"\n"
  23517. ".ascii \" def __init__ (self):\\n\"\n"
  23518. ".ascii \" super (test_cmd, self).__init__ ("
  23519. "\\\"test-cmd\\\", gdb.COMMAND_OBSCURE)\\n\"\n"
  23520. ".ascii \" def invoke (self, arg, from_tty):\\n\"\n"
  23521. ".ascii \" print (\\\"test-cmd output, arg = %s\\\" % arg)\\n\"\n"
  23522. ".ascii \"test_cmd ()\\n\"\n"
  23523. ".byte 0\n"
  23524. ".popsection\n"
  23525. );
  23526. @end example
  23527. Loading of inlined scripts requires a properly configured
  23528. @code{auto-load safe-path} (@pxref{Auto-loading safe path}).
  23529. The path to specify in @code{auto-load safe-path} is the path of the file
  23530. containing the @code{.debug_gdb_scripts} section.
  23531. @node Which flavor to choose?
  23532. @subsection Which flavor to choose?
  23533. Given the multiple ways of auto-loading extensions, it might not always
  23534. be clear which one to choose. This section provides some guidance.
  23535. @noindent
  23536. Benefits of the @file{-gdb.@var{ext}} way:
  23537. @itemize @bullet
  23538. @item
  23539. Can be used with file formats that don't support multiple sections.
  23540. @item
  23541. Ease of finding scripts for public libraries.
  23542. Scripts specified in the @code{.debug_gdb_scripts} section are searched for
  23543. in the source search path.
  23544. For publicly installed libraries, e.g., @file{libstdc++}, there typically
  23545. isn't a source directory in which to find the script.
  23546. @item
  23547. Doesn't require source code additions.
  23548. @end itemize
  23549. @noindent
  23550. Benefits of the @code{.debug_gdb_scripts} way:
  23551. @itemize @bullet
  23552. @item
  23553. Works with static linking.
  23554. Scripts for libraries done the @file{-gdb.@var{ext}} way require an objfile to
  23555. trigger their loading. When an application is statically linked the only
  23556. objfile available is the executable, and it is cumbersome to attach all the
  23557. scripts from all the input libraries to the executable's
  23558. @file{-gdb.@var{ext}} script.
  23559. @item
  23560. Works with classes that are entirely inlined.
  23561. Some classes can be entirely inlined, and thus there may not be an associated
  23562. shared library to attach a @file{-gdb.@var{ext}} script to.
  23563. @item
  23564. Scripts needn't be copied out of the source tree.
  23565. In some circumstances, apps can be built out of large collections of internal
  23566. libraries, and the build infrastructure necessary to install the
  23567. @file{-gdb.@var{ext}} scripts in a place where @value{GDBN} can find them is
  23568. cumbersome. It may be easier to specify the scripts in the
  23569. @code{.debug_gdb_scripts} section as relative paths, and add a path to the
  23570. top of the source tree to the source search path.
  23571. @end itemize
  23572. @node Multiple Extension Languages
  23573. @section Multiple Extension Languages
  23574. The Guile and Python extension languages do not share any state,
  23575. and generally do not interfere with each other.
  23576. There are some things to be aware of, however.
  23577. @subsection Python comes first
  23578. Python was @value{GDBN}'s first extension language, and to avoid breaking
  23579. existing behaviour Python comes first. This is generally solved by the
  23580. ``first one wins'' principle. @value{GDBN} maintains a list of enabled
  23581. extension languages, and when it makes a call to an extension language,
  23582. (say to pretty-print a value), it tries each in turn until an extension
  23583. language indicates it has performed the request (e.g., has returned the
  23584. pretty-printed form of a value).
  23585. This extends to errors while performing such requests: If an error happens
  23586. while, for example, trying to pretty-print an object then the error is
  23587. reported and any following extension languages are not tried.
  23588. @node Interpreters
  23589. @chapter Command Interpreters
  23590. @cindex command interpreters
  23591. @value{GDBN} supports multiple command interpreters, and some command
  23592. infrastructure to allow users or user interface writers to switch
  23593. between interpreters or run commands in other interpreters.
  23594. @value{GDBN} currently supports two command interpreters, the console
  23595. interpreter (sometimes called the command-line interpreter or @sc{cli})
  23596. and the machine interface interpreter (or @sc{gdb/mi}). This manual
  23597. describes both of these interfaces in great detail.
  23598. By default, @value{GDBN} will start with the console interpreter.
  23599. However, the user may choose to start @value{GDBN} with another
  23600. interpreter by specifying the @option{-i} or @option{--interpreter}
  23601. startup options. Defined interpreters include:
  23602. @table @code
  23603. @item console
  23604. @cindex console interpreter
  23605. The traditional console or command-line interpreter. This is the most often
  23606. used interpreter with @value{GDBN}. With no interpreter specified at runtime,
  23607. @value{GDBN} will use this interpreter.
  23608. @item mi
  23609. @cindex mi interpreter
  23610. The newest @sc{gdb/mi} interface (currently @code{mi3}). Used primarily
  23611. by programs wishing to use @value{GDBN} as a backend for a debugger GUI
  23612. or an IDE. For more information, see @ref{GDB/MI, ,The @sc{gdb/mi}
  23613. Interface}.
  23614. @item mi3
  23615. @cindex mi3 interpreter
  23616. The @sc{gdb/mi} interface introduced in @value{GDBN} 9.1.
  23617. @item mi2
  23618. @cindex mi2 interpreter
  23619. The @sc{gdb/mi} interface introduced in @value{GDBN} 6.0.
  23620. @item mi1
  23621. @cindex mi1 interpreter
  23622. The @sc{gdb/mi} interface introduced in @value{GDBN} 5.1.
  23623. @end table
  23624. @cindex invoke another interpreter
  23625. @kindex interpreter-exec
  23626. You may execute commands in any interpreter from the current
  23627. interpreter using the appropriate command. If you are running the
  23628. console interpreter, simply use the @code{interpreter-exec} command:
  23629. @smallexample
  23630. interpreter-exec mi "-data-list-register-names"
  23631. @end smallexample
  23632. @sc{gdb/mi} has a similar command, although it is only available in versions of
  23633. @value{GDBN} which support @sc{gdb/mi} version 2 (or greater).
  23634. Note that @code{interpreter-exec} only changes the interpreter for the
  23635. duration of the specified command. It does not change the interpreter
  23636. permanently.
  23637. @cindex start a new independent interpreter
  23638. Although you may only choose a single interpreter at startup, it is
  23639. possible to run an independent interpreter on a specified input/output
  23640. device (usually a tty).
  23641. For example, consider a debugger GUI or IDE that wants to provide a
  23642. @value{GDBN} console view. It may do so by embedding a terminal
  23643. emulator widget in its GUI, starting @value{GDBN} in the traditional
  23644. command-line mode with stdin/stdout/stderr redirected to that
  23645. terminal, and then creating an MI interpreter running on a specified
  23646. input/output device. The console interpreter created by @value{GDBN}
  23647. at startup handles commands the user types in the terminal widget,
  23648. while the GUI controls and synchronizes state with @value{GDBN} using
  23649. the separate MI interpreter.
  23650. To start a new secondary @dfn{user interface} running MI, use the
  23651. @code{new-ui} command:
  23652. @kindex new-ui
  23653. @cindex new user interface
  23654. @smallexample
  23655. new-ui @var{interpreter} @var{tty}
  23656. @end smallexample
  23657. The @var{interpreter} parameter specifies the interpreter to run.
  23658. This accepts the same values as the @code{interpreter-exec} command.
  23659. For example, @samp{console}, @samp{mi}, @samp{mi2}, etc. The
  23660. @var{tty} parameter specifies the name of the bidirectional file the
  23661. interpreter uses for input/output, usually the name of a
  23662. pseudoterminal slave on Unix systems. For example:
  23663. @smallexample
  23664. (@value{GDBP}) new-ui mi /dev/pts/9
  23665. @end smallexample
  23666. @noindent
  23667. runs an MI interpreter on @file{/dev/pts/9}.
  23668. @node TUI
  23669. @chapter @value{GDBN} Text User Interface
  23670. @cindex TUI
  23671. @cindex Text User Interface
  23672. The @value{GDBN} Text User Interface (TUI) is a terminal
  23673. interface which uses the @code{curses} library to show the source
  23674. file, the assembly output, the program registers and @value{GDBN}
  23675. commands in separate text windows. The TUI mode is supported only
  23676. on platforms where a suitable version of the @code{curses} library
  23677. is available.
  23678. The TUI mode is enabled by default when you invoke @value{GDBN} as
  23679. @samp{@value{GDBP} -tui}.
  23680. You can also switch in and out of TUI mode while @value{GDBN} runs by
  23681. using various TUI commands and key bindings, such as @command{tui
  23682. enable} or @kbd{C-x C-a}. @xref{TUI Commands, ,TUI Commands}, and
  23683. @ref{TUI Keys, ,TUI Key Bindings}.
  23684. @menu
  23685. * TUI Overview:: TUI overview
  23686. * TUI Keys:: TUI key bindings
  23687. * TUI Single Key Mode:: TUI single key mode
  23688. * TUI Mouse Support:: TUI mouse support
  23689. * TUI Commands:: TUI-specific commands
  23690. * TUI Configuration:: TUI configuration variables
  23691. @end menu
  23692. @node TUI Overview
  23693. @section TUI Overview
  23694. In TUI mode, @value{GDBN} can display several text windows:
  23695. @table @emph
  23696. @item command
  23697. This window is the @value{GDBN} command window with the @value{GDBN}
  23698. prompt and the @value{GDBN} output. The @value{GDBN} input is still
  23699. managed using readline.
  23700. @item source
  23701. The source window shows the source file of the program. The current
  23702. line and active breakpoints are displayed in this window.
  23703. @item assembly
  23704. The assembly window shows the disassembly output of the program.
  23705. @item register
  23706. This window shows the processor registers. Registers are highlighted
  23707. when their values change.
  23708. @end table
  23709. The source and assembly windows show the current program position
  23710. by highlighting the current line and marking it with a @samp{>} marker.
  23711. Breakpoints are indicated with two markers. The first marker
  23712. indicates the breakpoint type:
  23713. @table @code
  23714. @item B
  23715. Breakpoint which was hit at least once.
  23716. @item b
  23717. Breakpoint which was never hit.
  23718. @item H
  23719. Hardware breakpoint which was hit at least once.
  23720. @item h
  23721. Hardware breakpoint which was never hit.
  23722. @end table
  23723. The second marker indicates whether the breakpoint is enabled or not:
  23724. @table @code
  23725. @item +
  23726. Breakpoint is enabled.
  23727. @item -
  23728. Breakpoint is disabled.
  23729. @end table
  23730. The source, assembly and register windows are updated when the current
  23731. thread changes, when the frame changes, or when the program counter
  23732. changes.
  23733. These windows are not all visible at the same time. The command
  23734. window is always visible. The others can be arranged in several
  23735. layouts:
  23736. @itemize @bullet
  23737. @item
  23738. source only,
  23739. @item
  23740. assembly only,
  23741. @item
  23742. source and assembly,
  23743. @item
  23744. source and registers, or
  23745. @item
  23746. assembly and registers.
  23747. @end itemize
  23748. These are the standard layouts, but other layouts can be defined.
  23749. A status line above the command window shows the following information:
  23750. @table @emph
  23751. @item target
  23752. Indicates the current @value{GDBN} target.
  23753. (@pxref{Targets, ,Specifying a Debugging Target}).
  23754. @item process
  23755. Gives the current process or thread number.
  23756. When no process is being debugged, this field is set to @code{No process}.
  23757. @item function
  23758. Gives the current function name for the selected frame.
  23759. The name is demangled if demangling is turned on (@pxref{Print Settings}).
  23760. When there is no symbol corresponding to the current program counter,
  23761. the string @code{??} is displayed.
  23762. @item line
  23763. Indicates the current line number for the selected frame.
  23764. When the current line number is not known, the string @code{??} is displayed.
  23765. @item pc
  23766. Indicates the current program counter address.
  23767. @end table
  23768. @node TUI Keys
  23769. @section TUI Key Bindings
  23770. @cindex TUI key bindings
  23771. The TUI installs several key bindings in the readline keymaps
  23772. @ifset SYSTEM_READLINE
  23773. (@pxref{Command Line Editing, , , rluserman, GNU Readline Library}).
  23774. @end ifset
  23775. @ifclear SYSTEM_READLINE
  23776. (@pxref{Command Line Editing}).
  23777. @end ifclear
  23778. The following key bindings are installed for both TUI mode and the
  23779. @value{GDBN} standard mode.
  23780. @table @kbd
  23781. @kindex C-x C-a
  23782. @item C-x C-a
  23783. @kindex C-x a
  23784. @itemx C-x a
  23785. @kindex C-x A
  23786. @itemx C-x A
  23787. Enter or leave the TUI mode. When leaving the TUI mode,
  23788. the curses window management stops and @value{GDBN} operates using
  23789. its standard mode, writing on the terminal directly. When reentering
  23790. the TUI mode, control is given back to the curses windows.
  23791. The screen is then refreshed.
  23792. This key binding uses the bindable Readline function
  23793. @code{tui-switch-mode}.
  23794. @kindex C-x 1
  23795. @item C-x 1
  23796. Use a TUI layout with only one window. The layout will
  23797. either be @samp{source} or @samp{assembly}. When the TUI mode
  23798. is not active, it will switch to the TUI mode.
  23799. Think of this key binding as the Emacs @kbd{C-x 1} binding.
  23800. This key binding uses the bindable Readline function
  23801. @code{tui-delete-other-windows}.
  23802. @kindex C-x 2
  23803. @item C-x 2
  23804. Use a TUI layout with at least two windows. When the current
  23805. layout already has two windows, the next layout with two windows is used.
  23806. When a new layout is chosen, one window will always be common to the
  23807. previous layout and the new one.
  23808. Think of it as the Emacs @kbd{C-x 2} binding.
  23809. This key binding uses the bindable Readline function
  23810. @code{tui-change-windows}.
  23811. @kindex C-x o
  23812. @item C-x o
  23813. Change the active window. The TUI associates several key bindings
  23814. (like scrolling and arrow keys) with the active window. This command
  23815. gives the focus to the next TUI window.
  23816. Think of it as the Emacs @kbd{C-x o} binding.
  23817. This key binding uses the bindable Readline function
  23818. @code{tui-other-window}.
  23819. @kindex C-x s
  23820. @item C-x s
  23821. Switch in and out of the TUI SingleKey mode that binds single
  23822. keys to @value{GDBN} commands (@pxref{TUI Single Key Mode}).
  23823. This key binding uses the bindable Readline function
  23824. @code{next-keymap}.
  23825. @end table
  23826. The following key bindings only work in the TUI mode:
  23827. @table @asis
  23828. @kindex PgUp
  23829. @item @key{PgUp}
  23830. Scroll the active window one page up.
  23831. @kindex PgDn
  23832. @item @key{PgDn}
  23833. Scroll the active window one page down.
  23834. @kindex Up
  23835. @item @key{Up}
  23836. Scroll the active window one line up.
  23837. @kindex Down
  23838. @item @key{Down}
  23839. Scroll the active window one line down.
  23840. @kindex Left
  23841. @item @key{Left}
  23842. Scroll the active window one column left.
  23843. @kindex Right
  23844. @item @key{Right}
  23845. Scroll the active window one column right.
  23846. @kindex C-L
  23847. @item @kbd{C-L}
  23848. Refresh the screen.
  23849. @end table
  23850. Because the arrow keys scroll the active window in the TUI mode, they
  23851. are not available for their normal use by readline unless the command
  23852. window has the focus. When another window is active, you must use
  23853. other readline key bindings such as @kbd{C-p}, @kbd{C-n}, @kbd{C-b}
  23854. and @kbd{C-f} to control the command window.
  23855. @node TUI Single Key Mode
  23856. @section TUI Single Key Mode
  23857. @cindex TUI single key mode
  23858. The TUI also provides a @dfn{SingleKey} mode, which binds several
  23859. frequently used @value{GDBN} commands to single keys. Type @kbd{C-x s} to
  23860. switch into this mode, where the following key bindings are used:
  23861. @table @kbd
  23862. @kindex c @r{(SingleKey TUI key)}
  23863. @item c
  23864. continue
  23865. @kindex d @r{(SingleKey TUI key)}
  23866. @item d
  23867. down
  23868. @kindex f @r{(SingleKey TUI key)}
  23869. @item f
  23870. finish
  23871. @kindex n @r{(SingleKey TUI key)}
  23872. @item n
  23873. next
  23874. @kindex o @r{(SingleKey TUI key)}
  23875. @item o
  23876. nexti. The shortcut letter @samp{o} stands for ``step Over''.
  23877. @kindex q @r{(SingleKey TUI key)}
  23878. @item q
  23879. exit the SingleKey mode.
  23880. @kindex r @r{(SingleKey TUI key)}
  23881. @item r
  23882. run
  23883. @kindex s @r{(SingleKey TUI key)}
  23884. @item s
  23885. step
  23886. @kindex i @r{(SingleKey TUI key)}
  23887. @item i
  23888. stepi. The shortcut letter @samp{i} stands for ``step Into''.
  23889. @kindex u @r{(SingleKey TUI key)}
  23890. @item u
  23891. up
  23892. @kindex v @r{(SingleKey TUI key)}
  23893. @item v
  23894. info locals
  23895. @kindex w @r{(SingleKey TUI key)}
  23896. @item w
  23897. where
  23898. @end table
  23899. Other keys temporarily switch to the @value{GDBN} command prompt.
  23900. The key that was pressed is inserted in the editing buffer so that
  23901. it is possible to type most @value{GDBN} commands without interaction
  23902. with the TUI SingleKey mode. Once the command is entered the TUI
  23903. SingleKey mode is restored. The only way to permanently leave
  23904. this mode is by typing @kbd{q} or @kbd{C-x s}.
  23905. @cindex SingleKey keymap name
  23906. If @value{GDBN} was built with Readline 8.0 or later, the TUI
  23907. SingleKey keymap will be named @samp{SingleKey}. This can be used in
  23908. @file{.inputrc} to add additional bindings to this keymap.
  23909. @node TUI Mouse Support
  23910. @section TUI Mouse Support
  23911. @cindex TUI mouse support
  23912. If the curses library supports the mouse, the TUI supports mouse
  23913. actions.
  23914. The mouse wheel scrolls the appropriate window under the mouse cursor.
  23915. The TUI itself does not directly support copying/pasting with the
  23916. mouse. However, on Unix terminals, you can typically press and hold
  23917. the @key{SHIFT} key on your keyboard to temporarily bypass
  23918. @value{GDBN}'s TUI and access the terminal's native mouse copy/paste
  23919. functionality (commonly, click-drag-release or double-click to select
  23920. text, middle-click to paste). This copy/paste works with the
  23921. terminal's selection buffer, as opposed to the TUI's buffer.
  23922. @node TUI Commands
  23923. @section TUI-specific Commands
  23924. @cindex TUI commands
  23925. The TUI has specific commands to control the text windows.
  23926. These commands are always available, even when @value{GDBN} is not in
  23927. the TUI mode. When @value{GDBN} is in the standard mode, most
  23928. of these commands will automatically switch to the TUI mode.
  23929. Note that if @value{GDBN}'s @code{stdout} is not connected to a
  23930. terminal, or @value{GDBN} has been started with the machine interface
  23931. interpreter (@pxref{GDB/MI, ,The @sc{gdb/mi} Interface}), most of
  23932. these commands will fail with an error, because it would not be
  23933. possible or desirable to enable curses window management.
  23934. @table @code
  23935. @item tui enable
  23936. @kindex tui enable
  23937. Activate TUI mode. The last active TUI window layout will be used if
  23938. TUI mode has previously been used in the current debugging session,
  23939. otherwise a default layout is used.
  23940. @item tui disable
  23941. @kindex tui disable
  23942. Disable TUI mode, returning to the console interpreter.
  23943. @anchor{info_win_command}
  23944. @item info win
  23945. @kindex info win
  23946. List the names and sizes of all currently displayed windows.
  23947. @item tui new-layout @var{name} @var{window} @var{weight} @r{[}@var{window} @var{weight}@dots{}@r{]}
  23948. @kindex tui new-layout
  23949. Create a new TUI layout. The new layout will be named @var{name}, and
  23950. can be accessed using the @code{layout} command (see below).
  23951. Each @var{window} parameter is either the name of a window to display,
  23952. or a window description. The windows will be displayed from top to
  23953. bottom in the order listed.
  23954. The names of the windows are the same as the ones given to the
  23955. @code{focus} command (see below); additional, the @code{status}
  23956. window can be specified. Note that, because it is of fixed height,
  23957. the weight assigned to the status window is of no importance. It is
  23958. conventional to use @samp{0} here.
  23959. A window description looks a bit like an invocation of @code{tui
  23960. new-layout}, and is of the form
  23961. @{@r{[}@code{-horizontal}@r{]}@var{window} @var{weight} @r{[}@var{window} @var{weight}@dots{}@r{]}@}.
  23962. This specifies a sub-layout. If @code{-horizontal} is given, the
  23963. windows in this description will be arranged side-by-side, rather than
  23964. top-to-bottom.
  23965. Each @var{weight} is an integer. It is the weight of this window
  23966. relative to all the other windows in the layout. These numbers are
  23967. used to calculate how much of the screen is given to each window.
  23968. For example:
  23969. @example
  23970. (gdb) tui new-layout example src 1 regs 1 status 0 cmd 1
  23971. @end example
  23972. Here, the new layout is called @samp{example}. It shows the source
  23973. and register windows, followed by the status window, and then finally
  23974. the command window. The non-status windows all have the same weight,
  23975. so the terminal will be split into three roughly equal sections.
  23976. Here is a more complex example, showing a horizontal layout:
  23977. @example
  23978. (gdb) tui new-layout example @{-horizontal src 1 asm 1@} 2 status 0 cmd 1
  23979. @end example
  23980. This will result in side-by-side source and assembly windows; with the
  23981. status and command window being beneath these, filling the entire
  23982. width of the terminal. Because they have weight 2, the source and
  23983. assembly windows will be twice the height of the command window.
  23984. @kindex tui layout
  23985. @kindex layout
  23986. @item tui layout @var{name}
  23987. @itemx layout @var{name}
  23988. Changes which TUI windows are displayed. The @var{name} parameter
  23989. controls which layout is shown. It can be either one of the built-in
  23990. layout names, or the name of a layout defined by the user using
  23991. @code{tui new-layout}.
  23992. The built-in layouts are as follows:
  23993. @table @code
  23994. @item next
  23995. Display the next layout.
  23996. @item prev
  23997. Display the previous layout.
  23998. @item src
  23999. Display the source and command windows.
  24000. @item asm
  24001. Display the assembly and command windows.
  24002. @item split
  24003. Display the source, assembly, and command windows.
  24004. @item regs
  24005. When in @code{src} layout display the register, source, and command
  24006. windows. When in @code{asm} or @code{split} layout display the
  24007. register, assembler, and command windows.
  24008. @end table
  24009. @kindex focus
  24010. @item tui focus @var{name}
  24011. @itemx focus @var{name}
  24012. Changes which TUI window is currently active for scrolling. The
  24013. @var{name} parameter can be any of the following:
  24014. @table @code
  24015. @item next
  24016. Make the next window active for scrolling.
  24017. @item prev
  24018. Make the previous window active for scrolling.
  24019. @item src
  24020. Make the source window active for scrolling.
  24021. @item asm
  24022. Make the assembly window active for scrolling.
  24023. @item regs
  24024. Make the register window active for scrolling.
  24025. @item cmd
  24026. Make the command window active for scrolling.
  24027. @end table
  24028. @kindex tui refresh
  24029. @kindex refresh
  24030. @item tui refresh
  24031. @itemx refresh
  24032. Refresh the screen. This is similar to typing @kbd{C-L}.
  24033. @item tui reg @var{group}
  24034. @kindex tui reg
  24035. Changes the register group displayed in the tui register window to
  24036. @var{group}. If the register window is not currently displayed this
  24037. command will cause the register window to be displayed. The list of
  24038. register groups, as well as their order is target specific. The
  24039. following groups are available on most targets:
  24040. @table @code
  24041. @item next
  24042. Repeatedly selecting this group will cause the display to cycle
  24043. through all of the available register groups.
  24044. @item prev
  24045. Repeatedly selecting this group will cause the display to cycle
  24046. through all of the available register groups in the reverse order to
  24047. @var{next}.
  24048. @item general
  24049. Display the general registers.
  24050. @item float
  24051. Display the floating point registers.
  24052. @item system
  24053. Display the system registers.
  24054. @item vector
  24055. Display the vector registers.
  24056. @item all
  24057. Display all registers.
  24058. @end table
  24059. @item update
  24060. @kindex update
  24061. Update the source window and the current execution point.
  24062. @kindex tui window height
  24063. @kindex winheight
  24064. @item tui window height @var{name} +@var{count}
  24065. @itemx tui window height @var{name} -@var{count}
  24066. @itemx winheight @var{name} +@var{count}
  24067. @itemx winheight @var{name} -@var{count}
  24068. Change the height of the window @var{name} by @var{count} lines.
  24069. Positive counts increase the height, while negative counts decrease
  24070. it. The @var{name} parameter can be the name of any currently visible
  24071. window. The names of the currently visible windows can be discovered
  24072. using @kbd{info win} (@pxref{info_win_command,,info win}).
  24073. The set of currently visible windows must always fill the terminal,
  24074. and so, it is only possible to resize on window if there are other
  24075. visible windows that can either give or receive the extra terminal
  24076. space.
  24077. @kindex tui window width
  24078. @kindex winwidth
  24079. @item tui window width @var{name} +@var{count}
  24080. @itemx tui window width @var{name} -@var{count}
  24081. @itemx winwidth @var{name} +@var{count}
  24082. @itemx winwidth @var{name} -@var{count}
  24083. Change the width of the window @var{name} by @var{count} columns.
  24084. Positive counts increase the width, while negative counts decrease it.
  24085. The @var{name} parameter can be the name of any currently visible
  24086. window. The names of the currently visible windows can be discovered
  24087. using @code{info win} (@pxref{info_win_command,,info win}).
  24088. The set of currently visible windows must always fill the terminal,
  24089. and so, it is only possible to resize on window if there are other
  24090. visible windows that can either give or receive the extra terminal
  24091. space.
  24092. @end table
  24093. @node TUI Configuration
  24094. @section TUI Configuration Variables
  24095. @cindex TUI configuration variables
  24096. Several configuration variables control the appearance of TUI windows.
  24097. @table @code
  24098. @item set tui border-kind @var{kind}
  24099. @kindex set tui border-kind
  24100. Select the border appearance for the source, assembly and register windows.
  24101. The possible values are the following:
  24102. @table @code
  24103. @item space
  24104. Use a space character to draw the border.
  24105. @item ascii
  24106. Use @sc{ascii} characters @samp{+}, @samp{-} and @samp{|} to draw the border.
  24107. @item acs
  24108. Use the Alternate Character Set to draw the border. The border is
  24109. drawn using character line graphics if the terminal supports them.
  24110. @end table
  24111. @item set tui border-mode @var{mode}
  24112. @kindex set tui border-mode
  24113. @itemx set tui active-border-mode @var{mode}
  24114. @kindex set tui active-border-mode
  24115. Select the display attributes for the borders of the inactive windows
  24116. or the active window. The @var{mode} can be one of the following:
  24117. @table @code
  24118. @item normal
  24119. Use normal attributes to display the border.
  24120. @item standout
  24121. Use standout mode.
  24122. @item reverse
  24123. Use reverse video mode.
  24124. @item half
  24125. Use half bright mode.
  24126. @item half-standout
  24127. Use half bright and standout mode.
  24128. @item bold
  24129. Use extra bright or bold mode.
  24130. @item bold-standout
  24131. Use extra bright or bold and standout mode.
  24132. @end table
  24133. @item set tui tab-width @var{nchars}
  24134. @kindex set tui tab-width
  24135. @kindex tabset
  24136. Set the width of tab stops to be @var{nchars} characters. This
  24137. setting affects the display of TAB characters in the source and
  24138. assembly windows.
  24139. @item set tui compact-source @r{[}on@r{|}off@r{]}
  24140. @kindex set tui compact-source
  24141. Set whether the TUI source window is displayed in ``compact'' form.
  24142. The default display uses more space for line numbers and starts the
  24143. source text at the next tab stop; the compact display uses only as
  24144. much space as is needed for the line numbers in the current file, and
  24145. only a single space to separate the line numbers from the source.
  24146. @kindex set debug tui
  24147. @item set debug tui @r{[}on|off@r{]}
  24148. Turn on or off display of @value{GDBN} internal debug messages relating
  24149. to the TUI.
  24150. @kindex show debug tui
  24151. @item show debug tui
  24152. Show the current status of displaying @value{GDBN} internal debug
  24153. messages relating to the TUI.
  24154. @end table
  24155. Note that the colors of the TUI borders can be controlled using the
  24156. appropriate @code{set style} commands. @xref{Output Styling}.
  24157. @node Emacs
  24158. @chapter Using @value{GDBN} under @sc{gnu} Emacs
  24159. @cindex Emacs
  24160. @cindex @sc{gnu} Emacs
  24161. A special interface allows you to use @sc{gnu} Emacs to view (and
  24162. edit) the source files for the program you are debugging with
  24163. @value{GDBN}.
  24164. To use this interface, use the command @kbd{M-x gdb} in Emacs. Give the
  24165. executable file you want to debug as an argument. This command starts
  24166. @value{GDBN} as a subprocess of Emacs, with input and output through a newly
  24167. created Emacs buffer.
  24168. @c (Do not use the @code{-tui} option to run @value{GDBN} from Emacs.)
  24169. Running @value{GDBN} under Emacs can be just like running @value{GDBN} normally except for two
  24170. things:
  24171. @itemize @bullet
  24172. @item
  24173. All ``terminal'' input and output goes through an Emacs buffer, called
  24174. the GUD buffer.
  24175. This applies both to @value{GDBN} commands and their output, and to the input
  24176. and output done by the program you are debugging.
  24177. This is useful because it means that you can copy the text of previous
  24178. commands and input them again; you can even use parts of the output
  24179. in this way.
  24180. All the facilities of Emacs' Shell mode are available for interacting
  24181. with your program. In particular, you can send signals the usual
  24182. way---for example, @kbd{C-c C-c} for an interrupt, @kbd{C-c C-z} for a
  24183. stop.
  24184. @item
  24185. @value{GDBN} displays source code through Emacs.
  24186. Each time @value{GDBN} displays a stack frame, Emacs automatically finds the
  24187. source file for that frame and puts an arrow (@samp{=>}) at the
  24188. left margin of the current line. Emacs uses a separate buffer for
  24189. source display, and splits the screen to show both your @value{GDBN} session
  24190. and the source.
  24191. Explicit @value{GDBN} @code{list} or search commands still produce output as
  24192. usual, but you probably have no reason to use them from Emacs.
  24193. @end itemize
  24194. We call this @dfn{text command mode}. Emacs 22.1, and later, also uses
  24195. a graphical mode, enabled by default, which provides further buffers
  24196. that can control the execution and describe the state of your program.
  24197. @xref{GDB Graphical Interface,,, Emacs, The @sc{gnu} Emacs Manual}.
  24198. If you specify an absolute file name when prompted for the @kbd{M-x
  24199. gdb} argument, then Emacs sets your current working directory to where
  24200. your program resides. If you only specify the file name, then Emacs
  24201. sets your current working directory to the directory associated
  24202. with the previous buffer. In this case, @value{GDBN} may find your
  24203. program by searching your environment's @env{PATH} variable, but on
  24204. some operating systems it might not find the source. So, although the
  24205. @value{GDBN} input and output session proceeds normally, the auxiliary
  24206. buffer does not display the current source and line of execution.
  24207. The initial working directory of @value{GDBN} is printed on the top
  24208. line of the GUD buffer and this serves as a default for the commands
  24209. that specify files for @value{GDBN} to operate on. @xref{Files,
  24210. ,Commands to Specify Files}.
  24211. By default, @kbd{M-x gdb} calls the program called @file{gdb}. If you
  24212. need to call @value{GDBN} by a different name (for example, if you
  24213. keep several configurations around, with different names) you can
  24214. customize the Emacs variable @code{gud-gdb-command-name} to run the
  24215. one you want.
  24216. In the GUD buffer, you can use these special Emacs commands in
  24217. addition to the standard Shell mode commands:
  24218. @table @kbd
  24219. @item C-h m
  24220. Describe the features of Emacs' GUD Mode.
  24221. @item C-c C-s
  24222. Execute to another source line, like the @value{GDBN} @code{step} command; also
  24223. update the display window to show the current file and location.
  24224. @item C-c C-n
  24225. Execute to next source line in this function, skipping all function
  24226. calls, like the @value{GDBN} @code{next} command. Then update the display window
  24227. to show the current file and location.
  24228. @item C-c C-i
  24229. Execute one instruction, like the @value{GDBN} @code{stepi} command; update
  24230. display window accordingly.
  24231. @item C-c C-f
  24232. Execute until exit from the selected stack frame, like the @value{GDBN}
  24233. @code{finish} command.
  24234. @item C-c C-r
  24235. Continue execution of your program, like the @value{GDBN} @code{continue}
  24236. command.
  24237. @item C-c <
  24238. Go up the number of frames indicated by the numeric argument
  24239. (@pxref{Arguments, , Numeric Arguments, Emacs, The @sc{gnu} Emacs Manual}),
  24240. like the @value{GDBN} @code{up} command.
  24241. @item C-c >
  24242. Go down the number of frames indicated by the numeric argument, like the
  24243. @value{GDBN} @code{down} command.
  24244. @end table
  24245. In any source file, the Emacs command @kbd{C-x @key{SPC}} (@code{gud-break})
  24246. tells @value{GDBN} to set a breakpoint on the source line point is on.
  24247. In text command mode, if you type @kbd{M-x speedbar}, Emacs displays a
  24248. separate frame which shows a backtrace when the GUD buffer is current.
  24249. Move point to any frame in the stack and type @key{RET} to make it
  24250. become the current frame and display the associated source in the
  24251. source buffer. Alternatively, click @kbd{Mouse-2} to make the
  24252. selected frame become the current one. In graphical mode, the
  24253. speedbar displays watch expressions.
  24254. If you accidentally delete the source-display buffer, an easy way to get
  24255. it back is to type the command @code{f} in the @value{GDBN} buffer, to
  24256. request a frame display; when you run under Emacs, this recreates
  24257. the source buffer if necessary to show you the context of the current
  24258. frame.
  24259. The source files displayed in Emacs are in ordinary Emacs buffers
  24260. which are visiting the source files in the usual way. You can edit
  24261. the files with these buffers if you wish; but keep in mind that @value{GDBN}
  24262. communicates with Emacs in terms of line numbers. If you add or
  24263. delete lines from the text, the line numbers that @value{GDBN} knows cease
  24264. to correspond properly with the code.
  24265. A more detailed description of Emacs' interaction with @value{GDBN} is
  24266. given in the Emacs manual (@pxref{Debuggers,,, Emacs, The @sc{gnu}
  24267. Emacs Manual}).
  24268. @node GDB/MI
  24269. @chapter The @sc{gdb/mi} Interface
  24270. @unnumberedsec Function and Purpose
  24271. @cindex @sc{gdb/mi}, its purpose
  24272. @sc{gdb/mi} is a line based machine oriented text interface to
  24273. @value{GDBN} and is activated by specifying using the
  24274. @option{--interpreter} command line option (@pxref{Mode Options}). It
  24275. is specifically intended to support the development of systems which
  24276. use the debugger as just one small component of a larger system.
  24277. This chapter is a specification of the @sc{gdb/mi} interface. It is written
  24278. in the form of a reference manual.
  24279. Note that @sc{gdb/mi} is still under construction, so some of the
  24280. features described below are incomplete and subject to change
  24281. (@pxref{GDB/MI Development and Front Ends, , @sc{gdb/mi} Development and Front Ends}).
  24282. @unnumberedsec Notation and Terminology
  24283. @cindex notational conventions, for @sc{gdb/mi}
  24284. This chapter uses the following notation:
  24285. @itemize @bullet
  24286. @item
  24287. @code{|} separates two alternatives.
  24288. @item
  24289. @code{[ @var{something} ]} indicates that @var{something} is optional:
  24290. it may or may not be given.
  24291. @item
  24292. @code{( @var{group} )*} means that @var{group} inside the parentheses
  24293. may repeat zero or more times.
  24294. @item
  24295. @code{( @var{group} )+} means that @var{group} inside the parentheses
  24296. may repeat one or more times.
  24297. @item
  24298. @code{"@var{string}"} means a literal @var{string}.
  24299. @end itemize
  24300. @ignore
  24301. @heading Dependencies
  24302. @end ignore
  24303. @menu
  24304. * GDB/MI General Design::
  24305. * GDB/MI Command Syntax::
  24306. * GDB/MI Compatibility with CLI::
  24307. * GDB/MI Development and Front Ends::
  24308. * GDB/MI Output Records::
  24309. * GDB/MI Simple Examples::
  24310. * GDB/MI Command Description Format::
  24311. * GDB/MI Breakpoint Commands::
  24312. * GDB/MI Catchpoint Commands::
  24313. * GDB/MI Program Context::
  24314. * GDB/MI Thread Commands::
  24315. * GDB/MI Ada Tasking Commands::
  24316. * GDB/MI Program Execution::
  24317. * GDB/MI Stack Manipulation::
  24318. * GDB/MI Variable Objects::
  24319. * GDB/MI Data Manipulation::
  24320. * GDB/MI Tracepoint Commands::
  24321. * GDB/MI Symbol Query::
  24322. * GDB/MI File Commands::
  24323. @ignore
  24324. * GDB/MI Kod Commands::
  24325. * GDB/MI Memory Overlay Commands::
  24326. * GDB/MI Signal Handling Commands::
  24327. @end ignore
  24328. * GDB/MI Target Manipulation::
  24329. * GDB/MI File Transfer Commands::
  24330. * GDB/MI Ada Exceptions Commands::
  24331. * GDB/MI Support Commands::
  24332. * GDB/MI Miscellaneous Commands::
  24333. @end menu
  24334. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24335. @node GDB/MI General Design
  24336. @section @sc{gdb/mi} General Design
  24337. @cindex GDB/MI General Design
  24338. Interaction of a @sc{GDB/MI} frontend with @value{GDBN} involves three
  24339. parts---commands sent to @value{GDBN}, responses to those commands
  24340. and notifications. Each command results in exactly one response,
  24341. indicating either successful completion of the command, or an error.
  24342. For the commands that do not resume the target, the response contains the
  24343. requested information. For the commands that resume the target, the
  24344. response only indicates whether the target was successfully resumed.
  24345. Notifications is the mechanism for reporting changes in the state of the
  24346. target, or in @value{GDBN} state, that cannot conveniently be associated with
  24347. a command and reported as part of that command response.
  24348. The important examples of notifications are:
  24349. @itemize @bullet
  24350. @item
  24351. Exec notifications. These are used to report changes in
  24352. target state---when a target is resumed, or stopped. It would not
  24353. be feasible to include this information in response of resuming
  24354. commands, because one resume commands can result in multiple events in
  24355. different threads. Also, quite some time may pass before any event
  24356. happens in the target, while a frontend needs to know whether the resuming
  24357. command itself was successfully executed.
  24358. @item
  24359. Console output, and status notifications. Console output
  24360. notifications are used to report output of CLI commands, as well as
  24361. diagnostics for other commands. Status notifications are used to
  24362. report the progress of a long-running operation. Naturally, including
  24363. this information in command response would mean no output is produced
  24364. until the command is finished, which is undesirable.
  24365. @item
  24366. General notifications. Commands may have various side effects on
  24367. the @value{GDBN} or target state beyond their official purpose. For example,
  24368. a command may change the selected thread. Although such changes can
  24369. be included in command response, using notification allows for more
  24370. orthogonal frontend design.
  24371. @end itemize
  24372. There's no guarantee that whenever an MI command reports an error,
  24373. @value{GDBN} or the target are in any specific state, and especially,
  24374. the state is not reverted to the state before the MI command was
  24375. processed. Therefore, whenever an MI command results in an error,
  24376. we recommend that the frontend refreshes all the information shown in
  24377. the user interface.
  24378. @menu
  24379. * Context management::
  24380. * Asynchronous and non-stop modes::
  24381. * Thread groups::
  24382. @end menu
  24383. @node Context management
  24384. @subsection Context management
  24385. @subsubsection Threads and Frames
  24386. In most cases when @value{GDBN} accesses the target, this access is
  24387. done in context of a specific thread and frame (@pxref{Frames}).
  24388. Often, even when accessing global data, the target requires that a thread
  24389. be specified. The CLI interface maintains the selected thread and frame,
  24390. and supplies them to target on each command. This is convenient,
  24391. because a command line user would not want to specify that information
  24392. explicitly on each command, and because user interacts with
  24393. @value{GDBN} via a single terminal, so no confusion is possible as
  24394. to what thread and frame are the current ones.
  24395. In the case of MI, the concept of selected thread and frame is less
  24396. useful. First, a frontend can easily remember this information
  24397. itself. Second, a graphical frontend can have more than one window,
  24398. each one used for debugging a different thread, and the frontend might
  24399. want to access additional threads for internal purposes. This
  24400. increases the risk that by relying on implicitly selected thread, the
  24401. frontend may be operating on a wrong one. Therefore, each MI command
  24402. should explicitly specify which thread and frame to operate on. To
  24403. make it possible, each MI command accepts the @samp{--thread} and
  24404. @samp{--frame} options, the value to each is @value{GDBN} global
  24405. identifier for thread and frame to operate on.
  24406. Usually, each top-level window in a frontend allows the user to select
  24407. a thread and a frame, and remembers the user selection for further
  24408. operations. However, in some cases @value{GDBN} may suggest that the
  24409. current thread or frame be changed. For example, when stopping on a
  24410. breakpoint it is reasonable to switch to the thread where breakpoint is
  24411. hit. For another example, if the user issues the CLI @samp{thread} or
  24412. @samp{frame} commands via the frontend, it is desirable to change the
  24413. frontend's selection to the one specified by user. @value{GDBN}
  24414. communicates the suggestion to change current thread and frame using the
  24415. @samp{=thread-selected} notification.
  24416. Note that historically, MI shares the selected thread with CLI, so
  24417. frontends used the @code{-thread-select} to execute commands in the
  24418. right context. However, getting this to work right is cumbersome. The
  24419. simplest way is for frontend to emit @code{-thread-select} command
  24420. before every command. This doubles the number of commands that need
  24421. to be sent. The alternative approach is to suppress @code{-thread-select}
  24422. if the selected thread in @value{GDBN} is supposed to be identical to the
  24423. thread the frontend wants to operate on. However, getting this
  24424. optimization right can be tricky. In particular, if the frontend
  24425. sends several commands to @value{GDBN}, and one of the commands changes the
  24426. selected thread, then the behaviour of subsequent commands will
  24427. change. So, a frontend should either wait for response from such
  24428. problematic commands, or explicitly add @code{-thread-select} for
  24429. all subsequent commands. No frontend is known to do this exactly
  24430. right, so it is suggested to just always pass the @samp{--thread} and
  24431. @samp{--frame} options.
  24432. @subsubsection Language
  24433. The execution of several commands depends on which language is selected.
  24434. By default, the current language (@pxref{show language}) is used.
  24435. But for commands known to be language-sensitive, it is recommended
  24436. to use the @samp{--language} option. This option takes one argument,
  24437. which is the name of the language to use while executing the command.
  24438. For instance:
  24439. @smallexample
  24440. -data-evaluate-expression --language c "sizeof (void*)"
  24441. ^done,value="4"
  24442. (gdb)
  24443. @end smallexample
  24444. The valid language names are the same names accepted by the
  24445. @samp{set language} command (@pxref{Manually}), excluding @samp{auto},
  24446. @samp{local} or @samp{unknown}.
  24447. @node Asynchronous and non-stop modes
  24448. @subsection Asynchronous command execution and non-stop mode
  24449. On some targets, @value{GDBN} is capable of processing MI commands
  24450. even while the target is running. This is called @dfn{asynchronous
  24451. command execution} (@pxref{Background Execution}). The frontend may
  24452. specify a preference for asynchronous execution using the
  24453. @code{-gdb-set mi-async 1} command, which should be emitted before
  24454. either running the executable or attaching to the target. After the
  24455. frontend has started the executable or attached to the target, it can
  24456. find if asynchronous execution is enabled using the
  24457. @code{-list-target-features} command.
  24458. @table @code
  24459. @cindex foreground execution
  24460. @cindex background execution
  24461. @cindex asynchronous execution
  24462. @cindex execution, foreground, background and asynchronous
  24463. @kindex set mi-async
  24464. @item -gdb-set mi-async @r{[}on@r{|}off@r{]}
  24465. Set whether MI is in asynchronous mode.
  24466. When @code{off}, which is the default, MI execution commands (e.g.,
  24467. @code{-exec-continue}) are foreground commands, and @value{GDBN} waits
  24468. for the program to stop before processing further commands.
  24469. When @code{on}, MI execution commands are background execution
  24470. commands (e.g., @code{-exec-continue} becomes the equivalent of the
  24471. @code{c&} CLI command), and so @value{GDBN} is capable of processing
  24472. MI commands even while the target is running.
  24473. @kindex show mi-async
  24474. @item -gdb-show mi-async
  24475. Show whether MI asynchronous mode is enabled.
  24476. @end table
  24477. Note: In @value{GDBN} version 7.7 and earlier, this option was called
  24478. @code{target-async} instead of @code{mi-async}, and it had the effect
  24479. of both putting MI in asynchronous mode and making CLI background
  24480. commands possible. CLI background commands are now always possible
  24481. ``out of the box'' if the target supports them. The old spelling is
  24482. kept as a deprecated alias for backwards compatibility.
  24483. Even if @value{GDBN} can accept a command while target is running,
  24484. many commands that access the target do not work when the target is
  24485. running. Therefore, asynchronous command execution is most useful
  24486. when combined with non-stop mode (@pxref{Non-Stop Mode}). Then,
  24487. it is possible to examine the state of one thread, while other threads
  24488. are running.
  24489. When a given thread is running, MI commands that try to access the
  24490. target in the context of that thread may not work, or may work only on
  24491. some targets. In particular, commands that try to operate on thread's
  24492. stack will not work, on any target. Commands that read memory, or
  24493. modify breakpoints, may work or not work, depending on the target. Note
  24494. that even commands that operate on global state, such as @code{print},
  24495. @code{set}, and breakpoint commands, still access the target in the
  24496. context of a specific thread, so frontend should try to find a
  24497. stopped thread and perform the operation on that thread (using the
  24498. @samp{--thread} option).
  24499. Which commands will work in the context of a running thread is
  24500. highly target dependent. However, the two commands
  24501. @code{-exec-interrupt}, to stop a thread, and @code{-thread-info},
  24502. to find the state of a thread, will always work.
  24503. @node Thread groups
  24504. @subsection Thread groups
  24505. @value{GDBN} may be used to debug several processes at the same time.
  24506. On some platforms, @value{GDBN} may support debugging of several
  24507. hardware systems, each one having several cores with several different
  24508. processes running on each core. This section describes the MI
  24509. mechanism to support such debugging scenarios.
  24510. The key observation is that regardless of the structure of the
  24511. target, MI can have a global list of threads, because most commands that
  24512. accept the @samp{--thread} option do not need to know what process that
  24513. thread belongs to. Therefore, it is not necessary to introduce
  24514. neither additional @samp{--process} option, nor an notion of the
  24515. current process in the MI interface. The only strictly new feature
  24516. that is required is the ability to find how the threads are grouped
  24517. into processes.
  24518. To allow the user to discover such grouping, and to support arbitrary
  24519. hierarchy of machines/cores/processes, MI introduces the concept of a
  24520. @dfn{thread group}. Thread group is a collection of threads and other
  24521. thread groups. A thread group always has a string identifier, a type,
  24522. and may have additional attributes specific to the type. A new
  24523. command, @code{-list-thread-groups}, returns the list of top-level
  24524. thread groups, which correspond to processes that @value{GDBN} is
  24525. debugging at the moment. By passing an identifier of a thread group
  24526. to the @code{-list-thread-groups} command, it is possible to obtain
  24527. the members of specific thread group.
  24528. To allow the user to easily discover processes, and other objects, he
  24529. wishes to debug, a concept of @dfn{available thread group} is
  24530. introduced. Available thread group is an thread group that
  24531. @value{GDBN} is not debugging, but that can be attached to, using the
  24532. @code{-target-attach} command. The list of available top-level thread
  24533. groups can be obtained using @samp{-list-thread-groups --available}.
  24534. In general, the content of a thread group may be only retrieved only
  24535. after attaching to that thread group.
  24536. Thread groups are related to inferiors (@pxref{Inferiors Connections and
  24537. Programs}). Each inferior corresponds to a thread group of a special
  24538. type @samp{process}, and some additional operations are permitted on
  24539. such thread groups.
  24540. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24541. @node GDB/MI Command Syntax
  24542. @section @sc{gdb/mi} Command Syntax
  24543. @menu
  24544. * GDB/MI Input Syntax::
  24545. * GDB/MI Output Syntax::
  24546. @end menu
  24547. @node GDB/MI Input Syntax
  24548. @subsection @sc{gdb/mi} Input Syntax
  24549. @cindex input syntax for @sc{gdb/mi}
  24550. @cindex @sc{gdb/mi}, input syntax
  24551. @table @code
  24552. @item @var{command} @expansion{}
  24553. @code{@var{cli-command} | @var{mi-command}}
  24554. @item @var{cli-command} @expansion{}
  24555. @code{[ @var{token} ] @var{cli-command} @var{nl}}, where
  24556. @var{cli-command} is any existing @value{GDBN} CLI command.
  24557. @item @var{mi-command} @expansion{}
  24558. @code{[ @var{token} ] "-" @var{operation} ( " " @var{option} )*
  24559. @code{[} " --" @code{]} ( " " @var{parameter} )* @var{nl}}
  24560. @item @var{token} @expansion{}
  24561. "any sequence of digits"
  24562. @item @var{option} @expansion{}
  24563. @code{"-" @var{parameter} [ " " @var{parameter} ]}
  24564. @item @var{parameter} @expansion{}
  24565. @code{@var{non-blank-sequence} | @var{c-string}}
  24566. @item @var{operation} @expansion{}
  24567. @emph{any of the operations described in this chapter}
  24568. @item @var{non-blank-sequence} @expansion{}
  24569. @emph{anything, provided it doesn't contain special characters such as
  24570. "-", @var{nl}, """ and of course " "}
  24571. @item @var{c-string} @expansion{}
  24572. @code{""" @var{seven-bit-iso-c-string-content} """}
  24573. @item @var{nl} @expansion{}
  24574. @code{CR | CR-LF}
  24575. @end table
  24576. @noindent
  24577. Notes:
  24578. @itemize @bullet
  24579. @item
  24580. The CLI commands are still handled by the @sc{mi} interpreter; their
  24581. output is described below.
  24582. @item
  24583. The @code{@var{token}}, when present, is passed back when the command
  24584. finishes.
  24585. @item
  24586. Some @sc{mi} commands accept optional arguments as part of the parameter
  24587. list. Each option is identified by a leading @samp{-} (dash) and may be
  24588. followed by an optional argument parameter. Options occur first in the
  24589. parameter list and can be delimited from normal parameters using
  24590. @samp{--} (this is useful when some parameters begin with a dash).
  24591. @end itemize
  24592. Pragmatics:
  24593. @itemize @bullet
  24594. @item
  24595. We want easy access to the existing CLI syntax (for debugging).
  24596. @item
  24597. We want it to be easy to spot a @sc{mi} operation.
  24598. @end itemize
  24599. @node GDB/MI Output Syntax
  24600. @subsection @sc{gdb/mi} Output Syntax
  24601. @cindex output syntax of @sc{gdb/mi}
  24602. @cindex @sc{gdb/mi}, output syntax
  24603. The output from @sc{gdb/mi} consists of zero or more out-of-band records
  24604. followed, optionally, by a single result record. This result record
  24605. is for the most recent command. The sequence of output records is
  24606. terminated by @samp{(gdb)}.
  24607. If an input command was prefixed with a @code{@var{token}} then the
  24608. corresponding output for that command will also be prefixed by that same
  24609. @var{token}.
  24610. @table @code
  24611. @item @var{output} @expansion{}
  24612. @code{( @var{out-of-band-record} )* [ @var{result-record} ] "(gdb)" @var{nl}}
  24613. @item @var{result-record} @expansion{}
  24614. @code{ [ @var{token} ] "^" @var{result-class} ( "," @var{result} )* @var{nl}}
  24615. @item @var{out-of-band-record} @expansion{}
  24616. @code{@var{async-record} | @var{stream-record}}
  24617. @item @var{async-record} @expansion{}
  24618. @code{@var{exec-async-output} | @var{status-async-output} | @var{notify-async-output}}
  24619. @item @var{exec-async-output} @expansion{}
  24620. @code{[ @var{token} ] "*" @var{async-output nl}}
  24621. @item @var{status-async-output} @expansion{}
  24622. @code{[ @var{token} ] "+" @var{async-output nl}}
  24623. @item @var{notify-async-output} @expansion{}
  24624. @code{[ @var{token} ] "=" @var{async-output nl}}
  24625. @item @var{async-output} @expansion{}
  24626. @code{@var{async-class} ( "," @var{result} )*}
  24627. @item @var{result-class} @expansion{}
  24628. @code{"done" | "running" | "connected" | "error" | "exit"}
  24629. @item @var{async-class} @expansion{}
  24630. @code{"stopped" | @var{others}} (where @var{others} will be added
  24631. depending on the needs---this is still in development).
  24632. @item @var{result} @expansion{}
  24633. @code{ @var{variable} "=" @var{value}}
  24634. @item @var{variable} @expansion{}
  24635. @code{ @var{string} }
  24636. @item @var{value} @expansion{}
  24637. @code{ @var{const} | @var{tuple} | @var{list} }
  24638. @item @var{const} @expansion{}
  24639. @code{@var{c-string}}
  24640. @item @var{tuple} @expansion{}
  24641. @code{ "@{@}" | "@{" @var{result} ( "," @var{result} )* "@}" }
  24642. @item @var{list} @expansion{}
  24643. @code{ "[]" | "[" @var{value} ( "," @var{value} )* "]" | "["
  24644. @var{result} ( "," @var{result} )* "]" }
  24645. @item @var{stream-record} @expansion{}
  24646. @code{@var{console-stream-output} | @var{target-stream-output} | @var{log-stream-output}}
  24647. @item @var{console-stream-output} @expansion{}
  24648. @code{"~" @var{c-string nl}}
  24649. @item @var{target-stream-output} @expansion{}
  24650. @code{"@@" @var{c-string nl}}
  24651. @item @var{log-stream-output} @expansion{}
  24652. @code{"&" @var{c-string nl}}
  24653. @item @var{nl} @expansion{}
  24654. @code{CR | CR-LF}
  24655. @item @var{token} @expansion{}
  24656. @emph{any sequence of digits}.
  24657. @end table
  24658. @noindent
  24659. Notes:
  24660. @itemize @bullet
  24661. @item
  24662. All output sequences end in a single line containing a period.
  24663. @item
  24664. The @code{@var{token}} is from the corresponding request. Note that
  24665. for all async output, while the token is allowed by the grammar and
  24666. may be output by future versions of @value{GDBN} for select async
  24667. output messages, it is generally omitted. Frontends should treat
  24668. all async output as reporting general changes in the state of the
  24669. target and there should be no need to associate async output to any
  24670. prior command.
  24671. @item
  24672. @cindex status output in @sc{gdb/mi}
  24673. @var{status-async-output} contains on-going status information about the
  24674. progress of a slow operation. It can be discarded. All status output is
  24675. prefixed by @samp{+}.
  24676. @item
  24677. @cindex async output in @sc{gdb/mi}
  24678. @var{exec-async-output} contains asynchronous state change on the target
  24679. (stopped, started, disappeared). All async output is prefixed by
  24680. @samp{*}.
  24681. @item
  24682. @cindex notify output in @sc{gdb/mi}
  24683. @var{notify-async-output} contains supplementary information that the
  24684. client should handle (e.g., a new breakpoint information). All notify
  24685. output is prefixed by @samp{=}.
  24686. @item
  24687. @cindex console output in @sc{gdb/mi}
  24688. @var{console-stream-output} is output that should be displayed as is in the
  24689. console. It is the textual response to a CLI command. All the console
  24690. output is prefixed by @samp{~}.
  24691. @item
  24692. @cindex target output in @sc{gdb/mi}
  24693. @var{target-stream-output} is the output produced by the target program.
  24694. All the target output is prefixed by @samp{@@}.
  24695. @item
  24696. @cindex log output in @sc{gdb/mi}
  24697. @var{log-stream-output} is output text coming from @value{GDBN}'s internals, for
  24698. instance messages that should be displayed as part of an error log. All
  24699. the log output is prefixed by @samp{&}.
  24700. @item
  24701. @cindex list output in @sc{gdb/mi}
  24702. New @sc{gdb/mi} commands should only output @var{lists} containing
  24703. @var{values}.
  24704. @end itemize
  24705. @xref{GDB/MI Stream Records, , @sc{gdb/mi} Stream Records}, for more
  24706. details about the various output records.
  24707. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24708. @node GDB/MI Compatibility with CLI
  24709. @section @sc{gdb/mi} Compatibility with CLI
  24710. @cindex compatibility, @sc{gdb/mi} and CLI
  24711. @cindex @sc{gdb/mi}, compatibility with CLI
  24712. For the developers convenience CLI commands can be entered directly,
  24713. but there may be some unexpected behaviour. For example, commands
  24714. that query the user will behave as if the user replied yes, breakpoint
  24715. command lists are not executed and some CLI commands, such as
  24716. @code{if}, @code{when} and @code{define}, prompt for further input with
  24717. @samp{>}, which is not valid MI output.
  24718. This feature may be removed at some stage in the future and it is
  24719. recommended that front ends use the @code{-interpreter-exec} command
  24720. (@pxref{-interpreter-exec}).
  24721. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24722. @node GDB/MI Development and Front Ends
  24723. @section @sc{gdb/mi} Development and Front Ends
  24724. @cindex @sc{gdb/mi} development
  24725. The application which takes the MI output and presents the state of the
  24726. program being debugged to the user is called a @dfn{front end}.
  24727. Since @sc{gdb/mi} is used by a variety of front ends to @value{GDBN}, changes
  24728. to the MI interface may break existing usage. This section describes how the
  24729. protocol changes and how to request previous version of the protocol when it
  24730. does.
  24731. Some changes in MI need not break a carefully designed front end, and
  24732. for these the MI version will remain unchanged. The following is a
  24733. list of changes that may occur within one level, so front ends should
  24734. parse MI output in a way that can handle them:
  24735. @itemize @bullet
  24736. @item
  24737. New MI commands may be added.
  24738. @item
  24739. New fields may be added to the output of any MI command.
  24740. @item
  24741. The range of values for fields with specified values, e.g.,
  24742. @code{in_scope} (@pxref{-var-update}) may be extended.
  24743. @c The format of field's content e.g type prefix, may change so parse it
  24744. @c at your own risk. Yes, in general?
  24745. @c The order of fields may change? Shouldn't really matter but it might
  24746. @c resolve inconsistencies.
  24747. @end itemize
  24748. If the changes are likely to break front ends, the MI version level
  24749. will be increased by one. The new versions of the MI protocol are not compatible
  24750. with the old versions. Old versions of MI remain available, allowing front ends
  24751. to keep using them until they are modified to use the latest MI version.
  24752. Since @code{--interpreter=mi} always points to the latest MI version, it is
  24753. recommended that front ends request a specific version of MI when launching
  24754. @value{GDBN} (e.g.@: @code{--interpreter=mi2}) to make sure they get an
  24755. interpreter with the MI version they expect.
  24756. The following table gives a summary of the released versions of the MI
  24757. interface: the version number, the version of GDB in which it first appeared
  24758. and the breaking changes compared to the previous version.
  24759. @multitable @columnfractions .05 .05 .9
  24760. @headitem MI version @tab GDB version @tab Breaking changes
  24761. @item
  24762. @center 1
  24763. @tab
  24764. @center 5.1
  24765. @tab
  24766. None
  24767. @item
  24768. @center 2
  24769. @tab
  24770. @center 6.0
  24771. @tab
  24772. @itemize
  24773. @item
  24774. The @code{-environment-pwd}, @code{-environment-directory} and
  24775. @code{-environment-path} commands now returns values using the MI output
  24776. syntax, rather than CLI output syntax.
  24777. @item
  24778. @code{-var-list-children}'s @code{children} result field is now a list, rather
  24779. than a tuple.
  24780. @item
  24781. @code{-var-update}'s @code{changelist} result field is now a list, rather than
  24782. a tuple.
  24783. @end itemize
  24784. @item
  24785. @center 3
  24786. @tab
  24787. @center 9.1
  24788. @tab
  24789. @itemize
  24790. @item
  24791. The output of information about multi-location breakpoints has changed in the
  24792. responses to the @code{-break-insert} and @code{-break-info} commands, as well
  24793. as in the @code{=breakpoint-created} and @code{=breakpoint-modified} events.
  24794. The multiple locations are now placed in a @code{locations} field, whose value
  24795. is a list.
  24796. @end itemize
  24797. @end multitable
  24798. If your front end cannot yet migrate to a more recent version of the
  24799. MI protocol, you can nevertheless selectively enable specific features
  24800. available in those recent MI versions, using the following commands:
  24801. @table @code
  24802. @item -fix-multi-location-breakpoint-output
  24803. Use the output for multi-location breakpoints which was introduced by
  24804. MI 3, even when using MI versions 2 or 1. This command has no
  24805. effect when using MI version 3 or later.
  24806. @end table
  24807. The best way to avoid unexpected changes in MI that might break your front
  24808. end is to make your project known to @value{GDBN} developers and
  24809. follow development on @email{gdb@@sourceware.org} and
  24810. @email{gdb-patches@@sourceware.org}.
  24811. @cindex mailing lists
  24812. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  24813. @node GDB/MI Output Records
  24814. @section @sc{gdb/mi} Output Records
  24815. @menu
  24816. * GDB/MI Result Records::
  24817. * GDB/MI Stream Records::
  24818. * GDB/MI Async Records::
  24819. * GDB/MI Breakpoint Information::
  24820. * GDB/MI Frame Information::
  24821. * GDB/MI Thread Information::
  24822. * GDB/MI Ada Exception Information::
  24823. @end menu
  24824. @node GDB/MI Result Records
  24825. @subsection @sc{gdb/mi} Result Records
  24826. @cindex result records in @sc{gdb/mi}
  24827. @cindex @sc{gdb/mi}, result records
  24828. In addition to a number of out-of-band notifications, the response to a
  24829. @sc{gdb/mi} command includes one of the following result indications:
  24830. @table @code
  24831. @findex ^done
  24832. @item "^done" [ "," @var{results} ]
  24833. The synchronous operation was successful, @code{@var{results}} are the return
  24834. values.
  24835. @item "^running"
  24836. @findex ^running
  24837. This result record is equivalent to @samp{^done}. Historically, it
  24838. was output instead of @samp{^done} if the command has resumed the
  24839. target. This behaviour is maintained for backward compatibility, but
  24840. all frontends should treat @samp{^done} and @samp{^running}
  24841. identically and rely on the @samp{*running} output record to determine
  24842. which threads are resumed.
  24843. @item "^connected"
  24844. @findex ^connected
  24845. @value{GDBN} has connected to a remote target.
  24846. @item "^error" "," "msg=" @var{c-string} [ "," "code=" @var{c-string} ]
  24847. @findex ^error
  24848. The operation failed. The @code{msg=@var{c-string}} variable contains
  24849. the corresponding error message.
  24850. If present, the @code{code=@var{c-string}} variable provides an error
  24851. code on which consumers can rely on to detect the corresponding
  24852. error condition. At present, only one error code is defined:
  24853. @table @samp
  24854. @item "undefined-command"
  24855. Indicates that the command causing the error does not exist.
  24856. @end table
  24857. @item "^exit"
  24858. @findex ^exit
  24859. @value{GDBN} has terminated.
  24860. @end table
  24861. @node GDB/MI Stream Records
  24862. @subsection @sc{gdb/mi} Stream Records
  24863. @cindex @sc{gdb/mi}, stream records
  24864. @cindex stream records in @sc{gdb/mi}
  24865. @value{GDBN} internally maintains a number of output streams: the console, the
  24866. target, and the log. The output intended for each of these streams is
  24867. funneled through the @sc{gdb/mi} interface using @dfn{stream records}.
  24868. Each stream record begins with a unique @dfn{prefix character} which
  24869. identifies its stream (@pxref{GDB/MI Output Syntax, , @sc{gdb/mi} Output
  24870. Syntax}). In addition to the prefix, each stream record contains a
  24871. @code{@var{string-output}}. This is either raw text (with an implicit new
  24872. line) or a quoted C string (which does not contain an implicit newline).
  24873. @table @code
  24874. @item "~" @var{string-output}
  24875. The console output stream contains text that should be displayed in the
  24876. CLI console window. It contains the textual responses to CLI commands.
  24877. @item "@@" @var{string-output}
  24878. The target output stream contains any textual output from the running
  24879. target. This is only present when GDB's event loop is truly
  24880. asynchronous, which is currently only the case for remote targets.
  24881. @item "&" @var{string-output}
  24882. The log stream contains debugging messages being produced by @value{GDBN}'s
  24883. internals.
  24884. @end table
  24885. @node GDB/MI Async Records
  24886. @subsection @sc{gdb/mi} Async Records
  24887. @cindex async records in @sc{gdb/mi}
  24888. @cindex @sc{gdb/mi}, async records
  24889. @dfn{Async} records are used to notify the @sc{gdb/mi} client of
  24890. additional changes that have occurred. Those changes can either be a
  24891. consequence of @sc{gdb/mi} commands (e.g., a breakpoint modified) or a result of
  24892. target activity (e.g., target stopped).
  24893. The following is the list of possible async records:
  24894. @table @code
  24895. @item *running,thread-id="@var{thread}"
  24896. The target is now running. The @var{thread} field can be the global
  24897. thread ID of the thread that is now running, and it can be
  24898. @samp{all} if all threads are running. The frontend should assume
  24899. that no interaction with a running thread is possible after this
  24900. notification is produced. The frontend should not assume that this
  24901. notification is output only once for any command. @value{GDBN} may
  24902. emit this notification several times, either for different threads,
  24903. because it cannot resume all threads together, or even for a single
  24904. thread, if the thread must be stepped though some code before letting
  24905. it run freely.
  24906. @item *stopped,reason="@var{reason}",thread-id="@var{id}",stopped-threads="@var{stopped}",core="@var{core}"
  24907. The target has stopped. The @var{reason} field can have one of the
  24908. following values:
  24909. @table @code
  24910. @item breakpoint-hit
  24911. A breakpoint was reached.
  24912. @item watchpoint-trigger
  24913. A watchpoint was triggered.
  24914. @item read-watchpoint-trigger
  24915. A read watchpoint was triggered.
  24916. @item access-watchpoint-trigger
  24917. An access watchpoint was triggered.
  24918. @item function-finished
  24919. An -exec-finish or similar CLI command was accomplished.
  24920. @item location-reached
  24921. An -exec-until or similar CLI command was accomplished.
  24922. @item watchpoint-scope
  24923. A watchpoint has gone out of scope.
  24924. @item end-stepping-range
  24925. An -exec-next, -exec-next-instruction, -exec-step, -exec-step-instruction or
  24926. similar CLI command was accomplished.
  24927. @item exited-signalled
  24928. The inferior exited because of a signal.
  24929. @item exited
  24930. The inferior exited.
  24931. @item exited-normally
  24932. The inferior exited normally.
  24933. @item signal-received
  24934. A signal was received by the inferior.
  24935. @item solib-event
  24936. The inferior has stopped due to a library being loaded or unloaded.
  24937. This can happen when @code{stop-on-solib-events} (@pxref{Files}) is
  24938. set or when a @code{catch load} or @code{catch unload} catchpoint is
  24939. in use (@pxref{Set Catchpoints}).
  24940. @item fork
  24941. The inferior has forked. This is reported when @code{catch fork}
  24942. (@pxref{Set Catchpoints}) has been used.
  24943. @item vfork
  24944. The inferior has vforked. This is reported in when @code{catch vfork}
  24945. (@pxref{Set Catchpoints}) has been used.
  24946. @item syscall-entry
  24947. The inferior entered a system call. This is reported when @code{catch
  24948. syscall} (@pxref{Set Catchpoints}) has been used.
  24949. @item syscall-return
  24950. The inferior returned from a system call. This is reported when
  24951. @code{catch syscall} (@pxref{Set Catchpoints}) has been used.
  24952. @item exec
  24953. The inferior called @code{exec}. This is reported when @code{catch exec}
  24954. (@pxref{Set Catchpoints}) has been used.
  24955. @end table
  24956. The @var{id} field identifies the global thread ID of the thread
  24957. that directly caused the stop -- for example by hitting a breakpoint.
  24958. Depending on whether all-stop
  24959. mode is in effect (@pxref{All-Stop Mode}), @value{GDBN} may either
  24960. stop all threads, or only the thread that directly triggered the stop.
  24961. If all threads are stopped, the @var{stopped} field will have the
  24962. value of @code{"all"}. Otherwise, the value of the @var{stopped}
  24963. field will be a list of thread identifiers. Presently, this list will
  24964. always include a single thread, but frontend should be prepared to see
  24965. several threads in the list. The @var{core} field reports the
  24966. processor core on which the stop event has happened. This field may be absent
  24967. if such information is not available.
  24968. @item =thread-group-added,id="@var{id}"
  24969. @itemx =thread-group-removed,id="@var{id}"
  24970. A thread group was either added or removed. The @var{id} field
  24971. contains the @value{GDBN} identifier of the thread group. When a thread
  24972. group is added, it generally might not be associated with a running
  24973. process. When a thread group is removed, its id becomes invalid and
  24974. cannot be used in any way.
  24975. @item =thread-group-started,id="@var{id}",pid="@var{pid}"
  24976. A thread group became associated with a running program,
  24977. either because the program was just started or the thread group
  24978. was attached to a program. The @var{id} field contains the
  24979. @value{GDBN} identifier of the thread group. The @var{pid} field
  24980. contains process identifier, specific to the operating system.
  24981. @item =thread-group-exited,id="@var{id}"[,exit-code="@var{code}"]
  24982. A thread group is no longer associated with a running program,
  24983. either because the program has exited, or because it was detached
  24984. from. The @var{id} field contains the @value{GDBN} identifier of the
  24985. thread group. The @var{code} field is the exit code of the inferior; it exists
  24986. only when the inferior exited with some code.
  24987. @item =thread-created,id="@var{id}",group-id="@var{gid}"
  24988. @itemx =thread-exited,id="@var{id}",group-id="@var{gid}"
  24989. A thread either was created, or has exited. The @var{id} field
  24990. contains the global @value{GDBN} identifier of the thread. The @var{gid}
  24991. field identifies the thread group this thread belongs to.
  24992. @item =thread-selected,id="@var{id}"[,frame="@var{frame}"]
  24993. Informs that the selected thread or frame were changed. This notification
  24994. is not emitted as result of the @code{-thread-select} or
  24995. @code{-stack-select-frame} commands, but is emitted whenever an MI command
  24996. that is not documented to change the selected thread and frame actually
  24997. changes them. In particular, invoking, directly or indirectly
  24998. (via user-defined command), the CLI @code{thread} or @code{frame} commands,
  24999. will generate this notification. Changing the thread or frame from another
  25000. user interface (see @ref{Interpreters}) will also generate this notification.
  25001. The @var{frame} field is only present if the newly selected thread is
  25002. stopped. See @ref{GDB/MI Frame Information} for the format of its value.
  25003. We suggest that in response to this notification, front ends
  25004. highlight the selected thread and cause subsequent commands to apply to
  25005. that thread.
  25006. @item =library-loaded,...
  25007. Reports that a new library file was loaded by the program. This
  25008. notification has 5 fields---@var{id}, @var{target-name},
  25009. @var{host-name}, @var{symbols-loaded} and @var{ranges}. The @var{id} field is an
  25010. opaque identifier of the library. For remote debugging case,
  25011. @var{target-name} and @var{host-name} fields give the name of the
  25012. library file on the target, and on the host respectively. For native
  25013. debugging, both those fields have the same value. The
  25014. @var{symbols-loaded} field is emitted only for backward compatibility
  25015. and should not be relied on to convey any useful information. The
  25016. @var{thread-group} field, if present, specifies the id of the thread
  25017. group in whose context the library was loaded. If the field is
  25018. absent, it means the library was loaded in the context of all present
  25019. thread groups. The @var{ranges} field specifies the ranges of addresses belonging
  25020. to this library.
  25021. @item =library-unloaded,...
  25022. Reports that a library was unloaded by the program. This notification
  25023. has 3 fields---@var{id}, @var{target-name} and @var{host-name} with
  25024. the same meaning as for the @code{=library-loaded} notification.
  25025. The @var{thread-group} field, if present, specifies the id of the
  25026. thread group in whose context the library was unloaded. If the field is
  25027. absent, it means the library was unloaded in the context of all present
  25028. thread groups.
  25029. @item =traceframe-changed,num=@var{tfnum},tracepoint=@var{tpnum}
  25030. @itemx =traceframe-changed,end
  25031. Reports that the trace frame was changed and its new number is
  25032. @var{tfnum}. The number of the tracepoint associated with this trace
  25033. frame is @var{tpnum}.
  25034. @item =tsv-created,name=@var{name},initial=@var{initial}
  25035. Reports that the new trace state variable @var{name} is created with
  25036. initial value @var{initial}.
  25037. @item =tsv-deleted,name=@var{name}
  25038. @itemx =tsv-deleted
  25039. Reports that the trace state variable @var{name} is deleted or all
  25040. trace state variables are deleted.
  25041. @item =tsv-modified,name=@var{name},initial=@var{initial}[,current=@var{current}]
  25042. Reports that the trace state variable @var{name} is modified with
  25043. the initial value @var{initial}. The current value @var{current} of
  25044. trace state variable is optional and is reported if the current
  25045. value of trace state variable is known.
  25046. @item =breakpoint-created,bkpt=@{...@}
  25047. @itemx =breakpoint-modified,bkpt=@{...@}
  25048. @itemx =breakpoint-deleted,id=@var{number}
  25049. Reports that a breakpoint was created, modified, or deleted,
  25050. respectively. Only user-visible breakpoints are reported to the MI
  25051. user.
  25052. The @var{bkpt} argument is of the same form as returned by the various
  25053. breakpoint commands; @xref{GDB/MI Breakpoint Commands}. The
  25054. @var{number} is the ordinal number of the breakpoint.
  25055. Note that if a breakpoint is emitted in the result record of a
  25056. command, then it will not also be emitted in an async record.
  25057. @item =record-started,thread-group="@var{id}",method="@var{method}"[,format="@var{format}"]
  25058. @itemx =record-stopped,thread-group="@var{id}"
  25059. Execution log recording was either started or stopped on an
  25060. inferior. The @var{id} is the @value{GDBN} identifier of the thread
  25061. group corresponding to the affected inferior.
  25062. The @var{method} field indicates the method used to record execution. If the
  25063. method in use supports multiple recording formats, @var{format} will be present
  25064. and contain the currently used format. @xref{Process Record and Replay},
  25065. for existing method and format values.
  25066. @item =cmd-param-changed,param=@var{param},value=@var{value}
  25067. Reports that a parameter of the command @code{set @var{param}} is
  25068. changed to @var{value}. In the multi-word @code{set} command,
  25069. the @var{param} is the whole parameter list to @code{set} command.
  25070. For example, In command @code{set check type on}, @var{param}
  25071. is @code{check type} and @var{value} is @code{on}.
  25072. @item =memory-changed,thread-group=@var{id},addr=@var{addr},len=@var{len}[,type="code"]
  25073. Reports that bytes from @var{addr} to @var{data} + @var{len} were
  25074. written in an inferior. The @var{id} is the identifier of the
  25075. thread group corresponding to the affected inferior. The optional
  25076. @code{type="code"} part is reported if the memory written to holds
  25077. executable code.
  25078. @end table
  25079. @node GDB/MI Breakpoint Information
  25080. @subsection @sc{gdb/mi} Breakpoint Information
  25081. When @value{GDBN} reports information about a breakpoint, a
  25082. tracepoint, a watchpoint, or a catchpoint, it uses a tuple with the
  25083. following fields:
  25084. @table @code
  25085. @item number
  25086. The breakpoint number.
  25087. @item type
  25088. The type of the breakpoint. For ordinary breakpoints this will be
  25089. @samp{breakpoint}, but many values are possible.
  25090. @item catch-type
  25091. If the type of the breakpoint is @samp{catchpoint}, then this
  25092. indicates the exact type of catchpoint.
  25093. @item disp
  25094. This is the breakpoint disposition---either @samp{del}, meaning that
  25095. the breakpoint will be deleted at the next stop, or @samp{keep},
  25096. meaning that the breakpoint will not be deleted.
  25097. @item enabled
  25098. This indicates whether the breakpoint is enabled, in which case the
  25099. value is @samp{y}, or disabled, in which case the value is @samp{n}.
  25100. Note that this is not the same as the field @code{enable}.
  25101. @item addr
  25102. The address of the breakpoint. This may be a hexidecimal number,
  25103. giving the address; or the string @samp{<PENDING>}, for a pending
  25104. breakpoint; or the string @samp{<MULTIPLE>}, for a breakpoint with
  25105. multiple locations. This field will not be present if no address can
  25106. be determined. For example, a watchpoint does not have an address.
  25107. @item addr_flags
  25108. Optional field containing any flags related to the address. These flags are
  25109. architecture-dependent; see @ref{Architectures} for their meaning for a
  25110. particular CPU.
  25111. @item func
  25112. If known, the function in which the breakpoint appears.
  25113. If not known, this field is not present.
  25114. @item filename
  25115. The name of the source file which contains this function, if known.
  25116. If not known, this field is not present.
  25117. @item fullname
  25118. The full file name of the source file which contains this function, if
  25119. known. If not known, this field is not present.
  25120. @item line
  25121. The line number at which this breakpoint appears, if known.
  25122. If not known, this field is not present.
  25123. @item at
  25124. If the source file is not known, this field may be provided. If
  25125. provided, this holds the address of the breakpoint, possibly followed
  25126. by a symbol name.
  25127. @item pending
  25128. If this breakpoint is pending, this field is present and holds the
  25129. text used to set the breakpoint, as entered by the user.
  25130. @item evaluated-by
  25131. Where this breakpoint's condition is evaluated, either @samp{host} or
  25132. @samp{target}.
  25133. @item thread
  25134. If this is a thread-specific breakpoint, then this identifies the
  25135. thread in which the breakpoint can trigger.
  25136. @item task
  25137. If this breakpoint is restricted to a particular Ada task, then this
  25138. field will hold the task identifier.
  25139. @item cond
  25140. If the breakpoint is conditional, this is the condition expression.
  25141. @item ignore
  25142. The ignore count of the breakpoint.
  25143. @item enable
  25144. The enable count of the breakpoint.
  25145. @item traceframe-usage
  25146. FIXME.
  25147. @item static-tracepoint-marker-string-id
  25148. For a static tracepoint, the name of the static tracepoint marker.
  25149. @item mask
  25150. For a masked watchpoint, this is the mask.
  25151. @item pass
  25152. A tracepoint's pass count.
  25153. @item original-location
  25154. The location of the breakpoint as originally specified by the user.
  25155. This field is optional.
  25156. @item times
  25157. The number of times the breakpoint has been hit.
  25158. @item installed
  25159. This field is only given for tracepoints. This is either @samp{y},
  25160. meaning that the tracepoint is installed, or @samp{n}, meaning that it
  25161. is not.
  25162. @item what
  25163. Some extra data, the exact contents of which are type-dependent.
  25164. @item locations
  25165. This field is present if the breakpoint has multiple locations. It is also
  25166. exceptionally present if the breakpoint is enabled and has a single, disabled
  25167. location.
  25168. The value is a list of locations. The format of a location is described below.
  25169. @end table
  25170. A location in a multi-location breakpoint is represented as a tuple with the
  25171. following fields:
  25172. @table @code
  25173. @item number
  25174. The location number as a dotted pair, like @samp{1.2}. The first digit is the
  25175. number of the parent breakpoint. The second digit is the number of the
  25176. location within that breakpoint.
  25177. @item enabled
  25178. There are three possible values, with the following meanings:
  25179. @table @code
  25180. @item y
  25181. The location is enabled.
  25182. @item n
  25183. The location is disabled by the user.
  25184. @item N
  25185. The location is disabled because the breakpoint condition is invalid
  25186. at this location.
  25187. @end table
  25188. @item addr
  25189. The address of this location as an hexidecimal number.
  25190. @item addr_flags
  25191. Optional field containing any flags related to the address. These flags are
  25192. architecture-dependent; see @ref{Architectures} for their meaning for a
  25193. particular CPU.
  25194. @item func
  25195. If known, the function in which the location appears.
  25196. If not known, this field is not present.
  25197. @item file
  25198. The name of the source file which contains this location, if known.
  25199. If not known, this field is not present.
  25200. @item fullname
  25201. The full file name of the source file which contains this location, if
  25202. known. If not known, this field is not present.
  25203. @item line
  25204. The line number at which this location appears, if known.
  25205. If not known, this field is not present.
  25206. @item thread-groups
  25207. The thread groups this location is in.
  25208. @end table
  25209. For example, here is what the output of @code{-break-insert}
  25210. (@pxref{GDB/MI Breakpoint Commands}) might be:
  25211. @smallexample
  25212. -> -break-insert main
  25213. <- ^done,bkpt=@{number="1",type="breakpoint",disp="keep",
  25214. enabled="y",addr="0x08048564",func="main",file="myprog.c",
  25215. fullname="/home/nickrob/myprog.c",line="68",thread-groups=["i1"],
  25216. times="0"@}
  25217. <- (gdb)
  25218. @end smallexample
  25219. @node GDB/MI Frame Information
  25220. @subsection @sc{gdb/mi} Frame Information
  25221. Response from many MI commands includes an information about stack
  25222. frame. This information is a tuple that may have the following
  25223. fields:
  25224. @table @code
  25225. @item level
  25226. The level of the stack frame. The innermost frame has the level of
  25227. zero. This field is always present.
  25228. @item func
  25229. The name of the function corresponding to the frame. This field may
  25230. be absent if @value{GDBN} is unable to determine the function name.
  25231. @item addr
  25232. The code address for the frame. This field is always present.
  25233. @item addr_flags
  25234. Optional field containing any flags related to the address. These flags are
  25235. architecture-dependent; see @ref{Architectures} for their meaning for a
  25236. particular CPU.
  25237. @item file
  25238. The name of the source files that correspond to the frame's code
  25239. address. This field may be absent.
  25240. @item line
  25241. The source line corresponding to the frames' code address. This field
  25242. may be absent.
  25243. @item from
  25244. The name of the binary file (either executable or shared library) the
  25245. corresponds to the frame's code address. This field may be absent.
  25246. @end table
  25247. @node GDB/MI Thread Information
  25248. @subsection @sc{gdb/mi} Thread Information
  25249. Whenever @value{GDBN} has to report an information about a thread, it
  25250. uses a tuple with the following fields. The fields are always present unless
  25251. stated otherwise.
  25252. @table @code
  25253. @item id
  25254. The global numeric id assigned to the thread by @value{GDBN}.
  25255. @item target-id
  25256. The target-specific string identifying the thread.
  25257. @item details
  25258. Additional information about the thread provided by the target.
  25259. It is supposed to be human-readable and not interpreted by the
  25260. frontend. This field is optional.
  25261. @item name
  25262. The name of the thread. If the user specified a name using the
  25263. @code{thread name} command, then this name is given. Otherwise, if
  25264. @value{GDBN} can extract the thread name from the target, then that
  25265. name is given. If @value{GDBN} cannot find the thread name, then this
  25266. field is omitted.
  25267. @item state
  25268. The execution state of the thread, either @samp{stopped} or @samp{running},
  25269. depending on whether the thread is presently running.
  25270. @item frame
  25271. The stack frame currently executing in the thread. This field is only present
  25272. if the thread is stopped. Its format is documented in
  25273. @ref{GDB/MI Frame Information}.
  25274. @item core
  25275. The value of this field is an integer number of the processor core the
  25276. thread was last seen on. This field is optional.
  25277. @end table
  25278. @node GDB/MI Ada Exception Information
  25279. @subsection @sc{gdb/mi} Ada Exception Information
  25280. Whenever a @code{*stopped} record is emitted because the program
  25281. stopped after hitting an exception catchpoint (@pxref{Set Catchpoints}),
  25282. @value{GDBN} provides the name of the exception that was raised via
  25283. the @code{exception-name} field. Also, for exceptions that were raised
  25284. with an exception message, @value{GDBN} provides that message via
  25285. the @code{exception-message} field.
  25286. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25287. @node GDB/MI Simple Examples
  25288. @section Simple Examples of @sc{gdb/mi} Interaction
  25289. @cindex @sc{gdb/mi}, simple examples
  25290. This subsection presents several simple examples of interaction using
  25291. the @sc{gdb/mi} interface. In these examples, @samp{->} means that the
  25292. following line is passed to @sc{gdb/mi} as input, while @samp{<-} means
  25293. the output received from @sc{gdb/mi}.
  25294. Note the line breaks shown in the examples are here only for
  25295. readability, they don't appear in the real output.
  25296. @subheading Setting a Breakpoint
  25297. Setting a breakpoint generates synchronous output which contains detailed
  25298. information of the breakpoint.
  25299. @smallexample
  25300. -> -break-insert main
  25301. <- ^done,bkpt=@{number="1",type="breakpoint",disp="keep",
  25302. enabled="y",addr="0x08048564",func="main",file="myprog.c",
  25303. fullname="/home/nickrob/myprog.c",line="68",thread-groups=["i1"],
  25304. times="0"@}
  25305. <- (gdb)
  25306. @end smallexample
  25307. @subheading Program Execution
  25308. Program execution generates asynchronous records and MI gives the
  25309. reason that execution stopped.
  25310. @smallexample
  25311. -> -exec-run
  25312. <- ^running
  25313. <- (gdb)
  25314. <- *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0",
  25315. frame=@{addr="0x08048564",func="main",
  25316. args=[@{name="argc",value="1"@},@{name="argv",value="0xbfc4d4d4"@}],
  25317. file="myprog.c",fullname="/home/nickrob/myprog.c",line="68",
  25318. arch="i386:x86_64"@}
  25319. <- (gdb)
  25320. -> -exec-continue
  25321. <- ^running
  25322. <- (gdb)
  25323. <- *stopped,reason="exited-normally"
  25324. <- (gdb)
  25325. @end smallexample
  25326. @subheading Quitting @value{GDBN}
  25327. Quitting @value{GDBN} just prints the result class @samp{^exit}.
  25328. @smallexample
  25329. -> (gdb)
  25330. <- -gdb-exit
  25331. <- ^exit
  25332. @end smallexample
  25333. Please note that @samp{^exit} is printed immediately, but it might
  25334. take some time for @value{GDBN} to actually exit. During that time, @value{GDBN}
  25335. performs necessary cleanups, including killing programs being debugged
  25336. or disconnecting from debug hardware, so the frontend should wait till
  25337. @value{GDBN} exits and should only forcibly kill @value{GDBN} if it
  25338. fails to exit in reasonable time.
  25339. @subheading A Bad Command
  25340. Here's what happens if you pass a non-existent command:
  25341. @smallexample
  25342. -> -rubbish
  25343. <- ^error,msg="Undefined MI command: rubbish"
  25344. <- (gdb)
  25345. @end smallexample
  25346. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25347. @node GDB/MI Command Description Format
  25348. @section @sc{gdb/mi} Command Description Format
  25349. The remaining sections describe blocks of commands. Each block of
  25350. commands is laid out in a fashion similar to this section.
  25351. @subheading Motivation
  25352. The motivation for this collection of commands.
  25353. @subheading Introduction
  25354. A brief introduction to this collection of commands as a whole.
  25355. @subheading Commands
  25356. For each command in the block, the following is described:
  25357. @subsubheading Synopsis
  25358. @smallexample
  25359. -command @var{args}@dots{}
  25360. @end smallexample
  25361. @subsubheading Result
  25362. @subsubheading @value{GDBN} Command
  25363. The corresponding @value{GDBN} CLI command(s), if any.
  25364. @subsubheading Example
  25365. Example(s) formatted for readability. Some of the described commands have
  25366. not been implemented yet and these are labeled N.A.@: (not available).
  25367. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25368. @node GDB/MI Breakpoint Commands
  25369. @section @sc{gdb/mi} Breakpoint Commands
  25370. @cindex breakpoint commands for @sc{gdb/mi}
  25371. @cindex @sc{gdb/mi}, breakpoint commands
  25372. This section documents @sc{gdb/mi} commands for manipulating
  25373. breakpoints.
  25374. @subheading The @code{-break-after} Command
  25375. @findex -break-after
  25376. @subsubheading Synopsis
  25377. @smallexample
  25378. -break-after @var{number} @var{count}
  25379. @end smallexample
  25380. The breakpoint number @var{number} is not in effect until it has been
  25381. hit @var{count} times. To see how this is reflected in the output of
  25382. the @samp{-break-list} command, see the description of the
  25383. @samp{-break-list} command below.
  25384. @subsubheading @value{GDBN} Command
  25385. The corresponding @value{GDBN} command is @samp{ignore}.
  25386. @subsubheading Example
  25387. @smallexample
  25388. (gdb)
  25389. -break-insert main
  25390. ^done,bkpt=@{number="1",type="breakpoint",disp="keep",
  25391. enabled="y",addr="0x000100d0",func="main",file="hello.c",
  25392. fullname="/home/foo/hello.c",line="5",thread-groups=["i1"],
  25393. times="0"@}
  25394. (gdb)
  25395. -break-after 1 3
  25396. ~
  25397. ^done
  25398. (gdb)
  25399. -break-list
  25400. ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
  25401. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25402. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25403. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25404. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25405. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25406. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25407. body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
  25408. addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
  25409. line="5",thread-groups=["i1"],times="0",ignore="3"@}]@}
  25410. (gdb)
  25411. @end smallexample
  25412. @ignore
  25413. @subheading The @code{-break-catch} Command
  25414. @findex -break-catch
  25415. @end ignore
  25416. @subheading The @code{-break-commands} Command
  25417. @findex -break-commands
  25418. @subsubheading Synopsis
  25419. @smallexample
  25420. -break-commands @var{number} [ @var{command1} ... @var{commandN} ]
  25421. @end smallexample
  25422. Specifies the CLI commands that should be executed when breakpoint
  25423. @var{number} is hit. The parameters @var{command1} to @var{commandN}
  25424. are the commands. If no command is specified, any previously-set
  25425. commands are cleared. @xref{Break Commands}. Typical use of this
  25426. functionality is tracing a program, that is, printing of values of
  25427. some variables whenever breakpoint is hit and then continuing.
  25428. @subsubheading @value{GDBN} Command
  25429. The corresponding @value{GDBN} command is @samp{commands}.
  25430. @subsubheading Example
  25431. @smallexample
  25432. (gdb)
  25433. -break-insert main
  25434. ^done,bkpt=@{number="1",type="breakpoint",disp="keep",
  25435. enabled="y",addr="0x000100d0",func="main",file="hello.c",
  25436. fullname="/home/foo/hello.c",line="5",thread-groups=["i1"],
  25437. times="0"@}
  25438. (gdb)
  25439. -break-commands 1 "print v" "continue"
  25440. ^done
  25441. (gdb)
  25442. @end smallexample
  25443. @subheading The @code{-break-condition} Command
  25444. @findex -break-condition
  25445. @subsubheading Synopsis
  25446. @smallexample
  25447. -break-condition [ --force ] @var{number} [ @var{expr} ]
  25448. @end smallexample
  25449. Breakpoint @var{number} will stop the program only if the condition in
  25450. @var{expr} is true. The condition becomes part of the
  25451. @samp{-break-list} output (see the description of the @samp{-break-list}
  25452. command below). If the @samp{--force} flag is passed, the condition
  25453. is forcibly defined even when it is invalid for all locations of
  25454. breakpoint @var{number}. If the @var{expr} argument is omitted,
  25455. breakpoint @var{number} becomes unconditional.
  25456. @subsubheading @value{GDBN} Command
  25457. The corresponding @value{GDBN} command is @samp{condition}.
  25458. @subsubheading Example
  25459. @smallexample
  25460. (gdb)
  25461. -break-condition 1 1
  25462. ^done
  25463. (gdb)
  25464. -break-list
  25465. ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
  25466. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25467. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25468. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25469. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25470. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25471. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25472. body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
  25473. addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
  25474. line="5",cond="1",thread-groups=["i1"],times="0",ignore="3"@}]@}
  25475. (gdb)
  25476. @end smallexample
  25477. @subheading The @code{-break-delete} Command
  25478. @findex -break-delete
  25479. @subsubheading Synopsis
  25480. @smallexample
  25481. -break-delete ( @var{breakpoint} )+
  25482. @end smallexample
  25483. Delete the breakpoint(s) whose number(s) are specified in the argument
  25484. list. This is obviously reflected in the breakpoint list.
  25485. @subsubheading @value{GDBN} Command
  25486. The corresponding @value{GDBN} command is @samp{delete}.
  25487. @subsubheading Example
  25488. @smallexample
  25489. (gdb)
  25490. -break-delete 1
  25491. ^done
  25492. (gdb)
  25493. -break-list
  25494. ^done,BreakpointTable=@{nr_rows="0",nr_cols="6",
  25495. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25496. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25497. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25498. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25499. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25500. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25501. body=[]@}
  25502. (gdb)
  25503. @end smallexample
  25504. @subheading The @code{-break-disable} Command
  25505. @findex -break-disable
  25506. @subsubheading Synopsis
  25507. @smallexample
  25508. -break-disable ( @var{breakpoint} )+
  25509. @end smallexample
  25510. Disable the named @var{breakpoint}(s). The field @samp{enabled} in the
  25511. break list is now set to @samp{n} for the named @var{breakpoint}(s).
  25512. @subsubheading @value{GDBN} Command
  25513. The corresponding @value{GDBN} command is @samp{disable}.
  25514. @subsubheading Example
  25515. @smallexample
  25516. (gdb)
  25517. -break-disable 2
  25518. ^done
  25519. (gdb)
  25520. -break-list
  25521. ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
  25522. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25523. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25524. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25525. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25526. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25527. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25528. body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="n",
  25529. addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
  25530. line="5",thread-groups=["i1"],times="0"@}]@}
  25531. (gdb)
  25532. @end smallexample
  25533. @subheading The @code{-break-enable} Command
  25534. @findex -break-enable
  25535. @subsubheading Synopsis
  25536. @smallexample
  25537. -break-enable ( @var{breakpoint} )+
  25538. @end smallexample
  25539. Enable (previously disabled) @var{breakpoint}(s).
  25540. @subsubheading @value{GDBN} Command
  25541. The corresponding @value{GDBN} command is @samp{enable}.
  25542. @subsubheading Example
  25543. @smallexample
  25544. (gdb)
  25545. -break-enable 2
  25546. ^done
  25547. (gdb)
  25548. -break-list
  25549. ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
  25550. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25551. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25552. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25553. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25554. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25555. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25556. body=[bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y",
  25557. addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
  25558. line="5",thread-groups=["i1"],times="0"@}]@}
  25559. (gdb)
  25560. @end smallexample
  25561. @subheading The @code{-break-info} Command
  25562. @findex -break-info
  25563. @subsubheading Synopsis
  25564. @smallexample
  25565. -break-info @var{breakpoint}
  25566. @end smallexample
  25567. @c REDUNDANT???
  25568. Get information about a single breakpoint.
  25569. The result is a table of breakpoints. @xref{GDB/MI Breakpoint
  25570. Information}, for details on the format of each breakpoint in the
  25571. table.
  25572. @subsubheading @value{GDBN} Command
  25573. The corresponding @value{GDBN} command is @samp{info break @var{breakpoint}}.
  25574. @subsubheading Example
  25575. N.A.
  25576. @subheading The @code{-break-insert} Command
  25577. @findex -break-insert
  25578. @anchor{-break-insert}
  25579. @subsubheading Synopsis
  25580. @smallexample
  25581. -break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ] [ --qualified ]
  25582. [ -c @var{condition} ] [ --force-condition ] [ -i @var{ignore-count} ]
  25583. [ -p @var{thread-id} ] [ @var{location} ]
  25584. @end smallexample
  25585. @noindent
  25586. If specified, @var{location}, can be one of:
  25587. @table @var
  25588. @item linespec location
  25589. A linespec location. @xref{Linespec Locations}.
  25590. @item explicit location
  25591. An explicit location. @sc{gdb/mi} explicit locations are
  25592. analogous to the CLI's explicit locations using the option names
  25593. listed below. @xref{Explicit Locations}.
  25594. @table @samp
  25595. @item --source @var{filename}
  25596. The source file name of the location. This option requires the use
  25597. of either @samp{--function} or @samp{--line}.
  25598. @item --function @var{function}
  25599. The name of a function or method.
  25600. @item --label @var{label}
  25601. The name of a label.
  25602. @item --line @var{lineoffset}
  25603. An absolute or relative line offset from the start of the location.
  25604. @end table
  25605. @item address location
  25606. An address location, *@var{address}. @xref{Address Locations}.
  25607. @end table
  25608. @noindent
  25609. The possible optional parameters of this command are:
  25610. @table @samp
  25611. @item -t
  25612. Insert a temporary breakpoint.
  25613. @item -h
  25614. Insert a hardware breakpoint.
  25615. @item -f
  25616. If @var{location} cannot be parsed (for example if it
  25617. refers to unknown files or functions), create a pending
  25618. breakpoint. Without this flag, @value{GDBN} will report
  25619. an error, and won't create a breakpoint, if @var{location}
  25620. cannot be parsed.
  25621. @item -d
  25622. Create a disabled breakpoint.
  25623. @item -a
  25624. Create a tracepoint. @xref{Tracepoints}. When this parameter
  25625. is used together with @samp{-h}, a fast tracepoint is created.
  25626. @item -c @var{condition}
  25627. Make the breakpoint conditional on @var{condition}.
  25628. @item --force-condition
  25629. Forcibly define the breakpoint even if the condition is invalid at
  25630. all of the breakpoint locations.
  25631. @item -i @var{ignore-count}
  25632. Initialize the @var{ignore-count}.
  25633. @item -p @var{thread-id}
  25634. Restrict the breakpoint to the thread with the specified global
  25635. @var{thread-id}.
  25636. @item --qualified
  25637. This option makes @value{GDBN} interpret a function name specified as
  25638. a complete fully-qualified name.
  25639. @end table
  25640. @subsubheading Result
  25641. @xref{GDB/MI Breakpoint Information}, for details on the format of the
  25642. resulting breakpoint.
  25643. Note: this format is open to change.
  25644. @c An out-of-band breakpoint instead of part of the result?
  25645. @subsubheading @value{GDBN} Command
  25646. The corresponding @value{GDBN} commands are @samp{break}, @samp{tbreak},
  25647. @samp{hbreak}, and @samp{thbreak}. @c and @samp{rbreak}.
  25648. @subsubheading Example
  25649. @smallexample
  25650. (gdb)
  25651. -break-insert main
  25652. ^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",
  25653. fullname="/home/foo/recursive2.c,line="4",thread-groups=["i1"],
  25654. times="0"@}
  25655. (gdb)
  25656. -break-insert -t foo
  25657. ^done,bkpt=@{number="2",addr="0x00010774",file="recursive2.c",
  25658. fullname="/home/foo/recursive2.c,line="11",thread-groups=["i1"],
  25659. times="0"@}
  25660. (gdb)
  25661. -break-list
  25662. ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
  25663. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25664. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25665. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25666. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25667. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25668. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25669. body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
  25670. addr="0x0001072c", func="main",file="recursive2.c",
  25671. fullname="/home/foo/recursive2.c,"line="4",thread-groups=["i1"],
  25672. times="0"@},
  25673. bkpt=@{number="2",type="breakpoint",disp="del",enabled="y",
  25674. addr="0x00010774",func="foo",file="recursive2.c",
  25675. fullname="/home/foo/recursive2.c",line="11",thread-groups=["i1"],
  25676. times="0"@}]@}
  25677. (gdb)
  25678. @c -break-insert -r foo.*
  25679. @c ~int foo(int, int);
  25680. @c ^done,bkpt=@{number="3",addr="0x00010774",file="recursive2.c,
  25681. @c "fullname="/home/foo/recursive2.c",line="11",thread-groups=["i1"],
  25682. @c times="0"@}
  25683. @c (gdb)
  25684. @end smallexample
  25685. @subheading The @code{-dprintf-insert} Command
  25686. @findex -dprintf-insert
  25687. @subsubheading Synopsis
  25688. @smallexample
  25689. -dprintf-insert [ -t ] [ -f ] [ -d ] [ --qualified ]
  25690. [ -c @var{condition} ] [--force-condition] [ -i @var{ignore-count} ]
  25691. [ -p @var{thread-id} ] [ @var{location} ] [ @var{format} ]
  25692. [ @var{argument} ]
  25693. @end smallexample
  25694. @noindent
  25695. If supplied, @var{location} and @code{--qualified} may be specified
  25696. the same way as for the @code{-break-insert} command.
  25697. @xref{-break-insert}.
  25698. The possible optional parameters of this command are:
  25699. @table @samp
  25700. @item -t
  25701. Insert a temporary breakpoint.
  25702. @item -f
  25703. If @var{location} cannot be parsed (for example, if it
  25704. refers to unknown files or functions), create a pending
  25705. breakpoint. Without this flag, @value{GDBN} will report
  25706. an error, and won't create a breakpoint, if @var{location}
  25707. cannot be parsed.
  25708. @item -d
  25709. Create a disabled breakpoint.
  25710. @item -c @var{condition}
  25711. Make the breakpoint conditional on @var{condition}.
  25712. @item --force-condition
  25713. Forcibly define the breakpoint even if the condition is invalid at
  25714. all of the breakpoint locations.
  25715. @item -i @var{ignore-count}
  25716. Set the ignore count of the breakpoint (@pxref{Conditions, ignore count})
  25717. to @var{ignore-count}.
  25718. @item -p @var{thread-id}
  25719. Restrict the breakpoint to the thread with the specified global
  25720. @var{thread-id}.
  25721. @end table
  25722. @subsubheading Result
  25723. @xref{GDB/MI Breakpoint Information}, for details on the format of the
  25724. resulting breakpoint.
  25725. @c An out-of-band breakpoint instead of part of the result?
  25726. @subsubheading @value{GDBN} Command
  25727. The corresponding @value{GDBN} command is @samp{dprintf}.
  25728. @subsubheading Example
  25729. @smallexample
  25730. (gdb)
  25731. 4-dprintf-insert foo "At foo entry\n"
  25732. 4^done,bkpt=@{number="1",type="dprintf",disp="keep",enabled="y",
  25733. addr="0x000000000040061b",func="foo",file="mi-dprintf.c",
  25734. fullname="mi-dprintf.c",line="25",thread-groups=["i1"],
  25735. times="0",script=@{"printf \"At foo entry\\n\"","continue"@},
  25736. original-location="foo"@}
  25737. (gdb)
  25738. 5-dprintf-insert 26 "arg=%d, g=%d\n" arg g
  25739. 5^done,bkpt=@{number="2",type="dprintf",disp="keep",enabled="y",
  25740. addr="0x000000000040062a",func="foo",file="mi-dprintf.c",
  25741. fullname="mi-dprintf.c",line="26",thread-groups=["i1"],
  25742. times="0",script=@{"printf \"arg=%d, g=%d\\n\", arg, g","continue"@},
  25743. original-location="mi-dprintf.c:26"@}
  25744. (gdb)
  25745. @end smallexample
  25746. @subheading The @code{-break-list} Command
  25747. @findex -break-list
  25748. @subsubheading Synopsis
  25749. @smallexample
  25750. -break-list
  25751. @end smallexample
  25752. Displays the list of inserted breakpoints, showing the following fields:
  25753. @table @samp
  25754. @item Number
  25755. number of the breakpoint
  25756. @item Type
  25757. type of the breakpoint: @samp{breakpoint} or @samp{watchpoint}
  25758. @item Disposition
  25759. should the breakpoint be deleted or disabled when it is hit: @samp{keep}
  25760. or @samp{nokeep}
  25761. @item Enabled
  25762. is the breakpoint enabled or no: @samp{y} or @samp{n}
  25763. @item Address
  25764. memory location at which the breakpoint is set
  25765. @item What
  25766. logical location of the breakpoint, expressed by function name, file
  25767. name, line number
  25768. @item Thread-groups
  25769. list of thread groups to which this breakpoint applies
  25770. @item Times
  25771. number of times the breakpoint has been hit
  25772. @end table
  25773. If there are no breakpoints or watchpoints, the @code{BreakpointTable}
  25774. @code{body} field is an empty list.
  25775. @subsubheading @value{GDBN} Command
  25776. The corresponding @value{GDBN} command is @samp{info break}.
  25777. @subsubheading Example
  25778. @smallexample
  25779. (gdb)
  25780. -break-list
  25781. ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
  25782. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25783. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25784. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25785. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25786. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25787. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25788. body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
  25789. addr="0x000100d0",func="main",file="hello.c",line="5",thread-groups=["i1"],
  25790. times="0"@},
  25791. bkpt=@{number="2",type="breakpoint",disp="keep",enabled="y",
  25792. addr="0x00010114",func="foo",file="hello.c",fullname="/home/foo/hello.c",
  25793. line="13",thread-groups=["i1"],times="0"@}]@}
  25794. (gdb)
  25795. @end smallexample
  25796. Here's an example of the result when there are no breakpoints:
  25797. @smallexample
  25798. (gdb)
  25799. -break-list
  25800. ^done,BreakpointTable=@{nr_rows="0",nr_cols="6",
  25801. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25802. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25803. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25804. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25805. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25806. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25807. body=[]@}
  25808. (gdb)
  25809. @end smallexample
  25810. @subheading The @code{-break-passcount} Command
  25811. @findex -break-passcount
  25812. @subsubheading Synopsis
  25813. @smallexample
  25814. -break-passcount @var{tracepoint-number} @var{passcount}
  25815. @end smallexample
  25816. Set the passcount for tracepoint @var{tracepoint-number} to
  25817. @var{passcount}. If the breakpoint referred to by @var{tracepoint-number}
  25818. is not a tracepoint, error is emitted. This corresponds to CLI
  25819. command @samp{passcount}.
  25820. @subheading The @code{-break-watch} Command
  25821. @findex -break-watch
  25822. @subsubheading Synopsis
  25823. @smallexample
  25824. -break-watch [ -a | -r ]
  25825. @end smallexample
  25826. Create a watchpoint. With the @samp{-a} option it will create an
  25827. @dfn{access} watchpoint, i.e., a watchpoint that triggers either on a
  25828. read from or on a write to the memory location. With the @samp{-r}
  25829. option, the watchpoint created is a @dfn{read} watchpoint, i.e., it will
  25830. trigger only when the memory location is accessed for reading. Without
  25831. either of the options, the watchpoint created is a regular watchpoint,
  25832. i.e., it will trigger when the memory location is accessed for writing.
  25833. @xref{Set Watchpoints, , Setting Watchpoints}.
  25834. Note that @samp{-break-list} will report a single list of watchpoints and
  25835. breakpoints inserted.
  25836. @subsubheading @value{GDBN} Command
  25837. The corresponding @value{GDBN} commands are @samp{watch}, @samp{awatch}, and
  25838. @samp{rwatch}.
  25839. @subsubheading Example
  25840. Setting a watchpoint on a variable in the @code{main} function:
  25841. @smallexample
  25842. (gdb)
  25843. -break-watch x
  25844. ^done,wpt=@{number="2",exp="x"@}
  25845. (gdb)
  25846. -exec-continue
  25847. ^running
  25848. (gdb)
  25849. *stopped,reason="watchpoint-trigger",wpt=@{number="2",exp="x"@},
  25850. value=@{old="-268439212",new="55"@},
  25851. frame=@{func="main",args=[],file="recursive2.c",
  25852. fullname="/home/foo/bar/recursive2.c",line="5",arch="i386:x86_64"@}
  25853. (gdb)
  25854. @end smallexample
  25855. Setting a watchpoint on a variable local to a function. @value{GDBN} will stop
  25856. the program execution twice: first for the variable changing value, then
  25857. for the watchpoint going out of scope.
  25858. @smallexample
  25859. (gdb)
  25860. -break-watch C
  25861. ^done,wpt=@{number="5",exp="C"@}
  25862. (gdb)
  25863. -exec-continue
  25864. ^running
  25865. (gdb)
  25866. *stopped,reason="watchpoint-trigger",
  25867. wpt=@{number="5",exp="C"@},value=@{old="-276895068",new="3"@},
  25868. frame=@{func="callee4",args=[],
  25869. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  25870. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13",
  25871. arch="i386:x86_64"@}
  25872. (gdb)
  25873. -exec-continue
  25874. ^running
  25875. (gdb)
  25876. *stopped,reason="watchpoint-scope",wpnum="5",
  25877. frame=@{func="callee3",args=[@{name="strarg",
  25878. value="0x11940 \"A string argument.\""@}],
  25879. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  25880. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18",
  25881. arch="i386:x86_64"@}
  25882. (gdb)
  25883. @end smallexample
  25884. Listing breakpoints and watchpoints, at different points in the program
  25885. execution. Note that once the watchpoint goes out of scope, it is
  25886. deleted.
  25887. @smallexample
  25888. (gdb)
  25889. -break-watch C
  25890. ^done,wpt=@{number="2",exp="C"@}
  25891. (gdb)
  25892. -break-list
  25893. ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
  25894. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25895. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25896. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25897. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25898. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25899. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25900. body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
  25901. addr="0x00010734",func="callee4",
  25902. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  25903. fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c"line="8",thread-groups=["i1"],
  25904. times="1"@},
  25905. bkpt=@{number="2",type="watchpoint",disp="keep",
  25906. enabled="y",addr="",what="C",thread-groups=["i1"],times="0"@}]@}
  25907. (gdb)
  25908. -exec-continue
  25909. ^running
  25910. (gdb)
  25911. *stopped,reason="watchpoint-trigger",wpt=@{number="2",exp="C"@},
  25912. value=@{old="-276895068",new="3"@},
  25913. frame=@{func="callee4",args=[],
  25914. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  25915. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13",
  25916. arch="i386:x86_64"@}
  25917. (gdb)
  25918. -break-list
  25919. ^done,BreakpointTable=@{nr_rows="2",nr_cols="6",
  25920. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25921. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25922. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25923. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25924. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25925. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25926. body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
  25927. addr="0x00010734",func="callee4",
  25928. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  25929. fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",thread-groups=["i1"],
  25930. times="1"@},
  25931. bkpt=@{number="2",type="watchpoint",disp="keep",
  25932. enabled="y",addr="",what="C",thread-groups=["i1"],times="-5"@}]@}
  25933. (gdb)
  25934. -exec-continue
  25935. ^running
  25936. ^done,reason="watchpoint-scope",wpnum="2",
  25937. frame=@{func="callee3",args=[@{name="strarg",
  25938. value="0x11940 \"A string argument.\""@}],
  25939. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  25940. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18",
  25941. arch="i386:x86_64"@}
  25942. (gdb)
  25943. -break-list
  25944. ^done,BreakpointTable=@{nr_rows="1",nr_cols="6",
  25945. hdr=[@{width="3",alignment="-1",col_name="number",colhdr="Num"@},
  25946. @{width="14",alignment="-1",col_name="type",colhdr="Type"@},
  25947. @{width="4",alignment="-1",col_name="disp",colhdr="Disp"@},
  25948. @{width="3",alignment="-1",col_name="enabled",colhdr="Enb"@},
  25949. @{width="10",alignment="-1",col_name="addr",colhdr="Address"@},
  25950. @{width="40",alignment="2",col_name="what",colhdr="What"@}],
  25951. body=[bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
  25952. addr="0x00010734",func="callee4",
  25953. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  25954. fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
  25955. thread-groups=["i1"],times="1"@}]@}
  25956. (gdb)
  25957. @end smallexample
  25958. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  25959. @node GDB/MI Catchpoint Commands
  25960. @section @sc{gdb/mi} Catchpoint Commands
  25961. This section documents @sc{gdb/mi} commands for manipulating
  25962. catchpoints.
  25963. @menu
  25964. * Shared Library GDB/MI Catchpoint Commands::
  25965. * Ada Exception GDB/MI Catchpoint Commands::
  25966. * C++ Exception GDB/MI Catchpoint Commands::
  25967. @end menu
  25968. @node Shared Library GDB/MI Catchpoint Commands
  25969. @subsection Shared Library @sc{gdb/mi} Catchpoints
  25970. @subheading The @code{-catch-load} Command
  25971. @findex -catch-load
  25972. @subsubheading Synopsis
  25973. @smallexample
  25974. -catch-load [ -t ] [ -d ] @var{regexp}
  25975. @end smallexample
  25976. Add a catchpoint for library load events. If the @samp{-t} option is used,
  25977. the catchpoint is a temporary one (@pxref{Set Breaks, ,Setting
  25978. Breakpoints}). If the @samp{-d} option is used, the catchpoint is created
  25979. in a disabled state. The @samp{regexp} argument is a regular
  25980. expression used to match the name of the loaded library.
  25981. @subsubheading @value{GDBN} Command
  25982. The corresponding @value{GDBN} command is @samp{catch load}.
  25983. @subsubheading Example
  25984. @smallexample
  25985. -catch-load -t foo.so
  25986. ^done,bkpt=@{number="1",type="catchpoint",disp="del",enabled="y",
  25987. what="load of library matching foo.so",catch-type="load",times="0"@}
  25988. (gdb)
  25989. @end smallexample
  25990. @subheading The @code{-catch-unload} Command
  25991. @findex -catch-unload
  25992. @subsubheading Synopsis
  25993. @smallexample
  25994. -catch-unload [ -t ] [ -d ] @var{regexp}
  25995. @end smallexample
  25996. Add a catchpoint for library unload events. If the @samp{-t} option is
  25997. used, the catchpoint is a temporary one (@pxref{Set Breaks, ,Setting
  25998. Breakpoints}). If the @samp{-d} option is used, the catchpoint is
  25999. created in a disabled state. The @samp{regexp} argument is a regular
  26000. expression used to match the name of the unloaded library.
  26001. @subsubheading @value{GDBN} Command
  26002. The corresponding @value{GDBN} command is @samp{catch unload}.
  26003. @subsubheading Example
  26004. @smallexample
  26005. -catch-unload -d bar.so
  26006. ^done,bkpt=@{number="2",type="catchpoint",disp="keep",enabled="n",
  26007. what="load of library matching bar.so",catch-type="unload",times="0"@}
  26008. (gdb)
  26009. @end smallexample
  26010. @node Ada Exception GDB/MI Catchpoint Commands
  26011. @subsection Ada Exception @sc{gdb/mi} Catchpoints
  26012. The following @sc{gdb/mi} commands can be used to create catchpoints
  26013. that stop the execution when Ada exceptions are being raised.
  26014. @subheading The @code{-catch-assert} Command
  26015. @findex -catch-assert
  26016. @subsubheading Synopsis
  26017. @smallexample
  26018. -catch-assert [ -c @var{condition}] [ -d ] [ -t ]
  26019. @end smallexample
  26020. Add a catchpoint for failed Ada assertions.
  26021. The possible optional parameters for this command are:
  26022. @table @samp
  26023. @item -c @var{condition}
  26024. Make the catchpoint conditional on @var{condition}.
  26025. @item -d
  26026. Create a disabled catchpoint.
  26027. @item -t
  26028. Create a temporary catchpoint.
  26029. @end table
  26030. @subsubheading @value{GDBN} Command
  26031. The corresponding @value{GDBN} command is @samp{catch assert}.
  26032. @subsubheading Example
  26033. @smallexample
  26034. -catch-assert
  26035. ^done,bkptno="5",bkpt=@{number="5",type="breakpoint",disp="keep",
  26036. enabled="y",addr="0x0000000000404888",what="failed Ada assertions",
  26037. thread-groups=["i1"],times="0",
  26038. original-location="__gnat_debug_raise_assert_failure"@}
  26039. (gdb)
  26040. @end smallexample
  26041. @subheading The @code{-catch-exception} Command
  26042. @findex -catch-exception
  26043. @subsubheading Synopsis
  26044. @smallexample
  26045. -catch-exception [ -c @var{condition}] [ -d ] [ -e @var{exception-name} ]
  26046. [ -t ] [ -u ]
  26047. @end smallexample
  26048. Add a catchpoint stopping when Ada exceptions are raised.
  26049. By default, the command stops the program when any Ada exception
  26050. gets raised. But it is also possible, by using some of the
  26051. optional parameters described below, to create more selective
  26052. catchpoints.
  26053. The possible optional parameters for this command are:
  26054. @table @samp
  26055. @item -c @var{condition}
  26056. Make the catchpoint conditional on @var{condition}.
  26057. @item -d
  26058. Create a disabled catchpoint.
  26059. @item -e @var{exception-name}
  26060. Only stop when @var{exception-name} is raised. This option cannot
  26061. be used combined with @samp{-u}.
  26062. @item -t
  26063. Create a temporary catchpoint.
  26064. @item -u
  26065. Stop only when an unhandled exception gets raised. This option
  26066. cannot be used combined with @samp{-e}.
  26067. @end table
  26068. @subsubheading @value{GDBN} Command
  26069. The corresponding @value{GDBN} commands are @samp{catch exception}
  26070. and @samp{catch exception unhandled}.
  26071. @subsubheading Example
  26072. @smallexample
  26073. -catch-exception -e Program_Error
  26074. ^done,bkptno="4",bkpt=@{number="4",type="breakpoint",disp="keep",
  26075. enabled="y",addr="0x0000000000404874",
  26076. what="`Program_Error' Ada exception", thread-groups=["i1"],
  26077. times="0",original-location="__gnat_debug_raise_exception"@}
  26078. (gdb)
  26079. @end smallexample
  26080. @subheading The @code{-catch-handlers} Command
  26081. @findex -catch-handlers
  26082. @subsubheading Synopsis
  26083. @smallexample
  26084. -catch-handlers [ -c @var{condition}] [ -d ] [ -e @var{exception-name} ]
  26085. [ -t ]
  26086. @end smallexample
  26087. Add a catchpoint stopping when Ada exceptions are handled.
  26088. By default, the command stops the program when any Ada exception
  26089. gets handled. But it is also possible, by using some of the
  26090. optional parameters described below, to create more selective
  26091. catchpoints.
  26092. The possible optional parameters for this command are:
  26093. @table @samp
  26094. @item -c @var{condition}
  26095. Make the catchpoint conditional on @var{condition}.
  26096. @item -d
  26097. Create a disabled catchpoint.
  26098. @item -e @var{exception-name}
  26099. Only stop when @var{exception-name} is handled.
  26100. @item -t
  26101. Create a temporary catchpoint.
  26102. @end table
  26103. @subsubheading @value{GDBN} Command
  26104. The corresponding @value{GDBN} command is @samp{catch handlers}.
  26105. @subsubheading Example
  26106. @smallexample
  26107. -catch-handlers -e Constraint_Error
  26108. ^done,bkptno="4",bkpt=@{number="4",type="breakpoint",disp="keep",
  26109. enabled="y",addr="0x0000000000402f68",
  26110. what="`Constraint_Error' Ada exception handlers",thread-groups=["i1"],
  26111. times="0",original-location="__gnat_begin_handler"@}
  26112. (gdb)
  26113. @end smallexample
  26114. @node C++ Exception GDB/MI Catchpoint Commands
  26115. @subsection C@t{++} Exception @sc{gdb/mi} Catchpoints
  26116. The following @sc{gdb/mi} commands can be used to create catchpoints
  26117. that stop the execution when C@t{++} exceptions are being throw, rethrown,
  26118. or caught.
  26119. @subheading The @code{-catch-throw} Command
  26120. @findex -catch-throw
  26121. @subsubheading Synopsis
  26122. @smallexample
  26123. -catch-throw [ -t ] [ -r @var{regexp}]
  26124. @end smallexample
  26125. Stop when the debuggee throws a C@t{++} exception. If @var{regexp} is
  26126. given, then only exceptions whose type matches the regular expression
  26127. will be caught.
  26128. If @samp{-t} is given, then the catchpoint is enabled only for one
  26129. stop, the catchpoint is automatically deleted after stopping once for
  26130. the event.
  26131. @subsubheading @value{GDBN} Command
  26132. The corresponding @value{GDBN} commands are @samp{catch throw}
  26133. and @samp{tcatch throw} (@pxref{Set Catchpoints}).
  26134. @subsubheading Example
  26135. @smallexample
  26136. -catch-throw -r exception_type
  26137. ^done,bkpt=@{number="1",type="catchpoint",disp="keep",enabled="y",
  26138. what="exception throw",catch-type="throw",
  26139. thread-groups=["i1"],
  26140. regexp="exception_type",times="0"@}
  26141. (gdb)
  26142. -exec-run
  26143. ^running
  26144. (gdb)
  26145. ~"\n"
  26146. ~"Catchpoint 1 (exception thrown), 0x00007ffff7ae00ed
  26147. in __cxa_throw () from /lib64/libstdc++.so.6\n"
  26148. *stopped,bkptno="1",reason="breakpoint-hit",disp="keep",
  26149. frame=@{addr="0x00007ffff7ae00ed",func="__cxa_throw",
  26150. args=[],from="/lib64/libstdc++.so.6",arch="i386:x86-64"@},
  26151. thread-id="1",stopped-threads="all",core="6"
  26152. (gdb)
  26153. @end smallexample
  26154. @subheading The @code{-catch-rethrow} Command
  26155. @findex -catch-rethrow
  26156. @subsubheading Synopsis
  26157. @smallexample
  26158. -catch-rethrow [ -t ] [ -r @var{regexp}]
  26159. @end smallexample
  26160. Stop when a C@t{++} exception is re-thrown. If @var{regexp} is given,
  26161. then only exceptions whose type matches the regular expression will be
  26162. caught.
  26163. If @samp{-t} is given, then the catchpoint is enabled only for one
  26164. stop, the catchpoint is automatically deleted after the first event is
  26165. caught.
  26166. @subsubheading @value{GDBN} Command
  26167. The corresponding @value{GDBN} commands are @samp{catch rethrow}
  26168. and @samp{tcatch rethrow} (@pxref{Set Catchpoints}).
  26169. @subsubheading Example
  26170. @smallexample
  26171. -catch-rethrow -r exception_type
  26172. ^done,bkpt=@{number="1",type="catchpoint",disp="keep",enabled="y",
  26173. what="exception rethrow",catch-type="rethrow",
  26174. thread-groups=["i1"],
  26175. regexp="exception_type",times="0"@}
  26176. (gdb)
  26177. -exec-run
  26178. ^running
  26179. (gdb)
  26180. ~"\n"
  26181. ~"Catchpoint 1 (exception rethrown), 0x00007ffff7ae00ed
  26182. in __cxa_rethrow () from /lib64/libstdc++.so.6\n"
  26183. *stopped,bkptno="1",reason="breakpoint-hit",disp="keep",
  26184. frame=@{addr="0x00007ffff7ae00ed",func="__cxa_rethrow",
  26185. args=[],from="/lib64/libstdc++.so.6",arch="i386:x86-64"@},
  26186. thread-id="1",stopped-threads="all",core="6"
  26187. (gdb)
  26188. @end smallexample
  26189. @subheading The @code{-catch-catch} Command
  26190. @findex -catch-catch
  26191. @subsubheading Synopsis
  26192. @smallexample
  26193. -catch-catch [ -t ] [ -r @var{regexp}]
  26194. @end smallexample
  26195. Stop when the debuggee catches a C@t{++} exception. If @var{regexp}
  26196. is given, then only exceptions whose type matches the regular
  26197. expression will be caught.
  26198. If @samp{-t} is given, then the catchpoint is enabled only for one
  26199. stop, the catchpoint is automatically deleted after the first event is
  26200. caught.
  26201. @subsubheading @value{GDBN} Command
  26202. The corresponding @value{GDBN} commands are @samp{catch catch}
  26203. and @samp{tcatch catch} (@pxref{Set Catchpoints}).
  26204. @subsubheading Example
  26205. @smallexample
  26206. -catch-catch -r exception_type
  26207. ^done,bkpt=@{number="1",type="catchpoint",disp="keep",enabled="y",
  26208. what="exception catch",catch-type="catch",
  26209. thread-groups=["i1"],
  26210. regexp="exception_type",times="0"@}
  26211. (gdb)
  26212. -exec-run
  26213. ^running
  26214. (gdb)
  26215. ~"\n"
  26216. ~"Catchpoint 1 (exception caught), 0x00007ffff7ae00ed
  26217. in __cxa_begin_catch () from /lib64/libstdc++.so.6\n"
  26218. *stopped,bkptno="1",reason="breakpoint-hit",disp="keep",
  26219. frame=@{addr="0x00007ffff7ae00ed",func="__cxa_begin_catch",
  26220. args=[],from="/lib64/libstdc++.so.6",arch="i386:x86-64"@},
  26221. thread-id="1",stopped-threads="all",core="6"
  26222. (gdb)
  26223. @end smallexample
  26224. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26225. @node GDB/MI Program Context
  26226. @section @sc{gdb/mi} Program Context
  26227. @subheading The @code{-exec-arguments} Command
  26228. @findex -exec-arguments
  26229. @subsubheading Synopsis
  26230. @smallexample
  26231. -exec-arguments @var{args}
  26232. @end smallexample
  26233. Set the inferior program arguments, to be used in the next
  26234. @samp{-exec-run}.
  26235. @subsubheading @value{GDBN} Command
  26236. The corresponding @value{GDBN} command is @samp{set args}.
  26237. @subsubheading Example
  26238. @smallexample
  26239. (gdb)
  26240. -exec-arguments -v word
  26241. ^done
  26242. (gdb)
  26243. @end smallexample
  26244. @ignore
  26245. @subheading The @code{-exec-show-arguments} Command
  26246. @findex -exec-show-arguments
  26247. @subsubheading Synopsis
  26248. @smallexample
  26249. -exec-show-arguments
  26250. @end smallexample
  26251. Print the arguments of the program.
  26252. @subsubheading @value{GDBN} Command
  26253. The corresponding @value{GDBN} command is @samp{show args}.
  26254. @subsubheading Example
  26255. N.A.
  26256. @end ignore
  26257. @subheading The @code{-environment-cd} Command
  26258. @findex -environment-cd
  26259. @subsubheading Synopsis
  26260. @smallexample
  26261. -environment-cd @var{pathdir}
  26262. @end smallexample
  26263. Set @value{GDBN}'s working directory.
  26264. @subsubheading @value{GDBN} Command
  26265. The corresponding @value{GDBN} command is @samp{cd}.
  26266. @subsubheading Example
  26267. @smallexample
  26268. (gdb)
  26269. -environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
  26270. ^done
  26271. (gdb)
  26272. @end smallexample
  26273. @subheading The @code{-environment-directory} Command
  26274. @findex -environment-directory
  26275. @subsubheading Synopsis
  26276. @smallexample
  26277. -environment-directory [ -r ] [ @var{pathdir} ]+
  26278. @end smallexample
  26279. Add directories @var{pathdir} to beginning of search path for source files.
  26280. If the @samp{-r} option is used, the search path is reset to the default
  26281. search path. If directories @var{pathdir} are supplied in addition to the
  26282. @samp{-r} option, the search path is first reset and then addition
  26283. occurs as normal.
  26284. Multiple directories may be specified, separated by blanks. Specifying
  26285. multiple directories in a single command
  26286. results in the directories added to the beginning of the
  26287. search path in the same order they were presented in the command.
  26288. If blanks are needed as
  26289. part of a directory name, double-quotes should be used around
  26290. the name. In the command output, the path will show up separated
  26291. by the system directory-separator character. The directory-separator
  26292. character must not be used
  26293. in any directory name.
  26294. If no directories are specified, the current search path is displayed.
  26295. @subsubheading @value{GDBN} Command
  26296. The corresponding @value{GDBN} command is @samp{dir}.
  26297. @subsubheading Example
  26298. @smallexample
  26299. (gdb)
  26300. -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb
  26301. ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
  26302. (gdb)
  26303. -environment-directory ""
  26304. ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd"
  26305. (gdb)
  26306. -environment-directory -r /home/jjohnstn/src/gdb /usr/src
  26307. ^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd"
  26308. (gdb)
  26309. -environment-directory -r
  26310. ^done,source-path="$cdir:$cwd"
  26311. (gdb)
  26312. @end smallexample
  26313. @subheading The @code{-environment-path} Command
  26314. @findex -environment-path
  26315. @subsubheading Synopsis
  26316. @smallexample
  26317. -environment-path [ -r ] [ @var{pathdir} ]+
  26318. @end smallexample
  26319. Add directories @var{pathdir} to beginning of search path for object files.
  26320. If the @samp{-r} option is used, the search path is reset to the original
  26321. search path that existed at gdb start-up. If directories @var{pathdir} are
  26322. supplied in addition to the
  26323. @samp{-r} option, the search path is first reset and then addition
  26324. occurs as normal.
  26325. Multiple directories may be specified, separated by blanks. Specifying
  26326. multiple directories in a single command
  26327. results in the directories added to the beginning of the
  26328. search path in the same order they were presented in the command.
  26329. If blanks are needed as
  26330. part of a directory name, double-quotes should be used around
  26331. the name. In the command output, the path will show up separated
  26332. by the system directory-separator character. The directory-separator
  26333. character must not be used
  26334. in any directory name.
  26335. If no directories are specified, the current path is displayed.
  26336. @subsubheading @value{GDBN} Command
  26337. The corresponding @value{GDBN} command is @samp{path}.
  26338. @subsubheading Example
  26339. @smallexample
  26340. (gdb)
  26341. -environment-path
  26342. ^done,path="/usr/bin"
  26343. (gdb)
  26344. -environment-path /kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb /bin
  26345. ^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin"
  26346. (gdb)
  26347. -environment-path -r /usr/local/bin
  26348. ^done,path="/usr/local/bin:/usr/bin"
  26349. (gdb)
  26350. @end smallexample
  26351. @subheading The @code{-environment-pwd} Command
  26352. @findex -environment-pwd
  26353. @subsubheading Synopsis
  26354. @smallexample
  26355. -environment-pwd
  26356. @end smallexample
  26357. Show the current working directory.
  26358. @subsubheading @value{GDBN} Command
  26359. The corresponding @value{GDBN} command is @samp{pwd}.
  26360. @subsubheading Example
  26361. @smallexample
  26362. (gdb)
  26363. -environment-pwd
  26364. ^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb"
  26365. (gdb)
  26366. @end smallexample
  26367. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26368. @node GDB/MI Thread Commands
  26369. @section @sc{gdb/mi} Thread Commands
  26370. @subheading The @code{-thread-info} Command
  26371. @findex -thread-info
  26372. @subsubheading Synopsis
  26373. @smallexample
  26374. -thread-info [ @var{thread-id} ]
  26375. @end smallexample
  26376. Reports information about either a specific thread, if the
  26377. @var{thread-id} parameter is present, or about all threads.
  26378. @var{thread-id} is the thread's global thread ID. When printing
  26379. information about all threads, also reports the global ID of the
  26380. current thread.
  26381. @subsubheading @value{GDBN} Command
  26382. The @samp{info thread} command prints the same information
  26383. about all threads.
  26384. @subsubheading Result
  26385. The result contains the following attributes:
  26386. @table @samp
  26387. @item threads
  26388. A list of threads. The format of the elements of the list is described in
  26389. @ref{GDB/MI Thread Information}.
  26390. @item current-thread-id
  26391. The global id of the currently selected thread. This field is omitted if there
  26392. is no selected thread (for example, when the selected inferior is not running,
  26393. and therefore has no threads) or if a @var{thread-id} argument was passed to
  26394. the command.
  26395. @end table
  26396. @subsubheading Example
  26397. @smallexample
  26398. -thread-info
  26399. ^done,threads=[
  26400. @{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
  26401. frame=@{level="0",addr="0xffffe410",func="__kernel_vsyscall",
  26402. args=[]@},state="running"@},
  26403. @{id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
  26404. frame=@{level="0",addr="0x0804891f",func="foo",
  26405. args=[@{name="i",value="10"@}],
  26406. file="/tmp/a.c",fullname="/tmp/a.c",line="158",arch="i386:x86_64"@},
  26407. state="running"@}],
  26408. current-thread-id="1"
  26409. (gdb)
  26410. @end smallexample
  26411. @subheading The @code{-thread-list-ids} Command
  26412. @findex -thread-list-ids
  26413. @subsubheading Synopsis
  26414. @smallexample
  26415. -thread-list-ids
  26416. @end smallexample
  26417. Produces a list of the currently known global @value{GDBN} thread ids.
  26418. At the end of the list it also prints the total number of such
  26419. threads.
  26420. This command is retained for historical reasons, the
  26421. @code{-thread-info} command should be used instead.
  26422. @subsubheading @value{GDBN} Command
  26423. Part of @samp{info threads} supplies the same information.
  26424. @subsubheading Example
  26425. @smallexample
  26426. (gdb)
  26427. -thread-list-ids
  26428. ^done,thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@},
  26429. current-thread-id="1",number-of-threads="3"
  26430. (gdb)
  26431. @end smallexample
  26432. @subheading The @code{-thread-select} Command
  26433. @findex -thread-select
  26434. @subsubheading Synopsis
  26435. @smallexample
  26436. -thread-select @var{thread-id}
  26437. @end smallexample
  26438. Make thread with global thread number @var{thread-id} the current
  26439. thread. It prints the number of the new current thread, and the
  26440. topmost frame for that thread.
  26441. This command is deprecated in favor of explicitly using the
  26442. @samp{--thread} option to each command.
  26443. @subsubheading @value{GDBN} Command
  26444. The corresponding @value{GDBN} command is @samp{thread}.
  26445. @subsubheading Example
  26446. @smallexample
  26447. (gdb)
  26448. -exec-next
  26449. ^running
  26450. (gdb)
  26451. *stopped,reason="end-stepping-range",thread-id="2",line="187",
  26452. file="../../../devo/gdb/testsuite/gdb.threads/linux-dp.c"
  26453. (gdb)
  26454. -thread-list-ids
  26455. ^done,
  26456. thread-ids=@{thread-id="3",thread-id="2",thread-id="1"@},
  26457. number-of-threads="3"
  26458. (gdb)
  26459. -thread-select 3
  26460. ^done,new-thread-id="3",
  26461. frame=@{level="0",func="vprintf",
  26462. args=[@{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""@},
  26463. @{name="arg",value="0x2"@}],file="vprintf.c",line="31",arch="i386:x86_64"@}
  26464. (gdb)
  26465. @end smallexample
  26466. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26467. @node GDB/MI Ada Tasking Commands
  26468. @section @sc{gdb/mi} Ada Tasking Commands
  26469. @subheading The @code{-ada-task-info} Command
  26470. @findex -ada-task-info
  26471. @subsubheading Synopsis
  26472. @smallexample
  26473. -ada-task-info [ @var{task-id} ]
  26474. @end smallexample
  26475. Reports information about either a specific Ada task, if the
  26476. @var{task-id} parameter is present, or about all Ada tasks.
  26477. @subsubheading @value{GDBN} Command
  26478. The @samp{info tasks} command prints the same information
  26479. about all Ada tasks (@pxref{Ada Tasks}).
  26480. @subsubheading Result
  26481. The result is a table of Ada tasks. The following columns are
  26482. defined for each Ada task:
  26483. @table @samp
  26484. @item current
  26485. This field exists only for the current thread. It has the value @samp{*}.
  26486. @item id
  26487. The identifier that @value{GDBN} uses to refer to the Ada task.
  26488. @item task-id
  26489. The identifier that the target uses to refer to the Ada task.
  26490. @item thread-id
  26491. The global thread identifier of the thread corresponding to the Ada
  26492. task.
  26493. This field should always exist, as Ada tasks are always implemented
  26494. on top of a thread. But if @value{GDBN} cannot find this corresponding
  26495. thread for any reason, the field is omitted.
  26496. @item parent-id
  26497. This field exists only when the task was created by another task.
  26498. In this case, it provides the ID of the parent task.
  26499. @item priority
  26500. The base priority of the task.
  26501. @item state
  26502. The current state of the task. For a detailed description of the
  26503. possible states, see @ref{Ada Tasks}.
  26504. @item name
  26505. The name of the task.
  26506. @end table
  26507. @subsubheading Example
  26508. @smallexample
  26509. -ada-task-info
  26510. ^done,tasks=@{nr_rows="3",nr_cols="8",
  26511. hdr=[@{width="1",alignment="-1",col_name="current",colhdr=""@},
  26512. @{width="3",alignment="1",col_name="id",colhdr="ID"@},
  26513. @{width="9",alignment="1",col_name="task-id",colhdr="TID"@},
  26514. @{width="4",alignment="1",col_name="thread-id",colhdr=""@},
  26515. @{width="4",alignment="1",col_name="parent-id",colhdr="P-ID"@},
  26516. @{width="3",alignment="1",col_name="priority",colhdr="Pri"@},
  26517. @{width="22",alignment="-1",col_name="state",colhdr="State"@},
  26518. @{width="1",alignment="2",col_name="name",colhdr="Name"@}],
  26519. body=[@{current="*",id="1",task-id=" 644010",thread-id="1",priority="48",
  26520. state="Child Termination Wait",name="main_task"@}]@}
  26521. (gdb)
  26522. @end smallexample
  26523. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26524. @node GDB/MI Program Execution
  26525. @section @sc{gdb/mi} Program Execution
  26526. These are the asynchronous commands which generate the out-of-band
  26527. record @samp{*stopped}. Currently @value{GDBN} only really executes
  26528. asynchronously with remote targets and this interaction is mimicked in
  26529. other cases.
  26530. @subheading The @code{-exec-continue} Command
  26531. @findex -exec-continue
  26532. @subsubheading Synopsis
  26533. @smallexample
  26534. -exec-continue [--reverse] [--all|--thread-group N]
  26535. @end smallexample
  26536. Resumes the execution of the inferior program, which will continue
  26537. to execute until it reaches a debugger stop event. If the
  26538. @samp{--reverse} option is specified, execution resumes in reverse until
  26539. it reaches a stop event. Stop events may include
  26540. @itemize @bullet
  26541. @item
  26542. breakpoints or watchpoints
  26543. @item
  26544. signals or exceptions
  26545. @item
  26546. the end of the process (or its beginning under @samp{--reverse})
  26547. @item
  26548. the end or beginning of a replay log if one is being used.
  26549. @end itemize
  26550. In all-stop mode (@pxref{All-Stop
  26551. Mode}), may resume only one thread, or all threads, depending on the
  26552. value of the @samp{scheduler-locking} variable. If @samp{--all} is
  26553. specified, all threads (in all inferiors) will be resumed. The @samp{--all} option is
  26554. ignored in all-stop mode. If the @samp{--thread-group} options is
  26555. specified, then all threads in that thread group are resumed.
  26556. @subsubheading @value{GDBN} Command
  26557. The corresponding @value{GDBN} corresponding is @samp{continue}.
  26558. @subsubheading Example
  26559. @smallexample
  26560. -exec-continue
  26561. ^running
  26562. (gdb)
  26563. @@Hello world
  26564. *stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame=@{
  26565. func="foo",args=[],file="hello.c",fullname="/home/foo/bar/hello.c",
  26566. line="13",arch="i386:x86_64"@}
  26567. (gdb)
  26568. @end smallexample
  26569. @subheading The @code{-exec-finish} Command
  26570. @findex -exec-finish
  26571. @subsubheading Synopsis
  26572. @smallexample
  26573. -exec-finish [--reverse]
  26574. @end smallexample
  26575. Resumes the execution of the inferior program until the current
  26576. function is exited. Displays the results returned by the function.
  26577. If the @samp{--reverse} option is specified, resumes the reverse
  26578. execution of the inferior program until the point where current
  26579. function was called.
  26580. @subsubheading @value{GDBN} Command
  26581. The corresponding @value{GDBN} command is @samp{finish}.
  26582. @subsubheading Example
  26583. Function returning @code{void}.
  26584. @smallexample
  26585. -exec-finish
  26586. ^running
  26587. (gdb)
  26588. @@hello from foo
  26589. *stopped,reason="function-finished",frame=@{func="main",args=[],
  26590. file="hello.c",fullname="/home/foo/bar/hello.c",line="7",arch="i386:x86_64"@}
  26591. (gdb)
  26592. @end smallexample
  26593. Function returning other than @code{void}. The name of the internal
  26594. @value{GDBN} variable storing the result is printed, together with the
  26595. value itself.
  26596. @smallexample
  26597. -exec-finish
  26598. ^running
  26599. (gdb)
  26600. *stopped,reason="function-finished",frame=@{addr="0x000107b0",func="foo",
  26601. args=[@{name="a",value="1"],@{name="b",value="9"@}@},
  26602. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  26603. arch="i386:x86_64"@},
  26604. gdb-result-var="$1",return-value="0"
  26605. (gdb)
  26606. @end smallexample
  26607. @subheading The @code{-exec-interrupt} Command
  26608. @findex -exec-interrupt
  26609. @subsubheading Synopsis
  26610. @smallexample
  26611. -exec-interrupt [--all|--thread-group N]
  26612. @end smallexample
  26613. Interrupts the background execution of the target. Note how the token
  26614. associated with the stop message is the one for the execution command
  26615. that has been interrupted. The token for the interrupt itself only
  26616. appears in the @samp{^done} output. If the user is trying to
  26617. interrupt a non-running program, an error message will be printed.
  26618. Note that when asynchronous execution is enabled, this command is
  26619. asynchronous just like other execution commands. That is, first the
  26620. @samp{^done} response will be printed, and the target stop will be
  26621. reported after that using the @samp{*stopped} notification.
  26622. In non-stop mode, only the context thread is interrupted by default.
  26623. All threads (in all inferiors) will be interrupted if the
  26624. @samp{--all} option is specified. If the @samp{--thread-group}
  26625. option is specified, all threads in that group will be interrupted.
  26626. @subsubheading @value{GDBN} Command
  26627. The corresponding @value{GDBN} command is @samp{interrupt}.
  26628. @subsubheading Example
  26629. @smallexample
  26630. (gdb)
  26631. 111-exec-continue
  26632. 111^running
  26633. (gdb)
  26634. 222-exec-interrupt
  26635. 222^done
  26636. (gdb)
  26637. 111*stopped,signal-name="SIGINT",signal-meaning="Interrupt",
  26638. frame=@{addr="0x00010140",func="foo",args=[],file="try.c",
  26639. fullname="/home/foo/bar/try.c",line="13",arch="i386:x86_64"@}
  26640. (gdb)
  26641. (gdb)
  26642. -exec-interrupt
  26643. ^error,msg="mi_cmd_exec_interrupt: Inferior not executing."
  26644. (gdb)
  26645. @end smallexample
  26646. @subheading The @code{-exec-jump} Command
  26647. @findex -exec-jump
  26648. @subsubheading Synopsis
  26649. @smallexample
  26650. -exec-jump @var{location}
  26651. @end smallexample
  26652. Resumes execution of the inferior program at the location specified by
  26653. parameter. @xref{Specify Location}, for a description of the
  26654. different forms of @var{location}.
  26655. @subsubheading @value{GDBN} Command
  26656. The corresponding @value{GDBN} command is @samp{jump}.
  26657. @subsubheading Example
  26658. @smallexample
  26659. -exec-jump foo.c:10
  26660. *running,thread-id="all"
  26661. ^running
  26662. @end smallexample
  26663. @subheading The @code{-exec-next} Command
  26664. @findex -exec-next
  26665. @subsubheading Synopsis
  26666. @smallexample
  26667. -exec-next [--reverse]
  26668. @end smallexample
  26669. Resumes execution of the inferior program, stopping when the beginning
  26670. of the next source line is reached.
  26671. If the @samp{--reverse} option is specified, resumes reverse execution
  26672. of the inferior program, stopping at the beginning of the previous
  26673. source line. If you issue this command on the first line of a
  26674. function, it will take you back to the caller of that function, to the
  26675. source line where the function was called.
  26676. @subsubheading @value{GDBN} Command
  26677. The corresponding @value{GDBN} command is @samp{next}.
  26678. @subsubheading Example
  26679. @smallexample
  26680. -exec-next
  26681. ^running
  26682. (gdb)
  26683. *stopped,reason="end-stepping-range",line="8",file="hello.c"
  26684. (gdb)
  26685. @end smallexample
  26686. @subheading The @code{-exec-next-instruction} Command
  26687. @findex -exec-next-instruction
  26688. @subsubheading Synopsis
  26689. @smallexample
  26690. -exec-next-instruction [--reverse]
  26691. @end smallexample
  26692. Executes one machine instruction. If the instruction is a function
  26693. call, continues until the function returns. If the program stops at an
  26694. instruction in the middle of a source line, the address will be
  26695. printed as well.
  26696. If the @samp{--reverse} option is specified, resumes reverse execution
  26697. of the inferior program, stopping at the previous instruction. If the
  26698. previously executed instruction was a return from another function,
  26699. it will continue to execute in reverse until the call to that function
  26700. (from the current stack frame) is reached.
  26701. @subsubheading @value{GDBN} Command
  26702. The corresponding @value{GDBN} command is @samp{nexti}.
  26703. @subsubheading Example
  26704. @smallexample
  26705. (gdb)
  26706. -exec-next-instruction
  26707. ^running
  26708. (gdb)
  26709. *stopped,reason="end-stepping-range",
  26710. addr="0x000100d4",line="5",file="hello.c"
  26711. (gdb)
  26712. @end smallexample
  26713. @subheading The @code{-exec-return} Command
  26714. @findex -exec-return
  26715. @subsubheading Synopsis
  26716. @smallexample
  26717. -exec-return
  26718. @end smallexample
  26719. Makes current function return immediately. Doesn't execute the inferior.
  26720. Displays the new current frame.
  26721. @subsubheading @value{GDBN} Command
  26722. The corresponding @value{GDBN} command is @samp{return}.
  26723. @subsubheading Example
  26724. @smallexample
  26725. (gdb)
  26726. 200-break-insert callee4
  26727. 200^done,bkpt=@{number="1",addr="0x00010734",
  26728. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"@}
  26729. (gdb)
  26730. 000-exec-run
  26731. 000^running
  26732. (gdb)
  26733. 000*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
  26734. frame=@{func="callee4",args=[],
  26735. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  26736. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
  26737. arch="i386:x86_64"@}
  26738. (gdb)
  26739. 205-break-delete
  26740. 205^done
  26741. (gdb)
  26742. 111-exec-return
  26743. 111^done,frame=@{level="0",func="callee3",
  26744. args=[@{name="strarg",
  26745. value="0x11940 \"A string argument.\""@}],
  26746. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  26747. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18",
  26748. arch="i386:x86_64"@}
  26749. (gdb)
  26750. @end smallexample
  26751. @subheading The @code{-exec-run} Command
  26752. @findex -exec-run
  26753. @subsubheading Synopsis
  26754. @smallexample
  26755. -exec-run [ --all | --thread-group N ] [ --start ]
  26756. @end smallexample
  26757. Starts execution of the inferior from the beginning. The inferior
  26758. executes until either a breakpoint is encountered or the program
  26759. exits. In the latter case the output will include an exit code, if
  26760. the program has exited exceptionally.
  26761. When neither the @samp{--all} nor the @samp{--thread-group} option
  26762. is specified, the current inferior is started. If the
  26763. @samp{--thread-group} option is specified, it should refer to a thread
  26764. group of type @samp{process}, and that thread group will be started.
  26765. If the @samp{--all} option is specified, then all inferiors will be started.
  26766. Using the @samp{--start} option instructs the debugger to stop
  26767. the execution at the start of the inferior's main subprogram,
  26768. following the same behavior as the @code{start} command
  26769. (@pxref{Starting}).
  26770. @subsubheading @value{GDBN} Command
  26771. The corresponding @value{GDBN} command is @samp{run}.
  26772. @subsubheading Examples
  26773. @smallexample
  26774. (gdb)
  26775. -break-insert main
  26776. ^done,bkpt=@{number="1",addr="0x0001072c",file="recursive2.c",line="4"@}
  26777. (gdb)
  26778. -exec-run
  26779. ^running
  26780. (gdb)
  26781. *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",
  26782. frame=@{func="main",args=[],file="recursive2.c",
  26783. fullname="/home/foo/bar/recursive2.c",line="4",arch="i386:x86_64"@}
  26784. (gdb)
  26785. @end smallexample
  26786. @noindent
  26787. Program exited normally:
  26788. @smallexample
  26789. (gdb)
  26790. -exec-run
  26791. ^running
  26792. (gdb)
  26793. x = 55
  26794. *stopped,reason="exited-normally"
  26795. (gdb)
  26796. @end smallexample
  26797. @noindent
  26798. Program exited exceptionally:
  26799. @smallexample
  26800. (gdb)
  26801. -exec-run
  26802. ^running
  26803. (gdb)
  26804. x = 55
  26805. *stopped,reason="exited",exit-code="01"
  26806. (gdb)
  26807. @end smallexample
  26808. Another way the program can terminate is if it receives a signal such as
  26809. @code{SIGINT}. In this case, @sc{gdb/mi} displays this:
  26810. @smallexample
  26811. (gdb)
  26812. *stopped,reason="exited-signalled",signal-name="SIGINT",
  26813. signal-meaning="Interrupt"
  26814. @end smallexample
  26815. @c @subheading -exec-signal
  26816. @subheading The @code{-exec-step} Command
  26817. @findex -exec-step
  26818. @subsubheading Synopsis
  26819. @smallexample
  26820. -exec-step [--reverse]
  26821. @end smallexample
  26822. Resumes execution of the inferior program, stopping when the beginning
  26823. of the next source line is reached, if the next source line is not a
  26824. function call. If it is, stop at the first instruction of the called
  26825. function. If the @samp{--reverse} option is specified, resumes reverse
  26826. execution of the inferior program, stopping at the beginning of the
  26827. previously executed source line.
  26828. @subsubheading @value{GDBN} Command
  26829. The corresponding @value{GDBN} command is @samp{step}.
  26830. @subsubheading Example
  26831. Stepping into a function:
  26832. @smallexample
  26833. -exec-step
  26834. ^running
  26835. (gdb)
  26836. *stopped,reason="end-stepping-range",
  26837. frame=@{func="foo",args=[@{name="a",value="10"@},
  26838. @{name="b",value="0"@}],file="recursive2.c",
  26839. fullname="/home/foo/bar/recursive2.c",line="11",arch="i386:x86_64"@}
  26840. (gdb)
  26841. @end smallexample
  26842. Regular stepping:
  26843. @smallexample
  26844. -exec-step
  26845. ^running
  26846. (gdb)
  26847. *stopped,reason="end-stepping-range",line="14",file="recursive2.c"
  26848. (gdb)
  26849. @end smallexample
  26850. @subheading The @code{-exec-step-instruction} Command
  26851. @findex -exec-step-instruction
  26852. @subsubheading Synopsis
  26853. @smallexample
  26854. -exec-step-instruction [--reverse]
  26855. @end smallexample
  26856. Resumes the inferior which executes one machine instruction. If the
  26857. @samp{--reverse} option is specified, resumes reverse execution of the
  26858. inferior program, stopping at the previously executed instruction.
  26859. The output, once @value{GDBN} has stopped, will vary depending on
  26860. whether we have stopped in the middle of a source line or not. In the
  26861. former case, the address at which the program stopped will be printed
  26862. as well.
  26863. @subsubheading @value{GDBN} Command
  26864. The corresponding @value{GDBN} command is @samp{stepi}.
  26865. @subsubheading Example
  26866. @smallexample
  26867. (gdb)
  26868. -exec-step-instruction
  26869. ^running
  26870. (gdb)
  26871. *stopped,reason="end-stepping-range",
  26872. frame=@{func="foo",args=[],file="try.c",
  26873. fullname="/home/foo/bar/try.c",line="10",arch="i386:x86_64"@}
  26874. (gdb)
  26875. -exec-step-instruction
  26876. ^running
  26877. (gdb)
  26878. *stopped,reason="end-stepping-range",
  26879. frame=@{addr="0x000100f4",func="foo",args=[],file="try.c",
  26880. fullname="/home/foo/bar/try.c",line="10",arch="i386:x86_64"@}
  26881. (gdb)
  26882. @end smallexample
  26883. @subheading The @code{-exec-until} Command
  26884. @findex -exec-until
  26885. @subsubheading Synopsis
  26886. @smallexample
  26887. -exec-until [ @var{location} ]
  26888. @end smallexample
  26889. Executes the inferior until the @var{location} specified in the
  26890. argument is reached. If there is no argument, the inferior executes
  26891. until a source line greater than the current one is reached. The
  26892. reason for stopping in this case will be @samp{location-reached}.
  26893. @subsubheading @value{GDBN} Command
  26894. The corresponding @value{GDBN} command is @samp{until}.
  26895. @subsubheading Example
  26896. @smallexample
  26897. (gdb)
  26898. -exec-until recursive2.c:6
  26899. ^running
  26900. (gdb)
  26901. x = 55
  26902. *stopped,reason="location-reached",frame=@{func="main",args=[],
  26903. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="6",
  26904. arch="i386:x86_64"@}
  26905. (gdb)
  26906. @end smallexample
  26907. @ignore
  26908. @subheading -file-clear
  26909. Is this going away????
  26910. @end ignore
  26911. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26912. @node GDB/MI Stack Manipulation
  26913. @section @sc{gdb/mi} Stack Manipulation Commands
  26914. @subheading The @code{-enable-frame-filters} Command
  26915. @findex -enable-frame-filters
  26916. @smallexample
  26917. -enable-frame-filters
  26918. @end smallexample
  26919. @value{GDBN} allows Python-based frame filters to affect the output of
  26920. the MI commands relating to stack traces. As there is no way to
  26921. implement this in a fully backward-compatible way, a front end must
  26922. request that this functionality be enabled.
  26923. Once enabled, this feature cannot be disabled.
  26924. Note that if Python support has not been compiled into @value{GDBN},
  26925. this command will still succeed (and do nothing).
  26926. @subheading The @code{-stack-info-frame} Command
  26927. @findex -stack-info-frame
  26928. @subsubheading Synopsis
  26929. @smallexample
  26930. -stack-info-frame
  26931. @end smallexample
  26932. Get info on the selected frame.
  26933. @subsubheading @value{GDBN} Command
  26934. The corresponding @value{GDBN} command is @samp{info frame} or @samp{frame}
  26935. (without arguments).
  26936. @subsubheading Example
  26937. @smallexample
  26938. (gdb)
  26939. -stack-info-frame
  26940. ^done,frame=@{level="1",addr="0x0001076c",func="callee3",
  26941. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  26942. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17",
  26943. arch="i386:x86_64"@}
  26944. (gdb)
  26945. @end smallexample
  26946. @subheading The @code{-stack-info-depth} Command
  26947. @findex -stack-info-depth
  26948. @subsubheading Synopsis
  26949. @smallexample
  26950. -stack-info-depth [ @var{max-depth} ]
  26951. @end smallexample
  26952. Return the depth of the stack. If the integer argument @var{max-depth}
  26953. is specified, do not count beyond @var{max-depth} frames.
  26954. @subsubheading @value{GDBN} Command
  26955. There's no equivalent @value{GDBN} command.
  26956. @subsubheading Example
  26957. For a stack with frame levels 0 through 11:
  26958. @smallexample
  26959. (gdb)
  26960. -stack-info-depth
  26961. ^done,depth="12"
  26962. (gdb)
  26963. -stack-info-depth 4
  26964. ^done,depth="4"
  26965. (gdb)
  26966. -stack-info-depth 12
  26967. ^done,depth="12"
  26968. (gdb)
  26969. -stack-info-depth 11
  26970. ^done,depth="11"
  26971. (gdb)
  26972. -stack-info-depth 13
  26973. ^done,depth="12"
  26974. (gdb)
  26975. @end smallexample
  26976. @anchor{-stack-list-arguments}
  26977. @subheading The @code{-stack-list-arguments} Command
  26978. @findex -stack-list-arguments
  26979. @subsubheading Synopsis
  26980. @smallexample
  26981. -stack-list-arguments [ --no-frame-filters ] [ --skip-unavailable ] @var{print-values}
  26982. [ @var{low-frame} @var{high-frame} ]
  26983. @end smallexample
  26984. Display a list of the arguments for the frames between @var{low-frame}
  26985. and @var{high-frame} (inclusive). If @var{low-frame} and
  26986. @var{high-frame} are not provided, list the arguments for the whole
  26987. call stack. If the two arguments are equal, show the single frame
  26988. at the corresponding level. It is an error if @var{low-frame} is
  26989. larger than the actual number of frames. On the other hand,
  26990. @var{high-frame} may be larger than the actual number of frames, in
  26991. which case only existing frames will be returned.
  26992. If @var{print-values} is 0 or @code{--no-values}, print only the names of
  26993. the variables; if it is 1 or @code{--all-values}, print also their
  26994. values; and if it is 2 or @code{--simple-values}, print the name,
  26995. type and value for simple data types, and the name and type for arrays,
  26996. structures and unions. If the option @code{--no-frame-filters} is
  26997. supplied, then Python frame filters will not be executed.
  26998. If the @code{--skip-unavailable} option is specified, arguments that
  26999. are not available are not listed. Partially available arguments
  27000. are still displayed, however.
  27001. Use of this command to obtain arguments in a single frame is
  27002. deprecated in favor of the @samp{-stack-list-variables} command.
  27003. @subsubheading @value{GDBN} Command
  27004. @value{GDBN} does not have an equivalent command. @code{gdbtk} has a
  27005. @samp{gdb_get_args} command which partially overlaps with the
  27006. functionality of @samp{-stack-list-arguments}.
  27007. @subsubheading Example
  27008. @smallexample
  27009. (gdb)
  27010. -stack-list-frames
  27011. ^done,
  27012. stack=[
  27013. frame=@{level="0",addr="0x00010734",func="callee4",
  27014. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  27015. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
  27016. arch="i386:x86_64"@},
  27017. frame=@{level="1",addr="0x0001076c",func="callee3",
  27018. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  27019. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="17",
  27020. arch="i386:x86_64"@},
  27021. frame=@{level="2",addr="0x0001078c",func="callee2",
  27022. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  27023. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="22",
  27024. arch="i386:x86_64"@},
  27025. frame=@{level="3",addr="0x000107b4",func="callee1",
  27026. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  27027. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="27",
  27028. arch="i386:x86_64"@},
  27029. frame=@{level="4",addr="0x000107e0",func="main",
  27030. file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
  27031. fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="32",
  27032. arch="i386:x86_64"@}]
  27033. (gdb)
  27034. -stack-list-arguments 0
  27035. ^done,
  27036. stack-args=[
  27037. frame=@{level="0",args=[]@},
  27038. frame=@{level="1",args=[name="strarg"]@},
  27039. frame=@{level="2",args=[name="intarg",name="strarg"]@},
  27040. frame=@{level="3",args=[name="intarg",name="strarg",name="fltarg"]@},
  27041. frame=@{level="4",args=[]@}]
  27042. (gdb)
  27043. -stack-list-arguments 1
  27044. ^done,
  27045. stack-args=[
  27046. frame=@{level="0",args=[]@},
  27047. frame=@{level="1",
  27048. args=[@{name="strarg",value="0x11940 \"A string argument.\""@}]@},
  27049. frame=@{level="2",args=[
  27050. @{name="intarg",value="2"@},
  27051. @{name="strarg",value="0x11940 \"A string argument.\""@}]@},
  27052. @{frame=@{level="3",args=[
  27053. @{name="intarg",value="2"@},
  27054. @{name="strarg",value="0x11940 \"A string argument.\""@},
  27055. @{name="fltarg",value="3.5"@}]@},
  27056. frame=@{level="4",args=[]@}]
  27057. (gdb)
  27058. -stack-list-arguments 0 2 2
  27059. ^done,stack-args=[frame=@{level="2",args=[name="intarg",name="strarg"]@}]
  27060. (gdb)
  27061. -stack-list-arguments 1 2 2
  27062. ^done,stack-args=[frame=@{level="2",
  27063. args=[@{name="intarg",value="2"@},
  27064. @{name="strarg",value="0x11940 \"A string argument.\""@}]@}]
  27065. (gdb)
  27066. @end smallexample
  27067. @c @subheading -stack-list-exception-handlers
  27068. @anchor{-stack-list-frames}
  27069. @subheading The @code{-stack-list-frames} Command
  27070. @findex -stack-list-frames
  27071. @subsubheading Synopsis
  27072. @smallexample
  27073. -stack-list-frames [ --no-frame-filters @var{low-frame} @var{high-frame} ]
  27074. @end smallexample
  27075. List the frames currently on the stack. For each frame it displays the
  27076. following info:
  27077. @table @samp
  27078. @item @var{level}
  27079. The frame number, 0 being the topmost frame, i.e., the innermost function.
  27080. @item @var{addr}
  27081. The @code{$pc} value for that frame.
  27082. @item @var{func}
  27083. Function name.
  27084. @item @var{file}
  27085. File name of the source file where the function lives.
  27086. @item @var{fullname}
  27087. The full file name of the source file where the function lives.
  27088. @item @var{line}
  27089. Line number corresponding to the @code{$pc}.
  27090. @item @var{from}
  27091. The shared library where this function is defined. This is only given
  27092. if the frame's function is not known.
  27093. @item @var{arch}
  27094. Frame's architecture.
  27095. @end table
  27096. If invoked without arguments, this command prints a backtrace for the
  27097. whole stack. If given two integer arguments, it shows the frames whose
  27098. levels are between the two arguments (inclusive). If the two arguments
  27099. are equal, it shows the single frame at the corresponding level. It is
  27100. an error if @var{low-frame} is larger than the actual number of
  27101. frames. On the other hand, @var{high-frame} may be larger than the
  27102. actual number of frames, in which case only existing frames will be
  27103. returned. If the option @code{--no-frame-filters} is supplied, then
  27104. Python frame filters will not be executed.
  27105. @subsubheading @value{GDBN} Command
  27106. The corresponding @value{GDBN} commands are @samp{backtrace} and @samp{where}.
  27107. @subsubheading Example
  27108. Full stack backtrace:
  27109. @smallexample
  27110. (gdb)
  27111. -stack-list-frames
  27112. ^done,stack=
  27113. [frame=@{level="0",addr="0x0001076c",func="foo",
  27114. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="11",
  27115. arch="i386:x86_64"@},
  27116. frame=@{level="1",addr="0x000107a4",func="foo",
  27117. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27118. arch="i386:x86_64"@},
  27119. frame=@{level="2",addr="0x000107a4",func="foo",
  27120. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27121. arch="i386:x86_64"@},
  27122. frame=@{level="3",addr="0x000107a4",func="foo",
  27123. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27124. arch="i386:x86_64"@},
  27125. frame=@{level="4",addr="0x000107a4",func="foo",
  27126. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27127. arch="i386:x86_64"@},
  27128. frame=@{level="5",addr="0x000107a4",func="foo",
  27129. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27130. arch="i386:x86_64"@},
  27131. frame=@{level="6",addr="0x000107a4",func="foo",
  27132. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27133. arch="i386:x86_64"@},
  27134. frame=@{level="7",addr="0x000107a4",func="foo",
  27135. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27136. arch="i386:x86_64"@},
  27137. frame=@{level="8",addr="0x000107a4",func="foo",
  27138. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27139. arch="i386:x86_64"@},
  27140. frame=@{level="9",addr="0x000107a4",func="foo",
  27141. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27142. arch="i386:x86_64"@},
  27143. frame=@{level="10",addr="0x000107a4",func="foo",
  27144. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27145. arch="i386:x86_64"@},
  27146. frame=@{level="11",addr="0x00010738",func="main",
  27147. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="4",
  27148. arch="i386:x86_64"@}]
  27149. (gdb)
  27150. @end smallexample
  27151. Show frames between @var{low_frame} and @var{high_frame}:
  27152. @smallexample
  27153. (gdb)
  27154. -stack-list-frames 3 5
  27155. ^done,stack=
  27156. [frame=@{level="3",addr="0x000107a4",func="foo",
  27157. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27158. arch="i386:x86_64"@},
  27159. frame=@{level="4",addr="0x000107a4",func="foo",
  27160. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27161. arch="i386:x86_64"@},
  27162. frame=@{level="5",addr="0x000107a4",func="foo",
  27163. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27164. arch="i386:x86_64"@}]
  27165. (gdb)
  27166. @end smallexample
  27167. Show a single frame:
  27168. @smallexample
  27169. (gdb)
  27170. -stack-list-frames 3 3
  27171. ^done,stack=
  27172. [frame=@{level="3",addr="0x000107a4",func="foo",
  27173. file="recursive2.c",fullname="/home/foo/bar/recursive2.c",line="14",
  27174. arch="i386:x86_64"@}]
  27175. (gdb)
  27176. @end smallexample
  27177. @subheading The @code{-stack-list-locals} Command
  27178. @findex -stack-list-locals
  27179. @anchor{-stack-list-locals}
  27180. @subsubheading Synopsis
  27181. @smallexample
  27182. -stack-list-locals [ --no-frame-filters ] [ --skip-unavailable ] @var{print-values}
  27183. @end smallexample
  27184. Display the local variable names for the selected frame. If
  27185. @var{print-values} is 0 or @code{--no-values}, print only the names of
  27186. the variables; if it is 1 or @code{--all-values}, print also their
  27187. values; and if it is 2 or @code{--simple-values}, print the name,
  27188. type and value for simple data types, and the name and type for arrays,
  27189. structures and unions. In this last case, a frontend can immediately
  27190. display the value of simple data types and create variable objects for
  27191. other data types when the user wishes to explore their values in
  27192. more detail. If the option @code{--no-frame-filters} is supplied, then
  27193. Python frame filters will not be executed.
  27194. If the @code{--skip-unavailable} option is specified, local variables
  27195. that are not available are not listed. Partially available local
  27196. variables are still displayed, however.
  27197. This command is deprecated in favor of the
  27198. @samp{-stack-list-variables} command.
  27199. @subsubheading @value{GDBN} Command
  27200. @samp{info locals} in @value{GDBN}, @samp{gdb_get_locals} in @code{gdbtk}.
  27201. @subsubheading Example
  27202. @smallexample
  27203. (gdb)
  27204. -stack-list-locals 0
  27205. ^done,locals=[name="A",name="B",name="C"]
  27206. (gdb)
  27207. -stack-list-locals --all-values
  27208. ^done,locals=[@{name="A",value="1"@},@{name="B",value="2"@},
  27209. @{name="C",value="@{1, 2, 3@}"@}]
  27210. -stack-list-locals --simple-values
  27211. ^done,locals=[@{name="A",type="int",value="1"@},
  27212. @{name="B",type="int",value="2"@},@{name="C",type="int [3]"@}]
  27213. (gdb)
  27214. @end smallexample
  27215. @anchor{-stack-list-variables}
  27216. @subheading The @code{-stack-list-variables} Command
  27217. @findex -stack-list-variables
  27218. @subsubheading Synopsis
  27219. @smallexample
  27220. -stack-list-variables [ --no-frame-filters ] [ --skip-unavailable ] @var{print-values}
  27221. @end smallexample
  27222. Display the names of local variables and function arguments for the selected frame. If
  27223. @var{print-values} is 0 or @code{--no-values}, print only the names of
  27224. the variables; if it is 1 or @code{--all-values}, print also their
  27225. values; and if it is 2 or @code{--simple-values}, print the name,
  27226. type and value for simple data types, and the name and type for arrays,
  27227. structures and unions. If the option @code{--no-frame-filters} is
  27228. supplied, then Python frame filters will not be executed.
  27229. If the @code{--skip-unavailable} option is specified, local variables
  27230. and arguments that are not available are not listed. Partially
  27231. available arguments and local variables are still displayed, however.
  27232. @subsubheading Example
  27233. @smallexample
  27234. (gdb)
  27235. -stack-list-variables --thread 1 --frame 0 --all-values
  27236. ^done,variables=[@{name="x",value="11"@},@{name="s",value="@{a = 1, b = 2@}"@}]
  27237. (gdb)
  27238. @end smallexample
  27239. @subheading The @code{-stack-select-frame} Command
  27240. @findex -stack-select-frame
  27241. @subsubheading Synopsis
  27242. @smallexample
  27243. -stack-select-frame @var{framenum}
  27244. @end smallexample
  27245. Change the selected frame. Select a different frame @var{framenum} on
  27246. the stack.
  27247. This command in deprecated in favor of passing the @samp{--frame}
  27248. option to every command.
  27249. @subsubheading @value{GDBN} Command
  27250. The corresponding @value{GDBN} commands are @samp{frame}, @samp{up},
  27251. @samp{down}, @samp{select-frame}, @samp{up-silent}, and @samp{down-silent}.
  27252. @subsubheading Example
  27253. @smallexample
  27254. (gdb)
  27255. -stack-select-frame 2
  27256. ^done
  27257. (gdb)
  27258. @end smallexample
  27259. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27260. @node GDB/MI Variable Objects
  27261. @section @sc{gdb/mi} Variable Objects
  27262. @ignore
  27263. @subheading Motivation for Variable Objects in @sc{gdb/mi}
  27264. For the implementation of a variable debugger window (locals, watched
  27265. expressions, etc.), we are proposing the adaptation of the existing code
  27266. used by @code{Insight}.
  27267. The two main reasons for that are:
  27268. @enumerate 1
  27269. @item
  27270. It has been proven in practice (it is already on its second generation).
  27271. @item
  27272. It will shorten development time (needless to say how important it is
  27273. now).
  27274. @end enumerate
  27275. The original interface was designed to be used by Tcl code, so it was
  27276. slightly changed so it could be used through @sc{gdb/mi}. This section
  27277. describes the @sc{gdb/mi} operations that will be available and gives some
  27278. hints about their use.
  27279. @emph{Note}: In addition to the set of operations described here, we
  27280. expect the @sc{gui} implementation of a variable window to require, at
  27281. least, the following operations:
  27282. @itemize @bullet
  27283. @item @code{-gdb-show} @code{output-radix}
  27284. @item @code{-stack-list-arguments}
  27285. @item @code{-stack-list-locals}
  27286. @item @code{-stack-select-frame}
  27287. @end itemize
  27288. @end ignore
  27289. @subheading Introduction to Variable Objects
  27290. @cindex variable objects in @sc{gdb/mi}
  27291. Variable objects are "object-oriented" MI interface for examining and
  27292. changing values of expressions. Unlike some other MI interfaces that
  27293. work with expressions, variable objects are specifically designed for
  27294. simple and efficient presentation in the frontend. A variable object
  27295. is identified by string name. When a variable object is created, the
  27296. frontend specifies the expression for that variable object. The
  27297. expression can be a simple variable, or it can be an arbitrary complex
  27298. expression, and can even involve CPU registers. After creating a
  27299. variable object, the frontend can invoke other variable object
  27300. operations---for example to obtain or change the value of a variable
  27301. object, or to change display format.
  27302. Variable objects have hierarchical tree structure. Any variable object
  27303. that corresponds to a composite type, such as structure in C, has
  27304. a number of child variable objects, for example corresponding to each
  27305. element of a structure. A child variable object can itself have
  27306. children, recursively. Recursion ends when we reach
  27307. leaf variable objects, which always have built-in types. Child variable
  27308. objects are created only by explicit request, so if a frontend
  27309. is not interested in the children of a particular variable object, no
  27310. child will be created.
  27311. For a leaf variable object it is possible to obtain its value as a
  27312. string, or set the value from a string. String value can be also
  27313. obtained for a non-leaf variable object, but it's generally a string
  27314. that only indicates the type of the object, and does not list its
  27315. contents. Assignment to a non-leaf variable object is not allowed.
  27316. A frontend does not need to read the values of all variable objects each time
  27317. the program stops. Instead, MI provides an update command that lists all
  27318. variable objects whose values has changed since the last update
  27319. operation. This considerably reduces the amount of data that must
  27320. be transferred to the frontend. As noted above, children variable
  27321. objects are created on demand, and only leaf variable objects have a
  27322. real value. As result, gdb will read target memory only for leaf
  27323. variables that frontend has created.
  27324. The automatic update is not always desirable. For example, a frontend
  27325. might want to keep a value of some expression for future reference,
  27326. and never update it. For another example, fetching memory is
  27327. relatively slow for embedded targets, so a frontend might want
  27328. to disable automatic update for the variables that are either not
  27329. visible on the screen, or ``closed''. This is possible using so
  27330. called ``frozen variable objects''. Such variable objects are never
  27331. implicitly updated.
  27332. Variable objects can be either @dfn{fixed} or @dfn{floating}. For the
  27333. fixed variable object, the expression is parsed when the variable
  27334. object is created, including associating identifiers to specific
  27335. variables. The meaning of expression never changes. For a floating
  27336. variable object the values of variables whose names appear in the
  27337. expressions are re-evaluated every time in the context of the current
  27338. frame. Consider this example:
  27339. @smallexample
  27340. void do_work(...)
  27341. @{
  27342. struct work_state state;
  27343. if (...)
  27344. do_work(...);
  27345. @}
  27346. @end smallexample
  27347. If a fixed variable object for the @code{state} variable is created in
  27348. this function, and we enter the recursive call, the variable
  27349. object will report the value of @code{state} in the top-level
  27350. @code{do_work} invocation. On the other hand, a floating variable
  27351. object will report the value of @code{state} in the current frame.
  27352. If an expression specified when creating a fixed variable object
  27353. refers to a local variable, the variable object becomes bound to the
  27354. thread and frame in which the variable object is created. When such
  27355. variable object is updated, @value{GDBN} makes sure that the
  27356. thread/frame combination the variable object is bound to still exists,
  27357. and re-evaluates the variable object in context of that thread/frame.
  27358. The following is the complete set of @sc{gdb/mi} operations defined to
  27359. access this functionality:
  27360. @multitable @columnfractions .4 .6
  27361. @item @strong{Operation}
  27362. @tab @strong{Description}
  27363. @item @code{-enable-pretty-printing}
  27364. @tab enable Python-based pretty-printing
  27365. @item @code{-var-create}
  27366. @tab create a variable object
  27367. @item @code{-var-delete}
  27368. @tab delete the variable object and/or its children
  27369. @item @code{-var-set-format}
  27370. @tab set the display format of this variable
  27371. @item @code{-var-show-format}
  27372. @tab show the display format of this variable
  27373. @item @code{-var-info-num-children}
  27374. @tab tells how many children this object has
  27375. @item @code{-var-list-children}
  27376. @tab return a list of the object's children
  27377. @item @code{-var-info-type}
  27378. @tab show the type of this variable object
  27379. @item @code{-var-info-expression}
  27380. @tab print parent-relative expression that this variable object represents
  27381. @item @code{-var-info-path-expression}
  27382. @tab print full expression that this variable object represents
  27383. @item @code{-var-show-attributes}
  27384. @tab is this variable editable? does it exist here?
  27385. @item @code{-var-evaluate-expression}
  27386. @tab get the value of this variable
  27387. @item @code{-var-assign}
  27388. @tab set the value of this variable
  27389. @item @code{-var-update}
  27390. @tab update the variable and its children
  27391. @item @code{-var-set-frozen}
  27392. @tab set frozenness attribute
  27393. @item @code{-var-set-update-range}
  27394. @tab set range of children to display on update
  27395. @end multitable
  27396. In the next subsection we describe each operation in detail and suggest
  27397. how it can be used.
  27398. @subheading Description And Use of Operations on Variable Objects
  27399. @subheading The @code{-enable-pretty-printing} Command
  27400. @findex -enable-pretty-printing
  27401. @smallexample
  27402. -enable-pretty-printing
  27403. @end smallexample
  27404. @value{GDBN} allows Python-based visualizers to affect the output of the
  27405. MI variable object commands. However, because there was no way to
  27406. implement this in a fully backward-compatible way, a front end must
  27407. request that this functionality be enabled.
  27408. Once enabled, this feature cannot be disabled.
  27409. Note that if Python support has not been compiled into @value{GDBN},
  27410. this command will still succeed (and do nothing).
  27411. This feature is currently (as of @value{GDBN} 7.0) experimental, and
  27412. may work differently in future versions of @value{GDBN}.
  27413. @subheading The @code{-var-create} Command
  27414. @findex -var-create
  27415. @subsubheading Synopsis
  27416. @smallexample
  27417. -var-create @{@var{name} | "-"@}
  27418. @{@var{frame-addr} | "*" | "@@"@} @var{expression}
  27419. @end smallexample
  27420. This operation creates a variable object, which allows the monitoring of
  27421. a variable, the result of an expression, a memory cell or a CPU
  27422. register.
  27423. The @var{name} parameter is the string by which the object can be
  27424. referenced. It must be unique. If @samp{-} is specified, the varobj
  27425. system will generate a string ``varNNNNNN'' automatically. It will be
  27426. unique provided that one does not specify @var{name} of that format.
  27427. The command fails if a duplicate name is found.
  27428. The frame under which the expression should be evaluated can be
  27429. specified by @var{frame-addr}. A @samp{*} indicates that the current
  27430. frame should be used. A @samp{@@} indicates that a floating variable
  27431. object must be created.
  27432. @var{expression} is any expression valid on the current language set (must not
  27433. begin with a @samp{*}), or one of the following:
  27434. @itemize @bullet
  27435. @item
  27436. @samp{*@var{addr}}, where @var{addr} is the address of a memory cell
  27437. @item
  27438. @samp{*@var{addr}-@var{addr}} --- a memory address range (TBD)
  27439. @item
  27440. @samp{$@var{regname}} --- a CPU register name
  27441. @end itemize
  27442. @cindex dynamic varobj
  27443. A varobj's contents may be provided by a Python-based pretty-printer. In this
  27444. case the varobj is known as a @dfn{dynamic varobj}. Dynamic varobjs
  27445. have slightly different semantics in some cases. If the
  27446. @code{-enable-pretty-printing} command is not sent, then @value{GDBN}
  27447. will never create a dynamic varobj. This ensures backward
  27448. compatibility for existing clients.
  27449. @subsubheading Result
  27450. This operation returns attributes of the newly-created varobj. These
  27451. are:
  27452. @table @samp
  27453. @item name
  27454. The name of the varobj.
  27455. @item numchild
  27456. The number of children of the varobj. This number is not necessarily
  27457. reliable for a dynamic varobj. Instead, you must examine the
  27458. @samp{has_more} attribute.
  27459. @item value
  27460. The varobj's scalar value. For a varobj whose type is some sort of
  27461. aggregate (e.g., a @code{struct}), or for a dynamic varobj, this value
  27462. will not be interesting.
  27463. @item type
  27464. The varobj's type. This is a string representation of the type, as
  27465. would be printed by the @value{GDBN} CLI. If @samp{print object}
  27466. (@pxref{Print Settings, set print object}) is set to @code{on}, the
  27467. @emph{actual} (derived) type of the object is shown rather than the
  27468. @emph{declared} one.
  27469. @item thread-id
  27470. If a variable object is bound to a specific thread, then this is the
  27471. thread's global identifier.
  27472. @item has_more
  27473. For a dynamic varobj, this indicates whether there appear to be any
  27474. children available. For a non-dynamic varobj, this will be 0.
  27475. @item dynamic
  27476. This attribute will be present and have the value @samp{1} if the
  27477. varobj is a dynamic varobj. If the varobj is not a dynamic varobj,
  27478. then this attribute will not be present.
  27479. @item displayhint
  27480. A dynamic varobj can supply a display hint to the front end. The
  27481. value comes directly from the Python pretty-printer object's
  27482. @code{display_hint} method. @xref{Pretty Printing API}.
  27483. @end table
  27484. Typical output will look like this:
  27485. @smallexample
  27486. name="@var{name}",numchild="@var{N}",type="@var{type}",thread-id="@var{M}",
  27487. has_more="@var{has_more}"
  27488. @end smallexample
  27489. @subheading The @code{-var-delete} Command
  27490. @findex -var-delete
  27491. @subsubheading Synopsis
  27492. @smallexample
  27493. -var-delete [ -c ] @var{name}
  27494. @end smallexample
  27495. Deletes a previously created variable object and all of its children.
  27496. With the @samp{-c} option, just deletes the children.
  27497. Returns an error if the object @var{name} is not found.
  27498. @subheading The @code{-var-set-format} Command
  27499. @findex -var-set-format
  27500. @subsubheading Synopsis
  27501. @smallexample
  27502. -var-set-format @var{name} @var{format-spec}
  27503. @end smallexample
  27504. Sets the output format for the value of the object @var{name} to be
  27505. @var{format-spec}.
  27506. @anchor{-var-set-format}
  27507. The syntax for the @var{format-spec} is as follows:
  27508. @smallexample
  27509. @var{format-spec} @expansion{}
  27510. @{binary | decimal | hexadecimal | octal | natural | zero-hexadecimal@}
  27511. @end smallexample
  27512. The natural format is the default format choosen automatically
  27513. based on the variable type (like decimal for an @code{int}, hex
  27514. for pointers, etc.).
  27515. The zero-hexadecimal format has a representation similar to hexadecimal
  27516. but with padding zeroes to the left of the value. For example, a 32-bit
  27517. hexadecimal value of 0x1234 would be represented as 0x00001234 in the
  27518. zero-hexadecimal format.
  27519. For a variable with children, the format is set only on the
  27520. variable itself, and the children are not affected.
  27521. @subheading The @code{-var-show-format} Command
  27522. @findex -var-show-format
  27523. @subsubheading Synopsis
  27524. @smallexample
  27525. -var-show-format @var{name}
  27526. @end smallexample
  27527. Returns the format used to display the value of the object @var{name}.
  27528. @smallexample
  27529. @var{format} @expansion{}
  27530. @var{format-spec}
  27531. @end smallexample
  27532. @subheading The @code{-var-info-num-children} Command
  27533. @findex -var-info-num-children
  27534. @subsubheading Synopsis
  27535. @smallexample
  27536. -var-info-num-children @var{name}
  27537. @end smallexample
  27538. Returns the number of children of a variable object @var{name}:
  27539. @smallexample
  27540. numchild=@var{n}
  27541. @end smallexample
  27542. Note that this number is not completely reliable for a dynamic varobj.
  27543. It will return the current number of children, but more children may
  27544. be available.
  27545. @subheading The @code{-var-list-children} Command
  27546. @findex -var-list-children
  27547. @subsubheading Synopsis
  27548. @smallexample
  27549. -var-list-children [@var{print-values}] @var{name} [@var{from} @var{to}]
  27550. @end smallexample
  27551. @anchor{-var-list-children}
  27552. Return a list of the children of the specified variable object and
  27553. create variable objects for them, if they do not already exist. With
  27554. a single argument or if @var{print-values} has a value of 0 or
  27555. @code{--no-values}, print only the names of the variables; if
  27556. @var{print-values} is 1 or @code{--all-values}, also print their
  27557. values; and if it is 2 or @code{--simple-values} print the name and
  27558. value for simple data types and just the name for arrays, structures
  27559. and unions.
  27560. @var{from} and @var{to}, if specified, indicate the range of children
  27561. to report. If @var{from} or @var{to} is less than zero, the range is
  27562. reset and all children will be reported. Otherwise, children starting
  27563. at @var{from} (zero-based) and up to and excluding @var{to} will be
  27564. reported.
  27565. If a child range is requested, it will only affect the current call to
  27566. @code{-var-list-children}, but not future calls to @code{-var-update}.
  27567. For this, you must instead use @code{-var-set-update-range}. The
  27568. intent of this approach is to enable a front end to implement any
  27569. update approach it likes; for example, scrolling a view may cause the
  27570. front end to request more children with @code{-var-list-children}, and
  27571. then the front end could call @code{-var-set-update-range} with a
  27572. different range to ensure that future updates are restricted to just
  27573. the visible items.
  27574. For each child the following results are returned:
  27575. @table @var
  27576. @item name
  27577. Name of the variable object created for this child.
  27578. @item exp
  27579. The expression to be shown to the user by the front end to designate this child.
  27580. For example this may be the name of a structure member.
  27581. For a dynamic varobj, this value cannot be used to form an
  27582. expression. There is no way to do this at all with a dynamic varobj.
  27583. For C/C@t{++} structures there are several pseudo children returned to
  27584. designate access qualifiers. For these pseudo children @var{exp} is
  27585. @samp{public}, @samp{private}, or @samp{protected}. In this case the
  27586. type and value are not present.
  27587. A dynamic varobj will not report the access qualifying
  27588. pseudo-children, regardless of the language. This information is not
  27589. available at all with a dynamic varobj.
  27590. @item numchild
  27591. Number of children this child has. For a dynamic varobj, this will be
  27592. 0.
  27593. @item type
  27594. The type of the child. If @samp{print object}
  27595. (@pxref{Print Settings, set print object}) is set to @code{on}, the
  27596. @emph{actual} (derived) type of the object is shown rather than the
  27597. @emph{declared} one.
  27598. @item value
  27599. If values were requested, this is the value.
  27600. @item thread-id
  27601. If this variable object is associated with a thread, this is the
  27602. thread's global thread id. Otherwise this result is not present.
  27603. @item frozen
  27604. If the variable object is frozen, this variable will be present with a value of 1.
  27605. @item displayhint
  27606. A dynamic varobj can supply a display hint to the front end. The
  27607. value comes directly from the Python pretty-printer object's
  27608. @code{display_hint} method. @xref{Pretty Printing API}.
  27609. @item dynamic
  27610. This attribute will be present and have the value @samp{1} if the
  27611. varobj is a dynamic varobj. If the varobj is not a dynamic varobj,
  27612. then this attribute will not be present.
  27613. @end table
  27614. The result may have its own attributes:
  27615. @table @samp
  27616. @item displayhint
  27617. A dynamic varobj can supply a display hint to the front end. The
  27618. value comes directly from the Python pretty-printer object's
  27619. @code{display_hint} method. @xref{Pretty Printing API}.
  27620. @item has_more
  27621. This is an integer attribute which is nonzero if there are children
  27622. remaining after the end of the selected range.
  27623. @end table
  27624. @subsubheading Example
  27625. @smallexample
  27626. (gdb)
  27627. -var-list-children n
  27628. ^done,numchild=@var{n},children=[child=@{name=@var{name},exp=@var{exp},
  27629. numchild=@var{n},type=@var{type}@},@r{(repeats N times)}]
  27630. (gdb)
  27631. -var-list-children --all-values n
  27632. ^done,numchild=@var{n},children=[child=@{name=@var{name},exp=@var{exp},
  27633. numchild=@var{n},value=@var{value},type=@var{type}@},@r{(repeats N times)}]
  27634. @end smallexample
  27635. @subheading The @code{-var-info-type} Command
  27636. @findex -var-info-type
  27637. @subsubheading Synopsis
  27638. @smallexample
  27639. -var-info-type @var{name}
  27640. @end smallexample
  27641. Returns the type of the specified variable @var{name}. The type is
  27642. returned as a string in the same format as it is output by the
  27643. @value{GDBN} CLI:
  27644. @smallexample
  27645. type=@var{typename}
  27646. @end smallexample
  27647. @subheading The @code{-var-info-expression} Command
  27648. @findex -var-info-expression
  27649. @subsubheading Synopsis
  27650. @smallexample
  27651. -var-info-expression @var{name}
  27652. @end smallexample
  27653. Returns a string that is suitable for presenting this
  27654. variable object in user interface. The string is generally
  27655. not valid expression in the current language, and cannot be evaluated.
  27656. For example, if @code{a} is an array, and variable object
  27657. @code{A} was created for @code{a}, then we'll get this output:
  27658. @smallexample
  27659. (gdb) -var-info-expression A.1
  27660. ^done,lang="C",exp="1"
  27661. @end smallexample
  27662. @noindent
  27663. Here, the value of @code{lang} is the language name, which can be
  27664. found in @ref{Supported Languages}.
  27665. Note that the output of the @code{-var-list-children} command also
  27666. includes those expressions, so the @code{-var-info-expression} command
  27667. is of limited use.
  27668. @subheading The @code{-var-info-path-expression} Command
  27669. @findex -var-info-path-expression
  27670. @subsubheading Synopsis
  27671. @smallexample
  27672. -var-info-path-expression @var{name}
  27673. @end smallexample
  27674. Returns an expression that can be evaluated in the current
  27675. context and will yield the same value that a variable object has.
  27676. Compare this with the @code{-var-info-expression} command, which
  27677. result can be used only for UI presentation. Typical use of
  27678. the @code{-var-info-path-expression} command is creating a
  27679. watchpoint from a variable object.
  27680. This command is currently not valid for children of a dynamic varobj,
  27681. and will give an error when invoked on one.
  27682. For example, suppose @code{C} is a C@t{++} class, derived from class
  27683. @code{Base}, and that the @code{Base} class has a member called
  27684. @code{m_size}. Assume a variable @code{c} is has the type of
  27685. @code{C} and a variable object @code{C} was created for variable
  27686. @code{c}. Then, we'll get this output:
  27687. @smallexample
  27688. (gdb) -var-info-path-expression C.Base.public.m_size
  27689. ^done,path_expr=((Base)c).m_size)
  27690. @end smallexample
  27691. @subheading The @code{-var-show-attributes} Command
  27692. @findex -var-show-attributes
  27693. @subsubheading Synopsis
  27694. @smallexample
  27695. -var-show-attributes @var{name}
  27696. @end smallexample
  27697. List attributes of the specified variable object @var{name}:
  27698. @smallexample
  27699. status=@var{attr} [ ( ,@var{attr} )* ]
  27700. @end smallexample
  27701. @noindent
  27702. where @var{attr} is @code{@{ @{ editable | noneditable @} | TBD @}}.
  27703. @subheading The @code{-var-evaluate-expression} Command
  27704. @findex -var-evaluate-expression
  27705. @subsubheading Synopsis
  27706. @smallexample
  27707. -var-evaluate-expression [-f @var{format-spec}] @var{name}
  27708. @end smallexample
  27709. Evaluates the expression that is represented by the specified variable
  27710. object and returns its value as a string. The format of the string
  27711. can be specified with the @samp{-f} option. The possible values of
  27712. this option are the same as for @code{-var-set-format}
  27713. (@pxref{-var-set-format}). If the @samp{-f} option is not specified,
  27714. the current display format will be used. The current display format
  27715. can be changed using the @code{-var-set-format} command.
  27716. @smallexample
  27717. value=@var{value}
  27718. @end smallexample
  27719. Note that one must invoke @code{-var-list-children} for a variable
  27720. before the value of a child variable can be evaluated.
  27721. @subheading The @code{-var-assign} Command
  27722. @findex -var-assign
  27723. @subsubheading Synopsis
  27724. @smallexample
  27725. -var-assign @var{name} @var{expression}
  27726. @end smallexample
  27727. Assigns the value of @var{expression} to the variable object specified
  27728. by @var{name}. The object must be @samp{editable}. If the variable's
  27729. value is altered by the assign, the variable will show up in any
  27730. subsequent @code{-var-update} list.
  27731. @subsubheading Example
  27732. @smallexample
  27733. (gdb)
  27734. -var-assign var1 3
  27735. ^done,value="3"
  27736. (gdb)
  27737. -var-update *
  27738. ^done,changelist=[@{name="var1",in_scope="true",type_changed="false"@}]
  27739. (gdb)
  27740. @end smallexample
  27741. @subheading The @code{-var-update} Command
  27742. @findex -var-update
  27743. @subsubheading Synopsis
  27744. @smallexample
  27745. -var-update [@var{print-values}] @{@var{name} | "*"@}
  27746. @end smallexample
  27747. Reevaluate the expressions corresponding to the variable object
  27748. @var{name} and all its direct and indirect children, and return the
  27749. list of variable objects whose values have changed; @var{name} must
  27750. be a root variable object. Here, ``changed'' means that the result of
  27751. @code{-var-evaluate-expression} before and after the
  27752. @code{-var-update} is different. If @samp{*} is used as the variable
  27753. object names, all existing variable objects are updated, except
  27754. for frozen ones (@pxref{-var-set-frozen}). The option
  27755. @var{print-values} determines whether both names and values, or just
  27756. names are printed. The possible values of this option are the same
  27757. as for @code{-var-list-children} (@pxref{-var-list-children}). It is
  27758. recommended to use the @samp{--all-values} option, to reduce the
  27759. number of MI commands needed on each program stop.
  27760. With the @samp{*} parameter, if a variable object is bound to a
  27761. currently running thread, it will not be updated, without any
  27762. diagnostic.
  27763. If @code{-var-set-update-range} was previously used on a varobj, then
  27764. only the selected range of children will be reported.
  27765. @code{-var-update} reports all the changed varobjs in a tuple named
  27766. @samp{changelist}.
  27767. Each item in the change list is itself a tuple holding:
  27768. @table @samp
  27769. @item name
  27770. The name of the varobj.
  27771. @item value
  27772. If values were requested for this update, then this field will be
  27773. present and will hold the value of the varobj.
  27774. @item in_scope
  27775. @anchor{-var-update}
  27776. This field is a string which may take one of three values:
  27777. @table @code
  27778. @item "true"
  27779. The variable object's current value is valid.
  27780. @item "false"
  27781. The variable object does not currently hold a valid value but it may
  27782. hold one in the future if its associated expression comes back into
  27783. scope.
  27784. @item "invalid"
  27785. The variable object no longer holds a valid value.
  27786. This can occur when the executable file being debugged has changed,
  27787. either through recompilation or by using the @value{GDBN} @code{file}
  27788. command. The front end should normally choose to delete these variable
  27789. objects.
  27790. @end table
  27791. In the future new values may be added to this list so the front should
  27792. be prepared for this possibility. @xref{GDB/MI Development and Front Ends, ,@sc{GDB/MI} Development and Front Ends}.
  27793. @item type_changed
  27794. This is only present if the varobj is still valid. If the type
  27795. changed, then this will be the string @samp{true}; otherwise it will
  27796. be @samp{false}.
  27797. When a varobj's type changes, its children are also likely to have
  27798. become incorrect. Therefore, the varobj's children are automatically
  27799. deleted when this attribute is @samp{true}. Also, the varobj's update
  27800. range, when set using the @code{-var-set-update-range} command, is
  27801. unset.
  27802. @item new_type
  27803. If the varobj's type changed, then this field will be present and will
  27804. hold the new type.
  27805. @item new_num_children
  27806. For a dynamic varobj, if the number of children changed, or if the
  27807. type changed, this will be the new number of children.
  27808. The @samp{numchild} field in other varobj responses is generally not
  27809. valid for a dynamic varobj -- it will show the number of children that
  27810. @value{GDBN} knows about, but because dynamic varobjs lazily
  27811. instantiate their children, this will not reflect the number of
  27812. children which may be available.
  27813. The @samp{new_num_children} attribute only reports changes to the
  27814. number of children known by @value{GDBN}. This is the only way to
  27815. detect whether an update has removed children (which necessarily can
  27816. only happen at the end of the update range).
  27817. @item displayhint
  27818. The display hint, if any.
  27819. @item has_more
  27820. This is an integer value, which will be 1 if there are more children
  27821. available outside the varobj's update range.
  27822. @item dynamic
  27823. This attribute will be present and have the value @samp{1} if the
  27824. varobj is a dynamic varobj. If the varobj is not a dynamic varobj,
  27825. then this attribute will not be present.
  27826. @item new_children
  27827. If new children were added to a dynamic varobj within the selected
  27828. update range (as set by @code{-var-set-update-range}), then they will
  27829. be listed in this attribute.
  27830. @end table
  27831. @subsubheading Example
  27832. @smallexample
  27833. (gdb)
  27834. -var-assign var1 3
  27835. ^done,value="3"
  27836. (gdb)
  27837. -var-update --all-values var1
  27838. ^done,changelist=[@{name="var1",value="3",in_scope="true",
  27839. type_changed="false"@}]
  27840. (gdb)
  27841. @end smallexample
  27842. @subheading The @code{-var-set-frozen} Command
  27843. @findex -var-set-frozen
  27844. @anchor{-var-set-frozen}
  27845. @subsubheading Synopsis
  27846. @smallexample
  27847. -var-set-frozen @var{name} @var{flag}
  27848. @end smallexample
  27849. Set the frozenness flag on the variable object @var{name}. The
  27850. @var{flag} parameter should be either @samp{1} to make the variable
  27851. frozen or @samp{0} to make it unfrozen. If a variable object is
  27852. frozen, then neither itself, nor any of its children, are
  27853. implicitly updated by @code{-var-update} of
  27854. a parent variable or by @code{-var-update *}. Only
  27855. @code{-var-update} of the variable itself will update its value and
  27856. values of its children. After a variable object is unfrozen, it is
  27857. implicitly updated by all subsequent @code{-var-update} operations.
  27858. Unfreezing a variable does not update it, only subsequent
  27859. @code{-var-update} does.
  27860. @subsubheading Example
  27861. @smallexample
  27862. (gdb)
  27863. -var-set-frozen V 1
  27864. ^done
  27865. (gdb)
  27866. @end smallexample
  27867. @subheading The @code{-var-set-update-range} command
  27868. @findex -var-set-update-range
  27869. @anchor{-var-set-update-range}
  27870. @subsubheading Synopsis
  27871. @smallexample
  27872. -var-set-update-range @var{name} @var{from} @var{to}
  27873. @end smallexample
  27874. Set the range of children to be returned by future invocations of
  27875. @code{-var-update}.
  27876. @var{from} and @var{to} indicate the range of children to report. If
  27877. @var{from} or @var{to} is less than zero, the range is reset and all
  27878. children will be reported. Otherwise, children starting at @var{from}
  27879. (zero-based) and up to and excluding @var{to} will be reported.
  27880. @subsubheading Example
  27881. @smallexample
  27882. (gdb)
  27883. -var-set-update-range V 1 2
  27884. ^done
  27885. @end smallexample
  27886. @subheading The @code{-var-set-visualizer} command
  27887. @findex -var-set-visualizer
  27888. @anchor{-var-set-visualizer}
  27889. @subsubheading Synopsis
  27890. @smallexample
  27891. -var-set-visualizer @var{name} @var{visualizer}
  27892. @end smallexample
  27893. Set a visualizer for the variable object @var{name}.
  27894. @var{visualizer} is the visualizer to use. The special value
  27895. @samp{None} means to disable any visualizer in use.
  27896. If not @samp{None}, @var{visualizer} must be a Python expression.
  27897. This expression must evaluate to a callable object which accepts a
  27898. single argument. @value{GDBN} will call this object with the value of
  27899. the varobj @var{name} as an argument (this is done so that the same
  27900. Python pretty-printing code can be used for both the CLI and MI).
  27901. When called, this object must return an object which conforms to the
  27902. pretty-printing interface (@pxref{Pretty Printing API}).
  27903. The pre-defined function @code{gdb.default_visualizer} may be used to
  27904. select a visualizer by following the built-in process
  27905. (@pxref{Selecting Pretty-Printers}). This is done automatically when
  27906. a varobj is created, and so ordinarily is not needed.
  27907. This feature is only available if Python support is enabled. The MI
  27908. command @code{-list-features} (@pxref{GDB/MI Support Commands})
  27909. can be used to check this.
  27910. @subsubheading Example
  27911. Resetting the visualizer:
  27912. @smallexample
  27913. (gdb)
  27914. -var-set-visualizer V None
  27915. ^done
  27916. @end smallexample
  27917. Reselecting the default (type-based) visualizer:
  27918. @smallexample
  27919. (gdb)
  27920. -var-set-visualizer V gdb.default_visualizer
  27921. ^done
  27922. @end smallexample
  27923. Suppose @code{SomeClass} is a visualizer class. A lambda expression
  27924. can be used to instantiate this class for a varobj:
  27925. @smallexample
  27926. (gdb)
  27927. -var-set-visualizer V "lambda val: SomeClass()"
  27928. ^done
  27929. @end smallexample
  27930. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  27931. @node GDB/MI Data Manipulation
  27932. @section @sc{gdb/mi} Data Manipulation
  27933. @cindex data manipulation, in @sc{gdb/mi}
  27934. @cindex @sc{gdb/mi}, data manipulation
  27935. This section describes the @sc{gdb/mi} commands that manipulate data:
  27936. examine memory and registers, evaluate expressions, etc.
  27937. For details about what an addressable memory unit is,
  27938. @pxref{addressable memory unit}.
  27939. @c REMOVED FROM THE INTERFACE.
  27940. @c @subheading -data-assign
  27941. @c Change the value of a program variable. Plenty of side effects.
  27942. @c @subsubheading GDB Command
  27943. @c set variable
  27944. @c @subsubheading Example
  27945. @c N.A.
  27946. @subheading The @code{-data-disassemble} Command
  27947. @findex -data-disassemble
  27948. @subsubheading Synopsis
  27949. @smallexample
  27950. -data-disassemble
  27951. [ -s @var{start-addr} -e @var{end-addr} ]
  27952. | [ -a @var{addr} ]
  27953. | [ -f @var{filename} -l @var{linenum} [ -n @var{lines} ] ]
  27954. -- @var{mode}
  27955. @end smallexample
  27956. @noindent
  27957. Where:
  27958. @table @samp
  27959. @item @var{start-addr}
  27960. is the beginning address (or @code{$pc})
  27961. @item @var{end-addr}
  27962. is the end address
  27963. @item @var{addr}
  27964. is an address anywhere within (or the name of) the function to
  27965. disassemble. If an address is specified, the whole function
  27966. surrounding that address will be disassembled. If a name is
  27967. specified, the whole function with that name will be disassembled.
  27968. @item @var{filename}
  27969. is the name of the file to disassemble
  27970. @item @var{linenum}
  27971. is the line number to disassemble around
  27972. @item @var{lines}
  27973. is the number of disassembly lines to be produced. If it is -1,
  27974. the whole function will be disassembled, in case no @var{end-addr} is
  27975. specified. If @var{end-addr} is specified as a non-zero value, and
  27976. @var{lines} is lower than the number of disassembly lines between
  27977. @var{start-addr} and @var{end-addr}, only @var{lines} lines are
  27978. displayed; if @var{lines} is higher than the number of lines between
  27979. @var{start-addr} and @var{end-addr}, only the lines up to @var{end-addr}
  27980. are displayed.
  27981. @item @var{mode}
  27982. is one of:
  27983. @itemize @bullet
  27984. @item 0 disassembly only
  27985. @item 1 mixed source and disassembly (deprecated)
  27986. @item 2 disassembly with raw opcodes
  27987. @item 3 mixed source and disassembly with raw opcodes (deprecated)
  27988. @item 4 mixed source and disassembly
  27989. @item 5 mixed source and disassembly with raw opcodes
  27990. @end itemize
  27991. Modes 1 and 3 are deprecated. The output is ``source centric''
  27992. which hasn't proved useful in practice.
  27993. @xref{Machine Code}, for a discussion of the difference between
  27994. @code{/m} and @code{/s} output of the @code{disassemble} command.
  27995. @end table
  27996. @subsubheading Result
  27997. The result of the @code{-data-disassemble} command will be a list named
  27998. @samp{asm_insns}, the contents of this list depend on the @var{mode}
  27999. used with the @code{-data-disassemble} command.
  28000. For modes 0 and 2 the @samp{asm_insns} list contains tuples with the
  28001. following fields:
  28002. @table @code
  28003. @item address
  28004. The address at which this instruction was disassembled.
  28005. @item func-name
  28006. The name of the function this instruction is within.
  28007. @item offset
  28008. The decimal offset in bytes from the start of @samp{func-name}.
  28009. @item inst
  28010. The text disassembly for this @samp{address}.
  28011. @item opcodes
  28012. This field is only present for modes 2, 3 and 5. This contains the raw opcode
  28013. bytes for the @samp{inst} field.
  28014. @end table
  28015. For modes 1, 3, 4 and 5 the @samp{asm_insns} list contains tuples named
  28016. @samp{src_and_asm_line}, each of which has the following fields:
  28017. @table @code
  28018. @item line
  28019. The line number within @samp{file}.
  28020. @item file
  28021. The file name from the compilation unit. This might be an absolute
  28022. file name or a relative file name depending on the compile command
  28023. used.
  28024. @item fullname
  28025. Absolute file name of @samp{file}. It is converted to a canonical form
  28026. using the source file search path
  28027. (@pxref{Source Path, ,Specifying Source Directories})
  28028. and after resolving all the symbolic links.
  28029. If the source file is not found this field will contain the path as
  28030. present in the debug information.
  28031. @item line_asm_insn
  28032. This is a list of tuples containing the disassembly for @samp{line} in
  28033. @samp{file}. The fields of each tuple are the same as for
  28034. @code{-data-disassemble} in @var{mode} 0 and 2, so @samp{address},
  28035. @samp{func-name}, @samp{offset}, @samp{inst}, and optionally
  28036. @samp{opcodes}.
  28037. @end table
  28038. Note that whatever included in the @samp{inst} field, is not
  28039. manipulated directly by @sc{gdb/mi}, i.e., it is not possible to
  28040. adjust its format.
  28041. @subsubheading @value{GDBN} Command
  28042. The corresponding @value{GDBN} command is @samp{disassemble}.
  28043. @subsubheading Example
  28044. Disassemble from the current value of @code{$pc} to @code{$pc + 20}:
  28045. @smallexample
  28046. (gdb)
  28047. -data-disassemble -s $pc -e "$pc + 20" -- 0
  28048. ^done,
  28049. asm_insns=[
  28050. @{address="0x000107c0",func-name="main",offset="4",
  28051. inst="mov 2, %o0"@},
  28052. @{address="0x000107c4",func-name="main",offset="8",
  28053. inst="sethi %hi(0x11800), %o2"@},
  28054. @{address="0x000107c8",func-name="main",offset="12",
  28055. inst="or %o2, 0x140, %o1\t! 0x11940 <_lib_version+8>"@},
  28056. @{address="0x000107cc",func-name="main",offset="16",
  28057. inst="sethi %hi(0x11800), %o2"@},
  28058. @{address="0x000107d0",func-name="main",offset="20",
  28059. inst="or %o2, 0x168, %o4\t! 0x11968 <_lib_version+48>"@}]
  28060. (gdb)
  28061. @end smallexample
  28062. Disassemble the whole @code{main} function. Line 32 is part of
  28063. @code{main}.
  28064. @smallexample
  28065. -data-disassemble -f basics.c -l 32 -- 0
  28066. ^done,asm_insns=[
  28067. @{address="0x000107bc",func-name="main",offset="0",
  28068. inst="save %sp, -112, %sp"@},
  28069. @{address="0x000107c0",func-name="main",offset="4",
  28070. inst="mov 2, %o0"@},
  28071. @{address="0x000107c4",func-name="main",offset="8",
  28072. inst="sethi %hi(0x11800), %o2"@},
  28073. [@dots{}]
  28074. @{address="0x0001081c",func-name="main",offset="96",inst="ret "@},
  28075. @{address="0x00010820",func-name="main",offset="100",inst="restore "@}]
  28076. (gdb)
  28077. @end smallexample
  28078. Disassemble 3 instructions from the start of @code{main}:
  28079. @smallexample
  28080. (gdb)
  28081. -data-disassemble -f basics.c -l 32 -n 3 -- 0
  28082. ^done,asm_insns=[
  28083. @{address="0x000107bc",func-name="main",offset="0",
  28084. inst="save %sp, -112, %sp"@},
  28085. @{address="0x000107c0",func-name="main",offset="4",
  28086. inst="mov 2, %o0"@},
  28087. @{address="0x000107c4",func-name="main",offset="8",
  28088. inst="sethi %hi(0x11800), %o2"@}]
  28089. (gdb)
  28090. @end smallexample
  28091. Disassemble 3 instructions from the start of @code{main} in mixed mode:
  28092. @smallexample
  28093. (gdb)
  28094. -data-disassemble -f basics.c -l 32 -n 3 -- 1
  28095. ^done,asm_insns=[
  28096. src_and_asm_line=@{line="31",
  28097. file="../../../src/gdb/testsuite/gdb.mi/basics.c",
  28098. fullname="/absolute/path/to/src/gdb/testsuite/gdb.mi/basics.c",
  28099. line_asm_insn=[@{address="0x000107bc",
  28100. func-name="main",offset="0",inst="save %sp, -112, %sp"@}]@},
  28101. src_and_asm_line=@{line="32",
  28102. file="../../../src/gdb/testsuite/gdb.mi/basics.c",
  28103. fullname="/absolute/path/to/src/gdb/testsuite/gdb.mi/basics.c",
  28104. line_asm_insn=[@{address="0x000107c0",
  28105. func-name="main",offset="4",inst="mov 2, %o0"@},
  28106. @{address="0x000107c4",func-name="main",offset="8",
  28107. inst="sethi %hi(0x11800), %o2"@}]@}]
  28108. (gdb)
  28109. @end smallexample
  28110. @subheading The @code{-data-evaluate-expression} Command
  28111. @findex -data-evaluate-expression
  28112. @subsubheading Synopsis
  28113. @smallexample
  28114. -data-evaluate-expression @var{expr}
  28115. @end smallexample
  28116. Evaluate @var{expr} as an expression. The expression could contain an
  28117. inferior function call. The function call will execute synchronously.
  28118. If the expression contains spaces, it must be enclosed in double quotes.
  28119. @subsubheading @value{GDBN} Command
  28120. The corresponding @value{GDBN} commands are @samp{print}, @samp{output}, and
  28121. @samp{call}. In @code{gdbtk} only, there's a corresponding
  28122. @samp{gdb_eval} command.
  28123. @subsubheading Example
  28124. In the following example, the numbers that precede the commands are the
  28125. @dfn{tokens} described in @ref{GDB/MI Command Syntax, ,@sc{gdb/mi}
  28126. Command Syntax}. Notice how @sc{gdb/mi} returns the same tokens in its
  28127. output.
  28128. @smallexample
  28129. 211-data-evaluate-expression A
  28130. 211^done,value="1"
  28131. (gdb)
  28132. 311-data-evaluate-expression &A
  28133. 311^done,value="0xefffeb7c"
  28134. (gdb)
  28135. 411-data-evaluate-expression A+3
  28136. 411^done,value="4"
  28137. (gdb)
  28138. 511-data-evaluate-expression "A + 3"
  28139. 511^done,value="4"
  28140. (gdb)
  28141. @end smallexample
  28142. @subheading The @code{-data-list-changed-registers} Command
  28143. @findex -data-list-changed-registers
  28144. @subsubheading Synopsis
  28145. @smallexample
  28146. -data-list-changed-registers
  28147. @end smallexample
  28148. Display a list of the registers that have changed.
  28149. @subsubheading @value{GDBN} Command
  28150. @value{GDBN} doesn't have a direct analog for this command; @code{gdbtk}
  28151. has the corresponding command @samp{gdb_changed_register_list}.
  28152. @subsubheading Example
  28153. On a PPC MBX board:
  28154. @smallexample
  28155. (gdb)
  28156. -exec-continue
  28157. ^running
  28158. (gdb)
  28159. *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame=@{
  28160. func="main",args=[],file="try.c",fullname="/home/foo/bar/try.c",
  28161. line="5",arch="powerpc"@}
  28162. (gdb)
  28163. -data-list-changed-registers
  28164. ^done,changed-registers=["0","1","2","4","5","6","7","8","9",
  28165. "10","11","13","14","15","16","17","18","19","20","21","22","23",
  28166. "24","25","26","27","28","30","31","64","65","66","67","69"]
  28167. (gdb)
  28168. @end smallexample
  28169. @subheading The @code{-data-list-register-names} Command
  28170. @findex -data-list-register-names
  28171. @subsubheading Synopsis
  28172. @smallexample
  28173. -data-list-register-names [ ( @var{regno} )+ ]
  28174. @end smallexample
  28175. Show a list of register names for the current target. If no arguments
  28176. are given, it shows a list of the names of all the registers. If
  28177. integer numbers are given as arguments, it will print a list of the
  28178. names of the registers corresponding to the arguments. To ensure
  28179. consistency between a register name and its number, the output list may
  28180. include empty register names.
  28181. @subsubheading @value{GDBN} Command
  28182. @value{GDBN} does not have a command which corresponds to
  28183. @samp{-data-list-register-names}. In @code{gdbtk} there is a
  28184. corresponding command @samp{gdb_regnames}.
  28185. @subsubheading Example
  28186. For the PPC MBX board:
  28187. @smallexample
  28188. (gdb)
  28189. -data-list-register-names
  28190. ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7",
  28191. "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18",
  28192. "r19","r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
  28193. "r30","r31","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
  28194. "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19","f20",
  28195. "f21","f22","f23","f24","f25","f26","f27","f28","f29","f30","f31",
  28196. "", "pc","ps","cr","lr","ctr","xer"]
  28197. (gdb)
  28198. -data-list-register-names 1 2 3
  28199. ^done,register-names=["r1","r2","r3"]
  28200. (gdb)
  28201. @end smallexample
  28202. @subheading The @code{-data-list-register-values} Command
  28203. @findex -data-list-register-values
  28204. @subsubheading Synopsis
  28205. @smallexample
  28206. -data-list-register-values
  28207. [ @code{--skip-unavailable} ] @var{fmt} [ ( @var{regno} )*]
  28208. @end smallexample
  28209. Display the registers' contents. The format according to which the
  28210. registers' contents are to be returned is given by @var{fmt}, followed
  28211. by an optional list of numbers specifying the registers to display. A
  28212. missing list of numbers indicates that the contents of all the
  28213. registers must be returned. The @code{--skip-unavailable} option
  28214. indicates that only the available registers are to be returned.
  28215. Allowed formats for @var{fmt} are:
  28216. @table @code
  28217. @item x
  28218. Hexadecimal
  28219. @item o
  28220. Octal
  28221. @item t
  28222. Binary
  28223. @item d
  28224. Decimal
  28225. @item r
  28226. Raw
  28227. @item N
  28228. Natural
  28229. @end table
  28230. @subsubheading @value{GDBN} Command
  28231. The corresponding @value{GDBN} commands are @samp{info reg}, @samp{info
  28232. all-reg}, and (in @code{gdbtk}) @samp{gdb_fetch_registers}.
  28233. @subsubheading Example
  28234. For a PPC MBX board (note: line breaks are for readability only, they
  28235. don't appear in the actual output):
  28236. @smallexample
  28237. (gdb)
  28238. -data-list-register-values r 64 65
  28239. ^done,register-values=[@{number="64",value="0xfe00a300"@},
  28240. @{number="65",value="0x00029002"@}]
  28241. (gdb)
  28242. -data-list-register-values x
  28243. ^done,register-values=[@{number="0",value="0xfe0043c8"@},
  28244. @{number="1",value="0x3fff88"@},@{number="2",value="0xfffffffe"@},
  28245. @{number="3",value="0x0"@},@{number="4",value="0xa"@},
  28246. @{number="5",value="0x3fff68"@},@{number="6",value="0x3fff58"@},
  28247. @{number="7",value="0xfe011e98"@},@{number="8",value="0x2"@},
  28248. @{number="9",value="0xfa202820"@},@{number="10",value="0xfa202808"@},
  28249. @{number="11",value="0x1"@},@{number="12",value="0x0"@},
  28250. @{number="13",value="0x4544"@},@{number="14",value="0xffdfffff"@},
  28251. @{number="15",value="0xffffffff"@},@{number="16",value="0xfffffeff"@},
  28252. @{number="17",value="0xefffffed"@},@{number="18",value="0xfffffffe"@},
  28253. @{number="19",value="0xffffffff"@},@{number="20",value="0xffffffff"@},
  28254. @{number="21",value="0xffffffff"@},@{number="22",value="0xfffffff7"@},
  28255. @{number="23",value="0xffffffff"@},@{number="24",value="0xffffffff"@},
  28256. @{number="25",value="0xffffffff"@},@{number="26",value="0xfffffffb"@},
  28257. @{number="27",value="0xffffffff"@},@{number="28",value="0xf7bfffff"@},
  28258. @{number="29",value="0x0"@},@{number="30",value="0xfe010000"@},
  28259. @{number="31",value="0x0"@},@{number="32",value="0x0"@},
  28260. @{number="33",value="0x0"@},@{number="34",value="0x0"@},
  28261. @{number="35",value="0x0"@},@{number="36",value="0x0"@},
  28262. @{number="37",value="0x0"@},@{number="38",value="0x0"@},
  28263. @{number="39",value="0x0"@},@{number="40",value="0x0"@},
  28264. @{number="41",value="0x0"@},@{number="42",value="0x0"@},
  28265. @{number="43",value="0x0"@},@{number="44",value="0x0"@},
  28266. @{number="45",value="0x0"@},@{number="46",value="0x0"@},
  28267. @{number="47",value="0x0"@},@{number="48",value="0x0"@},
  28268. @{number="49",value="0x0"@},@{number="50",value="0x0"@},
  28269. @{number="51",value="0x0"@},@{number="52",value="0x0"@},
  28270. @{number="53",value="0x0"@},@{number="54",value="0x0"@},
  28271. @{number="55",value="0x0"@},@{number="56",value="0x0"@},
  28272. @{number="57",value="0x0"@},@{number="58",value="0x0"@},
  28273. @{number="59",value="0x0"@},@{number="60",value="0x0"@},
  28274. @{number="61",value="0x0"@},@{number="62",value="0x0"@},
  28275. @{number="63",value="0x0"@},@{number="64",value="0xfe00a300"@},
  28276. @{number="65",value="0x29002"@},@{number="66",value="0x202f04b5"@},
  28277. @{number="67",value="0xfe0043b0"@},@{number="68",value="0xfe00b3e4"@},
  28278. @{number="69",value="0x20002b03"@}]
  28279. (gdb)
  28280. @end smallexample
  28281. @subheading The @code{-data-read-memory} Command
  28282. @findex -data-read-memory
  28283. This command is deprecated, use @code{-data-read-memory-bytes} instead.
  28284. @subsubheading Synopsis
  28285. @smallexample
  28286. -data-read-memory [ -o @var{byte-offset} ]
  28287. @var{address} @var{word-format} @var{word-size}
  28288. @var{nr-rows} @var{nr-cols} [ @var{aschar} ]
  28289. @end smallexample
  28290. @noindent
  28291. where:
  28292. @table @samp
  28293. @item @var{address}
  28294. An expression specifying the address of the first memory word to be
  28295. read. Complex expressions containing embedded white space should be
  28296. quoted using the C convention.
  28297. @item @var{word-format}
  28298. The format to be used to print the memory words. The notation is the
  28299. same as for @value{GDBN}'s @code{print} command (@pxref{Output Formats,
  28300. ,Output Formats}).
  28301. @item @var{word-size}
  28302. The size of each memory word in bytes.
  28303. @item @var{nr-rows}
  28304. The number of rows in the output table.
  28305. @item @var{nr-cols}
  28306. The number of columns in the output table.
  28307. @item @var{aschar}
  28308. If present, indicates that each row should include an @sc{ascii} dump. The
  28309. value of @var{aschar} is used as a padding character when a byte is not a
  28310. member of the printable @sc{ascii} character set (printable @sc{ascii}
  28311. characters are those whose code is between 32 and 126, inclusively).
  28312. @item @var{byte-offset}
  28313. An offset to add to the @var{address} before fetching memory.
  28314. @end table
  28315. This command displays memory contents as a table of @var{nr-rows} by
  28316. @var{nr-cols} words, each word being @var{word-size} bytes. In total,
  28317. @code{@var{nr-rows} * @var{nr-cols} * @var{word-size}} bytes are read
  28318. (returned as @samp{total-bytes}). Should less than the requested number
  28319. of bytes be returned by the target, the missing words are identified
  28320. using @samp{N/A}. The number of bytes read from the target is returned
  28321. in @samp{nr-bytes} and the starting address used to read memory in
  28322. @samp{addr}.
  28323. The address of the next/previous row or page is available in
  28324. @samp{next-row} and @samp{prev-row}, @samp{next-page} and
  28325. @samp{prev-page}.
  28326. @subsubheading @value{GDBN} Command
  28327. The corresponding @value{GDBN} command is @samp{x}. @code{gdbtk} has
  28328. @samp{gdb_get_mem} memory read command.
  28329. @subsubheading Example
  28330. Read six bytes of memory starting at @code{bytes+6} but then offset by
  28331. @code{-6} bytes. Format as three rows of two columns. One byte per
  28332. word. Display each word in hex.
  28333. @smallexample
  28334. (gdb)
  28335. 9-data-read-memory -o -6 -- bytes+6 x 1 3 2
  28336. 9^done,addr="0x00001390",nr-bytes="6",total-bytes="6",
  28337. next-row="0x00001396",prev-row="0x0000138e",next-page="0x00001396",
  28338. prev-page="0x0000138a",memory=[
  28339. @{addr="0x00001390",data=["0x00","0x01"]@},
  28340. @{addr="0x00001392",data=["0x02","0x03"]@},
  28341. @{addr="0x00001394",data=["0x04","0x05"]@}]
  28342. (gdb)
  28343. @end smallexample
  28344. Read two bytes of memory starting at address @code{shorts + 64} and
  28345. display as a single word formatted in decimal.
  28346. @smallexample
  28347. (gdb)
  28348. 5-data-read-memory shorts+64 d 2 1 1
  28349. 5^done,addr="0x00001510",nr-bytes="2",total-bytes="2",
  28350. next-row="0x00001512",prev-row="0x0000150e",
  28351. next-page="0x00001512",prev-page="0x0000150e",memory=[
  28352. @{addr="0x00001510",data=["128"]@}]
  28353. (gdb)
  28354. @end smallexample
  28355. Read thirty two bytes of memory starting at @code{bytes+16} and format
  28356. as eight rows of four columns. Include a string encoding with @samp{x}
  28357. used as the non-printable character.
  28358. @smallexample
  28359. (gdb)
  28360. 4-data-read-memory bytes+16 x 1 8 4 x
  28361. 4^done,addr="0x000013a0",nr-bytes="32",total-bytes="32",
  28362. next-row="0x000013c0",prev-row="0x0000139c",
  28363. next-page="0x000013c0",prev-page="0x00001380",memory=[
  28364. @{addr="0x000013a0",data=["0x10","0x11","0x12","0x13"],ascii="xxxx"@},
  28365. @{addr="0x000013a4",data=["0x14","0x15","0x16","0x17"],ascii="xxxx"@},
  28366. @{addr="0x000013a8",data=["0x18","0x19","0x1a","0x1b"],ascii="xxxx"@},
  28367. @{addr="0x000013ac",data=["0x1c","0x1d","0x1e","0x1f"],ascii="xxxx"@},
  28368. @{addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"@},
  28369. @{addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&'"@},
  28370. @{addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"@},
  28371. @{addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"@}]
  28372. (gdb)
  28373. @end smallexample
  28374. @subheading The @code{-data-read-memory-bytes} Command
  28375. @findex -data-read-memory-bytes
  28376. @subsubheading Synopsis
  28377. @smallexample
  28378. -data-read-memory-bytes [ -o @var{offset} ]
  28379. @var{address} @var{count}
  28380. @end smallexample
  28381. @noindent
  28382. where:
  28383. @table @samp
  28384. @item @var{address}
  28385. An expression specifying the address of the first addressable memory unit
  28386. to be read. Complex expressions containing embedded white space should be
  28387. quoted using the C convention.
  28388. @item @var{count}
  28389. The number of addressable memory units to read. This should be an integer
  28390. literal.
  28391. @item @var{offset}
  28392. The offset relative to @var{address} at which to start reading. This
  28393. should be an integer literal. This option is provided so that a frontend
  28394. is not required to first evaluate address and then perform address
  28395. arithmetics itself.
  28396. @end table
  28397. This command attempts to read all accessible memory regions in the
  28398. specified range. First, all regions marked as unreadable in the memory
  28399. map (if one is defined) will be skipped. @xref{Memory Region
  28400. Attributes}. Second, @value{GDBN} will attempt to read the remaining
  28401. regions. For each one, if reading full region results in an errors,
  28402. @value{GDBN} will try to read a subset of the region.
  28403. In general, every single memory unit in the region may be readable or not,
  28404. and the only way to read every readable unit is to try a read at
  28405. every address, which is not practical. Therefore, @value{GDBN} will
  28406. attempt to read all accessible memory units at either beginning or the end
  28407. of the region, using a binary division scheme. This heuristic works
  28408. well for reading across a memory map boundary. Note that if a region
  28409. has a readable range that is neither at the beginning or the end,
  28410. @value{GDBN} will not read it.
  28411. The result record (@pxref{GDB/MI Result Records}) that is output of
  28412. the command includes a field named @samp{memory} whose content is a
  28413. list of tuples. Each tuple represent a successfully read memory block
  28414. and has the following fields:
  28415. @table @code
  28416. @item begin
  28417. The start address of the memory block, as hexadecimal literal.
  28418. @item end
  28419. The end address of the memory block, as hexadecimal literal.
  28420. @item offset
  28421. The offset of the memory block, as hexadecimal literal, relative to
  28422. the start address passed to @code{-data-read-memory-bytes}.
  28423. @item contents
  28424. The contents of the memory block, in hex.
  28425. @end table
  28426. @subsubheading @value{GDBN} Command
  28427. The corresponding @value{GDBN} command is @samp{x}.
  28428. @subsubheading Example
  28429. @smallexample
  28430. (gdb)
  28431. -data-read-memory-bytes &a 10
  28432. ^done,memory=[@{begin="0xbffff154",offset="0x00000000",
  28433. end="0xbffff15e",
  28434. contents="01000000020000000300"@}]
  28435. (gdb)
  28436. @end smallexample
  28437. @subheading The @code{-data-write-memory-bytes} Command
  28438. @findex -data-write-memory-bytes
  28439. @subsubheading Synopsis
  28440. @smallexample
  28441. -data-write-memory-bytes @var{address} @var{contents}
  28442. -data-write-memory-bytes @var{address} @var{contents} @r{[}@var{count}@r{]}
  28443. @end smallexample
  28444. @noindent
  28445. where:
  28446. @table @samp
  28447. @item @var{address}
  28448. An expression specifying the address of the first addressable memory unit
  28449. to be written. Complex expressions containing embedded white space should
  28450. be quoted using the C convention.
  28451. @item @var{contents}
  28452. The hex-encoded data to write. It is an error if @var{contents} does
  28453. not represent an integral number of addressable memory units.
  28454. @item @var{count}
  28455. Optional argument indicating the number of addressable memory units to be
  28456. written. If @var{count} is greater than @var{contents}' length,
  28457. @value{GDBN} will repeatedly write @var{contents} until it fills
  28458. @var{count} memory units.
  28459. @end table
  28460. @subsubheading @value{GDBN} Command
  28461. There's no corresponding @value{GDBN} command.
  28462. @subsubheading Example
  28463. @smallexample
  28464. (gdb)
  28465. -data-write-memory-bytes &a "aabbccdd"
  28466. ^done
  28467. (gdb)
  28468. @end smallexample
  28469. @smallexample
  28470. (gdb)
  28471. -data-write-memory-bytes &a "aabbccdd" 16e
  28472. ^done
  28473. (gdb)
  28474. @end smallexample
  28475. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  28476. @node GDB/MI Tracepoint Commands
  28477. @section @sc{gdb/mi} Tracepoint Commands
  28478. The commands defined in this section implement MI support for
  28479. tracepoints. For detailed introduction, see @ref{Tracepoints}.
  28480. @subheading The @code{-trace-find} Command
  28481. @findex -trace-find
  28482. @subsubheading Synopsis
  28483. @smallexample
  28484. -trace-find @var{mode} [@var{parameters}@dots{}]
  28485. @end smallexample
  28486. Find a trace frame using criteria defined by @var{mode} and
  28487. @var{parameters}. The following table lists permissible
  28488. modes and their parameters. For details of operation, see @ref{tfind}.
  28489. @table @samp
  28490. @item none
  28491. No parameters are required. Stops examining trace frames.
  28492. @item frame-number
  28493. An integer is required as parameter. Selects tracepoint frame with
  28494. that index.
  28495. @item tracepoint-number
  28496. An integer is required as parameter. Finds next
  28497. trace frame that corresponds to tracepoint with the specified number.
  28498. @item pc
  28499. An address is required as parameter. Finds
  28500. next trace frame that corresponds to any tracepoint at the specified
  28501. address.
  28502. @item pc-inside-range
  28503. Two addresses are required as parameters. Finds next trace
  28504. frame that corresponds to a tracepoint at an address inside the
  28505. specified range. Both bounds are considered to be inside the range.
  28506. @item pc-outside-range
  28507. Two addresses are required as parameters. Finds
  28508. next trace frame that corresponds to a tracepoint at an address outside
  28509. the specified range. Both bounds are considered to be inside the range.
  28510. @item line
  28511. Line specification is required as parameter. @xref{Specify Location}.
  28512. Finds next trace frame that corresponds to a tracepoint at
  28513. the specified location.
  28514. @end table
  28515. If @samp{none} was passed as @var{mode}, the response does not
  28516. have fields. Otherwise, the response may have the following fields:
  28517. @table @samp
  28518. @item found
  28519. This field has either @samp{0} or @samp{1} as the value, depending
  28520. on whether a matching tracepoint was found.
  28521. @item traceframe
  28522. The index of the found traceframe. This field is present iff
  28523. the @samp{found} field has value of @samp{1}.
  28524. @item tracepoint
  28525. The index of the found tracepoint. This field is present iff
  28526. the @samp{found} field has value of @samp{1}.
  28527. @item frame
  28528. The information about the frame corresponding to the found trace
  28529. frame. This field is present only if a trace frame was found.
  28530. @xref{GDB/MI Frame Information}, for description of this field.
  28531. @end table
  28532. @subsubheading @value{GDBN} Command
  28533. The corresponding @value{GDBN} command is @samp{tfind}.
  28534. @subheading -trace-define-variable
  28535. @findex -trace-define-variable
  28536. @subsubheading Synopsis
  28537. @smallexample
  28538. -trace-define-variable @var{name} [ @var{value} ]
  28539. @end smallexample
  28540. Create trace variable @var{name} if it does not exist. If
  28541. @var{value} is specified, sets the initial value of the specified
  28542. trace variable to that value. Note that the @var{name} should start
  28543. with the @samp{$} character.
  28544. @subsubheading @value{GDBN} Command
  28545. The corresponding @value{GDBN} command is @samp{tvariable}.
  28546. @subheading The @code{-trace-frame-collected} Command
  28547. @findex -trace-frame-collected
  28548. @subsubheading Synopsis
  28549. @smallexample
  28550. -trace-frame-collected
  28551. [--var-print-values @var{var_pval}]
  28552. [--comp-print-values @var{comp_pval}]
  28553. [--registers-format @var{regformat}]
  28554. [--memory-contents]
  28555. @end smallexample
  28556. This command returns the set of collected objects, register names,
  28557. trace state variable names, memory ranges and computed expressions
  28558. that have been collected at a particular trace frame. The optional
  28559. parameters to the command affect the output format in different ways.
  28560. See the output description table below for more details.
  28561. The reported names can be used in the normal manner to create
  28562. varobjs and inspect the objects themselves. The items returned by
  28563. this command are categorized so that it is clear which is a variable,
  28564. which is a register, which is a trace state variable, which is a
  28565. memory range and which is a computed expression.
  28566. For instance, if the actions were
  28567. @smallexample
  28568. collect myVar, myArray[myIndex], myObj.field, myPtr->field, myCount + 2
  28569. collect *(int*)0xaf02bef0@@40
  28570. @end smallexample
  28571. @noindent
  28572. the object collected in its entirety would be @code{myVar}. The
  28573. object @code{myArray} would be partially collected, because only the
  28574. element at index @code{myIndex} would be collected. The remaining
  28575. objects would be computed expressions.
  28576. An example output would be:
  28577. @smallexample
  28578. (gdb)
  28579. -trace-frame-collected
  28580. ^done,
  28581. explicit-variables=[@{name="myVar",value="1"@}],
  28582. computed-expressions=[@{name="myArray[myIndex]",value="0"@},
  28583. @{name="myObj.field",value="0"@},
  28584. @{name="myPtr->field",value="1"@},
  28585. @{name="myCount + 2",value="3"@},
  28586. @{name="$tvar1 + 1",value="43970027"@}],
  28587. registers=[@{number="0",value="0x7fe2c6e79ec8"@},
  28588. @{number="1",value="0x0"@},
  28589. @{number="2",value="0x4"@},
  28590. ...
  28591. @{number="125",value="0x0"@}],
  28592. tvars=[@{name="$tvar1",current="43970026"@}],
  28593. memory=[@{address="0x0000000000602264",length="4"@},
  28594. @{address="0x0000000000615bc0",length="4"@}]
  28595. (gdb)
  28596. @end smallexample
  28597. Where:
  28598. @table @code
  28599. @item explicit-variables
  28600. The set of objects that have been collected in their entirety (as
  28601. opposed to collecting just a few elements of an array or a few struct
  28602. members). For each object, its name and value are printed.
  28603. The @code{--var-print-values} option affects how or whether the value
  28604. field is output. If @var{var_pval} is 0, then print only the names;
  28605. if it is 1, print also their values; and if it is 2, print the name,
  28606. type and value for simple data types, and the name and type for
  28607. arrays, structures and unions.
  28608. @item computed-expressions
  28609. The set of computed expressions that have been collected at the
  28610. current trace frame. The @code{--comp-print-values} option affects
  28611. this set like the @code{--var-print-values} option affects the
  28612. @code{explicit-variables} set. See above.
  28613. @item registers
  28614. The registers that have been collected at the current trace frame.
  28615. For each register collected, the name and current value are returned.
  28616. The value is formatted according to the @code{--registers-format}
  28617. option. See the @command{-data-list-register-values} command for a
  28618. list of the allowed formats. The default is @samp{x}.
  28619. @item tvars
  28620. The trace state variables that have been collected at the current
  28621. trace frame. For each trace state variable collected, the name and
  28622. current value are returned.
  28623. @item memory
  28624. The set of memory ranges that have been collected at the current trace
  28625. frame. Its content is a list of tuples. Each tuple represents a
  28626. collected memory range and has the following fields:
  28627. @table @code
  28628. @item address
  28629. The start address of the memory range, as hexadecimal literal.
  28630. @item length
  28631. The length of the memory range, as decimal literal.
  28632. @item contents
  28633. The contents of the memory block, in hex. This field is only present
  28634. if the @code{--memory-contents} option is specified.
  28635. @end table
  28636. @end table
  28637. @subsubheading @value{GDBN} Command
  28638. There is no corresponding @value{GDBN} command.
  28639. @subsubheading Example
  28640. @subheading -trace-list-variables
  28641. @findex -trace-list-variables
  28642. @subsubheading Synopsis
  28643. @smallexample
  28644. -trace-list-variables
  28645. @end smallexample
  28646. Return a table of all defined trace variables. Each element of the
  28647. table has the following fields:
  28648. @table @samp
  28649. @item name
  28650. The name of the trace variable. This field is always present.
  28651. @item initial
  28652. The initial value. This is a 64-bit signed integer. This
  28653. field is always present.
  28654. @item current
  28655. The value the trace variable has at the moment. This is a 64-bit
  28656. signed integer. This field is absent iff current value is
  28657. not defined, for example if the trace was never run, or is
  28658. presently running.
  28659. @end table
  28660. @subsubheading @value{GDBN} Command
  28661. The corresponding @value{GDBN} command is @samp{tvariables}.
  28662. @subsubheading Example
  28663. @smallexample
  28664. (gdb)
  28665. -trace-list-variables
  28666. ^done,trace-variables=@{nr_rows="1",nr_cols="3",
  28667. hdr=[@{width="15",alignment="-1",col_name="name",colhdr="Name"@},
  28668. @{width="11",alignment="-1",col_name="initial",colhdr="Initial"@},
  28669. @{width="11",alignment="-1",col_name="current",colhdr="Current"@}],
  28670. body=[variable=@{name="$trace_timestamp",initial="0"@}
  28671. variable=@{name="$foo",initial="10",current="15"@}]@}
  28672. (gdb)
  28673. @end smallexample
  28674. @subheading -trace-save
  28675. @findex -trace-save
  28676. @subsubheading Synopsis
  28677. @smallexample
  28678. -trace-save [ -r ] [ -ctf ] @var{filename}
  28679. @end smallexample
  28680. Saves the collected trace data to @var{filename}. Without the
  28681. @samp{-r} option, the data is downloaded from the target and saved
  28682. in a local file. With the @samp{-r} option the target is asked
  28683. to perform the save.
  28684. By default, this command will save the trace in the tfile format. You can
  28685. supply the optional @samp{-ctf} argument to save it the CTF format. See
  28686. @ref{Trace Files} for more information about CTF.
  28687. @subsubheading @value{GDBN} Command
  28688. The corresponding @value{GDBN} command is @samp{tsave}.
  28689. @subheading -trace-start
  28690. @findex -trace-start
  28691. @subsubheading Synopsis
  28692. @smallexample
  28693. -trace-start
  28694. @end smallexample
  28695. Starts a tracing experiment. The result of this command does not
  28696. have any fields.
  28697. @subsubheading @value{GDBN} Command
  28698. The corresponding @value{GDBN} command is @samp{tstart}.
  28699. @subheading -trace-status
  28700. @findex -trace-status
  28701. @subsubheading Synopsis
  28702. @smallexample
  28703. -trace-status
  28704. @end smallexample
  28705. Obtains the status of a tracing experiment. The result may include
  28706. the following fields:
  28707. @table @samp
  28708. @item supported
  28709. May have a value of either @samp{0}, when no tracing operations are
  28710. supported, @samp{1}, when all tracing operations are supported, or
  28711. @samp{file} when examining trace file. In the latter case, examining
  28712. of trace frame is possible but new tracing experiement cannot be
  28713. started. This field is always present.
  28714. @item running
  28715. May have a value of either @samp{0} or @samp{1} depending on whether
  28716. tracing experiement is in progress on target. This field is present
  28717. if @samp{supported} field is not @samp{0}.
  28718. @item stop-reason
  28719. Report the reason why the tracing was stopped last time. This field
  28720. may be absent iff tracing was never stopped on target yet. The
  28721. value of @samp{request} means the tracing was stopped as result of
  28722. the @code{-trace-stop} command. The value of @samp{overflow} means
  28723. the tracing buffer is full. The value of @samp{disconnection} means
  28724. tracing was automatically stopped when @value{GDBN} has disconnected.
  28725. The value of @samp{passcount} means tracing was stopped when a
  28726. tracepoint was passed a maximal number of times for that tracepoint.
  28727. This field is present if @samp{supported} field is not @samp{0}.
  28728. @item stopping-tracepoint
  28729. The number of tracepoint whose passcount as exceeded. This field is
  28730. present iff the @samp{stop-reason} field has the value of
  28731. @samp{passcount}.
  28732. @item frames
  28733. @itemx frames-created
  28734. The @samp{frames} field is a count of the total number of trace frames
  28735. in the trace buffer, while @samp{frames-created} is the total created
  28736. during the run, including ones that were discarded, such as when a
  28737. circular trace buffer filled up. Both fields are optional.
  28738. @item buffer-size
  28739. @itemx buffer-free
  28740. These fields tell the current size of the tracing buffer and the
  28741. remaining space. These fields are optional.
  28742. @item circular
  28743. The value of the circular trace buffer flag. @code{1} means that the
  28744. trace buffer is circular and old trace frames will be discarded if
  28745. necessary to make room, @code{0} means that the trace buffer is linear
  28746. and may fill up.
  28747. @item disconnected
  28748. The value of the disconnected tracing flag. @code{1} means that
  28749. tracing will continue after @value{GDBN} disconnects, @code{0} means
  28750. that the trace run will stop.
  28751. @item trace-file
  28752. The filename of the trace file being examined. This field is
  28753. optional, and only present when examining a trace file.
  28754. @end table
  28755. @subsubheading @value{GDBN} Command
  28756. The corresponding @value{GDBN} command is @samp{tstatus}.
  28757. @subheading -trace-stop
  28758. @findex -trace-stop
  28759. @subsubheading Synopsis
  28760. @smallexample
  28761. -trace-stop
  28762. @end smallexample
  28763. Stops a tracing experiment. The result of this command has the same
  28764. fields as @code{-trace-status}, except that the @samp{supported} and
  28765. @samp{running} fields are not output.
  28766. @subsubheading @value{GDBN} Command
  28767. The corresponding @value{GDBN} command is @samp{tstop}.
  28768. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  28769. @node GDB/MI Symbol Query
  28770. @section @sc{gdb/mi} Symbol Query Commands
  28771. @ignore
  28772. @subheading The @code{-symbol-info-address} Command
  28773. @findex -symbol-info-address
  28774. @subsubheading Synopsis
  28775. @smallexample
  28776. -symbol-info-address @var{symbol}
  28777. @end smallexample
  28778. Describe where @var{symbol} is stored.
  28779. @subsubheading @value{GDBN} Command
  28780. The corresponding @value{GDBN} command is @samp{info address}.
  28781. @subsubheading Example
  28782. N.A.
  28783. @subheading The @code{-symbol-info-file} Command
  28784. @findex -symbol-info-file
  28785. @subsubheading Synopsis
  28786. @smallexample
  28787. -symbol-info-file
  28788. @end smallexample
  28789. Show the file for the symbol.
  28790. @subsubheading @value{GDBN} Command
  28791. There's no equivalent @value{GDBN} command. @code{gdbtk} has
  28792. @samp{gdb_find_file}.
  28793. @subsubheading Example
  28794. N.A.
  28795. @end ignore
  28796. @subheading The @code{-symbol-info-functions} Command
  28797. @findex -symbol-info-functions
  28798. @anchor{-symbol-info-functions}
  28799. @subsubheading Synopsis
  28800. @smallexample
  28801. -symbol-info-functions [--include-nondebug]
  28802. [--type @var{type_regexp}]
  28803. [--name @var{name_regexp}]
  28804. [--max-results @var{limit}]
  28805. @end smallexample
  28806. @noindent
  28807. Return a list containing the names and types for all global functions
  28808. taken from the debug information. The functions are grouped by source
  28809. file, and shown with the line number on which each function is
  28810. defined.
  28811. The @code{--include-nondebug} option causes the output to include
  28812. code symbols from the symbol table.
  28813. The options @code{--type} and @code{--name} allow the symbols returned
  28814. to be filtered based on either the name of the function, or the type
  28815. signature of the function.
  28816. The option @code{--max-results} restricts the command to return no
  28817. more than @var{limit} results. If exactly @var{limit} results are
  28818. returned then there might be additional results available if a higher
  28819. limit is used.
  28820. @subsubheading @value{GDBN} Command
  28821. The corresponding @value{GDBN} command is @samp{info functions}.
  28822. @subsubheading Example
  28823. @smallexample
  28824. @group
  28825. (gdb)
  28826. -symbol-info-functions
  28827. ^done,symbols=
  28828. @{debug=
  28829. [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  28830. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  28831. symbols=[@{line="36", name="f4", type="void (int *)",
  28832. description="void f4(int *);"@},
  28833. @{line="42", name="main", type="int ()",
  28834. description="int main();"@},
  28835. @{line="30", name="f1", type="my_int_t (int, int)",
  28836. description="static my_int_t f1(int, int);"@}]@},
  28837. @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  28838. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  28839. symbols=[@{line="33", name="f2", type="float (another_float_t)",
  28840. description="float f2(another_float_t);"@},
  28841. @{line="39", name="f3", type="int (another_int_t)",
  28842. description="int f3(another_int_t);"@},
  28843. @{line="27", name="f1", type="another_float_t (int)",
  28844. description="static another_float_t f1(int);"@}]@}]@}
  28845. @end group
  28846. @group
  28847. (gdb)
  28848. -symbol-info-functions --name f1
  28849. ^done,symbols=
  28850. @{debug=
  28851. [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  28852. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  28853. symbols=[@{line="30", name="f1", type="my_int_t (int, int)",
  28854. description="static my_int_t f1(int, int);"@}]@},
  28855. @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  28856. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  28857. symbols=[@{line="27", name="f1", type="another_float_t (int)",
  28858. description="static another_float_t f1(int);"@}]@}]@}
  28859. @end group
  28860. @group
  28861. (gdb)
  28862. -symbol-info-functions --type void
  28863. ^done,symbols=
  28864. @{debug=
  28865. [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  28866. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  28867. symbols=[@{line="36", name="f4", type="void (int *)",
  28868. description="void f4(int *);"@}]@}]@}
  28869. @end group
  28870. @group
  28871. (gdb)
  28872. -symbol-info-functions --include-nondebug
  28873. ^done,symbols=
  28874. @{debug=
  28875. [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  28876. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  28877. symbols=[@{line="36", name="f4", type="void (int *)",
  28878. description="void f4(int *);"@},
  28879. @{line="42", name="main", type="int ()",
  28880. description="int main();"@},
  28881. @{line="30", name="f1", type="my_int_t (int, int)",
  28882. description="static my_int_t f1(int, int);"@}]@},
  28883. @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  28884. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  28885. symbols=[@{line="33", name="f2", type="float (another_float_t)",
  28886. description="float f2(another_float_t);"@},
  28887. @{line="39", name="f3", type="int (another_int_t)",
  28888. description="int f3(another_int_t);"@},
  28889. @{line="27", name="f1", type="another_float_t (int)",
  28890. description="static another_float_t f1(int);"@}]@}],
  28891. nondebug=
  28892. [@{address="0x0000000000400398",name="_init"@},
  28893. @{address="0x00000000004003b0",name="_start"@},
  28894. ...
  28895. ]@}
  28896. @end group
  28897. @end smallexample
  28898. @subheading The @code{-symbol-info-module-functions} Command
  28899. @findex -symbol-info-module-functions
  28900. @anchor{-symbol-info-module-functions}
  28901. @subsubheading Synopsis
  28902. @smallexample
  28903. -symbol-info-module-functions [--module @var{module_regexp}]
  28904. [--name @var{name_regexp}]
  28905. [--type @var{type_regexp}]
  28906. @end smallexample
  28907. @noindent
  28908. Return a list containing the names of all known functions within all
  28909. know Fortran modules. The functions are grouped by source file and
  28910. containing module, and shown with the line number on which each
  28911. function is defined.
  28912. The option @code{--module} only returns results for modules matching
  28913. @var{module_regexp}. The option @code{--name} only returns functions
  28914. whose name matches @var{name_regexp}, and @code{--type} only returns
  28915. functions whose type matches @var{type_regexp}.
  28916. @subsubheading @value{GDBN} Command
  28917. The corresponding @value{GDBN} command is @samp{info module functions}.
  28918. @subsubheading Example
  28919. @smallexample
  28920. @group
  28921. (gdb)
  28922. -symbol-info-module-functions
  28923. ^done,symbols=
  28924. [@{module="mod1",
  28925. files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  28926. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  28927. symbols=[@{line="21",name="mod1::check_all",type="void (void)",
  28928. description="void mod1::check_all(void);"@}]@}]@},
  28929. @{module="mod2",
  28930. files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  28931. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  28932. symbols=[@{line="30",name="mod2::check_var_i",type="void (void)",
  28933. description="void mod2::check_var_i(void);"@}]@}]@},
  28934. @{module="mod3",
  28935. files=[@{filename="/projec/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  28936. fullname="/projec/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  28937. symbols=[@{line="21",name="mod3::check_all",type="void (void)",
  28938. description="void mod3::check_all(void);"@},
  28939. @{line="27",name="mod3::check_mod2",type="void (void)",
  28940. description="void mod3::check_mod2(void);"@}]@}]@},
  28941. @{module="modmany",
  28942. files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  28943. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  28944. symbols=[@{line="35",name="modmany::check_some",type="void (void)",
  28945. description="void modmany::check_some(void);"@}]@}]@},
  28946. @{module="moduse",
  28947. files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  28948. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  28949. symbols=[@{line="44",name="moduse::check_all",type="void (void)",
  28950. description="void moduse::check_all(void);"@},
  28951. @{line="49",name="moduse::check_var_x",type="void (void)",
  28952. description="void moduse::check_var_x(void);"@}]@}]@}]
  28953. @end group
  28954. @end smallexample
  28955. @subheading The @code{-symbol-info-module-variables} Command
  28956. @findex -symbol-info-module-variables
  28957. @anchor{-symbol-info-module-variables}
  28958. @subsubheading Synopsis
  28959. @smallexample
  28960. -symbol-info-module-variables [--module @var{module_regexp}]
  28961. [--name @var{name_regexp}]
  28962. [--type @var{type_regexp}]
  28963. @end smallexample
  28964. @noindent
  28965. Return a list containing the names of all known variables within all
  28966. know Fortran modules. The variables are grouped by source file and
  28967. containing module, and shown with the line number on which each
  28968. variable is defined.
  28969. The option @code{--module} only returns results for modules matching
  28970. @var{module_regexp}. The option @code{--name} only returns variables
  28971. whose name matches @var{name_regexp}, and @code{--type} only returns
  28972. variables whose type matches @var{type_regexp}.
  28973. @subsubheading @value{GDBN} Command
  28974. The corresponding @value{GDBN} command is @samp{info module variables}.
  28975. @subsubheading Example
  28976. @smallexample
  28977. @group
  28978. (gdb)
  28979. -symbol-info-module-variables
  28980. ^done,symbols=
  28981. [@{module="mod1",
  28982. files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  28983. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  28984. symbols=[@{line="18",name="mod1::var_const",type="integer(kind=4)",
  28985. description="integer(kind=4) mod1::var_const;"@},
  28986. @{line="17",name="mod1::var_i",type="integer(kind=4)",
  28987. description="integer(kind=4) mod1::var_i;"@}]@}]@},
  28988. @{module="mod2",
  28989. files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  28990. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  28991. symbols=[@{line="28",name="mod2::var_i",type="integer(kind=4)",
  28992. description="integer(kind=4) mod2::var_i;"@}]@}]@},
  28993. @{module="mod3",
  28994. files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  28995. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  28996. symbols=[@{line="18",name="mod3::mod1",type="integer(kind=4)",
  28997. description="integer(kind=4) mod3::mod1;"@},
  28998. @{line="17",name="mod3::mod2",type="integer(kind=4)",
  28999. description="integer(kind=4) mod3::mod2;"@},
  29000. @{line="19",name="mod3::var_i",type="integer(kind=4)",
  29001. description="integer(kind=4) mod3::var_i;"@}]@}]@},
  29002. @{module="modmany",
  29003. files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  29004. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  29005. symbols=[@{line="33",name="modmany::var_a",type="integer(kind=4)",
  29006. description="integer(kind=4) modmany::var_a;"@},
  29007. @{line="33",name="modmany::var_b",type="integer(kind=4)",
  29008. description="integer(kind=4) modmany::var_b;"@},
  29009. @{line="33",name="modmany::var_c",type="integer(kind=4)",
  29010. description="integer(kind=4) modmany::var_c;"@},
  29011. @{line="33",name="modmany::var_i",type="integer(kind=4)",
  29012. description="integer(kind=4) modmany::var_i;"@}]@}]@},
  29013. @{module="moduse",
  29014. files=[@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  29015. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  29016. symbols=[@{line="42",name="moduse::var_x",type="integer(kind=4)",
  29017. description="integer(kind=4) moduse::var_x;"@},
  29018. @{line="42",name="moduse::var_y",type="integer(kind=4)",
  29019. description="integer(kind=4) moduse::var_y;"@}]@}]@}]
  29020. @end group
  29021. @end smallexample
  29022. @subheading The @code{-symbol-info-modules} Command
  29023. @findex -symbol-info-modules
  29024. @anchor{-symbol-info-modules}
  29025. @subsubheading Synopsis
  29026. @smallexample
  29027. -symbol-info-modules [--name @var{name_regexp}]
  29028. [--max-results @var{limit}]
  29029. @end smallexample
  29030. @noindent
  29031. Return a list containing the names of all known Fortran modules. The
  29032. modules are grouped by source file, and shown with the line number on
  29033. which each modules is defined.
  29034. The option @code{--name} allows the modules returned to be filtered
  29035. based the name of the module.
  29036. The option @code{--max-results} restricts the command to return no
  29037. more than @var{limit} results. If exactly @var{limit} results are
  29038. returned then there might be additional results available if a higher
  29039. limit is used.
  29040. @subsubheading @value{GDBN} Command
  29041. The corresponding @value{GDBN} command is @samp{info modules}.
  29042. @subsubheading Example
  29043. @smallexample
  29044. @group
  29045. (gdb)
  29046. -symbol-info-modules
  29047. ^done,symbols=
  29048. @{debug=
  29049. [@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  29050. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  29051. symbols=[@{line="16",name="mod1"@},
  29052. @{line="22",name="mod2"@}]@},
  29053. @{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  29054. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  29055. symbols=[@{line="16",name="mod3"@},
  29056. @{line="22",name="modmany"@},
  29057. @{line="26",name="moduse"@}]@}]@}
  29058. @end group
  29059. @group
  29060. (gdb)
  29061. -symbol-info-modules --name mod[123]
  29062. ^done,symbols=
  29063. @{debug=
  29064. [@{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  29065. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules-2.f90",
  29066. symbols=[@{line="16",name="mod1"@},
  29067. @{line="22",name="mod2"@}]@},
  29068. @{filename="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  29069. fullname="/project/gdb/testsuite/gdb.mi/mi-fortran-modules.f90",
  29070. symbols=[@{line="16",name="mod3"@}]@}]@}
  29071. @end group
  29072. @end smallexample
  29073. @subheading The @code{-symbol-info-types} Command
  29074. @findex -symbol-info-types
  29075. @anchor{-symbol-info-types}
  29076. @subsubheading Synopsis
  29077. @smallexample
  29078. -symbol-info-types [--name @var{name_regexp}]
  29079. [--max-results @var{limit}]
  29080. @end smallexample
  29081. @noindent
  29082. Return a list of all defined types. The types are grouped by source
  29083. file, and shown with the line number on which each user defined type
  29084. is defined. Some base types are not defined in the source code but
  29085. are added to the debug information by the compiler, for example
  29086. @code{int}, @code{float}, etc.; these types do not have an associated
  29087. line number.
  29088. The option @code{--name} allows the list of types returned to be
  29089. filtered by name.
  29090. The option @code{--max-results} restricts the command to return no
  29091. more than @var{limit} results. If exactly @var{limit} results are
  29092. returned then there might be additional results available if a higher
  29093. limit is used.
  29094. @subsubheading @value{GDBN} Command
  29095. The corresponding @value{GDBN} command is @samp{info types}.
  29096. @subsubheading Example
  29097. @smallexample
  29098. @group
  29099. (gdb)
  29100. -symbol-info-types
  29101. ^done,symbols=
  29102. @{debug=
  29103. [@{filename="gdb.mi/mi-sym-info-1.c",
  29104. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29105. symbols=[@{name="float"@},
  29106. @{name="int"@},
  29107. @{line="27",name="typedef int my_int_t;"@}]@},
  29108. @{filename="gdb.mi/mi-sym-info-2.c",
  29109. fullname="/project/gdb.mi/mi-sym-info-2.c",
  29110. symbols=[@{line="24",name="typedef float another_float_t;"@},
  29111. @{line="23",name="typedef int another_int_t;"@},
  29112. @{name="float"@},
  29113. @{name="int"@}]@}]@}
  29114. @end group
  29115. @group
  29116. (gdb)
  29117. -symbol-info-types --name _int_
  29118. ^done,symbols=
  29119. @{debug=
  29120. [@{filename="gdb.mi/mi-sym-info-1.c",
  29121. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29122. symbols=[@{line="27",name="typedef int my_int_t;"@}]@},
  29123. @{filename="gdb.mi/mi-sym-info-2.c",
  29124. fullname="/project/gdb.mi/mi-sym-info-2.c",
  29125. symbols=[@{line="23",name="typedef int another_int_t;"@}]@}]@}
  29126. @end group
  29127. @end smallexample
  29128. @subheading The @code{-symbol-info-variables} Command
  29129. @findex -symbol-info-variables
  29130. @anchor{-symbol-info-variables}
  29131. @subsubheading Synopsis
  29132. @smallexample
  29133. -symbol-info-variables [--include-nondebug]
  29134. [--type @var{type_regexp}]
  29135. [--name @var{name_regexp}]
  29136. [--max-results @var{limit}]
  29137. @end smallexample
  29138. @noindent
  29139. Return a list containing the names and types for all global variables
  29140. taken from the debug information. The variables are grouped by source
  29141. file, and shown with the line number on which each variable is
  29142. defined.
  29143. The @code{--include-nondebug} option causes the output to include
  29144. data symbols from the symbol table.
  29145. The options @code{--type} and @code{--name} allow the symbols returned
  29146. to be filtered based on either the name of the variable, or the type
  29147. of the variable.
  29148. The option @code{--max-results} restricts the command to return no
  29149. more than @var{limit} results. If exactly @var{limit} results are
  29150. returned then there might be additional results available if a higher
  29151. limit is used.
  29152. @subsubheading @value{GDBN} Command
  29153. The corresponding @value{GDBN} command is @samp{info variables}.
  29154. @subsubheading Example
  29155. @smallexample
  29156. @group
  29157. (gdb)
  29158. -symbol-info-variables
  29159. ^done,symbols=
  29160. @{debug=
  29161. [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29162. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29163. symbols=[@{line="25",name="global_f1",type="float",
  29164. description="static float global_f1;"@},
  29165. @{line="24",name="global_i1",type="int",
  29166. description="static int global_i1;"@}]@},
  29167. @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  29168. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  29169. symbols=[@{line="21",name="global_f2",type="int",
  29170. description="int global_f2;"@},
  29171. @{line="20",name="global_i2",type="int",
  29172. description="int global_i2;"@},
  29173. @{line="19",name="global_f1",type="float",
  29174. description="static float global_f1;"@},
  29175. @{line="18",name="global_i1",type="int",
  29176. description="static int global_i1;"@}]@}]@}
  29177. @end group
  29178. @group
  29179. (gdb)
  29180. -symbol-info-variables --name f1
  29181. ^done,symbols=
  29182. @{debug=
  29183. [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29184. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29185. symbols=[@{line="25",name="global_f1",type="float",
  29186. description="static float global_f1;"@}]@},
  29187. @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  29188. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  29189. symbols=[@{line="19",name="global_f1",type="float",
  29190. description="static float global_f1;"@}]@}]@}
  29191. @end group
  29192. @group
  29193. (gdb)
  29194. -symbol-info-variables --type float
  29195. ^done,symbols=
  29196. @{debug=
  29197. [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29198. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29199. symbols=[@{line="25",name="global_f1",type="float",
  29200. description="static float global_f1;"@}]@},
  29201. @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  29202. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  29203. symbols=[@{line="19",name="global_f1",type="float",
  29204. description="static float global_f1;"@}]@}]@}
  29205. @end group
  29206. @group
  29207. (gdb)
  29208. -symbol-info-variables --include-nondebug
  29209. ^done,symbols=
  29210. @{debug=
  29211. [@{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29212. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-1.c",
  29213. symbols=[@{line="25",name="global_f1",type="float",
  29214. description="static float global_f1;"@},
  29215. @{line="24",name="global_i1",type="int",
  29216. description="static int global_i1;"@}]@},
  29217. @{filename="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  29218. fullname="/project/gdb/testsuite/gdb.mi/mi-sym-info-2.c",
  29219. symbols=[@{line="21",name="global_f2",type="int",
  29220. description="int global_f2;"@},
  29221. @{line="20",name="global_i2",type="int",
  29222. description="int global_i2;"@},
  29223. @{line="19",name="global_f1",type="float",
  29224. description="static float global_f1;"@},
  29225. @{line="18",name="global_i1",type="int",
  29226. description="static int global_i1;"@}]@}],
  29227. nondebug=
  29228. [@{address="0x00000000004005d0",name="_IO_stdin_used"@},
  29229. @{address="0x00000000004005d8",name="__dso_handle"@}
  29230. ...
  29231. ]@}
  29232. @end group
  29233. @end smallexample
  29234. @ignore
  29235. @subheading The @code{-symbol-info-line} Command
  29236. @findex -symbol-info-line
  29237. @subsubheading Synopsis
  29238. @smallexample
  29239. -symbol-info-line
  29240. @end smallexample
  29241. Show the core addresses of the code for a source line.
  29242. @subsubheading @value{GDBN} Command
  29243. The corresponding @value{GDBN} command is @samp{info line}.
  29244. @code{gdbtk} has the @samp{gdb_get_line} and @samp{gdb_get_file} commands.
  29245. @subsubheading Example
  29246. N.A.
  29247. @subheading The @code{-symbol-info-symbol} Command
  29248. @findex -symbol-info-symbol
  29249. @subsubheading Synopsis
  29250. @smallexample
  29251. -symbol-info-symbol @var{addr}
  29252. @end smallexample
  29253. Describe what symbol is at location @var{addr}.
  29254. @subsubheading @value{GDBN} Command
  29255. The corresponding @value{GDBN} command is @samp{info symbol}.
  29256. @subsubheading Example
  29257. N.A.
  29258. @subheading The @code{-symbol-list-functions} Command
  29259. @findex -symbol-list-functions
  29260. @subsubheading Synopsis
  29261. @smallexample
  29262. -symbol-list-functions
  29263. @end smallexample
  29264. List the functions in the executable.
  29265. @subsubheading @value{GDBN} Command
  29266. @samp{info functions} in @value{GDBN}, @samp{gdb_listfunc} and
  29267. @samp{gdb_search} in @code{gdbtk}.
  29268. @subsubheading Example
  29269. N.A.
  29270. @end ignore
  29271. @subheading The @code{-symbol-list-lines} Command
  29272. @findex -symbol-list-lines
  29273. @subsubheading Synopsis
  29274. @smallexample
  29275. -symbol-list-lines @var{filename}
  29276. @end smallexample
  29277. Print the list of lines that contain code and their associated program
  29278. addresses for the given source filename. The entries are sorted in
  29279. ascending PC order.
  29280. @subsubheading @value{GDBN} Command
  29281. There is no corresponding @value{GDBN} command.
  29282. @subsubheading Example
  29283. @smallexample
  29284. (gdb)
  29285. -symbol-list-lines basics.c
  29286. ^done,lines=[@{pc="0x08048554",line="7"@},@{pc="0x0804855a",line="8"@}]
  29287. (gdb)
  29288. @end smallexample
  29289. @ignore
  29290. @subheading The @code{-symbol-list-types} Command
  29291. @findex -symbol-list-types
  29292. @subsubheading Synopsis
  29293. @smallexample
  29294. -symbol-list-types
  29295. @end smallexample
  29296. List all the type names.
  29297. @subsubheading @value{GDBN} Command
  29298. The corresponding commands are @samp{info types} in @value{GDBN},
  29299. @samp{gdb_search} in @code{gdbtk}.
  29300. @subsubheading Example
  29301. N.A.
  29302. @subheading The @code{-symbol-list-variables} Command
  29303. @findex -symbol-list-variables
  29304. @subsubheading Synopsis
  29305. @smallexample
  29306. -symbol-list-variables
  29307. @end smallexample
  29308. List all the global and static variable names.
  29309. @subsubheading @value{GDBN} Command
  29310. @samp{info variables} in @value{GDBN}, @samp{gdb_search} in @code{gdbtk}.
  29311. @subsubheading Example
  29312. N.A.
  29313. @subheading The @code{-symbol-locate} Command
  29314. @findex -symbol-locate
  29315. @subsubheading Synopsis
  29316. @smallexample
  29317. -symbol-locate
  29318. @end smallexample
  29319. @subsubheading @value{GDBN} Command
  29320. @samp{gdb_loc} in @code{gdbtk}.
  29321. @subsubheading Example
  29322. N.A.
  29323. @subheading The @code{-symbol-type} Command
  29324. @findex -symbol-type
  29325. @subsubheading Synopsis
  29326. @smallexample
  29327. -symbol-type @var{variable}
  29328. @end smallexample
  29329. Show type of @var{variable}.
  29330. @subsubheading @value{GDBN} Command
  29331. The corresponding @value{GDBN} command is @samp{ptype}, @code{gdbtk} has
  29332. @samp{gdb_obj_variable}.
  29333. @subsubheading Example
  29334. N.A.
  29335. @end ignore
  29336. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29337. @node GDB/MI File Commands
  29338. @section @sc{gdb/mi} File Commands
  29339. This section describes the GDB/MI commands to specify executable file names
  29340. and to read in and obtain symbol table information.
  29341. @subheading The @code{-file-exec-and-symbols} Command
  29342. @findex -file-exec-and-symbols
  29343. @subsubheading Synopsis
  29344. @smallexample
  29345. -file-exec-and-symbols @var{file}
  29346. @end smallexample
  29347. Specify the executable file to be debugged. This file is the one from
  29348. which the symbol table is also read. If no file is specified, the
  29349. command clears the executable and symbol information. If breakpoints
  29350. are set when using this command with no arguments, @value{GDBN} will produce
  29351. error messages. Otherwise, no output is produced, except a completion
  29352. notification.
  29353. @subsubheading @value{GDBN} Command
  29354. The corresponding @value{GDBN} command is @samp{file}.
  29355. @subsubheading Example
  29356. @smallexample
  29357. (gdb)
  29358. -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
  29359. ^done
  29360. (gdb)
  29361. @end smallexample
  29362. @subheading The @code{-file-exec-file} Command
  29363. @findex -file-exec-file
  29364. @subsubheading Synopsis
  29365. @smallexample
  29366. -file-exec-file @var{file}
  29367. @end smallexample
  29368. Specify the executable file to be debugged. Unlike
  29369. @samp{-file-exec-and-symbols}, the symbol table is @emph{not} read
  29370. from this file. If used without argument, @value{GDBN} clears the information
  29371. about the executable file. No output is produced, except a completion
  29372. notification.
  29373. @subsubheading @value{GDBN} Command
  29374. The corresponding @value{GDBN} command is @samp{exec-file}.
  29375. @subsubheading Example
  29376. @smallexample
  29377. (gdb)
  29378. -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
  29379. ^done
  29380. (gdb)
  29381. @end smallexample
  29382. @ignore
  29383. @subheading The @code{-file-list-exec-sections} Command
  29384. @findex -file-list-exec-sections
  29385. @subsubheading Synopsis
  29386. @smallexample
  29387. -file-list-exec-sections
  29388. @end smallexample
  29389. List the sections of the current executable file.
  29390. @subsubheading @value{GDBN} Command
  29391. The @value{GDBN} command @samp{info file} shows, among the rest, the same
  29392. information as this command. @code{gdbtk} has a corresponding command
  29393. @samp{gdb_load_info}.
  29394. @subsubheading Example
  29395. N.A.
  29396. @end ignore
  29397. @subheading The @code{-file-list-exec-source-file} Command
  29398. @findex -file-list-exec-source-file
  29399. @subsubheading Synopsis
  29400. @smallexample
  29401. -file-list-exec-source-file
  29402. @end smallexample
  29403. List the line number, the current source file, and the absolute path
  29404. to the current source file for the current executable. The macro
  29405. information field has a value of @samp{1} or @samp{0} depending on
  29406. whether or not the file includes preprocessor macro information.
  29407. @subsubheading @value{GDBN} Command
  29408. The @value{GDBN} equivalent is @samp{info source}
  29409. @subsubheading Example
  29410. @smallexample
  29411. (gdb)
  29412. 123-file-list-exec-source-file
  29413. 123^done,line="1",file="foo.c",fullname="/home/bar/foo.c,macro-info="1"
  29414. (gdb)
  29415. @end smallexample
  29416. @subheading The @code{-file-list-exec-source-files} Command
  29417. @kindex info sources
  29418. @findex -file-list-exec-source-files
  29419. @subsubheading Synopsis
  29420. @smallexample
  29421. -file-list-exec-source-files @r{[} @var{--group-by-objfile} @r{]}
  29422. @r{[} @var{--dirname} @r{|} @var{--basename} @r{]}
  29423. @r{[} -- @r{]}
  29424. @r{[} @var{regexp} @r{]}
  29425. @end smallexample
  29426. This command returns information about the source files @value{GDBN}
  29427. knows about, it will output both the filename and fullname (absolute
  29428. file name) of a source file, though the fullname can be elided if this
  29429. information is not known to @value{GDBN}.
  29430. With no arguments this command returns a list of source files. Each
  29431. source file is represented by a tuple with the fields; @var{file},
  29432. @var{fullname}, and @var{debug-fully-read}. The @var{file} is the
  29433. display name for the file, while @var{fullname} is the absolute name
  29434. of the file. The @var{fullname} field can be elided if the absolute
  29435. name of the source file can't be computed. The field
  29436. @var{debug-fully-read} will be a string, either @code{true} or
  29437. @code{false}. When @code{true}, this indicates the full debug
  29438. information for the compilation unit describing this file has been
  29439. read in. When @code{false}, the full debug information has not yet
  29440. been read in. While reading in the full debug information it is
  29441. possible that @value{GDBN} could become aware of additional source
  29442. files.
  29443. The optional @var{regexp} can be used to filter the list of source
  29444. files returned. The @var{regexp} will be matched against the full
  29445. source file name. The matching is case-sensitive, except on operating
  29446. systems that have case-insensitive filesystem (e.g.,
  29447. MS-Windows). @samp{--} can be used before @var{regexp} to prevent
  29448. @value{GDBN} interpreting @var{regexp} as a command option (e.g.@: if
  29449. @var{regexp} starts with @samp{-}).
  29450. If @code{--dirname} is provided, then @var{regexp} is matched only
  29451. against the directory name of each source file. If @code{--basename}
  29452. is provided, then @var{regexp} is matched against the basename of each
  29453. source file. Only one of @code{--dirname} or @code{--basename} may be
  29454. given, and if either is given then @var{regexp} is required.
  29455. If @code{--group-by-objfile} is used then the format of the results is
  29456. changed. The results will now be a list of tuples, with each tuple
  29457. representing an object file (executable or shared library) loaded into
  29458. @value{GDBN}. The fields of these tuples are; @var{filename},
  29459. @var{debug-info}, and @var{sources}. The @var{filename} is the
  29460. absolute name of the object file, @var{debug-info} is a string with
  29461. one of the following values:
  29462. @table @code
  29463. @item none
  29464. This object file has no debug information.
  29465. @item partially-read
  29466. This object file has debug information, but it is not fully read in
  29467. yet. When it is read in later, GDB might become aware of additional
  29468. source files.
  29469. @item fully-read
  29470. This object file has debug information, and this information is fully
  29471. read into GDB. The list of source files is complete.
  29472. @end table
  29473. The @var{sources} is a list or tuples, with each tuple describing a
  29474. single source file with the same fields as described previously. The
  29475. @var{sources} list can be empty for object files that have no debug
  29476. information.
  29477. @subsubheading @value{GDBN} Command
  29478. The @value{GDBN} equivalent is @samp{info sources}.
  29479. @code{gdbtk} has an analogous command @samp{gdb_listfiles}.
  29480. @subsubheading Example
  29481. @smallexample
  29482. (@value{GDBP})
  29483. -file-list-exec-source-files
  29484. ^done,files=[@{file="foo.c",fullname="/home/foo.c",debug-fully-read="true"@},
  29485. @{file="/home/bar.c",fullname="/home/bar.c",debug-fully-read="true"@},
  29486. @{file="gdb_could_not_find_fullpath.c",debug-fully-read="true"@}]
  29487. (@value{GDBP})
  29488. -file-list-exec-source-files
  29489. ^done,files=[@{file="test.c",
  29490. fullname="/tmp/info-sources/test.c",
  29491. debug-fully-read="true"@},
  29492. @{file="/usr/include/stdc-predef.h",
  29493. fullname="/usr/include/stdc-predef.h",
  29494. debug-fully-read="true"@},
  29495. @{file="header.h",
  29496. fullname="/tmp/info-sources/header.h",
  29497. debug-fully-read="true"@},
  29498. @{file="helper.c",
  29499. fullname="/tmp/info-sources/helper.c",
  29500. debug-fully-read="true"@}]
  29501. (@value{GDBP})
  29502. -file-list-exec-source-files -- \\.c
  29503. ^done,files=[@{file="test.c",
  29504. fullname="/tmp/info-sources/test.c",
  29505. debug-fully-read="true"@},
  29506. @{file="helper.c",
  29507. fullname="/tmp/info-sources/helper.c",
  29508. debug-fully-read="true"@}]
  29509. (@value{GDBP})
  29510. -file-list-exec-source-files --group-by-objfile
  29511. ^done,files=[@{filename="/tmp/info-sources/test.x",
  29512. debug-info="fully-read",
  29513. sources=[@{file="test.c",
  29514. fullname="/tmp/info-sources/test.c",
  29515. debug-fully-read="true"@},
  29516. @{file="/usr/include/stdc-predef.h",
  29517. fullname="/usr/include/stdc-predef.h",
  29518. debug-fully-read="true"@},
  29519. @{file="header.h",
  29520. fullname="/tmp/info-sources/header.h",
  29521. debug-fully-read="true"@}]@},
  29522. @{filename="/lib64/ld-linux-x86-64.so.2",
  29523. debug-info="none",
  29524. sources=[]@},
  29525. @{filename="system-supplied DSO at 0x7ffff7fcf000",
  29526. debug-info="none",
  29527. sources=[]@},
  29528. @{filename="/tmp/info-sources/libhelper.so",
  29529. debug-info="fully-read",
  29530. sources=[@{file="helper.c",
  29531. fullname="/tmp/info-sources/helper.c",
  29532. debug-fully-read="true"@},
  29533. @{file="/usr/include/stdc-predef.h",
  29534. fullname="/usr/include/stdc-predef.h",
  29535. debug-fully-read="true"@},
  29536. @{file="header.h",
  29537. fullname="/tmp/info-sources/header.h",
  29538. debug-fully-read="true"@}]@},
  29539. @{filename="/lib64/libc.so.6",
  29540. debug-info="none",
  29541. sources=[]@}]
  29542. @end smallexample
  29543. @subheading The @code{-file-list-shared-libraries} Command
  29544. @findex -file-list-shared-libraries
  29545. @subsubheading Synopsis
  29546. @smallexample
  29547. -file-list-shared-libraries [ @var{regexp} ]
  29548. @end smallexample
  29549. List the shared libraries in the program.
  29550. With a regular expression @var{regexp}, only those libraries whose
  29551. names match @var{regexp} are listed.
  29552. @subsubheading @value{GDBN} Command
  29553. The corresponding @value{GDBN} command is @samp{info shared}. The fields
  29554. have a similar meaning to the @code{=library-loaded} notification.
  29555. The @code{ranges} field specifies the multiple segments belonging to this
  29556. library. Each range has the following fields:
  29557. @table @samp
  29558. @item from
  29559. The address defining the inclusive lower bound of the segment.
  29560. @item to
  29561. The address defining the exclusive upper bound of the segment.
  29562. @end table
  29563. @subsubheading Example
  29564. @smallexample
  29565. (gdb)
  29566. -file-list-exec-source-files
  29567. ^done,shared-libraries=[
  29568. @{id="/lib/libfoo.so",target-name="/lib/libfoo.so",host-name="/lib/libfoo.so",symbols-loaded="1",thread-group="i1",ranges=[@{from="0x72815989",to="0x728162c0"@}]@},
  29569. @{id="/lib/libbar.so",target-name="/lib/libbar.so",host-name="/lib/libbar.so",symbols-loaded="1",thread-group="i1",ranges=[@{from="0x76ee48c0",to="0x76ee9160"@}]@}]
  29570. (gdb)
  29571. @end smallexample
  29572. @ignore
  29573. @subheading The @code{-file-list-symbol-files} Command
  29574. @findex -file-list-symbol-files
  29575. @subsubheading Synopsis
  29576. @smallexample
  29577. -file-list-symbol-files
  29578. @end smallexample
  29579. List symbol files.
  29580. @subsubheading @value{GDBN} Command
  29581. The corresponding @value{GDBN} command is @samp{info file} (part of it).
  29582. @subsubheading Example
  29583. N.A.
  29584. @end ignore
  29585. @subheading The @code{-file-symbol-file} Command
  29586. @findex -file-symbol-file
  29587. @subsubheading Synopsis
  29588. @smallexample
  29589. -file-symbol-file @var{file}
  29590. @end smallexample
  29591. Read symbol table info from the specified @var{file} argument. When
  29592. used without arguments, clears @value{GDBN}'s symbol table info. No output is
  29593. produced, except for a completion notification.
  29594. @subsubheading @value{GDBN} Command
  29595. The corresponding @value{GDBN} command is @samp{symbol-file}.
  29596. @subsubheading Example
  29597. @smallexample
  29598. (gdb)
  29599. -file-symbol-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx
  29600. ^done
  29601. (gdb)
  29602. @end smallexample
  29603. @ignore
  29604. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29605. @node GDB/MI Memory Overlay Commands
  29606. @section @sc{gdb/mi} Memory Overlay Commands
  29607. The memory overlay commands are not implemented.
  29608. @c @subheading -overlay-auto
  29609. @c @subheading -overlay-list-mapping-state
  29610. @c @subheading -overlay-list-overlays
  29611. @c @subheading -overlay-map
  29612. @c @subheading -overlay-off
  29613. @c @subheading -overlay-on
  29614. @c @subheading -overlay-unmap
  29615. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29616. @node GDB/MI Signal Handling Commands
  29617. @section @sc{gdb/mi} Signal Handling Commands
  29618. Signal handling commands are not implemented.
  29619. @c @subheading -signal-handle
  29620. @c @subheading -signal-list-handle-actions
  29621. @c @subheading -signal-list-signal-types
  29622. @end ignore
  29623. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29624. @node GDB/MI Target Manipulation
  29625. @section @sc{gdb/mi} Target Manipulation Commands
  29626. @subheading The @code{-target-attach} Command
  29627. @findex -target-attach
  29628. @subsubheading Synopsis
  29629. @smallexample
  29630. -target-attach @var{pid} | @var{gid} | @var{file}
  29631. @end smallexample
  29632. Attach to a process @var{pid} or a file @var{file} outside of
  29633. @value{GDBN}, or a thread group @var{gid}. If attaching to a thread
  29634. group, the id previously returned by
  29635. @samp{-list-thread-groups --available} must be used.
  29636. @subsubheading @value{GDBN} Command
  29637. The corresponding @value{GDBN} command is @samp{attach}.
  29638. @subsubheading Example
  29639. @smallexample
  29640. (gdb)
  29641. -target-attach 34
  29642. =thread-created,id="1"
  29643. *stopped,thread-id="1",frame=@{addr="0xb7f7e410",func="bar",args=[]@}
  29644. ^done
  29645. (gdb)
  29646. @end smallexample
  29647. @ignore
  29648. @subheading The @code{-target-compare-sections} Command
  29649. @findex -target-compare-sections
  29650. @subsubheading Synopsis
  29651. @smallexample
  29652. -target-compare-sections [ @var{section} ]
  29653. @end smallexample
  29654. Compare data of section @var{section} on target to the exec file.
  29655. Without the argument, all sections are compared.
  29656. @subsubheading @value{GDBN} Command
  29657. The @value{GDBN} equivalent is @samp{compare-sections}.
  29658. @subsubheading Example
  29659. N.A.
  29660. @end ignore
  29661. @subheading The @code{-target-detach} Command
  29662. @findex -target-detach
  29663. @subsubheading Synopsis
  29664. @smallexample
  29665. -target-detach [ @var{pid} | @var{gid} ]
  29666. @end smallexample
  29667. Detach from the remote target which normally resumes its execution.
  29668. If either @var{pid} or @var{gid} is specified, detaches from either
  29669. the specified process, or specified thread group. There's no output.
  29670. @subsubheading @value{GDBN} Command
  29671. The corresponding @value{GDBN} command is @samp{detach}.
  29672. @subsubheading Example
  29673. @smallexample
  29674. (gdb)
  29675. -target-detach
  29676. ^done
  29677. (gdb)
  29678. @end smallexample
  29679. @subheading The @code{-target-disconnect} Command
  29680. @findex -target-disconnect
  29681. @subsubheading Synopsis
  29682. @smallexample
  29683. -target-disconnect
  29684. @end smallexample
  29685. Disconnect from the remote target. There's no output and the target is
  29686. generally not resumed.
  29687. @subsubheading @value{GDBN} Command
  29688. The corresponding @value{GDBN} command is @samp{disconnect}.
  29689. @subsubheading Example
  29690. @smallexample
  29691. (gdb)
  29692. -target-disconnect
  29693. ^done
  29694. (gdb)
  29695. @end smallexample
  29696. @subheading The @code{-target-download} Command
  29697. @findex -target-download
  29698. @subsubheading Synopsis
  29699. @smallexample
  29700. -target-download
  29701. @end smallexample
  29702. Loads the executable onto the remote target.
  29703. It prints out an update message every half second, which includes the fields:
  29704. @table @samp
  29705. @item section
  29706. The name of the section.
  29707. @item section-sent
  29708. The size of what has been sent so far for that section.
  29709. @item section-size
  29710. The size of the section.
  29711. @item total-sent
  29712. The total size of what was sent so far (the current and the previous sections).
  29713. @item total-size
  29714. The size of the overall executable to download.
  29715. @end table
  29716. @noindent
  29717. Each message is sent as status record (@pxref{GDB/MI Output Syntax, ,
  29718. @sc{gdb/mi} Output Syntax}).
  29719. In addition, it prints the name and size of the sections, as they are
  29720. downloaded. These messages include the following fields:
  29721. @table @samp
  29722. @item section
  29723. The name of the section.
  29724. @item section-size
  29725. The size of the section.
  29726. @item total-size
  29727. The size of the overall executable to download.
  29728. @end table
  29729. @noindent
  29730. At the end, a summary is printed.
  29731. @subsubheading @value{GDBN} Command
  29732. The corresponding @value{GDBN} command is @samp{load}.
  29733. @subsubheading Example
  29734. Note: each status message appears on a single line. Here the messages
  29735. have been broken down so that they can fit onto a page.
  29736. @smallexample
  29737. (gdb)
  29738. -target-download
  29739. +download,@{section=".text",section-size="6668",total-size="9880"@}
  29740. +download,@{section=".text",section-sent="512",section-size="6668",
  29741. total-sent="512",total-size="9880"@}
  29742. +download,@{section=".text",section-sent="1024",section-size="6668",
  29743. total-sent="1024",total-size="9880"@}
  29744. +download,@{section=".text",section-sent="1536",section-size="6668",
  29745. total-sent="1536",total-size="9880"@}
  29746. +download,@{section=".text",section-sent="2048",section-size="6668",
  29747. total-sent="2048",total-size="9880"@}
  29748. +download,@{section=".text",section-sent="2560",section-size="6668",
  29749. total-sent="2560",total-size="9880"@}
  29750. +download,@{section=".text",section-sent="3072",section-size="6668",
  29751. total-sent="3072",total-size="9880"@}
  29752. +download,@{section=".text",section-sent="3584",section-size="6668",
  29753. total-sent="3584",total-size="9880"@}
  29754. +download,@{section=".text",section-sent="4096",section-size="6668",
  29755. total-sent="4096",total-size="9880"@}
  29756. +download,@{section=".text",section-sent="4608",section-size="6668",
  29757. total-sent="4608",total-size="9880"@}
  29758. +download,@{section=".text",section-sent="5120",section-size="6668",
  29759. total-sent="5120",total-size="9880"@}
  29760. +download,@{section=".text",section-sent="5632",section-size="6668",
  29761. total-sent="5632",total-size="9880"@}
  29762. +download,@{section=".text",section-sent="6144",section-size="6668",
  29763. total-sent="6144",total-size="9880"@}
  29764. +download,@{section=".text",section-sent="6656",section-size="6668",
  29765. total-sent="6656",total-size="9880"@}
  29766. +download,@{section=".init",section-size="28",total-size="9880"@}
  29767. +download,@{section=".fini",section-size="28",total-size="9880"@}
  29768. +download,@{section=".data",section-size="3156",total-size="9880"@}
  29769. +download,@{section=".data",section-sent="512",section-size="3156",
  29770. total-sent="7236",total-size="9880"@}
  29771. +download,@{section=".data",section-sent="1024",section-size="3156",
  29772. total-sent="7748",total-size="9880"@}
  29773. +download,@{section=".data",section-sent="1536",section-size="3156",
  29774. total-sent="8260",total-size="9880"@}
  29775. +download,@{section=".data",section-sent="2048",section-size="3156",
  29776. total-sent="8772",total-size="9880"@}
  29777. +download,@{section=".data",section-sent="2560",section-size="3156",
  29778. total-sent="9284",total-size="9880"@}
  29779. +download,@{section=".data",section-sent="3072",section-size="3156",
  29780. total-sent="9796",total-size="9880"@}
  29781. ^done,address="0x10004",load-size="9880",transfer-rate="6586",
  29782. write-rate="429"
  29783. (gdb)
  29784. @end smallexample
  29785. @ignore
  29786. @subheading The @code{-target-exec-status} Command
  29787. @findex -target-exec-status
  29788. @subsubheading Synopsis
  29789. @smallexample
  29790. -target-exec-status
  29791. @end smallexample
  29792. Provide information on the state of the target (whether it is running or
  29793. not, for instance).
  29794. @subsubheading @value{GDBN} Command
  29795. There's no equivalent @value{GDBN} command.
  29796. @subsubheading Example
  29797. N.A.
  29798. @subheading The @code{-target-list-available-targets} Command
  29799. @findex -target-list-available-targets
  29800. @subsubheading Synopsis
  29801. @smallexample
  29802. -target-list-available-targets
  29803. @end smallexample
  29804. List the possible targets to connect to.
  29805. @subsubheading @value{GDBN} Command
  29806. The corresponding @value{GDBN} command is @samp{help target}.
  29807. @subsubheading Example
  29808. N.A.
  29809. @subheading The @code{-target-list-current-targets} Command
  29810. @findex -target-list-current-targets
  29811. @subsubheading Synopsis
  29812. @smallexample
  29813. -target-list-current-targets
  29814. @end smallexample
  29815. Describe the current target.
  29816. @subsubheading @value{GDBN} Command
  29817. The corresponding information is printed by @samp{info file} (among
  29818. other things).
  29819. @subsubheading Example
  29820. N.A.
  29821. @subheading The @code{-target-list-parameters} Command
  29822. @findex -target-list-parameters
  29823. @subsubheading Synopsis
  29824. @smallexample
  29825. -target-list-parameters
  29826. @end smallexample
  29827. @c ????
  29828. @end ignore
  29829. @subsubheading @value{GDBN} Command
  29830. No equivalent.
  29831. @subsubheading Example
  29832. N.A.
  29833. @subheading The @code{-target-flash-erase} Command
  29834. @findex -target-flash-erase
  29835. @subsubheading Synopsis
  29836. @smallexample
  29837. -target-flash-erase
  29838. @end smallexample
  29839. Erases all known flash memory regions on the target.
  29840. The corresponding @value{GDBN} command is @samp{flash-erase}.
  29841. The output is a list of flash regions that have been erased, with starting
  29842. addresses and memory region sizes.
  29843. @smallexample
  29844. (gdb)
  29845. -target-flash-erase
  29846. ^done,erased-regions=@{address="0x0",size="0x40000"@}
  29847. (gdb)
  29848. @end smallexample
  29849. @subheading The @code{-target-select} Command
  29850. @findex -target-select
  29851. @subsubheading Synopsis
  29852. @smallexample
  29853. -target-select @var{type} @var{parameters @dots{}}
  29854. @end smallexample
  29855. Connect @value{GDBN} to the remote target. This command takes two args:
  29856. @table @samp
  29857. @item @var{type}
  29858. The type of target, for instance @samp{remote}, etc.
  29859. @item @var{parameters}
  29860. Device names, host names and the like. @xref{Target Commands, ,
  29861. Commands for Managing Targets}, for more details.
  29862. @end table
  29863. The output is a connection notification, followed by the address at
  29864. which the target program is, in the following form:
  29865. @smallexample
  29866. ^connected,addr="@var{address}",func="@var{function name}",
  29867. args=[@var{arg list}]
  29868. @end smallexample
  29869. @subsubheading @value{GDBN} Command
  29870. The corresponding @value{GDBN} command is @samp{target}.
  29871. @subsubheading Example
  29872. @smallexample
  29873. (gdb)
  29874. -target-select remote /dev/ttya
  29875. ^connected,addr="0xfe00a300",func="??",args=[]
  29876. (gdb)
  29877. @end smallexample
  29878. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29879. @node GDB/MI File Transfer Commands
  29880. @section @sc{gdb/mi} File Transfer Commands
  29881. @subheading The @code{-target-file-put} Command
  29882. @findex -target-file-put
  29883. @subsubheading Synopsis
  29884. @smallexample
  29885. -target-file-put @var{hostfile} @var{targetfile}
  29886. @end smallexample
  29887. Copy file @var{hostfile} from the host system (the machine running
  29888. @value{GDBN}) to @var{targetfile} on the target system.
  29889. @subsubheading @value{GDBN} Command
  29890. The corresponding @value{GDBN} command is @samp{remote put}.
  29891. @subsubheading Example
  29892. @smallexample
  29893. (gdb)
  29894. -target-file-put localfile remotefile
  29895. ^done
  29896. (gdb)
  29897. @end smallexample
  29898. @subheading The @code{-target-file-get} Command
  29899. @findex -target-file-get
  29900. @subsubheading Synopsis
  29901. @smallexample
  29902. -target-file-get @var{targetfile} @var{hostfile}
  29903. @end smallexample
  29904. Copy file @var{targetfile} from the target system to @var{hostfile}
  29905. on the host system.
  29906. @subsubheading @value{GDBN} Command
  29907. The corresponding @value{GDBN} command is @samp{remote get}.
  29908. @subsubheading Example
  29909. @smallexample
  29910. (gdb)
  29911. -target-file-get remotefile localfile
  29912. ^done
  29913. (gdb)
  29914. @end smallexample
  29915. @subheading The @code{-target-file-delete} Command
  29916. @findex -target-file-delete
  29917. @subsubheading Synopsis
  29918. @smallexample
  29919. -target-file-delete @var{targetfile}
  29920. @end smallexample
  29921. Delete @var{targetfile} from the target system.
  29922. @subsubheading @value{GDBN} Command
  29923. The corresponding @value{GDBN} command is @samp{remote delete}.
  29924. @subsubheading Example
  29925. @smallexample
  29926. (gdb)
  29927. -target-file-delete remotefile
  29928. ^done
  29929. (gdb)
  29930. @end smallexample
  29931. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29932. @node GDB/MI Ada Exceptions Commands
  29933. @section Ada Exceptions @sc{gdb/mi} Commands
  29934. @subheading The @code{-info-ada-exceptions} Command
  29935. @findex -info-ada-exceptions
  29936. @subsubheading Synopsis
  29937. @smallexample
  29938. -info-ada-exceptions [ @var{regexp}]
  29939. @end smallexample
  29940. List all Ada exceptions defined within the program being debugged.
  29941. With a regular expression @var{regexp}, only those exceptions whose
  29942. names match @var{regexp} are listed.
  29943. @subsubheading @value{GDBN} Command
  29944. The corresponding @value{GDBN} command is @samp{info exceptions}.
  29945. @subsubheading Result
  29946. The result is a table of Ada exceptions. The following columns are
  29947. defined for each exception:
  29948. @table @samp
  29949. @item name
  29950. The name of the exception.
  29951. @item address
  29952. The address of the exception.
  29953. @end table
  29954. @subsubheading Example
  29955. @smallexample
  29956. -info-ada-exceptions aint
  29957. ^done,ada-exceptions=@{nr_rows="2",nr_cols="2",
  29958. hdr=[@{width="1",alignment="-1",col_name="name",colhdr="Name"@},
  29959. @{width="1",alignment="-1",col_name="address",colhdr="Address"@}],
  29960. body=[@{name="constraint_error",address="0x0000000000613da0"@},
  29961. @{name="const.aint_global_e",address="0x0000000000613b00"@}]@}
  29962. @end smallexample
  29963. @subheading Catching Ada Exceptions
  29964. The commands describing how to ask @value{GDBN} to stop when a program
  29965. raises an exception are described at @ref{Ada Exception GDB/MI
  29966. Catchpoint Commands}.
  29967. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29968. @node GDB/MI Support Commands
  29969. @section @sc{gdb/mi} Support Commands
  29970. Since new commands and features get regularly added to @sc{gdb/mi},
  29971. some commands are available to help front-ends query the debugger
  29972. about support for these capabilities. Similarly, it is also possible
  29973. to query @value{GDBN} about target support of certain features.
  29974. @subheading The @code{-info-gdb-mi-command} Command
  29975. @cindex @code{-info-gdb-mi-command}
  29976. @findex -info-gdb-mi-command
  29977. @subsubheading Synopsis
  29978. @smallexample
  29979. -info-gdb-mi-command @var{cmd_name}
  29980. @end smallexample
  29981. Query support for the @sc{gdb/mi} command named @var{cmd_name}.
  29982. Note that the dash (@code{-}) starting all @sc{gdb/mi} commands
  29983. is technically not part of the command name (@pxref{GDB/MI Input
  29984. Syntax}), and thus should be omitted in @var{cmd_name}. However,
  29985. for ease of use, this command also accepts the form with the leading
  29986. dash.
  29987. @subsubheading @value{GDBN} Command
  29988. There is no corresponding @value{GDBN} command.
  29989. @subsubheading Result
  29990. The result is a tuple. There is currently only one field:
  29991. @table @samp
  29992. @item exists
  29993. This field is equal to @code{"true"} if the @sc{gdb/mi} command exists,
  29994. @code{"false"} otherwise.
  29995. @end table
  29996. @subsubheading Example
  29997. Here is an example where the @sc{gdb/mi} command does not exist:
  29998. @smallexample
  29999. -info-gdb-mi-command unsupported-command
  30000. ^done,command=@{exists="false"@}
  30001. @end smallexample
  30002. @noindent
  30003. And here is an example where the @sc{gdb/mi} command is known
  30004. to the debugger:
  30005. @smallexample
  30006. -info-gdb-mi-command symbol-list-lines
  30007. ^done,command=@{exists="true"@}
  30008. @end smallexample
  30009. @subheading The @code{-list-features} Command
  30010. @findex -list-features
  30011. @cindex supported @sc{gdb/mi} features, list
  30012. Returns a list of particular features of the MI protocol that
  30013. this version of gdb implements. A feature can be a command,
  30014. or a new field in an output of some command, or even an
  30015. important bugfix. While a frontend can sometimes detect presence
  30016. of a feature at runtime, it is easier to perform detection at debugger
  30017. startup.
  30018. The command returns a list of strings, with each string naming an
  30019. available feature. Each returned string is just a name, it does not
  30020. have any internal structure. The list of possible feature names
  30021. is given below.
  30022. Example output:
  30023. @smallexample
  30024. (gdb) -list-features
  30025. ^done,result=["feature1","feature2"]
  30026. @end smallexample
  30027. The current list of features is:
  30028. @ftable @samp
  30029. @item frozen-varobjs
  30030. Indicates support for the @code{-var-set-frozen} command, as well
  30031. as possible presence of the @code{frozen} field in the output
  30032. of @code{-varobj-create}.
  30033. @item pending-breakpoints
  30034. Indicates support for the @option{-f} option to the @code{-break-insert}
  30035. command.
  30036. @item python
  30037. Indicates Python scripting support, Python-based
  30038. pretty-printing commands, and possible presence of the
  30039. @samp{display_hint} field in the output of @code{-var-list-children}
  30040. @item thread-info
  30041. Indicates support for the @code{-thread-info} command.
  30042. @item data-read-memory-bytes
  30043. Indicates support for the @code{-data-read-memory-bytes} and the
  30044. @code{-data-write-memory-bytes} commands.
  30045. @item breakpoint-notifications
  30046. Indicates that changes to breakpoints and breakpoints created via the
  30047. CLI will be announced via async records.
  30048. @item ada-task-info
  30049. Indicates support for the @code{-ada-task-info} command.
  30050. @item language-option
  30051. Indicates that all @sc{gdb/mi} commands accept the @option{--language}
  30052. option (@pxref{Context management}).
  30053. @item info-gdb-mi-command
  30054. Indicates support for the @code{-info-gdb-mi-command} command.
  30055. @item undefined-command-error-code
  30056. Indicates support for the "undefined-command" error code in error result
  30057. records, produced when trying to execute an undefined @sc{gdb/mi} command
  30058. (@pxref{GDB/MI Result Records}).
  30059. @item exec-run-start-option
  30060. Indicates that the @code{-exec-run} command supports the @option{--start}
  30061. option (@pxref{GDB/MI Program Execution}).
  30062. @item data-disassemble-a-option
  30063. Indicates that the @code{-data-disassemble} command supports the @option{-a}
  30064. option (@pxref{GDB/MI Data Manipulation}).
  30065. @end ftable
  30066. @subheading The @code{-list-target-features} Command
  30067. @findex -list-target-features
  30068. Returns a list of particular features that are supported by the
  30069. target. Those features affect the permitted MI commands, but
  30070. unlike the features reported by the @code{-list-features} command, the
  30071. features depend on which target GDB is using at the moment. Whenever
  30072. a target can change, due to commands such as @code{-target-select},
  30073. @code{-target-attach} or @code{-exec-run}, the list of target features
  30074. may change, and the frontend should obtain it again.
  30075. Example output:
  30076. @smallexample
  30077. (gdb) -list-target-features
  30078. ^done,result=["async"]
  30079. @end smallexample
  30080. The current list of features is:
  30081. @table @samp
  30082. @item async
  30083. Indicates that the target is capable of asynchronous command
  30084. execution, which means that @value{GDBN} will accept further commands
  30085. while the target is running.
  30086. @item reverse
  30087. Indicates that the target is capable of reverse execution.
  30088. @xref{Reverse Execution}, for more information.
  30089. @end table
  30090. @c %%%%%%%%%%%%%%%%%%%%%%%%%%%% SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  30091. @node GDB/MI Miscellaneous Commands
  30092. @section Miscellaneous @sc{gdb/mi} Commands
  30093. @c @subheading -gdb-complete
  30094. @subheading The @code{-gdb-exit} Command
  30095. @findex -gdb-exit
  30096. @subsubheading Synopsis
  30097. @smallexample
  30098. -gdb-exit
  30099. @end smallexample
  30100. Exit @value{GDBN} immediately.
  30101. @subsubheading @value{GDBN} Command
  30102. Approximately corresponds to @samp{quit}.
  30103. @subsubheading Example
  30104. @smallexample
  30105. (gdb)
  30106. -gdb-exit
  30107. ^exit
  30108. @end smallexample
  30109. @ignore
  30110. @subheading The @code{-exec-abort} Command
  30111. @findex -exec-abort
  30112. @subsubheading Synopsis
  30113. @smallexample
  30114. -exec-abort
  30115. @end smallexample
  30116. Kill the inferior running program.
  30117. @subsubheading @value{GDBN} Command
  30118. The corresponding @value{GDBN} command is @samp{kill}.
  30119. @subsubheading Example
  30120. N.A.
  30121. @end ignore
  30122. @subheading The @code{-gdb-set} Command
  30123. @findex -gdb-set
  30124. @subsubheading Synopsis
  30125. @smallexample
  30126. -gdb-set
  30127. @end smallexample
  30128. Set an internal @value{GDBN} variable.
  30129. @c IS THIS A DOLLAR VARIABLE? OR SOMETHING LIKE ANNOTATE ?????
  30130. @subsubheading @value{GDBN} Command
  30131. The corresponding @value{GDBN} command is @samp{set}.
  30132. @subsubheading Example
  30133. @smallexample
  30134. (gdb)
  30135. -gdb-set $foo=3
  30136. ^done
  30137. (gdb)
  30138. @end smallexample
  30139. @subheading The @code{-gdb-show} Command
  30140. @findex -gdb-show
  30141. @subsubheading Synopsis
  30142. @smallexample
  30143. -gdb-show
  30144. @end smallexample
  30145. Show the current value of a @value{GDBN} variable.
  30146. @subsubheading @value{GDBN} Command
  30147. The corresponding @value{GDBN} command is @samp{show}.
  30148. @subsubheading Example
  30149. @smallexample
  30150. (gdb)
  30151. -gdb-show annotate
  30152. ^done,value="0"
  30153. (gdb)
  30154. @end smallexample
  30155. @c @subheading -gdb-source
  30156. @subheading The @code{-gdb-version} Command
  30157. @findex -gdb-version
  30158. @subsubheading Synopsis
  30159. @smallexample
  30160. -gdb-version
  30161. @end smallexample
  30162. Show version information for @value{GDBN}. Used mostly in testing.
  30163. @subsubheading @value{GDBN} Command
  30164. The @value{GDBN} equivalent is @samp{show version}. @value{GDBN} by
  30165. default shows this information when you start an interactive session.
  30166. @subsubheading Example
  30167. @c This example modifies the actual output from GDB to avoid overfull
  30168. @c box in TeX.
  30169. @smallexample
  30170. (gdb)
  30171. -gdb-version
  30172. ~GNU gdb 5.2.1
  30173. ~Copyright 2000 Free Software Foundation, Inc.
  30174. ~GDB is free software, covered by the GNU General Public License, and
  30175. ~you are welcome to change it and/or distribute copies of it under
  30176. ~ certain conditions.
  30177. ~Type "show copying" to see the conditions.
  30178. ~There is absolutely no warranty for GDB. Type "show warranty" for
  30179. ~ details.
  30180. ~This GDB was configured as
  30181. "--host=sparc-sun-solaris2.5.1 --target=ppc-eabi".
  30182. ^done
  30183. (gdb)
  30184. @end smallexample
  30185. @subheading The @code{-list-thread-groups} Command
  30186. @findex -list-thread-groups
  30187. @subheading Synopsis
  30188. @smallexample
  30189. -list-thread-groups [ --available ] [ --recurse 1 ] [ @var{group} ... ]
  30190. @end smallexample
  30191. Lists thread groups (@pxref{Thread groups}). When a single thread
  30192. group is passed as the argument, lists the children of that group.
  30193. When several thread group are passed, lists information about those
  30194. thread groups. Without any parameters, lists information about all
  30195. top-level thread groups.
  30196. Normally, thread groups that are being debugged are reported.
  30197. With the @samp{--available} option, @value{GDBN} reports thread groups
  30198. available on the target.
  30199. The output of this command may have either a @samp{threads} result or
  30200. a @samp{groups} result. The @samp{thread} result has a list of tuples
  30201. as value, with each tuple describing a thread (@pxref{GDB/MI Thread
  30202. Information}). The @samp{groups} result has a list of tuples as value,
  30203. each tuple describing a thread group. If top-level groups are
  30204. requested (that is, no parameter is passed), or when several groups
  30205. are passed, the output always has a @samp{groups} result. The format
  30206. of the @samp{group} result is described below.
  30207. To reduce the number of roundtrips it's possible to list thread groups
  30208. together with their children, by passing the @samp{--recurse} option
  30209. and the recursion depth. Presently, only recursion depth of 1 is
  30210. permitted. If this option is present, then every reported thread group
  30211. will also include its children, either as @samp{group} or
  30212. @samp{threads} field.
  30213. In general, any combination of option and parameters is permitted, with
  30214. the following caveats:
  30215. @itemize @bullet
  30216. @item
  30217. When a single thread group is passed, the output will typically
  30218. be the @samp{threads} result. Because threads may not contain
  30219. anything, the @samp{recurse} option will be ignored.
  30220. @item
  30221. When the @samp{--available} option is passed, limited information may
  30222. be available. In particular, the list of threads of a process might
  30223. be inaccessible. Further, specifying specific thread groups might
  30224. not give any performance advantage over listing all thread groups.
  30225. The frontend should assume that @samp{-list-thread-groups --available}
  30226. is always an expensive operation and cache the results.
  30227. @end itemize
  30228. The @samp{groups} result is a list of tuples, where each tuple may
  30229. have the following fields:
  30230. @table @code
  30231. @item id
  30232. Identifier of the thread group. This field is always present.
  30233. The identifier is an opaque string; frontends should not try to
  30234. convert it to an integer, even though it might look like one.
  30235. @item type
  30236. The type of the thread group. At present, only @samp{process} is a
  30237. valid type.
  30238. @item pid
  30239. The target-specific process identifier. This field is only present
  30240. for thread groups of type @samp{process} and only if the process exists.
  30241. @item exit-code
  30242. The exit code of this group's last exited thread, formatted in octal.
  30243. This field is only present for thread groups of type @samp{process} and
  30244. only if the process is not running.
  30245. @item num_children
  30246. The number of children this thread group has. This field may be
  30247. absent for an available thread group.
  30248. @item threads
  30249. This field has a list of tuples as value, each tuple describing a
  30250. thread. It may be present if the @samp{--recurse} option is
  30251. specified, and it's actually possible to obtain the threads.
  30252. @item cores
  30253. This field is a list of integers, each identifying a core that one
  30254. thread of the group is running on. This field may be absent if
  30255. such information is not available.
  30256. @item executable
  30257. The name of the executable file that corresponds to this thread group.
  30258. The field is only present for thread groups of type @samp{process},
  30259. and only if there is a corresponding executable file.
  30260. @end table
  30261. @subheading Example
  30262. @smallexample
  30263. (@value{GDBP})
  30264. -list-thread-groups
  30265. ^done,groups=[@{id="17",type="process",pid="yyy",num_children="2"@}]
  30266. -list-thread-groups 17
  30267. ^done,threads=[@{id="2",target-id="Thread 0xb7e14b90 (LWP 21257)",
  30268. frame=@{level="0",addr="0xffffe410",func="__kernel_vsyscall",args=[]@},state="running"@},
  30269. @{id="1",target-id="Thread 0xb7e156b0 (LWP 21254)",
  30270. frame=@{level="0",addr="0x0804891f",func="foo",args=[@{name="i",value="10"@}],
  30271. file="/tmp/a.c",fullname="/tmp/a.c",line="158",arch="i386:x86_64"@},state="running"@}]]
  30272. -list-thread-groups --available
  30273. ^done,groups=[@{id="17",type="process",pid="yyy",num_children="2",cores=[1,2]@}]
  30274. -list-thread-groups --available --recurse 1
  30275. ^done,groups=[@{id="17", types="process",pid="yyy",num_children="2",cores=[1,2],
  30276. threads=[@{id="1",target-id="Thread 0xb7e14b90",cores=[1]@},
  30277. @{id="2",target-id="Thread 0xb7e14b90",cores=[2]@}]@},..]
  30278. -list-thread-groups --available --recurse 1 17 18
  30279. ^done,groups=[@{id="17", types="process",pid="yyy",num_children="2",cores=[1,2],
  30280. threads=[@{id="1",target-id="Thread 0xb7e14b90",cores=[1]@},
  30281. @{id="2",target-id="Thread 0xb7e14b90",cores=[2]@}]@},...]
  30282. @end smallexample
  30283. @subheading The @code{-info-os} Command
  30284. @findex -info-os
  30285. @subsubheading Synopsis
  30286. @smallexample
  30287. -info-os [ @var{type} ]
  30288. @end smallexample
  30289. If no argument is supplied, the command returns a table of available
  30290. operating-system-specific information types. If one of these types is
  30291. supplied as an argument @var{type}, then the command returns a table
  30292. of data of that type.
  30293. The types of information available depend on the target operating
  30294. system.
  30295. @subsubheading @value{GDBN} Command
  30296. The corresponding @value{GDBN} command is @samp{info os}.
  30297. @subsubheading Example
  30298. When run on a @sc{gnu}/Linux system, the output will look something
  30299. like this:
  30300. @smallexample
  30301. (@value{GDBP})
  30302. -info-os
  30303. ^done,OSDataTable=@{nr_rows="10",nr_cols="3",
  30304. hdr=[@{width="10",alignment="-1",col_name="col0",colhdr="Type"@},
  30305. @{width="10",alignment="-1",col_name="col1",colhdr="Description"@},
  30306. @{width="10",alignment="-1",col_name="col2",colhdr="Title"@}],
  30307. body=[item=@{col0="cpus",col1="Listing of all cpus/cores on the system",
  30308. col2="CPUs"@},
  30309. item=@{col0="files",col1="Listing of all file descriptors",
  30310. col2="File descriptors"@},
  30311. item=@{col0="modules",col1="Listing of all loaded kernel modules",
  30312. col2="Kernel modules"@},
  30313. item=@{col0="msg",col1="Listing of all message queues",
  30314. col2="Message queues"@},
  30315. item=@{col0="processes",col1="Listing of all processes",
  30316. col2="Processes"@},
  30317. item=@{col0="procgroups",col1="Listing of all process groups",
  30318. col2="Process groups"@},
  30319. item=@{col0="semaphores",col1="Listing of all semaphores",
  30320. col2="Semaphores"@},
  30321. item=@{col0="shm",col1="Listing of all shared-memory regions",
  30322. col2="Shared-memory regions"@},
  30323. item=@{col0="sockets",col1="Listing of all internet-domain sockets",
  30324. col2="Sockets"@},
  30325. item=@{col0="threads",col1="Listing of all threads",
  30326. col2="Threads"@}]
  30327. (@value{GDBP})
  30328. -info-os processes
  30329. ^done,OSDataTable=@{nr_rows="190",nr_cols="4",
  30330. hdr=[@{width="10",alignment="-1",col_name="col0",colhdr="pid"@},
  30331. @{width="10",alignment="-1",col_name="col1",colhdr="user"@},
  30332. @{width="10",alignment="-1",col_name="col2",colhdr="command"@},
  30333. @{width="10",alignment="-1",col_name="col3",colhdr="cores"@}],
  30334. body=[item=@{col0="1",col1="root",col2="/sbin/init",col3="0"@},
  30335. item=@{col0="2",col1="root",col2="[kthreadd]",col3="1"@},
  30336. item=@{col0="3",col1="root",col2="[ksoftirqd/0]",col3="0"@},
  30337. ...
  30338. item=@{col0="26446",col1="stan",col2="bash",col3="0"@},
  30339. item=@{col0="28152",col1="stan",col2="bash",col3="1"@}]@}
  30340. (@value{GDBP})
  30341. @end smallexample
  30342. (Note that the MI output here includes a @code{"Title"} column that
  30343. does not appear in command-line @code{info os}; this column is useful
  30344. for MI clients that want to enumerate the types of data, such as in a
  30345. popup menu, but is needless clutter on the command line, and
  30346. @code{info os} omits it.)
  30347. @subheading The @code{-add-inferior} Command
  30348. @findex -add-inferior
  30349. @subheading Synopsis
  30350. @smallexample
  30351. -add-inferior [ --no-connection ]
  30352. @end smallexample
  30353. Creates a new inferior (@pxref{Inferiors Connections and Programs}). The created
  30354. inferior is not associated with any executable. Such association may
  30355. be established with the @samp{-file-exec-and-symbols} command
  30356. (@pxref{GDB/MI File Commands}).
  30357. By default, the new inferior begins connected to the same target
  30358. connection as the current inferior. For example, if the current
  30359. inferior was connected to @code{gdbserver} with @code{target remote},
  30360. then the new inferior will be connected to the same @code{gdbserver}
  30361. instance. The @samp{--no-connection} option starts the new inferior
  30362. with no connection yet. You can then for example use the
  30363. @code{-target-select remote} command to connect to some other
  30364. @code{gdbserver} instance, use @code{-exec-run} to spawn a local
  30365. program, etc.
  30366. The command response always has a field, @var{inferior}, whose value
  30367. is the identifier of the thread group corresponding to the new
  30368. inferior.
  30369. An additional section field, @var{connection}, is optional. This
  30370. field will only exist if the new inferior has a target connection. If
  30371. this field exists, then its value will be a tuple containing the
  30372. following fields:
  30373. @table @samp
  30374. @item number
  30375. The number of the connection used for the new inferior.
  30376. @item name
  30377. The name of the connection type used for the new inferior.
  30378. @end table
  30379. @subheading @value{GDBN} Command
  30380. The corresponding @value{GDBN} command is @samp{add-inferior}
  30381. (@pxref{add_inferior_cli,,@samp{add-inferior}}).
  30382. @subheading Example
  30383. @smallexample
  30384. (@value{GDBP})
  30385. -add-inferior
  30386. ^done,inferior="i3"
  30387. @end smallexample
  30388. @subheading The @code{-interpreter-exec} Command
  30389. @findex -interpreter-exec
  30390. @subheading Synopsis
  30391. @smallexample
  30392. -interpreter-exec @var{interpreter} @var{command}
  30393. @end smallexample
  30394. @anchor{-interpreter-exec}
  30395. Execute the specified @var{command} in the given @var{interpreter}.
  30396. @subheading @value{GDBN} Command
  30397. The corresponding @value{GDBN} command is @samp{interpreter-exec}.
  30398. @subheading Example
  30399. @smallexample
  30400. (gdb)
  30401. -interpreter-exec console "break main"
  30402. &"During symbol reading, couldn't parse type; debugger out of date?.\n"
  30403. &"During symbol reading, bad structure-type format.\n"
  30404. ~"Breakpoint 1 at 0x8074fc6: file ../../src/gdb/main.c, line 743.\n"
  30405. ^done
  30406. (gdb)
  30407. @end smallexample
  30408. @subheading The @code{-inferior-tty-set} Command
  30409. @findex -inferior-tty-set
  30410. @subheading Synopsis
  30411. @smallexample
  30412. -inferior-tty-set /dev/pts/1
  30413. @end smallexample
  30414. Set terminal for future runs of the program being debugged.
  30415. @subheading @value{GDBN} Command
  30416. The corresponding @value{GDBN} command is @samp{set inferior-tty} /dev/pts/1.
  30417. @subheading Example
  30418. @smallexample
  30419. (gdb)
  30420. -inferior-tty-set /dev/pts/1
  30421. ^done
  30422. (gdb)
  30423. @end smallexample
  30424. @subheading The @code{-inferior-tty-show} Command
  30425. @findex -inferior-tty-show
  30426. @subheading Synopsis
  30427. @smallexample
  30428. -inferior-tty-show
  30429. @end smallexample
  30430. Show terminal for future runs of program being debugged.
  30431. @subheading @value{GDBN} Command
  30432. The corresponding @value{GDBN} command is @samp{show inferior-tty}.
  30433. @subheading Example
  30434. @smallexample
  30435. (gdb)
  30436. -inferior-tty-set /dev/pts/1
  30437. ^done
  30438. (gdb)
  30439. -inferior-tty-show
  30440. ^done,inferior_tty_terminal="/dev/pts/1"
  30441. (gdb)
  30442. @end smallexample
  30443. @subheading The @code{-enable-timings} Command
  30444. @findex -enable-timings
  30445. @subheading Synopsis
  30446. @smallexample
  30447. -enable-timings [yes | no]
  30448. @end smallexample
  30449. Toggle the printing of the wallclock, user and system times for an MI
  30450. command as a field in its output. This command is to help frontend
  30451. developers optimize the performance of their code. No argument is
  30452. equivalent to @samp{yes}.
  30453. @subheading @value{GDBN} Command
  30454. No equivalent.
  30455. @subheading Example
  30456. @smallexample
  30457. (gdb)
  30458. -enable-timings
  30459. ^done
  30460. (gdb)
  30461. -break-insert main
  30462. ^done,bkpt=@{number="1",type="breakpoint",disp="keep",enabled="y",
  30463. addr="0x080484ed",func="main",file="myprog.c",
  30464. fullname="/home/nickrob/myprog.c",line="73",thread-groups=["i1"],
  30465. times="0"@},
  30466. time=@{wallclock="0.05185",user="0.00800",system="0.00000"@}
  30467. (gdb)
  30468. -enable-timings no
  30469. ^done
  30470. (gdb)
  30471. -exec-run
  30472. ^running
  30473. (gdb)
  30474. *stopped,reason="breakpoint-hit",disp="keep",bkptno="1",thread-id="0",
  30475. frame=@{addr="0x080484ed",func="main",args=[@{name="argc",value="1"@},
  30476. @{name="argv",value="0xbfb60364"@}],file="myprog.c",
  30477. fullname="/home/nickrob/myprog.c",line="73",arch="i386:x86_64"@}
  30478. (gdb)
  30479. @end smallexample
  30480. @subheading The @code{-complete} Command
  30481. @findex -complete
  30482. @subheading Synopsis
  30483. @smallexample
  30484. -complete @var{command}
  30485. @end smallexample
  30486. Show a list of completions for partially typed CLI @var{command}.
  30487. This command is intended for @sc{gdb/mi} frontends that cannot use two separate
  30488. CLI and MI channels --- for example: because of lack of PTYs like on Windows or
  30489. because @value{GDBN} is used remotely via a SSH connection.
  30490. @subheading Result
  30491. The result consists of two or three fields:
  30492. @table @samp
  30493. @item completion
  30494. This field contains the completed @var{command}. If @var{command}
  30495. has no known completions, this field is omitted.
  30496. @item matches
  30497. This field contains a (possibly empty) array of matches. It is always present.
  30498. @item max_completions_reached
  30499. This field contains @code{1} if number of known completions is above
  30500. @code{max-completions} limit (@pxref{Completion}), otherwise it contains
  30501. @code{0}. It is always present.
  30502. @end table
  30503. @subheading @value{GDBN} Command
  30504. The corresponding @value{GDBN} command is @samp{complete}.
  30505. @subheading Example
  30506. @smallexample
  30507. (gdb)
  30508. -complete br
  30509. ^done,completion="break",
  30510. matches=["break","break-range"],
  30511. max_completions_reached="0"
  30512. (gdb)
  30513. -complete "b ma"
  30514. ^done,completion="b ma",
  30515. matches=["b madvise","b main"],max_completions_reached="0"
  30516. (gdb)
  30517. -complete "b push_b"
  30518. ^done,completion="b push_back(",
  30519. matches=[
  30520. "b A::push_back(void*)",
  30521. "b std::string::push_back(char)",
  30522. "b std::vector<int, std::allocator<int> >::push_back(int&&)"],
  30523. max_completions_reached="0"
  30524. (gdb)
  30525. -complete "nonexist"
  30526. ^done,matches=[],max_completions_reached="0"
  30527. (gdb)
  30528. @end smallexample
  30529. @node Annotations
  30530. @chapter @value{GDBN} Annotations
  30531. This chapter describes annotations in @value{GDBN}. Annotations were
  30532. designed to interface @value{GDBN} to graphical user interfaces or other
  30533. similar programs which want to interact with @value{GDBN} at a
  30534. relatively high level.
  30535. The annotation mechanism has largely been superseded by @sc{gdb/mi}
  30536. (@pxref{GDB/MI}).
  30537. @ignore
  30538. This is Edition @value{EDITION}, @value{DATE}.
  30539. @end ignore
  30540. @menu
  30541. * Annotations Overview:: What annotations are; the general syntax.
  30542. * Server Prefix:: Issuing a command without affecting user state.
  30543. * Prompting:: Annotations marking @value{GDBN}'s need for input.
  30544. * Errors:: Annotations for error messages.
  30545. * Invalidation:: Some annotations describe things now invalid.
  30546. * Annotations for Running::
  30547. Whether the program is running, how it stopped, etc.
  30548. * Source Annotations:: Annotations describing source code.
  30549. @end menu
  30550. @node Annotations Overview
  30551. @section What is an Annotation?
  30552. @cindex annotations
  30553. Annotations start with a newline character, two @samp{control-z}
  30554. characters, and the name of the annotation. If there is no additional
  30555. information associated with this annotation, the name of the annotation
  30556. is followed immediately by a newline. If there is additional
  30557. information, the name of the annotation is followed by a space, the
  30558. additional information, and a newline. The additional information
  30559. cannot contain newline characters.
  30560. Any output not beginning with a newline and two @samp{control-z}
  30561. characters denotes literal output from @value{GDBN}. Currently there is
  30562. no need for @value{GDBN} to output a newline followed by two
  30563. @samp{control-z} characters, but if there was such a need, the
  30564. annotations could be extended with an @samp{escape} annotation which
  30565. means those three characters as output.
  30566. The annotation @var{level}, which is specified using the
  30567. @option{--annotate} command line option (@pxref{Mode Options}), controls
  30568. how much information @value{GDBN} prints together with its prompt,
  30569. values of expressions, source lines, and other types of output. Level 0
  30570. is for no annotations, level 1 is for use when @value{GDBN} is run as a
  30571. subprocess of @sc{gnu} Emacs, level 3 is the maximum annotation suitable
  30572. for programs that control @value{GDBN}, and level 2 annotations have
  30573. been made obsolete (@pxref{Limitations, , Limitations of the Annotation
  30574. Interface, annotate, GDB's Obsolete Annotations}).
  30575. @table @code
  30576. @kindex set annotate
  30577. @item set annotate @var{level}
  30578. The @value{GDBN} command @code{set annotate} sets the level of
  30579. annotations to the specified @var{level}.
  30580. @item show annotate
  30581. @kindex show annotate
  30582. Show the current annotation level.
  30583. @end table
  30584. This chapter describes level 3 annotations.
  30585. A simple example of starting up @value{GDBN} with annotations is:
  30586. @smallexample
  30587. $ @kbd{gdb --annotate=3}
  30588. GNU gdb 6.0
  30589. Copyright 2003 Free Software Foundation, Inc.
  30590. GDB is free software, covered by the GNU General Public License,
  30591. and you are welcome to change it and/or distribute copies of it
  30592. under certain conditions.
  30593. Type "show copying" to see the conditions.
  30594. There is absolutely no warranty for GDB. Type "show warranty"
  30595. for details.
  30596. This GDB was configured as "i386-pc-linux-gnu"
  30597. ^Z^Zpre-prompt
  30598. (@value{GDBP})
  30599. ^Z^Zprompt
  30600. @kbd{quit}
  30601. ^Z^Zpost-prompt
  30602. $
  30603. @end smallexample
  30604. Here @samp{quit} is input to @value{GDBN}; the rest is output from
  30605. @value{GDBN}. The three lines beginning @samp{^Z^Z} (where @samp{^Z}
  30606. denotes a @samp{control-z} character) are annotations; the rest is
  30607. output from @value{GDBN}.
  30608. @node Server Prefix
  30609. @section The Server Prefix
  30610. @cindex server prefix
  30611. If you prefix a command with @samp{server } then it will not affect
  30612. the command history, nor will it affect @value{GDBN}'s notion of which
  30613. command to repeat if @key{RET} is pressed on a line by itself. This
  30614. means that commands can be run behind a user's back by a front-end in
  30615. a transparent manner.
  30616. The @code{server } prefix does not affect the recording of values into
  30617. the value history; to print a value without recording it into the
  30618. value history, use the @code{output} command instead of the
  30619. @code{print} command.
  30620. Using this prefix also disables confirmation requests
  30621. (@pxref{confirmation requests}).
  30622. @node Prompting
  30623. @section Annotation for @value{GDBN} Input
  30624. @cindex annotations for prompts
  30625. When @value{GDBN} prompts for input, it annotates this fact so it is possible
  30626. to know when to send output, when the output from a given command is
  30627. over, etc.
  30628. Different kinds of input each have a different @dfn{input type}. Each
  30629. input type has three annotations: a @code{pre-} annotation, which
  30630. denotes the beginning of any prompt which is being output, a plain
  30631. annotation, which denotes the end of the prompt, and then a @code{post-}
  30632. annotation which denotes the end of any echo which may (or may not) be
  30633. associated with the input. For example, the @code{prompt} input type
  30634. features the following annotations:
  30635. @smallexample
  30636. ^Z^Zpre-prompt
  30637. ^Z^Zprompt
  30638. ^Z^Zpost-prompt
  30639. @end smallexample
  30640. The input types are
  30641. @table @code
  30642. @findex pre-prompt annotation
  30643. @findex prompt annotation
  30644. @findex post-prompt annotation
  30645. @item prompt
  30646. When @value{GDBN} is prompting for a command (the main @value{GDBN} prompt).
  30647. @findex pre-commands annotation
  30648. @findex commands annotation
  30649. @findex post-commands annotation
  30650. @item commands
  30651. When @value{GDBN} prompts for a set of commands, like in the @code{commands}
  30652. command. The annotations are repeated for each command which is input.
  30653. @findex pre-overload-choice annotation
  30654. @findex overload-choice annotation
  30655. @findex post-overload-choice annotation
  30656. @item overload-choice
  30657. When @value{GDBN} wants the user to select between various overloaded functions.
  30658. @findex pre-query annotation
  30659. @findex query annotation
  30660. @findex post-query annotation
  30661. @item query
  30662. When @value{GDBN} wants the user to confirm a potentially dangerous operation.
  30663. @findex pre-prompt-for-continue annotation
  30664. @findex prompt-for-continue annotation
  30665. @findex post-prompt-for-continue annotation
  30666. @item prompt-for-continue
  30667. When @value{GDBN} is asking the user to press return to continue. Note: Don't
  30668. expect this to work well; instead use @code{set height 0} to disable
  30669. prompting. This is because the counting of lines is buggy in the
  30670. presence of annotations.
  30671. @end table
  30672. @node Errors
  30673. @section Errors
  30674. @cindex annotations for errors, warnings and interrupts
  30675. @findex quit annotation
  30676. @smallexample
  30677. ^Z^Zquit
  30678. @end smallexample
  30679. This annotation occurs right before @value{GDBN} responds to an interrupt.
  30680. @findex error annotation
  30681. @smallexample
  30682. ^Z^Zerror
  30683. @end smallexample
  30684. This annotation occurs right before @value{GDBN} responds to an error.
  30685. Quit and error annotations indicate that any annotations which @value{GDBN} was
  30686. in the middle of may end abruptly. For example, if a
  30687. @code{value-history-begin} annotation is followed by a @code{error}, one
  30688. cannot expect to receive the matching @code{value-history-end}. One
  30689. cannot expect not to receive it either, however; an error annotation
  30690. does not necessarily mean that @value{GDBN} is immediately returning all the way
  30691. to the top level.
  30692. @findex error-begin annotation
  30693. A quit or error annotation may be preceded by
  30694. @smallexample
  30695. ^Z^Zerror-begin
  30696. @end smallexample
  30697. Any output between that and the quit or error annotation is the error
  30698. message.
  30699. Warning messages are not yet annotated.
  30700. @c If we want to change that, need to fix warning(), type_error(),
  30701. @c range_error(), and possibly other places.
  30702. @node Invalidation
  30703. @section Invalidation Notices
  30704. @cindex annotations for invalidation messages
  30705. The following annotations say that certain pieces of state may have
  30706. changed.
  30707. @table @code
  30708. @findex frames-invalid annotation
  30709. @item ^Z^Zframes-invalid
  30710. The frames (for example, output from the @code{backtrace} command) may
  30711. have changed.
  30712. @findex breakpoints-invalid annotation
  30713. @item ^Z^Zbreakpoints-invalid
  30714. The breakpoints may have changed. For example, the user just added or
  30715. deleted a breakpoint.
  30716. @end table
  30717. @node Annotations for Running
  30718. @section Running the Program
  30719. @cindex annotations for running programs
  30720. @findex starting annotation
  30721. @findex stopping annotation
  30722. When the program starts executing due to a @value{GDBN} command such as
  30723. @code{step} or @code{continue},
  30724. @smallexample
  30725. ^Z^Zstarting
  30726. @end smallexample
  30727. is output. When the program stops,
  30728. @smallexample
  30729. ^Z^Zstopped
  30730. @end smallexample
  30731. is output. Before the @code{stopped} annotation, a variety of
  30732. annotations describe how the program stopped.
  30733. @table @code
  30734. @findex exited annotation
  30735. @item ^Z^Zexited @var{exit-status}
  30736. The program exited, and @var{exit-status} is the exit status (zero for
  30737. successful exit, otherwise nonzero).
  30738. @findex signalled annotation
  30739. @findex signal-name annotation
  30740. @findex signal-name-end annotation
  30741. @findex signal-string annotation
  30742. @findex signal-string-end annotation
  30743. @item ^Z^Zsignalled
  30744. The program exited with a signal. After the @code{^Z^Zsignalled}, the
  30745. annotation continues:
  30746. @smallexample
  30747. @var{intro-text}
  30748. ^Z^Zsignal-name
  30749. @var{name}
  30750. ^Z^Zsignal-name-end
  30751. @var{middle-text}
  30752. ^Z^Zsignal-string
  30753. @var{string}
  30754. ^Z^Zsignal-string-end
  30755. @var{end-text}
  30756. @end smallexample
  30757. @noindent
  30758. where @var{name} is the name of the signal, such as @code{SIGILL} or
  30759. @code{SIGSEGV}, and @var{string} is the explanation of the signal, such
  30760. as @code{Illegal Instruction} or @code{Segmentation fault}. The arguments
  30761. @var{intro-text}, @var{middle-text}, and @var{end-text} are for the
  30762. user's benefit and have no particular format.
  30763. @findex signal annotation
  30764. @item ^Z^Zsignal
  30765. The syntax of this annotation is just like @code{signalled}, but @value{GDBN} is
  30766. just saying that the program received the signal, not that it was
  30767. terminated with it.
  30768. @findex breakpoint annotation
  30769. @item ^Z^Zbreakpoint @var{number}
  30770. The program hit breakpoint number @var{number}.
  30771. @findex watchpoint annotation
  30772. @item ^Z^Zwatchpoint @var{number}
  30773. The program hit watchpoint number @var{number}.
  30774. @end table
  30775. @node Source Annotations
  30776. @section Displaying Source
  30777. @cindex annotations for source display
  30778. @findex source annotation
  30779. The following annotation is used instead of displaying source code:
  30780. @smallexample
  30781. ^Z^Zsource @var{filename}:@var{line}:@var{character}:@var{middle}:@var{addr}
  30782. @end smallexample
  30783. where @var{filename} is an absolute file name indicating which source
  30784. file, @var{line} is the line number within that file (where 1 is the
  30785. first line in the file), @var{character} is the character position
  30786. within the file (where 0 is the first character in the file) (for most
  30787. debug formats this will necessarily point to the beginning of a line),
  30788. @var{middle} is @samp{middle} if @var{addr} is in the middle of the
  30789. line, or @samp{beg} if @var{addr} is at the beginning of the line, and
  30790. @var{addr} is the address in the target program associated with the
  30791. source which is being displayed. The @var{addr} is in the form @samp{0x}
  30792. followed by one or more lowercase hex digits (note that this does not
  30793. depend on the language).
  30794. @node JIT Interface
  30795. @chapter JIT Compilation Interface
  30796. @cindex just-in-time compilation
  30797. @cindex JIT compilation interface
  30798. This chapter documents @value{GDBN}'s @dfn{just-in-time} (JIT) compilation
  30799. interface. A JIT compiler is a program or library that generates native
  30800. executable code at runtime and executes it, usually in order to achieve good
  30801. performance while maintaining platform independence.
  30802. Programs that use JIT compilation are normally difficult to debug because
  30803. portions of their code are generated at runtime, instead of being loaded from
  30804. object files, which is where @value{GDBN} normally finds the program's symbols
  30805. and debug information. In order to debug programs that use JIT compilation,
  30806. @value{GDBN} has an interface that allows the program to register in-memory
  30807. symbol files with @value{GDBN} at runtime.
  30808. If you are using @value{GDBN} to debug a program that uses this interface, then
  30809. it should work transparently so long as you have not stripped the binary. If
  30810. you are developing a JIT compiler, then the interface is documented in the rest
  30811. of this chapter. At this time, the only known client of this interface is the
  30812. LLVM JIT.
  30813. Broadly speaking, the JIT interface mirrors the dynamic loader interface. The
  30814. JIT compiler communicates with @value{GDBN} by writing data into a global
  30815. variable and calling a function at a well-known symbol. When @value{GDBN}
  30816. attaches, it reads a linked list of symbol files from the global variable to
  30817. find existing code, and puts a breakpoint in the function so that it can find
  30818. out about additional code.
  30819. @menu
  30820. * Declarations:: Relevant C struct declarations
  30821. * Registering Code:: Steps to register code
  30822. * Unregistering Code:: Steps to unregister code
  30823. * Custom Debug Info:: Emit debug information in a custom format
  30824. @end menu
  30825. @node Declarations
  30826. @section JIT Declarations
  30827. These are the relevant struct declarations that a C program should include to
  30828. implement the interface:
  30829. @smallexample
  30830. typedef enum
  30831. @{
  30832. JIT_NOACTION = 0,
  30833. JIT_REGISTER_FN,
  30834. JIT_UNREGISTER_FN
  30835. @} jit_actions_t;
  30836. struct jit_code_entry
  30837. @{
  30838. struct jit_code_entry *next_entry;
  30839. struct jit_code_entry *prev_entry;
  30840. const char *symfile_addr;
  30841. uint64_t symfile_size;
  30842. @};
  30843. struct jit_descriptor
  30844. @{
  30845. uint32_t version;
  30846. /* This type should be jit_actions_t, but we use uint32_t
  30847. to be explicit about the bitwidth. */
  30848. uint32_t action_flag;
  30849. struct jit_code_entry *relevant_entry;
  30850. struct jit_code_entry *first_entry;
  30851. @};
  30852. /* GDB puts a breakpoint in this function. */
  30853. void __attribute__((noinline)) __jit_debug_register_code() @{ @};
  30854. /* Make sure to specify the version statically, because the
  30855. debugger may check the version before we can set it. */
  30856. struct jit_descriptor __jit_debug_descriptor = @{ 1, 0, 0, 0 @};
  30857. @end smallexample
  30858. If the JIT is multi-threaded, then it is important that the JIT synchronize any
  30859. modifications to this global data properly, which can easily be done by putting
  30860. a global mutex around modifications to these structures.
  30861. @node Registering Code
  30862. @section Registering Code
  30863. To register code with @value{GDBN}, the JIT should follow this protocol:
  30864. @itemize @bullet
  30865. @item
  30866. Generate an object file in memory with symbols and other desired debug
  30867. information. The file must include the virtual addresses of the sections.
  30868. @item
  30869. Create a code entry for the file, which gives the start and size of the symbol
  30870. file.
  30871. @item
  30872. Add it to the linked list in the JIT descriptor.
  30873. @item
  30874. Point the relevant_entry field of the descriptor at the entry.
  30875. @item
  30876. Set @code{action_flag} to @code{JIT_REGISTER} and call
  30877. @code{__jit_debug_register_code}.
  30878. @end itemize
  30879. When @value{GDBN} is attached and the breakpoint fires, @value{GDBN} uses the
  30880. @code{relevant_entry} pointer so it doesn't have to walk the list looking for
  30881. new code. However, the linked list must still be maintained in order to allow
  30882. @value{GDBN} to attach to a running process and still find the symbol files.
  30883. @node Unregistering Code
  30884. @section Unregistering Code
  30885. If code is freed, then the JIT should use the following protocol:
  30886. @itemize @bullet
  30887. @item
  30888. Remove the code entry corresponding to the code from the linked list.
  30889. @item
  30890. Point the @code{relevant_entry} field of the descriptor at the code entry.
  30891. @item
  30892. Set @code{action_flag} to @code{JIT_UNREGISTER} and call
  30893. @code{__jit_debug_register_code}.
  30894. @end itemize
  30895. If the JIT frees or recompiles code without unregistering it, then @value{GDBN}
  30896. and the JIT will leak the memory used for the associated symbol files.
  30897. @node Custom Debug Info
  30898. @section Custom Debug Info
  30899. @cindex custom JIT debug info
  30900. @cindex JIT debug info reader
  30901. Generating debug information in platform-native file formats (like ELF
  30902. or COFF) may be an overkill for JIT compilers; especially if all the
  30903. debug info is used for is displaying a meaningful backtrace. The
  30904. issue can be resolved by having the JIT writers decide on a debug info
  30905. format and also provide a reader that parses the debug info generated
  30906. by the JIT compiler. This section gives a brief overview on writing
  30907. such a parser. More specific details can be found in the source file
  30908. @file{gdb/jit-reader.in}, which is also installed as a header at
  30909. @file{@var{includedir}/gdb/jit-reader.h} for easy inclusion.
  30910. The reader is implemented as a shared object (so this functionality is
  30911. not available on platforms which don't allow loading shared objects at
  30912. runtime). Two @value{GDBN} commands, @code{jit-reader-load} and
  30913. @code{jit-reader-unload} are provided, to be used to load and unload
  30914. the readers from a preconfigured directory. Once loaded, the shared
  30915. object is used the parse the debug information emitted by the JIT
  30916. compiler.
  30917. @menu
  30918. * Using JIT Debug Info Readers:: How to use supplied readers correctly
  30919. * Writing JIT Debug Info Readers:: Creating a debug-info reader
  30920. @end menu
  30921. @node Using JIT Debug Info Readers
  30922. @subsection Using JIT Debug Info Readers
  30923. @kindex jit-reader-load
  30924. @kindex jit-reader-unload
  30925. Readers can be loaded and unloaded using the @code{jit-reader-load}
  30926. and @code{jit-reader-unload} commands.
  30927. @table @code
  30928. @item jit-reader-load @var{reader}
  30929. Load the JIT reader named @var{reader}, which is a shared
  30930. object specified as either an absolute or a relative file name. In
  30931. the latter case, @value{GDBN} will try to load the reader from a
  30932. pre-configured directory, usually @file{@var{libdir}/gdb/} on a UNIX
  30933. system (here @var{libdir} is the system library directory, often
  30934. @file{/usr/local/lib}).
  30935. Only one reader can be active at a time; trying to load a second
  30936. reader when one is already loaded will result in @value{GDBN}
  30937. reporting an error. A new JIT reader can be loaded by first unloading
  30938. the current one using @code{jit-reader-unload} and then invoking
  30939. @code{jit-reader-load}.
  30940. @item jit-reader-unload
  30941. Unload the currently loaded JIT reader.
  30942. @end table
  30943. @node Writing JIT Debug Info Readers
  30944. @subsection Writing JIT Debug Info Readers
  30945. @cindex writing JIT debug info readers
  30946. As mentioned, a reader is essentially a shared object conforming to a
  30947. certain ABI. This ABI is described in @file{jit-reader.h}.
  30948. @file{jit-reader.h} defines the structures, macros and functions
  30949. required to write a reader. It is installed (along with
  30950. @value{GDBN}), in @file{@var{includedir}/gdb} where @var{includedir} is
  30951. the system include directory.
  30952. Readers need to be released under a GPL compatible license. A reader
  30953. can be declared as released under such a license by placing the macro
  30954. @code{GDB_DECLARE_GPL_COMPATIBLE_READER} in a source file.
  30955. The entry point for readers is the symbol @code{gdb_init_reader},
  30956. which is expected to be a function with the prototype
  30957. @findex gdb_init_reader
  30958. @smallexample
  30959. extern struct gdb_reader_funcs *gdb_init_reader (void);
  30960. @end smallexample
  30961. @cindex @code{struct gdb_reader_funcs}
  30962. @code{struct gdb_reader_funcs} contains a set of pointers to callback
  30963. functions. These functions are executed to read the debug info
  30964. generated by the JIT compiler (@code{read}), to unwind stack frames
  30965. (@code{unwind}) and to create canonical frame IDs
  30966. (@code{get_frame_id}). It also has a callback that is called when the
  30967. reader is being unloaded (@code{destroy}). The struct looks like this
  30968. @smallexample
  30969. struct gdb_reader_funcs
  30970. @{
  30971. /* Must be set to GDB_READER_INTERFACE_VERSION. */
  30972. int reader_version;
  30973. /* For use by the reader. */
  30974. void *priv_data;
  30975. gdb_read_debug_info *read;
  30976. gdb_unwind_frame *unwind;
  30977. gdb_get_frame_id *get_frame_id;
  30978. gdb_destroy_reader *destroy;
  30979. @};
  30980. @end smallexample
  30981. @cindex @code{struct gdb_symbol_callbacks}
  30982. @cindex @code{struct gdb_unwind_callbacks}
  30983. The callbacks are provided with another set of callbacks by
  30984. @value{GDBN} to do their job. For @code{read}, these callbacks are
  30985. passed in a @code{struct gdb_symbol_callbacks} and for @code{unwind}
  30986. and @code{get_frame_id}, in a @code{struct gdb_unwind_callbacks}.
  30987. @code{struct gdb_symbol_callbacks} has callbacks to create new object
  30988. files and new symbol tables inside those object files. @code{struct
  30989. gdb_unwind_callbacks} has callbacks to read registers off the current
  30990. frame and to write out the values of the registers in the previous
  30991. frame. Both have a callback (@code{target_read}) to read bytes off the
  30992. target's address space.
  30993. @node In-Process Agent
  30994. @chapter In-Process Agent
  30995. @cindex debugging agent
  30996. The traditional debugging model is conceptually low-speed, but works fine,
  30997. because most bugs can be reproduced in debugging-mode execution. However,
  30998. as multi-core or many-core processors are becoming mainstream, and
  30999. multi-threaded programs become more and more popular, there should be more
  31000. and more bugs that only manifest themselves at normal-mode execution, for
  31001. example, thread races, because debugger's interference with the program's
  31002. timing may conceal the bugs. On the other hand, in some applications,
  31003. it is not feasible for the debugger to interrupt the program's execution
  31004. long enough for the developer to learn anything helpful about its behavior.
  31005. If the program's correctness depends on its real-time behavior, delays
  31006. introduced by a debugger might cause the program to fail, even when the
  31007. code itself is correct. It is useful to be able to observe the program's
  31008. behavior without interrupting it.
  31009. Therefore, traditional debugging model is too intrusive to reproduce
  31010. some bugs. In order to reduce the interference with the program, we can
  31011. reduce the number of operations performed by debugger. The
  31012. @dfn{In-Process Agent}, a shared library, is running within the same
  31013. process with inferior, and is able to perform some debugging operations
  31014. itself. As a result, debugger is only involved when necessary, and
  31015. performance of debugging can be improved accordingly. Note that
  31016. interference with program can be reduced but can't be removed completely,
  31017. because the in-process agent will still stop or slow down the program.
  31018. The in-process agent can interpret and execute Agent Expressions
  31019. (@pxref{Agent Expressions}) during performing debugging operations. The
  31020. agent expressions can be used for different purposes, such as collecting
  31021. data in tracepoints, and condition evaluation in breakpoints.
  31022. @anchor{Control Agent}
  31023. You can control whether the in-process agent is used as an aid for
  31024. debugging with the following commands:
  31025. @table @code
  31026. @kindex set agent on
  31027. @item set agent on
  31028. Causes the in-process agent to perform some operations on behalf of the
  31029. debugger. Just which operations requested by the user will be done
  31030. by the in-process agent depends on the its capabilities. For example,
  31031. if you request to evaluate breakpoint conditions in the in-process agent,
  31032. and the in-process agent has such capability as well, then breakpoint
  31033. conditions will be evaluated in the in-process agent.
  31034. @kindex set agent off
  31035. @item set agent off
  31036. Disables execution of debugging operations by the in-process agent. All
  31037. of the operations will be performed by @value{GDBN}.
  31038. @kindex show agent
  31039. @item show agent
  31040. Display the current setting of execution of debugging operations by
  31041. the in-process agent.
  31042. @end table
  31043. @menu
  31044. * In-Process Agent Protocol::
  31045. @end menu
  31046. @node In-Process Agent Protocol
  31047. @section In-Process Agent Protocol
  31048. @cindex in-process agent protocol
  31049. The in-process agent is able to communicate with both @value{GDBN} and
  31050. GDBserver (@pxref{In-Process Agent}). This section documents the protocol
  31051. used for communications between @value{GDBN} or GDBserver and the IPA.
  31052. In general, @value{GDBN} or GDBserver sends commands
  31053. (@pxref{IPA Protocol Commands}) and data to in-process agent, and then
  31054. in-process agent replies back with the return result of the command, or
  31055. some other information. The data sent to in-process agent is composed
  31056. of primitive data types, such as 4-byte or 8-byte type, and composite
  31057. types, which are called objects (@pxref{IPA Protocol Objects}).
  31058. @menu
  31059. * IPA Protocol Objects::
  31060. * IPA Protocol Commands::
  31061. @end menu
  31062. @node IPA Protocol Objects
  31063. @subsection IPA Protocol Objects
  31064. @cindex ipa protocol objects
  31065. The commands sent to and results received from agent may contain some
  31066. complex data types called @dfn{objects}.
  31067. The in-process agent is running on the same machine with @value{GDBN}
  31068. or GDBserver, so it doesn't have to handle as much differences between
  31069. two ends as remote protocol (@pxref{Remote Protocol}) tries to handle.
  31070. However, there are still some differences of two ends in two processes:
  31071. @enumerate
  31072. @item
  31073. word size. On some 64-bit machines, @value{GDBN} or GDBserver can be
  31074. compiled as a 64-bit executable, while in-process agent is a 32-bit one.
  31075. @item
  31076. ABI. Some machines may have multiple types of ABI, @value{GDBN} or
  31077. GDBserver is compiled with one, and in-process agent is compiled with
  31078. the other one.
  31079. @end enumerate
  31080. Here are the IPA Protocol Objects:
  31081. @enumerate
  31082. @item
  31083. agent expression object. It represents an agent expression
  31084. (@pxref{Agent Expressions}).
  31085. @anchor{agent expression object}
  31086. @item
  31087. tracepoint action object. It represents a tracepoint action
  31088. (@pxref{Tracepoint Actions,,Tracepoint Action Lists}) to collect registers,
  31089. memory, static trace data and to evaluate expression.
  31090. @anchor{tracepoint action object}
  31091. @item
  31092. tracepoint object. It represents a tracepoint (@pxref{Tracepoints}).
  31093. @anchor{tracepoint object}
  31094. @end enumerate
  31095. The following table describes important attributes of each IPA protocol
  31096. object:
  31097. @multitable @columnfractions .30 .20 .50
  31098. @headitem Name @tab Size @tab Description
  31099. @item @emph{agent expression object} @tab @tab
  31100. @item length @tab 4 @tab length of bytes code
  31101. @item byte code @tab @var{length} @tab contents of byte code
  31102. @item @emph{tracepoint action for collecting memory} @tab @tab
  31103. @item 'M' @tab 1 @tab type of tracepoint action
  31104. @item addr @tab 8 @tab if @var{basereg} is @samp{-1}, @var{addr} is the
  31105. address of the lowest byte to collect, otherwise @var{addr} is the offset
  31106. of @var{basereg} for memory collecting.
  31107. @item len @tab 8 @tab length of memory for collecting
  31108. @item basereg @tab 4 @tab the register number containing the starting
  31109. memory address for collecting.
  31110. @item @emph{tracepoint action for collecting registers} @tab @tab
  31111. @item 'R' @tab 1 @tab type of tracepoint action
  31112. @item @emph{tracepoint action for collecting static trace data} @tab @tab
  31113. @item 'L' @tab 1 @tab type of tracepoint action
  31114. @item @emph{tracepoint action for expression evaluation} @tab @tab
  31115. @item 'X' @tab 1 @tab type of tracepoint action
  31116. @item agent expression @tab length of @tab @ref{agent expression object}
  31117. @item @emph{tracepoint object} @tab @tab
  31118. @item number @tab 4 @tab number of tracepoint
  31119. @item address @tab 8 @tab address of tracepoint inserted on
  31120. @item type @tab 4 @tab type of tracepoint
  31121. @item enabled @tab 1 @tab enable or disable of tracepoint
  31122. @item step_count @tab 8 @tab step
  31123. @item pass_count @tab 8 @tab pass
  31124. @item numactions @tab 4 @tab number of tracepoint actions
  31125. @item hit count @tab 8 @tab hit count
  31126. @item trace frame usage @tab 8 @tab trace frame usage
  31127. @item compiled_cond @tab 8 @tab compiled condition
  31128. @item orig_size @tab 8 @tab orig size
  31129. @item condition @tab 4 if condition is NULL otherwise length of
  31130. @ref{agent expression object}
  31131. @tab zero if condition is NULL, otherwise is
  31132. @ref{agent expression object}
  31133. @item actions @tab variable
  31134. @tab numactions number of @ref{tracepoint action object}
  31135. @end multitable
  31136. @node IPA Protocol Commands
  31137. @subsection IPA Protocol Commands
  31138. @cindex ipa protocol commands
  31139. The spaces in each command are delimiters to ease reading this commands
  31140. specification. They don't exist in real commands.
  31141. @table @samp
  31142. @item FastTrace:@var{tracepoint_object} @var{gdb_jump_pad_head}
  31143. Installs a new fast tracepoint described by @var{tracepoint_object}
  31144. (@pxref{tracepoint object}). The @var{gdb_jump_pad_head}, 8-byte long, is the
  31145. head of @dfn{jumppad}, which is used to jump to data collection routine
  31146. in IPA finally.
  31147. Replies:
  31148. @table @samp
  31149. @item OK @var{target_address} @var{gdb_jump_pad_head} @var{fjump_size} @var{fjump}
  31150. @var{target_address} is address of tracepoint in the inferior.
  31151. The @var{gdb_jump_pad_head} is updated head of jumppad. Both of
  31152. @var{target_address} and @var{gdb_jump_pad_head} are 8-byte long.
  31153. The @var{fjump} contains a sequence of instructions jump to jumppad entry.
  31154. The @var{fjump_size}, 4-byte long, is the size of @var{fjump}.
  31155. @item E @var{NN}
  31156. for an error
  31157. @end table
  31158. @item close
  31159. Closes the in-process agent. This command is sent when @value{GDBN} or GDBserver
  31160. is about to kill inferiors.
  31161. @item qTfSTM
  31162. @xref{qTfSTM}.
  31163. @item qTsSTM
  31164. @xref{qTsSTM}.
  31165. @item qTSTMat
  31166. @xref{qTSTMat}.
  31167. @item probe_marker_at:@var{address}
  31168. Asks in-process agent to probe the marker at @var{address}.
  31169. Replies:
  31170. @table @samp
  31171. @item E @var{NN}
  31172. for an error
  31173. @end table
  31174. @item unprobe_marker_at:@var{address}
  31175. Asks in-process agent to unprobe the marker at @var{address}.
  31176. @end table
  31177. @node GDB Bugs
  31178. @chapter Reporting Bugs in @value{GDBN}
  31179. @cindex bugs in @value{GDBN}
  31180. @cindex reporting bugs in @value{GDBN}
  31181. Your bug reports play an essential role in making @value{GDBN} reliable.
  31182. Reporting a bug may help you by bringing a solution to your problem, or it
  31183. may not. But in any case the principal function of a bug report is to help
  31184. the entire community by making the next version of @value{GDBN} work better. Bug
  31185. reports are your contribution to the maintenance of @value{GDBN}.
  31186. In order for a bug report to serve its purpose, you must include the
  31187. information that enables us to fix the bug.
  31188. @menu
  31189. * Bug Criteria:: Have you found a bug?
  31190. * Bug Reporting:: How to report bugs
  31191. @end menu
  31192. @node Bug Criteria
  31193. @section Have You Found a Bug?
  31194. @cindex bug criteria
  31195. If you are not sure whether you have found a bug, here are some guidelines:
  31196. @itemize @bullet
  31197. @cindex fatal signal
  31198. @cindex debugger crash
  31199. @cindex crash of debugger
  31200. @item
  31201. If the debugger gets a fatal signal, for any input whatever, that is a
  31202. @value{GDBN} bug. Reliable debuggers never crash.
  31203. @cindex error on valid input
  31204. @item
  31205. If @value{GDBN} produces an error message for valid input, that is a
  31206. bug. (Note that if you're cross debugging, the problem may also be
  31207. somewhere in the connection to the target.)
  31208. @cindex invalid input
  31209. @item
  31210. If @value{GDBN} does not produce an error message for invalid input,
  31211. that is a bug. However, you should note that your idea of
  31212. ``invalid input'' might be our idea of ``an extension'' or ``support
  31213. for traditional practice''.
  31214. @item
  31215. If you are an experienced user of debugging tools, your suggestions
  31216. for improvement of @value{GDBN} are welcome in any case.
  31217. @end itemize
  31218. @node Bug Reporting
  31219. @section How to Report Bugs
  31220. @cindex bug reports
  31221. @cindex @value{GDBN} bugs, reporting
  31222. A number of companies and individuals offer support for @sc{gnu} products.
  31223. If you obtained @value{GDBN} from a support organization, we recommend you
  31224. contact that organization first.
  31225. You can find contact information for many support companies and
  31226. individuals in the file @file{etc/SERVICE} in the @sc{gnu} Emacs
  31227. distribution.
  31228. @c should add a web page ref...
  31229. @ifset BUGURL
  31230. @ifset BUGURL_DEFAULT
  31231. In any event, we also recommend that you submit bug reports for
  31232. @value{GDBN}. The preferred method is to submit them directly using
  31233. @uref{http://www.gnu.org/software/gdb/bugs/, @value{GDBN}'s Bugs web
  31234. page}. Alternatively, the @email{bug-gdb@@gnu.org, e-mail gateway} can
  31235. be used.
  31236. @strong{Do not send bug reports to @samp{info-gdb}, or to
  31237. @samp{help-gdb}, or to any newsgroups.} Most users of @value{GDBN} do
  31238. not want to receive bug reports. Those that do have arranged to receive
  31239. @samp{bug-gdb}.
  31240. The mailing list @samp{bug-gdb} has a newsgroup @samp{gnu.gdb.bug} which
  31241. serves as a repeater. The mailing list and the newsgroup carry exactly
  31242. the same messages. Often people think of posting bug reports to the
  31243. newsgroup instead of mailing them. This appears to work, but it has one
  31244. problem which can be crucial: a newsgroup posting often lacks a mail
  31245. path back to the sender. Thus, if we need to ask for more information,
  31246. we may be unable to reach you. For this reason, it is better to send
  31247. bug reports to the mailing list.
  31248. @end ifset
  31249. @ifclear BUGURL_DEFAULT
  31250. In any event, we also recommend that you submit bug reports for
  31251. @value{GDBN} to @value{BUGURL}.
  31252. @end ifclear
  31253. @end ifset
  31254. The fundamental principle of reporting bugs usefully is this:
  31255. @strong{report all the facts}. If you are not sure whether to state a
  31256. fact or leave it out, state it!
  31257. Often people omit facts because they think they know what causes the
  31258. problem and assume that some details do not matter. Thus, you might
  31259. assume that the name of the variable you use in an example does not matter.
  31260. Well, probably it does not, but one cannot be sure. Perhaps the bug is a
  31261. stray memory reference which happens to fetch from the location where that
  31262. name is stored in memory; perhaps, if the name were different, the contents
  31263. of that location would fool the debugger into doing the right thing despite
  31264. the bug. Play it safe and give a specific, complete example. That is the
  31265. easiest thing for you to do, and the most helpful.
  31266. Keep in mind that the purpose of a bug report is to enable us to fix the
  31267. bug. It may be that the bug has been reported previously, but neither
  31268. you nor we can know that unless your bug report is complete and
  31269. self-contained.
  31270. Sometimes people give a few sketchy facts and ask, ``Does this ring a
  31271. bell?'' Those bug reports are useless, and we urge everyone to
  31272. @emph{refuse to respond to them} except to chide the sender to report
  31273. bugs properly.
  31274. To enable us to fix the bug, you should include all these things:
  31275. @itemize @bullet
  31276. @item
  31277. The version of @value{GDBN}. @value{GDBN} announces it if you start
  31278. with no arguments; you can also print it at any time using @code{show
  31279. version}.
  31280. Without this, we will not know whether there is any point in looking for
  31281. the bug in the current version of @value{GDBN}.
  31282. @item
  31283. The type of machine you are using, and the operating system name and
  31284. version number.
  31285. @item
  31286. The details of the @value{GDBN} build-time configuration.
  31287. @value{GDBN} shows these details if you invoke it with the
  31288. @option{--configuration} command-line option, or if you type
  31289. @code{show configuration} at @value{GDBN}'s prompt.
  31290. @item
  31291. What compiler (and its version) was used to compile @value{GDBN}---e.g.@:
  31292. ``@value{GCC}--2.8.1''.
  31293. @item
  31294. What compiler (and its version) was used to compile the program you are
  31295. debugging---e.g.@: ``@value{GCC}--2.8.1'', or ``HP92453-01 A.10.32.03 HP
  31296. C Compiler''. For @value{NGCC}, you can say @kbd{@value{GCC} --version}
  31297. to get this information; for other compilers, see the documentation for
  31298. those compilers.
  31299. @item
  31300. The command arguments you gave the compiler to compile your example and
  31301. observe the bug. For example, did you use @samp{-O}? To guarantee
  31302. you will not omit something important, list them all. A copy of the
  31303. Makefile (or the output from make) is sufficient.
  31304. If we were to try to guess the arguments, we would probably guess wrong
  31305. and then we might not encounter the bug.
  31306. @item
  31307. A complete input script, and all necessary source files, that will
  31308. reproduce the bug.
  31309. @item
  31310. A description of what behavior you observe that you believe is
  31311. incorrect. For example, ``It gets a fatal signal.''
  31312. Of course, if the bug is that @value{GDBN} gets a fatal signal, then we
  31313. will certainly notice it. But if the bug is incorrect output, we might
  31314. not notice unless it is glaringly wrong. You might as well not give us
  31315. a chance to make a mistake.
  31316. Even if the problem you experience is a fatal signal, you should still
  31317. say so explicitly. Suppose something strange is going on, such as, your
  31318. copy of @value{GDBN} is out of synch, or you have encountered a bug in
  31319. the C library on your system. (This has happened!) Your copy might
  31320. crash and ours would not. If you told us to expect a crash, then when
  31321. ours fails to crash, we would know that the bug was not happening for
  31322. us. If you had not told us to expect a crash, then we would not be able
  31323. to draw any conclusion from our observations.
  31324. @pindex script
  31325. @cindex recording a session script
  31326. To collect all this information, you can use a session recording program
  31327. such as @command{script}, which is available on many Unix systems.
  31328. Just run your @value{GDBN} session inside @command{script} and then
  31329. include the @file{typescript} file with your bug report.
  31330. Another way to record a @value{GDBN} session is to run @value{GDBN}
  31331. inside Emacs and then save the entire buffer to a file.
  31332. @item
  31333. If you wish to suggest changes to the @value{GDBN} source, send us context
  31334. diffs. If you even discuss something in the @value{GDBN} source, refer to
  31335. it by context, not by line number.
  31336. The line numbers in our development sources will not match those in your
  31337. sources. Your line numbers would convey no useful information to us.
  31338. @end itemize
  31339. Here are some things that are not necessary:
  31340. @itemize @bullet
  31341. @item
  31342. A description of the envelope of the bug.
  31343. Often people who encounter a bug spend a lot of time investigating
  31344. which changes to the input file will make the bug go away and which
  31345. changes will not affect it.
  31346. This is often time consuming and not very useful, because the way we
  31347. will find the bug is by running a single example under the debugger
  31348. with breakpoints, not by pure deduction from a series of examples.
  31349. We recommend that you save your time for something else.
  31350. Of course, if you can find a simpler example to report @emph{instead}
  31351. of the original one, that is a convenience for us. Errors in the
  31352. output will be easier to spot, running under the debugger will take
  31353. less time, and so on.
  31354. However, simplification is not vital; if you do not want to do this,
  31355. report the bug anyway and send us the entire test case you used.
  31356. @item
  31357. A patch for the bug.
  31358. A patch for the bug does help us if it is a good one. But do not omit
  31359. the necessary information, such as the test case, on the assumption that
  31360. a patch is all we need. We might see problems with your patch and decide
  31361. to fix the problem another way, or we might not understand it at all.
  31362. Sometimes with a program as complicated as @value{GDBN} it is very hard to
  31363. construct an example that will make the program follow a certain path
  31364. through the code. If you do not send us the example, we will not be able
  31365. to construct one, so we will not be able to verify that the bug is fixed.
  31366. And if we cannot understand what bug you are trying to fix, or why your
  31367. patch should be an improvement, we will not install it. A test case will
  31368. help us to understand.
  31369. @item
  31370. A guess about what the bug is or what it depends on.
  31371. Such guesses are usually wrong. Even we cannot guess right about such
  31372. things without first using the debugger to find the facts.
  31373. @end itemize
  31374. @c The readline documentation is distributed with the readline code
  31375. @c and consists of the two following files:
  31376. @c rluser.texi
  31377. @c hsuser.texi
  31378. @c Use -I with makeinfo to point to the appropriate directory,
  31379. @c environment var TEXINPUTS with TeX.
  31380. @ifclear SYSTEM_READLINE
  31381. @include rluser.texi
  31382. @include hsuser.texi
  31383. @end ifclear
  31384. @node In Memoriam
  31385. @appendix In Memoriam
  31386. The @value{GDBN} project mourns the loss of the following long-time
  31387. contributors:
  31388. @table @code
  31389. @item Fred Fish
  31390. Fred was a long-standing contributor to @value{GDBN} (1991-2006), and
  31391. to Free Software in general. Outside of @value{GDBN}, he was known in
  31392. the Amiga world for his series of Fish Disks, and the GeekGadget project.
  31393. @item Michael Snyder
  31394. Michael was one of the Global Maintainers of the @value{GDBN} project,
  31395. with contributions recorded as early as 1996, until 2011. In addition
  31396. to his day to day participation, he was a large driving force behind
  31397. adding Reverse Debugging to @value{GDBN}.
  31398. @end table
  31399. Beyond their technical contributions to the project, they were also
  31400. enjoyable members of the Free Software Community. We will miss them.
  31401. @node Formatting Documentation
  31402. @appendix Formatting Documentation
  31403. @cindex @value{GDBN} reference card
  31404. @cindex reference card
  31405. The @value{GDBN} 4 release includes an already-formatted reference card, ready
  31406. for printing with PostScript or Ghostscript, in the @file{gdb}
  31407. subdirectory of the main source directory@footnote{In
  31408. @file{gdb-@value{GDBVN}/gdb/refcard.ps} of the version @value{GDBVN}
  31409. release.}. If you can use PostScript or Ghostscript with your printer,
  31410. you can print the reference card immediately with @file{refcard.ps}.
  31411. The release also includes the source for the reference card. You
  31412. can format it, using @TeX{}, by typing:
  31413. @smallexample
  31414. make refcard.dvi
  31415. @end smallexample
  31416. The @value{GDBN} reference card is designed to print in @dfn{landscape}
  31417. mode on US ``letter'' size paper;
  31418. that is, on a sheet 11 inches wide by 8.5 inches
  31419. high. You will need to specify this form of printing as an option to
  31420. your @sc{dvi} output program.
  31421. @cindex documentation
  31422. All the documentation for @value{GDBN} comes as part of the machine-readable
  31423. distribution. The documentation is written in Texinfo format, which is
  31424. a documentation system that uses a single source file to produce both
  31425. on-line information and a printed manual. You can use one of the Info
  31426. formatting commands to create the on-line version of the documentation
  31427. and @TeX{} (or @code{texi2roff}) to typeset the printed version.
  31428. @value{GDBN} includes an already formatted copy of the on-line Info
  31429. version of this manual in the @file{gdb} subdirectory. The main Info
  31430. file is @file{gdb-@value{GDBVN}/gdb/gdb.info}, and it refers to
  31431. subordinate files matching @samp{gdb.info*} in the same directory. If
  31432. necessary, you can print out these files, or read them with any editor;
  31433. but they are easier to read using the @code{info} subsystem in @sc{gnu}
  31434. Emacs or the standalone @code{info} program, available as part of the
  31435. @sc{gnu} Texinfo distribution.
  31436. If you want to format these Info files yourself, you need one of the
  31437. Info formatting programs, such as @code{texinfo-format-buffer} or
  31438. @code{makeinfo}.
  31439. If you have @code{makeinfo} installed, and are in the top level
  31440. @value{GDBN} source directory (@file{gdb-@value{GDBVN}}, in the case of
  31441. version @value{GDBVN}), you can make the Info file by typing:
  31442. @smallexample
  31443. cd gdb
  31444. make gdb.info
  31445. @end smallexample
  31446. If you want to typeset and print copies of this manual, you need @TeX{},
  31447. a program to print its @sc{dvi} output files, and @file{texinfo.tex}, the
  31448. Texinfo definitions file.
  31449. @TeX{} is a typesetting program; it does not print files directly, but
  31450. produces output files called @sc{dvi} files. To print a typeset
  31451. document, you need a program to print @sc{dvi} files. If your system
  31452. has @TeX{} installed, chances are it has such a program. The precise
  31453. command to use depends on your system; @kbd{lpr -d} is common; another
  31454. (for PostScript devices) is @kbd{dvips}. The @sc{dvi} print command may
  31455. require a file name without any extension or a @samp{.dvi} extension.
  31456. @TeX{} also requires a macro definitions file called
  31457. @file{texinfo.tex}. This file tells @TeX{} how to typeset a document
  31458. written in Texinfo format. On its own, @TeX{} cannot either read or
  31459. typeset a Texinfo file. @file{texinfo.tex} is distributed with GDB
  31460. and is located in the @file{gdb-@var{version-number}/texinfo}
  31461. directory.
  31462. If you have @TeX{} and a @sc{dvi} printer program installed, you can
  31463. typeset and print this manual. First switch to the @file{gdb}
  31464. subdirectory of the main source directory (for example, to
  31465. @file{gdb-@value{GDBVN}/gdb}) and type:
  31466. @smallexample
  31467. make gdb.dvi
  31468. @end smallexample
  31469. Then give @file{gdb.dvi} to your @sc{dvi} printing program.
  31470. @node Installing GDB
  31471. @appendix Installing @value{GDBN}
  31472. @cindex installation
  31473. @menu
  31474. * Requirements:: Requirements for building @value{GDBN}
  31475. * Running Configure:: Invoking the @value{GDBN} @file{configure} script
  31476. * Separate Objdir:: Compiling @value{GDBN} in another directory
  31477. * Config Names:: Specifying names for hosts and targets
  31478. * Configure Options:: Summary of options for configure
  31479. * System-wide configuration:: Having a system-wide init file
  31480. @end menu
  31481. @node Requirements
  31482. @section Requirements for Building @value{GDBN}
  31483. @cindex building @value{GDBN}, requirements for
  31484. Building @value{GDBN} requires various tools and packages to be available.
  31485. Other packages will be used only if they are found.
  31486. @heading Tools/Packages Necessary for Building @value{GDBN}
  31487. @table @asis
  31488. @item C@t{++}11 compiler
  31489. @value{GDBN} is written in C@t{++}11. It should be buildable with any
  31490. recent C@t{++}11 compiler, e.g.@: GCC.
  31491. @item GNU make
  31492. @value{GDBN}'s build system relies on features only found in the GNU
  31493. make program. Other variants of @code{make} will not work.
  31494. @item GMP (The GNU Multiple Precision Arithmetic Library)
  31495. @value{GDBN} now uses GMP to perform some of its arithmetics.
  31496. This library may be included with your operating system distribution;
  31497. if it is not, you can get the latest version from
  31498. @url{https://gmplib.org/}. If GMP is installed at an unusual path,
  31499. you can use the @option{--with-libgmp-prefix} option to specify
  31500. its location.
  31501. @end table
  31502. @heading Tools/Packages Optional for Building @value{GDBN}
  31503. @table @asis
  31504. @item Expat
  31505. @anchor{Expat}
  31506. @value{GDBN} can use the Expat XML parsing library. This library may be
  31507. included with your operating system distribution; if it is not, you
  31508. can get the latest version from @url{http://expat.sourceforge.net}.
  31509. The @file{configure} script will search for this library in several
  31510. standard locations; if it is installed in an unusual path, you can
  31511. use the @option{--with-libexpat-prefix} option to specify its location.
  31512. Expat is used for:
  31513. @itemize @bullet
  31514. @item
  31515. Remote protocol memory maps (@pxref{Memory Map Format})
  31516. @item
  31517. Target descriptions (@pxref{Target Descriptions})
  31518. @item
  31519. Remote shared library lists (@xref{Library List Format},
  31520. or alternatively @pxref{Library List Format for SVR4 Targets})
  31521. @item
  31522. MS-Windows shared libraries (@pxref{Shared Libraries})
  31523. @item
  31524. Traceframe info (@pxref{Traceframe Info Format})
  31525. @item
  31526. Branch trace (@pxref{Branch Trace Format},
  31527. @pxref{Branch Trace Configuration Format})
  31528. @end itemize
  31529. @item Guile
  31530. @value{GDBN} can be scripted using GNU Guile. @xref{Guile}. By
  31531. default, @value{GDBN} will be compiled if the Guile libraries are
  31532. installed and are found by @file{configure}. You can use the
  31533. @code{--with-guile} option to request Guile, and pass either the Guile
  31534. version number or the file name of the relevant @code{pkg-config}
  31535. program to choose a particular version of Guile.
  31536. @item iconv
  31537. @value{GDBN}'s features related to character sets (@pxref{Character
  31538. Sets}) require a functioning @code{iconv} implementation. If you are
  31539. on a GNU system, then this is provided by the GNU C Library. Some
  31540. other systems also provide a working @code{iconv}.
  31541. If @value{GDBN} is using the @code{iconv} program which is installed
  31542. in a non-standard place, you will need to tell @value{GDBN} where to
  31543. find it. This is done with @option{--with-iconv-bin} which specifies
  31544. the directory that contains the @code{iconv} program. This program is
  31545. run in order to make a list of the available character sets.
  31546. On systems without @code{iconv}, you can install GNU Libiconv. If
  31547. Libiconv is installed in a standard place, @value{GDBN} will
  31548. automatically use it if it is needed. If you have previously
  31549. installed Libiconv in a non-standard place, you can use the
  31550. @option{--with-libiconv-prefix} option to @file{configure}.
  31551. @value{GDBN}'s top-level @file{configure} and @file{Makefile} will
  31552. arrange to build Libiconv if a directory named @file{libiconv} appears
  31553. in the top-most source directory. If Libiconv is built this way, and
  31554. if the operating system does not provide a suitable @code{iconv}
  31555. implementation, then the just-built library will automatically be used
  31556. by @value{GDBN}. One easy way to set this up is to download GNU
  31557. Libiconv, unpack it inside the top-level directory of the @value{GDBN}
  31558. source tree, and then rename the directory holding the Libiconv source
  31559. code to @samp{libiconv}.
  31560. @item lzma
  31561. @value{GDBN} can support debugging sections that are compressed with
  31562. the LZMA library. @xref{MiniDebugInfo}. If this library is not
  31563. included with your operating system, you can find it in the xz package
  31564. at @url{http://tukaani.org/xz/}. If the LZMA library is available in
  31565. the usual place, then the @file{configure} script will use it
  31566. automatically. If it is installed in an unusual path, you can use the
  31567. @option{--with-liblzma-prefix} option to specify its location.
  31568. @item MPFR
  31569. @anchor{MPFR}
  31570. @value{GDBN} can use the GNU MPFR multiple-precision floating-point
  31571. library. This library may be included with your operating system
  31572. distribution; if it is not, you can get the latest version from
  31573. @url{http://www.mpfr.org}. The @file{configure} script will search
  31574. for this library in several standard locations; if it is installed
  31575. in an unusual path, you can use the @option{--with-libmpfr-prefix}
  31576. option to specify its location.
  31577. GNU MPFR is used to emulate target floating-point arithmetic during
  31578. expression evaluation when the target uses different floating-point
  31579. formats than the host. If GNU MPFR it is not available, @value{GDBN}
  31580. will fall back to using host floating-point arithmetic.
  31581. @item Python
  31582. @value{GDBN} can be scripted using Python language. @xref{Python}.
  31583. By default, @value{GDBN} will be compiled if the Python libraries are
  31584. installed and are found by @file{configure}. You can use the
  31585. @code{--with-python} option to request Python, and pass either the
  31586. file name of the relevant @code{python} executable, or the name of the
  31587. directory in which Python is installed, to choose a particular
  31588. installation of Python.
  31589. @item zlib
  31590. @cindex compressed debug sections
  31591. @value{GDBN} will use the @samp{zlib} library, if available, to read
  31592. compressed debug sections. Some linkers, such as GNU gold, are capable
  31593. of producing binaries with compressed debug sections. If @value{GDBN}
  31594. is compiled with @samp{zlib}, it will be able to read the debug
  31595. information in such binaries.
  31596. The @samp{zlib} library is likely included with your operating system
  31597. distribution; if it is not, you can get the latest version from
  31598. @url{http://zlib.net}.
  31599. @end table
  31600. @node Running Configure
  31601. @section Invoking the @value{GDBN} @file{configure} Script
  31602. @cindex configuring @value{GDBN}
  31603. @value{GDBN} comes with a @file{configure} script that automates the process
  31604. of preparing @value{GDBN} for installation; you can then use @code{make} to
  31605. build the @code{gdb} program.
  31606. @iftex
  31607. @c irrelevant in info file; it's as current as the code it lives with.
  31608. @footnote{If you have a more recent version of @value{GDBN} than @value{GDBVN},
  31609. look at the @file{README} file in the sources; we may have improved the
  31610. installation procedures since publishing this manual.}
  31611. @end iftex
  31612. The @value{GDBN} distribution includes all the source code you need for
  31613. @value{GDBN} in a single directory, whose name is usually composed by
  31614. appending the version number to @samp{gdb}.
  31615. For example, the @value{GDBN} version @value{GDBVN} distribution is in the
  31616. @file{gdb-@value{GDBVN}} directory. That directory contains:
  31617. @table @code
  31618. @item gdb-@value{GDBVN}/configure @r{(and supporting files)}
  31619. script for configuring @value{GDBN} and all its supporting libraries
  31620. @item gdb-@value{GDBVN}/gdb
  31621. the source specific to @value{GDBN} itself
  31622. @item gdb-@value{GDBVN}/bfd
  31623. source for the Binary File Descriptor library
  31624. @item gdb-@value{GDBVN}/include
  31625. @sc{gnu} include files
  31626. @item gdb-@value{GDBVN}/libiberty
  31627. source for the @samp{-liberty} free software library
  31628. @item gdb-@value{GDBVN}/opcodes
  31629. source for the library of opcode tables and disassemblers
  31630. @item gdb-@value{GDBVN}/readline
  31631. source for the @sc{gnu} command-line interface
  31632. @end table
  31633. There may be other subdirectories as well.
  31634. The simplest way to configure and build @value{GDBN} is to run @file{configure}
  31635. from the @file{gdb-@var{version-number}} source directory, which in
  31636. this example is the @file{gdb-@value{GDBVN}} directory.
  31637. First switch to the @file{gdb-@var{version-number}} source directory
  31638. if you are not already in it; then run @file{configure}. Pass the
  31639. identifier for the platform on which @value{GDBN} will run as an
  31640. argument.
  31641. For example:
  31642. @smallexample
  31643. cd gdb-@value{GDBVN}
  31644. ./configure
  31645. make
  31646. @end smallexample
  31647. Running @samp{configure} and then running @code{make} builds the
  31648. included supporting libraries, then @code{gdb} itself. The configured
  31649. source files, and the binaries, are left in the corresponding source
  31650. directories.
  31651. @need 750
  31652. @file{configure} is a Bourne-shell (@code{/bin/sh}) script; if your
  31653. system does not recognize this automatically when you run a different
  31654. shell, you may need to run @code{sh} on it explicitly:
  31655. @smallexample
  31656. sh configure
  31657. @end smallexample
  31658. You should run the @file{configure} script from the top directory in the
  31659. source tree, the @file{gdb-@var{version-number}} directory. If you run
  31660. @file{configure} from one of the subdirectories, you will configure only
  31661. that subdirectory. That is usually not what you want. In particular,
  31662. if you run the first @file{configure} from the @file{gdb} subdirectory
  31663. of the @file{gdb-@var{version-number}} directory, you will omit the
  31664. configuration of @file{bfd}, @file{readline}, and other sibling
  31665. directories of the @file{gdb} subdirectory. This leads to build errors
  31666. about missing include files such as @file{bfd/bfd.h}.
  31667. You can install @code{@value{GDBN}} anywhere. The best way to do this
  31668. is to pass the @code{--prefix} option to @code{configure}, and then
  31669. install it with @code{make install}.
  31670. @node Separate Objdir
  31671. @section Compiling @value{GDBN} in Another Directory
  31672. If you want to run @value{GDBN} versions for several host or target machines,
  31673. you need a different @code{gdb} compiled for each combination of
  31674. host and target. @file{configure} is designed to make this easy by
  31675. allowing you to generate each configuration in a separate subdirectory,
  31676. rather than in the source directory. If your @code{make} program
  31677. handles the @samp{VPATH} feature (@sc{gnu} @code{make} does), running
  31678. @code{make} in each of these directories builds the @code{gdb}
  31679. program specified there.
  31680. To build @code{gdb} in a separate directory, run @file{configure}
  31681. with the @samp{--srcdir} option to specify where to find the source.
  31682. (You also need to specify a path to find @file{configure}
  31683. itself from your working directory. If the path to @file{configure}
  31684. would be the same as the argument to @samp{--srcdir}, you can leave out
  31685. the @samp{--srcdir} option; it is assumed.)
  31686. For example, with version @value{GDBVN}, you can build @value{GDBN} in a
  31687. separate directory for a Sun 4 like this:
  31688. @smallexample
  31689. @group
  31690. cd gdb-@value{GDBVN}
  31691. mkdir ../gdb-sun4
  31692. cd ../gdb-sun4
  31693. ../gdb-@value{GDBVN}/configure
  31694. make
  31695. @end group
  31696. @end smallexample
  31697. When @file{configure} builds a configuration using a remote source
  31698. directory, it creates a tree for the binaries with the same structure
  31699. (and using the same names) as the tree under the source directory. In
  31700. the example, you'd find the Sun 4 library @file{libiberty.a} in the
  31701. directory @file{gdb-sun4/libiberty}, and @value{GDBN} itself in
  31702. @file{gdb-sun4/gdb}.
  31703. Make sure that your path to the @file{configure} script has just one
  31704. instance of @file{gdb} in it. If your path to @file{configure} looks
  31705. like @file{../gdb-@value{GDBVN}/gdb/configure}, you are configuring only
  31706. one subdirectory of @value{GDBN}, not the whole package. This leads to
  31707. build errors about missing include files such as @file{bfd/bfd.h}.
  31708. One popular reason to build several @value{GDBN} configurations in separate
  31709. directories is to configure @value{GDBN} for cross-compiling (where
  31710. @value{GDBN} runs on one machine---the @dfn{host}---while debugging
  31711. programs that run on another machine---the @dfn{target}).
  31712. You specify a cross-debugging target by
  31713. giving the @samp{--target=@var{target}} option to @file{configure}.
  31714. When you run @code{make} to build a program or library, you must run
  31715. it in a configured directory---whatever directory you were in when you
  31716. called @file{configure} (or one of its subdirectories).
  31717. The @code{Makefile} that @file{configure} generates in each source
  31718. directory also runs recursively. If you type @code{make} in a source
  31719. directory such as @file{gdb-@value{GDBVN}} (or in a separate configured
  31720. directory configured with @samp{--srcdir=@var{dirname}/gdb-@value{GDBVN}}), you
  31721. will build all the required libraries, and then build GDB.
  31722. When you have multiple hosts or targets configured in separate
  31723. directories, you can run @code{make} on them in parallel (for example,
  31724. if they are NFS-mounted on each of the hosts); they will not interfere
  31725. with each other.
  31726. @node Config Names
  31727. @section Specifying Names for Hosts and Targets
  31728. The specifications used for hosts and targets in the @file{configure}
  31729. script are based on a three-part naming scheme, but some short predefined
  31730. aliases are also supported. The full naming scheme encodes three pieces
  31731. of information in the following pattern:
  31732. @smallexample
  31733. @var{architecture}-@var{vendor}-@var{os}
  31734. @end smallexample
  31735. For example, you can use the alias @code{sun4} as a @var{host} argument,
  31736. or as the value for @var{target} in a @code{--target=@var{target}}
  31737. option. The equivalent full name is @samp{sparc-sun-sunos4}.
  31738. The @file{configure} script accompanying @value{GDBN} does not provide
  31739. any query facility to list all supported host and target names or
  31740. aliases. @file{configure} calls the Bourne shell script
  31741. @code{config.sub} to map abbreviations to full names; you can read the
  31742. script, if you wish, or you can use it to test your guesses on
  31743. abbreviations---for example:
  31744. @smallexample
  31745. % sh config.sub i386-linux
  31746. i386-pc-linux-gnu
  31747. % sh config.sub alpha-linux
  31748. alpha-unknown-linux-gnu
  31749. % sh config.sub hp9k700
  31750. hppa1.1-hp-hpux
  31751. % sh config.sub sun4
  31752. sparc-sun-sunos4.1.1
  31753. % sh config.sub sun3
  31754. m68k-sun-sunos4.1.1
  31755. % sh config.sub i986v
  31756. Invalid configuration `i986v': machine `i986v' not recognized
  31757. @end smallexample
  31758. @noindent
  31759. @code{config.sub} is also distributed in the @value{GDBN} source
  31760. directory (@file{gdb-@value{GDBVN}}, for version @value{GDBVN}).
  31761. @node Configure Options
  31762. @section @file{configure} Options
  31763. Here is a summary of the @file{configure} options and arguments that
  31764. are most often useful for building @value{GDBN}. @file{configure}
  31765. also has several other options not listed here. @xref{Running
  31766. configure Scripts,,,autoconf}, for a full
  31767. explanation of @file{configure}.
  31768. @smallexample
  31769. configure @r{[}--help@r{]}
  31770. @r{[}--prefix=@var{dir}@r{]}
  31771. @r{[}--exec-prefix=@var{dir}@r{]}
  31772. @r{[}--srcdir=@var{dirname}@r{]}
  31773. @r{[}--target=@var{target}@r{]}
  31774. @end smallexample
  31775. @noindent
  31776. You may introduce options with a single @samp{-} rather than
  31777. @samp{--} if you prefer; but you may abbreviate option names if you use
  31778. @samp{--}.
  31779. @table @code
  31780. @item --help
  31781. Display a quick summary of how to invoke @file{configure}.
  31782. @item --prefix=@var{dir}
  31783. Configure the source to install programs and files under directory
  31784. @file{@var{dir}}.
  31785. @item --exec-prefix=@var{dir}
  31786. Configure the source to install programs under directory
  31787. @file{@var{dir}}.
  31788. @c avoid splitting the warning from the explanation:
  31789. @need 2000
  31790. @item --srcdir=@var{dirname}
  31791. Use this option to make configurations in directories separate from the
  31792. @value{GDBN} source directories. Among other things, you can use this to
  31793. build (or maintain) several configurations simultaneously, in separate
  31794. directories. @file{configure} writes configuration-specific files in
  31795. the current directory, but arranges for them to use the source in the
  31796. directory @var{dirname}. @file{configure} creates directories under
  31797. the working directory in parallel to the source directories below
  31798. @var{dirname}.
  31799. @item --target=@var{target}
  31800. Configure @value{GDBN} for cross-debugging programs running on the specified
  31801. @var{target}. Without this option, @value{GDBN} is configured to debug
  31802. programs that run on the same machine (@var{host}) as @value{GDBN} itself.
  31803. There is no convenient way to generate a list of all available
  31804. targets. Also see the @code{--enable-targets} option, below.
  31805. @end table
  31806. There are many other options that are specific to @value{GDBN}. This
  31807. lists just the most common ones; there are some very specialized
  31808. options not described here.
  31809. @table @code
  31810. @item --enable-targets=@r{[}@var{target}@r{]}@dots{}
  31811. @itemx --enable-targets=all
  31812. Configure @value{GDBN} for cross-debugging programs running on the
  31813. specified list of targets. The special value @samp{all} configures
  31814. @value{GDBN} for debugging programs running on any target it supports.
  31815. @item --with-gdb-datadir=@var{path}
  31816. Set the @value{GDBN}-specific data directory. @value{GDBN} will look
  31817. here for certain supporting files or scripts. This defaults to the
  31818. @file{gdb} subdirectory of @samp{datadir} (which can be set using
  31819. @code{--datadir}).
  31820. @item --with-relocated-sources=@var{dir}
  31821. Sets up the default source path substitution rule so that directory
  31822. names recorded in debug information will be automatically adjusted for
  31823. any directory under @var{dir}. @var{dir} should be a subdirectory of
  31824. @value{GDBN}'s configured prefix, the one mentioned in the
  31825. @code{--prefix} or @code{--exec-prefix} options to configure. This
  31826. option is useful if GDB is supposed to be moved to a different place
  31827. after it is built.
  31828. @item --enable-64-bit-bfd
  31829. Enable 64-bit support in BFD on 32-bit hosts.
  31830. @item --disable-gdbmi
  31831. Build @value{GDBN} without the GDB/MI machine interface
  31832. (@pxref{GDB/MI}).
  31833. @item --enable-tui
  31834. Build @value{GDBN} with the text-mode full-screen user interface
  31835. (TUI). Requires a curses library (ncurses and cursesX are also
  31836. supported).
  31837. @item --with-curses
  31838. Use the curses library instead of the termcap library, for text-mode
  31839. terminal operations.
  31840. @item --with-debuginfod
  31841. Build @value{GDBN} with @file{libdebuginfod}, the @code{debuginfod} client
  31842. library. Used to automatically fetch ELF, DWARF and source files from
  31843. @code{debuginfod} servers using build IDs associated with any missing
  31844. files. Enabled by default if @file{libdebuginfod} is installed and found
  31845. at configure time. For more information regarding @code{debuginfod} see
  31846. @ref{Debuginfod}.
  31847. @item --with-libunwind-ia64
  31848. Use the libunwind library for unwinding function call stack on ia64
  31849. target platforms. See http://www.nongnu.org/libunwind/index.html for
  31850. details.
  31851. @item --with-system-readline
  31852. Use the readline library installed on the host, rather than the
  31853. library supplied as part of @value{GDBN}. Readline 7 or newer is
  31854. required; this is enforced by the build system.
  31855. @item --with-system-zlib
  31856. Use the zlib library installed on the host, rather than the library
  31857. supplied as part of @value{GDBN}.
  31858. @item --with-expat
  31859. Build @value{GDBN} with Expat, a library for XML parsing. (Done by
  31860. default if libexpat is installed and found at configure time.) This
  31861. library is used to read XML files supplied with @value{GDBN}. If it
  31862. is unavailable, some features, such as remote protocol memory maps,
  31863. target descriptions, and shared library lists, that are based on XML
  31864. files, will not be available in @value{GDBN}. If your host does not
  31865. have libexpat installed, you can get the latest version from
  31866. `http://expat.sourceforge.net'.
  31867. @item --with-libiconv-prefix@r{[}=@var{dir}@r{]}
  31868. Build @value{GDBN} with GNU libiconv, a character set encoding
  31869. conversion library. This is not done by default, as on GNU systems
  31870. the @code{iconv} that is built in to the C library is sufficient. If
  31871. your host does not have a working @code{iconv}, you can get the latest
  31872. version of GNU iconv from `https://www.gnu.org/software/libiconv/'.
  31873. @value{GDBN}'s build system also supports building GNU libiconv as
  31874. part of the overall build. @xref{Requirements}.
  31875. @item --with-lzma
  31876. Build @value{GDBN} with LZMA, a compression library. (Done by default
  31877. if liblzma is installed and found at configure time.) LZMA is used by
  31878. @value{GDBN}'s "mini debuginfo" feature, which is only useful on
  31879. platforms using the ELF object file format. If your host does not
  31880. have liblzma installed, you can get the latest version from
  31881. `https://tukaani.org/xz/'.
  31882. @item --with-mpfr
  31883. Build @value{GDBN} with GNU MPFR, a library for multiple-precision
  31884. floating-point computation with correct rounding. (Done by default if
  31885. GNU MPFR is installed and found at configure time.) This library is
  31886. used to emulate target floating-point arithmetic during expression
  31887. evaluation when the target uses different floating-point formats than
  31888. the host. If GNU MPFR is not available, @value{GDBN} will fall back
  31889. to using host floating-point arithmetic. If your host does not have
  31890. GNU MPFR installed, you can get the latest version from
  31891. `http://www.mpfr.org'.
  31892. @item --with-python@r{[}=@var{python}@r{]}
  31893. Build @value{GDBN} with Python scripting support. (Done by default if
  31894. libpython is present and found at configure time.) Python makes
  31895. @value{GDBN} scripting much more powerful than the restricted CLI
  31896. scripting language. If your host does not have Python installed, you
  31897. can find it on `http://www.python.org/download/'. The oldest version
  31898. of Python supported by GDB is 2.6. The optional argument @var{python}
  31899. is used to find the Python headers and libraries. It can be either
  31900. the name of a Python executable, or the name of the directory in which
  31901. Python is installed.
  31902. @item --with-guile[=GUILE]'
  31903. Build @value{GDBN} with GNU Guile scripting support. (Done by default
  31904. if libguile is present and found at configure time.) If your host
  31905. does not have Guile installed, you can find it at
  31906. `https://www.gnu.org/software/guile/'. The optional argument GUILE
  31907. can be a version number, which will cause @code{configure} to try to
  31908. use that version of Guile; or the file name of a @code{pkg-config}
  31909. executable, which will be queried to find the information needed to
  31910. compile and link against Guile.
  31911. @item --without-included-regex
  31912. Don't use the regex library included with @value{GDBN} (as part of the
  31913. libiberty library). This is the default on hosts with version 2 of
  31914. the GNU C library.
  31915. @item --with-sysroot=@var{dir}
  31916. Use @var{dir} as the default system root directory for libraries whose
  31917. file names begin with @file{/lib}' or @file{/usr/lib'}. (The value of
  31918. @var{dir} can be modified at run time by using the @command{set
  31919. sysroot} command.) If @var{dir} is under the @value{GDBN} configured
  31920. prefix (set with @code{--prefix} or @code{--exec-prefix options}, the
  31921. default system root will be automatically adjusted if and when
  31922. @value{GDBN} is moved to a different location.
  31923. @item --with-system-gdbinit=@var{file}
  31924. Configure @value{GDBN} to automatically load a system-wide init file.
  31925. @var{file} should be an absolute file name. If @var{file} is in a
  31926. directory under the configured prefix, and @value{GDBN} is moved to
  31927. another location after being built, the location of the system-wide
  31928. init file will be adjusted accordingly.
  31929. @item --with-system-gdbinit-dir=@var{directory}
  31930. Configure @value{GDBN} to automatically load init files from a
  31931. system-wide directory. @var{directory} should be an absolute directory
  31932. name. If @var{directory} is in a directory under the configured
  31933. prefix, and @value{GDBN} is moved to another location after being
  31934. built, the location of the system-wide init directory will be
  31935. adjusted accordingly.
  31936. @item --enable-build-warnings
  31937. When building the @value{GDBN} sources, ask the compiler to warn about
  31938. any code which looks even vaguely suspicious. It passes many
  31939. different warning flags, depending on the exact version of the
  31940. compiler you are using.
  31941. @item --enable-werror
  31942. Treat compiler warnings as errors. It adds the @code{-Werror} flag
  31943. to the compiler, which will fail the compilation if the compiler
  31944. outputs any warning messages.
  31945. @item --enable-ubsan
  31946. Enable the GCC undefined behavior sanitizer. This is disabled by
  31947. default, but passing @code{--enable-ubsan=yes} or
  31948. @code{--enable-ubsan=auto} to @code{configure} will enable it. The
  31949. undefined behavior sanitizer checks for C@t{++} undefined behavior.
  31950. It has a performance cost, so if you are looking at @value{GDBN}'s
  31951. performance, you should disable it. The undefined behavior sanitizer
  31952. was first introduced in GCC 4.9.
  31953. @end table
  31954. @node System-wide configuration
  31955. @section System-wide configuration and settings
  31956. @cindex system-wide init file
  31957. @value{GDBN} can be configured to have a system-wide init file and a
  31958. system-wide init file directory; this file and files in that directory
  31959. (if they have a recognized file extension) will be read and executed at
  31960. startup (@pxref{Startup, , What @value{GDBN} does during startup}).
  31961. Here are the corresponding configure options:
  31962. @table @code
  31963. @item --with-system-gdbinit=@var{file}
  31964. Specify that the default location of the system-wide init file is
  31965. @var{file}.
  31966. @item --with-system-gdbinit-dir=@var{directory}
  31967. Specify that the default location of the system-wide init file directory
  31968. is @var{directory}.
  31969. @end table
  31970. If @value{GDBN} has been configured with the option @option{--prefix=$prefix},
  31971. they may be subject to relocation. Two possible cases:
  31972. @itemize @bullet
  31973. @item
  31974. If the default location of this init file/directory contains @file{$prefix},
  31975. it will be subject to relocation. Suppose that the configure options
  31976. are @option{--prefix=$prefix --with-system-gdbinit=$prefix/etc/gdbinit};
  31977. if @value{GDBN} is moved from @file{$prefix} to @file{$install}, the system
  31978. init file is looked for as @file{$install/etc/gdbinit} instead of
  31979. @file{$prefix/etc/gdbinit}.
  31980. @item
  31981. By contrast, if the default location does not contain the prefix,
  31982. it will not be relocated. E.g.@: if @value{GDBN} has been configured with
  31983. @option{--prefix=/usr/local --with-system-gdbinit=/usr/share/gdb/gdbinit},
  31984. then @value{GDBN} will always look for @file{/usr/share/gdb/gdbinit},
  31985. wherever @value{GDBN} is installed.
  31986. @end itemize
  31987. If the configured location of the system-wide init file (as given by the
  31988. @option{--with-system-gdbinit} option at configure time) is in the
  31989. data-directory (as specified by @option{--with-gdb-datadir} at configure
  31990. time) or in one of its subdirectories, then @value{GDBN} will look for the
  31991. system-wide init file in the directory specified by the
  31992. @option{--data-directory} command-line option.
  31993. Note that the system-wide init file is only read once, during @value{GDBN}
  31994. initialization. If the data-directory is changed after @value{GDBN} has
  31995. started with the @code{set data-directory} command, the file will not be
  31996. reread.
  31997. This applies similarly to the system-wide directory specified in
  31998. @option{--with-system-gdbinit-dir}.
  31999. Any supported scripting language can be used for these init files, as long
  32000. as the file extension matches the scripting language. To be interpreted
  32001. as regular @value{GDBN} commands, the files needs to have a @file{.gdb}
  32002. extension.
  32003. @menu
  32004. * System-wide Configuration Scripts:: Installed System-wide Configuration Scripts
  32005. @end menu
  32006. @node System-wide Configuration Scripts
  32007. @subsection Installed System-wide Configuration Scripts
  32008. @cindex system-wide configuration scripts
  32009. The @file{system-gdbinit} directory, located inside the data-directory
  32010. (as specified by @option{--with-gdb-datadir} at configure time) contains
  32011. a number of scripts which can be used as system-wide init files. To
  32012. automatically source those scripts at startup, @value{GDBN} should be
  32013. configured with @option{--with-system-gdbinit}. Otherwise, any user
  32014. should be able to source them by hand as needed.
  32015. The following scripts are currently available:
  32016. @itemize @bullet
  32017. @item @file{elinos.py}
  32018. @pindex elinos.py
  32019. @cindex ELinOS system-wide configuration script
  32020. This script is useful when debugging a program on an ELinOS target.
  32021. It takes advantage of the environment variables defined in a standard
  32022. ELinOS environment in order to determine the location of the system
  32023. shared libraries, and then sets the @samp{solib-absolute-prefix}
  32024. and @samp{solib-search-path} variables appropriately.
  32025. @item @file{wrs-linux.py}
  32026. @pindex wrs-linux.py
  32027. @cindex Wind River Linux system-wide configuration script
  32028. This script is useful when debugging a program on a target running
  32029. Wind River Linux. It expects the @env{ENV_PREFIX} to be set to
  32030. the host-side sysroot used by the target system.
  32031. @end itemize
  32032. @node Maintenance Commands
  32033. @appendix Maintenance Commands
  32034. @cindex maintenance commands
  32035. @cindex internal commands
  32036. In addition to commands intended for @value{GDBN} users, @value{GDBN}
  32037. includes a number of commands intended for @value{GDBN} developers,
  32038. that are not documented elsewhere in this manual. These commands are
  32039. provided here for reference. (For commands that turn on debugging
  32040. messages, see @ref{Debugging Output}.)
  32041. @table @code
  32042. @kindex maint agent
  32043. @kindex maint agent-eval
  32044. @item maint agent @r{[}-at @var{location}@r{,}@r{]} @var{expression}
  32045. @itemx maint agent-eval @r{[}-at @var{location}@r{,}@r{]} @var{expression}
  32046. Translate the given @var{expression} into remote agent bytecodes.
  32047. This command is useful for debugging the Agent Expression mechanism
  32048. (@pxref{Agent Expressions}). The @samp{agent} version produces an
  32049. expression useful for data collection, such as by tracepoints, while
  32050. @samp{maint agent-eval} produces an expression that evaluates directly
  32051. to a result. For instance, a collection expression for @code{globa +
  32052. globb} will include bytecodes to record four bytes of memory at each
  32053. of the addresses of @code{globa} and @code{globb}, while discarding
  32054. the result of the addition, while an evaluation expression will do the
  32055. addition and return the sum.
  32056. If @code{-at} is given, generate remote agent bytecode for @var{location}.
  32057. If not, generate remote agent bytecode for current frame PC address.
  32058. @kindex maint agent-printf
  32059. @item maint agent-printf @var{format},@var{expr},...
  32060. Translate the given format string and list of argument expressions
  32061. into remote agent bytecodes and display them as a disassembled list.
  32062. This command is useful for debugging the agent version of dynamic
  32063. printf (@pxref{Dynamic Printf}).
  32064. @kindex maint info breakpoints
  32065. @item @anchor{maint info breakpoints}maint info breakpoints
  32066. Using the same format as @samp{info breakpoints}, display both the
  32067. breakpoints you've set explicitly, and those @value{GDBN} is using for
  32068. internal purposes. Internal breakpoints are shown with negative
  32069. breakpoint numbers. The type column identifies what kind of breakpoint
  32070. is shown:
  32071. @table @code
  32072. @item breakpoint
  32073. Normal, explicitly set breakpoint.
  32074. @item watchpoint
  32075. Normal, explicitly set watchpoint.
  32076. @item longjmp
  32077. Internal breakpoint, used to handle correctly stepping through
  32078. @code{longjmp} calls.
  32079. @item longjmp resume
  32080. Internal breakpoint at the target of a @code{longjmp}.
  32081. @item until
  32082. Temporary internal breakpoint used by the @value{GDBN} @code{until} command.
  32083. @item finish
  32084. Temporary internal breakpoint used by the @value{GDBN} @code{finish} command.
  32085. @item shlib events
  32086. Shared library events.
  32087. @end table
  32088. @kindex maint info btrace
  32089. @item maint info btrace
  32090. Pint information about raw branch tracing data.
  32091. @kindex maint btrace packet-history
  32092. @item maint btrace packet-history
  32093. Print the raw branch trace packets that are used to compute the
  32094. execution history for the @samp{record btrace} command. Both the
  32095. information and the format in which it is printed depend on the btrace
  32096. recording format.
  32097. @table @code
  32098. @item bts
  32099. For the BTS recording format, print a list of blocks of sequential
  32100. code. For each block, the following information is printed:
  32101. @table @asis
  32102. @item Block number
  32103. Newer blocks have higher numbers. The oldest block has number zero.
  32104. @item Lowest @samp{PC}
  32105. @item Highest @samp{PC}
  32106. @end table
  32107. @item pt
  32108. For the Intel Processor Trace recording format, print a list of
  32109. Intel Processor Trace packets. For each packet, the following
  32110. information is printed:
  32111. @table @asis
  32112. @item Packet number
  32113. Newer packets have higher numbers. The oldest packet has number zero.
  32114. @item Trace offset
  32115. The packet's offset in the trace stream.
  32116. @item Packet opcode and payload
  32117. @end table
  32118. @end table
  32119. @kindex maint btrace clear-packet-history
  32120. @item maint btrace clear-packet-history
  32121. Discards the cached packet history printed by the @samp{maint btrace
  32122. packet-history} command. The history will be computed again when
  32123. needed.
  32124. @kindex maint btrace clear
  32125. @item maint btrace clear
  32126. Discard the branch trace data. The data will be fetched anew and the
  32127. branch trace will be recomputed when needed.
  32128. This implicitly truncates the branch trace to a single branch trace
  32129. buffer. When updating branch trace incrementally, the branch trace
  32130. available to @value{GDBN} may be bigger than a single branch trace
  32131. buffer.
  32132. @kindex maint set btrace pt skip-pad
  32133. @item maint set btrace pt skip-pad
  32134. @kindex maint show btrace pt skip-pad
  32135. @item maint show btrace pt skip-pad
  32136. Control whether @value{GDBN} will skip PAD packets when computing the
  32137. packet history.
  32138. @kindex maint info jit
  32139. @item maint info jit
  32140. Print information about JIT code objects loaded in the current inferior.
  32141. @kindex set displaced-stepping
  32142. @kindex show displaced-stepping
  32143. @cindex displaced stepping support
  32144. @cindex out-of-line single-stepping
  32145. @item set displaced-stepping
  32146. @itemx show displaced-stepping
  32147. Control whether or not @value{GDBN} will do @dfn{displaced stepping}
  32148. if the target supports it. Displaced stepping is a way to single-step
  32149. over breakpoints without removing them from the inferior, by executing
  32150. an out-of-line copy of the instruction that was originally at the
  32151. breakpoint location. It is also known as out-of-line single-stepping.
  32152. @table @code
  32153. @item set displaced-stepping on
  32154. If the target architecture supports it, @value{GDBN} will use
  32155. displaced stepping to step over breakpoints.
  32156. @item set displaced-stepping off
  32157. @value{GDBN} will not use displaced stepping to step over breakpoints,
  32158. even if such is supported by the target architecture.
  32159. @cindex non-stop mode, and @samp{set displaced-stepping}
  32160. @item set displaced-stepping auto
  32161. This is the default mode. @value{GDBN} will use displaced stepping
  32162. only if non-stop mode is active (@pxref{Non-Stop Mode}) and the target
  32163. architecture supports displaced stepping.
  32164. @end table
  32165. @kindex maint check-psymtabs
  32166. @item maint check-psymtabs
  32167. Check the consistency of currently expanded psymtabs versus symtabs.
  32168. Use this to check, for example, whether a symbol is in one but not the other.
  32169. @kindex maint check-symtabs
  32170. @item maint check-symtabs
  32171. Check the consistency of currently expanded symtabs.
  32172. @kindex maint expand-symtabs
  32173. @item maint expand-symtabs [@var{regexp}]
  32174. Expand symbol tables.
  32175. If @var{regexp} is specified, only expand symbol tables for file
  32176. names matching @var{regexp}.
  32177. @kindex maint set catch-demangler-crashes
  32178. @kindex maint show catch-demangler-crashes
  32179. @cindex demangler crashes
  32180. @item maint set catch-demangler-crashes [on|off]
  32181. @itemx maint show catch-demangler-crashes
  32182. Control whether @value{GDBN} should attempt to catch crashes in the
  32183. symbol name demangler. The default is to attempt to catch crashes.
  32184. If enabled, the first time a crash is caught, a core file is created,
  32185. the offending symbol is displayed and the user is presented with the
  32186. option to terminate the current session.
  32187. @kindex maint cplus first_component
  32188. @item maint cplus first_component @var{name}
  32189. Print the first C@t{++} class/namespace component of @var{name}.
  32190. @kindex maint cplus namespace
  32191. @item maint cplus namespace
  32192. Print the list of possible C@t{++} namespaces.
  32193. @kindex maint deprecate
  32194. @kindex maint undeprecate
  32195. @cindex deprecated commands
  32196. @item maint deprecate @var{command} @r{[}@var{replacement}@r{]}
  32197. @itemx maint undeprecate @var{command}
  32198. Deprecate or undeprecate the named @var{command}. Deprecated commands
  32199. cause @value{GDBN} to issue a warning when you use them. The optional
  32200. argument @var{replacement} says which newer command should be used in
  32201. favor of the deprecated one; if it is given, @value{GDBN} will mention
  32202. the replacement as part of the warning.
  32203. @kindex maint dump-me
  32204. @item maint dump-me
  32205. @cindex @code{SIGQUIT} signal, dump core of @value{GDBN}
  32206. Cause a fatal signal in the debugger and force it to dump its core.
  32207. This is supported only on systems which support aborting a program
  32208. with the @code{SIGQUIT} signal.
  32209. @kindex maint internal-error
  32210. @kindex maint internal-warning
  32211. @kindex maint demangler-warning
  32212. @cindex demangler crashes
  32213. @item maint internal-error @r{[}@var{message-text}@r{]}
  32214. @itemx maint internal-warning @r{[}@var{message-text}@r{]}
  32215. @itemx maint demangler-warning @r{[}@var{message-text}@r{]}
  32216. Cause @value{GDBN} to call the internal function @code{internal_error},
  32217. @code{internal_warning} or @code{demangler_warning} and hence behave
  32218. as though an internal problem has been detected. In addition to
  32219. reporting the internal problem, these functions give the user the
  32220. opportunity to either quit @value{GDBN} or (for @code{internal_error}
  32221. and @code{internal_warning}) create a core file of the current
  32222. @value{GDBN} session.
  32223. These commands take an optional parameter @var{message-text} that is
  32224. used as the text of the error or warning message.
  32225. Here's an example of using @code{internal-error}:
  32226. @smallexample
  32227. (@value{GDBP}) @kbd{maint internal-error testing, 1, 2}
  32228. @dots{}/maint.c:121: internal-error: testing, 1, 2
  32229. A problem internal to GDB has been detected. Further
  32230. debugging may prove unreliable.
  32231. Quit this debugging session? (y or n) @kbd{n}
  32232. Create a core file? (y or n) @kbd{n}
  32233. (@value{GDBP})
  32234. @end smallexample
  32235. @cindex @value{GDBN} internal error
  32236. @cindex internal errors, control of @value{GDBN} behavior
  32237. @cindex demangler crashes
  32238. @kindex maint set internal-error
  32239. @kindex maint show internal-error
  32240. @kindex maint set internal-warning
  32241. @kindex maint show internal-warning
  32242. @kindex maint set demangler-warning
  32243. @kindex maint show demangler-warning
  32244. @item maint set internal-error @var{action} [ask|yes|no]
  32245. @itemx maint show internal-error @var{action}
  32246. @itemx maint set internal-warning @var{action} [ask|yes|no]
  32247. @itemx maint show internal-warning @var{action}
  32248. @itemx maint set demangler-warning @var{action} [ask|yes|no]
  32249. @itemx maint show demangler-warning @var{action}
  32250. When @value{GDBN} reports an internal problem (error or warning) it
  32251. gives the user the opportunity to both quit @value{GDBN} and create a
  32252. core file of the current @value{GDBN} session. These commands let you
  32253. override the default behaviour for each particular @var{action},
  32254. described in the table below.
  32255. @table @samp
  32256. @item quit
  32257. You can specify that @value{GDBN} should always (yes) or never (no)
  32258. quit. The default is to ask the user what to do.
  32259. @item corefile
  32260. You can specify that @value{GDBN} should always (yes) or never (no)
  32261. create a core file. The default is to ask the user what to do. Note
  32262. that there is no @code{corefile} option for @code{demangler-warning}:
  32263. demangler warnings always create a core file and this cannot be
  32264. disabled.
  32265. @end table
  32266. @kindex maint set internal-error
  32267. @kindex maint show internal-error
  32268. @kindex maint set internal-warning
  32269. @kindex maint show internal-warning
  32270. @item maint set internal-error backtrace @r{[}on|off@r{]}
  32271. @itemx maint show internal-error backtrace
  32272. @itemx maint set internal-warning backtrace @r{[}on|off@r{]}
  32273. @itemx maint show internal-warning backtrace
  32274. When @value{GDBN} reports an internal problem (error or warning) it is
  32275. possible to have a backtrace of @value{GDBN} printed to the standard
  32276. error stream. This is @samp{on} by default for @code{internal-error}
  32277. and @samp{off} by default for @code{internal-warning}.
  32278. @anchor{maint packet}
  32279. @kindex maint packet
  32280. @item maint packet @var{text}
  32281. If @value{GDBN} is talking to an inferior via the serial protocol,
  32282. then this command sends the string @var{text} to the inferior, and
  32283. displays the response packet. @value{GDBN} supplies the initial
  32284. @samp{$} character, the terminating @samp{#} character, and the
  32285. checksum.
  32286. Any non-printable characters in the reply are printed as escaped hex,
  32287. e.g. @samp{\x00}, @samp{\x01}, etc.
  32288. @kindex maint print architecture
  32289. @item maint print architecture @r{[}@var{file}@r{]}
  32290. Print the entire architecture configuration. The optional argument
  32291. @var{file} names the file where the output goes.
  32292. @kindex maint print c-tdesc
  32293. @item maint print c-tdesc @r{[}-single-feature@r{]} @r{[}@var{file}@r{]}
  32294. Print the target description (@pxref{Target Descriptions}) as
  32295. a C source file. By default, the target description is for the current
  32296. target, but if the optional argument @var{file} is provided, that file
  32297. is used to produce the description. The @var{file} should be an XML
  32298. document, of the form described in @ref{Target Description Format}.
  32299. The created source file is built into @value{GDBN} when @value{GDBN} is
  32300. built again. This command is used by developers after they add or
  32301. modify XML target descriptions.
  32302. When the optional flag @samp{-single-feature} is provided then the
  32303. target description being processed (either the default, or from
  32304. @var{file}) must only contain a single feature. The source file
  32305. produced is different in this case.
  32306. @kindex maint print xml-tdesc
  32307. @item maint print xml-tdesc @r{[}@var{file}@r{]}
  32308. Print the target description (@pxref{Target Descriptions}) as an XML
  32309. file. By default print the target description for the current target,
  32310. but if the optional argument @var{file} is provided, then that file is
  32311. read in by GDB and then used to produce the description. The
  32312. @var{file} should be an XML document, of the form described in
  32313. @ref{Target Description Format}.
  32314. @kindex maint check xml-descriptions
  32315. @item maint check xml-descriptions @var{dir}
  32316. Check that the target descriptions dynamically created by @value{GDBN}
  32317. equal the descriptions created from XML files found in @var{dir}.
  32318. @anchor{maint check libthread-db}
  32319. @kindex maint check libthread-db
  32320. @item maint check libthread-db
  32321. Run integrity checks on the current inferior's thread debugging
  32322. library. This exercises all @code{libthread_db} functionality used by
  32323. @value{GDBN} on GNU/Linux systems, and by extension also exercises the
  32324. @code{proc_service} functions provided by @value{GDBN} that
  32325. @code{libthread_db} uses. Note that parts of the test may be skipped
  32326. on some platforms when debugging core files.
  32327. @kindex maint print core-file-backed-mappings
  32328. @cindex memory address space mappings
  32329. @item maint print core-file-backed-mappings
  32330. Print the file-backed mappings which were loaded from a core file note.
  32331. This output represents state internal to @value{GDBN} and should be
  32332. similar to the mappings displayed by the @code{info proc mappings}
  32333. command.
  32334. @kindex maint print dummy-frames
  32335. @item maint print dummy-frames
  32336. Prints the contents of @value{GDBN}'s internal dummy-frame stack.
  32337. @smallexample
  32338. (@value{GDBP}) @kbd{b add}
  32339. @dots{}
  32340. (@value{GDBP}) @kbd{print add(2,3)}
  32341. Breakpoint 2, add (a=2, b=3) at @dots{}
  32342. 58 return (a + b);
  32343. The program being debugged stopped while in a function called from GDB.
  32344. @dots{}
  32345. (@value{GDBP}) @kbd{maint print dummy-frames}
  32346. 0xa8206d8: id=@{stack=0xbfffe734,code=0xbfffe73f,!special@}, ptid=process 9353
  32347. (@value{GDBP})
  32348. @end smallexample
  32349. Takes an optional file parameter.
  32350. @kindex maint print registers
  32351. @kindex maint print raw-registers
  32352. @kindex maint print cooked-registers
  32353. @kindex maint print register-groups
  32354. @kindex maint print remote-registers
  32355. @item maint print registers @r{[}@var{file}@r{]}
  32356. @itemx maint print raw-registers @r{[}@var{file}@r{]}
  32357. @itemx maint print cooked-registers @r{[}@var{file}@r{]}
  32358. @itemx maint print register-groups @r{[}@var{file}@r{]}
  32359. @itemx maint print remote-registers @r{[}@var{file}@r{]}
  32360. Print @value{GDBN}'s internal register data structures.
  32361. The command @code{maint print raw-registers} includes the contents of
  32362. the raw register cache; the command @code{maint print
  32363. cooked-registers} includes the (cooked) value of all registers,
  32364. including registers which aren't available on the target nor visible
  32365. to user; the command @code{maint print register-groups} includes the
  32366. groups that each register is a member of; and the command @code{maint
  32367. print remote-registers} includes the remote target's register numbers
  32368. and offsets in the `G' packets.
  32369. These commands take an optional parameter, a file name to which to
  32370. write the information.
  32371. @kindex maint print reggroups
  32372. @item maint print reggroups @r{[}@var{file}@r{]}
  32373. Print @value{GDBN}'s internal register group data structures. The
  32374. optional argument @var{file} tells to what file to write the
  32375. information.
  32376. The register groups info looks like this:
  32377. @smallexample
  32378. (@value{GDBP}) @kbd{maint print reggroups}
  32379. Group Type
  32380. general user
  32381. float user
  32382. all user
  32383. vector user
  32384. system user
  32385. save internal
  32386. restore internal
  32387. @end smallexample
  32388. @kindex maint flush register-cache
  32389. @kindex flushregs
  32390. @cindex register cache, flushing
  32391. @item maint flush register-cache
  32392. @itemx flushregs
  32393. Flush the contents of the register cache and as a consequence the
  32394. frame cache. This command is useful when debugging issues related to
  32395. register fetching, or frame unwinding. The command @code{flushregs}
  32396. is deprecated in favor of @code{maint flush register-cache}.
  32397. @kindex maint flush source-cache
  32398. @cindex source code, caching
  32399. @item maint flush source-cache
  32400. Flush @value{GDBN}'s cache of source code file contents. After
  32401. @value{GDBN} reads a source file, and optionally applies styling
  32402. (@pxref{Output Styling}), the file contents are cached. This command
  32403. clears that cache. The next time @value{GDBN} wants to show lines
  32404. from a source file, the content will be re-read.
  32405. This command is useful when debugging issues related to source code
  32406. styling. After flushing the cache any source code displayed by
  32407. @value{GDBN} will be re-read and re-styled.
  32408. @kindex maint print objfiles
  32409. @cindex info for known object files
  32410. @item maint print objfiles @r{[}@var{regexp}@r{]}
  32411. Print a dump of all known object files.
  32412. If @var{regexp} is specified, only print object files whose names
  32413. match @var{regexp}. For each object file, this command prints its name,
  32414. address in memory, and all of its psymtabs and symtabs.
  32415. @kindex maint print user-registers
  32416. @cindex user registers
  32417. @item maint print user-registers
  32418. List all currently available @dfn{user registers}. User registers
  32419. typically provide alternate names for actual hardware registers. They
  32420. include the four ``standard'' registers @code{$fp}, @code{$pc},
  32421. @code{$sp}, and @code{$ps}. @xref{standard registers}. User
  32422. registers can be used in expressions in the same way as the canonical
  32423. register names, but only the latter are listed by the @code{info
  32424. registers} and @code{maint print registers} commands.
  32425. @kindex maint print section-scripts
  32426. @cindex info for known .debug_gdb_scripts-loaded scripts
  32427. @item maint print section-scripts [@var{regexp}]
  32428. Print a dump of scripts specified in the @code{.debug_gdb_section} section.
  32429. If @var{regexp} is specified, only print scripts loaded by object files
  32430. matching @var{regexp}.
  32431. For each script, this command prints its name as specified in the objfile,
  32432. and the full path if known.
  32433. @xref{dotdebug_gdb_scripts section}.
  32434. @kindex maint print statistics
  32435. @cindex bcache statistics
  32436. @item maint print statistics
  32437. This command prints, for each object file in the program, various data
  32438. about that object file followed by the byte cache (@dfn{bcache})
  32439. statistics for the object file. The objfile data includes the number
  32440. of minimal, partial, full, and stabs symbols, the number of types
  32441. defined by the objfile, the number of as yet unexpanded psym tables,
  32442. the number of line tables and string tables, and the amount of memory
  32443. used by the various tables. The bcache statistics include the counts,
  32444. sizes, and counts of duplicates of all and unique objects, max,
  32445. average, and median entry size, total memory used and its overhead and
  32446. savings, and various measures of the hash table size and chain
  32447. lengths.
  32448. @kindex maint print target-stack
  32449. @cindex target stack description
  32450. @item maint print target-stack
  32451. A @dfn{target} is an interface between the debugger and a particular
  32452. kind of file or process. Targets can be stacked in @dfn{strata},
  32453. so that more than one target can potentially respond to a request.
  32454. In particular, memory accesses will walk down the stack of targets
  32455. until they find a target that is interested in handling that particular
  32456. address.
  32457. This command prints a short description of each layer that was pushed on
  32458. the @dfn{target stack}, starting from the top layer down to the bottom one.
  32459. @kindex maint print type
  32460. @cindex type chain of a data type
  32461. @item maint print type @var{expr}
  32462. Print the type chain for a type specified by @var{expr}. The argument
  32463. can be either a type name or a symbol. If it is a symbol, the type of
  32464. that symbol is described. The type chain produced by this command is
  32465. a recursive definition of the data type as stored in @value{GDBN}'s
  32466. data structures, including its flags and contained types.
  32467. @kindex maint selftest
  32468. @cindex self tests
  32469. @item maint selftest @r{[}-verbose@r{]} @r{[}@var{filter}@r{]}
  32470. Run any self tests that were compiled in to @value{GDBN}. This will
  32471. print a message showing how many tests were run, and how many failed.
  32472. If a @var{filter} is passed, only the tests with @var{filter} in their
  32473. name will be ran. If @code{-verbose} is passed, the self tests can be
  32474. more verbose.
  32475. @kindex maint set selftest verbose
  32476. @kindex maint show selftest verbose
  32477. @cindex self tests
  32478. @item maint set selftest verbose
  32479. @item maint show selftest verbose
  32480. Control whether self tests are run verbosely or not.
  32481. @kindex maint info selftests
  32482. @cindex self tests
  32483. @item maint info selftests
  32484. List the selftests compiled in to @value{GDBN}.
  32485. @kindex maint set dwarf always-disassemble
  32486. @kindex maint show dwarf always-disassemble
  32487. @item maint set dwarf always-disassemble
  32488. @item maint show dwarf always-disassemble
  32489. Control the behavior of @code{info address} when using DWARF debugging
  32490. information.
  32491. The default is @code{off}, which means that @value{GDBN} should try to
  32492. describe a variable's location in an easily readable format. When
  32493. @code{on}, @value{GDBN} will instead display the DWARF location
  32494. expression in an assembly-like format. Note that some locations are
  32495. too complex for @value{GDBN} to describe simply; in this case you will
  32496. always see the disassembly form.
  32497. Here is an example of the resulting disassembly:
  32498. @smallexample
  32499. (gdb) info addr argc
  32500. Symbol "argc" is a complex DWARF expression:
  32501. 1: DW_OP_fbreg 0
  32502. @end smallexample
  32503. For more information on these expressions, see
  32504. @uref{http://www.dwarfstd.org/, the DWARF standard}.
  32505. @kindex maint set dwarf max-cache-age
  32506. @kindex maint show dwarf max-cache-age
  32507. @item maint set dwarf max-cache-age
  32508. @itemx maint show dwarf max-cache-age
  32509. Control the DWARF compilation unit cache.
  32510. @cindex DWARF compilation units cache
  32511. In object files with inter-compilation-unit references, such as those
  32512. produced by the GCC option @samp{-feliminate-dwarf2-dups}, the DWARF
  32513. reader needs to frequently refer to previously read compilation units.
  32514. This setting controls how long a compilation unit will remain in the
  32515. cache if it is not referenced. A higher limit means that cached
  32516. compilation units will be stored in memory longer, and more total
  32517. memory will be used. Setting it to zero disables caching, which will
  32518. slow down @value{GDBN} startup, but reduce memory consumption.
  32519. @kindex maint set dwarf unwinders
  32520. @kindex maint show dwarf unwinders
  32521. @item maint set dwarf unwinders
  32522. @itemx maint show dwarf unwinders
  32523. Control use of the DWARF frame unwinders.
  32524. @cindex DWARF frame unwinders
  32525. Many targets that support DWARF debugging use @value{GDBN}'s DWARF
  32526. frame unwinders to build the backtrace. Many of these targets will
  32527. also have a second mechanism for building the backtrace for use in
  32528. cases where DWARF information is not available, this second mechanism
  32529. is often an analysis of a function's prologue.
  32530. In order to extend testing coverage of the second level stack
  32531. unwinding mechanisms it is helpful to be able to disable the DWARF
  32532. stack unwinders, this can be done with this switch.
  32533. In normal use of @value{GDBN} disabling the DWARF unwinders is not
  32534. advisable, there are cases that are better handled through DWARF than
  32535. prologue analysis, and the debug experience is likely to be better
  32536. with the DWARF frame unwinders enabled.
  32537. If DWARF frame unwinders are not supported for a particular target
  32538. architecture, then enabling this flag does not cause them to be used.
  32539. @kindex maint set worker-threads
  32540. @kindex maint show worker-threads
  32541. @item maint set worker-threads
  32542. @item maint show worker-threads
  32543. Control the number of worker threads that may be used by @value{GDBN}.
  32544. On capable hosts, @value{GDBN} may use multiple threads to speed up
  32545. certain CPU-intensive operations, such as demangling symbol names.
  32546. While the number of threads used by @value{GDBN} may vary, this
  32547. command can be used to set an upper bound on this number. The default
  32548. is @code{unlimited}, which lets @value{GDBN} choose a reasonable
  32549. number. Note that this only controls worker threads started by
  32550. @value{GDBN} itself; libraries used by @value{GDBN} may start threads
  32551. of their own.
  32552. @kindex maint set profile
  32553. @kindex maint show profile
  32554. @cindex profiling GDB
  32555. @item maint set profile
  32556. @itemx maint show profile
  32557. Control profiling of @value{GDBN}.
  32558. Profiling will be disabled until you use the @samp{maint set profile}
  32559. command to enable it. When you enable profiling, the system will begin
  32560. collecting timing and execution count data; when you disable profiling or
  32561. exit @value{GDBN}, the results will be written to a log file. Remember that
  32562. if you use profiling, @value{GDBN} will overwrite the profiling log file
  32563. (often called @file{gmon.out}). If you have a record of important profiling
  32564. data in a @file{gmon.out} file, be sure to move it to a safe location.
  32565. Configuring with @samp{--enable-profiling} arranges for @value{GDBN} to be
  32566. compiled with the @samp{-pg} compiler option.
  32567. @kindex maint set show-debug-regs
  32568. @kindex maint show show-debug-regs
  32569. @cindex hardware debug registers
  32570. @item maint set show-debug-regs
  32571. @itemx maint show show-debug-regs
  32572. Control whether to show variables that mirror the hardware debug
  32573. registers. Use @code{on} to enable, @code{off} to disable. If
  32574. enabled, the debug registers values are shown when @value{GDBN} inserts or
  32575. removes a hardware breakpoint or watchpoint, and when the inferior
  32576. triggers a hardware-assisted breakpoint or watchpoint.
  32577. @kindex maint set show-all-tib
  32578. @kindex maint show show-all-tib
  32579. @item maint set show-all-tib
  32580. @itemx maint show show-all-tib
  32581. Control whether to show all non zero areas within a 1k block starting
  32582. at thread local base, when using the @samp{info w32 thread-information-block}
  32583. command.
  32584. @kindex maint set target-async
  32585. @kindex maint show target-async
  32586. @item maint set target-async
  32587. @itemx maint show target-async
  32588. This controls whether @value{GDBN} targets operate in synchronous or
  32589. asynchronous mode (@pxref{Background Execution}). Normally the
  32590. default is asynchronous, if it is available; but this can be changed
  32591. to more easily debug problems occurring only in synchronous mode.
  32592. @kindex maint set target-non-stop @var{mode} [on|off|auto]
  32593. @kindex maint show target-non-stop
  32594. @item maint set target-non-stop
  32595. @itemx maint show target-non-stop
  32596. This controls whether @value{GDBN} targets always operate in non-stop
  32597. mode even if @code{set non-stop} is @code{off} (@pxref{Non-Stop
  32598. Mode}). The default is @code{auto}, meaning non-stop mode is enabled
  32599. if supported by the target.
  32600. @table @code
  32601. @item maint set target-non-stop auto
  32602. This is the default mode. @value{GDBN} controls the target in
  32603. non-stop mode if the target supports it.
  32604. @item maint set target-non-stop on
  32605. @value{GDBN} controls the target in non-stop mode even if the target
  32606. does not indicate support.
  32607. @item maint set target-non-stop off
  32608. @value{GDBN} does not control the target in non-stop mode even if the
  32609. target supports it.
  32610. @end table
  32611. @kindex maint set tui-resize-message
  32612. @kindex maint show tui-resize-message
  32613. @item maint set tui-resize-message
  32614. @item maint show tui-resize-message
  32615. Control whether @value{GDBN} displays a message each time the terminal
  32616. is resized when in TUI mode. The default is @code{off}, which means
  32617. that @value{GDBN} is silent during resizes. When @code{on},
  32618. @value{GDBN} will display a message after a resize is completed; the
  32619. message will include a number indicating how many times the terminal
  32620. has been resized. This setting is intended for use by the test suite,
  32621. where it would otherwise be difficult to determine when a resize and
  32622. refresh has been completed.
  32623. @kindex maint set per-command
  32624. @kindex maint show per-command
  32625. @item maint set per-command
  32626. @itemx maint show per-command
  32627. @cindex resources used by commands
  32628. @value{GDBN} can display the resources used by each command.
  32629. This is useful in debugging performance problems.
  32630. @table @code
  32631. @item maint set per-command space [on|off]
  32632. @itemx maint show per-command space
  32633. Enable or disable the printing of the memory used by GDB for each command.
  32634. If enabled, @value{GDBN} will display how much memory each command
  32635. took, following the command's own output.
  32636. This can also be requested by invoking @value{GDBN} with the
  32637. @option{--statistics} command-line switch (@pxref{Mode Options}).
  32638. @item maint set per-command time [on|off]
  32639. @itemx maint show per-command time
  32640. Enable or disable the printing of the execution time of @value{GDBN}
  32641. for each command.
  32642. If enabled, @value{GDBN} will display how much time it
  32643. took to execute each command, following the command's own output.
  32644. Both CPU time and wallclock time are printed.
  32645. Printing both is useful when trying to determine whether the cost is
  32646. CPU or, e.g., disk/network latency.
  32647. Note that the CPU time printed is for @value{GDBN} only, it does not include
  32648. the execution time of the inferior because there's no mechanism currently
  32649. to compute how much time was spent by @value{GDBN} and how much time was
  32650. spent by the program been debugged.
  32651. This can also be requested by invoking @value{GDBN} with the
  32652. @option{--statistics} command-line switch (@pxref{Mode Options}).
  32653. @item maint set per-command symtab [on|off]
  32654. @itemx maint show per-command symtab
  32655. Enable or disable the printing of basic symbol table statistics
  32656. for each command.
  32657. If enabled, @value{GDBN} will display the following information:
  32658. @enumerate a
  32659. @item
  32660. number of symbol tables
  32661. @item
  32662. number of primary symbol tables
  32663. @item
  32664. number of blocks in the blockvector
  32665. @end enumerate
  32666. @end table
  32667. @kindex maint set check-libthread-db
  32668. @kindex maint show check-libthread-db
  32669. @item maint set check-libthread-db [on|off]
  32670. @itemx maint show check-libthread-db
  32671. Control whether @value{GDBN} should run integrity checks on inferior
  32672. specific thread debugging libraries as they are loaded. The default
  32673. is not to perform such checks. If any check fails @value{GDBN} will
  32674. unload the library and continue searching for a suitable candidate as
  32675. described in @ref{set libthread-db-search-path}. For more information
  32676. about the tests, see @ref{maint check libthread-db}.
  32677. @kindex maint set gnu-source-highlight enabled
  32678. @kindex maint show gnu-source-highlight enabled
  32679. @item maint set gnu-source-highlight enabled @r{[}on|off@r{]}
  32680. @itemx maint show gnu-source-highlight enabled
  32681. Control whether @value{GDBN} should use the GNU Source Highlight
  32682. library for applying styling to source code (@pxref{Output Styling}).
  32683. This will be @samp{on} by default if the GNU Source Highlight library
  32684. is available. If the GNU Source Highlight library is not available,
  32685. then this will be @samp{off} by default, and attempting to change this
  32686. value to @samp{on} will give an error.
  32687. If the GNU Source Highlight library is not being used, then
  32688. @value{GDBN} will use the Python Pygments package for source code
  32689. styling, if it is available.
  32690. This option is useful for debugging @value{GDBN}'s use of the Pygments
  32691. library when @value{GDBN} is linked against the GNU Source Highlight
  32692. library.
  32693. @kindex maint space
  32694. @cindex memory used by commands
  32695. @item maint space @var{value}
  32696. An alias for @code{maint set per-command space}.
  32697. A non-zero value enables it, zero disables it.
  32698. @kindex maint time
  32699. @cindex time of command execution
  32700. @item maint time @var{value}
  32701. An alias for @code{maint set per-command time}.
  32702. A non-zero value enables it, zero disables it.
  32703. @kindex maint translate-address
  32704. @item maint translate-address @r{[}@var{section}@r{]} @var{addr}
  32705. Find the symbol stored at the location specified by the address
  32706. @var{addr} and an optional section name @var{section}. If found,
  32707. @value{GDBN} prints the name of the closest symbol and an offset from
  32708. the symbol's location to the specified address. This is similar to
  32709. the @code{info address} command (@pxref{Symbols}), except that this
  32710. command also allows to find symbols in other sections.
  32711. If section was not specified, the section in which the symbol was found
  32712. is also printed. For dynamically linked executables, the name of
  32713. executable or shared library containing the symbol is printed as well.
  32714. @kindex maint test-options
  32715. @item maint test-options require-delimiter
  32716. @itemx maint test-options unknown-is-error
  32717. @itemx maint test-options unknown-is-operand
  32718. These commands are used by the testsuite to validate the command
  32719. options framework. The @code{require-delimiter} variant requires a
  32720. double-dash delimiter to indicate end of options. The
  32721. @code{unknown-is-error} and @code{unknown-is-operand} do not. The
  32722. @code{unknown-is-error} variant throws an error on unknown option,
  32723. while @code{unknown-is-operand} treats unknown options as the start of
  32724. the command's operands. When run, the commands output the result of
  32725. the processed options. When completed, the commands store the
  32726. internal result of completion in a variable exposed by the @code{maint
  32727. show test-options-completion-result} command.
  32728. @kindex maint show test-options-completion-result
  32729. @item maint show test-options-completion-result
  32730. Shows the result of completing the @code{maint test-options}
  32731. subcommands. This is used by the testsuite to validate completion
  32732. support in the command options framework.
  32733. @kindex maint set test-settings
  32734. @kindex maint show test-settings
  32735. @item maint set test-settings @var{kind}
  32736. @itemx maint show test-settings @var{kind}
  32737. These are representative commands for each @var{kind} of setting type
  32738. @value{GDBN} supports. They are used by the testsuite for exercising
  32739. the settings infrastructure.
  32740. @kindex maint set backtrace-on-fatal-signal
  32741. @kindex maint show backtrace-on-fatal-signal
  32742. @item maint set backtrace-on-fatal-signal [on|off]
  32743. @itemx maint show backtrace-on-fatal-signal
  32744. When this setting is @code{on}, if @value{GDBN} itself terminates with
  32745. a fatal signal (e.g.@: SIGSEGV), then a limited backtrace will be
  32746. printed to the standard error stream. This backtrace can be used to
  32747. help diagnose crashes within @value{GDBN} in situations where a user
  32748. is unable to share a corefile with the @value{GDBN} developers.
  32749. If the functionality to provide this backtrace is not available for
  32750. the platform on which GDB is running then this feature will be
  32751. @code{off} by default, and attempting to turn this feature on will
  32752. give an error.
  32753. For platforms that do support creating the backtrace this feature is
  32754. @code{on} by default.
  32755. @kindex maint with
  32756. @item maint with @var{setting} [@var{value}] [-- @var{command}]
  32757. Like the @code{with} command, but works with @code{maintenance set}
  32758. variables. This is used by the testsuite to exercise the @code{with}
  32759. command's infrastructure.
  32760. @end table
  32761. The following command is useful for non-interactive invocations of
  32762. @value{GDBN}, such as in the test suite.
  32763. @table @code
  32764. @item set watchdog @var{nsec}
  32765. @kindex set watchdog
  32766. @cindex watchdog timer
  32767. @cindex timeout for commands
  32768. Set the maximum number of seconds @value{GDBN} will wait for the
  32769. target operation to finish. If this time expires, @value{GDBN}
  32770. reports and error and the command is aborted.
  32771. @item show watchdog
  32772. Show the current setting of the target wait timeout.
  32773. @end table
  32774. @node Remote Protocol
  32775. @appendix @value{GDBN} Remote Serial Protocol
  32776. @menu
  32777. * Overview::
  32778. * Packets::
  32779. * Stop Reply Packets::
  32780. * General Query Packets::
  32781. * Architecture-Specific Protocol Details::
  32782. * Tracepoint Packets::
  32783. * Host I/O Packets::
  32784. * Interrupts::
  32785. * Notification Packets::
  32786. * Remote Non-Stop::
  32787. * Packet Acknowledgment::
  32788. * Examples::
  32789. * File-I/O Remote Protocol Extension::
  32790. * Library List Format::
  32791. * Library List Format for SVR4 Targets::
  32792. * Memory Map Format::
  32793. * Thread List Format::
  32794. * Traceframe Info Format::
  32795. * Branch Trace Format::
  32796. * Branch Trace Configuration Format::
  32797. @end menu
  32798. @node Overview
  32799. @section Overview
  32800. There may be occasions when you need to know something about the
  32801. protocol---for example, if there is only one serial port to your target
  32802. machine, you might want your program to do something special if it
  32803. recognizes a packet meant for @value{GDBN}.
  32804. In the examples below, @samp{->} and @samp{<-} are used to indicate
  32805. transmitted and received data, respectively.
  32806. @cindex protocol, @value{GDBN} remote serial
  32807. @cindex serial protocol, @value{GDBN} remote
  32808. @cindex remote serial protocol
  32809. All @value{GDBN} commands and responses (other than acknowledgments
  32810. and notifications, see @ref{Notification Packets}) are sent as a
  32811. @var{packet}. A @var{packet} is introduced with the character
  32812. @samp{$}, the actual @var{packet-data}, and the terminating character
  32813. @samp{#} followed by a two-digit @var{checksum}:
  32814. @smallexample
  32815. @code{$}@var{packet-data}@code{#}@var{checksum}
  32816. @end smallexample
  32817. @noindent
  32818. @cindex checksum, for @value{GDBN} remote
  32819. @noindent
  32820. The two-digit @var{checksum} is computed as the modulo 256 sum of all
  32821. characters between the leading @samp{$} and the trailing @samp{#} (an
  32822. eight bit unsigned checksum).
  32823. Implementors should note that prior to @value{GDBN} 5.0 the protocol
  32824. specification also included an optional two-digit @var{sequence-id}:
  32825. @smallexample
  32826. @code{$}@var{sequence-id}@code{:}@var{packet-data}@code{#}@var{checksum}
  32827. @end smallexample
  32828. @cindex sequence-id, for @value{GDBN} remote
  32829. @noindent
  32830. That @var{sequence-id} was appended to the acknowledgment. @value{GDBN}
  32831. has never output @var{sequence-id}s. Stubs that handle packets added
  32832. since @value{GDBN} 5.0 must not accept @var{sequence-id}.
  32833. When either the host or the target machine receives a packet, the first
  32834. response expected is an acknowledgment: either @samp{+} (to indicate
  32835. the package was received correctly) or @samp{-} (to request
  32836. retransmission):
  32837. @smallexample
  32838. -> @code{$}@var{packet-data}@code{#}@var{checksum}
  32839. <- @code{+}
  32840. @end smallexample
  32841. @noindent
  32842. The @samp{+}/@samp{-} acknowledgments can be disabled
  32843. once a connection is established.
  32844. @xref{Packet Acknowledgment}, for details.
  32845. The host (@value{GDBN}) sends @var{command}s, and the target (the
  32846. debugging stub incorporated in your program) sends a @var{response}. In
  32847. the case of step and continue @var{command}s, the response is only sent
  32848. when the operation has completed, and the target has again stopped all
  32849. threads in all attached processes. This is the default all-stop mode
  32850. behavior, but the remote protocol also supports @value{GDBN}'s non-stop
  32851. execution mode; see @ref{Remote Non-Stop}, for details.
  32852. @var{packet-data} consists of a sequence of characters with the
  32853. exception of @samp{#} and @samp{$} (see @samp{X} packet for additional
  32854. exceptions).
  32855. @cindex remote protocol, field separator
  32856. Fields within the packet should be separated using @samp{,} @samp{;} or
  32857. @samp{:}. Except where otherwise noted all numbers are represented in
  32858. @sc{hex} with leading zeros suppressed.
  32859. Implementors should note that prior to @value{GDBN} 5.0, the character
  32860. @samp{:} could not appear as the third character in a packet (as it
  32861. would potentially conflict with the @var{sequence-id}).
  32862. @cindex remote protocol, binary data
  32863. @anchor{Binary Data}
  32864. Binary data in most packets is encoded either as two hexadecimal
  32865. digits per byte of binary data. This allowed the traditional remote
  32866. protocol to work over connections which were only seven-bit clean.
  32867. Some packets designed more recently assume an eight-bit clean
  32868. connection, and use a more efficient encoding to send and receive
  32869. binary data.
  32870. The binary data representation uses @code{7d} (@sc{ascii} @samp{@}})
  32871. as an escape character. Any escaped byte is transmitted as the escape
  32872. character followed by the original character XORed with @code{0x20}.
  32873. For example, the byte @code{0x7d} would be transmitted as the two
  32874. bytes @code{0x7d 0x5d}. The bytes @code{0x23} (@sc{ascii} @samp{#}),
  32875. @code{0x24} (@sc{ascii} @samp{$}), and @code{0x7d} (@sc{ascii}
  32876. @samp{@}}) must always be escaped. Responses sent by the stub
  32877. must also escape @code{0x2a} (@sc{ascii} @samp{*}), so that it
  32878. is not interpreted as the start of a run-length encoded sequence
  32879. (described next).
  32880. Response @var{data} can be run-length encoded to save space.
  32881. Run-length encoding replaces runs of identical characters with one
  32882. instance of the repeated character, followed by a @samp{*} and a
  32883. repeat count. The repeat count is itself sent encoded, to avoid
  32884. binary characters in @var{data}: a value of @var{n} is sent as
  32885. @code{@var{n}+29}. For a repeat count greater or equal to 3, this
  32886. produces a printable @sc{ascii} character, e.g.@: a space (@sc{ascii}
  32887. code 32) for a repeat count of 3. (This is because run-length
  32888. encoding starts to win for counts 3 or more.) Thus, for example,
  32889. @samp{0* } is a run-length encoding of ``0000'': the space character
  32890. after @samp{*} means repeat the leading @code{0} @w{@code{32 - 29 =
  32891. 3}} more times.
  32892. The printable characters @samp{#} and @samp{$} or with a numeric value
  32893. greater than 126 must not be used. Runs of six repeats (@samp{#}) or
  32894. seven repeats (@samp{$}) can be expanded using a repeat count of only
  32895. five (@samp{"}). For example, @samp{00000000} can be encoded as
  32896. @samp{0*"00}.
  32897. The error response returned for some packets includes a two character
  32898. error number. That number is not well defined.
  32899. @cindex empty response, for unsupported packets
  32900. For any @var{command} not supported by the stub, an empty response
  32901. (@samp{$#00}) should be returned. That way it is possible to extend the
  32902. protocol. A newer @value{GDBN} can tell if a packet is supported based
  32903. on that response.
  32904. At a minimum, a stub is required to support the @samp{?} command to
  32905. tell @value{GDBN} the reason for halting, @samp{g} and @samp{G}
  32906. commands for register access, and the @samp{m} and @samp{M} commands
  32907. for memory access. Stubs that only control single-threaded targets
  32908. can implement run control with the @samp{c} (continue) command, and if
  32909. the target architecture supports hardware-assisted single-stepping,
  32910. the @samp{s} (step) command. Stubs that support multi-threading
  32911. targets should support the @samp{vCont} command. All other commands
  32912. are optional.
  32913. @node Packets
  32914. @section Packets
  32915. The following table provides a complete list of all currently defined
  32916. @var{command}s and their corresponding response @var{data}.
  32917. @xref{File-I/O Remote Protocol Extension}, for details about the File
  32918. I/O extension of the remote protocol.
  32919. Each packet's description has a template showing the packet's overall
  32920. syntax, followed by an explanation of the packet's meaning. We
  32921. include spaces in some of the templates for clarity; these are not
  32922. part of the packet's syntax. No @value{GDBN} packet uses spaces to
  32923. separate its components. For example, a template like @samp{foo
  32924. @var{bar} @var{baz}} describes a packet beginning with the three ASCII
  32925. bytes @samp{foo}, followed by a @var{bar}, followed directly by a
  32926. @var{baz}. @value{GDBN} does not transmit a space character between the
  32927. @samp{foo} and the @var{bar}, or between the @var{bar} and the
  32928. @var{baz}.
  32929. @cindex @var{thread-id}, in remote protocol
  32930. @anchor{thread-id syntax}
  32931. Several packets and replies include a @var{thread-id} field to identify
  32932. a thread. Normally these are positive numbers with a target-specific
  32933. interpretation, formatted as big-endian hex strings. A @var{thread-id}
  32934. can also be a literal @samp{-1} to indicate all threads, or @samp{0} to
  32935. pick any thread.
  32936. In addition, the remote protocol supports a multiprocess feature in
  32937. which the @var{thread-id} syntax is extended to optionally include both
  32938. process and thread ID fields, as @samp{p@var{pid}.@var{tid}}.
  32939. The @var{pid} (process) and @var{tid} (thread) components each have the
  32940. format described above: a positive number with target-specific
  32941. interpretation formatted as a big-endian hex string, literal @samp{-1}
  32942. to indicate all processes or threads (respectively), or @samp{0} to
  32943. indicate an arbitrary process or thread. Specifying just a process, as
  32944. @samp{p@var{pid}}, is equivalent to @samp{p@var{pid}.-1}. It is an
  32945. error to specify all processes but a specific thread, such as
  32946. @samp{p-1.@var{tid}}. Note that the @samp{p} prefix is @emph{not} used
  32947. for those packets and replies explicitly documented to include a process
  32948. ID, rather than a @var{thread-id}.
  32949. The multiprocess @var{thread-id} syntax extensions are only used if both
  32950. @value{GDBN} and the stub report support for the @samp{multiprocess}
  32951. feature using @samp{qSupported}. @xref{multiprocess extensions}, for
  32952. more information.
  32953. Note that all packet forms beginning with an upper- or lower-case
  32954. letter, other than those described here, are reserved for future use.
  32955. Here are the packet descriptions.
  32956. @table @samp
  32957. @item !
  32958. @cindex @samp{!} packet
  32959. @anchor{extended mode}
  32960. Enable extended mode. In extended mode, the remote server is made
  32961. persistent. The @samp{R} packet is used to restart the program being
  32962. debugged.
  32963. Reply:
  32964. @table @samp
  32965. @item OK
  32966. The remote target both supports and has enabled extended mode.
  32967. @end table
  32968. @item ?
  32969. @cindex @samp{?} packet
  32970. @anchor{? packet}
  32971. This is sent when connection is first established to query the reason
  32972. the target halted. The reply is the same as for step and continue.
  32973. This packet has a special interpretation when the target is in
  32974. non-stop mode; see @ref{Remote Non-Stop}.
  32975. Reply:
  32976. @xref{Stop Reply Packets}, for the reply specifications.
  32977. @item A @var{arglen},@var{argnum},@var{arg},@dots{}
  32978. @cindex @samp{A} packet
  32979. Initialized @code{argv[]} array passed into program. @var{arglen}
  32980. specifies the number of bytes in the hex encoded byte stream
  32981. @var{arg}. See @code{gdbserver} for more details.
  32982. Reply:
  32983. @table @samp
  32984. @item OK
  32985. The arguments were set.
  32986. @item E @var{NN}
  32987. An error occurred.
  32988. @end table
  32989. @item b @var{baud}
  32990. @cindex @samp{b} packet
  32991. (Don't use this packet; its behavior is not well-defined.)
  32992. Change the serial line speed to @var{baud}.
  32993. JTC: @emph{When does the transport layer state change? When it's
  32994. received, or after the ACK is transmitted. In either case, there are
  32995. problems if the command or the acknowledgment packet is dropped.}
  32996. Stan: @emph{If people really wanted to add something like this, and get
  32997. it working for the first time, they ought to modify ser-unix.c to send
  32998. some kind of out-of-band message to a specially-setup stub and have the
  32999. switch happen "in between" packets, so that from remote protocol's point
  33000. of view, nothing actually happened.}
  33001. @item B @var{addr},@var{mode}
  33002. @cindex @samp{B} packet
  33003. Set (@var{mode} is @samp{S}) or clear (@var{mode} is @samp{C}) a
  33004. breakpoint at @var{addr}.
  33005. Don't use this packet. Use the @samp{Z} and @samp{z} packets instead
  33006. (@pxref{insert breakpoint or watchpoint packet}).
  33007. @cindex @samp{bc} packet
  33008. @anchor{bc}
  33009. @item bc
  33010. Backward continue. Execute the target system in reverse. No parameter.
  33011. @xref{Reverse Execution}, for more information.
  33012. Reply:
  33013. @xref{Stop Reply Packets}, for the reply specifications.
  33014. @cindex @samp{bs} packet
  33015. @anchor{bs}
  33016. @item bs
  33017. Backward single step. Execute one instruction in reverse. No parameter.
  33018. @xref{Reverse Execution}, for more information.
  33019. Reply:
  33020. @xref{Stop Reply Packets}, for the reply specifications.
  33021. @item c @r{[}@var{addr}@r{]}
  33022. @cindex @samp{c} packet
  33023. Continue at @var{addr}, which is the address to resume. If @var{addr}
  33024. is omitted, resume at current address.
  33025. This packet is deprecated for multi-threading support. @xref{vCont
  33026. packet}.
  33027. Reply:
  33028. @xref{Stop Reply Packets}, for the reply specifications.
  33029. @item C @var{sig}@r{[};@var{addr}@r{]}
  33030. @cindex @samp{C} packet
  33031. Continue with signal @var{sig} (hex signal number). If
  33032. @samp{;@var{addr}} is omitted, resume at same address.
  33033. This packet is deprecated for multi-threading support. @xref{vCont
  33034. packet}.
  33035. Reply:
  33036. @xref{Stop Reply Packets}, for the reply specifications.
  33037. @item d
  33038. @cindex @samp{d} packet
  33039. Toggle debug flag.
  33040. Don't use this packet; instead, define a general set packet
  33041. (@pxref{General Query Packets}).
  33042. @item D
  33043. @itemx D;@var{pid}
  33044. @cindex @samp{D} packet
  33045. The first form of the packet is used to detach @value{GDBN} from the
  33046. remote system. It is sent to the remote target
  33047. before @value{GDBN} disconnects via the @code{detach} command.
  33048. The second form, including a process ID, is used when multiprocess
  33049. protocol extensions are enabled (@pxref{multiprocess extensions}), to
  33050. detach only a specific process. The @var{pid} is specified as a
  33051. big-endian hex string.
  33052. Reply:
  33053. @table @samp
  33054. @item OK
  33055. for success
  33056. @item E @var{NN}
  33057. for an error
  33058. @end table
  33059. @item F @var{RC},@var{EE},@var{CF};@var{XX}
  33060. @cindex @samp{F} packet
  33061. A reply from @value{GDBN} to an @samp{F} packet sent by the target.
  33062. This is part of the File-I/O protocol extension. @xref{File-I/O
  33063. Remote Protocol Extension}, for the specification.
  33064. @item g
  33065. @anchor{read registers packet}
  33066. @cindex @samp{g} packet
  33067. Read general registers.
  33068. Reply:
  33069. @table @samp
  33070. @item @var{XX@dots{}}
  33071. Each byte of register data is described by two hex digits. The bytes
  33072. with the register are transmitted in target byte order. The size of
  33073. each register and their position within the @samp{g} packet are
  33074. determined by the @value{GDBN} internal gdbarch functions
  33075. @code{DEPRECATED_REGISTER_RAW_SIZE} and @code{gdbarch_register_name}.
  33076. When reading registers from a trace frame (@pxref{Analyze Collected
  33077. Data,,Using the Collected Data}), the stub may also return a string of
  33078. literal @samp{x}'s in place of the register data digits, to indicate
  33079. that the corresponding register has not been collected, thus its value
  33080. is unavailable. For example, for an architecture with 4 registers of
  33081. 4 bytes each, the following reply indicates to @value{GDBN} that
  33082. registers 0 and 2 have not been collected, while registers 1 and 3
  33083. have been collected, and both have zero value:
  33084. @smallexample
  33085. -> @code{g}
  33086. <- @code{xxxxxxxx00000000xxxxxxxx00000000}
  33087. @end smallexample
  33088. @item E @var{NN}
  33089. for an error.
  33090. @end table
  33091. @item G @var{XX@dots{}}
  33092. @cindex @samp{G} packet
  33093. Write general registers. @xref{read registers packet}, for a
  33094. description of the @var{XX@dots{}} data.
  33095. Reply:
  33096. @table @samp
  33097. @item OK
  33098. for success
  33099. @item E @var{NN}
  33100. for an error
  33101. @end table
  33102. @item H @var{op} @var{thread-id}
  33103. @cindex @samp{H} packet
  33104. Set thread for subsequent operations (@samp{m}, @samp{M}, @samp{g},
  33105. @samp{G}, et.al.). Depending on the operation to be performed, @var{op}
  33106. should be @samp{c} for step and continue operations (note that this
  33107. is deprecated, supporting the @samp{vCont} command is a better
  33108. option), and @samp{g} for other operations. The thread designator
  33109. @var{thread-id} has the format and interpretation described in
  33110. @ref{thread-id syntax}.
  33111. Reply:
  33112. @table @samp
  33113. @item OK
  33114. for success
  33115. @item E @var{NN}
  33116. for an error
  33117. @end table
  33118. @c FIXME: JTC:
  33119. @c 'H': How restrictive (or permissive) is the thread model. If a
  33120. @c thread is selected and stopped, are other threads allowed
  33121. @c to continue to execute? As I mentioned above, I think the
  33122. @c semantics of each command when a thread is selected must be
  33123. @c described. For example:
  33124. @c
  33125. @c 'g': If the stub supports threads and a specific thread is
  33126. @c selected, returns the register block from that thread;
  33127. @c otherwise returns current registers.
  33128. @c
  33129. @c 'G' If the stub supports threads and a specific thread is
  33130. @c selected, sets the registers of the register block of
  33131. @c that thread; otherwise sets current registers.
  33132. @item i @r{[}@var{addr}@r{[},@var{nnn}@r{]]}
  33133. @anchor{cycle step packet}
  33134. @cindex @samp{i} packet
  33135. Step the remote target by a single clock cycle. If @samp{,@var{nnn}} is
  33136. present, cycle step @var{nnn} cycles. If @var{addr} is present, cycle
  33137. step starting at that address.
  33138. @item I
  33139. @cindex @samp{I} packet
  33140. Signal, then cycle step. @xref{step with signal packet}. @xref{cycle
  33141. step packet}.
  33142. @item k
  33143. @cindex @samp{k} packet
  33144. Kill request.
  33145. The exact effect of this packet is not specified.
  33146. For a bare-metal target, it may power cycle or reset the target
  33147. system. For that reason, the @samp{k} packet has no reply.
  33148. For a single-process target, it may kill that process if possible.
  33149. A multiple-process target may choose to kill just one process, or all
  33150. that are under @value{GDBN}'s control. For more precise control, use
  33151. the vKill packet (@pxref{vKill packet}).
  33152. If the target system immediately closes the connection in response to
  33153. @samp{k}, @value{GDBN} does not consider the lack of packet
  33154. acknowledgment to be an error, and assumes the kill was successful.
  33155. If connected using @kbd{target extended-remote}, and the target does
  33156. not close the connection in response to a kill request, @value{GDBN}
  33157. probes the target state as if a new connection was opened
  33158. (@pxref{? packet}).
  33159. @item m @var{addr},@var{length}
  33160. @cindex @samp{m} packet
  33161. Read @var{length} addressable memory units starting at address @var{addr}
  33162. (@pxref{addressable memory unit}). Note that @var{addr} may not be aligned to
  33163. any particular boundary.
  33164. The stub need not use any particular size or alignment when gathering
  33165. data from memory for the response; even if @var{addr} is word-aligned
  33166. and @var{length} is a multiple of the word size, the stub is free to
  33167. use byte accesses, or not. For this reason, this packet may not be
  33168. suitable for accessing memory-mapped I/O devices.
  33169. @cindex alignment of remote memory accesses
  33170. @cindex size of remote memory accesses
  33171. @cindex memory, alignment and size of remote accesses
  33172. Reply:
  33173. @table @samp
  33174. @item @var{XX@dots{}}
  33175. Memory contents; each byte is transmitted as a two-digit hexadecimal number.
  33176. The reply may contain fewer addressable memory units than requested if the
  33177. server was able to read only part of the region of memory.
  33178. @item E @var{NN}
  33179. @var{NN} is errno
  33180. @end table
  33181. @item M @var{addr},@var{length}:@var{XX@dots{}}
  33182. @cindex @samp{M} packet
  33183. Write @var{length} addressable memory units starting at address @var{addr}
  33184. (@pxref{addressable memory unit}). The data is given by @var{XX@dots{}}; each
  33185. byte is transmitted as a two-digit hexadecimal number.
  33186. Reply:
  33187. @table @samp
  33188. @item OK
  33189. for success
  33190. @item E @var{NN}
  33191. for an error (this includes the case where only part of the data was
  33192. written).
  33193. @end table
  33194. @item p @var{n}
  33195. @cindex @samp{p} packet
  33196. Read the value of register @var{n}; @var{n} is in hex.
  33197. @xref{read registers packet}, for a description of how the returned
  33198. register value is encoded.
  33199. Reply:
  33200. @table @samp
  33201. @item @var{XX@dots{}}
  33202. the register's value
  33203. @item E @var{NN}
  33204. for an error
  33205. @item @w{}
  33206. Indicating an unrecognized @var{query}.
  33207. @end table
  33208. @item P @var{n@dots{}}=@var{r@dots{}}
  33209. @anchor{write register packet}
  33210. @cindex @samp{P} packet
  33211. Write register @var{n@dots{}} with value @var{r@dots{}}. The register
  33212. number @var{n} is in hexadecimal, and @var{r@dots{}} contains two hex
  33213. digits for each byte in the register (target byte order).
  33214. Reply:
  33215. @table @samp
  33216. @item OK
  33217. for success
  33218. @item E @var{NN}
  33219. for an error
  33220. @end table
  33221. @item q @var{name} @var{params}@dots{}
  33222. @itemx Q @var{name} @var{params}@dots{}
  33223. @cindex @samp{q} packet
  33224. @cindex @samp{Q} packet
  33225. General query (@samp{q}) and set (@samp{Q}). These packets are
  33226. described fully in @ref{General Query Packets}.
  33227. @item r
  33228. @cindex @samp{r} packet
  33229. Reset the entire system.
  33230. Don't use this packet; use the @samp{R} packet instead.
  33231. @item R @var{XX}
  33232. @cindex @samp{R} packet
  33233. Restart the program being debugged. The @var{XX}, while needed, is ignored.
  33234. This packet is only available in extended mode (@pxref{extended mode}).
  33235. The @samp{R} packet has no reply.
  33236. @item s @r{[}@var{addr}@r{]}
  33237. @cindex @samp{s} packet
  33238. Single step, resuming at @var{addr}. If
  33239. @var{addr} is omitted, resume at same address.
  33240. This packet is deprecated for multi-threading support. @xref{vCont
  33241. packet}.
  33242. Reply:
  33243. @xref{Stop Reply Packets}, for the reply specifications.
  33244. @item S @var{sig}@r{[};@var{addr}@r{]}
  33245. @anchor{step with signal packet}
  33246. @cindex @samp{S} packet
  33247. Step with signal. This is analogous to the @samp{C} packet, but
  33248. requests a single-step, rather than a normal resumption of execution.
  33249. This packet is deprecated for multi-threading support. @xref{vCont
  33250. packet}.
  33251. Reply:
  33252. @xref{Stop Reply Packets}, for the reply specifications.
  33253. @item t @var{addr}:@var{PP},@var{MM}
  33254. @cindex @samp{t} packet
  33255. Search backwards starting at address @var{addr} for a match with pattern
  33256. @var{PP} and mask @var{MM}, both of which are are 4 byte long.
  33257. There must be at least 3 digits in @var{addr}.
  33258. @item T @var{thread-id}
  33259. @cindex @samp{T} packet
  33260. Find out if the thread @var{thread-id} is alive. @xref{thread-id syntax}.
  33261. Reply:
  33262. @table @samp
  33263. @item OK
  33264. thread is still alive
  33265. @item E @var{NN}
  33266. thread is dead
  33267. @end table
  33268. @item v
  33269. Packets starting with @samp{v} are identified by a multi-letter name,
  33270. up to the first @samp{;} or @samp{?} (or the end of the packet).
  33271. @item vAttach;@var{pid}
  33272. @cindex @samp{vAttach} packet
  33273. Attach to a new process with the specified process ID @var{pid}.
  33274. The process ID is a
  33275. hexadecimal integer identifying the process. In all-stop mode, all
  33276. threads in the attached process are stopped; in non-stop mode, it may be
  33277. attached without being stopped if that is supported by the target.
  33278. @c In non-stop mode, on a successful vAttach, the stub should set the
  33279. @c current thread to a thread of the newly-attached process. After
  33280. @c attaching, GDB queries for the attached process's thread ID with qC.
  33281. @c Also note that, from a user perspective, whether or not the
  33282. @c target is stopped on attach in non-stop mode depends on whether you
  33283. @c use the foreground or background version of the attach command, not
  33284. @c on what vAttach does; GDB does the right thing with respect to either
  33285. @c stopping or restarting threads.
  33286. This packet is only available in extended mode (@pxref{extended mode}).
  33287. Reply:
  33288. @table @samp
  33289. @item E @var{nn}
  33290. for an error
  33291. @item @r{Any stop packet}
  33292. for success in all-stop mode (@pxref{Stop Reply Packets})
  33293. @item OK
  33294. for success in non-stop mode (@pxref{Remote Non-Stop})
  33295. @end table
  33296. @item vCont@r{[};@var{action}@r{[}:@var{thread-id}@r{]]}@dots{}
  33297. @cindex @samp{vCont} packet
  33298. @anchor{vCont packet}
  33299. Resume the inferior, specifying different actions for each thread.
  33300. For each inferior thread, the leftmost action with a matching
  33301. @var{thread-id} is applied. Threads that don't match any action
  33302. remain in their current state. Thread IDs are specified using the
  33303. syntax described in @ref{thread-id syntax}. If multiprocess
  33304. extensions (@pxref{multiprocess extensions}) are supported, actions
  33305. can be specified to match all threads in a process by using the
  33306. @samp{p@var{pid}.-1} form of the @var{thread-id}. An action with no
  33307. @var{thread-id} matches all threads. Specifying no actions is an
  33308. error.
  33309. Currently supported actions are:
  33310. @table @samp
  33311. @item c
  33312. Continue.
  33313. @item C @var{sig}
  33314. Continue with signal @var{sig}. The signal @var{sig} should be two hex digits.
  33315. @item s
  33316. Step.
  33317. @item S @var{sig}
  33318. Step with signal @var{sig}. The signal @var{sig} should be two hex digits.
  33319. @item t
  33320. Stop.
  33321. @item r @var{start},@var{end}
  33322. Step once, and then keep stepping as long as the thread stops at
  33323. addresses between @var{start} (inclusive) and @var{end} (exclusive).
  33324. The remote stub reports a stop reply when either the thread goes out
  33325. of the range or is stopped due to an unrelated reason, such as hitting
  33326. a breakpoint. @xref{range stepping}.
  33327. If the range is empty (@var{start} == @var{end}), then the action
  33328. becomes equivalent to the @samp{s} action. In other words,
  33329. single-step once, and report the stop (even if the stepped instruction
  33330. jumps to @var{start}).
  33331. (A stop reply may be sent at any point even if the PC is still within
  33332. the stepping range; for example, it is valid to implement this packet
  33333. in a degenerate way as a single instruction step operation.)
  33334. @end table
  33335. The optional argument @var{addr} normally associated with the
  33336. @samp{c}, @samp{C}, @samp{s}, and @samp{S} packets is
  33337. not supported in @samp{vCont}.
  33338. The @samp{t} action is only relevant in non-stop mode
  33339. (@pxref{Remote Non-Stop}) and may be ignored by the stub otherwise.
  33340. A stop reply should be generated for any affected thread not already stopped.
  33341. When a thread is stopped by means of a @samp{t} action,
  33342. the corresponding stop reply should indicate that the thread has stopped with
  33343. signal @samp{0}, regardless of whether the target uses some other signal
  33344. as an implementation detail.
  33345. The server must ignore @samp{c}, @samp{C}, @samp{s}, @samp{S}, and
  33346. @samp{r} actions for threads that are already running. Conversely,
  33347. the server must ignore @samp{t} actions for threads that are already
  33348. stopped.
  33349. @emph{Note:} In non-stop mode, a thread is considered running until
  33350. @value{GDBN} acknowledges an asynchronous stop notification for it with
  33351. the @samp{vStopped} packet (@pxref{Remote Non-Stop}).
  33352. The stub must support @samp{vCont} if it reports support for
  33353. multiprocess extensions (@pxref{multiprocess extensions}).
  33354. Reply:
  33355. @xref{Stop Reply Packets}, for the reply specifications.
  33356. @item vCont?
  33357. @cindex @samp{vCont?} packet
  33358. Request a list of actions supported by the @samp{vCont} packet.
  33359. Reply:
  33360. @table @samp
  33361. @item vCont@r{[};@var{action}@dots{}@r{]}
  33362. The @samp{vCont} packet is supported. Each @var{action} is a supported
  33363. command in the @samp{vCont} packet.
  33364. @item @w{}
  33365. The @samp{vCont} packet is not supported.
  33366. @end table
  33367. @anchor{vCtrlC packet}
  33368. @item vCtrlC
  33369. @cindex @samp{vCtrlC} packet
  33370. Interrupt remote target as if a control-C was pressed on the remote
  33371. terminal. This is the equivalent to reacting to the @code{^C}
  33372. (@samp{\003}, the control-C character) character in all-stop mode
  33373. while the target is running, except this works in non-stop mode.
  33374. @xref{interrupting remote targets}, for more info on the all-stop
  33375. variant.
  33376. Reply:
  33377. @table @samp
  33378. @item E @var{nn}
  33379. for an error
  33380. @item OK
  33381. for success
  33382. @end table
  33383. @item vFile:@var{operation}:@var{parameter}@dots{}
  33384. @cindex @samp{vFile} packet
  33385. Perform a file operation on the target system. For details,
  33386. see @ref{Host I/O Packets}.
  33387. @item vFlashErase:@var{addr},@var{length}
  33388. @cindex @samp{vFlashErase} packet
  33389. Direct the stub to erase @var{length} bytes of flash starting at
  33390. @var{addr}. The region may enclose any number of flash blocks, but
  33391. its start and end must fall on block boundaries, as indicated by the
  33392. flash block size appearing in the memory map (@pxref{Memory Map
  33393. Format}). @value{GDBN} groups flash memory programming operations
  33394. together, and sends a @samp{vFlashDone} request after each group; the
  33395. stub is allowed to delay erase operation until the @samp{vFlashDone}
  33396. packet is received.
  33397. Reply:
  33398. @table @samp
  33399. @item OK
  33400. for success
  33401. @item E @var{NN}
  33402. for an error
  33403. @end table
  33404. @item vFlashWrite:@var{addr}:@var{XX@dots{}}
  33405. @cindex @samp{vFlashWrite} packet
  33406. Direct the stub to write data to flash address @var{addr}. The data
  33407. is passed in binary form using the same encoding as for the @samp{X}
  33408. packet (@pxref{Binary Data}). The memory ranges specified by
  33409. @samp{vFlashWrite} packets preceding a @samp{vFlashDone} packet must
  33410. not overlap, and must appear in order of increasing addresses
  33411. (although @samp{vFlashErase} packets for higher addresses may already
  33412. have been received; the ordering is guaranteed only between
  33413. @samp{vFlashWrite} packets). If a packet writes to an address that was
  33414. neither erased by a preceding @samp{vFlashErase} packet nor by some other
  33415. target-specific method, the results are unpredictable.
  33416. Reply:
  33417. @table @samp
  33418. @item OK
  33419. for success
  33420. @item E.memtype
  33421. for vFlashWrite addressing non-flash memory
  33422. @item E @var{NN}
  33423. for an error
  33424. @end table
  33425. @item vFlashDone
  33426. @cindex @samp{vFlashDone} packet
  33427. Indicate to the stub that flash programming operation is finished.
  33428. The stub is permitted to delay or batch the effects of a group of
  33429. @samp{vFlashErase} and @samp{vFlashWrite} packets until a
  33430. @samp{vFlashDone} packet is received. The contents of the affected
  33431. regions of flash memory are unpredictable until the @samp{vFlashDone}
  33432. request is completed.
  33433. @item vKill;@var{pid}
  33434. @cindex @samp{vKill} packet
  33435. @anchor{vKill packet}
  33436. Kill the process with the specified process ID @var{pid}, which is a
  33437. hexadecimal integer identifying the process. This packet is used in
  33438. preference to @samp{k} when multiprocess protocol extensions are
  33439. supported; see @ref{multiprocess extensions}.
  33440. Reply:
  33441. @table @samp
  33442. @item E @var{nn}
  33443. for an error
  33444. @item OK
  33445. for success
  33446. @end table
  33447. @item vMustReplyEmpty
  33448. @cindex @samp{vMustReplyEmpty} packet
  33449. The correct reply to an unknown @samp{v} packet is to return the empty
  33450. string, however, some older versions of @command{gdbserver} would
  33451. incorrectly return @samp{OK} for unknown @samp{v} packets.
  33452. The @samp{vMustReplyEmpty} is used as a feature test to check how
  33453. @command{gdbserver} handles unknown packets, it is important that this
  33454. packet be handled in the same way as other unknown @samp{v} packets.
  33455. If this packet is handled differently to other unknown @samp{v}
  33456. packets then it is possible that @value{GDBN} may run into problems in
  33457. other areas, specifically around use of @samp{vFile:setfs:}.
  33458. @item vRun;@var{filename}@r{[};@var{argument}@r{]}@dots{}
  33459. @cindex @samp{vRun} packet
  33460. Run the program @var{filename}, passing it each @var{argument} on its
  33461. command line. The file and arguments are hex-encoded strings. If
  33462. @var{filename} is an empty string, the stub may use a default program
  33463. (e.g.@: the last program run). The program is created in the stopped
  33464. state.
  33465. @c FIXME: What about non-stop mode?
  33466. This packet is only available in extended mode (@pxref{extended mode}).
  33467. Reply:
  33468. @table @samp
  33469. @item E @var{nn}
  33470. for an error
  33471. @item @r{Any stop packet}
  33472. for success (@pxref{Stop Reply Packets})
  33473. @end table
  33474. @item vStopped
  33475. @cindex @samp{vStopped} packet
  33476. @xref{Notification Packets}.
  33477. @item X @var{addr},@var{length}:@var{XX@dots{}}
  33478. @anchor{X packet}
  33479. @cindex @samp{X} packet
  33480. Write data to memory, where the data is transmitted in binary.
  33481. Memory is specified by its address @var{addr} and number of addressable memory
  33482. units @var{length} (@pxref{addressable memory unit});
  33483. @samp{@var{XX}@dots{}} is binary data (@pxref{Binary Data}).
  33484. Reply:
  33485. @table @samp
  33486. @item OK
  33487. for success
  33488. @item E @var{NN}
  33489. for an error
  33490. @end table
  33491. @item z @var{type},@var{addr},@var{kind}
  33492. @itemx Z @var{type},@var{addr},@var{kind}
  33493. @anchor{insert breakpoint or watchpoint packet}
  33494. @cindex @samp{z} packet
  33495. @cindex @samp{Z} packets
  33496. Insert (@samp{Z}) or remove (@samp{z}) a @var{type} breakpoint or
  33497. watchpoint starting at address @var{address} of kind @var{kind}.
  33498. Each breakpoint and watchpoint packet @var{type} is documented
  33499. separately.
  33500. @emph{Implementation notes: A remote target shall return an empty string
  33501. for an unrecognized breakpoint or watchpoint packet @var{type}. A
  33502. remote target shall support either both or neither of a given
  33503. @samp{Z@var{type}@dots{}} and @samp{z@var{type}@dots{}} packet pair. To
  33504. avoid potential problems with duplicate packets, the operations should
  33505. be implemented in an idempotent way.}
  33506. @item z0,@var{addr},@var{kind}
  33507. @itemx Z0,@var{addr},@var{kind}@r{[};@var{cond_list}@dots{}@r{]}@r{[};cmds:@var{persist},@var{cmd_list}@dots{}@r{]}
  33508. @cindex @samp{z0} packet
  33509. @cindex @samp{Z0} packet
  33510. Insert (@samp{Z0}) or remove (@samp{z0}) a software breakpoint at address
  33511. @var{addr} of type @var{kind}.
  33512. A software breakpoint is implemented by replacing the instruction at
  33513. @var{addr} with a software breakpoint or trap instruction. The
  33514. @var{kind} is target-specific and typically indicates the size of the
  33515. breakpoint in bytes that should be inserted. E.g., the @sc{arm} and
  33516. @sc{mips} can insert either a 2 or 4 byte breakpoint. Some
  33517. architectures have additional meanings for @var{kind}
  33518. (@pxref{Architecture-Specific Protocol Details}); if no
  33519. architecture-specific value is being used, it should be @samp{0}.
  33520. @var{kind} is hex-encoded. @var{cond_list} is an optional list of
  33521. conditional expressions in bytecode form that should be evaluated on
  33522. the target's side. These are the conditions that should be taken into
  33523. consideration when deciding if the breakpoint trigger should be
  33524. reported back to @value{GDBN}.
  33525. See also the @samp{swbreak} stop reason (@pxref{swbreak stop reason})
  33526. for how to best report a software breakpoint event to @value{GDBN}.
  33527. The @var{cond_list} parameter is comprised of a series of expressions,
  33528. concatenated without separators. Each expression has the following form:
  33529. @table @samp
  33530. @item X @var{len},@var{expr}
  33531. @var{len} is the length of the bytecode expression and @var{expr} is the
  33532. actual conditional expression in bytecode form.
  33533. @end table
  33534. The optional @var{cmd_list} parameter introduces commands that may be
  33535. run on the target, rather than being reported back to @value{GDBN}.
  33536. The parameter starts with a numeric flag @var{persist}; if the flag is
  33537. nonzero, then the breakpoint may remain active and the commands
  33538. continue to be run even when @value{GDBN} disconnects from the target.
  33539. Following this flag is a series of expressions concatenated with no
  33540. separators. Each expression has the following form:
  33541. @table @samp
  33542. @item X @var{len},@var{expr}
  33543. @var{len} is the length of the bytecode expression and @var{expr} is the
  33544. actual commands expression in bytecode form.
  33545. @end table
  33546. @emph{Implementation note: It is possible for a target to copy or move
  33547. code that contains software breakpoints (e.g., when implementing
  33548. overlays). The behavior of this packet, in the presence of such a
  33549. target, is not defined.}
  33550. Reply:
  33551. @table @samp
  33552. @item OK
  33553. success
  33554. @item @w{}
  33555. not supported
  33556. @item E @var{NN}
  33557. for an error
  33558. @end table
  33559. @item z1,@var{addr},@var{kind}
  33560. @itemx Z1,@var{addr},@var{kind}@r{[};@var{cond_list}@dots{}@r{]}@r{[};cmds:@var{persist},@var{cmd_list}@dots{}@r{]}
  33561. @cindex @samp{z1} packet
  33562. @cindex @samp{Z1} packet
  33563. Insert (@samp{Z1}) or remove (@samp{z1}) a hardware breakpoint at
  33564. address @var{addr}.
  33565. A hardware breakpoint is implemented using a mechanism that is not
  33566. dependent on being able to modify the target's memory. The
  33567. @var{kind}, @var{cond_list}, and @var{cmd_list} arguments have the
  33568. same meaning as in @samp{Z0} packets.
  33569. @emph{Implementation note: A hardware breakpoint is not affected by code
  33570. movement.}
  33571. Reply:
  33572. @table @samp
  33573. @item OK
  33574. success
  33575. @item @w{}
  33576. not supported
  33577. @item E @var{NN}
  33578. for an error
  33579. @end table
  33580. @item z2,@var{addr},@var{kind}
  33581. @itemx Z2,@var{addr},@var{kind}
  33582. @cindex @samp{z2} packet
  33583. @cindex @samp{Z2} packet
  33584. Insert (@samp{Z2}) or remove (@samp{z2}) a write watchpoint at @var{addr}.
  33585. The number of bytes to watch is specified by @var{kind}.
  33586. Reply:
  33587. @table @samp
  33588. @item OK
  33589. success
  33590. @item @w{}
  33591. not supported
  33592. @item E @var{NN}
  33593. for an error
  33594. @end table
  33595. @item z3,@var{addr},@var{kind}
  33596. @itemx Z3,@var{addr},@var{kind}
  33597. @cindex @samp{z3} packet
  33598. @cindex @samp{Z3} packet
  33599. Insert (@samp{Z3}) or remove (@samp{z3}) a read watchpoint at @var{addr}.
  33600. The number of bytes to watch is specified by @var{kind}.
  33601. Reply:
  33602. @table @samp
  33603. @item OK
  33604. success
  33605. @item @w{}
  33606. not supported
  33607. @item E @var{NN}
  33608. for an error
  33609. @end table
  33610. @item z4,@var{addr},@var{kind}
  33611. @itemx Z4,@var{addr},@var{kind}
  33612. @cindex @samp{z4} packet
  33613. @cindex @samp{Z4} packet
  33614. Insert (@samp{Z4}) or remove (@samp{z4}) an access watchpoint at @var{addr}.
  33615. The number of bytes to watch is specified by @var{kind}.
  33616. Reply:
  33617. @table @samp
  33618. @item OK
  33619. success
  33620. @item @w{}
  33621. not supported
  33622. @item E @var{NN}
  33623. for an error
  33624. @end table
  33625. @end table
  33626. @node Stop Reply Packets
  33627. @section Stop Reply Packets
  33628. @cindex stop reply packets
  33629. The @samp{C}, @samp{c}, @samp{S}, @samp{s}, @samp{vCont},
  33630. @samp{vAttach}, @samp{vRun}, @samp{vStopped}, and @samp{?} packets can
  33631. receive any of the below as a reply. Except for @samp{?}
  33632. and @samp{vStopped}, that reply is only returned
  33633. when the target halts. In the below the exact meaning of @dfn{signal
  33634. number} is defined by the header @file{include/gdb/signals.h} in the
  33635. @value{GDBN} source code.
  33636. In non-stop mode, the server will simply reply @samp{OK} to commands
  33637. such as @samp{vCont}; any stop will be the subject of a future
  33638. notification. @xref{Remote Non-Stop}.
  33639. As in the description of request packets, we include spaces in the
  33640. reply templates for clarity; these are not part of the reply packet's
  33641. syntax. No @value{GDBN} stop reply packet uses spaces to separate its
  33642. components.
  33643. @table @samp
  33644. @item S @var{AA}
  33645. The program received signal number @var{AA} (a two-digit hexadecimal
  33646. number). This is equivalent to a @samp{T} response with no
  33647. @var{n}:@var{r} pairs.
  33648. @item T @var{AA} @var{n1}:@var{r1};@var{n2}:@var{r2};@dots{}
  33649. @cindex @samp{T} packet reply
  33650. The program received signal number @var{AA} (a two-digit hexadecimal
  33651. number). This is equivalent to an @samp{S} response, except that the
  33652. @samp{@var{n}:@var{r}} pairs can carry values of important registers
  33653. and other information directly in the stop reply packet, reducing
  33654. round-trip latency. Single-step and breakpoint traps are reported
  33655. this way. Each @samp{@var{n}:@var{r}} pair is interpreted as follows:
  33656. @itemize @bullet
  33657. @item
  33658. If @var{n} is a hexadecimal number, it is a register number, and the
  33659. corresponding @var{r} gives that register's value. The data @var{r} is a
  33660. series of bytes in target byte order, with each byte given by a
  33661. two-digit hex number.
  33662. @item
  33663. If @var{n} is @samp{thread}, then @var{r} is the @var{thread-id} of
  33664. the stopped thread, as specified in @ref{thread-id syntax}.
  33665. @item
  33666. If @var{n} is @samp{core}, then @var{r} is the hexadecimal number of
  33667. the core on which the stop event was detected.
  33668. @item
  33669. If @var{n} is a recognized @dfn{stop reason}, it describes a more
  33670. specific event that stopped the target. The currently defined stop
  33671. reasons are listed below. The @var{aa} should be @samp{05}, the trap
  33672. signal. At most one stop reason should be present.
  33673. @item
  33674. Otherwise, @value{GDBN} should ignore this @samp{@var{n}:@var{r}} pair
  33675. and go on to the next; this allows us to extend the protocol in the
  33676. future.
  33677. @end itemize
  33678. The currently defined stop reasons are:
  33679. @table @samp
  33680. @item watch
  33681. @itemx rwatch
  33682. @itemx awatch
  33683. The packet indicates a watchpoint hit, and @var{r} is the data address, in
  33684. hex.
  33685. @item syscall_entry
  33686. @itemx syscall_return
  33687. The packet indicates a syscall entry or return, and @var{r} is the
  33688. syscall number, in hex.
  33689. @cindex shared library events, remote reply
  33690. @item library
  33691. The packet indicates that the loaded libraries have changed.
  33692. @value{GDBN} should use @samp{qXfer:libraries:read} to fetch a new
  33693. list of loaded libraries. The @var{r} part is ignored.
  33694. @cindex replay log events, remote reply
  33695. @item replaylog
  33696. The packet indicates that the target cannot continue replaying
  33697. logged execution events, because it has reached the end (or the
  33698. beginning when executing backward) of the log. The value of @var{r}
  33699. will be either @samp{begin} or @samp{end}. @xref{Reverse Execution},
  33700. for more information.
  33701. @item swbreak
  33702. @anchor{swbreak stop reason}
  33703. The packet indicates a software breakpoint instruction was executed,
  33704. irrespective of whether it was @value{GDBN} that planted the
  33705. breakpoint or the breakpoint is hardcoded in the program. The @var{r}
  33706. part must be left empty.
  33707. On some architectures, such as x86, at the architecture level, when a
  33708. breakpoint instruction executes the program counter points at the
  33709. breakpoint address plus an offset. On such targets, the stub is
  33710. responsible for adjusting the PC to point back at the breakpoint
  33711. address.
  33712. This packet should not be sent by default; older @value{GDBN} versions
  33713. did not support it. @value{GDBN} requests it, by supplying an
  33714. appropriate @samp{qSupported} feature (@pxref{qSupported}). The
  33715. remote stub must also supply the appropriate @samp{qSupported} feature
  33716. indicating support.
  33717. This packet is required for correct non-stop mode operation.
  33718. @item hwbreak
  33719. The packet indicates the target stopped for a hardware breakpoint.
  33720. The @var{r} part must be left empty.
  33721. The same remarks about @samp{qSupported} and non-stop mode above
  33722. apply.
  33723. @cindex fork events, remote reply
  33724. @item fork
  33725. The packet indicates that @code{fork} was called, and @var{r}
  33726. is the thread ID of the new child process. Refer to
  33727. @ref{thread-id syntax} for the format of the @var{thread-id}
  33728. field. This packet is only applicable to targets that support
  33729. fork events.
  33730. This packet should not be sent by default; older @value{GDBN} versions
  33731. did not support it. @value{GDBN} requests it, by supplying an
  33732. appropriate @samp{qSupported} feature (@pxref{qSupported}). The
  33733. remote stub must also supply the appropriate @samp{qSupported} feature
  33734. indicating support.
  33735. @cindex vfork events, remote reply
  33736. @item vfork
  33737. The packet indicates that @code{vfork} was called, and @var{r}
  33738. is the thread ID of the new child process. Refer to
  33739. @ref{thread-id syntax} for the format of the @var{thread-id}
  33740. field. This packet is only applicable to targets that support
  33741. vfork events.
  33742. This packet should not be sent by default; older @value{GDBN} versions
  33743. did not support it. @value{GDBN} requests it, by supplying an
  33744. appropriate @samp{qSupported} feature (@pxref{qSupported}). The
  33745. remote stub must also supply the appropriate @samp{qSupported} feature
  33746. indicating support.
  33747. @cindex vforkdone events, remote reply
  33748. @item vforkdone
  33749. The packet indicates that a child process created by a vfork
  33750. has either called @code{exec} or terminated, so that the
  33751. address spaces of the parent and child process are no longer
  33752. shared. The @var{r} part is ignored. This packet is only
  33753. applicable to targets that support vforkdone events.
  33754. This packet should not be sent by default; older @value{GDBN} versions
  33755. did not support it. @value{GDBN} requests it, by supplying an
  33756. appropriate @samp{qSupported} feature (@pxref{qSupported}). The
  33757. remote stub must also supply the appropriate @samp{qSupported} feature
  33758. indicating support.
  33759. @cindex exec events, remote reply
  33760. @item exec
  33761. The packet indicates that @code{execve} was called, and @var{r}
  33762. is the absolute pathname of the file that was executed, in hex.
  33763. This packet is only applicable to targets that support exec events.
  33764. This packet should not be sent by default; older @value{GDBN} versions
  33765. did not support it. @value{GDBN} requests it, by supplying an
  33766. appropriate @samp{qSupported} feature (@pxref{qSupported}). The
  33767. remote stub must also supply the appropriate @samp{qSupported} feature
  33768. indicating support.
  33769. @cindex thread create event, remote reply
  33770. @anchor{thread create event}
  33771. @item create
  33772. The packet indicates that the thread was just created. The new thread
  33773. is stopped until @value{GDBN} sets it running with a resumption packet
  33774. (@pxref{vCont packet}). This packet should not be sent by default;
  33775. @value{GDBN} requests it with the @ref{QThreadEvents} packet. See
  33776. also the @samp{w} (@pxref{thread exit event}) remote reply below. The
  33777. @var{r} part is ignored.
  33778. @end table
  33779. @item W @var{AA}
  33780. @itemx W @var{AA} ; process:@var{pid}
  33781. The process exited, and @var{AA} is the exit status. This is only
  33782. applicable to certain targets.
  33783. The second form of the response, including the process ID of the
  33784. exited process, can be used only when @value{GDBN} has reported
  33785. support for multiprocess protocol extensions; see @ref{multiprocess
  33786. extensions}. Both @var{AA} and @var{pid} are formatted as big-endian
  33787. hex strings.
  33788. @item X @var{AA}
  33789. @itemx X @var{AA} ; process:@var{pid}
  33790. The process terminated with signal @var{AA}.
  33791. The second form of the response, including the process ID of the
  33792. terminated process, can be used only when @value{GDBN} has reported
  33793. support for multiprocess protocol extensions; see @ref{multiprocess
  33794. extensions}. Both @var{AA} and @var{pid} are formatted as big-endian
  33795. hex strings.
  33796. @anchor{thread exit event}
  33797. @cindex thread exit event, remote reply
  33798. @item w @var{AA} ; @var{tid}
  33799. The thread exited, and @var{AA} is the exit status. This response
  33800. should not be sent by default; @value{GDBN} requests it with the
  33801. @ref{QThreadEvents} packet. See also @ref{thread create event} above.
  33802. @var{AA} is formatted as a big-endian hex string.
  33803. @item N
  33804. There are no resumed threads left in the target. In other words, even
  33805. though the process is alive, the last resumed thread has exited. For
  33806. example, say the target process has two threads: thread 1 and thread
  33807. 2. The client leaves thread 1 stopped, and resumes thread 2, which
  33808. subsequently exits. At this point, even though the process is still
  33809. alive, and thus no @samp{W} stop reply is sent, no thread is actually
  33810. executing either. The @samp{N} stop reply thus informs the client
  33811. that it can stop waiting for stop replies. This packet should not be
  33812. sent by default; older @value{GDBN} versions did not support it.
  33813. @value{GDBN} requests it, by supplying an appropriate
  33814. @samp{qSupported} feature (@pxref{qSupported}). The remote stub must
  33815. also supply the appropriate @samp{qSupported} feature indicating
  33816. support.
  33817. @item O @var{XX}@dots{}
  33818. @samp{@var{XX}@dots{}} is hex encoding of @sc{ascii} data, to be
  33819. written as the program's console output. This can happen at any time
  33820. while the program is running and the debugger should continue to wait
  33821. for @samp{W}, @samp{T}, etc. This reply is not permitted in non-stop mode.
  33822. @item F @var{call-id},@var{parameter}@dots{}
  33823. @var{call-id} is the identifier which says which host system call should
  33824. be called. This is just the name of the function. Translation into the
  33825. correct system call is only applicable as it's defined in @value{GDBN}.
  33826. @xref{File-I/O Remote Protocol Extension}, for a list of implemented
  33827. system calls.
  33828. @samp{@var{parameter}@dots{}} is a list of parameters as defined for
  33829. this very system call.
  33830. The target replies with this packet when it expects @value{GDBN} to
  33831. call a host system call on behalf of the target. @value{GDBN} replies
  33832. with an appropriate @samp{F} packet and keeps up waiting for the next
  33833. reply packet from the target. The latest @samp{C}, @samp{c}, @samp{S}
  33834. or @samp{s} action is expected to be continued. @xref{File-I/O Remote
  33835. Protocol Extension}, for more details.
  33836. @end table
  33837. @node General Query Packets
  33838. @section General Query Packets
  33839. @cindex remote query requests
  33840. Packets starting with @samp{q} are @dfn{general query packets};
  33841. packets starting with @samp{Q} are @dfn{general set packets}. General
  33842. query and set packets are a semi-unified form for retrieving and
  33843. sending information to and from the stub.
  33844. The initial letter of a query or set packet is followed by a name
  33845. indicating what sort of thing the packet applies to. For example,
  33846. @value{GDBN} may use a @samp{qSymbol} packet to exchange symbol
  33847. definitions with the stub. These packet names follow some
  33848. conventions:
  33849. @itemize @bullet
  33850. @item
  33851. The name must not contain commas, colons or semicolons.
  33852. @item
  33853. Most @value{GDBN} query and set packets have a leading upper case
  33854. letter.
  33855. @item
  33856. The names of custom vendor packets should use a company prefix, in
  33857. lower case, followed by a period. For example, packets designed at
  33858. the Acme Corporation might begin with @samp{qacme.foo} (for querying
  33859. foos) or @samp{Qacme.bar} (for setting bars).
  33860. @end itemize
  33861. The name of a query or set packet should be separated from any
  33862. parameters by a @samp{:}; the parameters themselves should be
  33863. separated by @samp{,} or @samp{;}. Stubs must be careful to match the
  33864. full packet name, and check for a separator or the end of the packet,
  33865. in case two packet names share a common prefix. New packets should not begin
  33866. with @samp{qC}, @samp{qP}, or @samp{qL}@footnote{The @samp{qP} and @samp{qL}
  33867. packets predate these conventions, and have arguments without any terminator
  33868. for the packet name; we suspect they are in widespread use in places that
  33869. are difficult to upgrade. The @samp{qC} packet has no arguments, but some
  33870. existing stubs (e.g.@: RedBoot) are known to not check for the end of the
  33871. packet.}.
  33872. Like the descriptions of the other packets, each description here
  33873. has a template showing the packet's overall syntax, followed by an
  33874. explanation of the packet's meaning. We include spaces in some of the
  33875. templates for clarity; these are not part of the packet's syntax. No
  33876. @value{GDBN} packet uses spaces to separate its components.
  33877. Here are the currently defined query and set packets:
  33878. @table @samp
  33879. @item QAgent:1
  33880. @itemx QAgent:0
  33881. Turn on or off the agent as a helper to perform some debugging operations
  33882. delegated from @value{GDBN} (@pxref{Control Agent}).
  33883. @item QAllow:@var{op}:@var{val}@dots{}
  33884. @cindex @samp{QAllow} packet
  33885. Specify which operations @value{GDBN} expects to request of the
  33886. target, as a semicolon-separated list of operation name and value
  33887. pairs. Possible values for @var{op} include @samp{WriteReg},
  33888. @samp{WriteMem}, @samp{InsertBreak}, @samp{InsertTrace},
  33889. @samp{InsertFastTrace}, and @samp{Stop}. @var{val} is either 0,
  33890. indicating that @value{GDBN} will not request the operation, or 1,
  33891. indicating that it may. (The target can then use this to set up its
  33892. own internals optimally, for instance if the debugger never expects to
  33893. insert breakpoints, it may not need to install its own trap handler.)
  33894. @item qC
  33895. @cindex current thread, remote request
  33896. @cindex @samp{qC} packet
  33897. Return the current thread ID.
  33898. Reply:
  33899. @table @samp
  33900. @item QC @var{thread-id}
  33901. Where @var{thread-id} is a thread ID as documented in
  33902. @ref{thread-id syntax}.
  33903. @item @r{(anything else)}
  33904. Any other reply implies the old thread ID.
  33905. @end table
  33906. @item qCRC:@var{addr},@var{length}
  33907. @cindex CRC of memory block, remote request
  33908. @cindex @samp{qCRC} packet
  33909. @anchor{qCRC packet}
  33910. Compute the CRC checksum of a block of memory using CRC-32 defined in
  33911. IEEE 802.3. The CRC is computed byte at a time, taking the most
  33912. significant bit of each byte first. The initial pattern code
  33913. @code{0xffffffff} is used to ensure leading zeros affect the CRC.
  33914. @emph{Note:} This is the same CRC used in validating separate debug
  33915. files (@pxref{Separate Debug Files, , Debugging Information in Separate
  33916. Files}). However the algorithm is slightly different. When validating
  33917. separate debug files, the CRC is computed taking the @emph{least}
  33918. significant bit of each byte first, and the final result is inverted to
  33919. detect trailing zeros.
  33920. Reply:
  33921. @table @samp
  33922. @item E @var{NN}
  33923. An error (such as memory fault)
  33924. @item C @var{crc32}
  33925. The specified memory region's checksum is @var{crc32}.
  33926. @end table
  33927. @item QDisableRandomization:@var{value}
  33928. @cindex disable address space randomization, remote request
  33929. @cindex @samp{QDisableRandomization} packet
  33930. Some target operating systems will randomize the virtual address space
  33931. of the inferior process as a security feature, but provide a feature
  33932. to disable such randomization, e.g.@: to allow for a more deterministic
  33933. debugging experience. On such systems, this packet with a @var{value}
  33934. of 1 directs the target to disable address space randomization for
  33935. processes subsequently started via @samp{vRun} packets, while a packet
  33936. with a @var{value} of 0 tells the target to enable address space
  33937. randomization.
  33938. This packet is only available in extended mode (@pxref{extended mode}).
  33939. Reply:
  33940. @table @samp
  33941. @item OK
  33942. The request succeeded.
  33943. @item E @var{nn}
  33944. An error occurred. The error number @var{nn} is given as hex digits.
  33945. @item @w{}
  33946. An empty reply indicates that @samp{QDisableRandomization} is not supported
  33947. by the stub.
  33948. @end table
  33949. This packet is not probed by default; the remote stub must request it,
  33950. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  33951. This should only be done on targets that actually support disabling
  33952. address space randomization.
  33953. @item QStartupWithShell:@var{value}
  33954. @cindex startup with shell, remote request
  33955. @cindex @samp{QStartupWithShell} packet
  33956. On UNIX-like targets, it is possible to start the inferior using a
  33957. shell program. This is the default behavior on both @value{GDBN} and
  33958. @command{gdbserver} (@pxref{set startup-with-shell}). This packet is
  33959. used to inform @command{gdbserver} whether it should start the
  33960. inferior using a shell or not.
  33961. If @var{value} is @samp{0}, @command{gdbserver} will not use a shell
  33962. to start the inferior. If @var{value} is @samp{1},
  33963. @command{gdbserver} will use a shell to start the inferior. All other
  33964. values are considered an error.
  33965. This packet is only available in extended mode (@pxref{extended
  33966. mode}).
  33967. Reply:
  33968. @table @samp
  33969. @item OK
  33970. The request succeeded.
  33971. @item E @var{nn}
  33972. An error occurred. The error number @var{nn} is given as hex digits.
  33973. @end table
  33974. This packet is not probed by default; the remote stub must request it,
  33975. by supplying an appropriate @samp{qSupported} response
  33976. (@pxref{qSupported}). This should only be done on targets that
  33977. actually support starting the inferior using a shell.
  33978. Use of this packet is controlled by the @code{set startup-with-shell}
  33979. command; @pxref{set startup-with-shell}.
  33980. @item QEnvironmentHexEncoded:@var{hex-value}
  33981. @anchor{QEnvironmentHexEncoded}
  33982. @cindex set environment variable, remote request
  33983. @cindex @samp{QEnvironmentHexEncoded} packet
  33984. On UNIX-like targets, it is possible to set environment variables that
  33985. will be passed to the inferior during the startup process. This
  33986. packet is used to inform @command{gdbserver} of an environment
  33987. variable that has been defined by the user on @value{GDBN} (@pxref{set
  33988. environment}).
  33989. The packet is composed by @var{hex-value}, an hex encoded
  33990. representation of the @var{name=value} format representing an
  33991. environment variable. The name of the environment variable is
  33992. represented by @var{name}, and the value to be assigned to the
  33993. environment variable is represented by @var{value}. If the variable
  33994. has no value (i.e., the value is @code{null}), then @var{value} will
  33995. not be present.
  33996. This packet is only available in extended mode (@pxref{extended
  33997. mode}).
  33998. Reply:
  33999. @table @samp
  34000. @item OK
  34001. The request succeeded.
  34002. @end table
  34003. This packet is not probed by default; the remote stub must request it,
  34004. by supplying an appropriate @samp{qSupported} response
  34005. (@pxref{qSupported}). This should only be done on targets that
  34006. actually support passing environment variables to the starting
  34007. inferior.
  34008. This packet is related to the @code{set environment} command;
  34009. @pxref{set environment}.
  34010. @item QEnvironmentUnset:@var{hex-value}
  34011. @anchor{QEnvironmentUnset}
  34012. @cindex unset environment variable, remote request
  34013. @cindex @samp{QEnvironmentUnset} packet
  34014. On UNIX-like targets, it is possible to unset environment variables
  34015. before starting the inferior in the remote target. This packet is
  34016. used to inform @command{gdbserver} of an environment variable that has
  34017. been unset by the user on @value{GDBN} (@pxref{unset environment}).
  34018. The packet is composed by @var{hex-value}, an hex encoded
  34019. representation of the name of the environment variable to be unset.
  34020. This packet is only available in extended mode (@pxref{extended
  34021. mode}).
  34022. Reply:
  34023. @table @samp
  34024. @item OK
  34025. The request succeeded.
  34026. @end table
  34027. This packet is not probed by default; the remote stub must request it,
  34028. by supplying an appropriate @samp{qSupported} response
  34029. (@pxref{qSupported}). This should only be done on targets that
  34030. actually support passing environment variables to the starting
  34031. inferior.
  34032. This packet is related to the @code{unset environment} command;
  34033. @pxref{unset environment}.
  34034. @item QEnvironmentReset
  34035. @anchor{QEnvironmentReset}
  34036. @cindex reset environment, remote request
  34037. @cindex @samp{QEnvironmentReset} packet
  34038. On UNIX-like targets, this packet is used to reset the state of
  34039. environment variables in the remote target before starting the
  34040. inferior. In this context, reset means unsetting all environment
  34041. variables that were previously set by the user (i.e., were not
  34042. initially present in the environment). It is sent to
  34043. @command{gdbserver} before the @samp{QEnvironmentHexEncoded}
  34044. (@pxref{QEnvironmentHexEncoded}) and the @samp{QEnvironmentUnset}
  34045. (@pxref{QEnvironmentUnset}) packets.
  34046. This packet is only available in extended mode (@pxref{extended
  34047. mode}).
  34048. Reply:
  34049. @table @samp
  34050. @item OK
  34051. The request succeeded.
  34052. @end table
  34053. This packet is not probed by default; the remote stub must request it,
  34054. by supplying an appropriate @samp{qSupported} response
  34055. (@pxref{qSupported}). This should only be done on targets that
  34056. actually support passing environment variables to the starting
  34057. inferior.
  34058. @item QSetWorkingDir:@r{[}@var{directory}@r{]}
  34059. @anchor{QSetWorkingDir packet}
  34060. @cindex set working directory, remote request
  34061. @cindex @samp{QSetWorkingDir} packet
  34062. This packet is used to inform the remote server of the intended
  34063. current working directory for programs that are going to be executed.
  34064. The packet is composed by @var{directory}, an hex encoded
  34065. representation of the directory that the remote inferior will use as
  34066. its current working directory. If @var{directory} is an empty string,
  34067. the remote server should reset the inferior's current working
  34068. directory to its original, empty value.
  34069. This packet is only available in extended mode (@pxref{extended
  34070. mode}).
  34071. Reply:
  34072. @table @samp
  34073. @item OK
  34074. The request succeeded.
  34075. @end table
  34076. @item qfThreadInfo
  34077. @itemx qsThreadInfo
  34078. @cindex list active threads, remote request
  34079. @cindex @samp{qfThreadInfo} packet
  34080. @cindex @samp{qsThreadInfo} packet
  34081. Obtain a list of all active thread IDs from the target (OS). Since there
  34082. may be too many active threads to fit into one reply packet, this query
  34083. works iteratively: it may require more than one query/reply sequence to
  34084. obtain the entire list of threads. The first query of the sequence will
  34085. be the @samp{qfThreadInfo} query; subsequent queries in the
  34086. sequence will be the @samp{qsThreadInfo} query.
  34087. NOTE: This packet replaces the @samp{qL} query (see below).
  34088. Reply:
  34089. @table @samp
  34090. @item m @var{thread-id}
  34091. A single thread ID
  34092. @item m @var{thread-id},@var{thread-id}@dots{}
  34093. a comma-separated list of thread IDs
  34094. @item l
  34095. (lower case letter @samp{L}) denotes end of list.
  34096. @end table
  34097. In response to each query, the target will reply with a list of one or
  34098. more thread IDs, separated by commas.
  34099. @value{GDBN} will respond to each reply with a request for more thread
  34100. ids (using the @samp{qs} form of the query), until the target responds
  34101. with @samp{l} (lower-case ell, for @dfn{last}).
  34102. Refer to @ref{thread-id syntax}, for the format of the @var{thread-id}
  34103. fields.
  34104. @emph{Note: @value{GDBN} will send the @code{qfThreadInfo} query during the
  34105. initial connection with the remote target, and the very first thread ID
  34106. mentioned in the reply will be stopped by @value{GDBN} in a subsequent
  34107. message. Therefore, the stub should ensure that the first thread ID in
  34108. the @code{qfThreadInfo} reply is suitable for being stopped by @value{GDBN}.}
  34109. @item qGetTLSAddr:@var{thread-id},@var{offset},@var{lm}
  34110. @cindex get thread-local storage address, remote request
  34111. @cindex @samp{qGetTLSAddr} packet
  34112. Fetch the address associated with thread local storage specified
  34113. by @var{thread-id}, @var{offset}, and @var{lm}.
  34114. @var{thread-id} is the thread ID associated with the
  34115. thread for which to fetch the TLS address. @xref{thread-id syntax}.
  34116. @var{offset} is the (big endian, hex encoded) offset associated with the
  34117. thread local variable. (This offset is obtained from the debug
  34118. information associated with the variable.)
  34119. @var{lm} is the (big endian, hex encoded) OS/ABI-specific encoding of the
  34120. load module associated with the thread local storage. For example,
  34121. a @sc{gnu}/Linux system will pass the link map address of the shared
  34122. object associated with the thread local storage under consideration.
  34123. Other operating environments may choose to represent the load module
  34124. differently, so the precise meaning of this parameter will vary.
  34125. Reply:
  34126. @table @samp
  34127. @item @var{XX}@dots{}
  34128. Hex encoded (big endian) bytes representing the address of the thread
  34129. local storage requested.
  34130. @item E @var{nn}
  34131. An error occurred. The error number @var{nn} is given as hex digits.
  34132. @item @w{}
  34133. An empty reply indicates that @samp{qGetTLSAddr} is not supported by the stub.
  34134. @end table
  34135. @item qGetTIBAddr:@var{thread-id}
  34136. @cindex get thread information block address
  34137. @cindex @samp{qGetTIBAddr} packet
  34138. Fetch address of the Windows OS specific Thread Information Block.
  34139. @var{thread-id} is the thread ID associated with the thread.
  34140. Reply:
  34141. @table @samp
  34142. @item @var{XX}@dots{}
  34143. Hex encoded (big endian) bytes representing the linear address of the
  34144. thread information block.
  34145. @item E @var{nn}
  34146. An error occured. This means that either the thread was not found, or the
  34147. address could not be retrieved.
  34148. @item @w{}
  34149. An empty reply indicates that @samp{qGetTIBAddr} is not supported by the stub.
  34150. @end table
  34151. @item qL @var{startflag} @var{threadcount} @var{nextthread}
  34152. Obtain thread information from RTOS. Where: @var{startflag} (one hex
  34153. digit) is one to indicate the first query and zero to indicate a
  34154. subsequent query; @var{threadcount} (two hex digits) is the maximum
  34155. number of threads the response packet can contain; and @var{nextthread}
  34156. (eight hex digits), for subsequent queries (@var{startflag} is zero), is
  34157. returned in the response as @var{argthread}.
  34158. Don't use this packet; use the @samp{qfThreadInfo} query instead (see above).
  34159. Reply:
  34160. @table @samp
  34161. @item qM @var{count} @var{done} @var{argthread} @var{thread}@dots{}
  34162. Where: @var{count} (two hex digits) is the number of threads being
  34163. returned; @var{done} (one hex digit) is zero to indicate more threads
  34164. and one indicates no further threads; @var{argthreadid} (eight hex
  34165. digits) is @var{nextthread} from the request packet; @var{thread}@dots{}
  34166. is a sequence of thread IDs, @var{threadid} (eight hex
  34167. digits), from the target. See @code{remote.c:parse_threadlist_response()}.
  34168. @end table
  34169. @item qMemTags:@var{start address},@var{length}:@var{type}
  34170. @anchor{qMemTags}
  34171. @cindex fetch memory tags
  34172. @cindex @samp{qMemTags} packet
  34173. Fetch memory tags of type @var{type} from the address range
  34174. @w{@r{[}@var{start address}, @var{start address} + @var{length}@r{)}}. The
  34175. target is responsible for calculating how many tags will be returned, as this
  34176. is architecture-specific.
  34177. @var{start address} is the starting address of the memory range.
  34178. @var{length} is the length, in bytes, of the memory range.
  34179. @var{type} is the type of tag the request wants to fetch. The type is a signed
  34180. integer.
  34181. Reply:
  34182. @table @samp
  34183. @item @var{mxx}@dots{}
  34184. Hex encoded sequence of uninterpreted bytes, @var{xx}@dots{}, representing the
  34185. tags found in the requested memory range.
  34186. @item E @var{nn}
  34187. An error occured. This means that fetching of memory tags failed for some
  34188. reason.
  34189. @item @w{}
  34190. An empty reply indicates that @samp{qMemTags} is not supported by the stub,
  34191. although this should not happen given @value{GDBN} will only send this packet
  34192. if the stub has advertised support for memory tagging via @samp{qSupported}.
  34193. @end table
  34194. @item QMemTags:@var{start address},@var{length}:@var{type}:@var{tag bytes}
  34195. @anchor{QMemTags}
  34196. @cindex store memory tags
  34197. @cindex @samp{QMemTags} packet
  34198. Store memory tags of type @var{type} to the address range
  34199. @w{@r{[}@var{start address}, @var{start address} + @var{length}@r{)}}. The
  34200. target is responsible for interpreting the type, the tag bytes and modifying
  34201. the memory tag granules accordingly, given this is architecture-specific.
  34202. The interpretation of how many tags (@var{nt}) should be written to how many
  34203. memory tag granules (@var{ng}) is also architecture-specific. The behavior is
  34204. implementation-specific, but the following is suggested.
  34205. If the number of memory tags, @var{nt}, is greater than or equal to the
  34206. number of memory tag granules, @var{ng}, only @var{ng} tags will be
  34207. stored.
  34208. If @var{nt} is less than @var{ng}, the behavior is that of a fill operation,
  34209. and the tag bytes will be used as a pattern that will get repeated until
  34210. @var{ng} tags are stored.
  34211. @var{start address} is the starting address of the memory range. The address
  34212. does not have any restriction on alignment or size.
  34213. @var{length} is the length, in bytes, of the memory range.
  34214. @var{type} is the type of tag the request wants to fetch. The type is a signed
  34215. integer.
  34216. @var{tag bytes} is a sequence of hex encoded uninterpreted bytes which will be
  34217. interpreted by the target. Each pair of hex digits is interpreted as a
  34218. single byte.
  34219. Reply:
  34220. @table @samp
  34221. @item OK
  34222. The request was successful and the memory tag granules were modified
  34223. accordingly.
  34224. @item E @var{nn}
  34225. An error occured. This means that modifying the memory tag granules failed
  34226. for some reason.
  34227. @item @w{}
  34228. An empty reply indicates that @samp{QMemTags} is not supported by the stub,
  34229. although this should not happen given @value{GDBN} will only send this packet
  34230. if the stub has advertised support for memory tagging via @samp{qSupported}.
  34231. @end table
  34232. @item qOffsets
  34233. @cindex section offsets, remote request
  34234. @cindex @samp{qOffsets} packet
  34235. Get section offsets that the target used when relocating the downloaded
  34236. image.
  34237. Reply:
  34238. @table @samp
  34239. @item Text=@var{xxx};Data=@var{yyy}@r{[};Bss=@var{zzz}@r{]}
  34240. Relocate the @code{Text} section by @var{xxx} from its original address.
  34241. Relocate the @code{Data} section by @var{yyy} from its original address.
  34242. If the object file format provides segment information (e.g.@: @sc{elf}
  34243. @samp{PT_LOAD} program headers), @value{GDBN} will relocate entire
  34244. segments by the supplied offsets.
  34245. @emph{Note: while a @code{Bss} offset may be included in the response,
  34246. @value{GDBN} ignores this and instead applies the @code{Data} offset
  34247. to the @code{Bss} section.}
  34248. @item TextSeg=@var{xxx}@r{[};DataSeg=@var{yyy}@r{]}
  34249. Relocate the first segment of the object file, which conventionally
  34250. contains program code, to a starting address of @var{xxx}. If
  34251. @samp{DataSeg} is specified, relocate the second segment, which
  34252. conventionally contains modifiable data, to a starting address of
  34253. @var{yyy}. @value{GDBN} will report an error if the object file
  34254. does not contain segment information, or does not contain at least
  34255. as many segments as mentioned in the reply. Extra segments are
  34256. kept at fixed offsets relative to the last relocated segment.
  34257. @end table
  34258. @item qP @var{mode} @var{thread-id}
  34259. @cindex thread information, remote request
  34260. @cindex @samp{qP} packet
  34261. Returns information on @var{thread-id}. Where: @var{mode} is a hex
  34262. encoded 32 bit mode; @var{thread-id} is a thread ID
  34263. (@pxref{thread-id syntax}).
  34264. Don't use this packet; use the @samp{qThreadExtraInfo} query instead
  34265. (see below).
  34266. Reply: see @code{remote.c:remote_unpack_thread_info_response()}.
  34267. @item QNonStop:1
  34268. @itemx QNonStop:0
  34269. @cindex non-stop mode, remote request
  34270. @cindex @samp{QNonStop} packet
  34271. @anchor{QNonStop}
  34272. Enter non-stop (@samp{QNonStop:1}) or all-stop (@samp{QNonStop:0}) mode.
  34273. @xref{Remote Non-Stop}, for more information.
  34274. Reply:
  34275. @table @samp
  34276. @item OK
  34277. The request succeeded.
  34278. @item E @var{nn}
  34279. An error occurred. The error number @var{nn} is given as hex digits.
  34280. @item @w{}
  34281. An empty reply indicates that @samp{QNonStop} is not supported by
  34282. the stub.
  34283. @end table
  34284. This packet is not probed by default; the remote stub must request it,
  34285. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  34286. Use of this packet is controlled by the @code{set non-stop} command;
  34287. @pxref{Non-Stop Mode}.
  34288. @item QCatchSyscalls:1 @r{[};@var{sysno}@r{]}@dots{}
  34289. @itemx QCatchSyscalls:0
  34290. @cindex catch syscalls from inferior, remote request
  34291. @cindex @samp{QCatchSyscalls} packet
  34292. @anchor{QCatchSyscalls}
  34293. Enable (@samp{QCatchSyscalls:1}) or disable (@samp{QCatchSyscalls:0})
  34294. catching syscalls from the inferior process.
  34295. For @samp{QCatchSyscalls:1}, each listed syscall @var{sysno} (encoded
  34296. in hex) should be reported to @value{GDBN}. If no syscall @var{sysno}
  34297. is listed, every system call should be reported.
  34298. Note that if a syscall not in the list is reported, @value{GDBN} will
  34299. still filter the event according to its own list from all corresponding
  34300. @code{catch syscall} commands. However, it is more efficient to only
  34301. report the requested syscalls.
  34302. Multiple @samp{QCatchSyscalls:1} packets do not combine; any earlier
  34303. @samp{QCatchSyscalls:1} list is completely replaced by the new list.
  34304. If the inferior process execs, the state of @samp{QCatchSyscalls} is
  34305. kept for the new process too. On targets where exec may affect syscall
  34306. numbers, for example with exec between 32 and 64-bit processes, the
  34307. client should send a new packet with the new syscall list.
  34308. Reply:
  34309. @table @samp
  34310. @item OK
  34311. The request succeeded.
  34312. @item E @var{nn}
  34313. An error occurred. @var{nn} are hex digits.
  34314. @item @w{}
  34315. An empty reply indicates that @samp{QCatchSyscalls} is not supported by
  34316. the stub.
  34317. @end table
  34318. Use of this packet is controlled by the @code{set remote catch-syscalls}
  34319. command (@pxref{Remote Configuration, set remote catch-syscalls}).
  34320. This packet is not probed by default; the remote stub must request it,
  34321. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  34322. @item QPassSignals: @var{signal} @r{[};@var{signal}@r{]}@dots{}
  34323. @cindex pass signals to inferior, remote request
  34324. @cindex @samp{QPassSignals} packet
  34325. @anchor{QPassSignals}
  34326. Each listed @var{signal} should be passed directly to the inferior process.
  34327. Signals are numbered identically to continue packets and stop replies
  34328. (@pxref{Stop Reply Packets}). Each @var{signal} list item should be
  34329. strictly greater than the previous item. These signals do not need to stop
  34330. the inferior, or be reported to @value{GDBN}. All other signals should be
  34331. reported to @value{GDBN}. Multiple @samp{QPassSignals} packets do not
  34332. combine; any earlier @samp{QPassSignals} list is completely replaced by the
  34333. new list. This packet improves performance when using @samp{handle
  34334. @var{signal} nostop noprint pass}.
  34335. Reply:
  34336. @table @samp
  34337. @item OK
  34338. The request succeeded.
  34339. @item E @var{nn}
  34340. An error occurred. The error number @var{nn} is given as hex digits.
  34341. @item @w{}
  34342. An empty reply indicates that @samp{QPassSignals} is not supported by
  34343. the stub.
  34344. @end table
  34345. Use of this packet is controlled by the @code{set remote pass-signals}
  34346. command (@pxref{Remote Configuration, set remote pass-signals}).
  34347. This packet is not probed by default; the remote stub must request it,
  34348. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  34349. @item QProgramSignals: @var{signal} @r{[};@var{signal}@r{]}@dots{}
  34350. @cindex signals the inferior may see, remote request
  34351. @cindex @samp{QProgramSignals} packet
  34352. @anchor{QProgramSignals}
  34353. Each listed @var{signal} may be delivered to the inferior process.
  34354. Others should be silently discarded.
  34355. In some cases, the remote stub may need to decide whether to deliver a
  34356. signal to the program or not without @value{GDBN} involvement. One
  34357. example of that is while detaching --- the program's threads may have
  34358. stopped for signals that haven't yet had a chance of being reported to
  34359. @value{GDBN}, and so the remote stub can use the signal list specified
  34360. by this packet to know whether to deliver or ignore those pending
  34361. signals.
  34362. This does not influence whether to deliver a signal as requested by a
  34363. resumption packet (@pxref{vCont packet}).
  34364. Signals are numbered identically to continue packets and stop replies
  34365. (@pxref{Stop Reply Packets}). Each @var{signal} list item should be
  34366. strictly greater than the previous item. Multiple
  34367. @samp{QProgramSignals} packets do not combine; any earlier
  34368. @samp{QProgramSignals} list is completely replaced by the new list.
  34369. Reply:
  34370. @table @samp
  34371. @item OK
  34372. The request succeeded.
  34373. @item E @var{nn}
  34374. An error occurred. The error number @var{nn} is given as hex digits.
  34375. @item @w{}
  34376. An empty reply indicates that @samp{QProgramSignals} is not supported
  34377. by the stub.
  34378. @end table
  34379. Use of this packet is controlled by the @code{set remote program-signals}
  34380. command (@pxref{Remote Configuration, set remote program-signals}).
  34381. This packet is not probed by default; the remote stub must request it,
  34382. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  34383. @anchor{QThreadEvents}
  34384. @item QThreadEvents:1
  34385. @itemx QThreadEvents:0
  34386. @cindex thread create/exit events, remote request
  34387. @cindex @samp{QThreadEvents} packet
  34388. Enable (@samp{QThreadEvents:1}) or disable (@samp{QThreadEvents:0})
  34389. reporting of thread create and exit events. @xref{thread create
  34390. event}, for the reply specifications. For example, this is used in
  34391. non-stop mode when @value{GDBN} stops a set of threads and
  34392. synchronously waits for the their corresponding stop replies. Without
  34393. exit events, if one of the threads exits, @value{GDBN} would hang
  34394. forever not knowing that it should no longer expect a stop for that
  34395. same thread. @value{GDBN} does not enable this feature unless the
  34396. stub reports that it supports it by including @samp{QThreadEvents+} in
  34397. its @samp{qSupported} reply.
  34398. Reply:
  34399. @table @samp
  34400. @item OK
  34401. The request succeeded.
  34402. @item E @var{nn}
  34403. An error occurred. The error number @var{nn} is given as hex digits.
  34404. @item @w{}
  34405. An empty reply indicates that @samp{QThreadEvents} is not supported by
  34406. the stub.
  34407. @end table
  34408. Use of this packet is controlled by the @code{set remote thread-events}
  34409. command (@pxref{Remote Configuration, set remote thread-events}).
  34410. @item qRcmd,@var{command}
  34411. @cindex execute remote command, remote request
  34412. @cindex @samp{qRcmd} packet
  34413. @var{command} (hex encoded) is passed to the local interpreter for
  34414. execution. Invalid commands should be reported using the output
  34415. string. Before the final result packet, the target may also respond
  34416. with a number of intermediate @samp{O@var{output}} console output
  34417. packets. @emph{Implementors should note that providing access to a
  34418. stubs's interpreter may have security implications}.
  34419. Reply:
  34420. @table @samp
  34421. @item OK
  34422. A command response with no output.
  34423. @item @var{OUTPUT}
  34424. A command response with the hex encoded output string @var{OUTPUT}.
  34425. @item E @var{NN}
  34426. Indicate a badly formed request. The error number @var{NN} is given as
  34427. hex digits.
  34428. @item @w{}
  34429. An empty reply indicates that @samp{qRcmd} is not recognized.
  34430. @end table
  34431. (Note that the @code{qRcmd} packet's name is separated from the
  34432. command by a @samp{,}, not a @samp{:}, contrary to the naming
  34433. conventions above. Please don't use this packet as a model for new
  34434. packets.)
  34435. @item qSearch:memory:@var{address};@var{length};@var{search-pattern}
  34436. @cindex searching memory, in remote debugging
  34437. @ifnotinfo
  34438. @cindex @samp{qSearch:memory} packet
  34439. @end ifnotinfo
  34440. @cindex @samp{qSearch memory} packet
  34441. @anchor{qSearch memory}
  34442. Search @var{length} bytes at @var{address} for @var{search-pattern}.
  34443. Both @var{address} and @var{length} are encoded in hex;
  34444. @var{search-pattern} is a sequence of bytes, also hex encoded.
  34445. Reply:
  34446. @table @samp
  34447. @item 0
  34448. The pattern was not found.
  34449. @item 1,address
  34450. The pattern was found at @var{address}.
  34451. @item E @var{NN}
  34452. A badly formed request or an error was encountered while searching memory.
  34453. @item @w{}
  34454. An empty reply indicates that @samp{qSearch:memory} is not recognized.
  34455. @end table
  34456. @item QStartNoAckMode
  34457. @cindex @samp{QStartNoAckMode} packet
  34458. @anchor{QStartNoAckMode}
  34459. Request that the remote stub disable the normal @samp{+}/@samp{-}
  34460. protocol acknowledgments (@pxref{Packet Acknowledgment}).
  34461. Reply:
  34462. @table @samp
  34463. @item OK
  34464. The stub has switched to no-acknowledgment mode.
  34465. @value{GDBN} acknowledges this response,
  34466. but neither the stub nor @value{GDBN} shall send or expect further
  34467. @samp{+}/@samp{-} acknowledgments in the current connection.
  34468. @item @w{}
  34469. An empty reply indicates that the stub does not support no-acknowledgment mode.
  34470. @end table
  34471. @item qSupported @r{[}:@var{gdbfeature} @r{[};@var{gdbfeature}@r{]}@dots{} @r{]}
  34472. @cindex supported packets, remote query
  34473. @cindex features of the remote protocol
  34474. @cindex @samp{qSupported} packet
  34475. @anchor{qSupported}
  34476. Tell the remote stub about features supported by @value{GDBN}, and
  34477. query the stub for features it supports. This packet allows
  34478. @value{GDBN} and the remote stub to take advantage of each others'
  34479. features. @samp{qSupported} also consolidates multiple feature probes
  34480. at startup, to improve @value{GDBN} performance---a single larger
  34481. packet performs better than multiple smaller probe packets on
  34482. high-latency links. Some features may enable behavior which must not
  34483. be on by default, e.g.@: because it would confuse older clients or
  34484. stubs. Other features may describe packets which could be
  34485. automatically probed for, but are not. These features must be
  34486. reported before @value{GDBN} will use them. This ``default
  34487. unsupported'' behavior is not appropriate for all packets, but it
  34488. helps to keep the initial connection time under control with new
  34489. versions of @value{GDBN} which support increasing numbers of packets.
  34490. Reply:
  34491. @table @samp
  34492. @item @var{stubfeature} @r{[};@var{stubfeature}@r{]}@dots{}
  34493. The stub supports or does not support each returned @var{stubfeature},
  34494. depending on the form of each @var{stubfeature} (see below for the
  34495. possible forms).
  34496. @item @w{}
  34497. An empty reply indicates that @samp{qSupported} is not recognized,
  34498. or that no features needed to be reported to @value{GDBN}.
  34499. @end table
  34500. The allowed forms for each feature (either a @var{gdbfeature} in the
  34501. @samp{qSupported} packet, or a @var{stubfeature} in the response)
  34502. are:
  34503. @table @samp
  34504. @item @var{name}=@var{value}
  34505. The remote protocol feature @var{name} is supported, and associated
  34506. with the specified @var{value}. The format of @var{value} depends
  34507. on the feature, but it must not include a semicolon.
  34508. @item @var{name}+
  34509. The remote protocol feature @var{name} is supported, and does not
  34510. need an associated value.
  34511. @item @var{name}-
  34512. The remote protocol feature @var{name} is not supported.
  34513. @item @var{name}?
  34514. The remote protocol feature @var{name} may be supported, and
  34515. @value{GDBN} should auto-detect support in some other way when it is
  34516. needed. This form will not be used for @var{gdbfeature} notifications,
  34517. but may be used for @var{stubfeature} responses.
  34518. @end table
  34519. Whenever the stub receives a @samp{qSupported} request, the
  34520. supplied set of @value{GDBN} features should override any previous
  34521. request. This allows @value{GDBN} to put the stub in a known
  34522. state, even if the stub had previously been communicating with
  34523. a different version of @value{GDBN}.
  34524. The following values of @var{gdbfeature} (for the packet sent by @value{GDBN})
  34525. are defined:
  34526. @table @samp
  34527. @item multiprocess
  34528. This feature indicates whether @value{GDBN} supports multiprocess
  34529. extensions to the remote protocol. @value{GDBN} does not use such
  34530. extensions unless the stub also reports that it supports them by
  34531. including @samp{multiprocess+} in its @samp{qSupported} reply.
  34532. @xref{multiprocess extensions}, for details.
  34533. @item xmlRegisters
  34534. This feature indicates that @value{GDBN} supports the XML target
  34535. description. If the stub sees @samp{xmlRegisters=} with target
  34536. specific strings separated by a comma, it will report register
  34537. description.
  34538. @item qRelocInsn
  34539. This feature indicates whether @value{GDBN} supports the
  34540. @samp{qRelocInsn} packet (@pxref{Tracepoint Packets,,Relocate
  34541. instruction reply packet}).
  34542. @item swbreak
  34543. This feature indicates whether @value{GDBN} supports the swbreak stop
  34544. reason in stop replies. @xref{swbreak stop reason}, for details.
  34545. @item hwbreak
  34546. This feature indicates whether @value{GDBN} supports the hwbreak stop
  34547. reason in stop replies. @xref{swbreak stop reason}, for details.
  34548. @item fork-events
  34549. This feature indicates whether @value{GDBN} supports fork event
  34550. extensions to the remote protocol. @value{GDBN} does not use such
  34551. extensions unless the stub also reports that it supports them by
  34552. including @samp{fork-events+} in its @samp{qSupported} reply.
  34553. @item vfork-events
  34554. This feature indicates whether @value{GDBN} supports vfork event
  34555. extensions to the remote protocol. @value{GDBN} does not use such
  34556. extensions unless the stub also reports that it supports them by
  34557. including @samp{vfork-events+} in its @samp{qSupported} reply.
  34558. @item exec-events
  34559. This feature indicates whether @value{GDBN} supports exec event
  34560. extensions to the remote protocol. @value{GDBN} does not use such
  34561. extensions unless the stub also reports that it supports them by
  34562. including @samp{exec-events+} in its @samp{qSupported} reply.
  34563. @item vContSupported
  34564. This feature indicates whether @value{GDBN} wants to know the
  34565. supported actions in the reply to @samp{vCont?} packet.
  34566. @end table
  34567. Stubs should ignore any unknown values for
  34568. @var{gdbfeature}. Any @value{GDBN} which sends a @samp{qSupported}
  34569. packet supports receiving packets of unlimited length (earlier
  34570. versions of @value{GDBN} may reject overly long responses). Additional values
  34571. for @var{gdbfeature} may be defined in the future to let the stub take
  34572. advantage of new features in @value{GDBN}, e.g.@: incompatible
  34573. improvements in the remote protocol---the @samp{multiprocess} feature is
  34574. an example of such a feature. The stub's reply should be independent
  34575. of the @var{gdbfeature} entries sent by @value{GDBN}; first @value{GDBN}
  34576. describes all the features it supports, and then the stub replies with
  34577. all the features it supports.
  34578. Similarly, @value{GDBN} will silently ignore unrecognized stub feature
  34579. responses, as long as each response uses one of the standard forms.
  34580. Some features are flags. A stub which supports a flag feature
  34581. should respond with a @samp{+} form response. Other features
  34582. require values, and the stub should respond with an @samp{=}
  34583. form response.
  34584. Each feature has a default value, which @value{GDBN} will use if
  34585. @samp{qSupported} is not available or if the feature is not mentioned
  34586. in the @samp{qSupported} response. The default values are fixed; a
  34587. stub is free to omit any feature responses that match the defaults.
  34588. Not all features can be probed, but for those which can, the probing
  34589. mechanism is useful: in some cases, a stub's internal
  34590. architecture may not allow the protocol layer to know some information
  34591. about the underlying target in advance. This is especially common in
  34592. stubs which may be configured for multiple targets.
  34593. These are the currently defined stub features and their properties:
  34594. @multitable @columnfractions 0.35 0.2 0.12 0.2
  34595. @c NOTE: The first row should be @headitem, but we do not yet require
  34596. @c a new enough version of Texinfo (4.7) to use @headitem.
  34597. @item Feature Name
  34598. @tab Value Required
  34599. @tab Default
  34600. @tab Probe Allowed
  34601. @item @samp{PacketSize}
  34602. @tab Yes
  34603. @tab @samp{-}
  34604. @tab No
  34605. @item @samp{qXfer:auxv:read}
  34606. @tab No
  34607. @tab @samp{-}
  34608. @tab Yes
  34609. @item @samp{qXfer:btrace:read}
  34610. @tab No
  34611. @tab @samp{-}
  34612. @tab Yes
  34613. @item @samp{qXfer:btrace-conf:read}
  34614. @tab No
  34615. @tab @samp{-}
  34616. @tab Yes
  34617. @item @samp{qXfer:exec-file:read}
  34618. @tab No
  34619. @tab @samp{-}
  34620. @tab Yes
  34621. @item @samp{qXfer:features:read}
  34622. @tab No
  34623. @tab @samp{-}
  34624. @tab Yes
  34625. @item @samp{qXfer:libraries:read}
  34626. @tab No
  34627. @tab @samp{-}
  34628. @tab Yes
  34629. @item @samp{qXfer:libraries-svr4:read}
  34630. @tab No
  34631. @tab @samp{-}
  34632. @tab Yes
  34633. @item @samp{augmented-libraries-svr4-read}
  34634. @tab No
  34635. @tab @samp{-}
  34636. @tab No
  34637. @item @samp{qXfer:memory-map:read}
  34638. @tab No
  34639. @tab @samp{-}
  34640. @tab Yes
  34641. @item @samp{qXfer:sdata:read}
  34642. @tab No
  34643. @tab @samp{-}
  34644. @tab Yes
  34645. @item @samp{qXfer:siginfo:read}
  34646. @tab No
  34647. @tab @samp{-}
  34648. @tab Yes
  34649. @item @samp{qXfer:siginfo:write}
  34650. @tab No
  34651. @tab @samp{-}
  34652. @tab Yes
  34653. @item @samp{qXfer:threads:read}
  34654. @tab No
  34655. @tab @samp{-}
  34656. @tab Yes
  34657. @item @samp{qXfer:traceframe-info:read}
  34658. @tab No
  34659. @tab @samp{-}
  34660. @tab Yes
  34661. @item @samp{qXfer:uib:read}
  34662. @tab No
  34663. @tab @samp{-}
  34664. @tab Yes
  34665. @item @samp{qXfer:fdpic:read}
  34666. @tab No
  34667. @tab @samp{-}
  34668. @tab Yes
  34669. @item @samp{Qbtrace:off}
  34670. @tab Yes
  34671. @tab @samp{-}
  34672. @tab Yes
  34673. @item @samp{Qbtrace:bts}
  34674. @tab Yes
  34675. @tab @samp{-}
  34676. @tab Yes
  34677. @item @samp{Qbtrace:pt}
  34678. @tab Yes
  34679. @tab @samp{-}
  34680. @tab Yes
  34681. @item @samp{Qbtrace-conf:bts:size}
  34682. @tab Yes
  34683. @tab @samp{-}
  34684. @tab Yes
  34685. @item @samp{Qbtrace-conf:pt:size}
  34686. @tab Yes
  34687. @tab @samp{-}
  34688. @tab Yes
  34689. @item @samp{QNonStop}
  34690. @tab No
  34691. @tab @samp{-}
  34692. @tab Yes
  34693. @item @samp{QCatchSyscalls}
  34694. @tab No
  34695. @tab @samp{-}
  34696. @tab Yes
  34697. @item @samp{QPassSignals}
  34698. @tab No
  34699. @tab @samp{-}
  34700. @tab Yes
  34701. @item @samp{QStartNoAckMode}
  34702. @tab No
  34703. @tab @samp{-}
  34704. @tab Yes
  34705. @item @samp{multiprocess}
  34706. @tab No
  34707. @tab @samp{-}
  34708. @tab No
  34709. @item @samp{ConditionalBreakpoints}
  34710. @tab No
  34711. @tab @samp{-}
  34712. @tab No
  34713. @item @samp{ConditionalTracepoints}
  34714. @tab No
  34715. @tab @samp{-}
  34716. @tab No
  34717. @item @samp{ReverseContinue}
  34718. @tab No
  34719. @tab @samp{-}
  34720. @tab No
  34721. @item @samp{ReverseStep}
  34722. @tab No
  34723. @tab @samp{-}
  34724. @tab No
  34725. @item @samp{TracepointSource}
  34726. @tab No
  34727. @tab @samp{-}
  34728. @tab No
  34729. @item @samp{QAgent}
  34730. @tab No
  34731. @tab @samp{-}
  34732. @tab No
  34733. @item @samp{QAllow}
  34734. @tab No
  34735. @tab @samp{-}
  34736. @tab No
  34737. @item @samp{QDisableRandomization}
  34738. @tab No
  34739. @tab @samp{-}
  34740. @tab No
  34741. @item @samp{EnableDisableTracepoints}
  34742. @tab No
  34743. @tab @samp{-}
  34744. @tab No
  34745. @item @samp{QTBuffer:size}
  34746. @tab No
  34747. @tab @samp{-}
  34748. @tab No
  34749. @item @samp{tracenz}
  34750. @tab No
  34751. @tab @samp{-}
  34752. @tab No
  34753. @item @samp{BreakpointCommands}
  34754. @tab No
  34755. @tab @samp{-}
  34756. @tab No
  34757. @item @samp{swbreak}
  34758. @tab No
  34759. @tab @samp{-}
  34760. @tab No
  34761. @item @samp{hwbreak}
  34762. @tab No
  34763. @tab @samp{-}
  34764. @tab No
  34765. @item @samp{fork-events}
  34766. @tab No
  34767. @tab @samp{-}
  34768. @tab No
  34769. @item @samp{vfork-events}
  34770. @tab No
  34771. @tab @samp{-}
  34772. @tab No
  34773. @item @samp{exec-events}
  34774. @tab No
  34775. @tab @samp{-}
  34776. @tab No
  34777. @item @samp{QThreadEvents}
  34778. @tab No
  34779. @tab @samp{-}
  34780. @tab No
  34781. @item @samp{no-resumed}
  34782. @tab No
  34783. @tab @samp{-}
  34784. @tab No
  34785. @item @samp{memory-tagging}
  34786. @tab No
  34787. @tab @samp{-}
  34788. @tab No
  34789. @end multitable
  34790. These are the currently defined stub features, in more detail:
  34791. @table @samp
  34792. @cindex packet size, remote protocol
  34793. @item PacketSize=@var{bytes}
  34794. The remote stub can accept packets up to at least @var{bytes} in
  34795. length. @value{GDBN} will send packets up to this size for bulk
  34796. transfers, and will never send larger packets. This is a limit on the
  34797. data characters in the packet, including the frame and checksum.
  34798. There is no trailing NUL byte in a remote protocol packet; if the stub
  34799. stores packets in a NUL-terminated format, it should allow an extra
  34800. byte in its buffer for the NUL. If this stub feature is not supported,
  34801. @value{GDBN} guesses based on the size of the @samp{g} packet response.
  34802. @item qXfer:auxv:read
  34803. The remote stub understands the @samp{qXfer:auxv:read} packet
  34804. (@pxref{qXfer auxiliary vector read}).
  34805. @item qXfer:btrace:read
  34806. The remote stub understands the @samp{qXfer:btrace:read}
  34807. packet (@pxref{qXfer btrace read}).
  34808. @item qXfer:btrace-conf:read
  34809. The remote stub understands the @samp{qXfer:btrace-conf:read}
  34810. packet (@pxref{qXfer btrace-conf read}).
  34811. @item qXfer:exec-file:read
  34812. The remote stub understands the @samp{qXfer:exec-file:read} packet
  34813. (@pxref{qXfer executable filename read}).
  34814. @item qXfer:features:read
  34815. The remote stub understands the @samp{qXfer:features:read} packet
  34816. (@pxref{qXfer target description read}).
  34817. @item qXfer:libraries:read
  34818. The remote stub understands the @samp{qXfer:libraries:read} packet
  34819. (@pxref{qXfer library list read}).
  34820. @item qXfer:libraries-svr4:read
  34821. The remote stub understands the @samp{qXfer:libraries-svr4:read} packet
  34822. (@pxref{qXfer svr4 library list read}).
  34823. @item augmented-libraries-svr4-read
  34824. The remote stub understands the augmented form of the
  34825. @samp{qXfer:libraries-svr4:read} packet
  34826. (@pxref{qXfer svr4 library list read}).
  34827. @item qXfer:memory-map:read
  34828. The remote stub understands the @samp{qXfer:memory-map:read} packet
  34829. (@pxref{qXfer memory map read}).
  34830. @item qXfer:sdata:read
  34831. The remote stub understands the @samp{qXfer:sdata:read} packet
  34832. (@pxref{qXfer sdata read}).
  34833. @item qXfer:siginfo:read
  34834. The remote stub understands the @samp{qXfer:siginfo:read} packet
  34835. (@pxref{qXfer siginfo read}).
  34836. @item qXfer:siginfo:write
  34837. The remote stub understands the @samp{qXfer:siginfo:write} packet
  34838. (@pxref{qXfer siginfo write}).
  34839. @item qXfer:threads:read
  34840. The remote stub understands the @samp{qXfer:threads:read} packet
  34841. (@pxref{qXfer threads read}).
  34842. @item qXfer:traceframe-info:read
  34843. The remote stub understands the @samp{qXfer:traceframe-info:read}
  34844. packet (@pxref{qXfer traceframe info read}).
  34845. @item qXfer:uib:read
  34846. The remote stub understands the @samp{qXfer:uib:read}
  34847. packet (@pxref{qXfer unwind info block}).
  34848. @item qXfer:fdpic:read
  34849. The remote stub understands the @samp{qXfer:fdpic:read}
  34850. packet (@pxref{qXfer fdpic loadmap read}).
  34851. @item QNonStop
  34852. The remote stub understands the @samp{QNonStop} packet
  34853. (@pxref{QNonStop}).
  34854. @item QCatchSyscalls
  34855. The remote stub understands the @samp{QCatchSyscalls} packet
  34856. (@pxref{QCatchSyscalls}).
  34857. @item QPassSignals
  34858. The remote stub understands the @samp{QPassSignals} packet
  34859. (@pxref{QPassSignals}).
  34860. @item QStartNoAckMode
  34861. The remote stub understands the @samp{QStartNoAckMode} packet and
  34862. prefers to operate in no-acknowledgment mode. @xref{Packet Acknowledgment}.
  34863. @item multiprocess
  34864. @anchor{multiprocess extensions}
  34865. @cindex multiprocess extensions, in remote protocol
  34866. The remote stub understands the multiprocess extensions to the remote
  34867. protocol syntax. The multiprocess extensions affect the syntax of
  34868. thread IDs in both packets and replies (@pxref{thread-id syntax}), and
  34869. add process IDs to the @samp{D} packet and @samp{W} and @samp{X}
  34870. replies. Note that reporting this feature indicates support for the
  34871. syntactic extensions only, not that the stub necessarily supports
  34872. debugging of more than one process at a time. The stub must not use
  34873. multiprocess extensions in packet replies unless @value{GDBN} has also
  34874. indicated it supports them in its @samp{qSupported} request.
  34875. @item qXfer:osdata:read
  34876. The remote stub understands the @samp{qXfer:osdata:read} packet
  34877. ((@pxref{qXfer osdata read}).
  34878. @item ConditionalBreakpoints
  34879. The target accepts and implements evaluation of conditional expressions
  34880. defined for breakpoints. The target will only report breakpoint triggers
  34881. when such conditions are true (@pxref{Conditions, ,Break Conditions}).
  34882. @item ConditionalTracepoints
  34883. The remote stub accepts and implements conditional expressions defined
  34884. for tracepoints (@pxref{Tracepoint Conditions}).
  34885. @item ReverseContinue
  34886. The remote stub accepts and implements the reverse continue packet
  34887. (@pxref{bc}).
  34888. @item ReverseStep
  34889. The remote stub accepts and implements the reverse step packet
  34890. (@pxref{bs}).
  34891. @item TracepointSource
  34892. The remote stub understands the @samp{QTDPsrc} packet that supplies
  34893. the source form of tracepoint definitions.
  34894. @item QAgent
  34895. The remote stub understands the @samp{QAgent} packet.
  34896. @item QAllow
  34897. The remote stub understands the @samp{QAllow} packet.
  34898. @item QDisableRandomization
  34899. The remote stub understands the @samp{QDisableRandomization} packet.
  34900. @item StaticTracepoint
  34901. @cindex static tracepoints, in remote protocol
  34902. The remote stub supports static tracepoints.
  34903. @item InstallInTrace
  34904. @anchor{install tracepoint in tracing}
  34905. The remote stub supports installing tracepoint in tracing.
  34906. @item EnableDisableTracepoints
  34907. The remote stub supports the @samp{QTEnable} (@pxref{QTEnable}) and
  34908. @samp{QTDisable} (@pxref{QTDisable}) packets that allow tracepoints
  34909. to be enabled and disabled while a trace experiment is running.
  34910. @item QTBuffer:size
  34911. The remote stub supports the @samp{QTBuffer:size} (@pxref{QTBuffer-size})
  34912. packet that allows to change the size of the trace buffer.
  34913. @item tracenz
  34914. @cindex string tracing, in remote protocol
  34915. The remote stub supports the @samp{tracenz} bytecode for collecting strings.
  34916. See @ref{Bytecode Descriptions} for details about the bytecode.
  34917. @item BreakpointCommands
  34918. @cindex breakpoint commands, in remote protocol
  34919. The remote stub supports running a breakpoint's command list itself,
  34920. rather than reporting the hit to @value{GDBN}.
  34921. @item Qbtrace:off
  34922. The remote stub understands the @samp{Qbtrace:off} packet.
  34923. @item Qbtrace:bts
  34924. The remote stub understands the @samp{Qbtrace:bts} packet.
  34925. @item Qbtrace:pt
  34926. The remote stub understands the @samp{Qbtrace:pt} packet.
  34927. @item Qbtrace-conf:bts:size
  34928. The remote stub understands the @samp{Qbtrace-conf:bts:size} packet.
  34929. @item Qbtrace-conf:pt:size
  34930. The remote stub understands the @samp{Qbtrace-conf:pt:size} packet.
  34931. @item swbreak
  34932. The remote stub reports the @samp{swbreak} stop reason for memory
  34933. breakpoints.
  34934. @item hwbreak
  34935. The remote stub reports the @samp{hwbreak} stop reason for hardware
  34936. breakpoints.
  34937. @item fork-events
  34938. The remote stub reports the @samp{fork} stop reason for fork events.
  34939. @item vfork-events
  34940. The remote stub reports the @samp{vfork} stop reason for vfork events
  34941. and vforkdone events.
  34942. @item exec-events
  34943. The remote stub reports the @samp{exec} stop reason for exec events.
  34944. @item vContSupported
  34945. The remote stub reports the supported actions in the reply to
  34946. @samp{vCont?} packet.
  34947. @item QThreadEvents
  34948. The remote stub understands the @samp{QThreadEvents} packet.
  34949. @item no-resumed
  34950. The remote stub reports the @samp{N} stop reply.
  34951. @item memory-tagging
  34952. The remote stub supports and implements the required memory tagging
  34953. functionality and understands the @samp{qMemTags} (@pxref{qMemTags}) and
  34954. @samp{QMemTags} (@pxref{QMemTags}) packets.
  34955. For AArch64 GNU/Linux systems, this feature also requires access to the
  34956. @file{/proc/@var{pid}/smaps} file so memory mapping page flags can be inspected.
  34957. This is done via the @samp{vFile} requests.
  34958. @end table
  34959. @item qSymbol::
  34960. @cindex symbol lookup, remote request
  34961. @cindex @samp{qSymbol} packet
  34962. Notify the target that @value{GDBN} is prepared to serve symbol lookup
  34963. requests. Accept requests from the target for the values of symbols.
  34964. Reply:
  34965. @table @samp
  34966. @item OK
  34967. The target does not need to look up any (more) symbols.
  34968. @item qSymbol:@var{sym_name}
  34969. The target requests the value of symbol @var{sym_name} (hex encoded).
  34970. @value{GDBN} may provide the value by using the
  34971. @samp{qSymbol:@var{sym_value}:@var{sym_name}} message, described
  34972. below.
  34973. @end table
  34974. @item qSymbol:@var{sym_value}:@var{sym_name}
  34975. Set the value of @var{sym_name} to @var{sym_value}.
  34976. @var{sym_name} (hex encoded) is the name of a symbol whose value the
  34977. target has previously requested.
  34978. @var{sym_value} (hex) is the value for symbol @var{sym_name}. If
  34979. @value{GDBN} cannot supply a value for @var{sym_name}, then this field
  34980. will be empty.
  34981. Reply:
  34982. @table @samp
  34983. @item OK
  34984. The target does not need to look up any (more) symbols.
  34985. @item qSymbol:@var{sym_name}
  34986. The target requests the value of a new symbol @var{sym_name} (hex
  34987. encoded). @value{GDBN} will continue to supply the values of symbols
  34988. (if available), until the target ceases to request them.
  34989. @end table
  34990. @item qTBuffer
  34991. @itemx QTBuffer
  34992. @itemx QTDisconnected
  34993. @itemx QTDP
  34994. @itemx QTDPsrc
  34995. @itemx QTDV
  34996. @itemx qTfP
  34997. @itemx qTfV
  34998. @itemx QTFrame
  34999. @itemx qTMinFTPILen
  35000. @xref{Tracepoint Packets}.
  35001. @anchor{qThreadExtraInfo}
  35002. @item qThreadExtraInfo,@var{thread-id}
  35003. @cindex thread attributes info, remote request
  35004. @cindex @samp{qThreadExtraInfo} packet
  35005. Obtain from the target OS a printable string description of thread
  35006. attributes for the thread @var{thread-id}; see @ref{thread-id syntax},
  35007. for the forms of @var{thread-id}. This
  35008. string may contain anything that the target OS thinks is interesting
  35009. for @value{GDBN} to tell the user about the thread. The string is
  35010. displayed in @value{GDBN}'s @code{info threads} display. Some
  35011. examples of possible thread extra info strings are @samp{Runnable}, or
  35012. @samp{Blocked on Mutex}.
  35013. Reply:
  35014. @table @samp
  35015. @item @var{XX}@dots{}
  35016. Where @samp{@var{XX}@dots{}} is a hex encoding of @sc{ascii} data,
  35017. comprising the printable string containing the extra information about
  35018. the thread's attributes.
  35019. @end table
  35020. (Note that the @code{qThreadExtraInfo} packet's name is separated from
  35021. the command by a @samp{,}, not a @samp{:}, contrary to the naming
  35022. conventions above. Please don't use this packet as a model for new
  35023. packets.)
  35024. @item QTNotes
  35025. @itemx qTP
  35026. @itemx QTSave
  35027. @itemx qTsP
  35028. @itemx qTsV
  35029. @itemx QTStart
  35030. @itemx QTStop
  35031. @itemx QTEnable
  35032. @itemx QTDisable
  35033. @itemx QTinit
  35034. @itemx QTro
  35035. @itemx qTStatus
  35036. @itemx qTV
  35037. @itemx qTfSTM
  35038. @itemx qTsSTM
  35039. @itemx qTSTMat
  35040. @xref{Tracepoint Packets}.
  35041. @item qXfer:@var{object}:read:@var{annex}:@var{offset},@var{length}
  35042. @cindex read special object, remote request
  35043. @cindex @samp{qXfer} packet
  35044. @anchor{qXfer read}
  35045. Read uninterpreted bytes from the target's special data area
  35046. identified by the keyword @var{object}. Request @var{length} bytes
  35047. starting at @var{offset} bytes into the data. The content and
  35048. encoding of @var{annex} is specific to @var{object}; it can supply
  35049. additional details about what data to access.
  35050. Reply:
  35051. @table @samp
  35052. @item m @var{data}
  35053. Data @var{data} (@pxref{Binary Data}) has been read from the
  35054. target. There may be more data at a higher address (although
  35055. it is permitted to return @samp{m} even for the last valid
  35056. block of data, as long as at least one byte of data was read).
  35057. It is possible for @var{data} to have fewer bytes than the @var{length} in the
  35058. request.
  35059. @item l @var{data}
  35060. Data @var{data} (@pxref{Binary Data}) has been read from the target.
  35061. There is no more data to be read. It is possible for @var{data} to
  35062. have fewer bytes than the @var{length} in the request.
  35063. @item l
  35064. The @var{offset} in the request is at the end of the data.
  35065. There is no more data to be read.
  35066. @item E00
  35067. The request was malformed, or @var{annex} was invalid.
  35068. @item E @var{nn}
  35069. The offset was invalid, or there was an error encountered reading the data.
  35070. The @var{nn} part is a hex-encoded @code{errno} value.
  35071. @item @w{}
  35072. An empty reply indicates the @var{object} string was not recognized by
  35073. the stub, or that the object does not support reading.
  35074. @end table
  35075. Here are the specific requests of this form defined so far. All the
  35076. @samp{qXfer:@var{object}:read:@dots{}} requests use the same reply
  35077. formats, listed above.
  35078. @table @samp
  35079. @item qXfer:auxv:read::@var{offset},@var{length}
  35080. @anchor{qXfer auxiliary vector read}
  35081. Access the target's @dfn{auxiliary vector}. @xref{OS Information,
  35082. auxiliary vector}. Note @var{annex} must be empty.
  35083. This packet is not probed by default; the remote stub must request it,
  35084. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35085. @item qXfer:btrace:read:@var{annex}:@var{offset},@var{length}
  35086. @anchor{qXfer btrace read}
  35087. Return a description of the current branch trace.
  35088. @xref{Branch Trace Format}. The annex part of the generic @samp{qXfer}
  35089. packet may have one of the following values:
  35090. @table @code
  35091. @item all
  35092. Returns all available branch trace.
  35093. @item new
  35094. Returns all available branch trace if the branch trace changed since
  35095. the last read request.
  35096. @item delta
  35097. Returns the new branch trace since the last read request. Adds a new
  35098. block to the end of the trace that begins at zero and ends at the source
  35099. location of the first branch in the trace buffer. This extra block is
  35100. used to stitch traces together.
  35101. If the trace buffer overflowed, returns an error indicating the overflow.
  35102. @end table
  35103. This packet is not probed by default; the remote stub must request it
  35104. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35105. @item qXfer:btrace-conf:read::@var{offset},@var{length}
  35106. @anchor{qXfer btrace-conf read}
  35107. Return a description of the current branch trace configuration.
  35108. @xref{Branch Trace Configuration Format}.
  35109. This packet is not probed by default; the remote stub must request it
  35110. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35111. @item qXfer:exec-file:read:@var{annex}:@var{offset},@var{length}
  35112. @anchor{qXfer executable filename read}
  35113. Return the full absolute name of the file that was executed to create
  35114. a process running on the remote system. The annex specifies the
  35115. numeric process ID of the process to query, encoded as a hexadecimal
  35116. number. If the annex part is empty the remote stub should return the
  35117. filename corresponding to the currently executing process.
  35118. This packet is not probed by default; the remote stub must request it,
  35119. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35120. @item qXfer:features:read:@var{annex}:@var{offset},@var{length}
  35121. @anchor{qXfer target description read}
  35122. Access the @dfn{target description}. @xref{Target Descriptions}. The
  35123. annex specifies which XML document to access. The main description is
  35124. always loaded from the @samp{target.xml} annex.
  35125. This packet is not probed by default; the remote stub must request it,
  35126. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35127. @item qXfer:libraries:read:@var{annex}:@var{offset},@var{length}
  35128. @anchor{qXfer library list read}
  35129. Access the target's list of loaded libraries. @xref{Library List Format}.
  35130. The annex part of the generic @samp{qXfer} packet must be empty
  35131. (@pxref{qXfer read}).
  35132. Targets which maintain a list of libraries in the program's memory do
  35133. not need to implement this packet; it is designed for platforms where
  35134. the operating system manages the list of loaded libraries.
  35135. This packet is not probed by default; the remote stub must request it,
  35136. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35137. @item qXfer:libraries-svr4:read:@var{annex}:@var{offset},@var{length}
  35138. @anchor{qXfer svr4 library list read}
  35139. Access the target's list of loaded libraries when the target is an SVR4
  35140. platform. @xref{Library List Format for SVR4 Targets}. The annex part
  35141. of the generic @samp{qXfer} packet must be empty unless the remote
  35142. stub indicated it supports the augmented form of this packet
  35143. by supplying an appropriate @samp{qSupported} response
  35144. (@pxref{qXfer read}, @ref{qSupported}).
  35145. This packet is optional for better performance on SVR4 targets.
  35146. @value{GDBN} uses memory read packets to read the SVR4 library list otherwise.
  35147. This packet is not probed by default; the remote stub must request it,
  35148. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35149. If the remote stub indicates it supports the augmented form of this
  35150. packet then the annex part of the generic @samp{qXfer} packet may
  35151. contain a semicolon-separated list of @samp{@var{name}=@var{value}}
  35152. arguments. The currently supported arguments are:
  35153. @table @code
  35154. @item start=@var{address}
  35155. A hexadecimal number specifying the address of the @samp{struct
  35156. link_map} to start reading the library list from. If unset or zero
  35157. then the first @samp{struct link_map} in the library list will be
  35158. chosen as the starting point.
  35159. @item prev=@var{address}
  35160. A hexadecimal number specifying the address of the @samp{struct
  35161. link_map} immediately preceding the @samp{struct link_map}
  35162. specified by the @samp{start} argument. If unset or zero then
  35163. the remote stub will expect that no @samp{struct link_map}
  35164. exists prior to the starting point.
  35165. @end table
  35166. Arguments that are not understood by the remote stub will be silently
  35167. ignored.
  35168. @item qXfer:memory-map:read::@var{offset},@var{length}
  35169. @anchor{qXfer memory map read}
  35170. Access the target's @dfn{memory-map}. @xref{Memory Map Format}. The
  35171. annex part of the generic @samp{qXfer} packet must be empty
  35172. (@pxref{qXfer read}).
  35173. This packet is not probed by default; the remote stub must request it,
  35174. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35175. @item qXfer:sdata:read::@var{offset},@var{length}
  35176. @anchor{qXfer sdata read}
  35177. Read contents of the extra collected static tracepoint marker
  35178. information. The annex part of the generic @samp{qXfer} packet must
  35179. be empty (@pxref{qXfer read}). @xref{Tracepoint Actions,,Tracepoint
  35180. Action Lists}.
  35181. This packet is not probed by default; the remote stub must request it,
  35182. by supplying an appropriate @samp{qSupported} response
  35183. (@pxref{qSupported}).
  35184. @item qXfer:siginfo:read::@var{offset},@var{length}
  35185. @anchor{qXfer siginfo read}
  35186. Read contents of the extra signal information on the target
  35187. system. The annex part of the generic @samp{qXfer} packet must be
  35188. empty (@pxref{qXfer read}).
  35189. This packet is not probed by default; the remote stub must request it,
  35190. by supplying an appropriate @samp{qSupported} response
  35191. (@pxref{qSupported}).
  35192. @item qXfer:threads:read::@var{offset},@var{length}
  35193. @anchor{qXfer threads read}
  35194. Access the list of threads on target. @xref{Thread List Format}. The
  35195. annex part of the generic @samp{qXfer} packet must be empty
  35196. (@pxref{qXfer read}).
  35197. This packet is not probed by default; the remote stub must request it,
  35198. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35199. @item qXfer:traceframe-info:read::@var{offset},@var{length}
  35200. @anchor{qXfer traceframe info read}
  35201. Return a description of the current traceframe's contents.
  35202. @xref{Traceframe Info Format}. The annex part of the generic
  35203. @samp{qXfer} packet must be empty (@pxref{qXfer read}).
  35204. This packet is not probed by default; the remote stub must request it,
  35205. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35206. @item qXfer:uib:read:@var{pc}:@var{offset},@var{length}
  35207. @anchor{qXfer unwind info block}
  35208. Return the unwind information block for @var{pc}. This packet is used
  35209. on OpenVMS/ia64 to ask the kernel unwind information.
  35210. This packet is not probed by default.
  35211. @item qXfer:fdpic:read:@var{annex}:@var{offset},@var{length}
  35212. @anchor{qXfer fdpic loadmap read}
  35213. Read contents of @code{loadmap}s on the target system. The
  35214. annex, either @samp{exec} or @samp{interp}, specifies which @code{loadmap},
  35215. executable @code{loadmap} or interpreter @code{loadmap} to read.
  35216. This packet is not probed by default; the remote stub must request it,
  35217. by supplying an appropriate @samp{qSupported} response (@pxref{qSupported}).
  35218. @item qXfer:osdata:read::@var{offset},@var{length}
  35219. @anchor{qXfer osdata read}
  35220. Access the target's @dfn{operating system information}.
  35221. @xref{Operating System Information}.
  35222. @end table
  35223. @item qXfer:@var{object}:write:@var{annex}:@var{offset}:@var{data}@dots{}
  35224. @cindex write data into object, remote request
  35225. @anchor{qXfer write}
  35226. Write uninterpreted bytes into the target's special data area
  35227. identified by the keyword @var{object}, starting at @var{offset} bytes
  35228. into the data. The binary-encoded data (@pxref{Binary Data}) to be
  35229. written is given by @var{data}@dots{}. The content and encoding of @var{annex}
  35230. is specific to @var{object}; it can supply additional details about what data
  35231. to access.
  35232. Reply:
  35233. @table @samp
  35234. @item @var{nn}
  35235. @var{nn} (hex encoded) is the number of bytes written.
  35236. This may be fewer bytes than supplied in the request.
  35237. @item E00
  35238. The request was malformed, or @var{annex} was invalid.
  35239. @item E @var{nn}
  35240. The offset was invalid, or there was an error encountered writing the data.
  35241. The @var{nn} part is a hex-encoded @code{errno} value.
  35242. @item @w{}
  35243. An empty reply indicates the @var{object} string was not
  35244. recognized by the stub, or that the object does not support writing.
  35245. @end table
  35246. Here are the specific requests of this form defined so far. All the
  35247. @samp{qXfer:@var{object}:write:@dots{}} requests use the same reply
  35248. formats, listed above.
  35249. @table @samp
  35250. @item qXfer:siginfo:write::@var{offset}:@var{data}@dots{}
  35251. @anchor{qXfer siginfo write}
  35252. Write @var{data} to the extra signal information on the target system.
  35253. The annex part of the generic @samp{qXfer} packet must be
  35254. empty (@pxref{qXfer write}).
  35255. This packet is not probed by default; the remote stub must request it,
  35256. by supplying an appropriate @samp{qSupported} response
  35257. (@pxref{qSupported}).
  35258. @end table
  35259. @item qXfer:@var{object}:@var{operation}:@dots{}
  35260. Requests of this form may be added in the future. When a stub does
  35261. not recognize the @var{object} keyword, or its support for
  35262. @var{object} does not recognize the @var{operation} keyword, the stub
  35263. must respond with an empty packet.
  35264. @item qAttached:@var{pid}
  35265. @cindex query attached, remote request
  35266. @cindex @samp{qAttached} packet
  35267. Return an indication of whether the remote server attached to an
  35268. existing process or created a new process. When the multiprocess
  35269. protocol extensions are supported (@pxref{multiprocess extensions}),
  35270. @var{pid} is an integer in hexadecimal format identifying the target
  35271. process. Otherwise, @value{GDBN} will omit the @var{pid} field and
  35272. the query packet will be simplified as @samp{qAttached}.
  35273. This query is used, for example, to know whether the remote process
  35274. should be detached or killed when a @value{GDBN} session is ended with
  35275. the @code{quit} command.
  35276. Reply:
  35277. @table @samp
  35278. @item 1
  35279. The remote server attached to an existing process.
  35280. @item 0
  35281. The remote server created a new process.
  35282. @item E @var{NN}
  35283. A badly formed request or an error was encountered.
  35284. @end table
  35285. @item Qbtrace:bts
  35286. Enable branch tracing for the current thread using Branch Trace Store.
  35287. Reply:
  35288. @table @samp
  35289. @item OK
  35290. Branch tracing has been enabled.
  35291. @item E.errtext
  35292. A badly formed request or an error was encountered.
  35293. @end table
  35294. @item Qbtrace:pt
  35295. Enable branch tracing for the current thread using Intel Processor Trace.
  35296. Reply:
  35297. @table @samp
  35298. @item OK
  35299. Branch tracing has been enabled.
  35300. @item E.errtext
  35301. A badly formed request or an error was encountered.
  35302. @end table
  35303. @item Qbtrace:off
  35304. Disable branch tracing for the current thread.
  35305. Reply:
  35306. @table @samp
  35307. @item OK
  35308. Branch tracing has been disabled.
  35309. @item E.errtext
  35310. A badly formed request or an error was encountered.
  35311. @end table
  35312. @item Qbtrace-conf:bts:size=@var{value}
  35313. Set the requested ring buffer size for new threads that use the
  35314. btrace recording method in bts format.
  35315. Reply:
  35316. @table @samp
  35317. @item OK
  35318. The ring buffer size has been set.
  35319. @item E.errtext
  35320. A badly formed request or an error was encountered.
  35321. @end table
  35322. @item Qbtrace-conf:pt:size=@var{value}
  35323. Set the requested ring buffer size for new threads that use the
  35324. btrace recording method in pt format.
  35325. Reply:
  35326. @table @samp
  35327. @item OK
  35328. The ring buffer size has been set.
  35329. @item E.errtext
  35330. A badly formed request or an error was encountered.
  35331. @end table
  35332. @end table
  35333. @node Architecture-Specific Protocol Details
  35334. @section Architecture-Specific Protocol Details
  35335. This section describes how the remote protocol is applied to specific
  35336. target architectures. Also see @ref{Standard Target Features}, for
  35337. details of XML target descriptions for each architecture.
  35338. @menu
  35339. * ARM-Specific Protocol Details::
  35340. * MIPS-Specific Protocol Details::
  35341. @end menu
  35342. @node ARM-Specific Protocol Details
  35343. @subsection @acronym{ARM}-specific Protocol Details
  35344. @menu
  35345. * ARM Breakpoint Kinds::
  35346. * ARM Memory Tag Types::
  35347. @end menu
  35348. @node ARM Breakpoint Kinds
  35349. @subsubsection @acronym{ARM} Breakpoint Kinds
  35350. @cindex breakpoint kinds, @acronym{ARM}
  35351. These breakpoint kinds are defined for the @samp{Z0} and @samp{Z1} packets.
  35352. @table @r
  35353. @item 2
  35354. 16-bit Thumb mode breakpoint.
  35355. @item 3
  35356. 32-bit Thumb mode (Thumb-2) breakpoint.
  35357. @item 4
  35358. 32-bit @acronym{ARM} mode breakpoint.
  35359. @end table
  35360. @node ARM Memory Tag Types
  35361. @subsubsection @acronym{ARM} Memory Tag Types
  35362. @cindex memory tag types, @acronym{ARM}
  35363. These memory tag types are defined for the @samp{qMemTag} and @samp{QMemTag}
  35364. packets.
  35365. @table @r
  35366. @item 0
  35367. MTE logical tag
  35368. @item 1
  35369. MTE allocation tag
  35370. @end table
  35371. @node MIPS-Specific Protocol Details
  35372. @subsection @acronym{MIPS}-specific Protocol Details
  35373. @menu
  35374. * MIPS Register packet Format::
  35375. * MIPS Breakpoint Kinds::
  35376. @end menu
  35377. @node MIPS Register packet Format
  35378. @subsubsection @acronym{MIPS} Register Packet Format
  35379. @cindex register packet format, @acronym{MIPS}
  35380. The following @code{g}/@code{G} packets have previously been defined.
  35381. In the below, some thirty-two bit registers are transferred as
  35382. sixty-four bits. Those registers should be zero/sign extended (which?)
  35383. to fill the space allocated. Register bytes are transferred in target
  35384. byte order. The two nibbles within a register byte are transferred
  35385. most-significant -- least-significant.
  35386. @table @r
  35387. @item MIPS32
  35388. All registers are transferred as thirty-two bit quantities in the order:
  35389. 32 general-purpose; sr; lo; hi; bad; cause; pc; 32 floating-point
  35390. registers; fsr; fir; fp.
  35391. @item MIPS64
  35392. All registers are transferred as sixty-four bit quantities (including
  35393. thirty-two bit registers such as @code{sr}). The ordering is the same
  35394. as @code{MIPS32}.
  35395. @end table
  35396. @node MIPS Breakpoint Kinds
  35397. @subsubsection @acronym{MIPS} Breakpoint Kinds
  35398. @cindex breakpoint kinds, @acronym{MIPS}
  35399. These breakpoint kinds are defined for the @samp{Z0} and @samp{Z1} packets.
  35400. @table @r
  35401. @item 2
  35402. 16-bit @acronym{MIPS16} mode breakpoint.
  35403. @item 3
  35404. 16-bit @acronym{microMIPS} mode breakpoint.
  35405. @item 4
  35406. 32-bit standard @acronym{MIPS} mode breakpoint.
  35407. @item 5
  35408. 32-bit @acronym{microMIPS} mode breakpoint.
  35409. @end table
  35410. @node Tracepoint Packets
  35411. @section Tracepoint Packets
  35412. @cindex tracepoint packets
  35413. @cindex packets, tracepoint
  35414. Here we describe the packets @value{GDBN} uses to implement
  35415. tracepoints (@pxref{Tracepoints}).
  35416. @table @samp
  35417. @item QTDP:@var{n}:@var{addr}:@var{ena}:@var{step}:@var{pass}[:F@var{flen}][:X@var{len},@var{bytes}]@r{[}-@r{]}
  35418. @cindex @samp{QTDP} packet
  35419. Create a new tracepoint, number @var{n}, at @var{addr}. If @var{ena}
  35420. is @samp{E}, then the tracepoint is enabled; if it is @samp{D}, then
  35421. the tracepoint is disabled. The @var{step} gives the tracepoint's step
  35422. count, and @var{pass} gives its pass count. If an @samp{F} is present,
  35423. then the tracepoint is to be a fast tracepoint, and the @var{flen} is
  35424. the number of bytes that the target should copy elsewhere to make room
  35425. for the tracepoint. If an @samp{X} is present, it introduces a
  35426. tracepoint condition, which consists of a hexadecimal length, followed
  35427. by a comma and hex-encoded bytes, in a manner similar to action
  35428. encodings as described below. If the trailing @samp{-} is present,
  35429. further @samp{QTDP} packets will follow to specify this tracepoint's
  35430. actions.
  35431. Replies:
  35432. @table @samp
  35433. @item OK
  35434. The packet was understood and carried out.
  35435. @item qRelocInsn
  35436. @xref{Tracepoint Packets,,Relocate instruction reply packet}.
  35437. @item @w{}
  35438. The packet was not recognized.
  35439. @end table
  35440. @item QTDP:-@var{n}:@var{addr}:@r{[}S@r{]}@var{action}@dots{}@r{[}-@r{]}
  35441. Define actions to be taken when a tracepoint is hit. The @var{n} and
  35442. @var{addr} must be the same as in the initial @samp{QTDP} packet for
  35443. this tracepoint. This packet may only be sent immediately after
  35444. another @samp{QTDP} packet that ended with a @samp{-}. If the
  35445. trailing @samp{-} is present, further @samp{QTDP} packets will follow,
  35446. specifying more actions for this tracepoint.
  35447. In the series of action packets for a given tracepoint, at most one
  35448. can have an @samp{S} before its first @var{action}. If such a packet
  35449. is sent, it and the following packets define ``while-stepping''
  35450. actions. Any prior packets define ordinary actions --- that is, those
  35451. taken when the tracepoint is first hit. If no action packet has an
  35452. @samp{S}, then all the packets in the series specify ordinary
  35453. tracepoint actions.
  35454. The @samp{@var{action}@dots{}} portion of the packet is a series of
  35455. actions, concatenated without separators. Each action has one of the
  35456. following forms:
  35457. @table @samp
  35458. @item R @var{mask}
  35459. Collect the registers whose bits are set in @var{mask},
  35460. a hexadecimal number whose @var{i}'th bit is set if register number
  35461. @var{i} should be collected. (The least significant bit is numbered
  35462. zero.) Note that @var{mask} may be any number of digits long; it may
  35463. not fit in a 32-bit word.
  35464. @item M @var{basereg},@var{offset},@var{len}
  35465. Collect @var{len} bytes of memory starting at the address in register
  35466. number @var{basereg}, plus @var{offset}. If @var{basereg} is
  35467. @samp{-1}, then the range has a fixed address: @var{offset} is the
  35468. address of the lowest byte to collect. The @var{basereg},
  35469. @var{offset}, and @var{len} parameters are all unsigned hexadecimal
  35470. values (the @samp{-1} value for @var{basereg} is a special case).
  35471. @item X @var{len},@var{expr}
  35472. Evaluate @var{expr}, whose length is @var{len}, and collect memory as
  35473. it directs. The agent expression @var{expr} is as described in
  35474. @ref{Agent Expressions}. Each byte of the expression is encoded as a
  35475. two-digit hex number in the packet; @var{len} is the number of bytes
  35476. in the expression (and thus one-half the number of hex digits in the
  35477. packet).
  35478. @end table
  35479. Any number of actions may be packed together in a single @samp{QTDP}
  35480. packet, as long as the packet does not exceed the maximum packet
  35481. length (400 bytes, for many stubs). There may be only one @samp{R}
  35482. action per tracepoint, and it must precede any @samp{M} or @samp{X}
  35483. actions. Any registers referred to by @samp{M} and @samp{X} actions
  35484. must be collected by a preceding @samp{R} action. (The
  35485. ``while-stepping'' actions are treated as if they were attached to a
  35486. separate tracepoint, as far as these restrictions are concerned.)
  35487. Replies:
  35488. @table @samp
  35489. @item OK
  35490. The packet was understood and carried out.
  35491. @item qRelocInsn
  35492. @xref{Tracepoint Packets,,Relocate instruction reply packet}.
  35493. @item @w{}
  35494. The packet was not recognized.
  35495. @end table
  35496. @item QTDPsrc:@var{n}:@var{addr}:@var{type}:@var{start}:@var{slen}:@var{bytes}
  35497. @cindex @samp{QTDPsrc} packet
  35498. Specify a source string of tracepoint @var{n} at address @var{addr}.
  35499. This is useful to get accurate reproduction of the tracepoints
  35500. originally downloaded at the beginning of the trace run. The @var{type}
  35501. is the name of the tracepoint part, such as @samp{cond} for the
  35502. tracepoint's conditional expression (see below for a list of types), while
  35503. @var{bytes} is the string, encoded in hexadecimal.
  35504. @var{start} is the offset of the @var{bytes} within the overall source
  35505. string, while @var{slen} is the total length of the source string.
  35506. This is intended for handling source strings that are longer than will
  35507. fit in a single packet.
  35508. @c Add detailed example when this info is moved into a dedicated
  35509. @c tracepoint descriptions section.
  35510. The available string types are @samp{at} for the location,
  35511. @samp{cond} for the conditional, and @samp{cmd} for an action command.
  35512. @value{GDBN} sends a separate packet for each command in the action
  35513. list, in the same order in which the commands are stored in the list.
  35514. The target does not need to do anything with source strings except
  35515. report them back as part of the replies to the @samp{qTfP}/@samp{qTsP}
  35516. query packets.
  35517. Although this packet is optional, and @value{GDBN} will only send it
  35518. if the target replies with @samp{TracepointSource} @xref{General
  35519. Query Packets}, it makes both disconnected tracing and trace files
  35520. much easier to use. Otherwise the user must be careful that the
  35521. tracepoints in effect while looking at trace frames are identical to
  35522. the ones in effect during the trace run; even a small discrepancy
  35523. could cause @samp{tdump} not to work, or a particular trace frame not
  35524. be found.
  35525. @item QTDV:@var{n}:@var{value}:@var{builtin}:@var{name}
  35526. @cindex define trace state variable, remote request
  35527. @cindex @samp{QTDV} packet
  35528. Create a new trace state variable, number @var{n}, with an initial
  35529. value of @var{value}, which is a 64-bit signed integer. Both @var{n}
  35530. and @var{value} are encoded as hexadecimal values. @value{GDBN} has
  35531. the option of not using this packet for initial values of zero; the
  35532. target should simply create the trace state variables as they are
  35533. mentioned in expressions. The value @var{builtin} should be 1 (one)
  35534. if the trace state variable is builtin and 0 (zero) if it is not builtin.
  35535. @value{GDBN} only sets @var{builtin} to 1 if a previous @samp{qTfV} or
  35536. @samp{qTsV} packet had it set. The contents of @var{name} is the
  35537. hex-encoded name (without the leading @samp{$}) of the trace state
  35538. variable.
  35539. @item QTFrame:@var{n}
  35540. @cindex @samp{QTFrame} packet
  35541. Select the @var{n}'th tracepoint frame from the buffer, and use the
  35542. register and memory contents recorded there to answer subsequent
  35543. request packets from @value{GDBN}.
  35544. A successful reply from the stub indicates that the stub has found the
  35545. requested frame. The response is a series of parts, concatenated
  35546. without separators, describing the frame we selected. Each part has
  35547. one of the following forms:
  35548. @table @samp
  35549. @item F @var{f}
  35550. The selected frame is number @var{n} in the trace frame buffer;
  35551. @var{f} is a hexadecimal number. If @var{f} is @samp{-1}, then there
  35552. was no frame matching the criteria in the request packet.
  35553. @item T @var{t}
  35554. The selected trace frame records a hit of tracepoint number @var{t};
  35555. @var{t} is a hexadecimal number.
  35556. @end table
  35557. @item QTFrame:pc:@var{addr}
  35558. Like @samp{QTFrame:@var{n}}, but select the first tracepoint frame after the
  35559. currently selected frame whose PC is @var{addr};
  35560. @var{addr} is a hexadecimal number.
  35561. @item QTFrame:tdp:@var{t}
  35562. Like @samp{QTFrame:@var{n}}, but select the first tracepoint frame after the
  35563. currently selected frame that is a hit of tracepoint @var{t}; @var{t}
  35564. is a hexadecimal number.
  35565. @item QTFrame:range:@var{start}:@var{end}
  35566. Like @samp{QTFrame:@var{n}}, but select the first tracepoint frame after the
  35567. currently selected frame whose PC is between @var{start} (inclusive)
  35568. and @var{end} (inclusive); @var{start} and @var{end} are hexadecimal
  35569. numbers.
  35570. @item QTFrame:outside:@var{start}:@var{end}
  35571. Like @samp{QTFrame:range:@var{start}:@var{end}}, but select the first
  35572. frame @emph{outside} the given range of addresses (exclusive).
  35573. @item qTMinFTPILen
  35574. @cindex @samp{qTMinFTPILen} packet
  35575. This packet requests the minimum length of instruction at which a fast
  35576. tracepoint (@pxref{Set Tracepoints}) may be placed. For instance, on
  35577. the 32-bit x86 architecture, it is possible to use a 4-byte jump, but
  35578. it depends on the target system being able to create trampolines in
  35579. the first 64K of memory, which might or might not be possible for that
  35580. system. So the reply to this packet will be 4 if it is able to
  35581. arrange for that.
  35582. Replies:
  35583. @table @samp
  35584. @item 0
  35585. The minimum instruction length is currently unknown.
  35586. @item @var{length}
  35587. The minimum instruction length is @var{length}, where @var{length}
  35588. is a hexadecimal number greater or equal to 1. A reply
  35589. of 1 means that a fast tracepoint may be placed on any instruction
  35590. regardless of size.
  35591. @item E
  35592. An error has occurred.
  35593. @item @w{}
  35594. An empty reply indicates that the request is not supported by the stub.
  35595. @end table
  35596. @item QTStart
  35597. @cindex @samp{QTStart} packet
  35598. Begin the tracepoint experiment. Begin collecting data from
  35599. tracepoint hits in the trace frame buffer. This packet supports the
  35600. @samp{qRelocInsn} reply (@pxref{Tracepoint Packets,,Relocate
  35601. instruction reply packet}).
  35602. @item QTStop
  35603. @cindex @samp{QTStop} packet
  35604. End the tracepoint experiment. Stop collecting trace frames.
  35605. @item QTEnable:@var{n}:@var{addr}
  35606. @anchor{QTEnable}
  35607. @cindex @samp{QTEnable} packet
  35608. Enable tracepoint @var{n} at address @var{addr} in a started tracepoint
  35609. experiment. If the tracepoint was previously disabled, then collection
  35610. of data from it will resume.
  35611. @item QTDisable:@var{n}:@var{addr}
  35612. @anchor{QTDisable}
  35613. @cindex @samp{QTDisable} packet
  35614. Disable tracepoint @var{n} at address @var{addr} in a started tracepoint
  35615. experiment. No more data will be collected from the tracepoint unless
  35616. @samp{QTEnable:@var{n}:@var{addr}} is subsequently issued.
  35617. @item QTinit
  35618. @cindex @samp{QTinit} packet
  35619. Clear the table of tracepoints, and empty the trace frame buffer.
  35620. @item QTro:@var{start1},@var{end1}:@var{start2},@var{end2}:@dots{}
  35621. @cindex @samp{QTro} packet
  35622. Establish the given ranges of memory as ``transparent''. The stub
  35623. will answer requests for these ranges from memory's current contents,
  35624. if they were not collected as part of the tracepoint hit.
  35625. @value{GDBN} uses this to mark read-only regions of memory, like those
  35626. containing program code. Since these areas never change, they should
  35627. still have the same contents they did when the tracepoint was hit, so
  35628. there's no reason for the stub to refuse to provide their contents.
  35629. @item QTDisconnected:@var{value}
  35630. @cindex @samp{QTDisconnected} packet
  35631. Set the choice to what to do with the tracing run when @value{GDBN}
  35632. disconnects from the target. A @var{value} of 1 directs the target to
  35633. continue the tracing run, while 0 tells the target to stop tracing if
  35634. @value{GDBN} is no longer in the picture.
  35635. @item qTStatus
  35636. @cindex @samp{qTStatus} packet
  35637. Ask the stub if there is a trace experiment running right now.
  35638. The reply has the form:
  35639. @table @samp
  35640. @item T@var{running}@r{[};@var{field}@r{]}@dots{}
  35641. @var{running} is a single digit @code{1} if the trace is presently
  35642. running, or @code{0} if not. It is followed by semicolon-separated
  35643. optional fields that an agent may use to report additional status.
  35644. @end table
  35645. If the trace is not running, the agent may report any of several
  35646. explanations as one of the optional fields:
  35647. @table @samp
  35648. @item tnotrun:0
  35649. No trace has been run yet.
  35650. @item tstop[:@var{text}]:0
  35651. The trace was stopped by a user-originated stop command. The optional
  35652. @var{text} field is a user-supplied string supplied as part of the
  35653. stop command (for instance, an explanation of why the trace was
  35654. stopped manually). It is hex-encoded.
  35655. @item tfull:0
  35656. The trace stopped because the trace buffer filled up.
  35657. @item tdisconnected:0
  35658. The trace stopped because @value{GDBN} disconnected from the target.
  35659. @item tpasscount:@var{tpnum}
  35660. The trace stopped because tracepoint @var{tpnum} exceeded its pass count.
  35661. @item terror:@var{text}:@var{tpnum}
  35662. The trace stopped because tracepoint @var{tpnum} had an error. The
  35663. string @var{text} is available to describe the nature of the error
  35664. (for instance, a divide by zero in the condition expression); it
  35665. is hex encoded.
  35666. @item tunknown:0
  35667. The trace stopped for some other reason.
  35668. @end table
  35669. Additional optional fields supply statistical and other information.
  35670. Although not required, they are extremely useful for users monitoring
  35671. the progress of a trace run. If a trace has stopped, and these
  35672. numbers are reported, they must reflect the state of the just-stopped
  35673. trace.
  35674. @table @samp
  35675. @item tframes:@var{n}
  35676. The number of trace frames in the buffer.
  35677. @item tcreated:@var{n}
  35678. The total number of trace frames created during the run. This may
  35679. be larger than the trace frame count, if the buffer is circular.
  35680. @item tsize:@var{n}
  35681. The total size of the trace buffer, in bytes.
  35682. @item tfree:@var{n}
  35683. The number of bytes still unused in the buffer.
  35684. @item circular:@var{n}
  35685. The value of the circular trace buffer flag. @code{1} means that the
  35686. trace buffer is circular and old trace frames will be discarded if
  35687. necessary to make room, @code{0} means that the trace buffer is linear
  35688. and may fill up.
  35689. @item disconn:@var{n}
  35690. The value of the disconnected tracing flag. @code{1} means that
  35691. tracing will continue after @value{GDBN} disconnects, @code{0} means
  35692. that the trace run will stop.
  35693. @end table
  35694. @item qTP:@var{tp}:@var{addr}
  35695. @cindex tracepoint status, remote request
  35696. @cindex @samp{qTP} packet
  35697. Ask the stub for the current state of tracepoint number @var{tp} at
  35698. address @var{addr}.
  35699. Replies:
  35700. @table @samp
  35701. @item V@var{hits}:@var{usage}
  35702. The tracepoint has been hit @var{hits} times so far during the trace
  35703. run, and accounts for @var{usage} in the trace buffer. Note that
  35704. @code{while-stepping} steps are not counted as separate hits, but the
  35705. steps' space consumption is added into the usage number.
  35706. @end table
  35707. @item qTV:@var{var}
  35708. @cindex trace state variable value, remote request
  35709. @cindex @samp{qTV} packet
  35710. Ask the stub for the value of the trace state variable number @var{var}.
  35711. Replies:
  35712. @table @samp
  35713. @item V@var{value}
  35714. The value of the variable is @var{value}. This will be the current
  35715. value of the variable if the user is examining a running target, or a
  35716. saved value if the variable was collected in the trace frame that the
  35717. user is looking at. Note that multiple requests may result in
  35718. different reply values, such as when requesting values while the
  35719. program is running.
  35720. @item U
  35721. The value of the variable is unknown. This would occur, for example,
  35722. if the user is examining a trace frame in which the requested variable
  35723. was not collected.
  35724. @end table
  35725. @item qTfP
  35726. @cindex @samp{qTfP} packet
  35727. @itemx qTsP
  35728. @cindex @samp{qTsP} packet
  35729. These packets request data about tracepoints that are being used by
  35730. the target. @value{GDBN} sends @code{qTfP} to get the first piece
  35731. of data, and multiple @code{qTsP} to get additional pieces. Replies
  35732. to these packets generally take the form of the @code{QTDP} packets
  35733. that define tracepoints. (FIXME add detailed syntax)
  35734. @item qTfV
  35735. @cindex @samp{qTfV} packet
  35736. @itemx qTsV
  35737. @cindex @samp{qTsV} packet
  35738. These packets request data about trace state variables that are on the
  35739. target. @value{GDBN} sends @code{qTfV} to get the first vari of data,
  35740. and multiple @code{qTsV} to get additional variables. Replies to
  35741. these packets follow the syntax of the @code{QTDV} packets that define
  35742. trace state variables.
  35743. @item qTfSTM
  35744. @itemx qTsSTM
  35745. @anchor{qTfSTM}
  35746. @anchor{qTsSTM}
  35747. @cindex @samp{qTfSTM} packet
  35748. @cindex @samp{qTsSTM} packet
  35749. These packets request data about static tracepoint markers that exist
  35750. in the target program. @value{GDBN} sends @code{qTfSTM} to get the
  35751. first piece of data, and multiple @code{qTsSTM} to get additional
  35752. pieces. Replies to these packets take the following form:
  35753. Reply:
  35754. @table @samp
  35755. @item m @var{address}:@var{id}:@var{extra}
  35756. A single marker
  35757. @item m @var{address}:@var{id}:@var{extra},@var{address}:@var{id}:@var{extra}@dots{}
  35758. a comma-separated list of markers
  35759. @item l
  35760. (lower case letter @samp{L}) denotes end of list.
  35761. @item E @var{nn}
  35762. An error occurred. The error number @var{nn} is given as hex digits.
  35763. @item @w{}
  35764. An empty reply indicates that the request is not supported by the
  35765. stub.
  35766. @end table
  35767. The @var{address} is encoded in hex;
  35768. @var{id} and @var{extra} are strings encoded in hex.
  35769. In response to each query, the target will reply with a list of one or
  35770. more markers, separated by commas. @value{GDBN} will respond to each
  35771. reply with a request for more markers (using the @samp{qs} form of the
  35772. query), until the target responds with @samp{l} (lower-case ell, for
  35773. @dfn{last}).
  35774. @item qTSTMat:@var{address}
  35775. @anchor{qTSTMat}
  35776. @cindex @samp{qTSTMat} packet
  35777. This packets requests data about static tracepoint markers in the
  35778. target program at @var{address}. Replies to this packet follow the
  35779. syntax of the @samp{qTfSTM} and @code{qTsSTM} packets that list static
  35780. tracepoint markers.
  35781. @item QTSave:@var{filename}
  35782. @cindex @samp{QTSave} packet
  35783. This packet directs the target to save trace data to the file name
  35784. @var{filename} in the target's filesystem. The @var{filename} is encoded
  35785. as a hex string; the interpretation of the file name (relative vs
  35786. absolute, wild cards, etc) is up to the target.
  35787. @item qTBuffer:@var{offset},@var{len}
  35788. @cindex @samp{qTBuffer} packet
  35789. Return up to @var{len} bytes of the current contents of trace buffer,
  35790. starting at @var{offset}. The trace buffer is treated as if it were
  35791. a contiguous collection of traceframes, as per the trace file format.
  35792. The reply consists as many hex-encoded bytes as the target can deliver
  35793. in a packet; it is not an error to return fewer than were asked for.
  35794. A reply consisting of just @code{l} indicates that no bytes are
  35795. available.
  35796. @item QTBuffer:circular:@var{value}
  35797. This packet directs the target to use a circular trace buffer if
  35798. @var{value} is 1, or a linear buffer if the value is 0.
  35799. @item QTBuffer:size:@var{size}
  35800. @anchor{QTBuffer-size}
  35801. @cindex @samp{QTBuffer size} packet
  35802. This packet directs the target to make the trace buffer be of size
  35803. @var{size} if possible. A value of @code{-1} tells the target to
  35804. use whatever size it prefers.
  35805. @item QTNotes:@r{[}@var{type}:@var{text}@r{]}@r{[};@var{type}:@var{text}@r{]}@dots{}
  35806. @cindex @samp{QTNotes} packet
  35807. This packet adds optional textual notes to the trace run. Allowable
  35808. types include @code{user}, @code{notes}, and @code{tstop}, the
  35809. @var{text} fields are arbitrary strings, hex-encoded.
  35810. @end table
  35811. @subsection Relocate instruction reply packet
  35812. When installing fast tracepoints in memory, the target may need to
  35813. relocate the instruction currently at the tracepoint address to a
  35814. different address in memory. For most instructions, a simple copy is
  35815. enough, but, for example, call instructions that implicitly push the
  35816. return address on the stack, and relative branches or other
  35817. PC-relative instructions require offset adjustment, so that the effect
  35818. of executing the instruction at a different address is the same as if
  35819. it had executed in the original location.
  35820. In response to several of the tracepoint packets, the target may also
  35821. respond with a number of intermediate @samp{qRelocInsn} request
  35822. packets before the final result packet, to have @value{GDBN} handle
  35823. this relocation operation. If a packet supports this mechanism, its
  35824. documentation will explicitly say so. See for example the above
  35825. descriptions for the @samp{QTStart} and @samp{QTDP} packets. The
  35826. format of the request is:
  35827. @table @samp
  35828. @item qRelocInsn:@var{from};@var{to}
  35829. This requests @value{GDBN} to copy instruction at address @var{from}
  35830. to address @var{to}, possibly adjusted so that executing the
  35831. instruction at @var{to} has the same effect as executing it at
  35832. @var{from}. @value{GDBN} writes the adjusted instruction to target
  35833. memory starting at @var{to}.
  35834. @end table
  35835. Replies:
  35836. @table @samp
  35837. @item qRelocInsn:@var{adjusted_size}
  35838. Informs the stub the relocation is complete. The @var{adjusted_size} is
  35839. the length in bytes of resulting relocated instruction sequence.
  35840. @item E @var{NN}
  35841. A badly formed request was detected, or an error was encountered while
  35842. relocating the instruction.
  35843. @end table
  35844. @node Host I/O Packets
  35845. @section Host I/O Packets
  35846. @cindex Host I/O, remote protocol
  35847. @cindex file transfer, remote protocol
  35848. The @dfn{Host I/O} packets allow @value{GDBN} to perform I/O
  35849. operations on the far side of a remote link. For example, Host I/O is
  35850. used to upload and download files to a remote target with its own
  35851. filesystem. Host I/O uses the same constant values and data structure
  35852. layout as the target-initiated File-I/O protocol. However, the
  35853. Host I/O packets are structured differently. The target-initiated
  35854. protocol relies on target memory to store parameters and buffers.
  35855. Host I/O requests are initiated by @value{GDBN}, and the
  35856. target's memory is not involved. @xref{File-I/O Remote Protocol
  35857. Extension}, for more details on the target-initiated protocol.
  35858. The Host I/O request packets all encode a single operation along with
  35859. its arguments. They have this format:
  35860. @table @samp
  35861. @item vFile:@var{operation}: @var{parameter}@dots{}
  35862. @var{operation} is the name of the particular request; the target
  35863. should compare the entire packet name up to the second colon when checking
  35864. for a supported operation. The format of @var{parameter} depends on
  35865. the operation. Numbers are always passed in hexadecimal. Negative
  35866. numbers have an explicit minus sign (i.e.@: two's complement is not
  35867. used). Strings (e.g.@: filenames) are encoded as a series of
  35868. hexadecimal bytes. The last argument to a system call may be a
  35869. buffer of escaped binary data (@pxref{Binary Data}).
  35870. @end table
  35871. The valid responses to Host I/O packets are:
  35872. @table @samp
  35873. @item F @var{result} [, @var{errno}] [; @var{attachment}]
  35874. @var{result} is the integer value returned by this operation, usually
  35875. non-negative for success and -1 for errors. If an error has occured,
  35876. @var{errno} will be included in the result specifying a
  35877. value defined by the File-I/O protocol (@pxref{Errno Values}). For
  35878. operations which return data, @var{attachment} supplies the data as a
  35879. binary buffer. Binary buffers in response packets are escaped in the
  35880. normal way (@pxref{Binary Data}). See the individual packet
  35881. documentation for the interpretation of @var{result} and
  35882. @var{attachment}.
  35883. @item @w{}
  35884. An empty response indicates that this operation is not recognized.
  35885. @end table
  35886. These are the supported Host I/O operations:
  35887. @table @samp
  35888. @item vFile:open: @var{filename}, @var{flags}, @var{mode}
  35889. Open a file at @var{filename} and return a file descriptor for it, or
  35890. return -1 if an error occurs. The @var{filename} is a string,
  35891. @var{flags} is an integer indicating a mask of open flags
  35892. (@pxref{Open Flags}), and @var{mode} is an integer indicating a mask
  35893. of mode bits to use if the file is created (@pxref{mode_t Values}).
  35894. @xref{open}, for details of the open flags and mode values.
  35895. @item vFile:close: @var{fd}
  35896. Close the open file corresponding to @var{fd} and return 0, or
  35897. -1 if an error occurs.
  35898. @item vFile:pread: @var{fd}, @var{count}, @var{offset}
  35899. Read data from the open file corresponding to @var{fd}. Up to
  35900. @var{count} bytes will be read from the file, starting at @var{offset}
  35901. relative to the start of the file. The target may read fewer bytes;
  35902. common reasons include packet size limits and an end-of-file
  35903. condition. The number of bytes read is returned. Zero should only be
  35904. returned for a successful read at the end of the file, or if
  35905. @var{count} was zero.
  35906. The data read should be returned as a binary attachment on success.
  35907. If zero bytes were read, the response should include an empty binary
  35908. attachment (i.e.@: a trailing semicolon). The return value is the
  35909. number of target bytes read; the binary attachment may be longer if
  35910. some characters were escaped.
  35911. @item vFile:pwrite: @var{fd}, @var{offset}, @var{data}
  35912. Write @var{data} (a binary buffer) to the open file corresponding
  35913. to @var{fd}. Start the write at @var{offset} from the start of the
  35914. file. Unlike many @code{write} system calls, there is no
  35915. separate @var{count} argument; the length of @var{data} in the
  35916. packet is used. @samp{vFile:pwrite} returns the number of bytes written,
  35917. which may be shorter than the length of @var{data}, or -1 if an
  35918. error occurred.
  35919. @item vFile:fstat: @var{fd}
  35920. Get information about the open file corresponding to @var{fd}.
  35921. On success the information is returned as a binary attachment
  35922. and the return value is the size of this attachment in bytes.
  35923. If an error occurs the return value is -1. The format of the
  35924. returned binary attachment is as described in @ref{struct stat}.
  35925. @item vFile:unlink: @var{filename}
  35926. Delete the file at @var{filename} on the target. Return 0,
  35927. or -1 if an error occurs. The @var{filename} is a string.
  35928. @item vFile:readlink: @var{filename}
  35929. Read value of symbolic link @var{filename} on the target. Return
  35930. the number of bytes read, or -1 if an error occurs.
  35931. The data read should be returned as a binary attachment on success.
  35932. If zero bytes were read, the response should include an empty binary
  35933. attachment (i.e.@: a trailing semicolon). The return value is the
  35934. number of target bytes read; the binary attachment may be longer if
  35935. some characters were escaped.
  35936. @item vFile:setfs: @var{pid}
  35937. Select the filesystem on which @code{vFile} operations with
  35938. @var{filename} arguments will operate. This is required for
  35939. @value{GDBN} to be able to access files on remote targets where
  35940. the remote stub does not share a common filesystem with the
  35941. inferior(s).
  35942. If @var{pid} is nonzero, select the filesystem as seen by process
  35943. @var{pid}. If @var{pid} is zero, select the filesystem as seen by
  35944. the remote stub. Return 0 on success, or -1 if an error occurs.
  35945. If @code{vFile:setfs:} indicates success, the selected filesystem
  35946. remains selected until the next successful @code{vFile:setfs:}
  35947. operation.
  35948. @end table
  35949. @node Interrupts
  35950. @section Interrupts
  35951. @cindex interrupts (remote protocol)
  35952. @anchor{interrupting remote targets}
  35953. In all-stop mode, when a program on the remote target is running,
  35954. @value{GDBN} may attempt to interrupt it by sending a @samp{Ctrl-C},
  35955. @code{BREAK} or a @code{BREAK} followed by @code{g}, control of which
  35956. is specified via @value{GDBN}'s @samp{interrupt-sequence}.
  35957. The precise meaning of @code{BREAK} is defined by the transport
  35958. mechanism and may, in fact, be undefined. @value{GDBN} does not
  35959. currently define a @code{BREAK} mechanism for any of the network
  35960. interfaces except for TCP, in which case @value{GDBN} sends the
  35961. @code{telnet} BREAK sequence.
  35962. @samp{Ctrl-C}, on the other hand, is defined and implemented for all
  35963. transport mechanisms. It is represented by sending the single byte
  35964. @code{0x03} without any of the usual packet overhead described in
  35965. the Overview section (@pxref{Overview}). When a @code{0x03} byte is
  35966. transmitted as part of a packet, it is considered to be packet data
  35967. and does @emph{not} represent an interrupt. E.g., an @samp{X} packet
  35968. (@pxref{X packet}), used for binary downloads, may include an unescaped
  35969. @code{0x03} as part of its packet.
  35970. @code{BREAK} followed by @code{g} is also known as Magic SysRq g.
  35971. When Linux kernel receives this sequence from serial port,
  35972. it stops execution and connects to gdb.
  35973. In non-stop mode, because packet resumptions are asynchronous
  35974. (@pxref{vCont packet}), @value{GDBN} is always free to send a remote
  35975. command to the remote stub, even when the target is running. For that
  35976. reason, @value{GDBN} instead sends a regular packet (@pxref{vCtrlC
  35977. packet}) with the usual packet framing instead of the single byte
  35978. @code{0x03}.
  35979. Stubs are not required to recognize these interrupt mechanisms and the
  35980. precise meaning associated with receipt of the interrupt is
  35981. implementation defined. If the target supports debugging of multiple
  35982. threads and/or processes, it should attempt to interrupt all
  35983. currently-executing threads and processes.
  35984. If the stub is successful at interrupting the
  35985. running program, it should send one of the stop
  35986. reply packets (@pxref{Stop Reply Packets}) to @value{GDBN} as a result
  35987. of successfully stopping the program in all-stop mode, and a stop reply
  35988. for each stopped thread in non-stop mode.
  35989. Interrupts received while the
  35990. program is stopped are queued and the program will be interrupted when
  35991. it is resumed next time.
  35992. @node Notification Packets
  35993. @section Notification Packets
  35994. @cindex notification packets
  35995. @cindex packets, notification
  35996. The @value{GDBN} remote serial protocol includes @dfn{notifications},
  35997. packets that require no acknowledgment. Both the GDB and the stub
  35998. may send notifications (although the only notifications defined at
  35999. present are sent by the stub). Notifications carry information
  36000. without incurring the round-trip latency of an acknowledgment, and so
  36001. are useful for low-impact communications where occasional packet loss
  36002. is not a problem.
  36003. A notification packet has the form @samp{% @var{data} #
  36004. @var{checksum}}, where @var{data} is the content of the notification,
  36005. and @var{checksum} is a checksum of @var{data}, computed and formatted
  36006. as for ordinary @value{GDBN} packets. A notification's @var{data}
  36007. never contains @samp{$}, @samp{%} or @samp{#} characters. Upon
  36008. receiving a notification, the recipient sends no @samp{+} or @samp{-}
  36009. to acknowledge the notification's receipt or to report its corruption.
  36010. Every notification's @var{data} begins with a name, which contains no
  36011. colon characters, followed by a colon character.
  36012. Recipients should silently ignore corrupted notifications and
  36013. notifications they do not understand. Recipients should restart
  36014. timeout periods on receipt of a well-formed notification, whether or
  36015. not they understand it.
  36016. Senders should only send the notifications described here when this
  36017. protocol description specifies that they are permitted. In the
  36018. future, we may extend the protocol to permit existing notifications in
  36019. new contexts; this rule helps older senders avoid confusing newer
  36020. recipients.
  36021. (Older versions of @value{GDBN} ignore bytes received until they see
  36022. the @samp{$} byte that begins an ordinary packet, so new stubs may
  36023. transmit notifications without fear of confusing older clients. There
  36024. are no notifications defined for @value{GDBN} to send at the moment, but we
  36025. assume that most older stubs would ignore them, as well.)
  36026. Each notification is comprised of three parts:
  36027. @table @samp
  36028. @item @var{name}:@var{event}
  36029. The notification packet is sent by the side that initiates the
  36030. exchange (currently, only the stub does that), with @var{event}
  36031. carrying the specific information about the notification, and
  36032. @var{name} specifying the name of the notification.
  36033. @item @var{ack}
  36034. The acknowledge sent by the other side, usually @value{GDBN}, to
  36035. acknowledge the exchange and request the event.
  36036. @end table
  36037. The purpose of an asynchronous notification mechanism is to report to
  36038. @value{GDBN} that something interesting happened in the remote stub.
  36039. The remote stub may send notification @var{name}:@var{event}
  36040. at any time, but @value{GDBN} acknowledges the notification when
  36041. appropriate. The notification event is pending before @value{GDBN}
  36042. acknowledges. Only one notification at a time may be pending; if
  36043. additional events occur before @value{GDBN} has acknowledged the
  36044. previous notification, they must be queued by the stub for later
  36045. synchronous transmission in response to @var{ack} packets from
  36046. @value{GDBN}. Because the notification mechanism is unreliable,
  36047. the stub is permitted to resend a notification if it believes
  36048. @value{GDBN} may not have received it.
  36049. Specifically, notifications may appear when @value{GDBN} is not
  36050. otherwise reading input from the stub, or when @value{GDBN} is
  36051. expecting to read a normal synchronous response or a
  36052. @samp{+}/@samp{-} acknowledgment to a packet it has sent.
  36053. Notification packets are distinct from any other communication from
  36054. the stub so there is no ambiguity.
  36055. After receiving a notification, @value{GDBN} shall acknowledge it by
  36056. sending a @var{ack} packet as a regular, synchronous request to the
  36057. stub. Such acknowledgment is not required to happen immediately, as
  36058. @value{GDBN} is permitted to send other, unrelated packets to the
  36059. stub first, which the stub should process normally.
  36060. Upon receiving a @var{ack} packet, if the stub has other queued
  36061. events to report to @value{GDBN}, it shall respond by sending a
  36062. normal @var{event}. @value{GDBN} shall then send another @var{ack}
  36063. packet to solicit further responses; again, it is permitted to send
  36064. other, unrelated packets as well which the stub should process
  36065. normally.
  36066. If the stub receives a @var{ack} packet and there are no additional
  36067. @var{event} to report, the stub shall return an @samp{OK} response.
  36068. At this point, @value{GDBN} has finished processing a notification
  36069. and the stub has completed sending any queued events. @value{GDBN}
  36070. won't accept any new notifications until the final @samp{OK} is
  36071. received . If further notification events occur, the stub shall send
  36072. a new notification, @value{GDBN} shall accept the notification, and
  36073. the process shall be repeated.
  36074. The process of asynchronous notification can be illustrated by the
  36075. following example:
  36076. @smallexample
  36077. <- @code{%Stop:T0505:98e7ffbf;04:4ce6ffbf;08:b1b6e54c;thread:p7526.7526;core:0;}
  36078. @code{...}
  36079. -> @code{vStopped}
  36080. <- @code{T0505:68f37db7;04:40f37db7;08:63850408;thread:p7526.7528;core:0;}
  36081. -> @code{vStopped}
  36082. <- @code{T0505:68e3fdb6;04:40e3fdb6;08:63850408;thread:p7526.7529;core:0;}
  36083. -> @code{vStopped}
  36084. <- @code{OK}
  36085. @end smallexample
  36086. The following notifications are defined:
  36087. @multitable @columnfractions 0.12 0.12 0.38 0.38
  36088. @item Notification
  36089. @tab Ack
  36090. @tab Event
  36091. @tab Description
  36092. @item Stop
  36093. @tab vStopped
  36094. @tab @var{reply}. The @var{reply} has the form of a stop reply, as
  36095. described in @ref{Stop Reply Packets}. Refer to @ref{Remote Non-Stop},
  36096. for information on how these notifications are acknowledged by
  36097. @value{GDBN}.
  36098. @tab Report an asynchronous stop event in non-stop mode.
  36099. @end multitable
  36100. @node Remote Non-Stop
  36101. @section Remote Protocol Support for Non-Stop Mode
  36102. @value{GDBN}'s remote protocol supports non-stop debugging of
  36103. multi-threaded programs, as described in @ref{Non-Stop Mode}. If the stub
  36104. supports non-stop mode, it should report that to @value{GDBN} by including
  36105. @samp{QNonStop+} in its @samp{qSupported} response (@pxref{qSupported}).
  36106. @value{GDBN} typically sends a @samp{QNonStop} packet only when
  36107. establishing a new connection with the stub. Entering non-stop mode
  36108. does not alter the state of any currently-running threads, but targets
  36109. must stop all threads in any already-attached processes when entering
  36110. all-stop mode. @value{GDBN} uses the @samp{?} packet as necessary to
  36111. probe the target state after a mode change.
  36112. In non-stop mode, when an attached process encounters an event that
  36113. would otherwise be reported with a stop reply, it uses the
  36114. asynchronous notification mechanism (@pxref{Notification Packets}) to
  36115. inform @value{GDBN}. In contrast to all-stop mode, where all threads
  36116. in all processes are stopped when a stop reply is sent, in non-stop
  36117. mode only the thread reporting the stop event is stopped. That is,
  36118. when reporting a @samp{S} or @samp{T} response to indicate completion
  36119. of a step operation, hitting a breakpoint, or a fault, only the
  36120. affected thread is stopped; any other still-running threads continue
  36121. to run. When reporting a @samp{W} or @samp{X} response, all running
  36122. threads belonging to other attached processes continue to run.
  36123. In non-stop mode, the target shall respond to the @samp{?} packet as
  36124. follows. First, any incomplete stop reply notification/@samp{vStopped}
  36125. sequence in progress is abandoned. The target must begin a new
  36126. sequence reporting stop events for all stopped threads, whether or not
  36127. it has previously reported those events to @value{GDBN}. The first
  36128. stop reply is sent as a synchronous reply to the @samp{?} packet, and
  36129. subsequent stop replies are sent as responses to @samp{vStopped} packets
  36130. using the mechanism described above. The target must not send
  36131. asynchronous stop reply notifications until the sequence is complete.
  36132. If all threads are running when the target receives the @samp{?} packet,
  36133. or if the target is not attached to any process, it shall respond
  36134. @samp{OK}.
  36135. If the stub supports non-stop mode, it should also support the
  36136. @samp{swbreak} stop reason if software breakpoints are supported, and
  36137. the @samp{hwbreak} stop reason if hardware breakpoints are supported
  36138. (@pxref{swbreak stop reason}). This is because given the asynchronous
  36139. nature of non-stop mode, between the time a thread hits a breakpoint
  36140. and the time the event is finally processed by @value{GDBN}, the
  36141. breakpoint may have already been removed from the target. Due to
  36142. this, @value{GDBN} needs to be able to tell whether a trap stop was
  36143. caused by a delayed breakpoint event, which should be ignored, as
  36144. opposed to a random trap signal, which should be reported to the user.
  36145. Note the @samp{swbreak} feature implies that the target is responsible
  36146. for adjusting the PC when a software breakpoint triggers, if
  36147. necessary, such as on the x86 architecture.
  36148. @node Packet Acknowledgment
  36149. @section Packet Acknowledgment
  36150. @cindex acknowledgment, for @value{GDBN} remote
  36151. @cindex packet acknowledgment, for @value{GDBN} remote
  36152. By default, when either the host or the target machine receives a packet,
  36153. the first response expected is an acknowledgment: either @samp{+} (to indicate
  36154. the package was received correctly) or @samp{-} (to request retransmission).
  36155. This mechanism allows the @value{GDBN} remote protocol to operate over
  36156. unreliable transport mechanisms, such as a serial line.
  36157. In cases where the transport mechanism is itself reliable (such as a pipe or
  36158. TCP connection), the @samp{+}/@samp{-} acknowledgments are redundant.
  36159. It may be desirable to disable them in that case to reduce communication
  36160. overhead, or for other reasons. This can be accomplished by means of the
  36161. @samp{QStartNoAckMode} packet; @pxref{QStartNoAckMode}.
  36162. When in no-acknowledgment mode, neither the stub nor @value{GDBN} shall send or
  36163. expect @samp{+}/@samp{-} protocol acknowledgments. The packet
  36164. and response format still includes the normal checksum, as described in
  36165. @ref{Overview}, but the checksum may be ignored by the receiver.
  36166. If the stub supports @samp{QStartNoAckMode} and prefers to operate in
  36167. no-acknowledgment mode, it should report that to @value{GDBN}
  36168. by including @samp{QStartNoAckMode+} in its response to @samp{qSupported};
  36169. @pxref{qSupported}.
  36170. If @value{GDBN} also supports @samp{QStartNoAckMode} and it has not been
  36171. disabled via the @code{set remote noack-packet off} command
  36172. (@pxref{Remote Configuration}),
  36173. @value{GDBN} may then send a @samp{QStartNoAckMode} packet to the stub.
  36174. Only then may the stub actually turn off packet acknowledgments.
  36175. @value{GDBN} sends a final @samp{+} acknowledgment of the stub's @samp{OK}
  36176. response, which can be safely ignored by the stub.
  36177. Note that @code{set remote noack-packet} command only affects negotiation
  36178. between @value{GDBN} and the stub when subsequent connections are made;
  36179. it does not affect the protocol acknowledgment state for any current
  36180. connection.
  36181. Since @samp{+}/@samp{-} acknowledgments are enabled by default when a
  36182. new connection is established,
  36183. there is also no protocol request to re-enable the acknowledgments
  36184. for the current connection, once disabled.
  36185. @node Examples
  36186. @section Examples
  36187. Example sequence of a target being re-started. Notice how the restart
  36188. does not get any direct output:
  36189. @smallexample
  36190. -> @code{R00}
  36191. <- @code{+}
  36192. @emph{target restarts}
  36193. -> @code{?}
  36194. <- @code{+}
  36195. <- @code{T001:1234123412341234}
  36196. -> @code{+}
  36197. @end smallexample
  36198. Example sequence of a target being stepped by a single instruction:
  36199. @smallexample
  36200. -> @code{G1445@dots{}}
  36201. <- @code{+}
  36202. -> @code{s}
  36203. <- @code{+}
  36204. @emph{time passes}
  36205. <- @code{T001:1234123412341234}
  36206. -> @code{+}
  36207. -> @code{g}
  36208. <- @code{+}
  36209. <- @code{1455@dots{}}
  36210. -> @code{+}
  36211. @end smallexample
  36212. @node File-I/O Remote Protocol Extension
  36213. @section File-I/O Remote Protocol Extension
  36214. @cindex File-I/O remote protocol extension
  36215. @menu
  36216. * File-I/O Overview::
  36217. * Protocol Basics::
  36218. * The F Request Packet::
  36219. * The F Reply Packet::
  36220. * The Ctrl-C Message::
  36221. * Console I/O::
  36222. * List of Supported Calls::
  36223. * Protocol-specific Representation of Datatypes::
  36224. * Constants::
  36225. * File-I/O Examples::
  36226. @end menu
  36227. @node File-I/O Overview
  36228. @subsection File-I/O Overview
  36229. @cindex file-i/o overview
  36230. The @dfn{File I/O remote protocol extension} (short: File-I/O) allows the
  36231. target to use the host's file system and console I/O to perform various
  36232. system calls. System calls on the target system are translated into a
  36233. remote protocol packet to the host system, which then performs the needed
  36234. actions and returns a response packet to the target system.
  36235. This simulates file system operations even on targets that lack file systems.
  36236. The protocol is defined to be independent of both the host and target systems.
  36237. It uses its own internal representation of datatypes and values. Both
  36238. @value{GDBN} and the target's @value{GDBN} stub are responsible for
  36239. translating the system-dependent value representations into the internal
  36240. protocol representations when data is transmitted.
  36241. The communication is synchronous. A system call is possible only when
  36242. @value{GDBN} is waiting for a response from the @samp{C}, @samp{c}, @samp{S}
  36243. or @samp{s} packets. While @value{GDBN} handles the request for a system call,
  36244. the target is stopped to allow deterministic access to the target's
  36245. memory. Therefore File-I/O is not interruptible by target signals. On
  36246. the other hand, it is possible to interrupt File-I/O by a user interrupt
  36247. (@samp{Ctrl-C}) within @value{GDBN}.
  36248. The target's request to perform a host system call does not finish
  36249. the latest @samp{C}, @samp{c}, @samp{S} or @samp{s} action. That means,
  36250. after finishing the system call, the target returns to continuing the
  36251. previous activity (continue, step). No additional continue or step
  36252. request from @value{GDBN} is required.
  36253. @smallexample
  36254. (@value{GDBP}) continue
  36255. <- target requests 'system call X'
  36256. target is stopped, @value{GDBN} executes system call
  36257. -> @value{GDBN} returns result
  36258. ... target continues, @value{GDBN} returns to wait for the target
  36259. <- target hits breakpoint and sends a Txx packet
  36260. @end smallexample
  36261. The protocol only supports I/O on the console and to regular files on
  36262. the host file system. Character or block special devices, pipes,
  36263. named pipes, sockets or any other communication method on the host
  36264. system are not supported by this protocol.
  36265. File I/O is not supported in non-stop mode.
  36266. @node Protocol Basics
  36267. @subsection Protocol Basics
  36268. @cindex protocol basics, file-i/o
  36269. The File-I/O protocol uses the @code{F} packet as the request as well
  36270. as reply packet. Since a File-I/O system call can only occur when
  36271. @value{GDBN} is waiting for a response from the continuing or stepping target,
  36272. the File-I/O request is a reply that @value{GDBN} has to expect as a result
  36273. of a previous @samp{C}, @samp{c}, @samp{S} or @samp{s} packet.
  36274. This @code{F} packet contains all information needed to allow @value{GDBN}
  36275. to call the appropriate host system call:
  36276. @itemize @bullet
  36277. @item
  36278. A unique identifier for the requested system call.
  36279. @item
  36280. All parameters to the system call. Pointers are given as addresses
  36281. in the target memory address space. Pointers to strings are given as
  36282. pointer/length pair. Numerical values are given as they are.
  36283. Numerical control flags are given in a protocol-specific representation.
  36284. @end itemize
  36285. At this point, @value{GDBN} has to perform the following actions.
  36286. @itemize @bullet
  36287. @item
  36288. If the parameters include pointer values to data needed as input to a
  36289. system call, @value{GDBN} requests this data from the target with a
  36290. standard @code{m} packet request. This additional communication has to be
  36291. expected by the target implementation and is handled as any other @code{m}
  36292. packet.
  36293. @item
  36294. @value{GDBN} translates all value from protocol representation to host
  36295. representation as needed. Datatypes are coerced into the host types.
  36296. @item
  36297. @value{GDBN} calls the system call.
  36298. @item
  36299. It then coerces datatypes back to protocol representation.
  36300. @item
  36301. If the system call is expected to return data in buffer space specified
  36302. by pointer parameters to the call, the data is transmitted to the
  36303. target using a @code{M} or @code{X} packet. This packet has to be expected
  36304. by the target implementation and is handled as any other @code{M} or @code{X}
  36305. packet.
  36306. @end itemize
  36307. Eventually @value{GDBN} replies with another @code{F} packet which contains all
  36308. necessary information for the target to continue. This at least contains
  36309. @itemize @bullet
  36310. @item
  36311. Return value.
  36312. @item
  36313. @code{errno}, if has been changed by the system call.
  36314. @item
  36315. ``Ctrl-C'' flag.
  36316. @end itemize
  36317. After having done the needed type and value coercion, the target continues
  36318. the latest continue or step action.
  36319. @node The F Request Packet
  36320. @subsection The @code{F} Request Packet
  36321. @cindex file-i/o request packet
  36322. @cindex @code{F} request packet
  36323. The @code{F} request packet has the following format:
  36324. @table @samp
  36325. @item F@var{call-id},@var{parameter@dots{}}
  36326. @var{call-id} is the identifier to indicate the host system call to be called.
  36327. This is just the name of the function.
  36328. @var{parameter@dots{}} are the parameters to the system call.
  36329. Parameters are hexadecimal integer values, either the actual values in case
  36330. of scalar datatypes, pointers to target buffer space in case of compound
  36331. datatypes and unspecified memory areas, or pointer/length pairs in case
  36332. of string parameters. These are appended to the @var{call-id} as a
  36333. comma-delimited list. All values are transmitted in ASCII
  36334. string representation, pointer/length pairs separated by a slash.
  36335. @end table
  36336. @node The F Reply Packet
  36337. @subsection The @code{F} Reply Packet
  36338. @cindex file-i/o reply packet
  36339. @cindex @code{F} reply packet
  36340. The @code{F} reply packet has the following format:
  36341. @table @samp
  36342. @item F@var{retcode},@var{errno},@var{Ctrl-C flag};@var{call-specific attachment}
  36343. @var{retcode} is the return code of the system call as hexadecimal value.
  36344. @var{errno} is the @code{errno} set by the call, in protocol-specific
  36345. representation.
  36346. This parameter can be omitted if the call was successful.
  36347. @var{Ctrl-C flag} is only sent if the user requested a break. In this
  36348. case, @var{errno} must be sent as well, even if the call was successful.
  36349. The @var{Ctrl-C flag} itself consists of the character @samp{C}:
  36350. @smallexample
  36351. F0,0,C
  36352. @end smallexample
  36353. @noindent
  36354. or, if the call was interrupted before the host call has been performed:
  36355. @smallexample
  36356. F-1,4,C
  36357. @end smallexample
  36358. @noindent
  36359. assuming 4 is the protocol-specific representation of @code{EINTR}.
  36360. @end table
  36361. @node The Ctrl-C Message
  36362. @subsection The @samp{Ctrl-C} Message
  36363. @cindex ctrl-c message, in file-i/o protocol
  36364. If the @samp{Ctrl-C} flag is set in the @value{GDBN}
  36365. reply packet (@pxref{The F Reply Packet}),
  36366. the target should behave as if it had
  36367. gotten a break message. The meaning for the target is ``system call
  36368. interrupted by @code{SIGINT}''. Consequentially, the target should actually stop
  36369. (as with a break message) and return to @value{GDBN} with a @code{T02}
  36370. packet.
  36371. It's important for the target to know in which
  36372. state the system call was interrupted. There are two possible cases:
  36373. @itemize @bullet
  36374. @item
  36375. The system call hasn't been performed on the host yet.
  36376. @item
  36377. The system call on the host has been finished.
  36378. @end itemize
  36379. These two states can be distinguished by the target by the value of the
  36380. returned @code{errno}. If it's the protocol representation of @code{EINTR}, the system
  36381. call hasn't been performed. This is equivalent to the @code{EINTR} handling
  36382. on POSIX systems. In any other case, the target may presume that the
  36383. system call has been finished --- successfully or not --- and should behave
  36384. as if the break message arrived right after the system call.
  36385. @value{GDBN} must behave reliably. If the system call has not been called
  36386. yet, @value{GDBN} may send the @code{F} reply immediately, setting @code{EINTR} as
  36387. @code{errno} in the packet. If the system call on the host has been finished
  36388. before the user requests a break, the full action must be finished by
  36389. @value{GDBN}. This requires sending @code{M} or @code{X} packets as necessary.
  36390. The @code{F} packet may only be sent when either nothing has happened
  36391. or the full action has been completed.
  36392. @node Console I/O
  36393. @subsection Console I/O
  36394. @cindex console i/o as part of file-i/o
  36395. By default and if not explicitly closed by the target system, the file
  36396. descriptors 0, 1 and 2 are connected to the @value{GDBN} console. Output
  36397. on the @value{GDBN} console is handled as any other file output operation
  36398. (@code{write(1, @dots{})} or @code{write(2, @dots{})}). Console input is handled
  36399. by @value{GDBN} so that after the target read request from file descriptor
  36400. 0 all following typing is buffered until either one of the following
  36401. conditions is met:
  36402. @itemize @bullet
  36403. @item
  36404. The user types @kbd{Ctrl-c}. The behaviour is as explained above, and the
  36405. @code{read}
  36406. system call is treated as finished.
  36407. @item
  36408. The user presses @key{RET}. This is treated as end of input with a trailing
  36409. newline.
  36410. @item
  36411. The user types @kbd{Ctrl-d}. This is treated as end of input. No trailing
  36412. character (neither newline nor @samp{Ctrl-D}) is appended to the input.
  36413. @end itemize
  36414. If the user has typed more characters than fit in the buffer given to
  36415. the @code{read} call, the trailing characters are buffered in @value{GDBN} until
  36416. either another @code{read(0, @dots{})} is requested by the target, or debugging
  36417. is stopped at the user's request.
  36418. @node List of Supported Calls
  36419. @subsection List of Supported Calls
  36420. @cindex list of supported file-i/o calls
  36421. @menu
  36422. * open::
  36423. * close::
  36424. * read::
  36425. * write::
  36426. * lseek::
  36427. * rename::
  36428. * unlink::
  36429. * stat/fstat::
  36430. * gettimeofday::
  36431. * isatty::
  36432. * system::
  36433. @end menu
  36434. @node open
  36435. @unnumberedsubsubsec open
  36436. @cindex open, file-i/o system call
  36437. @table @asis
  36438. @item Synopsis:
  36439. @smallexample
  36440. int open(const char *pathname, int flags);
  36441. int open(const char *pathname, int flags, mode_t mode);
  36442. @end smallexample
  36443. @item Request:
  36444. @samp{Fopen,@var{pathptr}/@var{len},@var{flags},@var{mode}}
  36445. @noindent
  36446. @var{flags} is the bitwise @code{OR} of the following values:
  36447. @table @code
  36448. @item O_CREAT
  36449. If the file does not exist it will be created. The host
  36450. rules apply as far as file ownership and time stamps
  36451. are concerned.
  36452. @item O_EXCL
  36453. When used with @code{O_CREAT}, if the file already exists it is
  36454. an error and open() fails.
  36455. @item O_TRUNC
  36456. If the file already exists and the open mode allows
  36457. writing (@code{O_RDWR} or @code{O_WRONLY} is given) it will be
  36458. truncated to zero length.
  36459. @item O_APPEND
  36460. The file is opened in append mode.
  36461. @item O_RDONLY
  36462. The file is opened for reading only.
  36463. @item O_WRONLY
  36464. The file is opened for writing only.
  36465. @item O_RDWR
  36466. The file is opened for reading and writing.
  36467. @end table
  36468. @noindent
  36469. Other bits are silently ignored.
  36470. @noindent
  36471. @var{mode} is the bitwise @code{OR} of the following values:
  36472. @table @code
  36473. @item S_IRUSR
  36474. User has read permission.
  36475. @item S_IWUSR
  36476. User has write permission.
  36477. @item S_IRGRP
  36478. Group has read permission.
  36479. @item S_IWGRP
  36480. Group has write permission.
  36481. @item S_IROTH
  36482. Others have read permission.
  36483. @item S_IWOTH
  36484. Others have write permission.
  36485. @end table
  36486. @noindent
  36487. Other bits are silently ignored.
  36488. @item Return value:
  36489. @code{open} returns the new file descriptor or -1 if an error
  36490. occurred.
  36491. @item Errors:
  36492. @table @code
  36493. @item EEXIST
  36494. @var{pathname} already exists and @code{O_CREAT} and @code{O_EXCL} were used.
  36495. @item EISDIR
  36496. @var{pathname} refers to a directory.
  36497. @item EACCES
  36498. The requested access is not allowed.
  36499. @item ENAMETOOLONG
  36500. @var{pathname} was too long.
  36501. @item ENOENT
  36502. A directory component in @var{pathname} does not exist.
  36503. @item ENODEV
  36504. @var{pathname} refers to a device, pipe, named pipe or socket.
  36505. @item EROFS
  36506. @var{pathname} refers to a file on a read-only filesystem and
  36507. write access was requested.
  36508. @item EFAULT
  36509. @var{pathname} is an invalid pointer value.
  36510. @item ENOSPC
  36511. No space on device to create the file.
  36512. @item EMFILE
  36513. The process already has the maximum number of files open.
  36514. @item ENFILE
  36515. The limit on the total number of files open on the system
  36516. has been reached.
  36517. @item EINTR
  36518. The call was interrupted by the user.
  36519. @end table
  36520. @end table
  36521. @node close
  36522. @unnumberedsubsubsec close
  36523. @cindex close, file-i/o system call
  36524. @table @asis
  36525. @item Synopsis:
  36526. @smallexample
  36527. int close(int fd);
  36528. @end smallexample
  36529. @item Request:
  36530. @samp{Fclose,@var{fd}}
  36531. @item Return value:
  36532. @code{close} returns zero on success, or -1 if an error occurred.
  36533. @item Errors:
  36534. @table @code
  36535. @item EBADF
  36536. @var{fd} isn't a valid open file descriptor.
  36537. @item EINTR
  36538. The call was interrupted by the user.
  36539. @end table
  36540. @end table
  36541. @node read
  36542. @unnumberedsubsubsec read
  36543. @cindex read, file-i/o system call
  36544. @table @asis
  36545. @item Synopsis:
  36546. @smallexample
  36547. int read(int fd, void *buf, unsigned int count);
  36548. @end smallexample
  36549. @item Request:
  36550. @samp{Fread,@var{fd},@var{bufptr},@var{count}}
  36551. @item Return value:
  36552. On success, the number of bytes read is returned.
  36553. Zero indicates end of file. If count is zero, read
  36554. returns zero as well. On error, -1 is returned.
  36555. @item Errors:
  36556. @table @code
  36557. @item EBADF
  36558. @var{fd} is not a valid file descriptor or is not open for
  36559. reading.
  36560. @item EFAULT
  36561. @var{bufptr} is an invalid pointer value.
  36562. @item EINTR
  36563. The call was interrupted by the user.
  36564. @end table
  36565. @end table
  36566. @node write
  36567. @unnumberedsubsubsec write
  36568. @cindex write, file-i/o system call
  36569. @table @asis
  36570. @item Synopsis:
  36571. @smallexample
  36572. int write(int fd, const void *buf, unsigned int count);
  36573. @end smallexample
  36574. @item Request:
  36575. @samp{Fwrite,@var{fd},@var{bufptr},@var{count}}
  36576. @item Return value:
  36577. On success, the number of bytes written are returned.
  36578. Zero indicates nothing was written. On error, -1
  36579. is returned.
  36580. @item Errors:
  36581. @table @code
  36582. @item EBADF
  36583. @var{fd} is not a valid file descriptor or is not open for
  36584. writing.
  36585. @item EFAULT
  36586. @var{bufptr} is an invalid pointer value.
  36587. @item EFBIG
  36588. An attempt was made to write a file that exceeds the
  36589. host-specific maximum file size allowed.
  36590. @item ENOSPC
  36591. No space on device to write the data.
  36592. @item EINTR
  36593. The call was interrupted by the user.
  36594. @end table
  36595. @end table
  36596. @node lseek
  36597. @unnumberedsubsubsec lseek
  36598. @cindex lseek, file-i/o system call
  36599. @table @asis
  36600. @item Synopsis:
  36601. @smallexample
  36602. long lseek (int fd, long offset, int flag);
  36603. @end smallexample
  36604. @item Request:
  36605. @samp{Flseek,@var{fd},@var{offset},@var{flag}}
  36606. @var{flag} is one of:
  36607. @table @code
  36608. @item SEEK_SET
  36609. The offset is set to @var{offset} bytes.
  36610. @item SEEK_CUR
  36611. The offset is set to its current location plus @var{offset}
  36612. bytes.
  36613. @item SEEK_END
  36614. The offset is set to the size of the file plus @var{offset}
  36615. bytes.
  36616. @end table
  36617. @item Return value:
  36618. On success, the resulting unsigned offset in bytes from
  36619. the beginning of the file is returned. Otherwise, a
  36620. value of -1 is returned.
  36621. @item Errors:
  36622. @table @code
  36623. @item EBADF
  36624. @var{fd} is not a valid open file descriptor.
  36625. @item ESPIPE
  36626. @var{fd} is associated with the @value{GDBN} console.
  36627. @item EINVAL
  36628. @var{flag} is not a proper value.
  36629. @item EINTR
  36630. The call was interrupted by the user.
  36631. @end table
  36632. @end table
  36633. @node rename
  36634. @unnumberedsubsubsec rename
  36635. @cindex rename, file-i/o system call
  36636. @table @asis
  36637. @item Synopsis:
  36638. @smallexample
  36639. int rename(const char *oldpath, const char *newpath);
  36640. @end smallexample
  36641. @item Request:
  36642. @samp{Frename,@var{oldpathptr}/@var{len},@var{newpathptr}/@var{len}}
  36643. @item Return value:
  36644. On success, zero is returned. On error, -1 is returned.
  36645. @item Errors:
  36646. @table @code
  36647. @item EISDIR
  36648. @var{newpath} is an existing directory, but @var{oldpath} is not a
  36649. directory.
  36650. @item EEXIST
  36651. @var{newpath} is a non-empty directory.
  36652. @item EBUSY
  36653. @var{oldpath} or @var{newpath} is a directory that is in use by some
  36654. process.
  36655. @item EINVAL
  36656. An attempt was made to make a directory a subdirectory
  36657. of itself.
  36658. @item ENOTDIR
  36659. A component used as a directory in @var{oldpath} or new
  36660. path is not a directory. Or @var{oldpath} is a directory
  36661. and @var{newpath} exists but is not a directory.
  36662. @item EFAULT
  36663. @var{oldpathptr} or @var{newpathptr} are invalid pointer values.
  36664. @item EACCES
  36665. No access to the file or the path of the file.
  36666. @item ENAMETOOLONG
  36667. @var{oldpath} or @var{newpath} was too long.
  36668. @item ENOENT
  36669. A directory component in @var{oldpath} or @var{newpath} does not exist.
  36670. @item EROFS
  36671. The file is on a read-only filesystem.
  36672. @item ENOSPC
  36673. The device containing the file has no room for the new
  36674. directory entry.
  36675. @item EINTR
  36676. The call was interrupted by the user.
  36677. @end table
  36678. @end table
  36679. @node unlink
  36680. @unnumberedsubsubsec unlink
  36681. @cindex unlink, file-i/o system call
  36682. @table @asis
  36683. @item Synopsis:
  36684. @smallexample
  36685. int unlink(const char *pathname);
  36686. @end smallexample
  36687. @item Request:
  36688. @samp{Funlink,@var{pathnameptr}/@var{len}}
  36689. @item Return value:
  36690. On success, zero is returned. On error, -1 is returned.
  36691. @item Errors:
  36692. @table @code
  36693. @item EACCES
  36694. No access to the file or the path of the file.
  36695. @item EPERM
  36696. The system does not allow unlinking of directories.
  36697. @item EBUSY
  36698. The file @var{pathname} cannot be unlinked because it's
  36699. being used by another process.
  36700. @item EFAULT
  36701. @var{pathnameptr} is an invalid pointer value.
  36702. @item ENAMETOOLONG
  36703. @var{pathname} was too long.
  36704. @item ENOENT
  36705. A directory component in @var{pathname} does not exist.
  36706. @item ENOTDIR
  36707. A component of the path is not a directory.
  36708. @item EROFS
  36709. The file is on a read-only filesystem.
  36710. @item EINTR
  36711. The call was interrupted by the user.
  36712. @end table
  36713. @end table
  36714. @node stat/fstat
  36715. @unnumberedsubsubsec stat/fstat
  36716. @cindex fstat, file-i/o system call
  36717. @cindex stat, file-i/o system call
  36718. @table @asis
  36719. @item Synopsis:
  36720. @smallexample
  36721. int stat(const char *pathname, struct stat *buf);
  36722. int fstat(int fd, struct stat *buf);
  36723. @end smallexample
  36724. @item Request:
  36725. @samp{Fstat,@var{pathnameptr}/@var{len},@var{bufptr}}@*
  36726. @samp{Ffstat,@var{fd},@var{bufptr}}
  36727. @item Return value:
  36728. On success, zero is returned. On error, -1 is returned.
  36729. @item Errors:
  36730. @table @code
  36731. @item EBADF
  36732. @var{fd} is not a valid open file.
  36733. @item ENOENT
  36734. A directory component in @var{pathname} does not exist or the
  36735. path is an empty string.
  36736. @item ENOTDIR
  36737. A component of the path is not a directory.
  36738. @item EFAULT
  36739. @var{pathnameptr} is an invalid pointer value.
  36740. @item EACCES
  36741. No access to the file or the path of the file.
  36742. @item ENAMETOOLONG
  36743. @var{pathname} was too long.
  36744. @item EINTR
  36745. The call was interrupted by the user.
  36746. @end table
  36747. @end table
  36748. @node gettimeofday
  36749. @unnumberedsubsubsec gettimeofday
  36750. @cindex gettimeofday, file-i/o system call
  36751. @table @asis
  36752. @item Synopsis:
  36753. @smallexample
  36754. int gettimeofday(struct timeval *tv, void *tz);
  36755. @end smallexample
  36756. @item Request:
  36757. @samp{Fgettimeofday,@var{tvptr},@var{tzptr}}
  36758. @item Return value:
  36759. On success, 0 is returned, -1 otherwise.
  36760. @item Errors:
  36761. @table @code
  36762. @item EINVAL
  36763. @var{tz} is a non-NULL pointer.
  36764. @item EFAULT
  36765. @var{tvptr} and/or @var{tzptr} is an invalid pointer value.
  36766. @end table
  36767. @end table
  36768. @node isatty
  36769. @unnumberedsubsubsec isatty
  36770. @cindex isatty, file-i/o system call
  36771. @table @asis
  36772. @item Synopsis:
  36773. @smallexample
  36774. int isatty(int fd);
  36775. @end smallexample
  36776. @item Request:
  36777. @samp{Fisatty,@var{fd}}
  36778. @item Return value:
  36779. Returns 1 if @var{fd} refers to the @value{GDBN} console, 0 otherwise.
  36780. @item Errors:
  36781. @table @code
  36782. @item EINTR
  36783. The call was interrupted by the user.
  36784. @end table
  36785. @end table
  36786. Note that the @code{isatty} call is treated as a special case: it returns
  36787. 1 to the target if the file descriptor is attached
  36788. to the @value{GDBN} console, 0 otherwise. Implementing through system calls
  36789. would require implementing @code{ioctl} and would be more complex than
  36790. needed.
  36791. @node system
  36792. @unnumberedsubsubsec system
  36793. @cindex system, file-i/o system call
  36794. @table @asis
  36795. @item Synopsis:
  36796. @smallexample
  36797. int system(const char *command);
  36798. @end smallexample
  36799. @item Request:
  36800. @samp{Fsystem,@var{commandptr}/@var{len}}
  36801. @item Return value:
  36802. If @var{len} is zero, the return value indicates whether a shell is
  36803. available. A zero return value indicates a shell is not available.
  36804. For non-zero @var{len}, the value returned is -1 on error and the
  36805. return status of the command otherwise. Only the exit status of the
  36806. command is returned, which is extracted from the host's @code{system}
  36807. return value by calling @code{WEXITSTATUS(retval)}. In case
  36808. @file{/bin/sh} could not be executed, 127 is returned.
  36809. @item Errors:
  36810. @table @code
  36811. @item EINTR
  36812. The call was interrupted by the user.
  36813. @end table
  36814. @end table
  36815. @value{GDBN} takes over the full task of calling the necessary host calls
  36816. to perform the @code{system} call. The return value of @code{system} on
  36817. the host is simplified before it's returned
  36818. to the target. Any termination signal information from the child process
  36819. is discarded, and the return value consists
  36820. entirely of the exit status of the called command.
  36821. Due to security concerns, the @code{system} call is by default refused
  36822. by @value{GDBN}. The user has to allow this call explicitly with the
  36823. @code{set remote system-call-allowed 1} command.
  36824. @table @code
  36825. @item set remote system-call-allowed
  36826. @kindex set remote system-call-allowed
  36827. Control whether to allow the @code{system} calls in the File I/O
  36828. protocol for the remote target. The default is zero (disabled).
  36829. @item show remote system-call-allowed
  36830. @kindex show remote system-call-allowed
  36831. Show whether the @code{system} calls are allowed in the File I/O
  36832. protocol.
  36833. @end table
  36834. @node Protocol-specific Representation of Datatypes
  36835. @subsection Protocol-specific Representation of Datatypes
  36836. @cindex protocol-specific representation of datatypes, in file-i/o protocol
  36837. @menu
  36838. * Integral Datatypes::
  36839. * Pointer Values::
  36840. * Memory Transfer::
  36841. * struct stat::
  36842. * struct timeval::
  36843. @end menu
  36844. @node Integral Datatypes
  36845. @unnumberedsubsubsec Integral Datatypes
  36846. @cindex integral datatypes, in file-i/o protocol
  36847. The integral datatypes used in the system calls are @code{int},
  36848. @code{unsigned int}, @code{long}, @code{unsigned long},
  36849. @code{mode_t}, and @code{time_t}.
  36850. @code{int}, @code{unsigned int}, @code{mode_t} and @code{time_t} are
  36851. implemented as 32 bit values in this protocol.
  36852. @code{long} and @code{unsigned long} are implemented as 64 bit types.
  36853. @xref{Limits}, for corresponding MIN and MAX values (similar to those
  36854. in @file{limits.h}) to allow range checking on host and target.
  36855. @code{time_t} datatypes are defined as seconds since the Epoch.
  36856. All integral datatypes transferred as part of a memory read or write of a
  36857. structured datatype e.g.@: a @code{struct stat} have to be given in big endian
  36858. byte order.
  36859. @node Pointer Values
  36860. @unnumberedsubsubsec Pointer Values
  36861. @cindex pointer values, in file-i/o protocol
  36862. Pointers to target data are transmitted as they are. An exception
  36863. is made for pointers to buffers for which the length isn't
  36864. transmitted as part of the function call, namely strings. Strings
  36865. are transmitted as a pointer/length pair, both as hex values, e.g.@:
  36866. @smallexample
  36867. @code{1aaf/12}
  36868. @end smallexample
  36869. @noindent
  36870. which is a pointer to data of length 18 bytes at position 0x1aaf.
  36871. The length is defined as the full string length in bytes, including
  36872. the trailing null byte. For example, the string @code{"hello world"}
  36873. at address 0x123456 is transmitted as
  36874. @smallexample
  36875. @code{123456/d}
  36876. @end smallexample
  36877. @node Memory Transfer
  36878. @unnumberedsubsubsec Memory Transfer
  36879. @cindex memory transfer, in file-i/o protocol
  36880. Structured data which is transferred using a memory read or write (for
  36881. example, a @code{struct stat}) is expected to be in a protocol-specific format
  36882. with all scalar multibyte datatypes being big endian. Translation to
  36883. this representation needs to be done both by the target before the @code{F}
  36884. packet is sent, and by @value{GDBN} before
  36885. it transfers memory to the target. Transferred pointers to structured
  36886. data should point to the already-coerced data at any time.
  36887. @node struct stat
  36888. @unnumberedsubsubsec struct stat
  36889. @cindex struct stat, in file-i/o protocol
  36890. The buffer of type @code{struct stat} used by the target and @value{GDBN}
  36891. is defined as follows:
  36892. @smallexample
  36893. struct stat @{
  36894. unsigned int st_dev; /* device */
  36895. unsigned int st_ino; /* inode */
  36896. mode_t st_mode; /* protection */
  36897. unsigned int st_nlink; /* number of hard links */
  36898. unsigned int st_uid; /* user ID of owner */
  36899. unsigned int st_gid; /* group ID of owner */
  36900. unsigned int st_rdev; /* device type (if inode device) */
  36901. unsigned long st_size; /* total size, in bytes */
  36902. unsigned long st_blksize; /* blocksize for filesystem I/O */
  36903. unsigned long st_blocks; /* number of blocks allocated */
  36904. time_t st_atime; /* time of last access */
  36905. time_t st_mtime; /* time of last modification */
  36906. time_t st_ctime; /* time of last change */
  36907. @};
  36908. @end smallexample
  36909. The integral datatypes conform to the definitions given in the
  36910. appropriate section (see @ref{Integral Datatypes}, for details) so this
  36911. structure is of size 64 bytes.
  36912. The values of several fields have a restricted meaning and/or
  36913. range of values.
  36914. @table @code
  36915. @item st_dev
  36916. A value of 0 represents a file, 1 the console.
  36917. @item st_ino
  36918. No valid meaning for the target. Transmitted unchanged.
  36919. @item st_mode
  36920. Valid mode bits are described in @ref{Constants}. Any other
  36921. bits have currently no meaning for the target.
  36922. @item st_uid
  36923. @itemx st_gid
  36924. @itemx st_rdev
  36925. No valid meaning for the target. Transmitted unchanged.
  36926. @item st_atime
  36927. @itemx st_mtime
  36928. @itemx st_ctime
  36929. These values have a host and file system dependent
  36930. accuracy. Especially on Windows hosts, the file system may not
  36931. support exact timing values.
  36932. @end table
  36933. The target gets a @code{struct stat} of the above representation and is
  36934. responsible for coercing it to the target representation before
  36935. continuing.
  36936. Note that due to size differences between the host, target, and protocol
  36937. representations of @code{struct stat} members, these members could eventually
  36938. get truncated on the target.
  36939. @node struct timeval
  36940. @unnumberedsubsubsec struct timeval
  36941. @cindex struct timeval, in file-i/o protocol
  36942. The buffer of type @code{struct timeval} used by the File-I/O protocol
  36943. is defined as follows:
  36944. @smallexample
  36945. struct timeval @{
  36946. time_t tv_sec; /* second */
  36947. long tv_usec; /* microsecond */
  36948. @};
  36949. @end smallexample
  36950. The integral datatypes conform to the definitions given in the
  36951. appropriate section (see @ref{Integral Datatypes}, for details) so this
  36952. structure is of size 8 bytes.
  36953. @node Constants
  36954. @subsection Constants
  36955. @cindex constants, in file-i/o protocol
  36956. The following values are used for the constants inside of the
  36957. protocol. @value{GDBN} and target are responsible for translating these
  36958. values before and after the call as needed.
  36959. @menu
  36960. * Open Flags::
  36961. * mode_t Values::
  36962. * Errno Values::
  36963. * Lseek Flags::
  36964. * Limits::
  36965. @end menu
  36966. @node Open Flags
  36967. @unnumberedsubsubsec Open Flags
  36968. @cindex open flags, in file-i/o protocol
  36969. All values are given in hexadecimal representation.
  36970. @smallexample
  36971. O_RDONLY 0x0
  36972. O_WRONLY 0x1
  36973. O_RDWR 0x2
  36974. O_APPEND 0x8
  36975. O_CREAT 0x200
  36976. O_TRUNC 0x400
  36977. O_EXCL 0x800
  36978. @end smallexample
  36979. @node mode_t Values
  36980. @unnumberedsubsubsec mode_t Values
  36981. @cindex mode_t values, in file-i/o protocol
  36982. All values are given in octal representation.
  36983. @smallexample
  36984. S_IFREG 0100000
  36985. S_IFDIR 040000
  36986. S_IRUSR 0400
  36987. S_IWUSR 0200
  36988. S_IXUSR 0100
  36989. S_IRGRP 040
  36990. S_IWGRP 020
  36991. S_IXGRP 010
  36992. S_IROTH 04
  36993. S_IWOTH 02
  36994. S_IXOTH 01
  36995. @end smallexample
  36996. @node Errno Values
  36997. @unnumberedsubsubsec Errno Values
  36998. @cindex errno values, in file-i/o protocol
  36999. All values are given in decimal representation.
  37000. @smallexample
  37001. EPERM 1
  37002. ENOENT 2
  37003. EINTR 4
  37004. EBADF 9
  37005. EACCES 13
  37006. EFAULT 14
  37007. EBUSY 16
  37008. EEXIST 17
  37009. ENODEV 19
  37010. ENOTDIR 20
  37011. EISDIR 21
  37012. EINVAL 22
  37013. ENFILE 23
  37014. EMFILE 24
  37015. EFBIG 27
  37016. ENOSPC 28
  37017. ESPIPE 29
  37018. EROFS 30
  37019. ENAMETOOLONG 91
  37020. EUNKNOWN 9999
  37021. @end smallexample
  37022. @code{EUNKNOWN} is used as a fallback error value if a host system returns
  37023. any error value not in the list of supported error numbers.
  37024. @node Lseek Flags
  37025. @unnumberedsubsubsec Lseek Flags
  37026. @cindex lseek flags, in file-i/o protocol
  37027. @smallexample
  37028. SEEK_SET 0
  37029. SEEK_CUR 1
  37030. SEEK_END 2
  37031. @end smallexample
  37032. @node Limits
  37033. @unnumberedsubsubsec Limits
  37034. @cindex limits, in file-i/o protocol
  37035. All values are given in decimal representation.
  37036. @smallexample
  37037. INT_MIN -2147483648
  37038. INT_MAX 2147483647
  37039. UINT_MAX 4294967295
  37040. LONG_MIN -9223372036854775808
  37041. LONG_MAX 9223372036854775807
  37042. ULONG_MAX 18446744073709551615
  37043. @end smallexample
  37044. @node File-I/O Examples
  37045. @subsection File-I/O Examples
  37046. @cindex file-i/o examples
  37047. Example sequence of a write call, file descriptor 3, buffer is at target
  37048. address 0x1234, 6 bytes should be written:
  37049. @smallexample
  37050. <- @code{Fwrite,3,1234,6}
  37051. @emph{request memory read from target}
  37052. -> @code{m1234,6}
  37053. <- XXXXXX
  37054. @emph{return "6 bytes written"}
  37055. -> @code{F6}
  37056. @end smallexample
  37057. Example sequence of a read call, file descriptor 3, buffer is at target
  37058. address 0x1234, 6 bytes should be read:
  37059. @smallexample
  37060. <- @code{Fread,3,1234,6}
  37061. @emph{request memory write to target}
  37062. -> @code{X1234,6:XXXXXX}
  37063. @emph{return "6 bytes read"}
  37064. -> @code{F6}
  37065. @end smallexample
  37066. Example sequence of a read call, call fails on the host due to invalid
  37067. file descriptor (@code{EBADF}):
  37068. @smallexample
  37069. <- @code{Fread,3,1234,6}
  37070. -> @code{F-1,9}
  37071. @end smallexample
  37072. Example sequence of a read call, user presses @kbd{Ctrl-c} before syscall on
  37073. host is called:
  37074. @smallexample
  37075. <- @code{Fread,3,1234,6}
  37076. -> @code{F-1,4,C}
  37077. <- @code{T02}
  37078. @end smallexample
  37079. Example sequence of a read call, user presses @kbd{Ctrl-c} after syscall on
  37080. host is called:
  37081. @smallexample
  37082. <- @code{Fread,3,1234,6}
  37083. -> @code{X1234,6:XXXXXX}
  37084. <- @code{T02}
  37085. @end smallexample
  37086. @node Library List Format
  37087. @section Library List Format
  37088. @cindex library list format, remote protocol
  37089. On some platforms, a dynamic loader (e.g.@: @file{ld.so}) runs in the
  37090. same process as your application to manage libraries. In this case,
  37091. @value{GDBN} can use the loader's symbol table and normal memory
  37092. operations to maintain a list of shared libraries. On other
  37093. platforms, the operating system manages loaded libraries.
  37094. @value{GDBN} can not retrieve the list of currently loaded libraries
  37095. through memory operations, so it uses the @samp{qXfer:libraries:read}
  37096. packet (@pxref{qXfer library list read}) instead. The remote stub
  37097. queries the target's operating system and reports which libraries
  37098. are loaded.
  37099. The @samp{qXfer:libraries:read} packet returns an XML document which
  37100. lists loaded libraries and their offsets. Each library has an
  37101. associated name and one or more segment or section base addresses,
  37102. which report where the library was loaded in memory.
  37103. For the common case of libraries that are fully linked binaries, the
  37104. library should have a list of segments. If the target supports
  37105. dynamic linking of a relocatable object file, its library XML element
  37106. should instead include a list of allocated sections. The segment or
  37107. section bases are start addresses, not relocation offsets; they do not
  37108. depend on the library's link-time base addresses.
  37109. @value{GDBN} must be linked with the Expat library to support XML
  37110. library lists. @xref{Expat}.
  37111. A simple memory map, with one loaded library relocated by a single
  37112. offset, looks like this:
  37113. @smallexample
  37114. <library-list>
  37115. <library name="/lib/libc.so.6">
  37116. <segment address="0x10000000"/>
  37117. </library>
  37118. </library-list>
  37119. @end smallexample
  37120. Another simple memory map, with one loaded library with three
  37121. allocated sections (.text, .data, .bss), looks like this:
  37122. @smallexample
  37123. <library-list>
  37124. <library name="sharedlib.o">
  37125. <section address="0x10000000"/>
  37126. <section address="0x20000000"/>
  37127. <section address="0x30000000"/>
  37128. </library>
  37129. </library-list>
  37130. @end smallexample
  37131. The format of a library list is described by this DTD:
  37132. @smallexample
  37133. <!-- library-list: Root element with versioning -->
  37134. <!ELEMENT library-list (library)*>
  37135. <!ATTLIST library-list version CDATA #FIXED "1.0">
  37136. <!ELEMENT library (segment*, section*)>
  37137. <!ATTLIST library name CDATA #REQUIRED>
  37138. <!ELEMENT segment EMPTY>
  37139. <!ATTLIST segment address CDATA #REQUIRED>
  37140. <!ELEMENT section EMPTY>
  37141. <!ATTLIST section address CDATA #REQUIRED>
  37142. @end smallexample
  37143. In addition, segments and section descriptors cannot be mixed within a
  37144. single library element, and you must supply at least one segment or
  37145. section for each library.
  37146. @node Library List Format for SVR4 Targets
  37147. @section Library List Format for SVR4 Targets
  37148. @cindex library list format, remote protocol
  37149. On SVR4 platforms @value{GDBN} can use the symbol table of a dynamic loader
  37150. (e.g.@: @file{ld.so}) and normal memory operations to maintain a list of
  37151. shared libraries. Still a special library list provided by this packet is
  37152. more efficient for the @value{GDBN} remote protocol.
  37153. The @samp{qXfer:libraries-svr4:read} packet returns an XML document which lists
  37154. loaded libraries and their SVR4 linker parameters. For each library on SVR4
  37155. target, the following parameters are reported:
  37156. @itemize @minus
  37157. @item
  37158. @code{name}, the absolute file name from the @code{l_name} field of
  37159. @code{struct link_map}.
  37160. @item
  37161. @code{lm} with address of @code{struct link_map} used for TLS
  37162. (Thread Local Storage) access.
  37163. @item
  37164. @code{l_addr}, the displacement as read from the field @code{l_addr} of
  37165. @code{struct link_map}. For prelinked libraries this is not an absolute
  37166. memory address. It is a displacement of absolute memory address against
  37167. address the file was prelinked to during the library load.
  37168. @item
  37169. @code{l_ld}, which is memory address of the @code{PT_DYNAMIC} segment
  37170. @end itemize
  37171. Additionally the single @code{main-lm} attribute specifies address of
  37172. @code{struct link_map} used for the main executable. This parameter is used
  37173. for TLS access and its presence is optional.
  37174. @value{GDBN} must be linked with the Expat library to support XML
  37175. SVR4 library lists. @xref{Expat}.
  37176. A simple memory map, with two loaded libraries (which do not use prelink),
  37177. looks like this:
  37178. @smallexample
  37179. <library-list-svr4 version="1.0" main-lm="0xe4f8f8">
  37180. <library name="/lib/ld-linux.so.2" lm="0xe4f51c" l_addr="0xe2d000"
  37181. l_ld="0xe4eefc"/>
  37182. <library name="/lib/libc.so.6" lm="0xe4fbe8" l_addr="0x154000"
  37183. l_ld="0x152350"/>
  37184. </library-list-svr>
  37185. @end smallexample
  37186. The format of an SVR4 library list is described by this DTD:
  37187. @smallexample
  37188. <!-- library-list-svr4: Root element with versioning -->
  37189. <!ELEMENT library-list-svr4 (library)*>
  37190. <!ATTLIST library-list-svr4 version CDATA #FIXED "1.0">
  37191. <!ATTLIST library-list-svr4 main-lm CDATA #IMPLIED>
  37192. <!ELEMENT library EMPTY>
  37193. <!ATTLIST library name CDATA #REQUIRED>
  37194. <!ATTLIST library lm CDATA #REQUIRED>
  37195. <!ATTLIST library l_addr CDATA #REQUIRED>
  37196. <!ATTLIST library l_ld CDATA #REQUIRED>
  37197. @end smallexample
  37198. @node Memory Map Format
  37199. @section Memory Map Format
  37200. @cindex memory map format
  37201. To be able to write into flash memory, @value{GDBN} needs to obtain a
  37202. memory map from the target. This section describes the format of the
  37203. memory map.
  37204. The memory map is obtained using the @samp{qXfer:memory-map:read}
  37205. (@pxref{qXfer memory map read}) packet and is an XML document that
  37206. lists memory regions.
  37207. @value{GDBN} must be linked with the Expat library to support XML
  37208. memory maps. @xref{Expat}.
  37209. The top-level structure of the document is shown below:
  37210. @smallexample
  37211. <?xml version="1.0"?>
  37212. <!DOCTYPE memory-map
  37213. PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN"
  37214. "http://sourceware.org/gdb/gdb-memory-map.dtd">
  37215. <memory-map>
  37216. region...
  37217. </memory-map>
  37218. @end smallexample
  37219. Each region can be either:
  37220. @itemize
  37221. @item
  37222. A region of RAM starting at @var{addr} and extending for @var{length}
  37223. bytes from there:
  37224. @smallexample
  37225. <memory type="ram" start="@var{addr}" length="@var{length}"/>
  37226. @end smallexample
  37227. @item
  37228. A region of read-only memory:
  37229. @smallexample
  37230. <memory type="rom" start="@var{addr}" length="@var{length}"/>
  37231. @end smallexample
  37232. @item
  37233. A region of flash memory, with erasure blocks @var{blocksize}
  37234. bytes in length:
  37235. @smallexample
  37236. <memory type="flash" start="@var{addr}" length="@var{length}">
  37237. <property name="blocksize">@var{blocksize}</property>
  37238. </memory>
  37239. @end smallexample
  37240. @end itemize
  37241. Regions must not overlap. @value{GDBN} assumes that areas of memory not covered
  37242. by the memory map are RAM, and uses the ordinary @samp{M} and @samp{X}
  37243. packets to write to addresses in such ranges.
  37244. The formal DTD for memory map format is given below:
  37245. @smallexample
  37246. <!-- ................................................... -->
  37247. <!-- Memory Map XML DTD ................................ -->
  37248. <!-- File: memory-map.dtd .............................. -->
  37249. <!-- .................................... .............. -->
  37250. <!-- memory-map.dtd -->
  37251. <!-- memory-map: Root element with versioning -->
  37252. <!ELEMENT memory-map (memory)*>
  37253. <!ATTLIST memory-map version CDATA #FIXED "1.0.0">
  37254. <!ELEMENT memory (property)*>
  37255. <!-- memory: Specifies a memory region,
  37256. and its type, or device. -->
  37257. <!ATTLIST memory type (ram|rom|flash) #REQUIRED
  37258. start CDATA #REQUIRED
  37259. length CDATA #REQUIRED>
  37260. <!-- property: Generic attribute tag -->
  37261. <!ELEMENT property (#PCDATA | property)*>
  37262. <!ATTLIST property name (blocksize) #REQUIRED>
  37263. @end smallexample
  37264. @node Thread List Format
  37265. @section Thread List Format
  37266. @cindex thread list format
  37267. To efficiently update the list of threads and their attributes,
  37268. @value{GDBN} issues the @samp{qXfer:threads:read} packet
  37269. (@pxref{qXfer threads read}) and obtains the XML document with
  37270. the following structure:
  37271. @smallexample
  37272. <?xml version="1.0"?>
  37273. <threads>
  37274. <thread id="id" core="0" name="name">
  37275. ... description ...
  37276. </thread>
  37277. </threads>
  37278. @end smallexample
  37279. Each @samp{thread} element must have the @samp{id} attribute that
  37280. identifies the thread (@pxref{thread-id syntax}). The
  37281. @samp{core} attribute, if present, specifies which processor core
  37282. the thread was last executing on. The @samp{name} attribute, if
  37283. present, specifies the human-readable name of the thread. The content
  37284. of the of @samp{thread} element is interpreted as human-readable
  37285. auxiliary information. The @samp{handle} attribute, if present,
  37286. is a hex encoded representation of the thread handle.
  37287. @node Traceframe Info Format
  37288. @section Traceframe Info Format
  37289. @cindex traceframe info format
  37290. To be able to know which objects in the inferior can be examined when
  37291. inspecting a tracepoint hit, @value{GDBN} needs to obtain the list of
  37292. memory ranges, registers and trace state variables that have been
  37293. collected in a traceframe.
  37294. This list is obtained using the @samp{qXfer:traceframe-info:read}
  37295. (@pxref{qXfer traceframe info read}) packet and is an XML document.
  37296. @value{GDBN} must be linked with the Expat library to support XML
  37297. traceframe info discovery. @xref{Expat}.
  37298. The top-level structure of the document is shown below:
  37299. @smallexample
  37300. <?xml version="1.0"?>
  37301. <!DOCTYPE traceframe-info
  37302. PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN"
  37303. "http://sourceware.org/gdb/gdb-traceframe-info.dtd">
  37304. <traceframe-info>
  37305. block...
  37306. </traceframe-info>
  37307. @end smallexample
  37308. Each traceframe block can be either:
  37309. @itemize
  37310. @item
  37311. A region of collected memory starting at @var{addr} and extending for
  37312. @var{length} bytes from there:
  37313. @smallexample
  37314. <memory start="@var{addr}" length="@var{length}"/>
  37315. @end smallexample
  37316. @item
  37317. A block indicating trace state variable numbered @var{number} has been
  37318. collected:
  37319. @smallexample
  37320. <tvar id="@var{number}"/>
  37321. @end smallexample
  37322. @end itemize
  37323. The formal DTD for the traceframe info format is given below:
  37324. @smallexample
  37325. <!ELEMENT traceframe-info (memory | tvar)* >
  37326. <!ATTLIST traceframe-info version CDATA #FIXED "1.0">
  37327. <!ELEMENT memory EMPTY>
  37328. <!ATTLIST memory start CDATA #REQUIRED
  37329. length CDATA #REQUIRED>
  37330. <!ELEMENT tvar>
  37331. <!ATTLIST tvar id CDATA #REQUIRED>
  37332. @end smallexample
  37333. @node Branch Trace Format
  37334. @section Branch Trace Format
  37335. @cindex branch trace format
  37336. In order to display the branch trace of an inferior thread,
  37337. @value{GDBN} needs to obtain the list of branches. This list is
  37338. represented as list of sequential code blocks that are connected via
  37339. branches. The code in each block has been executed sequentially.
  37340. This list is obtained using the @samp{qXfer:btrace:read}
  37341. (@pxref{qXfer btrace read}) packet and is an XML document.
  37342. @value{GDBN} must be linked with the Expat library to support XML
  37343. traceframe info discovery. @xref{Expat}.
  37344. The top-level structure of the document is shown below:
  37345. @smallexample
  37346. <?xml version="1.0"?>
  37347. <!DOCTYPE btrace
  37348. PUBLIC "+//IDN gnu.org//DTD GDB Branch Trace V1.0//EN"
  37349. "http://sourceware.org/gdb/gdb-btrace.dtd">
  37350. <btrace>
  37351. block...
  37352. </btrace>
  37353. @end smallexample
  37354. @itemize
  37355. @item
  37356. A block of sequentially executed instructions starting at @var{begin}
  37357. and ending at @var{end}:
  37358. @smallexample
  37359. <block begin="@var{begin}" end="@var{end}"/>
  37360. @end smallexample
  37361. @end itemize
  37362. The formal DTD for the branch trace format is given below:
  37363. @smallexample
  37364. <!ELEMENT btrace (block* | pt) >
  37365. <!ATTLIST btrace version CDATA #FIXED "1.0">
  37366. <!ELEMENT block EMPTY>
  37367. <!ATTLIST block begin CDATA #REQUIRED
  37368. end CDATA #REQUIRED>
  37369. <!ELEMENT pt (pt-config?, raw?)>
  37370. <!ELEMENT pt-config (cpu?)>
  37371. <!ELEMENT cpu EMPTY>
  37372. <!ATTLIST cpu vendor CDATA #REQUIRED
  37373. family CDATA #REQUIRED
  37374. model CDATA #REQUIRED
  37375. stepping CDATA #REQUIRED>
  37376. <!ELEMENT raw (#PCDATA)>
  37377. @end smallexample
  37378. @node Branch Trace Configuration Format
  37379. @section Branch Trace Configuration Format
  37380. @cindex branch trace configuration format
  37381. For each inferior thread, @value{GDBN} can obtain the branch trace
  37382. configuration using the @samp{qXfer:btrace-conf:read}
  37383. (@pxref{qXfer btrace-conf read}) packet.
  37384. The configuration describes the branch trace format and configuration
  37385. settings for that format. The following information is described:
  37386. @table @code
  37387. @item bts
  37388. This thread uses the @dfn{Branch Trace Store} (@acronym{BTS}) format.
  37389. @table @code
  37390. @item size
  37391. The size of the @acronym{BTS} ring buffer in bytes.
  37392. @end table
  37393. @item pt
  37394. This thread uses the @dfn{Intel Processor Trace} (@acronym{Intel
  37395. PT}) format.
  37396. @table @code
  37397. @item size
  37398. The size of the @acronym{Intel PT} ring buffer in bytes.
  37399. @end table
  37400. @end table
  37401. @value{GDBN} must be linked with the Expat library to support XML
  37402. branch trace configuration discovery. @xref{Expat}.
  37403. The formal DTD for the branch trace configuration format is given below:
  37404. @smallexample
  37405. <!ELEMENT btrace-conf (bts?, pt?)>
  37406. <!ATTLIST btrace-conf version CDATA #FIXED "1.0">
  37407. <!ELEMENT bts EMPTY>
  37408. <!ATTLIST bts size CDATA #IMPLIED>
  37409. <!ELEMENT pt EMPTY>
  37410. <!ATTLIST pt size CDATA #IMPLIED>
  37411. @end smallexample
  37412. @include agentexpr.texi
  37413. @node Target Descriptions
  37414. @appendix Target Descriptions
  37415. @cindex target descriptions
  37416. One of the challenges of using @value{GDBN} to debug embedded systems
  37417. is that there are so many minor variants of each processor
  37418. architecture in use. It is common practice for vendors to start with
  37419. a standard processor core --- ARM, PowerPC, or @acronym{MIPS}, for example ---
  37420. and then make changes to adapt it to a particular market niche. Some
  37421. architectures have hundreds of variants, available from dozens of
  37422. vendors. This leads to a number of problems:
  37423. @itemize @bullet
  37424. @item
  37425. With so many different customized processors, it is difficult for
  37426. the @value{GDBN} maintainers to keep up with the changes.
  37427. @item
  37428. Since individual variants may have short lifetimes or limited
  37429. audiences, it may not be worthwhile to carry information about every
  37430. variant in the @value{GDBN} source tree.
  37431. @item
  37432. When @value{GDBN} does support the architecture of the embedded system
  37433. at hand, the task of finding the correct architecture name to give the
  37434. @command{set architecture} command can be error-prone.
  37435. @end itemize
  37436. To address these problems, the @value{GDBN} remote protocol allows a
  37437. target system to not only identify itself to @value{GDBN}, but to
  37438. actually describe its own features. This lets @value{GDBN} support
  37439. processor variants it has never seen before --- to the extent that the
  37440. descriptions are accurate, and that @value{GDBN} understands them.
  37441. @value{GDBN} must be linked with the Expat library to support XML
  37442. target descriptions. @xref{Expat}.
  37443. @menu
  37444. * Retrieving Descriptions:: How descriptions are fetched from a target.
  37445. * Target Description Format:: The contents of a target description.
  37446. * Predefined Target Types:: Standard types available for target
  37447. descriptions.
  37448. * Enum Target Types:: How to define enum target types.
  37449. * Standard Target Features:: Features @value{GDBN} knows about.
  37450. @end menu
  37451. @node Retrieving Descriptions
  37452. @section Retrieving Descriptions
  37453. Target descriptions can be read from the target automatically, or
  37454. specified by the user manually. The default behavior is to read the
  37455. description from the target. @value{GDBN} retrieves it via the remote
  37456. protocol using @samp{qXfer} requests (@pxref{General Query Packets,
  37457. qXfer}). The @var{annex} in the @samp{qXfer} packet will be
  37458. @samp{target.xml}. The contents of the @samp{target.xml} annex are an
  37459. XML document, of the form described in @ref{Target Description
  37460. Format}.
  37461. Alternatively, you can specify a file to read for the target description.
  37462. If a file is set, the target will not be queried. The commands to
  37463. specify a file are:
  37464. @table @code
  37465. @cindex set tdesc filename
  37466. @item set tdesc filename @var{path}
  37467. Read the target description from @var{path}.
  37468. @cindex unset tdesc filename
  37469. @item unset tdesc filename
  37470. Do not read the XML target description from a file. @value{GDBN}
  37471. will use the description supplied by the current target.
  37472. @cindex show tdesc filename
  37473. @item show tdesc filename
  37474. Show the filename to read for a target description, if any.
  37475. @end table
  37476. @node Target Description Format
  37477. @section Target Description Format
  37478. @cindex target descriptions, XML format
  37479. A target description annex is an @uref{http://www.w3.org/XML/, XML}
  37480. document which complies with the Document Type Definition provided in
  37481. the @value{GDBN} sources in @file{gdb/features/gdb-target.dtd}. This
  37482. means you can use generally available tools like @command{xmllint} to
  37483. check that your feature descriptions are well-formed and valid.
  37484. However, to help people unfamiliar with XML write descriptions for
  37485. their targets, we also describe the grammar here.
  37486. Target descriptions can identify the architecture of the remote target
  37487. and (for some architectures) provide information about custom register
  37488. sets. They can also identify the OS ABI of the remote target.
  37489. @value{GDBN} can use this information to autoconfigure for your
  37490. target, or to warn you if you connect to an unsupported target.
  37491. Here is a simple target description:
  37492. @smallexample
  37493. <target version="1.0">
  37494. <architecture>i386:x86-64</architecture>
  37495. </target>
  37496. @end smallexample
  37497. @noindent
  37498. This minimal description only says that the target uses
  37499. the x86-64 architecture.
  37500. A target description has the following overall form, with [ ] marking
  37501. optional elements and @dots{} marking repeatable elements. The elements
  37502. are explained further below.
  37503. @smallexample
  37504. <?xml version="1.0"?>
  37505. <!DOCTYPE target SYSTEM "gdb-target.dtd">
  37506. <target version="1.0">
  37507. @r{[}@var{architecture}@r{]}
  37508. @r{[}@var{osabi}@r{]}
  37509. @r{[}@var{compatible}@r{]}
  37510. @r{[}@var{feature}@dots{}@r{]}
  37511. </target>
  37512. @end smallexample
  37513. @noindent
  37514. The description is generally insensitive to whitespace and line
  37515. breaks, under the usual common-sense rules. The XML version
  37516. declaration and document type declaration can generally be omitted
  37517. (@value{GDBN} does not require them), but specifying them may be
  37518. useful for XML validation tools. The @samp{version} attribute for
  37519. @samp{<target>} may also be omitted, but we recommend
  37520. including it; if future versions of @value{GDBN} use an incompatible
  37521. revision of @file{gdb-target.dtd}, they will detect and report
  37522. the version mismatch.
  37523. @subsection Inclusion
  37524. @cindex target descriptions, inclusion
  37525. @cindex XInclude
  37526. @ifnotinfo
  37527. @cindex <xi:include>
  37528. @end ifnotinfo
  37529. It can sometimes be valuable to split a target description up into
  37530. several different annexes, either for organizational purposes, or to
  37531. share files between different possible target descriptions. You can
  37532. divide a description into multiple files by replacing any element of
  37533. the target description with an inclusion directive of the form:
  37534. @smallexample
  37535. <xi:include href="@var{document}"/>
  37536. @end smallexample
  37537. @noindent
  37538. When @value{GDBN} encounters an element of this form, it will retrieve
  37539. the named XML @var{document}, and replace the inclusion directive with
  37540. the contents of that document. If the current description was read
  37541. using @samp{qXfer}, then so will be the included document;
  37542. @var{document} will be interpreted as the name of an annex. If the
  37543. current description was read from a file, @value{GDBN} will look for
  37544. @var{document} as a file in the same directory where it found the
  37545. original description.
  37546. @subsection Architecture
  37547. @cindex <architecture>
  37548. An @samp{<architecture>} element has this form:
  37549. @smallexample
  37550. <architecture>@var{arch}</architecture>
  37551. @end smallexample
  37552. @var{arch} is one of the architectures from the set accepted by
  37553. @code{set architecture} (@pxref{Targets, ,Specifying a Debugging Target}).
  37554. @subsection OS ABI
  37555. @cindex @code{<osabi>}
  37556. This optional field was introduced in @value{GDBN} version 7.0.
  37557. Previous versions of @value{GDBN} ignore it.
  37558. An @samp{<osabi>} element has this form:
  37559. @smallexample
  37560. <osabi>@var{abi-name}</osabi>
  37561. @end smallexample
  37562. @var{abi-name} is an OS ABI name from the same selection accepted by
  37563. @w{@code{set osabi}} (@pxref{ABI, ,Configuring the Current ABI}).
  37564. @subsection Compatible Architecture
  37565. @cindex @code{<compatible>}
  37566. This optional field was introduced in @value{GDBN} version 7.0.
  37567. Previous versions of @value{GDBN} ignore it.
  37568. A @samp{<compatible>} element has this form:
  37569. @smallexample
  37570. <compatible>@var{arch}</compatible>
  37571. @end smallexample
  37572. @var{arch} is one of the architectures from the set accepted by
  37573. @code{set architecture} (@pxref{Targets, ,Specifying a Debugging Target}).
  37574. A @samp{<compatible>} element is used to specify that the target
  37575. is able to run binaries in some other than the main target architecture
  37576. given by the @samp{<architecture>} element. For example, on the
  37577. Cell Broadband Engine, the main architecture is @code{powerpc:common}
  37578. or @code{powerpc:common64}, but the system is able to run binaries
  37579. in the @code{spu} architecture as well. The way to describe this
  37580. capability with @samp{<compatible>} is as follows:
  37581. @smallexample
  37582. <architecture>powerpc:common</architecture>
  37583. <compatible>spu</compatible>
  37584. @end smallexample
  37585. @subsection Features
  37586. @cindex <feature>
  37587. Each @samp{<feature>} describes some logical portion of the target
  37588. system. Features are currently used to describe available CPU
  37589. registers and the types of their contents. A @samp{<feature>} element
  37590. has this form:
  37591. @smallexample
  37592. <feature name="@var{name}">
  37593. @r{[}@var{type}@dots{}@r{]}
  37594. @var{reg}@dots{}
  37595. </feature>
  37596. @end smallexample
  37597. @noindent
  37598. Each feature's name should be unique within the description. The name
  37599. of a feature does not matter unless @value{GDBN} has some special
  37600. knowledge of the contents of that feature; if it does, the feature
  37601. should have its standard name. @xref{Standard Target Features}.
  37602. @subsection Types
  37603. Any register's value is a collection of bits which @value{GDBN} must
  37604. interpret. The default interpretation is a two's complement integer,
  37605. but other types can be requested by name in the register description.
  37606. Some predefined types are provided by @value{GDBN} (@pxref{Predefined
  37607. Target Types}), and the description can define additional composite
  37608. and enum types.
  37609. Each type element must have an @samp{id} attribute, which gives
  37610. a unique (within the containing @samp{<feature>}) name to the type.
  37611. Types must be defined before they are used.
  37612. @cindex <vector>
  37613. Some targets offer vector registers, which can be treated as arrays
  37614. of scalar elements. These types are written as @samp{<vector>} elements,
  37615. specifying the array element type, @var{type}, and the number of elements,
  37616. @var{count}:
  37617. @smallexample
  37618. <vector id="@var{id}" type="@var{type}" count="@var{count}"/>
  37619. @end smallexample
  37620. @cindex <union>
  37621. If a register's value is usefully viewed in multiple ways, define it
  37622. with a union type containing the useful representations. The
  37623. @samp{<union>} element contains one or more @samp{<field>} elements,
  37624. each of which has a @var{name} and a @var{type}:
  37625. @smallexample
  37626. <union id="@var{id}">
  37627. <field name="@var{name}" type="@var{type}"/>
  37628. @dots{}
  37629. </union>
  37630. @end smallexample
  37631. @cindex <struct>
  37632. @cindex <flags>
  37633. If a register's value is composed from several separate values, define
  37634. it with either a structure type or a flags type.
  37635. A flags type may only contain bitfields.
  37636. A structure type may either contain only bitfields or contain no bitfields.
  37637. If the value contains only bitfields, its total size in bytes must be
  37638. specified.
  37639. Non-bitfield values have a @var{name} and @var{type}.
  37640. @smallexample
  37641. <struct id="@var{id}">
  37642. <field name="@var{name}" type="@var{type}"/>
  37643. @dots{}
  37644. </struct>
  37645. @end smallexample
  37646. Both @var{name} and @var{type} values are required.
  37647. No implicit padding is added.
  37648. Bitfield values have a @var{name}, @var{start}, @var{end} and @var{type}.
  37649. @smallexample
  37650. <struct id="@var{id}" size="@var{size}">
  37651. <field name="@var{name}" start="@var{start}" end="@var{end}" type="@var{type}"/>
  37652. @dots{}
  37653. </struct>
  37654. @end smallexample
  37655. @smallexample
  37656. <flags id="@var{id}" size="@var{size}">
  37657. <field name="@var{name}" start="@var{start}" end="@var{end}" type="@var{type}"/>
  37658. @dots{}
  37659. </flags>
  37660. @end smallexample
  37661. The @var{name} value is required.
  37662. Bitfield values may be named with the empty string, @samp{""},
  37663. in which case the field is ``filler'' and its value is not printed.
  37664. Not all bits need to be specified, so ``filler'' fields are optional.
  37665. The @var{start} and @var{end} values are required, and @var{type}
  37666. is optional.
  37667. The field's @var{start} must be less than or equal to its @var{end},
  37668. and zero represents the least significant bit.
  37669. The default value of @var{type} is @code{bool} for single bit fields,
  37670. and an unsigned integer otherwise.
  37671. Which to choose? Structures or flags?
  37672. Registers defined with @samp{flags} have these advantages over
  37673. defining them with @samp{struct}:
  37674. @itemize @bullet
  37675. @item
  37676. Arithmetic may be performed on them as if they were integers.
  37677. @item
  37678. They are printed in a more readable fashion.
  37679. @end itemize
  37680. Registers defined with @samp{struct} have one advantage over
  37681. defining them with @samp{flags}:
  37682. @itemize @bullet
  37683. @item
  37684. One can fetch individual fields like in @samp{C}.
  37685. @smallexample
  37686. (gdb) print $my_struct_reg.field3
  37687. $1 = 42
  37688. @end smallexample
  37689. @end itemize
  37690. @subsection Registers
  37691. @cindex <reg>
  37692. Each register is represented as an element with this form:
  37693. @smallexample
  37694. <reg name="@var{name}"
  37695. bitsize="@var{size}"
  37696. @r{[}regnum="@var{num}"@r{]}
  37697. @r{[}save-restore="@var{save-restore}"@r{]}
  37698. @r{[}type="@var{type}"@r{]}
  37699. @r{[}group="@var{group}"@r{]}/>
  37700. @end smallexample
  37701. @noindent
  37702. The components are as follows:
  37703. @table @var
  37704. @item name
  37705. The register's name; it must be unique within the target description.
  37706. @item bitsize
  37707. The register's size, in bits.
  37708. @item regnum
  37709. The register's number. If omitted, a register's number is one greater
  37710. than that of the previous register (either in the current feature or in
  37711. a preceding feature); the first register in the target description
  37712. defaults to zero. This register number is used to read or write
  37713. the register; e.g.@: it is used in the remote @code{p} and @code{P}
  37714. packets, and registers appear in the @code{g} and @code{G} packets
  37715. in order of increasing register number.
  37716. @item save-restore
  37717. Whether the register should be preserved across inferior function
  37718. calls; this must be either @code{yes} or @code{no}. The default is
  37719. @code{yes}, which is appropriate for most registers except for
  37720. some system control registers; this is not related to the target's
  37721. ABI.
  37722. @item type
  37723. The type of the register. It may be a predefined type, a type
  37724. defined in the current feature, or one of the special types @code{int}
  37725. and @code{float}. @code{int} is an integer type of the correct size
  37726. for @var{bitsize}, and @code{float} is a floating point type (in the
  37727. architecture's normal floating point format) of the correct size for
  37728. @var{bitsize}. The default is @code{int}.
  37729. @item group
  37730. The register group to which this register belongs. It can be one of the
  37731. standard register groups @code{general}, @code{float}, @code{vector} or an
  37732. arbitrary string. Group names should be limited to alphanumeric characters.
  37733. If a group name is made up of multiple words the words may be separated by
  37734. hyphens; e.g.@: @code{special-group} or @code{ultra-special-group}. If no
  37735. @var{group} is specified, @value{GDBN} will not display the register in
  37736. @code{info registers}.
  37737. @end table
  37738. @node Predefined Target Types
  37739. @section Predefined Target Types
  37740. @cindex target descriptions, predefined types
  37741. Type definitions in the self-description can build up composite types
  37742. from basic building blocks, but can not define fundamental types. Instead,
  37743. standard identifiers are provided by @value{GDBN} for the fundamental
  37744. types. The currently supported types are:
  37745. @table @code
  37746. @item bool
  37747. Boolean type, occupying a single bit.
  37748. @item int8
  37749. @itemx int16
  37750. @itemx int24
  37751. @itemx int32
  37752. @itemx int64
  37753. @itemx int128
  37754. Signed integer types holding the specified number of bits.
  37755. @item uint8
  37756. @itemx uint16
  37757. @itemx uint24
  37758. @itemx uint32
  37759. @itemx uint64
  37760. @itemx uint128
  37761. Unsigned integer types holding the specified number of bits.
  37762. @item code_ptr
  37763. @itemx data_ptr
  37764. Pointers to unspecified code and data. The program counter and
  37765. any dedicated return address register may be marked as code
  37766. pointers; printing a code pointer converts it into a symbolic
  37767. address. The stack pointer and any dedicated address registers
  37768. may be marked as data pointers.
  37769. @item ieee_half
  37770. Half precision IEEE floating point.
  37771. @item ieee_single
  37772. Single precision IEEE floating point.
  37773. @item ieee_double
  37774. Double precision IEEE floating point.
  37775. @item bfloat16
  37776. The 16-bit @dfn{brain floating point} format used e.g.@: by x86 and ARM.
  37777. @item arm_fpa_ext
  37778. The 12-byte extended precision format used by ARM FPA registers.
  37779. @item i387_ext
  37780. The 10-byte extended precision format used by x87 registers.
  37781. @item i386_eflags
  37782. 32bit @sc{eflags} register used by x86.
  37783. @item i386_mxcsr
  37784. 32bit @sc{mxcsr} register used by x86.
  37785. @end table
  37786. @node Enum Target Types
  37787. @section Enum Target Types
  37788. @cindex target descriptions, enum types
  37789. Enum target types are useful in @samp{struct} and @samp{flags}
  37790. register descriptions. @xref{Target Description Format}.
  37791. Enum types have a name, size and a list of name/value pairs.
  37792. @smallexample
  37793. <enum id="@var{id}" size="@var{size}">
  37794. <evalue name="@var{name}" value="@var{value}"/>
  37795. @dots{}
  37796. </enum>
  37797. @end smallexample
  37798. Enums must be defined before they are used.
  37799. @smallexample
  37800. <enum id="levels_type" size="4">
  37801. <evalue name="low" value="0"/>
  37802. <evalue name="high" value="1"/>
  37803. </enum>
  37804. <flags id="flags_type" size="4">
  37805. <field name="X" start="0"/>
  37806. <field name="LEVEL" start="1" end="1" type="levels_type"/>
  37807. </flags>
  37808. <reg name="flags" bitsize="32" type="flags_type"/>
  37809. @end smallexample
  37810. Given that description, a value of 3 for the @samp{flags} register
  37811. would be printed as:
  37812. @smallexample
  37813. (gdb) info register flags
  37814. flags 0x3 [ X LEVEL=high ]
  37815. @end smallexample
  37816. @node Standard Target Features
  37817. @section Standard Target Features
  37818. @cindex target descriptions, standard features
  37819. A target description must contain either no registers or all the
  37820. target's registers. If the description contains no registers, then
  37821. @value{GDBN} will assume a default register layout, selected based on
  37822. the architecture. If the description contains any registers, the
  37823. default layout will not be used; the standard registers must be
  37824. described in the target description, in such a way that @value{GDBN}
  37825. can recognize them.
  37826. This is accomplished by giving specific names to feature elements
  37827. which contain standard registers. @value{GDBN} will look for features
  37828. with those names and verify that they contain the expected registers;
  37829. if any known feature is missing required registers, or if any required
  37830. feature is missing, @value{GDBN} will reject the target
  37831. description. You can add additional registers to any of the
  37832. standard features --- @value{GDBN} will display them just as if
  37833. they were added to an unrecognized feature.
  37834. This section lists the known features and their expected contents.
  37835. Sample XML documents for these features are included in the
  37836. @value{GDBN} source tree, in the directory @file{gdb/features}.
  37837. Names recognized by @value{GDBN} should include the name of the
  37838. company or organization which selected the name, and the overall
  37839. architecture to which the feature applies; so e.g.@: the feature
  37840. containing ARM core registers is named @samp{org.gnu.gdb.arm.core}.
  37841. The names of registers are not case sensitive for the purpose
  37842. of recognizing standard features, but @value{GDBN} will only display
  37843. registers using the capitalization used in the description.
  37844. @menu
  37845. * AArch64 Features::
  37846. * ARC Features::
  37847. * ARM Features::
  37848. * i386 Features::
  37849. * LoongArch Features::
  37850. * MicroBlaze Features::
  37851. * MIPS Features::
  37852. * M68K Features::
  37853. * NDS32 Features::
  37854. * Nios II Features::
  37855. * OpenRISC 1000 Features::
  37856. * PowerPC Features::
  37857. * RISC-V Features::
  37858. * RX Features::
  37859. * S/390 and System z Features::
  37860. * Sparc Features::
  37861. * TIC6x Features::
  37862. @end menu
  37863. @node AArch64 Features
  37864. @subsection AArch64 Features
  37865. @cindex target descriptions, AArch64 features
  37866. The @samp{org.gnu.gdb.aarch64.core} feature is required for AArch64
  37867. targets. It should contain registers @samp{x0} through @samp{x30},
  37868. @samp{sp}, @samp{pc}, and @samp{cpsr}.
  37869. The @samp{org.gnu.gdb.aarch64.fpu} feature is optional. If present,
  37870. it should contain registers @samp{v0} through @samp{v31}, @samp{fpsr},
  37871. and @samp{fpcr}.
  37872. The @samp{org.gnu.gdb.aarch64.sve} feature is optional. If present,
  37873. it should contain registers @samp{z0} through @samp{z31}, @samp{p0}
  37874. through @samp{p15}, @samp{ffr} and @samp{vg}.
  37875. The @samp{org.gnu.gdb.aarch64.pauth} feature is optional. If present,
  37876. it should contain registers @samp{pauth_dmask} and @samp{pauth_cmask}.
  37877. @node ARC Features
  37878. @subsection ARC Features
  37879. @cindex target descriptions, ARC Features
  37880. ARC processors are so configurable that even core registers and their numbers
  37881. are not predetermined completely. Moreover, @emph{flags} and @emph{PC}
  37882. registers, which are important to @value{GDBN}, are not ``core'' registers in
  37883. ARC. Therefore, there are two features that their presence is mandatory:
  37884. @samp{org.gnu.gdb.arc.core} and @samp{org.gnu.gdb.arc.aux}.
  37885. The @samp{org.gnu.gdb.arc.core} feature is required for all targets. It must
  37886. contain registers:
  37887. @itemize @minus
  37888. @item
  37889. @samp{r0} through @samp{r25} for normal register file targets.
  37890. @item
  37891. @samp{r0} through @samp{r3}, and @samp{r10} through @samp{r15} for reduced
  37892. register file targets.
  37893. @item
  37894. @samp{gp}, @samp{fp}, @samp{sp}, @samp{r30}@footnote{Not necessary for ARCv1.},
  37895. @samp{blink}, @samp{lp_count}, @samp{pcl}.
  37896. @end itemize
  37897. In case of an ARCompact target (ARCv1 ISA), the @samp{org.gnu.gdb.arc.core}
  37898. feature may contain registers @samp{ilink1} and @samp{ilink2}. While in case
  37899. of ARC EM and ARC HS targets (ARCv2 ISA), register @samp{ilink} may be present.
  37900. The difference between ARCv1 and ARCv2 is the naming of registers @emph{29th}
  37901. and @emph{30th}. They are called @samp{ilink1} and @samp{ilink2} for ARCv1 and
  37902. are optional. For ARCv2, they are called @samp{ilink} and @samp{r30} and only
  37903. @samp{ilink} is optional. The optionality of @samp{ilink*} registers is
  37904. because of their inaccessibility during user space debugging sessions.
  37905. Extension core registers @samp{r32} through @samp{r59} are optional and their
  37906. existence depends on the configuration. When debugging GNU/Linux applications,
  37907. i.e.@: user space debugging, these core registers are not available.
  37908. The @samp{org.gnu.gdb.arc.aux} feature is required for all ARC targets. Here
  37909. is the list of registers pertinent to this feature:
  37910. @itemize @minus
  37911. @item
  37912. mandatory: @samp{pc} and @samp{status32}.
  37913. @item
  37914. optional: @samp{lp_start}, @samp{lp_end}, and @samp{bta}.
  37915. @end itemize
  37916. @node ARM Features
  37917. @subsection ARM Features
  37918. @cindex target descriptions, ARM features
  37919. The @samp{org.gnu.gdb.arm.core} feature is required for non-M-profile
  37920. ARM targets.
  37921. It should contain registers @samp{r0} through @samp{r13}, @samp{sp},
  37922. @samp{lr}, @samp{pc}, and @samp{cpsr}.
  37923. For M-profile targets (e.g.@: Cortex-M3), the @samp{org.gnu.gdb.arm.core}
  37924. feature is replaced by @samp{org.gnu.gdb.arm.m-profile}. It should contain
  37925. registers @samp{r0} through @samp{r13}, @samp{sp}, @samp{lr}, @samp{pc},
  37926. and @samp{xpsr}.
  37927. The @samp{org.gnu.gdb.arm.fpa} feature is optional. If present, it
  37928. should contain registers @samp{f0} through @samp{f7} and @samp{fps}.
  37929. The @samp{org.gnu.gdb.arm.m-profile-mve} feature is optional. If present, it
  37930. must contain register @samp{vpr}.
  37931. If the @samp{org.gnu.gdb.arm.m-profile-mve} feature is available, @value{GDBN}
  37932. will synthesize the @samp{p0} pseudo register from @samp{vpr} contents.
  37933. If the @samp{org.gnu.gdb.arm.vfp} feature is available alongside the
  37934. @samp{org.gnu.gdb.arm.m-profile-mve} feature, @value{GDBN} will
  37935. synthesize the @samp{q} pseudo registers from @samp{d} register
  37936. contents.
  37937. The @samp{org.gnu.gdb.xscale.iwmmxt} feature is optional. If present,
  37938. it should contain at least registers @samp{wR0} through @samp{wR15} and
  37939. @samp{wCGR0} through @samp{wCGR3}. The @samp{wCID}, @samp{wCon},
  37940. @samp{wCSSF}, and @samp{wCASF} registers are optional.
  37941. The @samp{org.gnu.gdb.arm.vfp} feature is optional. If present, it
  37942. should contain at least registers @samp{d0} through @samp{d15}. If
  37943. they are present, @samp{d16} through @samp{d31} should also be included.
  37944. @value{GDBN} will synthesize the single-precision registers from
  37945. halves of the double-precision registers.
  37946. The @samp{org.gnu.gdb.arm.neon} feature is optional. It does not
  37947. need to contain registers; it instructs @value{GDBN} to display the
  37948. VFP double-precision registers as vectors and to synthesize the
  37949. quad-precision registers from pairs of double-precision registers.
  37950. If this feature is present, @samp{org.gnu.gdb.arm.vfp} must also
  37951. be present and include 32 double-precision registers.
  37952. The @samp{org.gnu.gdb.arm.m-profile-pacbti} feature is optional, and
  37953. acknowledges support for the ARMv8.1-m PACBTI extensions. @value{GDBN}
  37954. will track return address signing states and will decorate backtraces using
  37955. the [PAC] marker, similar to AArch64's PAC extension.
  37956. @xref{AArch64 PAC}.
  37957. @node i386 Features
  37958. @subsection i386 Features
  37959. @cindex target descriptions, i386 features
  37960. The @samp{org.gnu.gdb.i386.core} feature is required for i386/amd64
  37961. targets. It should describe the following registers:
  37962. @itemize @minus
  37963. @item
  37964. @samp{eax} through @samp{edi} plus @samp{eip} for i386
  37965. @item
  37966. @samp{rax} through @samp{r15} plus @samp{rip} for amd64
  37967. @item
  37968. @samp{eflags}, @samp{cs}, @samp{ss}, @samp{ds}, @samp{es},
  37969. @samp{fs}, @samp{gs}
  37970. @item
  37971. @samp{st0} through @samp{st7}
  37972. @item
  37973. @samp{fctrl}, @samp{fstat}, @samp{ftag}, @samp{fiseg}, @samp{fioff},
  37974. @samp{foseg}, @samp{fooff} and @samp{fop}
  37975. @end itemize
  37976. The register sets may be different, depending on the target.
  37977. The @samp{org.gnu.gdb.i386.sse} feature is optional. It should
  37978. describe registers:
  37979. @itemize @minus
  37980. @item
  37981. @samp{xmm0} through @samp{xmm7} for i386
  37982. @item
  37983. @samp{xmm0} through @samp{xmm15} for amd64
  37984. @item
  37985. @samp{mxcsr}
  37986. @end itemize
  37987. The @samp{org.gnu.gdb.i386.avx} feature is optional and requires the
  37988. @samp{org.gnu.gdb.i386.sse} feature. It should
  37989. describe the upper 128 bits of @sc{ymm} registers:
  37990. @itemize @minus
  37991. @item
  37992. @samp{ymm0h} through @samp{ymm7h} for i386
  37993. @item
  37994. @samp{ymm0h} through @samp{ymm15h} for amd64
  37995. @end itemize
  37996. The @samp{org.gnu.gdb.i386.mpx} is an optional feature representing Intel
  37997. Memory Protection Extension (MPX). It should describe the following registers:
  37998. @itemize @minus
  37999. @item
  38000. @samp{bnd0raw} through @samp{bnd3raw} for i386 and amd64.
  38001. @item
  38002. @samp{bndcfgu} and @samp{bndstatus} for i386 and amd64.
  38003. @end itemize
  38004. The @samp{org.gnu.gdb.i386.linux} feature is optional. It should
  38005. describe a single register, @samp{orig_eax}.
  38006. The @samp{org.gnu.gdb.i386.segments} feature is optional. It should
  38007. describe two system registers: @samp{fs_base} and @samp{gs_base}.
  38008. The @samp{org.gnu.gdb.i386.avx512} feature is optional and requires the
  38009. @samp{org.gnu.gdb.i386.avx} feature. It should
  38010. describe additional @sc{xmm} registers:
  38011. @itemize @minus
  38012. @item
  38013. @samp{xmm16h} through @samp{xmm31h}, only valid for amd64.
  38014. @end itemize
  38015. It should describe the upper 128 bits of additional @sc{ymm} registers:
  38016. @itemize @minus
  38017. @item
  38018. @samp{ymm16h} through @samp{ymm31h}, only valid for amd64.
  38019. @end itemize
  38020. It should
  38021. describe the upper 256 bits of @sc{zmm} registers:
  38022. @itemize @minus
  38023. @item
  38024. @samp{zmm0h} through @samp{zmm7h} for i386.
  38025. @item
  38026. @samp{zmm0h} through @samp{zmm15h} for amd64.
  38027. @end itemize
  38028. It should
  38029. describe the additional @sc{zmm} registers:
  38030. @itemize @minus
  38031. @item
  38032. @samp{zmm16h} through @samp{zmm31h}, only valid for amd64.
  38033. @end itemize
  38034. The @samp{org.gnu.gdb.i386.pkeys} feature is optional. It should
  38035. describe a single register, @samp{pkru}. It is a 32-bit register
  38036. valid for i386 and amd64.
  38037. @node LoongArch Features
  38038. @subsection LoongArch Features
  38039. @cindex target descriptions, LoongArch Features
  38040. The @samp{org.gnu.gdb.loongarch.base} feature is required for LoongArch
  38041. targets. It should contain the registers @samp{r0} through @samp{r31},
  38042. @samp{pc}, and @samp{badv}. Either the architectural names (@samp{r0},
  38043. @samp{r1}, etc) can be used, or the ABI names (@samp{zero}, @samp{ra}, etc).
  38044. @node MicroBlaze Features
  38045. @subsection MicroBlaze Features
  38046. @cindex target descriptions, MicroBlaze features
  38047. The @samp{org.gnu.gdb.microblaze.core} feature is required for MicroBlaze
  38048. targets. It should contain registers @samp{r0} through @samp{r31},
  38049. @samp{rpc}, @samp{rmsr}, @samp{rear}, @samp{resr}, @samp{rfsr}, @samp{rbtr},
  38050. @samp{rpvr}, @samp{rpvr1} through @samp{rpvr11}, @samp{redr}, @samp{rpid},
  38051. @samp{rzpr}, @samp{rtlbx}, @samp{rtlbsx}, @samp{rtlblo}, and @samp{rtlbhi}.
  38052. The @samp{org.gnu.gdb.microblaze.stack-protect} feature is optional.
  38053. If present, it should contain registers @samp{rshr} and @samp{rslr}
  38054. @node MIPS Features
  38055. @subsection @acronym{MIPS} Features
  38056. @cindex target descriptions, @acronym{MIPS} features
  38057. The @samp{org.gnu.gdb.mips.cpu} feature is required for @acronym{MIPS} targets.
  38058. It should contain registers @samp{r0} through @samp{r31}, @samp{lo},
  38059. @samp{hi}, and @samp{pc}. They may be 32-bit or 64-bit depending
  38060. on the target.
  38061. The @samp{org.gnu.gdb.mips.cp0} feature is also required. It should
  38062. contain at least the @samp{status}, @samp{badvaddr}, and @samp{cause}
  38063. registers. They may be 32-bit or 64-bit depending on the target.
  38064. The @samp{org.gnu.gdb.mips.fpu} feature is currently required, though
  38065. it may be optional in a future version of @value{GDBN}. It should
  38066. contain registers @samp{f0} through @samp{f31}, @samp{fcsr}, and
  38067. @samp{fir}. They may be 32-bit or 64-bit depending on the target.
  38068. The @samp{org.gnu.gdb.mips.dsp} feature is optional. It should
  38069. contain registers @samp{hi1} through @samp{hi3}, @samp{lo1} through
  38070. @samp{lo3}, and @samp{dspctl}. The @samp{dspctl} register should
  38071. be 32-bit and the rest may be 32-bit or 64-bit depending on the target.
  38072. The @samp{org.gnu.gdb.mips.linux} feature is optional. It should
  38073. contain a single register, @samp{restart}, which is used by the
  38074. Linux kernel to control restartable syscalls.
  38075. @node M68K Features
  38076. @subsection M68K Features
  38077. @cindex target descriptions, M68K features
  38078. @table @code
  38079. @item @samp{org.gnu.gdb.m68k.core}
  38080. @itemx @samp{org.gnu.gdb.coldfire.core}
  38081. @itemx @samp{org.gnu.gdb.fido.core}
  38082. One of those features must be always present.
  38083. The feature that is present determines which flavor of m68k is
  38084. used. The feature that is present should contain registers
  38085. @samp{d0} through @samp{d7}, @samp{a0} through @samp{a5}, @samp{fp},
  38086. @samp{sp}, @samp{ps} and @samp{pc}.
  38087. @item @samp{org.gnu.gdb.coldfire.fp}
  38088. This feature is optional. If present, it should contain registers
  38089. @samp{fp0} through @samp{fp7}, @samp{fpcontrol}, @samp{fpstatus} and
  38090. @samp{fpiaddr}.
  38091. Note that, despite the fact that this feature's name says
  38092. @samp{coldfire}, it is used to describe any floating point registers.
  38093. The size of the registers must match the main m68k flavor; so, for
  38094. example, if the primary feature is reported as @samp{coldfire}, then
  38095. 64-bit floating point registers are required.
  38096. @end table
  38097. @node NDS32 Features
  38098. @subsection NDS32 Features
  38099. @cindex target descriptions, NDS32 features
  38100. The @samp{org.gnu.gdb.nds32.core} feature is required for NDS32
  38101. targets. It should contain at least registers @samp{r0} through
  38102. @samp{r10}, @samp{r15}, @samp{fp}, @samp{gp}, @samp{lp}, @samp{sp},
  38103. and @samp{pc}.
  38104. The @samp{org.gnu.gdb.nds32.fpu} feature is optional. If present,
  38105. it should contain 64-bit double-precision floating-point registers
  38106. @samp{fd0} through @emph{fdN}, which should be @samp{fd3}, @samp{fd7},
  38107. @samp{fd15}, or @samp{fd31} based on the FPU configuration implemented.
  38108. @emph{Note:} The first sixteen 64-bit double-precision floating-point
  38109. registers are overlapped with the thirty-two 32-bit single-precision
  38110. floating-point registers. The 32-bit single-precision registers, if
  38111. not being listed explicitly, will be synthesized from halves of the
  38112. overlapping 64-bit double-precision registers. Listing 32-bit
  38113. single-precision registers explicitly is deprecated, and the
  38114. support to it could be totally removed some day.
  38115. @node Nios II Features
  38116. @subsection Nios II Features
  38117. @cindex target descriptions, Nios II features
  38118. The @samp{org.gnu.gdb.nios2.cpu} feature is required for Nios II
  38119. targets. It should contain the 32 core registers (@samp{zero},
  38120. @samp{at}, @samp{r2} through @samp{r23}, @samp{et} through @samp{ra}),
  38121. @samp{pc}, and the 16 control registers (@samp{status} through
  38122. @samp{mpuacc}).
  38123. @node OpenRISC 1000 Features
  38124. @subsection Openrisc 1000 Features
  38125. @cindex target descriptions, OpenRISC 1000 features
  38126. The @samp{org.gnu.gdb.or1k.group0} feature is required for OpenRISC 1000
  38127. targets. It should contain the 32 general purpose registers (@samp{r0}
  38128. through @samp{r31}), @samp{ppc}, @samp{npc} and @samp{sr}.
  38129. @node PowerPC Features
  38130. @subsection PowerPC Features
  38131. @cindex target descriptions, PowerPC features
  38132. The @samp{org.gnu.gdb.power.core} feature is required for PowerPC
  38133. targets. It should contain registers @samp{r0} through @samp{r31},
  38134. @samp{pc}, @samp{msr}, @samp{cr}, @samp{lr}, @samp{ctr}, and
  38135. @samp{xer}. They may be 32-bit or 64-bit depending on the target.
  38136. The @samp{org.gnu.gdb.power.fpu} feature is optional. It should
  38137. contain registers @samp{f0} through @samp{f31} and @samp{fpscr}.
  38138. The @samp{org.gnu.gdb.power.altivec} feature is optional. It should
  38139. contain registers @samp{vr0} through @samp{vr31}, @samp{vscr}, and
  38140. @samp{vrsave}. @value{GDBN} will define pseudo-registers @samp{v0}
  38141. through @samp{v31} as aliases for the corresponding @samp{vrX}
  38142. registers.
  38143. The @samp{org.gnu.gdb.power.vsx} feature is optional. It should
  38144. contain registers @samp{vs0h} through @samp{vs31h}. @value{GDBN} will
  38145. combine these registers with the floating point registers (@samp{f0}
  38146. through @samp{f31}) and the altivec registers (@samp{vr0} through
  38147. @samp{vr31}) to present the 128-bit wide registers @samp{vs0} through
  38148. @samp{vs63}, the set of vector-scalar registers for POWER7.
  38149. Therefore, this feature requires both @samp{org.gnu.gdb.power.fpu} and
  38150. @samp{org.gnu.gdb.power.altivec}.
  38151. The @samp{org.gnu.gdb.power.spe} feature is optional. It should
  38152. contain registers @samp{ev0h} through @samp{ev31h}, @samp{acc}, and
  38153. @samp{spefscr}. SPE targets should provide 32-bit registers in
  38154. @samp{org.gnu.gdb.power.core} and provide the upper halves in
  38155. @samp{ev0h} through @samp{ev31h}. @value{GDBN} will combine
  38156. these to present registers @samp{ev0} through @samp{ev31} to the
  38157. user.
  38158. The @samp{org.gnu.gdb.power.ppr} feature is optional. It should
  38159. contain the 64-bit register @samp{ppr}.
  38160. The @samp{org.gnu.gdb.power.dscr} feature is optional. It should
  38161. contain the 64-bit register @samp{dscr}.
  38162. The @samp{org.gnu.gdb.power.tar} feature is optional. It should
  38163. contain the 64-bit register @samp{tar}.
  38164. The @samp{org.gnu.gdb.power.ebb} feature is optional. It should
  38165. contain registers @samp{bescr}, @samp{ebbhr} and @samp{ebbrr}, all
  38166. 64-bit wide.
  38167. The @samp{org.gnu.gdb.power.linux.pmu} feature is optional. It should
  38168. contain registers @samp{mmcr0}, @samp{mmcr2}, @samp{siar}, @samp{sdar}
  38169. and @samp{sier}, all 64-bit wide. This is the subset of the isa 2.07
  38170. server PMU registers provided by @sc{gnu}/Linux.
  38171. The @samp{org.gnu.gdb.power.htm.spr} feature is optional. It should
  38172. contain registers @samp{tfhar}, @samp{texasr} and @samp{tfiar}, all
  38173. 64-bit wide.
  38174. The @samp{org.gnu.gdb.power.htm.core} feature is optional. It should
  38175. contain the checkpointed general-purpose registers @samp{cr0} through
  38176. @samp{cr31}, as well as the checkpointed registers @samp{clr} and
  38177. @samp{cctr}. These registers may all be either 32-bit or 64-bit
  38178. depending on the target. It should also contain the checkpointed
  38179. registers @samp{ccr} and @samp{cxer}, which should both be 32-bit
  38180. wide.
  38181. The @samp{org.gnu.gdb.power.htm.fpu} feature is optional. It should
  38182. contain the checkpointed 64-bit floating-point registers @samp{cf0}
  38183. through @samp{cf31}, as well as the checkpointed 64-bit register
  38184. @samp{cfpscr}.
  38185. The @samp{org.gnu.gdb.power.htm.altivec} feature is optional. It
  38186. should contain the checkpointed altivec registers @samp{cvr0} through
  38187. @samp{cvr31}, all 128-bit wide. It should also contain the
  38188. checkpointed registers @samp{cvscr} and @samp{cvrsave}, both 32-bit
  38189. wide.
  38190. The @samp{org.gnu.gdb.power.htm.vsx} feature is optional. It should
  38191. contain registers @samp{cvs0h} through @samp{cvs31h}. @value{GDBN}
  38192. will combine these registers with the checkpointed floating point
  38193. registers (@samp{cf0} through @samp{cf31}) and the checkpointed
  38194. altivec registers (@samp{cvr0} through @samp{cvr31}) to present the
  38195. 128-bit wide checkpointed vector-scalar registers @samp{cvs0} through
  38196. @samp{cvs63}. Therefore, this feature requires both
  38197. @samp{org.gnu.gdb.power.htm.altivec} and
  38198. @samp{org.gnu.gdb.power.htm.fpu}.
  38199. The @samp{org.gnu.gdb.power.htm.ppr} feature is optional. It should
  38200. contain the 64-bit checkpointed register @samp{cppr}.
  38201. The @samp{org.gnu.gdb.power.htm.dscr} feature is optional. It should
  38202. contain the 64-bit checkpointed register @samp{cdscr}.
  38203. The @samp{org.gnu.gdb.power.htm.tar} feature is optional. It should
  38204. contain the 64-bit checkpointed register @samp{ctar}.
  38205. @node RISC-V Features
  38206. @subsection RISC-V Features
  38207. @cindex target descriptions, RISC-V Features
  38208. The @samp{org.gnu.gdb.riscv.cpu} feature is required for RISC-V
  38209. targets. It should contain the registers @samp{x0} through
  38210. @samp{x31}, and @samp{pc}. Either the architectural names (@samp{x0},
  38211. @samp{x1}, etc) can be used, or the ABI names (@samp{zero}, @samp{ra},
  38212. etc).
  38213. The @samp{org.gnu.gdb.riscv.fpu} feature is optional. If present, it
  38214. should contain registers @samp{f0} through @samp{f31}, @samp{fflags},
  38215. @samp{frm}, and @samp{fcsr}. As with the cpu feature, either the
  38216. architectural register names, or the ABI names can be used.
  38217. The @samp{org.gnu.gdb.riscv.virtual} feature is optional. If present,
  38218. it should contain registers that are not backed by real registers on
  38219. the target, but are instead virtual, where the register value is
  38220. derived from other target state. In many ways these are like
  38221. @value{GDBN}s pseudo-registers, except implemented by the target.
  38222. Currently the only register expected in this set is the one byte
  38223. @samp{priv} register that contains the target's privilege level in the
  38224. least significant two bits.
  38225. The @samp{org.gnu.gdb.riscv.csr} feature is optional. If present, it
  38226. should contain all of the target's standard CSRs. Standard CSRs are
  38227. those defined in the RISC-V specification documents. There is some
  38228. overlap between this feature and the fpu feature; the @samp{fflags},
  38229. @samp{frm}, and @samp{fcsr} registers could be in either feature. The
  38230. expectation is that these registers will be in the fpu feature if the
  38231. target has floating point hardware, but can be moved into the csr
  38232. feature if the target has the floating point control registers, but no
  38233. other floating point hardware.
  38234. The @samp{org.gnu.gdb.riscv.vector} feature is optional. If present,
  38235. it should contain registers @samp{v0} through @samp{v31}, all of which
  38236. must be the same size. These requirements are based on the v0.10
  38237. draft vector extension, as the vector extension is not yet final. In
  38238. the event that the register set of the vector extension changes for
  38239. the final specification, the requirements given here could change for
  38240. future releases of @value{GDBN}.
  38241. @node RX Features
  38242. @subsection RX Features
  38243. @cindex target descriptions, RX Features
  38244. The @samp{org.gnu.gdb.rx.core} feature is required for RX
  38245. targets. It should contain the registers @samp{r0} through
  38246. @samp{r15}, @samp{usp}, @samp{isp}, @samp{psw}, @samp{pc}, @samp{intb},
  38247. @samp{bpsw}, @samp{bpc}, @samp{fintv}, @samp{fpsw}, and @samp{acc}.
  38248. @node S/390 and System z Features
  38249. @subsection S/390 and System z Features
  38250. @cindex target descriptions, S/390 features
  38251. @cindex target descriptions, System z features
  38252. The @samp{org.gnu.gdb.s390.core} feature is required for S/390 and
  38253. System z targets. It should contain the PSW and the 16 general
  38254. registers. In particular, System z targets should provide the 64-bit
  38255. registers @samp{pswm}, @samp{pswa}, and @samp{r0} through @samp{r15}.
  38256. S/390 targets should provide the 32-bit versions of these registers.
  38257. A System z target that runs in 31-bit addressing mode should provide
  38258. 32-bit versions of @samp{pswm} and @samp{pswa}, as well as the general
  38259. register's upper halves @samp{r0h} through @samp{r15h}, and their
  38260. lower halves @samp{r0l} through @samp{r15l}.
  38261. The @samp{org.gnu.gdb.s390.fpr} feature is required. It should
  38262. contain the 64-bit registers @samp{f0} through @samp{f15}, and
  38263. @samp{fpc}.
  38264. The @samp{org.gnu.gdb.s390.acr} feature is required. It should
  38265. contain the 32-bit registers @samp{acr0} through @samp{acr15}.
  38266. The @samp{org.gnu.gdb.s390.linux} feature is optional. It should
  38267. contain the register @samp{orig_r2}, which is 64-bit wide on System z
  38268. targets and 32-bit otherwise. In addition, the feature may contain
  38269. the @samp{last_break} register, whose width depends on the addressing
  38270. mode, as well as the @samp{system_call} register, which is always
  38271. 32-bit wide.
  38272. The @samp{org.gnu.gdb.s390.tdb} feature is optional. It should
  38273. contain the 64-bit registers @samp{tdb0}, @samp{tac}, @samp{tct},
  38274. @samp{atia}, and @samp{tr0} through @samp{tr15}.
  38275. The @samp{org.gnu.gdb.s390.vx} feature is optional. It should contain
  38276. 64-bit wide registers @samp{v0l} through @samp{v15l}, which will be
  38277. combined by @value{GDBN} with the floating point registers @samp{f0}
  38278. through @samp{f15} to present the 128-bit wide vector registers
  38279. @samp{v0} through @samp{v15}. In addition, this feature should
  38280. contain the 128-bit wide vector registers @samp{v16} through
  38281. @samp{v31}.
  38282. The @samp{org.gnu.gdb.s390.gs} feature is optional. It should contain
  38283. the 64-bit wide guarded-storage-control registers @samp{gsd},
  38284. @samp{gssm}, and @samp{gsepla}.
  38285. The @samp{org.gnu.gdb.s390.gsbc} feature is optional. It should contain
  38286. the 64-bit wide guarded-storage broadcast control registers
  38287. @samp{bc_gsd}, @samp{bc_gssm}, and @samp{bc_gsepla}.
  38288. @node Sparc Features
  38289. @subsection Sparc Features
  38290. @cindex target descriptions, sparc32 features
  38291. @cindex target descriptions, sparc64 features
  38292. The @samp{org.gnu.gdb.sparc.cpu} feature is required for sparc32/sparc64
  38293. targets. It should describe the following registers:
  38294. @itemize @minus
  38295. @item
  38296. @samp{g0} through @samp{g7}
  38297. @item
  38298. @samp{o0} through @samp{o7}
  38299. @item
  38300. @samp{l0} through @samp{l7}
  38301. @item
  38302. @samp{i0} through @samp{i7}
  38303. @end itemize
  38304. They may be 32-bit or 64-bit depending on the target.
  38305. Also the @samp{org.gnu.gdb.sparc.fpu} feature is required for sparc32/sparc64
  38306. targets. It should describe the following registers:
  38307. @itemize @minus
  38308. @item
  38309. @samp{f0} through @samp{f31}
  38310. @item
  38311. @samp{f32} through @samp{f62} for sparc64
  38312. @end itemize
  38313. The @samp{org.gnu.gdb.sparc.cp0} feature is required for sparc32/sparc64
  38314. targets. It should describe the following registers:
  38315. @itemize @minus
  38316. @item
  38317. @samp{y}, @samp{psr}, @samp{wim}, @samp{tbr}, @samp{pc}, @samp{npc},
  38318. @samp{fsr}, and @samp{csr} for sparc32
  38319. @item
  38320. @samp{pc}, @samp{npc}, @samp{state}, @samp{fsr}, @samp{fprs}, and @samp{y}
  38321. for sparc64
  38322. @end itemize
  38323. @node TIC6x Features
  38324. @subsection TMS320C6x Features
  38325. @cindex target descriptions, TIC6x features
  38326. @cindex target descriptions, TMS320C6x features
  38327. The @samp{org.gnu.gdb.tic6x.core} feature is required for TMS320C6x
  38328. targets. It should contain registers @samp{A0} through @samp{A15},
  38329. registers @samp{B0} through @samp{B15}, @samp{CSR} and @samp{PC}.
  38330. The @samp{org.gnu.gdb.tic6x.gp} feature is optional. It should
  38331. contain registers @samp{A16} through @samp{A31} and @samp{B16}
  38332. through @samp{B31}.
  38333. The @samp{org.gnu.gdb.tic6x.c6xp} feature is optional. It should
  38334. contain registers @samp{TSR}, @samp{ILC} and @samp{RILC}.
  38335. @node Operating System Information
  38336. @appendix Operating System Information
  38337. @cindex operating system information
  38338. Users of @value{GDBN} often wish to obtain information about the state of
  38339. the operating system running on the target---for example the list of
  38340. processes, or the list of open files. This section describes the
  38341. mechanism that makes it possible. This mechanism is similar to the
  38342. target features mechanism (@pxref{Target Descriptions}), but focuses
  38343. on a different aspect of target.
  38344. Operating system information is retrieved from the target via the
  38345. remote protocol, using @samp{qXfer} requests (@pxref{qXfer osdata
  38346. read}). The object name in the request should be @samp{osdata}, and
  38347. the @var{annex} identifies the data to be fetched.
  38348. @menu
  38349. * Process list::
  38350. @end menu
  38351. @node Process list
  38352. @appendixsection Process list
  38353. @cindex operating system information, process list
  38354. When requesting the process list, the @var{annex} field in the
  38355. @samp{qXfer} request should be @samp{processes}. The returned data is
  38356. an XML document. The formal syntax of this document is defined in
  38357. @file{gdb/features/osdata.dtd}.
  38358. An example document is:
  38359. @smallexample
  38360. <?xml version="1.0"?>
  38361. <!DOCTYPE target SYSTEM "osdata.dtd">
  38362. <osdata type="processes">
  38363. <item>
  38364. <column name="pid">1</column>
  38365. <column name="user">root</column>
  38366. <column name="command">/sbin/init</column>
  38367. <column name="cores">1,2,3</column>
  38368. </item>
  38369. </osdata>
  38370. @end smallexample
  38371. Each item should include a column whose name is @samp{pid}. The value
  38372. of that column should identify the process on the target. The
  38373. @samp{user} and @samp{command} columns are optional, and will be
  38374. displayed by @value{GDBN}. The @samp{cores} column, if present,
  38375. should contain a comma-separated list of cores that this process
  38376. is running on. Target may provide additional columns,
  38377. which @value{GDBN} currently ignores.
  38378. @node Trace File Format
  38379. @appendix Trace File Format
  38380. @cindex trace file format
  38381. The trace file comes in three parts: a header, a textual description
  38382. section, and a trace frame section with binary data.
  38383. The header has the form @code{\x7fTRACE0\n}. The first byte is
  38384. @code{0x7f} so as to indicate that the file contains binary data,
  38385. while the @code{0} is a version number that may have different values
  38386. in the future.
  38387. The description section consists of multiple lines of @sc{ascii} text
  38388. separated by newline characters (@code{0xa}). The lines may include a
  38389. variety of optional descriptive or context-setting information, such
  38390. as tracepoint definitions or register set size. @value{GDBN} will
  38391. ignore any line that it does not recognize. An empty line marks the end
  38392. of this section.
  38393. @table @code
  38394. @item R @var{size}
  38395. Specifies the size of a register block in bytes. This is equal to the
  38396. size of a @code{g} packet payload in the remote protocol. @var{size}
  38397. is an ascii decimal number. There should be only one such line in
  38398. a single trace file.
  38399. @item status @var{status}
  38400. Trace status. @var{status} has the same format as a @code{qTStatus}
  38401. remote packet reply. There should be only one such line in a single trace
  38402. file.
  38403. @item tp @var{payload}
  38404. Tracepoint definition. The @var{payload} has the same format as
  38405. @code{qTfP}/@code{qTsP} remote packet reply payload. A single tracepoint
  38406. may take multiple lines of definition, corresponding to the multiple
  38407. reply packets.
  38408. @item tsv @var{payload}
  38409. Trace state variable definition. The @var{payload} has the same format as
  38410. @code{qTfV}/@code{qTsV} remote packet reply payload. A single variable
  38411. may take multiple lines of definition, corresponding to the multiple
  38412. reply packets.
  38413. @item tdesc @var{payload}
  38414. Target description in XML format. The @var{payload} is a single line of
  38415. the XML file. All such lines should be concatenated together to get
  38416. the original XML file. This file is in the same format as @code{qXfer}
  38417. @code{features} payload, and corresponds to the main @code{target.xml}
  38418. file. Includes are not allowed.
  38419. @end table
  38420. The trace frame section consists of a number of consecutive frames.
  38421. Each frame begins with a two-byte tracepoint number, followed by a
  38422. four-byte size giving the amount of data in the frame. The data in
  38423. the frame consists of a number of blocks, each introduced by a
  38424. character indicating its type (at least register, memory, and trace
  38425. state variable). The data in this section is raw binary, not a
  38426. hexadecimal or other encoding; its endianness matches the target's
  38427. endianness.
  38428. @c FIXME bi-arch may require endianness/arch info in description section
  38429. @table @code
  38430. @item R @var{bytes}
  38431. Register block. The number and ordering of bytes matches that of a
  38432. @code{g} packet in the remote protocol. Note that these are the
  38433. actual bytes, in target order, not a hexadecimal encoding.
  38434. @item M @var{address} @var{length} @var{bytes}...
  38435. Memory block. This is a contiguous block of memory, at the 8-byte
  38436. address @var{address}, with a 2-byte length @var{length}, followed by
  38437. @var{length} bytes.
  38438. @item V @var{number} @var{value}
  38439. Trace state variable block. This records the 8-byte signed value
  38440. @var{value} of trace state variable numbered @var{number}.
  38441. @end table
  38442. Future enhancements of the trace file format may include additional types
  38443. of blocks.
  38444. @node Index Section Format
  38445. @appendix @code{.gdb_index} section format
  38446. @cindex .gdb_index section format
  38447. @cindex index section format
  38448. This section documents the index section that is created by @code{save
  38449. gdb-index} (@pxref{Index Files}). The index section is
  38450. DWARF-specific; some knowledge of DWARF is assumed in this
  38451. description.
  38452. The mapped index file format is designed to be directly
  38453. @code{mmap}able on any architecture. In most cases, a datum is
  38454. represented using a little-endian 32-bit integer value, called an
  38455. @code{offset_type}. Big endian machines must byte-swap the values
  38456. before using them. Exceptions to this rule are noted. The data is
  38457. laid out such that alignment is always respected.
  38458. A mapped index consists of several areas, laid out in order.
  38459. @enumerate
  38460. @item
  38461. The file header. This is a sequence of values, of @code{offset_type}
  38462. unless otherwise noted:
  38463. @enumerate
  38464. @item
  38465. The version number, currently 8. Versions 1, 2 and 3 are obsolete.
  38466. Version 4 uses a different hashing function from versions 5 and 6.
  38467. Version 6 includes symbols for inlined functions, whereas versions 4
  38468. and 5 do not. Version 7 adds attributes to the CU indices in the
  38469. symbol table. Version 8 specifies that symbols from DWARF type units
  38470. (@samp{DW_TAG_type_unit}) refer to the type unit's symbol table and not the
  38471. compilation unit (@samp{DW_TAG_comp_unit}) using the type.
  38472. @value{GDBN} will only read version 4, 5, or 6 indices
  38473. by specifying @code{set use-deprecated-index-sections on}.
  38474. GDB has a workaround for potentially broken version 7 indices so it is
  38475. currently not flagged as deprecated.
  38476. @item
  38477. The offset, from the start of the file, of the CU list.
  38478. @item
  38479. The offset, from the start of the file, of the types CU list. Note
  38480. that this area can be empty, in which case this offset will be equal
  38481. to the next offset.
  38482. @item
  38483. The offset, from the start of the file, of the address area.
  38484. @item
  38485. The offset, from the start of the file, of the symbol table.
  38486. @item
  38487. The offset, from the start of the file, of the constant pool.
  38488. @end enumerate
  38489. @item
  38490. The CU list. This is a sequence of pairs of 64-bit little-endian
  38491. values, sorted by the CU offset. The first element in each pair is
  38492. the offset of a CU in the @code{.debug_info} section. The second
  38493. element in each pair is the length of that CU. References to a CU
  38494. elsewhere in the map are done using a CU index, which is just the
  38495. 0-based index into this table. Note that if there are type CUs, then
  38496. conceptually CUs and type CUs form a single list for the purposes of
  38497. CU indices.
  38498. @item
  38499. The types CU list. This is a sequence of triplets of 64-bit
  38500. little-endian values. In a triplet, the first value is the CU offset,
  38501. the second value is the type offset in the CU, and the third value is
  38502. the type signature. The types CU list is not sorted.
  38503. @item
  38504. The address area. The address area consists of a sequence of address
  38505. entries. Each address entry has three elements:
  38506. @enumerate
  38507. @item
  38508. The low address. This is a 64-bit little-endian value.
  38509. @item
  38510. The high address. This is a 64-bit little-endian value. Like
  38511. @code{DW_AT_high_pc}, the value is one byte beyond the end.
  38512. @item
  38513. The CU index. This is an @code{offset_type} value.
  38514. @end enumerate
  38515. @item
  38516. The symbol table. This is an open-addressed hash table. The size of
  38517. the hash table is always a power of 2.
  38518. Each slot in the hash table consists of a pair of @code{offset_type}
  38519. values. The first value is the offset of the symbol's name in the
  38520. constant pool. The second value is the offset of the CU vector in the
  38521. constant pool.
  38522. If both values are 0, then this slot in the hash table is empty. This
  38523. is ok because while 0 is a valid constant pool index, it cannot be a
  38524. valid index for both a string and a CU vector.
  38525. The hash value for a table entry is computed by applying an
  38526. iterative hash function to the symbol's name. Starting with an
  38527. initial value of @code{r = 0}, each (unsigned) character @samp{c} in
  38528. the string is incorporated into the hash using the formula depending on the
  38529. index version:
  38530. @table @asis
  38531. @item Version 4
  38532. The formula is @code{r = r * 67 + c - 113}.
  38533. @item Versions 5 to 7
  38534. The formula is @code{r = r * 67 + tolower (c) - 113}.
  38535. @end table
  38536. The terminating @samp{\0} is not incorporated into the hash.
  38537. The step size used in the hash table is computed via
  38538. @code{((hash * 17) & (size - 1)) | 1}, where @samp{hash} is the hash
  38539. value, and @samp{size} is the size of the hash table. The step size
  38540. is used to find the next candidate slot when handling a hash
  38541. collision.
  38542. The names of C@t{++} symbols in the hash table are canonicalized. We
  38543. don't currently have a simple description of the canonicalization
  38544. algorithm; if you intend to create new index sections, you must read
  38545. the code.
  38546. @item
  38547. The constant pool. This is simply a bunch of bytes. It is organized
  38548. so that alignment is correct: CU vectors are stored first, followed by
  38549. strings.
  38550. A CU vector in the constant pool is a sequence of @code{offset_type}
  38551. values. The first value is the number of CU indices in the vector.
  38552. Each subsequent value is the index and symbol attributes of a CU in
  38553. the CU list. This element in the hash table is used to indicate which
  38554. CUs define the symbol and how the symbol is used.
  38555. See below for the format of each CU index+attributes entry.
  38556. A string in the constant pool is zero-terminated.
  38557. @end enumerate
  38558. Attributes were added to CU index values in @code{.gdb_index} version 7.
  38559. If a symbol has multiple uses within a CU then there is one
  38560. CU index+attributes value for each use.
  38561. The format of each CU index+attributes entry is as follows
  38562. (bit 0 = LSB):
  38563. @table @asis
  38564. @item Bits 0-23
  38565. This is the index of the CU in the CU list.
  38566. @item Bits 24-27
  38567. These bits are reserved for future purposes and must be zero.
  38568. @item Bits 28-30
  38569. The kind of the symbol in the CU.
  38570. @table @asis
  38571. @item 0
  38572. This value is reserved and should not be used.
  38573. By reserving zero the full @code{offset_type} value is backwards compatible
  38574. with previous versions of the index.
  38575. @item 1
  38576. The symbol is a type.
  38577. @item 2
  38578. The symbol is a variable or an enum value.
  38579. @item 3
  38580. The symbol is a function.
  38581. @item 4
  38582. Any other kind of symbol.
  38583. @item 5,6,7
  38584. These values are reserved.
  38585. @end table
  38586. @item Bit 31
  38587. This bit is zero if the value is global and one if it is static.
  38588. The determination of whether a symbol is global or static is complicated.
  38589. The authorative reference is the file @file{dwarf2read.c} in
  38590. @value{GDBN} sources.
  38591. @end table
  38592. This pseudo-code describes the computation of a symbol's kind and
  38593. global/static attributes in the index.
  38594. @smallexample
  38595. is_external = get_attribute (die, DW_AT_external);
  38596. language = get_attribute (cu_die, DW_AT_language);
  38597. switch (die->tag)
  38598. @{
  38599. case DW_TAG_typedef:
  38600. case DW_TAG_base_type:
  38601. case DW_TAG_subrange_type:
  38602. kind = TYPE;
  38603. is_static = 1;
  38604. break;
  38605. case DW_TAG_enumerator:
  38606. kind = VARIABLE;
  38607. is_static = language != CPLUS;
  38608. break;
  38609. case DW_TAG_subprogram:
  38610. kind = FUNCTION;
  38611. is_static = ! (is_external || language == ADA);
  38612. break;
  38613. case DW_TAG_constant:
  38614. kind = VARIABLE;
  38615. is_static = ! is_external;
  38616. break;
  38617. case DW_TAG_variable:
  38618. kind = VARIABLE;
  38619. is_static = ! is_external;
  38620. break;
  38621. case DW_TAG_namespace:
  38622. kind = TYPE;
  38623. is_static = 0;
  38624. break;
  38625. case DW_TAG_class_type:
  38626. case DW_TAG_interface_type:
  38627. case DW_TAG_structure_type:
  38628. case DW_TAG_union_type:
  38629. case DW_TAG_enumeration_type:
  38630. kind = TYPE;
  38631. is_static = language != CPLUS;
  38632. break;
  38633. default:
  38634. assert (0);
  38635. @}
  38636. @end smallexample
  38637. @node Debuginfod
  38638. @appendix Download debugging resources with Debuginfod
  38639. @cindex debuginfod
  38640. @code{debuginfod} is an HTTP server for distributing ELF, DWARF and source
  38641. files.
  38642. With the @code{debuginfod} client library, @file{libdebuginfod}, @value{GDBN}
  38643. can query servers using the build IDs associated with missing debug info,
  38644. executables and source files in order to download them on demand.
  38645. For instructions on building @value{GDBN} with @file{libdebuginfod},
  38646. @pxref{Configure Options,,--with-debuginfod}. @code{debuginfod} is packaged
  38647. with @code{elfutils}, starting with version 0.178. See
  38648. @uref{https://sourceware.org/elfutils/Debuginfod.html} for more information
  38649. regarding @code{debuginfod}.
  38650. @menu
  38651. * Debuginfod Settings:: Configuring debuginfod with @value{GDBN}
  38652. @end menu
  38653. @node Debuginfod Settings
  38654. @section Debuginfod Settings
  38655. @value{GDBN} provides the following commands for configuring @code{debuginfod}.
  38656. @table @code
  38657. @kindex set debuginfod enabled
  38658. @anchor{set debuginfod enabled}
  38659. @item set debuginfod enabled
  38660. @itemx set debuginfod enabled on
  38661. @cindex enable debuginfod
  38662. @value{GDBN} will attempt to query @code{debuginfod} servers when missing debug
  38663. info or source files.
  38664. @item set debuginfod enabled off
  38665. @value{GDBN} will not attempt to query @code{debuginfod} servers when missing
  38666. debug info or source files. By default, @code{debuginfod enabled} is set to
  38667. @code{off} for non-interactive sessions.
  38668. @item set debuginfod enabled ask
  38669. @value{GDBN} will prompt the user to enable or disable @code{debuginfod} before
  38670. attempting to perform the next query. By default, @code{debuginfod enabled}
  38671. is set to @code{ask} for interactive sessions.
  38672. @kindex show debuginfod enabled
  38673. @item show debuginfod enabled
  38674. Display whether @code{debuginfod enabled} is set to @code{on}, @code{off} or
  38675. @code{ask}.
  38676. @kindex set debuginfod urls
  38677. @cindex configure debuginfod URLs
  38678. @item set debuginfod urls
  38679. @itemx set debuginfod urls @var{urls}
  38680. Set the space-separated list of URLs that @code{debuginfod} will attempt to
  38681. query. Only @code{http://}, @code{https://} and @code{file://} protocols
  38682. should be used. The default value of @code{debuginfod urls} is copied from
  38683. the @var{DEBUGINFOD_URLS} environment variable.
  38684. @kindex show debuginfod urls
  38685. @item show debuginfod urls
  38686. Display the list of URLs that @code{debuginfod} will attempt to query.
  38687. @kindex set debuginfod verbose
  38688. @cindex debuginfod verbosity
  38689. @item set debuginfod verbose
  38690. @itemx set debuginfod verbose @var{n}
  38691. Enable or disable @code{debuginfod}-related output. Use a non-zero value
  38692. to enable and @code{0} to disable. @code{debuginfod} output is shown by
  38693. default.
  38694. @kindex show debuginfod verbose
  38695. @item show debuginfod verbose
  38696. Show the current verbosity setting.
  38697. @end table
  38698. @node Man Pages
  38699. @appendix Manual pages
  38700. @cindex Man pages
  38701. @menu
  38702. * gdb man:: The GNU Debugger man page
  38703. * gdbserver man:: Remote Server for the GNU Debugger man page
  38704. * gcore man:: Generate a core file of a running program
  38705. * gdbinit man:: gdbinit scripts
  38706. * gdb-add-index man:: Add index files to speed up GDB
  38707. @end menu
  38708. @node gdb man
  38709. @heading gdb man
  38710. @c man title gdb The GNU Debugger
  38711. @c man begin SYNOPSIS gdb
  38712. gdb [OPTIONS] [@var{prog}|@var{prog} @var{procID}|@var{prog} @var{core}]
  38713. @c man end
  38714. @c man begin DESCRIPTION gdb
  38715. The purpose of a debugger such as @value{GDBN} is to allow you to see what is
  38716. going on ``inside'' another program while it executes -- or what another
  38717. program was doing at the moment it crashed.
  38718. @value{GDBN} can do four main kinds of things (plus other things in support of
  38719. these) to help you catch bugs in the act:
  38720. @itemize @bullet
  38721. @item
  38722. Start your program, specifying anything that might affect its behavior.
  38723. @item
  38724. Make your program stop on specified conditions.
  38725. @item
  38726. Examine what has happened, when your program has stopped.
  38727. @item
  38728. Change things in your program, so you can experiment with correcting the
  38729. effects of one bug and go on to learn about another.
  38730. @end itemize
  38731. You can use @value{GDBN} to debug programs written in C, C@t{++}, Fortran and
  38732. Modula-2.
  38733. @value{GDBN} is invoked with the shell command @code{gdb}. Once started, it reads
  38734. commands from the terminal until you tell it to exit with the @value{GDBN}
  38735. command @code{quit} or @code{exit}. You can get online help from @value{GDBN} itself
  38736. by using the command @code{help}.
  38737. You can run @code{gdb} with no arguments or options; but the most
  38738. usual way to start @value{GDBN} is with one argument or two, specifying an
  38739. executable program as the argument:
  38740. @smallexample
  38741. gdb program
  38742. @end smallexample
  38743. You can also start with both an executable program and a core file specified:
  38744. @smallexample
  38745. gdb program core
  38746. @end smallexample
  38747. You can, instead, specify a process ID as a second argument or use option
  38748. @code{-p}, if you want to debug a running process:
  38749. @smallexample
  38750. gdb program 1234
  38751. gdb -p 1234
  38752. @end smallexample
  38753. @noindent
  38754. would attach @value{GDBN} to process @code{1234}. With option @option{-p} you
  38755. can omit the @var{program} filename.
  38756. Here are some of the most frequently needed @value{GDBN} commands:
  38757. @c pod2man highlights the right hand side of the @item lines.
  38758. @table @env
  38759. @item break [@var{file}:][@var{function}|@var{line}]
  38760. Set a breakpoint at @var{function} or @var{line} (in @var{file}).
  38761. @item run [@var{arglist}]
  38762. Start your program (with @var{arglist}, if specified).
  38763. @item bt
  38764. Backtrace: display the program stack.
  38765. @item print @var{expr}
  38766. Display the value of an expression.
  38767. @item c
  38768. Continue running your program (after stopping, e.g.@: at a breakpoint).
  38769. @item next
  38770. Execute next program line (after stopping); step @emph{over} any
  38771. function calls in the line.
  38772. @item edit [@var{file}:]@var{function}
  38773. look at the program line where it is presently stopped.
  38774. @item list [@var{file}:]@var{function}
  38775. type the text of the program in the vicinity of where it is presently stopped.
  38776. @item step
  38777. Execute next program line (after stopping); step @emph{into} any
  38778. function calls in the line.
  38779. @item help [@var{name}]
  38780. Show information about @value{GDBN} command @var{name}, or general information
  38781. about using @value{GDBN}.
  38782. @item quit
  38783. @itemx exit
  38784. Exit from @value{GDBN}.
  38785. @end table
  38786. @ifset man
  38787. For full details on @value{GDBN},
  38788. see @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
  38789. by Richard M. Stallman and Roland H. Pesch. The same text is available online
  38790. as the @code{gdb} entry in the @code{info} program.
  38791. @end ifset
  38792. @c man end
  38793. @c man begin OPTIONS gdb
  38794. Any arguments other than options specify an executable
  38795. file and core file (or process ID); that is, the first argument
  38796. encountered with no
  38797. associated option flag is equivalent to a @option{--se} option, and the second,
  38798. if any, is equivalent to a @option{-c} option if it's the name of a file.
  38799. Many options have
  38800. both long and abbreviated forms; both are shown here. The long forms are also
  38801. recognized if you truncate them, so long as enough of the option is
  38802. present to be unambiguous.
  38803. The abbreviated forms are shown here with @samp{-} and long forms are shown
  38804. with @samp{--} to reflect how they are shown in @option{--help}. However,
  38805. @value{GDBN} recognizes all of the following conventions for most options:
  38806. @table @code
  38807. @item --option=@var{value}
  38808. @item --option @var{value}
  38809. @item -option=@var{value}
  38810. @item -option @var{value}
  38811. @item --o=@var{value}
  38812. @item --o @var{value}
  38813. @item -o=@var{value}
  38814. @item -o @var{value}
  38815. @end table
  38816. All the options and command line arguments you give are processed
  38817. in sequential order. The order makes a difference when the @option{-x}
  38818. option is used.
  38819. @table @env
  38820. @item --help
  38821. @itemx -h
  38822. List all options, with brief explanations.
  38823. @item --symbols=@var{file}
  38824. @itemx -s @var{file}
  38825. Read symbol table from @var{file}.
  38826. @item --write
  38827. Enable writing into executable and core files.
  38828. @item --exec=@var{file}
  38829. @itemx -e @var{file}
  38830. Use @var{file} as the executable file to execute when
  38831. appropriate, and for examining pure data in conjunction with a core
  38832. dump.
  38833. @item --se=@var{file}
  38834. Read symbol table from @var{file} and use it as the executable
  38835. file.
  38836. @item --core=@var{file}
  38837. @itemx -c @var{file}
  38838. Use @var{file} as a core dump to examine.
  38839. @item --command=@var{file}
  38840. @itemx -x @var{file}
  38841. Execute @value{GDBN} commands from @var{file}.
  38842. @item --eval-command=@var{command}
  38843. @item -ex @var{command}
  38844. Execute given @value{GDBN} @var{command}.
  38845. @item --init-eval-command=@var{command}
  38846. @item -iex
  38847. Execute @value{GDBN} @var{command} before loading the inferior.
  38848. @item --directory=@var{directory}
  38849. @itemx -d @var{directory}
  38850. Add @var{directory} to the path to search for source files.
  38851. @item --nh
  38852. Do not execute commands from @file{~/.config/gdb/gdbinit},
  38853. @file{~/.gdbinit}, @file{~/.config/gdb/gdbearlyinit}, or
  38854. @file{~/.gdbearlyinit}
  38855. @item --nx
  38856. @itemx -n
  38857. Do not execute commands from any @file{.gdbinit} or
  38858. @file{.gdbearlyinit} initialization files.
  38859. @item --quiet
  38860. @item --silent
  38861. @itemx -q
  38862. ``Quiet''. Do not print the introductory and copyright messages. These
  38863. messages are also suppressed in batch mode.
  38864. @item --batch
  38865. Run in batch mode. Exit with status @code{0} after processing all the command
  38866. files specified with @option{-x} (and @file{.gdbinit}, if not inhibited).
  38867. Exit with nonzero status if an error occurs in executing the @value{GDBN}
  38868. commands in the command files.
  38869. Batch mode may be useful for running @value{GDBN} as a filter, for example to
  38870. download and run a program on another computer; in order to make this
  38871. more useful, the message
  38872. @smallexample
  38873. Program exited normally.
  38874. @end smallexample
  38875. @noindent
  38876. (which is ordinarily issued whenever a program running under @value{GDBN} control
  38877. terminates) is not issued when running in batch mode.
  38878. @item --batch-silent
  38879. Run in batch mode, just like @option{--batch}, but totally silent. All @value{GDBN}
  38880. output is supressed (stderr is unaffected). This is much quieter than
  38881. @option{--silent} and would be useless for an interactive session.
  38882. This is particularly useful when using targets that give @samp{Loading section}
  38883. messages, for example.
  38884. Note that targets that give their output via @value{GDBN}, as opposed to writing
  38885. directly to @code{stdout}, will also be made silent.
  38886. @item --args @var{prog} [@var{arglist}]
  38887. Change interpretation of command line so that arguments following this
  38888. option are passed as arguments to the inferior. As an example, take
  38889. the following command:
  38890. @smallexample
  38891. gdb ./a.out -q
  38892. @end smallexample
  38893. @noindent
  38894. It would start @value{GDBN} with @option{-q}, not printing the introductory message. On
  38895. the other hand, using:
  38896. @smallexample
  38897. gdb --args ./a.out -q
  38898. @end smallexample
  38899. @noindent
  38900. starts @value{GDBN} with the introductory message, and passes the option to the inferior.
  38901. @item --pid=@var{pid}
  38902. Attach @value{GDBN} to an already running program, with the PID @var{pid}.
  38903. @item --tui
  38904. Open the terminal user interface.
  38905. @item --readnow
  38906. Read all symbols from the given symfile on the first access.
  38907. @item --readnever
  38908. Do not read symbol files.
  38909. @item --return-child-result
  38910. @value{GDBN}'s exit code will be the same as the child's exit code.
  38911. @item --configuration
  38912. Print details about GDB configuration and then exit.
  38913. @item --version
  38914. Print version information and then exit.
  38915. @item --cd=@var{directory}
  38916. Run @value{GDBN} using @var{directory} as its working directory,
  38917. instead of the current directory.
  38918. @item --data-directory=@var{directory}
  38919. @item -D
  38920. Run @value{GDBN} using @var{directory} as its data directory. The data
  38921. directory is where @value{GDBN} searches for its auxiliary files.
  38922. @item --fullname
  38923. @itemx -f
  38924. Emacs sets this option when it runs @value{GDBN} as a subprocess. It tells
  38925. @value{GDBN} to output the full file name and line number in a standard,
  38926. recognizable fashion each time a stack frame is displayed (which
  38927. includes each time the program stops). This recognizable format looks
  38928. like two @samp{\032} characters, followed by the file name, line number
  38929. and character position separated by colons, and a newline. The
  38930. Emacs-to-@value{GDBN} interface program uses the two @samp{\032}
  38931. characters as a signal to display the source code for the frame.
  38932. @item -b @var{baudrate}
  38933. Set the line speed (baud rate or bits per second) of any serial
  38934. interface used by @value{GDBN} for remote debugging.
  38935. @item -l @var{timeout}
  38936. Set timeout, in seconds, for remote debugging.
  38937. @item --tty=@var{device}
  38938. Run using @var{device} for your program's standard input and output.
  38939. @end table
  38940. @c man end
  38941. @c man begin SEEALSO gdb
  38942. @ifset man
  38943. The full documentation for @value{GDBN} is maintained as a Texinfo manual.
  38944. If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
  38945. documentation are properly installed at your site, the command
  38946. @smallexample
  38947. info gdb
  38948. @end smallexample
  38949. @noindent
  38950. should give you access to the complete manual.
  38951. @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
  38952. Richard M. Stallman and Roland H. Pesch, July 1991.
  38953. @end ifset
  38954. @c man end
  38955. @node gdbserver man
  38956. @heading gdbserver man
  38957. @c man title gdbserver Remote Server for the GNU Debugger
  38958. @format
  38959. @c man begin SYNOPSIS gdbserver
  38960. gdbserver @var{comm} @var{prog} [@var{args}@dots{}]
  38961. gdbserver --attach @var{comm} @var{pid}
  38962. gdbserver --multi @var{comm}
  38963. @c man end
  38964. @end format
  38965. @c man begin DESCRIPTION gdbserver
  38966. @command{gdbserver} is a program that allows you to run @value{GDBN} on a different machine
  38967. than the one which is running the program being debugged.
  38968. @ifclear man
  38969. @subheading Usage (server (target) side)
  38970. @end ifclear
  38971. @ifset man
  38972. Usage (server (target) side):
  38973. @end ifset
  38974. First, you need to have a copy of the program you want to debug put onto
  38975. the target system. The program can be stripped to save space if needed, as
  38976. @command{gdbserver} doesn't care about symbols. All symbol handling is taken care of by
  38977. the @value{GDBN} running on the host system.
  38978. To use the server, you log on to the target system, and run the @command{gdbserver}
  38979. program. You must tell it (a) how to communicate with @value{GDBN}, (b) the name of
  38980. your program, and (c) its arguments. The general syntax is:
  38981. @smallexample
  38982. target> gdbserver @var{comm} @var{program} [@var{args} ...]
  38983. @end smallexample
  38984. For example, using a serial port, you might say:
  38985. @smallexample
  38986. @ifset man
  38987. @c @file would wrap it as F</dev/com1>.
  38988. target> gdbserver /dev/com1 emacs foo.txt
  38989. @end ifset
  38990. @ifclear man
  38991. target> gdbserver @file{/dev/com1} emacs foo.txt
  38992. @end ifclear
  38993. @end smallexample
  38994. This tells @command{gdbserver} to debug emacs with an argument of foo.txt, and
  38995. to communicate with @value{GDBN} via @file{/dev/com1}. @command{gdbserver} now
  38996. waits patiently for the host @value{GDBN} to communicate with it.
  38997. To use a TCP connection, you could say:
  38998. @smallexample
  38999. target> gdbserver host:2345 emacs foo.txt
  39000. @end smallexample
  39001. This says pretty much the same thing as the last example, except that we are
  39002. going to communicate with the @code{host} @value{GDBN} via TCP. The @code{host:2345} argument means
  39003. that we are expecting to see a TCP connection from @code{host} to local TCP port
  39004. 2345. (Currently, the @code{host} part is ignored.) You can choose any number you
  39005. want for the port number as long as it does not conflict with any existing TCP
  39006. ports on the target system. This same port number must be used in the host
  39007. @value{GDBN}s @code{target remote} command, which will be described shortly. Note that if
  39008. you chose a port number that conflicts with another service, @command{gdbserver} will
  39009. print an error message and exit.
  39010. @command{gdbserver} can also attach to running programs.
  39011. This is accomplished via the @option{--attach} argument. The syntax is:
  39012. @smallexample
  39013. target> gdbserver --attach @var{comm} @var{pid}
  39014. @end smallexample
  39015. @var{pid} is the process ID of a currently running process. It isn't
  39016. necessary to point @command{gdbserver} at a binary for the running process.
  39017. To start @code{gdbserver} without supplying an initial command to run
  39018. or process ID to attach, use the @option{--multi} command line option.
  39019. In such case you should connect using @kbd{target extended-remote} to start
  39020. the program you want to debug.
  39021. @smallexample
  39022. target> gdbserver --multi @var{comm}
  39023. @end smallexample
  39024. @ifclear man
  39025. @subheading Usage (host side)
  39026. @end ifclear
  39027. @ifset man
  39028. Usage (host side):
  39029. @end ifset
  39030. You need an unstripped copy of the target program on your host system, since
  39031. @value{GDBN} needs to examine its symbol tables and such. Start up @value{GDBN} as you normally
  39032. would, with the target program as the first argument. (You may need to use the
  39033. @option{--baud} option if the serial line is running at anything except 9600 baud.)
  39034. That is @code{gdb TARGET-PROG}, or @code{gdb --baud BAUD TARGET-PROG}. After that, the only
  39035. new command you need to know about is @code{target remote}
  39036. (or @code{target extended-remote}). Its argument is either
  39037. a device name (usually a serial device, like @file{/dev/ttyb}), or a @code{HOST:PORT}
  39038. descriptor. For example:
  39039. @smallexample
  39040. @ifset man
  39041. @c @file would wrap it as F</dev/ttyb>.
  39042. (gdb) target remote /dev/ttyb
  39043. @end ifset
  39044. @ifclear man
  39045. (gdb) target remote @file{/dev/ttyb}
  39046. @end ifclear
  39047. @end smallexample
  39048. @noindent
  39049. communicates with the server via serial line @file{/dev/ttyb}, and:
  39050. @smallexample
  39051. (gdb) target remote the-target:2345
  39052. @end smallexample
  39053. @noindent
  39054. communicates via a TCP connection to port 2345 on host `the-target', where
  39055. you previously started up @command{gdbserver} with the same port number. Note that for
  39056. TCP connections, you must start up @command{gdbserver} prior to using the `target remote'
  39057. command, otherwise you may get an error that looks something like
  39058. `Connection refused'.
  39059. @command{gdbserver} can also debug multiple inferiors at once,
  39060. described in
  39061. @ifset man
  39062. the @value{GDBN} manual in node @code{Inferiors Connections and Programs}
  39063. -- shell command @code{info -f gdb -n 'Inferiors Connections and Programs'}.
  39064. @end ifset
  39065. @ifclear man
  39066. @ref{Inferiors Connections and Programs}.
  39067. @end ifclear
  39068. In such case use the @code{extended-remote} @value{GDBN} command variant:
  39069. @smallexample
  39070. (gdb) target extended-remote the-target:2345
  39071. @end smallexample
  39072. The @command{gdbserver} option @option{--multi} may or may not be used in such
  39073. case.
  39074. @c man end
  39075. @c man begin OPTIONS gdbserver
  39076. There are three different modes for invoking @command{gdbserver}:
  39077. @itemize @bullet
  39078. @item
  39079. Debug a specific program specified by its program name:
  39080. @smallexample
  39081. gdbserver @var{comm} @var{prog} [@var{args}@dots{}]
  39082. @end smallexample
  39083. The @var{comm} parameter specifies how should the server communicate
  39084. with @value{GDBN}; it is either a device name (to use a serial line),
  39085. a TCP port number (@code{:1234}), or @code{-} or @code{stdio} to use
  39086. stdin/stdout of @code{gdbserver}. Specify the name of the program to
  39087. debug in @var{prog}. Any remaining arguments will be passed to the
  39088. program verbatim. When the program exits, @value{GDBN} will close the
  39089. connection, and @code{gdbserver} will exit.
  39090. @item
  39091. Debug a specific program by specifying the process ID of a running
  39092. program:
  39093. @smallexample
  39094. gdbserver --attach @var{comm} @var{pid}
  39095. @end smallexample
  39096. The @var{comm} parameter is as described above. Supply the process ID
  39097. of a running program in @var{pid}; @value{GDBN} will do everything
  39098. else. Like with the previous mode, when the process @var{pid} exits,
  39099. @value{GDBN} will close the connection, and @code{gdbserver} will exit.
  39100. @item
  39101. Multi-process mode -- debug more than one program/process:
  39102. @smallexample
  39103. gdbserver --multi @var{comm}
  39104. @end smallexample
  39105. In this mode, @value{GDBN} can instruct @command{gdbserver} which
  39106. command(s) to run. Unlike the other 2 modes, @value{GDBN} will not
  39107. close the connection when a process being debugged exits, so you can
  39108. debug several processes in the same session.
  39109. @end itemize
  39110. In each of the modes you may specify these options:
  39111. @table @env
  39112. @item --help
  39113. List all options, with brief explanations.
  39114. @item --version
  39115. This option causes @command{gdbserver} to print its version number and exit.
  39116. @item --attach
  39117. @command{gdbserver} will attach to a running program. The syntax is:
  39118. @smallexample
  39119. target> gdbserver --attach @var{comm} @var{pid}
  39120. @end smallexample
  39121. @var{pid} is the process ID of a currently running process. It isn't
  39122. necessary to point @command{gdbserver} at a binary for the running process.
  39123. @item --multi
  39124. To start @code{gdbserver} without supplying an initial command to run
  39125. or process ID to attach, use this command line option.
  39126. Then you can connect using @kbd{target extended-remote} and start
  39127. the program you want to debug. The syntax is:
  39128. @smallexample
  39129. target> gdbserver --multi @var{comm}
  39130. @end smallexample
  39131. @item --debug
  39132. Instruct @code{gdbserver} to display extra status information about the debugging
  39133. process.
  39134. This option is intended for @code{gdbserver} development and for bug reports to
  39135. the developers.
  39136. @item --remote-debug
  39137. Instruct @code{gdbserver} to display remote protocol debug output.
  39138. This option is intended for @code{gdbserver} development and for bug reports to
  39139. the developers.
  39140. @item --debug-file=@var{filename}
  39141. Instruct @code{gdbserver} to send any debug output to the given @var{filename}.
  39142. This option is intended for @code{gdbserver} development and for bug reports to
  39143. the developers.
  39144. @item --debug-format=option1@r{[},option2,...@r{]}
  39145. Instruct @code{gdbserver} to include extra information in each line
  39146. of debugging output.
  39147. @xref{Other Command-Line Arguments for gdbserver}.
  39148. @item --wrapper
  39149. Specify a wrapper to launch programs
  39150. for debugging. The option should be followed by the name of the
  39151. wrapper, then any command-line arguments to pass to the wrapper, then
  39152. @kbd{--} indicating the end of the wrapper arguments.
  39153. @item --once
  39154. By default, @command{gdbserver} keeps the listening TCP port open, so that
  39155. additional connections are possible. However, if you start @code{gdbserver}
  39156. with the @option{--once} option, it will stop listening for any further
  39157. connection attempts after connecting to the first @value{GDBN} session.
  39158. @c --disable-packet is not documented for users.
  39159. @c --disable-randomization and --no-disable-randomization are superseded by
  39160. @c QDisableRandomization.
  39161. @end table
  39162. @c man end
  39163. @c man begin SEEALSO gdbserver
  39164. @ifset man
  39165. The full documentation for @value{GDBN} is maintained as a Texinfo manual.
  39166. If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
  39167. documentation are properly installed at your site, the command
  39168. @smallexample
  39169. info gdb
  39170. @end smallexample
  39171. should give you access to the complete manual.
  39172. @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
  39173. Richard M. Stallman and Roland H. Pesch, July 1991.
  39174. @end ifset
  39175. @c man end
  39176. @node gcore man
  39177. @heading gcore
  39178. @c man title gcore Generate a core file of a running program
  39179. @format
  39180. @c man begin SYNOPSIS gcore
  39181. gcore [-a] [-o @var{prefix}] @var{pid1} [@var{pid2}...@var{pidN}]
  39182. @c man end
  39183. @end format
  39184. @c man begin DESCRIPTION gcore
  39185. Generate core dumps of one or more running programs with process IDs
  39186. @var{pid1}, @var{pid2}, etc. A core file produced by @command{gcore}
  39187. is equivalent to one produced by the kernel when the process crashes
  39188. (and when @kbd{ulimit -c} was used to set up an appropriate core dump
  39189. limit). However, unlike after a crash, after @command{gcore} finishes
  39190. its job the program remains running without any change.
  39191. @c man end
  39192. @c man begin OPTIONS gcore
  39193. @table @env
  39194. @item -a
  39195. Dump all memory mappings. The actual effect of this option depends on
  39196. the Operating System. On @sc{gnu}/Linux, it will disable
  39197. @code{use-coredump-filter} (@pxref{set use-coredump-filter}) and
  39198. enable @code{dump-excluded-mappings} (@pxref{set
  39199. dump-excluded-mappings}).
  39200. @item -o @var{prefix}
  39201. The optional argument @var{prefix} specifies the prefix to be used
  39202. when composing the file names of the core dumps. The file name is
  39203. composed as @file{@var{prefix}.@var{pid}}, where @var{pid} is the
  39204. process ID of the running program being analyzed by @command{gcore}.
  39205. If not specified, @var{prefix} defaults to @var{gcore}.
  39206. @end table
  39207. @c man end
  39208. @c man begin SEEALSO gcore
  39209. @ifset man
  39210. The full documentation for @value{GDBN} is maintained as a Texinfo manual.
  39211. If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
  39212. documentation are properly installed at your site, the command
  39213. @smallexample
  39214. info gdb
  39215. @end smallexample
  39216. @noindent
  39217. should give you access to the complete manual.
  39218. @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
  39219. Richard M. Stallman and Roland H. Pesch, July 1991.
  39220. @end ifset
  39221. @c man end
  39222. @node gdbinit man
  39223. @heading gdbinit
  39224. @c man title gdbinit GDB initialization scripts
  39225. @format
  39226. @c man begin SYNOPSIS gdbinit
  39227. @ifset SYSTEM_GDBINIT
  39228. @value{SYSTEM_GDBINIT}
  39229. @end ifset
  39230. @ifset SYSTEM_GDBINIT_DIR
  39231. @value{SYSTEM_GDBINIT_DIR}/*
  39232. @end ifset
  39233. ~/.config/gdb/gdbinit
  39234. ~/.gdbinit
  39235. ./.gdbinit
  39236. @c man end
  39237. @end format
  39238. @c man begin DESCRIPTION gdbinit
  39239. These files contain @value{GDBN} commands to automatically execute during
  39240. @value{GDBN} startup. The lines of contents are canned sequences of commands,
  39241. described in
  39242. @ifset man
  39243. the @value{GDBN} manual in node @code{Sequences}
  39244. -- shell command @code{info -f gdb -n Sequences}.
  39245. @end ifset
  39246. @ifclear man
  39247. @ref{Sequences}.
  39248. @end ifclear
  39249. Please read more in
  39250. @ifset man
  39251. the @value{GDBN} manual in node @code{Startup}
  39252. -- shell command @code{info -f gdb -n Startup}.
  39253. @end ifset
  39254. @ifclear man
  39255. @ref{Startup}.
  39256. @end ifclear
  39257. @table @env
  39258. @ifset SYSTEM_GDBINIT
  39259. @item @value{SYSTEM_GDBINIT}
  39260. @end ifset
  39261. @ifclear SYSTEM_GDBINIT
  39262. @item (not enabled with @code{--with-system-gdbinit} during compilation)
  39263. @end ifclear
  39264. System-wide initialization file. It is executed unless user specified
  39265. @value{GDBN} option @code{-nx} or @code{-n}.
  39266. See more in
  39267. @ifset man
  39268. the @value{GDBN} manual in node @code{System-wide configuration}
  39269. -- shell command @code{info -f gdb -n 'System-wide configuration'}.
  39270. @end ifset
  39271. @ifset SYSTEM_GDBINIT_DIR
  39272. @item @value{SYSTEM_GDBINIT_DIR}
  39273. @end ifset
  39274. @ifclear SYSTEM_GDBINIT_DIR
  39275. @item (not enabled with @code{--with-system-gdbinit-dir} during compilation)
  39276. @end ifclear
  39277. System-wide initialization directory. All files in this directory are
  39278. executed on startup unless user specified @value{GDBN} option @code{-nx} or
  39279. @code{-n}, as long as they have a recognized file extension.
  39280. See more in
  39281. @ifset man
  39282. the @value{GDBN} manual in node @code{System-wide configuration}
  39283. -- shell command @code{info -f gdb -n 'System-wide configuration'}.
  39284. @end ifset
  39285. @ifclear man
  39286. @ref{System-wide configuration}.
  39287. @end ifclear
  39288. @item @file{~/.config/gdb/gdbinit} or @file{~/.gdbinit}
  39289. User initialization file. It is executed unless user specified
  39290. @value{GDBN} options @code{-nx}, @code{-n} or @code{-nh}.
  39291. @item @file{.gdbinit}
  39292. Initialization file for current directory. It may need to be enabled with
  39293. @value{GDBN} security command @code{set auto-load local-gdbinit}.
  39294. See more in
  39295. @ifset man
  39296. the @value{GDBN} manual in node @code{Init File in the Current Directory}
  39297. -- shell command @code{info -f gdb -n 'Init File in the Current Directory'}.
  39298. @end ifset
  39299. @ifclear man
  39300. @ref{Init File in the Current Directory}.
  39301. @end ifclear
  39302. @end table
  39303. @c man end
  39304. @c man begin SEEALSO gdbinit
  39305. @ifset man
  39306. gdb(1), @code{info -f gdb -n Startup}
  39307. The full documentation for @value{GDBN} is maintained as a Texinfo manual.
  39308. If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
  39309. documentation are properly installed at your site, the command
  39310. @smallexample
  39311. info gdb
  39312. @end smallexample
  39313. should give you access to the complete manual.
  39314. @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
  39315. Richard M. Stallman and Roland H. Pesch, July 1991.
  39316. @end ifset
  39317. @c man end
  39318. @node gdb-add-index man
  39319. @heading gdb-add-index
  39320. @pindex gdb-add-index
  39321. @anchor{gdb-add-index}
  39322. @c man title gdb-add-index Add index files to speed up GDB
  39323. @c man begin SYNOPSIS gdb-add-index
  39324. gdb-add-index @var{filename}
  39325. @c man end
  39326. @c man begin DESCRIPTION gdb-add-index
  39327. When @value{GDBN} finds a symbol file, it scans the symbols in the
  39328. file in order to construct an internal symbol table. This lets most
  39329. @value{GDBN} operations work quickly--at the cost of a delay early on.
  39330. For large programs, this delay can be quite lengthy, so @value{GDBN}
  39331. provides a way to build an index, which speeds up startup.
  39332. To determine whether a file contains such an index, use the command
  39333. @kbd{readelf -S filename}: the index is stored in a section named
  39334. @code{.gdb_index}. The index file can only be produced on systems
  39335. which use ELF binaries and DWARF debug information (i.e., sections
  39336. named @code{.debug_*}).
  39337. @command{gdb-add-index} uses @value{GDBN} and @command{objdump} found
  39338. in the @env{PATH} environment variable. If you want to use different
  39339. versions of these programs, you can specify them through the
  39340. @env{GDB} and @env{OBJDUMP} environment variables.
  39341. See more in
  39342. @ifset man
  39343. the @value{GDBN} manual in node @code{Index Files}
  39344. -- shell command @kbd{info -f gdb -n "Index Files"}.
  39345. @end ifset
  39346. @ifclear man
  39347. @ref{Index Files}.
  39348. @end ifclear
  39349. @c man end
  39350. @c man begin SEEALSO gdb-add-index
  39351. @ifset man
  39352. The full documentation for @value{GDBN} is maintained as a Texinfo manual.
  39353. If the @code{info} and @code{gdb} programs and @value{GDBN}'s Texinfo
  39354. documentation are properly installed at your site, the command
  39355. @smallexample
  39356. info gdb
  39357. @end smallexample
  39358. should give you access to the complete manual.
  39359. @cite{Using GDB: A Guide to the GNU Source-Level Debugger},
  39360. Richard M. Stallman and Roland H. Pesch, July 1991.
  39361. @end ifset
  39362. @c man end
  39363. @include gpl.texi
  39364. @node GNU Free Documentation License
  39365. @appendix GNU Free Documentation License
  39366. @include fdl.texi
  39367. @node Concept Index
  39368. @unnumbered Concept Index
  39369. @printindex cp
  39370. @node Command and Variable Index
  39371. @unnumbered Command, Variable, and Function Index
  39372. @printindex fn
  39373. @tex
  39374. % I think something like @@colophon should be in texinfo. In the
  39375. % meantime:
  39376. \long\def\colophon{\hbox to0pt{}\vfill
  39377. \centerline{The body of this manual is set in}
  39378. \centerline{\fontname\tenrm,}
  39379. \centerline{with headings in {\bf\fontname\tenbf}}
  39380. \centerline{and examples in {\tt\fontname\tentt}.}
  39381. \centerline{{\it\fontname\tenit\/},}
  39382. \centerline{{\bf\fontname\tenbf}, and}
  39383. \centerline{{\sl\fontname\tensl\/}}
  39384. \centerline{are used for emphasis.}\vfill}
  39385. \page\colophon
  39386. % Blame: doc@@cygnus.com, 1991.
  39387. @end tex
  39388. @bye