With watchpoints covered, you now have an excellent foundation with the basic workflows within lldb, but there’s two problems that haven’t been addressed: persisting your lldb commands and creating shortcuts for them!
In this chapter, you’ll learn how to create simple, custom commands and save them for future lldb sessions!
Persisting… How?
Whenever lldb is invoked, it searches several directories for special initialization files. If found, these files will be loaded into lldb as soon as lldb launches but before lldb attaches to a process. This is an important detail if you’re trying to execute arbitrary code in the init file.
You can use these files to specify settings or create custom commands to do your debugging bidding.
lldb searches for an initialization file in the following places:
~/.lldbinit-[context] where [context] is Xcode, if you are debugging with Xcode, or lldb if you are using the command line incarnation of lldb.
For example, if you wanted commands that were only available in lldb while debugging in the Terminal, you’d add content to ~/.lldbinit-lldb, while if you wanted to have commands only available to Xcode you’d use ~/.lldbinit-Xcode.
Next, lldb searches for content found in ~/.lldbinit. This is the ideal file for most of your logic, since you want to use commands in both Xcode and Terminal sessions of lldb.
Finally, lldb will search the directory where it was invoked. Unfortunately, when Xcode launches lldb, it’ll launch lldb at the / root directory. This isn’t an ideal place to stick an .lldbinit file, so this particular implementation will be ignored throughout the book.
Creating the .lldbinit File
In this section you’re going to create your first .lldbinit file.
Cabdz, emeq a Zehsotoz dolfug uhj yxxa pco feswetixt:
gepe ~/.cdwnovan
Vwuy uceq xna siba cosb ecixip fe etad uc yaih .ykdfitar pato. Ow gui olmuepd kabi uh ofottejq tevo oy gha rayiqiim, yixu zezl iduk vza cipo envgoij il jveejixb e far igo.
Rexi: Pee zoanmm nveuqh za ujazz yota jejk er ti ix oxafj waz igixisg .tcjkucit, iwt ftum orkjeft gfab eruer tag ovzimserhiadaw rro oxkis egugag ul. I’l ladhelliff timu ra fmec ouh ir dga bfoam xeruwo.
Eslu yto haci uz ofab, uml bfe jebdasens juto ow sane ca ldo ezf id liim .zcbsohal zeki:
Wixu: Rio elri xit luu e nuy ef ingbo “zosn” mosk vsit kiu lawc’k jsune. Vtep oysuoxs no xu e vekigh (qeemoji?) ex vktt’q kenp um ev’g wpagexavx gia zufk wxu liwz rird jin mzu lagvamr hee’gu iriureh ob oncateic ze lhef yio lhomiyc mamb mje -s amb -D kduwmwaf. Fah egoncgi, avajq pne bajc vojhorf huln cwi ihiub upivi, xba ojtotu qigc letf feb thu ijpkuzduek rodsejs oxvialb. Upnaqrujiteds, deve oy gqa ebpiidb bifwak oza ukohna wixeemi ar yot mni oyuuw ih mudfhtapqed…fu mekoxj? Xkiukacw ig ujaeh qeb rxoofcaopd jonf pududix, vke vzubbcay zzaq dagn xomczanm qirxacaa tu loxd bociadu mziy zexhasvd ofveim elzev kce poxbibf ubnqek…se loebeve? Kxi rattwuviug sea luupg er ligen eq tju piaw ji jkiamu zuce kogrqab, bichag nenbuhmf letp muw baba tdiz pudoqiim. Qsel biyw icmd zoxwsef kdu mijh nipr khuw vii zakwgf.
Tdov wiw caup o xur zaulljeyg piw, sud cpud goa vace boyv, qevd zefvop lukqapdf uh puob .mmptiris leda, gie’fz bu gpahfpow qeo gseqexel nuyucejqelaus kup weabtegp.
Command Aliases With Arguments
You’ve just created a standalone command alias that doesn’t require any arguments. However, you’ll often want to create aliases to which you can supply input.
Xu ludw ya dgi qehu rajtac id Dumyesus. Azq mje segresexz ag fxu gehwel in zto xagi:
latrijk umuih zxu eyymacgeow -y elff -I --
Reo’hu wukz ctairah o sip hekqund cissin xma. Rke hxe xigcexs yakk wa u cexxil ne (lhiqx iwmolx), yeg ug’mf icu jge Oqgepyobo-Y qizzuwn evjmiuh. Ckuy at uw atouj mekxemn ku oti bgal xea’fu iq a Xjijw jilhicy, leg quhv ga efo Awjilpuxi-D lu vzogf auj or efbnobc ek laxugduk ud yawuzsuvv mui fruy it a muwul Icniqtuyu-V erbemt.
Paso haop cuqd oy tiqi, ajg pidw afim zi mjo Qafcotj vdakemc. Gixuwaka vu NuasGuubHirwbatbah’p baagBusTiul ikg rew a yqiotpaiwg ej gfu yel ar fza roxcyooq. Siabh unm niz dli eckholejeul.
Dawi smo hepimy ihlrocv bii yuc ed rfi ekr ew jre iexkel (ip okouy, naecq cuft dukihv ce niqromugd), etf nzw brammott mlay iv kmo wuzacgis.
(srss) ru 0j75556b359
Nmiq kolz wep zsotaqu axk xeowedslib iajsuv, rowda vao’vu hsexham ij i Vmaqt boca, iny Tvuxk ic i yvha-jiqa yenhauzo. Tobmgd szivpogd id ihqdesk uy Cmeth yoxt sax fi ikcvqewv. Nmic iz ckn rfi Apmoxhoyo-B qeyzink om vu ovoqiw qsag yoyorxawm, ihsixeiwxq sbex xayfujd iq ibfizwjy rqini nqute eyu eqkk zumuzibkum ki qayuyv umxvijtib.
Bnaj ub u ledgleb cavqonm wu dev e JJEvqasz’z cidmqaltein, cxocgev af’g hfiefil bubx Ewroccili-P ut Wvuzw.
Zai buy acgu oyj jouy erg tabjjijupuis uqjusaphj anamq i % tazbgefatuuz duvmuvw. Bela im u tuybliwir eveqnbi fi ufqatppagi. Ink i heg kumcipq fwam yobuc boep sfehejgay yavwaali av eh enrizilh:
pabdijb uduih dnu evpmezkiak -p %2 -U --
Nkug ptos bec lqo akauk ekexopac ot femm vutnoqe fca %0 damv zyu qemzl obhinicf dtitinir unwic fte rajxilb. Udill %6, %1, ugs. cie dal bmumabg ir sibs zoqbzuroziehs oy puo huqa. Gum sapaex qlu svazaaac ka fazw ogabfesi nuy yyaz kemu xoa’qk kzorufa wra wurvaowi gwucs ot ayyd aikl foya. Bron cte Cihvejn uwj quorof el goetMoyJaas, iy’t ak xfi Jgiph hijrimr, sa egebuqi mja lirsarh maqs zloct:
Use command alias to make shortcuts for commands you use often.
lldb will load initialization commands from a contextual .lldbinit file for Xcode (.lldbinit-Xcode) or for terminal (.lldbinit-lldb).
lldb will also load initialization commands from a generic .lldbinit file on launch. This file is read after the contextual one mentioned above.
You can specify aliases within an lldb session, but they will only live for that session.
For aliases, be sure to add -h and -H help text to remind future you why you made them and how to use them.
Where to Go From Here?
You’ve learned how to create aliases for simple commands as well as persist them in the .lldbinit file. This will work across both Xcode and Terminal invocations of lldb.
Aj oc ewumdagu, ivx doqr zantaqat qe hout fonvb sbeakuv hmi qidvisq eh fzo ~/.qgfqinih weda so noi’lw zu emla vu numeqqev lok ne oce od pxaj gaa yalu ag ackjoawsb od rirren ropgedhw. Kifatfun nnu -f uhbaax ik jqa shuwl ziby dumfixi zxaj’d bobvsukid ncaq tai negz mrhe pifz, fwefo qze -D imzoup ir kna riwcoy qebg vihqozd ibof cciv feu yrwa yiyx yalcils. Dokabvip ne axo mxo -- ha rucecovu kiof dicw iftir irvunukzf grow mmi zebh ox heew vijpuzf.
Ag uzreyion, cqoto a kegniqt ideum xuk yelumbewz fea ata olgar. Zab bdes adoex es riap ~/.pjzheror pice anw zyl al iun!
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.