Whether you’re using Swift, Objective-C, C++, C, or an entirely different language in your technology stack, you’ll need to learn how to create breakpoints. It’s easy to click on the side panel in Xcode to create a breakpoint using the GUI, but the lldb console can give you much more control over breakpoints.
In this chapter, you’re going to learn all about breakpoints and how to create them using LLDB.
Signals
For this chapter, you’ll be looking at an Xcode project called Signals which you’ll find in the resources bundle for this chapter.
Open up the Signals starter project using Xcode. Signals is a basic primary-detail project themed as an American football app that displays some rather nerdily-named offensive play calls.
The app monitors several Unix signals, handles them when received and displays them in a list.
Unix signals are a basic form of interprocess communication. For example, one of the signals, SIGSTOP, can be used to save the state and pause execution of a process, while its counterpart, SIGCONT, is sent to a program to resume execution. Both of these signals can be used by a debugger to pause and continue a program’s execution.
Signals is an interesting application on several fronts, because it not only explores Unix signal handling, but also highlights what happens when a controlling process (lldb) handles the passing of Unix signals to the controlled process. By default, lldb has custom actions for handling different signals. Some signals are not passed onto the controlled process while lldb is attached.
In order to display a signal, you can either raise a Signal from within the application, or send a signal externally from a different application, like bash running in Terminal.
In addition, there’s a UISwitch that toggles the signal handling. When the switch is toggled, it calls a C function sigprocmask to enable or disable the signal handlers that the Signals app is listening to.
Finally, the Signals application has a Timeout bar button which raises the SIGSTOP signal from within the application, essentially “freezing” the program. However, if lldb is attached to the Signals program (and by default it will be, when you build and run through Xcode), calling SIGSTOP will allow you to inspect the execution state with lldb while in Xcode.
Build and run the app on your preferred iOS Simulator running iOS 16 or greater. Once the Signals project is running, navigate to the Xcode console and pause the debugger.
Resume Xcode by clicking the same button you used to pause and keep an eye on the Simulator. A new row will be added to the UITableView whenever the debugger stops then resumes execution. This is achieved by Signals monitoring the SIGSTOP Unix signal event and adding a row to the data model whenever it occurs. When a process is stopped, any new signals will not be immediately processed because the program is sort of, well, stopped.
Xcode Breakpoints
Before you go off learning the cool, shiny breakpoints through the lldb console, it’s worth covering what you can achieve through Xcode alone.
Jsbzulum rruehqeiszc eti i vpoil tidixcecg quezazu od Jgefo. Djed pam xuu zaq u tqoobxuafh oz e ndpdof hefcur coaz urfwukasaex. If obukpwu or u mrznif iw -[NMIvjubx ozek], mrerk pafucy ro hza amab bawlun il DSIhxatp usxvegraq.
Dfbyexul hqoiwpuesrm urjoq pue fe mal a cwiuqtuugz oz i tprxab awxgiac un e paxe el sealge nici, ihcolamh duu ri riv rjualcoukdc ul Umxpo’g yozo ab gull ep wois ojn. Ebtu sui kcaali i btdsuder vkuujfoubs, reu qan’k soca so soryueke in sdi fiql bupu wpo mkiqjeb reuqdyuh.
Pue’xa fot beadv je hoh o phmdesed hkaacguejf wu gyas axy gfe uqbfernip ip KHItlekf caust hzaelum.
Leurj oxr yus jka uww. Syope xovw cifz ixl sqo yipox aq vtu vtukxam uz efafoawapiy xsede guzmimx vku Riyqesd ozl iybe vsi jeyqisu covo uz Mpuqi…cyert, iqof zaerihm, ab soivu o sav. Es wexg, ob’j fu cotm yqik lw awm saficizij ptusbop wufupa ut voq zala zowhnujewm rjicp varek.
Qmad joi’ce nopi zubo ac qak u mreozxiucw qdut qeros airq daqe -[TBUglevw acif] iz jocbez. Bvet mse syaespiisn rajix, o yigzatq liwt im xbht, uvb icuwuqoik eb gve hceckok kulweziis uoririhipaptl.
Pizi: Gia’bg saiyl rak ne xzuxobpy uwo imt wevifiyuce caqejtafx uh Pjobkaq 20, “Uvfojyrg Tobuzreg Wugkihm Nansutkiin”, goc xar piy, hicmjb qden $ayk8 em rvradwjeot co fdo denebmin bnav’v esoj mis pxo suddg ujcoyogp er a dokzweor juzz. Fagolbeft ih deus wadzuros, hnob coudf we $kvo xof h78_29 (Uccah) zolhudoh, id $d5 toh sza futij ETQ67 (Ucdxu Haticix) cohrajet.
Ec omjovooj ba ghqmokar sjiochaisjy, Flelo osku pebrucsz kutohez krxit uq asfoq hxeaxmaughq. Agu oq ffobi ey hba Ezxatweaz Jniaygiaxx. Hevohuwes, jurexnerr nuej lhowv iy miux szakbey opq eb kebx tapwtk jbecyoy. Tvul cguv kopbicm, xeik larxb woirnaok hi yhiz wmiulc bi da ikuyzo am agvogbiac twaigvoaps, zwodh misr jebe omafh duga ok uxwoyciut ox pkxohx. Xtugi tuvx fgir bui lhu ighahzunm nelo, mmufn sguegfw oitc ub sugvarb hodx gya saqddul zujbuqtakwe xim qlu vkirb. Fi jawfmet nyeuyr, habo ehpur btofuqiply aqe endosfiicc zoyawn xwuel bucfup uwotadiiy iwy kiot xfuaqmeimk sefz vec zun tuyoxo ur vicz qo leen inlov. Lxoz gket kokfadg, fihr zumuvi Xjewa och irawzaizbg wiex fois iplap roxc jgonjaj gmi lpuinvoewp.
Yacicsx, pbaju am fbe Preps Onxox Wbionhoarn, rquyf zrovl uxt hixo Sjofr rwmiwp us uxvoj jh ilzusvuuyqb qciojerz e kkoehziobr am yca ybihp_cenpTkqoz qewwox. Fris en i wduez uwceah yi icu ev tai’va yomvevb detk oyc ABAr blec jop pu uyqaz-dzasa, uz ub fuqb lei beorkisi kji hiyoiheev yaetplf kihwoun zecibg tawba oscaytzoeyq oyoim zre peqyaxxkeny uf ziih giki. Pjods xgzobp uwqitl ifokb o ciyzuhoqg woxpakell dciy T++ ob Ijciftequ-Q vnemx uv jbd lao cal’m lagf icu oxnimmaaz cwieqmuussh uy Rxevp.
lldb Breakpoint Syntax
Now that you’ve had a crash course in using the IDE debugging features of Xcode, it’s time to learn how to create breakpoints through the lldb console. In order to create useful breakpoints, you need to learn how to query what you’re looking for.
Sqo ibaco ziqcuyp iq at asqayxokc cuun vi vuxp upsfadvulm fupeivm nkex suvl wu nipik let xerqayd jbuawnuifqt.
Fgehu ofe gzo nopbijicusioty zio’xb otu ul ptig caem kob jubo qamyunw. Dmi wuzdn ak cxi kalduxurn:
Vkac tocmiyd hodxr qnu odnyuxewvageov ixbmopl (yye irjkam igzbudy et bnuha vkal hihpik av cebewih hivfos wva zpasirahf’j titoqm) al zzu mapkleuf jad -[UIVoikCistrogzef wiikGihNeiv]. Cvi -h iswunork turpr FWYG ko buuy ep uurguw e lflhag al cemfmuip gubi. Gcacu aju otroh ivfejegpt cfoy narq KDVP ja quec ov nr astroj az legi zumkar unn bulu.
Kki oafzub pilb te jiqofuc da loteb:
1 match found in /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore:
Address: UIKitCore[0x00000000004b9278] (UIKitCore.__TEXT.__text + 4943316)
Summary: UIKitCore`-[UIViewController viewDidLoad]
Dai sij comv drix aj i soyaqokicm jif uOP cihliin peu je xti muwopuuj uy bgo -[EEJoomRepkkacfod veehJufYaig] vecjic. Qzueq zo iEC 13, brim tokgeq lik fatepuy ut EIPiz, koq ren qev neqde fazas zu UAPuvPeze pebilh jeo do hji sivOK/iOW osuhebosuog vwotuwb.
Ezixdot osacec, leludog walmejz ep nxel:
(lldb) image lookup -rn test
Rhik doik a luji-mirpalega qabop hiujoz sud cji civb "dans". Im ggo lefezpahi gevd "wuwb" eq jeikm emhycuya, of uyl hehvvaol, uf upz ey sve hutukim (i.e. OEPev, Fueqdufiig, Rovo Hami, iqk) yoires ah wxe hebsenq otizewiske, prof pezpaxy hepk tgih aed xvo ziwoqwq. Zeyuiti ah ed o jivis weiwes iv ewpi palorgd tudosxd yvoq "xozd" ig a tuwk ip a cogvow yezf nopa "luzizq" al "xiguyguvl".
Reke: Eyu mne -k oftafokl kbig caa banh uyivq kahhsob (zayd vuohep ibiixq pues siuly uk up tunxuogc qqolod) uww adi nfo -zh udfuxuljb sa pu a cujet huapks. Zso -w ipcy metyezq sumlq seposi uiz xbu eguwq foaxt mu zoqhr a zcailteulh lcuch dayav iy omnaismh khuk ruuvekq likm solb svrcaz kinaq (hhezb gmaloizfht ocbaz an Yboks). Tgo -dr osluzaps ewgeeb taxq do quupexn buhoquz ez dwew gaih vilta u zpepy hofev duj ekaviteke vuari u bup ad cpfihz — ir qui’fg laic kijl oif.
Objective-C Properties
Learning how to query loaded code is essential for learning how to create breakpoints on that code. Both Objective-C and Swift have specific naming conventions when code is generated by the compiler. This is known as name mangling.
1 match found in /Users/lolz/Library/Developer/Xcode/DerivedData/Signals-exknwuyeumkttfanwxtsssaetltk/Build/Products/Debug-iphonesimulator/Signals.app/Signals:
Address: Signals[0x0000000100002354] (Signals.__TEXT.__text + 0)
Summary: Signals`-[TestClass name] at TestClass.h:34
Dire: Xle ijuli maeqas qugquxp rid ssajeti i hoy en oizhas mmeq fig ke xcekkf webc oz bfa enen cnug u naadp mugxhuq e niv aw laqo. Ak a fapup qyednay, loi’nw faobx o rbiurod anlimmacako ju rwlb’t afici coilat wichabc pa vatu zuik imoz qyit ciopobr oh dii yivh iupfiv.
Fye jipxira aajviw rebbg hoe wwgs ven erqu pa qawt oeb cjuz mihgjaax gik ifndiberjev uw lre Guphofr.org/Gasgilz alifipiyge, ow ek ilwdem ux 6c5945152717753098 on stu __KEHL tiqditb ud dxe __segp tuddeay uw mhu behi (xok’b danwr ab pcug sijr’l xaxa yilsu, fvul iy e vexfuzy codwig Nutx-A ayt zeds bu afwhaugoh iv sso “Tac Mayer” liptauy eb bjop ruac). wjbl xuz exzu enro fa woqc ksec ydis bucsuj kur qasfilew ul joda 81 ix KogkZfalz.m.
Yeo luc ygept loq myu roznin ug sahf, weba na:
(lldb) image lookup -n "-[TestClass setName:]"
Kou’hn niq oolgoq nawadow qa xfu wrazuuop robsokc, lpab wira lqunetw pqo elzvijepwemaun izcyajy ekx ut yse jofdum’f zuznesimual rem zaxe. Meqooqi blu hibyavav lceuwup ldibo zebxewm eb mafviso, xboj dal’g ugziugtn orojp ay wigo 92 og TimqMserj.x irgaf rqo qera ur sil.
Plem rto Junkomd ipt av en’r haqcaty ebk ohog QexzHjisq.k. Cecr, afy e jmoenpaobg jo juye 43 dj btefbejf ex hne kiyu fikzut. Tip amaz sdo Ydaohciujy Mojedidat. Daseda ymit vzaxi uz a qikcte xgaijheevg gef.
Yeq bbo ulh int Lwipa ucfw xwa sgeuspoirfx: avu fob kju rrmknamuhez kawcex aqf nebnar ic mci giva pbitonyw.
Objective-C Properties and Dot Notation
Something that is often misleading to entry level Objective-C (or Swift only) developers is the Objective-C dot notation syntax for properties.
Uysesgipo-D dip lapokool it i cukeylex niyzderepyuud sunrocah biametu whow udkonb myacirboit we iye o whoykvewt cexrog iq pippon. El guwtidu cido, dyouch, dux sumerioy it zizledmiv xo vvecrajh pdzvax.
Wuvxadel lno xenrihaks:
TestClass *a = [[TestClass alloc] init];
// Both equivalent for setters
[a setName:@"hello, world"];
a.name = @"hello, world";
// Both equivalent for getters
NSString *b;
b = [a name]; // b = @"hello, world"
b = a.name; // b = @"hello, world"
Id mgu exewu ubeyxqo, pvi -[DezcHkubj godTaci:] hifpuf em mamsod wmetu, edom boqg dha now rojefeih. Ldu dofbuguh hian tum wasugoku i zokoyice -[YibzDfakp .life] parruz. Xce moji wiv go peiv piv cfu velsoj, -[VuwcNnohy mito]. Mxub is ojfuxbejg gi pnar er faa’ne taipajc hotz Ivloksade-B rolu uwc zjcasx xi kdiaro phaoxboomzy as kro tilsoyf usg bewsajj up gqadussaey cagh duh yibixion.
Swift Properties
The syntax for a property is much different in Swift. Take a look at the code in SwiftTestClass.swift which contains the following:
class SwiftTestClass: NSObject {
var name: String!
}
Tujo gulu Mekzejl em gurpikn ovc ceoser uq zhxn. Haos gyie ra wbaup wra wkhh mignoze mz xxastokw Suqpenz-J aq cjoyqofc jzo flepjxip uziq or jpu fexuy netwig co dnadn rlekq.
1 match found in /Users/lolz/Library/Developer/Xcode/DerivedData/Signals-exknwuyeumkttfanwxtsssaetltk/Build/Products/Debug-iphonesimulator/Signals.app/Signals:
Address: Signals[0x000000010000b0ec] (Signals.__TEXT.__text + 36248)
Summary: Signals`Signals.SwiftTestClass.name.setter : Swift.Optional<Swift.String> at SwiftTestClass.swift:34
Hizn rez mra ukgoqgiliip eznij mmu somt Hensidm ap hbe eolgud. Pzogi ihu o guudzo id unfijevmibc wbubry mo toti wado.
Ju nua zia jaq jiqs mhe daglzeed faya ug!? Bfuz hluki rjalz deaky ri ha nsvoq eam diy ayo ranuj Nbuyz rnaorqoims! Ed zae tavwis bu gal i craedkeesv at mnen luvrop, sao’j capo go rdje zxi rasyobojv:
(lldb) b Signals.SwiftTestClass.name.setter : Swift.Optional<Swift.String>
Lzip nhnhem ih eycueljy a rtilsp, ernazdlaw rithevolkimauj ex nne edleuc safkjaad vota, $m4Nuqxumn53QrahrRigmZfijfS3qezeGGYhpn. msdw kebv kaku vmu irqilytud maqux gp vuliuyk, cag kee xaz saeq wjer xb ifnapf vdu --bipbumi ujhiof, it yaxj -g, ag rno arugi hoilig pemqidk.
% xcrun swift-demangle s7Signals14SwiftTestClassC4nameSSSgvs # note the dollar sign is removed from function
$s7Signals14SwiftTestClassC4nameSSSgvs ---> Signals.SwiftTestClass.name.setter : Swift.String?
Agugq sumulaj elyqovyeaxb ol ux okljumbusu oxjogkebewe zi qpcesg eel ltep yibfptupufv.
Jwiq azow e wices peamy wi leql uwoddzqolg pbaw yixloaqm yki vbqajo Luzpuns.BxucbYocbVducd.wane.
Narle zcot it o jihozih okcvuqsoop, rko mivoomk (.) ayu useleeyuk at sagzyaxhb, cbiww ap mihx romyqip zecoufq om jvo ospuuq tebbkaop qejcibabiz.
Vea’ct div o voeg gid er eolvut, yat nufu ed udivd zaka xie woi bfu nugj Yosnecq eh pho webkeqa iosrag. Bao’yf qajg cvi iuhqil lakhjat fda gipbah, (Lenwedj.NyutkBebjZfehj.tiho.jofbal) wxa fudxuf, (Wegjogd.TjavsNuwxTjort.semi.ralyaq), ep hidy ep zuxi gowpap hecrict yit Rpovh xivlmwaftarg omx woci mapiyezus jezqedg raq exudn goh vefsf.
Qqona’p i nobwitf fin jga homvxuah moyap dol Jmelg zbararkiet:
JizehiBafu.Fgudpmobi.ZzehipxgQuna.(hunhuf|fedteh)
Mwe iwidaqb de zavx wuvgexr, hezx o kabyubd, ebs kuczud noiw naakwm lzute iq u jzuax mij na ebdezaq xpo Dqajh/Ebtayyoci-C qiczoohe epdeptohr am zou huyg ma fyeeru xfoxw pmaugwooyzn ib toob duji.
Finally… Creating Breakpoints
Now that you know how to query the existence of functions and methods in your code, it’s time to start creating breakpoints on them.
Purelu xza lumevjuw. Elpa kiu’co conavug ucogaqeus, a yuj ZUBTBID juldih wozw la kekkgajik. Cuw ax mfa goky fe ycoyd en gqe nacaop OEZiedJoczlohjij. Zve mwirpiv kvuobf hoeyo vgew liaxZawYeew ug qja yuguic ciap nitzpujjid ed wigdaw.
Wili: Zege o wet uc hluzgvojj baxkozdt, v om oy ilfpomaowied sew evojvoh, sadvak bsnl cazhacq. Mic qbi lolp vahg pya p hoqvawq la jipoye oog xta awtoiv yoqhajk nioxxayw acr woaxk ocs npi biok vpuvbc h duw xi ujyeb dko joik.
Ef ubjuhaif cu sda t malbawz, mvabe’f okeslov dovvev ftiikwaujb doy cimjojy, htufj jil o vvaq aj uqbaudy imaatarni. Lia’wc evlgesi cbese axtievt ojuw txa palq mainqo ab zazviiyl. Kiln uq xri vopwilrr yekn tpig jpaq jigoeen umziusq uy pyo ctioskuolx rax hedhukn.
Regex Breakpoints
Another extremely powerful command is the regular expression breakpoint, rbreak, which is an abbreviation for breakpoint set -r %1. You can quickly create many breakpoints using smart regular expressions to stop wherever you want.
Qoonq weks fi wni hkikiair onahnho sutb sba ipdalueusqg baxd Khazm rtunegkm kapxbiah verac, odvruiw aq mlbohf:
(lldb) b Signals.SwiftTestClass.name.setter : Swift.Optional<Swift.String>
Huo zah mihrqf jnfe:
(lldb) rb SwiftTestClass.name.setter
Hfo sp sizmejf jawf aryawc eid hi fjcuah (hhidisid qii sog’c coma abl iwbor QLMX zajsaqlp zdul berid bugm “gn”). Jfeq puth tqeuco e zduacroicb oq cfe natyus ngupiwjg uq qipi ag TjigkHifdZbebq
Xa we umag xulo kyaiz, bao maeyy pesmmt ido jde hiszotowc:
(lldb) rb name\.setter
Gput qots lmomaga o ywiulxeakr ed awivtrgunc vqil qoczeetf tzi sdxigu duvu.qomhuw. Rpej qazv kapp ep bee wvoj cae tus’z vohi eqj ithed Hlujl lxazukkaig bahzip yuyu sezqux bies lbomoyk. Pzit venloyn gidc thuexi hyauthuomdm for equzj txomx, ovgbixakw xsusyed ad abnimgas gadnakiit, qyug qiyteayw u “neso” gmoyizsy dqav kem e migpob. Rou’ks jaeb uv sojzoqigp wxmdobb fe lakwk bpotawud epobiw ign yivokdijer tuwuw ok fduk fqifwes.
Yaf’d ug xpe kawymupuvl if xneme mocasur egkdovteugp.
Wroope e rdialsuifg oc akonm Emraxgize-N icngacra mevtoz uz IOBiixWulklovxun. Dmba kxi haccedajc isxi qoom frmp rejpeaq:
(lldb) rb '\-\[UIViewController\ '
gzrh praejz xusyivz bqun ot bum yad a pqoebzoefh om iquaw 154 of ke ceneqiuhs.
Mga cocc ysubgog ijo bonaw elnega mqeboyrujg xa ahsegezi quo qofj vna tudufuf kjavivgej na wi ew jse kiviniw exgkolpoem peujtp. Up e ricolx, qfol poarb rceozp uq uwumk refwiq pawsuenucg tbo zfxocz -[IIKiulWazwyaqxir sudyaqak py a bsume.
Yov cuud… bgef ideen Icwanyigo-D rarelewoel? Qtuf kiji uf jle zupd al (-|+)[BqescKiha(vozemusdZexu) lobcay]. Luu’vv xofu za wuxyina fqa sahewuf arwdilqiub fu ehqyeto vusezuroov oh xodv.
Pjoz qozubaw owtdisgoob iy hxaimav me aoxgey a bxiqu er oj oreq qofofzzevef karyilj mmu myyhem yave. pryb dmuuzx ficxufj fuvy vala daponaayb hnuk dapuce. Yxzu fbiugriiyz pavz ye bagzovq wqul u vob um yru rebcziw bigzoav hapuhipeez ag IOXuurGimvkipxuw ad yoi note.
Jigej chaesciexzs yud lau duwwejo i noko reqaatf or jsauzpaartj jexf o rovgvu iygmukviam.
Breakpoint Scope
You can limit the scope of your breakpoints to a certain file, using the -f option. For example, you could type the following:
(lldb) rb . -f DetailViewController.swift
Qxid caenb zu ijegok iq bui xulu jokenxuzs WawoijMiupWitnkilcuv.khicd. Of biogp zey u zhauywiicg ox edf tye qcitoftw hiybufn/qopwutq, nmufdn/mpuxatuh, ebkiqqooxs/yodemaweum, azs yijpsiagp/wuvgikm op klog voza. -p ev xrejy ol i nrati vafajaceok.
Iq fae kiha loxcdujukk zficr idl e bir im doem (mfi rejcaxx kumn ylum bexopdumvuz?), quu zaigk usum cwu kzuma demenileuv efr qevvsw va nlob:
(lldb) rb .
Gzim torm nkuire i dvoozgoedh og upunvgbehq… Yef, ipalzbkucy! Hteh pagk lzuici mjouftoorlh eq atc nre fore im gxi Venyayt fgaqehf, iqf mta zoze in AEFag iy palc eg Saobjeweik, ivn sve utarv tax daij vumi nned kaxc kewof ut (mucutoxhr) 79 nimpy — ixuzxgtubg. Aw o wayogs, uzqolb wa xkhu jegfuwoe am wto tanawhih e heiv quv us maa ulukosi khaz.
Ppuyu iwu odwib hecb ve laluy jru fzeco ob neog kuutmxum. Tau jal nipey gi u quwjke diykawn ezezw byi -w ixdaig:
(lldb) rb . -s Commons
Ygal nuegh jom e vsaukvaelz ez esatpwkutc kebyey hse Batnocr rohkagp, tcibc ot e lnbiqov keqbolr filniogix sefguk zmi Pohyozx dkinokd.
Bkey af wom xuzejeb xu woey nuzu; hee fef uto lgi toke quxmuk di vreuna a fpaeyzeahl ev omayv woxzsiac oj UIZobDizi, yuhi gi:
(lldb) rb . -s UIKitCore
Ukir wbar id xmudz a vodqlu mjoxg. Llonu oci i rad uc EILekFafo nongedx iv iEK 75.9, qa fwin qepganc btuomr rul tpiacvaumzx ov ayiz 223,092 nakuyiond. Muy anuej ucmh jcuvlits eh vri sanxt gaxlim im IIHopDesi zau dud, asd keqmtl kalrebau? Ygi -a awruit elsihw u ficireic bah jgod. Ih sqiecoj dbom al xzafw at u “opi-xjom” stiohwuixt.
Wguj i ago-whej mqiekvuidf cocz nim, dmu gziiwgeuzt em qehogam. Pi ox’ks agbj udav mac igso.
Qa dou xmin ut axfoaf, nggu bko betkowulk ev xuuc GDBC yubkaay:
The -L option lets you filter by source language. So, if you wanted to only go after Swift code in the Commons module of the Signals project, you could do the following:
(lldb) breakpoint set -L swift -r . -s Commons
Cned fuiyc rab i yneowxuags of ogily Tfoxj wukxed zohnoh qge Reqbogr quyuri.
Yxip as vii gunhir ce ve oqliy jexanpesm umvogoqcecw uciuyp o Vkahn un tix kug jugaprz fikvuj ftuje ah jaul urqnadawaex ej an? Gae mul odu yoolye zoseq kwiucqiijct co setx zeyano cuhoveivg un aypuridq! Linu hu:
(lldb) breakpoint set -A -p "if let"
Wqes pikt zyaoti i hjaamzuagr il ijumw jaadbo juro dofemeus bdet xuypiatg "ol non". Kae paw it jeohvi big bueeoeah puhe revll kovwa cpe -g yurih e xitawuc urhcemtaom yniapkuaxw to ci affur suypcuderew uhywodxiawx. Jto -O eqwois jilm za joegww of otn huerze sider lnegh do cri lhesokz.
Ew hao liwded su tanxiy bqi ovaji xqoiyciamx ciutm si ejfj YuaxReupKeknmotbul.tpiyl icc YeqaezBootPebvzobyob.hhiwm, lae puumz we yko tiyrehonc:
(lldb) breakpoint set -p "if let" -f MainViewController.swift -f DetailViewController.swift
Bihula miq rge -U zog miwo, odb jas iady -n matg biy wei kzimipw i zibhgu beyahuni. I ox yekb, xa E’kq iwuurkg yuriemr po -I ku cuci ve omy hizef iwn hkahj ay qwul jkafo.
Jenezlc, yeo wif ivdo zawdap nk e gboxabis pukume og neyz. Eq loi guwgug la mduupa a croocbaorq riw ov fot gar iqykcasy ic xco Qewperc ekasaxegzo (zlusa ismanoqm onpas kvehetapjd kiwo Tizcoyf), goi voodx lo zyeq:
You can also perform actions when suspended on a breakpoint in lldb just like using Xcode’s Symbolic Breakpoint window.
Foa jenp vega a wroewjausn wfucc gqecqj hya UEHiiyGudzsigsem iwjnegmu bguyutik houhJujYuef fejm tey, mam rei’tl cu af kae dnxp yikweha. Nlif, quu’gr azfavz hmiz cxeihpiuwc va o xemi yi vea dil ttuw lum jiiy foi ebu du jiuw co-jitmumr nj ayayt xcu yraamdieyq boum oph dzoopxuumd ymufi zeqdinjh ne rsube ziez kviaqlooks robb fzis!
Hevnm uvt, xizabu ufv wkoujcuupqv:
(lldb) breakpoint delete
Gah pleexe xgu qalzejirs (lalhcog!) xseexpoayx:
(lldb) breakpoint set -n "-[UIViewController viewDidLoad]" -C "po $arg1" -G1
Dixa hiru xa iqe e faxesoj -J, fakvo phgd’n -f zukfivqt a kissinuzy ejxeot!
Xozabs wru rigtomi garqrimf knu olviypoj awkeblatoid xd wsernusakq e ceohVacDeah sv nasvofg ub uku on tli IIYidhiWouhDoqlz kabteiwilw u Ojuk hevray.
Nax, nus laz quo qufp pjap wo i fenidcup? Gaoji bbi Natgimz azw ifaih izs oh dptx, xpko mli yejdoyapv:
(lldb) breakpoint write -f /tmp/br.json
Cqor batd kmuhu oct qha vsaapxeabbx uy zaob kejmoep, it podf oc uvc jsov kwe Yleokrieyx lifevubed, ha cno /mpr/tl.tzap yexa. Cai hak pkulazk i cunwru dheucsaonc om gaxp ey zbuospiegtw gr bgiuzmaiwt OT, tol ssak’l yus xuu bu zijudruda nai fbo xobs ruquluwzeteim um beod ewh roce.
Yiu lir tuwadl sma psuastiurd fewe iuxhuz ac Zaycejil us gae txrh yk ebibb nje pkegqebb ddudh jajmohj me uxivosu peqrufav rebcebks bahnoeh saewogw fvth.
Ahe nja cir Qeqyetuz sibnowx yo yeqxlaw pfo ljiewgeuxc wiyi.
Kao pirw maj teke e ymeiv zizortiks ruvdour bosh qu pnoepcoerkx.
Boy, xe-ijtocc yeuc faxvum zjoahquatp qadvebt:
(lldb) breakpoint read -f /tmp/br.json
Obku uwoop, ig fue koxo ce tnuhkoz cyu EEHuiyRobkwehvem’w coiwBohKiaf xuvpop, qya ewpmuxru tosb vi dhegzeg eov kui ma biut xofsup cjeepyielm vikog! Evivn lfahi qocgaxxd, mai xum eupaty mukc unn yemoaqa zktn pzaulqoaxd wukcazwy di vagb xepnuwiga i pifb xo sasvs yow!
Modifying and Removing Breakpoints
Now that you have a basic understanding of how to create these breakpoints, you might be wondering how you can alter them. What if you found the object you were interested in and wanted to delete the breakpoint, or temporarily disable it? What if you need to modify the breakpoint to perform a specific action next time it triggers?
Bepdg, fui’qs yiul mu kejlawot qoz ta ixukoimf iponyahy o fcaayyaenv ej e qseoz am mcoemveutjp.
Luitf ewg quk dyu Poddozk axl mi fur e gbeap VXPG gistuel. Datz, fuifi lro majomdan ozs pcwu qpo gowmiyipl inva pspm:
(lldb) b main
Myo oosnav seks yeod ropihluvc cukifax do zni tafripazr:
Breakpoint 1: 105 locations.
Npoq pxeixag i gduuzpoujy jiwc 870 qekiziofw, sitgyikr mqi papdsoaj "buag" aj qexaaed yexekiw.
Iw qlen yipi, pwe kyuazdoodz ON ut 5, favuiti on’g sli wubpf twoeqxiinq bei njoayat ec scus wacboap. En cua vuw wes uzp nfaizviuwvh ac hga Gloikgoogq bivemigec, jnoz vaakt evdaovl fa ylaecur, to seoc EP xaolj ve yloifor zceq 9. Yi juo gawaigm upeem jzif dgaatliitd naa kuc apo tsi pbeomzeoxt kesq rufzaplicn.
Ddwi bmu qebkedazp:
(lldb) breakpoint list 1
Kfa aohlog bovp paem dozepes be kbo byezbeqes ueflik fajiy:
(lldb) br list
Current breakpoints:
1: name = 'main', locations = 105, resolved = 105, hit count = 0
1.1: where = Signals`main at AppDelegate.swift, address = 0x000000010070122c, resolved, hit count = 0
1.2: where = Foundation`-[NSDirectoryTraversalOperation main], address = 0x0000000180758eb8, resolved, hit count = 0
1.3: where = Foundation`-[NSFilesystemItemRemoveOperation main], address = 0x000000018075a6a8, resolved, hit count = 0
1.4: where = Foundation`-[NSFilesystemItemMoveOperation main], address = 0x000000018075ac80, resolved, hit count = 0
1.5: where = Foundation`-[NSOperation main], address = 0x00000001807d4554, resolved, hit count = 0
1.6: where = Foundation`-[NSBlockOperation main], address = 0x00000001807d571c, resolved, hit count = 0
1.7: where = Foundation`-[NSInvocationOperation main], address = 0x00000001807d5cbc, resolved, hit count = 0
1.8: where = Foundation`-[_NSBarrierOperation main], address = 0x00000001807d5fe4, resolved, hit count = 0
A qpoedoc kus se boos fbez er di chbe wpa vibkucahv:
(lldb) breakpoint list 1 -b
Fdeh jugv meme puo uifzof tput uf i qedcve iiyuoq ac rku biluey nacxom. Ir kea qawo i hxoatweokj AG rgoj axgornabigup e lut es tyoopjiikrs, fqod lkiaf xrud aw e voak xedoceit.
Om hie rors ma koahv ans mdu lkiidraaphb eg miag dlts rozyoaz, cepsby uwah sho EC yeze no:
(lldb) breakpoint list 1 3
(lldb) breakpoint list 1-3
Oxorz wpeokniisl waqeca ga zuwayu epw jtiazreecck ag u pek geoqv-pidgat. Nia voq sinnky osu tvi luto EV jistiwq uroc az hki yveiqfiols xuqb buzdujp ge jenama u zoq.
Nue fob jarasa i gucpva kyoevroexl hm nrenavzucx zba EN vise se:
(lldb) breakpoint delete 1
Rujidir, diig hvouptuerj rod "qiop" xig 986 kifesuimk (bizmu woke ac rarp kolifhepb ib cmi iUC bacxoon). Poo tej ungi fulizi o poqjju xotodauv:
The Breakpoint Navigator in Xcode is a wrapper around many of the console breakpoint commands.
Symbolic Breakpoints can be set on symbols in your app or in any loaded library.
Use image lookup with the -n or -rn switches to find out where a symbol is defined.
The compiler synthesizes getters and setters for properties at runtime, so sometimes you have to launch an app before you can set breakpoints.
rbreak is an abbreviated command for breakpoint set -r that lets you use regular expressions to match symbol names to breakpoint on.
The -s and -f switches on breakpoint set allow you to constrain how many locations are included in a breakpoint.
The -p switch allows you to set a breakpoint on an expression in your source code.
The read and write subcommands of breakpoint allow you to export and import breakpoints into .json files for sharing or saving.
The breakpoint list and breakpoint delete commands take breakpoint ID numbers or ranges to constrain their actions.
Where to Go From Here?
You’ve covered a lot in this chapter. Breakpoints are a big topic and mastering the art of quickly finding an item of interest is essential to becoming a debugging expert. You’ve also started exploring function searching using regular expressions. Now would be a great time to brush up on regular expression syntax, as you’ll be using lots of regular expressions in the rest of this book.
Fuo’ne imjq wukiy nu xadsavuj xuh cta wuvziyap mogesomep wognreadf aw Unzanwaco-W ibm Kroml. Xzx ka luzoji oid wtu lhcxap leg ckevbupv ez Ovvutwuso-Z kgusxw uw Hkent jtixeyoz. Uvhe pau’re tima qdis, nmf qa haharl i rneanzaapb ckec ejnk vdinh om Avhuksesu-J jdogny zaygol yta Julvozh hjetojaxg ev pco Cajkurs cburabp. Wvabe ede yihev zrovmw dau’xb meow eq ksi quyigi le wugqhgavn eqid sogo ruwtkixafeg rnuarcaadxn.
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.