您的位置:首页 > 移动开发 > IOS开发

XCode_LLDB_调试锦集

2015-10-30 18:30 429 查看
长篇高能

Diy_Commands来自:https://github.com/facebook/chisel

快捷键cmd+L快速定位至源码文件中指定行。快捷键cmd+k快速清除console中的调试信息。打印UIHierarchypo[[selfview]recursiveDescription]po[[[[UIApplicationsharedApplication]windows]objectAtIndex:0]recursiveDescription](lldb)helpDebuggercommands:apropos--Findalistofdebuggercommandsrelatedtoaparticularword/subject.breakpoint--Asetofcommandsforoperatingonbreakpoints.Alsosee_regexp-break.command--Asetofcommandsformanagingorcustomizingthedebuggercommands.disassemble--Disassemblebytesinthecurrentfunction,orelsewhereintheexecutableprogramasspecifiedbytheuser.expression--Evaluateanexpression(ObjC++orSwift)inthecurrentprogramcontext,usinguserdefinedvariablesandvariablescurrentlyinscope.frame--Asetofcommandsforoperatingonthecurrentthread'sframes.gdb-remote--ConnecttoaremoteGDBserver.Ifnohostnameisprovided,localhostisassumed.gui--SwitchintothecursesbasedGUImode.help--Showalistofalldebuggercommands,orgivedetailsaboutspecificcommands.kdp-remote--ConnecttoaremoteKDPserver.udpport41139isthedefaultportnumber.log--Asetofcommandsforoperatingonlogs.memory--Asetofcommandsforoperatingonmemory.platform--Asetofcommandstomanageandcreateplatforms.plugin--Asetofcommandsformanagingorcustomizingplugincommands.process--Asetofcommandsforoperatingonaprocess.quit--QuitoutoftheLLDBdebugger.register--Asetofcommandstoaccessthreadregisters.script--Passanexpressiontothescriptinterpreterforevaluationandreturntheresults.Dropintotheinteractiveinterpreterifnoexpressionisgiven.settings--Asetofcommandsformanipulatinginternalsettabledebuggervariables.source--Asetofcommandsforaccessingsourcefileinformationtarget--Asetofcommandsforoperatingondebuggertargets.thread--Asetofcommandsforoperatingononeormorethreadswithinarunningprocess.type--Asetofcommandsforoperatingonthetypesystemversion--ShowversionofLLDBdebugger.watchpoint--Asetofcommandsforoperatingonwatchpoints.Currentcommandabbreviations(type'helpcommandalias'formoreinfo):add-dsym--('targetsymbolsadd')Addadebugsymbolfiletooneofthetarget'scurrentmodulesbyspecifyingapathtoadebugsymbolsfile,orusingtheoptionstospecifyamoduletodownloadsymbolsfor.attach--('_regexp-attach')Attachtoaprocessidifindecimal,otherwisetreattheargumentasaprocessnametoattachto.b--('_regexp-break')Setabreakpointusingaregularexpressiontospecifythelocation,where<linenum>isindecimaland<address>isinhex.bt--('_regexp-bt')Showabacktrace.Anoptionalargumentisaccepted;ifthatargumentisanumber,itspecifiesthenumberofframestodisplay.Ifthatargumentis'all',fullbacktracesofallthreadsaredisplayed.c--('processcontinue')Continueexecutionofallthreadsinthecurrentprocess.call--('expression--')Evaluateanexpression(ObjC++orSwift)inthecurrentprogramcontext,usinguserdefinedvariablesandvariablescurrentlyinscope.continue--('processcontinue')Continueexecutionofallthreadsinthecurrentprocess.detach--('processdetach')Detachfromthecurrentprocessbeingdebugged.di--('disassemble')Disassemblebytesinthecurrentfunction,orelsewhereintheexecutableprogramasspecifiedbytheuser.dis--('disassemble')Disassemblebytesinthecurrentfunction,orelsewhereintheexecutableprogramasspecifiedbytheuser.display--('_regexp-display')Addanexpressionevaluationstop-hook.down--('_regexp-down')Godown"n"framesinthestack(1framebydefault).env--('_regexp-env')Implementsashortcuttoviewingandsettingenvironmentvariables.exit--('quit')QuitoutoftheLLDBdebugger.f--('frameselect')Selectaframebyindexfromwithinthecurrentthreadandmakeitthecurrentframe.file--('targetcreate')Createatargetusingtheargumentasthemainexecutable.finish--('threadstep-out')Finishexecutingthefunctionofthecurrentlyselectedframeandreturntoitscallsiteinspecifiedthread(currentthread,ifnonespecified).image--('targetmodules')Asetofcommandsforaccessinginformationforoneormoretargetmodules.j--('_regexp-jump')Setstheprogramcountertoanewaddress.jump--('_regexp-jump')Setstheprogramcountertoanewaddress.kill--('processkill')Terminatethecurrentprocessbeingdebugged.l--('_regexp-list')ImplementstheGDB'list'commandinallofitsformsexceptFILE:FUNCTIONandmapsthemtotheappropriate'sourcelist'commands.list--('_regexp-list')ImplementstheGDB'list'commandinallofitsformsexceptFILE:FUNCTIONandmapsthemtotheappropriate'sourcelist'commands.n--('threadstep-over')Sourcelevelsinglestepinspecifiedthread(currentthread,ifnonespecified),steppingovercalls.next--('threadstep-over')Sourcelevelsinglestepinspecifiedthread(currentthread,ifnonespecified),steppingovercalls.nexti--('threadstep-inst-over')Singlesteponeinstructioninspecifiedthread(currentthread,ifnonespecified),steppingovercalls.ni--('threadstep-inst-over')Singlesteponeinstructioninspecifiedthread(currentthread,ifnonespecified),steppingovercalls.p--('expression--')Evaluateanexpression(ObjC++orSwift)inthecurrentprogramcontext,usinguserdefinedvariablesandvariablescurrentlyinscope.po--('expression-O--')Evaluateanexpression(ObjC++orSwift)inthecurrentprogramcontext,usinguserdefinedvariablesandvariablescurrentlyinscope.print--('expression--')Evaluateanexpression(ObjC++orSwift)inthecurrentprogramcontext,usinguserdefinedvariablesandvariablescurrentlyinscope.q--('quit')QuitoutoftheLLDBdebugger.r--('processlaunch-c/bin/sh--')Launchtheexecutableinthedebugger.rbreak--('breakpointset-r%1')Setsabreakpointorsetofbreakpointsintheexecutable.repl--('expression-r--')Evaluateanexpression(ObjC++orSwift)inthecurrentprogramcontext,usinguserdefinedvariablesandvariablescurrentlyinscope.run--('processlaunch-c/bin/sh--')Launchtheexecutableinthedebugger.s--('threadstep-in')Sourcelevelsinglestepinspecifiedthread(currentthread,ifnonespecified).si--('threadstep-inst')Singlesteponeinstructioninspecifiedthread(currentthread,ifnonespecified).step--('threadstep-in')Sourcelevelsinglestepinspecifiedthread(currentthread,ifnonespecified).stepi--('threadstep-inst')Singlesteponeinstructioninspecifiedthread(currentthread,ifnonespecified).t--('threadselect')Selectathreadasthecurrentlyactivethread.tbreak--('_regexp-tbreak')Setaoneshotbreakpointusingaregularexpressiontospecifythelocation,where<linenum>isindecimaland<address>isinhex.undisplay--('_regexp-undisplay')Removeanexpressionevaluationstop-hook.up--('_regexp-up')Goup"n"framesinthestack(1framebydefault).x--('memoryread')Readfromthememoryoftheprocessbeingdebugged.Currentuser-definedcommands:alamborder--Formoreinformationrun'helpalamborder'alamunborder--Formoreinformationrun'helpalamunborder'binside--Formoreinformationrun'helpbinside'bmessage--Formoreinformationrun'helpbmessage'border--Formoreinformationrun'helpborder'caflush--Formoreinformationrun'helpcaflush'dcomponents--Formoreinformationrun'helpdcomponents'fa11y--Formoreinformationrun'helpfa11y'flicker--Formoreinformationrun'helpflicker'fv--Formoreinformationrun'helpfv'fvc--Formoreinformationrun'helpfvc'hide--Formoreinformationrun'helphide'mask--Formoreinformationrun'helpmask'pa11y--Formoreinformationrun'helppa11y'pactions--Formoreinformationrun'helppactions'paltrace--Formoreinformationrun'helppaltrace'panim--Formoreinformationrun'helppanim'pca--Formoreinformationrun'helppca'pcells--Formoreinformationrun'helppcells'pclass--打印一个对象的继承关系pcomponents--Formoreinformationrun'helppcomponents'pcurl--Formoreinformationrun'helppcurl'pdata--Formoreinformationrun'helppdata'pdocspath--打印Document全路径pinternals--打印对象内部所有属性pinvocation--Formoreinformationrun'helppinvocation'pivar--Formoreinformationrun'helppivar'pjson--Formoreinformationrun'helppjson'pkp--Formoreinformationrun'helppkp'presponder--Formoreinformationrun'helppresponder'ptv--Formoreinformationrun'helpptv'pvc--Formoreinformationrun'helppvc'pviews--Formoreinformationrun'helppviews'rcomponents--Formoreinformationrun'helprcomponents'show--Formoreinformationrun'helpshow'slowanim--Formoreinformationrun'helpslowanim'taplog--Formoreinformationrun'helptaplog'unborder--Formoreinformationrun'helpunborder'unmask--Formoreinformationrun'helpunmask'unslowanim--Formoreinformationrun'helpunslowanim'visualize--Formoreinformationrun'helpvisualize'vs--Formoreinformationrun'helpvs'wivar--Formoreinformationrun'helpwivar'Therearemanycommands;here'safew:(CompatibilitywithiOS/Macindicatedatright)
CommandDescriptioniOSOSX
pviewsPrinttherecursiveviewdescriptionforthekeywindow.YesYes
pvcPrinttherecursiveviewcontrollerdescriptionforthekeywindow.YesNo
visualizeOpena
UIImage
,
CGImageRef
,
UIView
,
CALayer
,
NSData
(ofanimage),
UIColor
,
CIColor
,or
CGColorRef
inPreview.apponyourMac.
YesNo
fvFindaviewinthehierarchywhoseclassnamematchestheprovidedregex.YesNo
fvcFindaviewcontrollerinthehierarchywhoseclassnamematchestheprovidedregex.YesNo
show/hideShoworhidethegivenvieworlayer.Youdon'tevenhavetocontinuetheprocesstoseethechanges!YesYes
mask/unmaskOverlayavieworlayerwithatransparentrectangletovisualizewhereitis.YesNo
border/unborderAddabordertoavieworlayertovisualizewhereitis.YesYes
caflushFlushtherenderserver(equivalenttoa"repaint"ifnoanimationsarein-flight).)YesYes
bmessageSetasymbolicbreakpointonthemethodofaclassorthemethodofaninstancewithoutworryingwhichclassinthehierarchyactuallyimplementsthemethod.YesYes
wivarSetawatchpointonaninstancevariableofanobject.YesYes
presponderPrinttheresponderchainstartingfromthegivenobject.YesYes
1、brew安装命令【ruby-e"$(curl-fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"】2、通过brew安装chisel【brewinstallchisel】3、创建~/.lldbinit【cd~/】【touch.lldbinit】【open~/.lldbinit】4、Addthefollowinglineto~/.lldbinittoloadchiselwhenXcodelaunches:commandscriptimport/usr/local/opt/chisel/libexec/fblldb.py重启XCode,开始调试之旅吧-(IBAction)checkBtnAction:(id)sender触发断点(lldb)posender<UIButton:0x8231d10;frame=(17520;6040);opaque=NO;autoresize=RM+BM;tag=2;layer=<CALayer:0x8231e00>>(lldb)pviewssender<UIButton:0x8231d10;frame=(17520;6040);opaque=NO;autoresize=RM+BM;tag=2;layer=<CALayer:0x8231e00>>|<UIImageView:0x820c070;frame=(813;13.513.5);clipsToBounds=YES;opaque=NO;userInteractionEnabled=NO;layer=<CALayer:0x820c920>>|<UIButtonLabel:0x8205a00;frame=(21.511;3018);text='';clipsToBounds=YES;opaque=NO;userInteractionEnabled=NO;layer=<CALayer:0x8205c40>>(lldb)pvc效果同:IOS8中UIViewController的一个私有方法
[UIViewController
_printHierarchy]
<KLTabBarController:0x1bb32b0;view=<UILayoutContainerView;0x8278540>;frame=(0,0;320,480)>|<KLNavigationController:0x1bb3830;view=<UILayoutContainerView;0x1be8e70>;frame=(0,0;320,480)>||<EduHomePageViewController:0x1bb6be0;view=<UIView;0x1b9b960>;frame=(0,0;320,480)>||<StudentCircleTabViewController:0x82ce240;view=<UIView;0x82c9ac0>;frame=(0,64;320,416)>||<AddTopicViewController:0x82e8570;view=<UIView;0x821d400>;frame=(0,64;320,416)>|<KLNavigationController:0x1bbc260;viewnotloaded>||<ContactMainListViewController:0x1bba470;viewnotloaded>|<KLNavigationController:0x1b69a90;viewnotloaded>||<DynamicTabViewController:0x1b62140;viewnotloaded>|<KLNavigationController:0x1b96cd0;viewnotloaded>||<MineViewController:0x1b96e80;viewnotloaded>(lldb)visualizeimagefvfvc通过类名搜索当前内存中存在的view和viewController实例的命令,支持正则搜索。(lldb)fvUIButton0x8231d10UIButton0x8205a00UIButtonLabel0x8206ee0UIButtonLabel0x8232d00UIButton0x820da20UIButtonLabel0x82302b0UIButton0x8230600UIButton0x821f030UIButtonLabel0x8231b70UIButton(lldb)fvlabel0x821fe90UILabel0x8205a00UIButtonLabel0x8206ee0UIButtonLabel0x821e560UITextFieldLabel0x820da20UIButtonLabel0x82e88c0UILabel0x821f030UIButtonLabel0x821ce60UILabel0x1b99050UITabBarButtonLabel0x1bea750UITabBarButtonLabel0x1b4e310UITabBarButtonLabel0x1b4b510UITabBarButtonLabel[b]///////////////////////////////////////////////////////////////////////////////////////[/b](lldb)fvscrollView0x821fa80UIScrollView(lldb)fvcviewc0x1bb6be0EduHomePageViewController0x82ce240StudentCircleTabViewController0x82e8570AddTopicViewController0x1bba470ContactMainListViewController0x1b62140DynamicTabViewController0x1b96e80MineViewController[b]///////////////////////////////////////////////////////////////////////////////////////[/b]实时显示和隐藏一个指定的UIView(lldb)hidesender(lldb)showsender[b]///////////////////////////////////////////////////////////////////////////////////////[/b](lldb)bordersender(lldb)unbordersender(lldb)masksender(lldb)unmasksender(lldb)psender(UIButton*)$132=0x0824e1c0(lldb)bordersenderborder命令还可以指定添加的边框颜色Color和边框宽度Width:
border0x0824e1c0
-c
purple-w2
(lldb)border0x0824e1c0-cpurple-w2(lldb)unbordersender///////////////////////////////////////////////////////////////////////////////////////caflush相当于执行了
[CATransaction
flush]
方法,要注意如果在动画过程中执行这个命令,就直接渲染出动画结束的效果。当调试界面颜色、坐标之类的时候,可以直接在控制台修改属性,然后
caflush
就可以看到效果(lldb)posender<UIButton:0x8232d00;frame=(8820;6040);opaque=NO;autoresize=RM+BM;tag=1;layer=<CALayer:0x82319e0>>(lldb)psender(UIButton*)$277=0x08232d00(lldb)e(void)[$277setBackgroundColor:[UIColorgreenColor]](lldb)caflush[b]///////////////////////////////////////////////////////////////////////////////////////[/b]

bmessage

欲在
[BeyondCtrlviewWillAppear:]
里打断点,但若BeyondCtrl并没有实现
viewWillAppear:
方法时:
(lldb)bmessage
-[MyViewControllerviewWillAppear:]
他会在其父类的
viewWillAppear:
方法中打断点,并添加上了条件:
[self
isKindOfClass:[BeyondCtrlclass]]
[b]///////////////////////////////////////////////////////////////////////////////////////[/b][b]Printtheresponderchainstartingfromthegivenobject.[/b](lldb)prespondersender<UIButton:0x8232d00;frame=(8820;6040);opaque=NO;autoresize=RM+BM;tag=1;layer=<CALayer:0x82319e0>>|<UIScrollView:0x821fa80;frame=(-10-12;340358);clipsToBounds=YES;autoresize=RM+BM;gestureRecognizers=<NSArray:0x821d710>;layer=<CALayer:0x821fa50>;contentOffset:{0,0}>||<UIView:0x821d400;frame=(064;320416);autoresize=W+H;layer=<CALayer:0x821d3d0>>|||<AddTopicViewController:0x82e8570>||||<UIViewControllerWrapperView:0x82a29b0;frame=(00;320480);autoresize=W+H;layer=<CALayer:0x82a25b0>>|||||<UINavigationTransitionView:0x827a000;frame=(00;320480);clipsToBounds=YES;autoresize=W+H;layer=<CALayer:0x827a120>>||||||<UILayoutContainerView:0x1be8e70;frame=(00;320480);autoresize=W+H;gestureRecognizers=<NSArray:0x827dae0>;layer=<CALayer:0x82791e0>>|||||||<KLNavigationController:0x1bb3830>||||||||<UIViewControllerWrapperView:0x827dd00;frame=(00;320480);autoresize=W+H;layer=<CALayer:0x827ddf0>>|||||||||<UITransitionView:0x82783f0;frame=(00;320480);clipsToBounds=YES;autoresize=W+H;layer=<CALayer:0x8278780>>||||||||||<UILayoutContainerView:0x8278540;frame=(00;320480);autoresize=W+H;layer=<CALayer:0x8277ee0>>|||||||||||<KLTabBarController:0x1bb32b0>||||||||||||<UIWindow:0x1be8a70;frame=(00;320480);autoresize=W+H;gestureRecognizers=<NSArray:0x1b70350>;layer=<UIWindowLayer:0x1bb3bf0>>|||||||||||||<UIApplication:0x1b881e0>||||||||||||||<AppDelegate:0x1b89a10>[b][b]///////////////////////////////////////////////////////////////////////////////////////[/b][/b](lldb)pcells<__NSArrayI0x821bd60>(<TopicTableViewCell:0x82eb890;baseClass=UITableViewCell;frame=(00.00999832;320100);autoresize=W;layer=<CALayer:0x824e8e0>>,<TopicTableViewCell:0x82f7060;baseClass=UITableViewCell;frame=(0100.01;320100);autoresize=W;layer=<CALayer:0x826eca0>>,<TopicTableViewCell:0x82644f0;baseClass=UITableViewCell;frame=(0200.01;320100);autoresize=W;layer=<CALayer:0x8264900>>,<TopicTableViewCell:0x82413d0;baseClass=UITableViewCell;frame=(0300.01;320100);autoresize=W;layer=<CALayer:0x8241570>>)

然后重启Xcode

GDBandLLDBCommandExamples

ThetablesinthischapterlistcommonlyusedGDBcommandsandpresentequivalentLLDBcommandsandalternativeforms.Alsolistedarethebuilt-inGDBcompatibilityaliasesinLLDB.NoticethatfullLLDBcommandnamescanbematchedbyuniqueshortforms,whichcanbeusedinstead.Forexample,insteadof
breakpointset
,
br
se
canbeused.

ExecutionCommands

GDBLLDB
Launchaprocesswithnoarguments.
(gdb)run
(gdb)r
(lldb)
processlaunch
(lldb)
run
(lldb)
r
Launchaprocesswitharguments
<args>
.
(gdb)run<args>
(gdb)r<args>
(lldb)processlaunch--<args>
(lldb)r<args>
Launchprocess
a.out
witharguments123withouthavingtosupplytheargseverytime.
%gdb--argsa.out123
(gdb)run
...
(gdb)run
...
(%lldb--a.out123
(lldb)run
...
(lldb)run
...
Launchaprocesswithargumentsinanewterminalwindow(OSXonly).
(lldb)processlaunch--tty--<args>
(lldb)prola-t--<args>
LaunchaprocesswithargumentsinanexistingTerminalwindow,
/dev/ttys006
(OSXonly).
(lldb)processlaunch--tty=/dev/ttys006--<args>
(lldb)prola-t/dev/ttys006--<args>
Setenvironmentvariablesforprocessbeforelaunching.
(gdb)setenvDEBUG1
(lldb)settingssettarget.env-varsDEBUG=1
(lldb)setsetarget.env-varsDEBUG=1
Setenvironmentvariablesforprocessandlaunchprocessinonecommand.
(lldb)processlaunch-vDEBUG=1
AttachtotheprocesswithprocessID123.
(gdb)attach123
(lldb)
processattach--pid
123
(lldb)attach-p123
Attachtoaprocessnamed
a.out
.
(gdb)attacha.out
(lldb)processattach--namea.out
(lldb)proat-na.out
Waitforaprocessnamed
a.out
tolaunchandattach.
(gdb)attach-waitfora.out
(lldb)processattach--namea.out--waitfor
(lldb)proat-na.out-w
AttachtoaremoteGDBprotocolserverrunningonthesystem
eorgadd
,port8000.
(gdb)targetremoteeorgadd:8000
(lldb)gdb-remoteeorgadd:8000
AttachtoaremoteGDBprotocolserverrunningonthelocalsystem,port8000.
(gdb)targetremotelocalhost:8000
(lldb)gdb-remote8000
AttachtoaDarwinkernelinkdpmodeonthesystem
eorgadd
.
(gdb)kdp-reattacheorgadd
(lldb)kdp-remoteeorgadd
Doasource-levelsinglestepinthecurrentlyselectedthread.【代码级】
(gdb)step
(gdb)s
(lldb)threadstep-in
(lldb)
step
(lldb)s
Doasource-levelsinglestepoverinthecurrentlyselectedthread.【代码级】
(gdb)next
(gdb)n
(lldb)threadstep-over
(lldb)
next
(lldb)
n
Doaninstruction-levelsinglestepinthecurrentlyselectedthread.【汇编级】
(gdb)stepi
(gdb)si
(lldb)threadstep-inst
(lldb)
si
Doaninstruction-levelsinglestepoverinthecurrentlyselectedthread.【汇编级】
(gdb)nexti
(gdb)ni
(lldb)threadstep-inst-over
(lldb)ni
Stepoutofthecurrentlyselectedframe.【重要】
(gdb)finish
(lldb)threadstep-out
(lldb)
finish
Backtraceanddisassembleeverytimeyoustop.【牛逼】
(lldb)
targetstop-hookadd
Enteryourstophookcommand(s).Type'
DONE
'
toend.
>bt
>register
read
>disassemble--pc
>
DONE
Stophook#1added.

BreakpointCommands

GDBLLDB
Setabreakpointatallfunctionsnamed
main
.
(gdb)breakmain
(lldb)breakpointset--namemain
(lldb)brs-nmain
(lldb)bmain
Setabreakpointinfile
test.c
atline12.
(gdb)breaktest.c:12
(lldb)breakpointset--filetest.c--line12
(lldb)brs-ftest.c-l12
(lldb)btest.c:12
SetabreakpointatallC++methodswhosebasenameis
main
.
(gdb)breakmain
(Note:ThiswillbreakonanyCfunctionsnamed
main
.)
(lldb)breakpointset--methodmain
(lldb)brs-Mmain
SetabreakpointatanObjective-Cfunction:
-[NSStringstringWithFormat:]
.【十分重要】适合于不能断下来的方法
(gdb)break-[NSStringstringWithFormat:]
(lldb)breakpointset--name"-[NSStringstringWithFormat:]"
(lldb)
b
-[NSStringstringWithFormat:]
【提示attempttoinsertnil,但是断不下来】
使用LLDB命令,在提示的方法上面,下内存断点
(LLDB)b-[__NSPlaceholderDictionaryinitWithObjects:forKeys:count:];
即可断下来,原来是:请求的dict中lastGetTime是从缓存中取的,第一次是nil
第2个解决的问题:NSLog打印一个长度为0的数组报错:NSRangeException>-[__NSCFStringdeleteCharactersInRange:]:
Rangeorindexoutofbounds解决办法:由于没有stepinto的概念,所以一直没有找到问题最后,打了一个内存断点,才找到问题所在,
b-[__NSCFStringdeleteCharactersInRange:]原来是,用了一个NSArray的分类,美化打印效果,结果在打印的时候,没有对空数组作验证导致崩溃
SetabreakpointatallObjective-Cmethodswhoseselectoris
count
.
(gdb)breakcount
(Note:ThiswillbreakonanyCorC++functionsnamed
count
.)
(lldb)breakpointset--selectorcount
(lldb)brs-Scount
Setabreakpointbyaregularexpressiononafunctionname.
(gdb)rbreakregular-expression
(lldb)breakpointset--regexregular-expression
(lldb)brs-rregular-expression
Setabreakpointbyaregularexpressiononasourcefile’scontents.
(gdb)shellgrep-e-npatternsource-file
(gdb)breaksource-file:CopyLineNumbers
(lldb)breakpointset--source-patternregular-expression--fileSourceFile
(lldb)brs-pregular-expression-ffile
Listallbreakpoints.
(gdb)infobreak
(lldb)breakpointlist
(lldb)brl
Deleteabreakpoint.
(gdb)delete1
(lldb)breakpointdelete1
(lldb)brdel1

WatchpointCommands

GDBLLDB
Setawatchpointonavariablewhenitiswrittento.
(gdb)watchglobal_var
(lldb)watchpointsetvariableglobal_var
(lldb)wasvglobal_var
Setawatchpointonamemorylocationwhenitiswrittento.
(gdb)watch-locationg_char_ptr
(lldb)watchpointsetexpression--my_ptr
(lldb)wase--my_ptr
Note:Thesizeoftheregiontowatchfordefaultstothepointersizeifno
-xbyte_size
isspecified.Thiscommandtakes“raw”input,evaluatedasanexpressionreturninganunsignedintegerpointingtothestartoftheregion,aftertheoptionterminator(
--
).
Setaconditiononawatchpoint.
(lldb)watchsetvarglobal
(lldb)watchpointmodify-c'(global==5)'
(lldb)c
...
(lldb)bt
*thread#1:tid=0x1c03,0x0000000100000ef5a.out`modify+21atmain.cpp:16,stopreason=watchpoint1
frame#0:0x0000000100000ef5a.out`modify+21atmain.cpp:16
frame#1:0x0000000100000eaca.out`main+108atmain.cpp:25
frame#2:0x00007fff8ac9c7e1libdyld.dylib`start+1
(int32_t)global=5
Listallwatchpoints.
(gdb)infobreak
(lldb)watchpointlist
(lldb)watchl
Deleteawatchpoint.
(gdb)delete1
(lldb)watchpointdelete1
(lldb)watchdel1

ExaminingVariables

GDBLLDB
Showtheargumentsandlocalvariablesforthecurrentframe.
(gdb)infoargs
and
(gdb)infolocals
(lldb)framevariable
(lldb)frv
Showthelocalvariablesforthecurrentframe.
(gdb)infolocals
(lldb)framevariable--no-args
(lldb)frv-a
Showthecontentsofthelocalvariable
bar
.
(gdb)pbar
(lldb)framevariablebar
(lldb)frvbar
(lldb)pbar
Showthecontentsofthelocalvariable
bar
formattedashex.
(gdb)p/xbar
(lldb)framevariable--formatxbar
(lldb)frv-fxbar
Showthecontentsoftheglobalvariable
baz
.
(gdb)pbaz
(lldb)targetvariablebaz
(lldb)tavbaz
Showtheglobal/staticvariablesdefinedinthecurrentsourcefile.
(lldb)targetvariable
(lldb)tav
Displaythevariables
argc
and
argv
everytimeyoustop.
(gdb)displayargc
(gdb)displayargv
(lldb)targetstop-hookadd--one-liner"framevariableargcargv"
(lldb)tasta-o"frvargcargv"
(lldb)displayargc
(lldb)displayargv
Displaythevariables
argc
and
argv
onlywhenyoustopinthefunctionnamed
main
.
(lldb)targetstop-hookadd--namemain--one-liner"framevariableargcargv"
(lldb)tasta-nmain-o"frvargcargv"
Displaythevariable
*this
onlywhenyoustopintheCclassnamed
MyClass
.
(lldb)targetstop-hookadd--classnameMyClass--one-liner"framevariable*this"
(lldb)tasta-cMyClass-o"frv*this"

EvaluatingExpressions

GDBLLDB
Evaluateageneralizedexpressioninthecurrentframe.
(gdb)print(int)printf("Printnine:%d.",4+5)
Orifyoudon’twanttoseevoidreturns:
(gdb)call(int)printf("Printnine:%d.",4+5)
(lldb)expr(int)printf("Printnine:%d.",4+5)
Orusethe
print
alias:
(lldb)print(int)printf("Printnine:%d.",4+5)
Createandassignavaluetoaconveniencevariable.
(gdb)set$foo=5
(gdb)setvariable$foo=5
Orusethe
print
command:
(gdb)print$foo=5
Orusethe
call
command:
(gdb)call$foo=5
Tospecifythetypeofthevariable:
(gdb)set$foo=(unsignedint)5
LLDBevaluatesavariabledeclarationexpressionasyouwouldwriteitinC:
(lldb)exprunsignedint$foo=5
PrinttheObjective-C
description
ofanobject.
(gdb)po[SomeClassreturnAnObject]
(lldb)expr-O--[SomeClassreturnAnObject]
Orusethe
po
alias:
(lldb)po[SomeClassreturnAnObject]
Printthedynamictypeoftheresultofanexpression.
(gdb)setprintobject1
(gdb)psomeCPPObjectPtrOrReference
Note:OnlyforC++objects.
(lldb)expr-drun-target--[SomeClassreturnAnObject]
(lldb)expr-drun-target--someCPPObjectPtrOrReference
Orsetdynamictypeprintingasdefault:
(lldb)settingssettarget.prefer-dynamicrun-target
Callafunctiontostopatabreakpointinthefunction.
(gdb)setunwindonsignal0
(gdb)pfunction_with_a_breakpoint()
(lldb)expr-u0--function_with_a_breakpoint()

ExaminingThreadState

GDBLLDB
Showthestackbacktraceforthecurrentthread.
(gdb)bt
(lldb)
threadbacktrace
(lldb)
bt
Showthestackbacktracesforallthreads.
(gdb)threadapplyallbt
(lldb)threadbacktraceall
(lldb)
btall
Backtracethefirstfiveframesofthecurrentthread.
(gdb)bt5
(lldb)
threadbacktrace-c5
(lldb)
bt5
(lldb-169andlater)
(lldb)
bt-c5
(lldb-168andearlier)
Selectadifferentstackframebyindexforthecurrentthread.【重要】
(gdb)frame12
(lldb)
frameselect
12
(lldb)
frs
12
(lldb)
f
12
Listinformationaboutthecurrentlyselectedframeinthecurrentthread.
(lldb)
frameinfo
Selectthestackframethatcalledthecurrentstackframe.【重要】
(gdb)up
(lldb)
up
(lldb)frameselect--relative=1
Selectthestackframethatiscalledbythecurrentstackframe.【重要】
(gdb)down
(lldb)
down
(lldb)frameselect--relative=-1
(lldb)frs-r-1
Selectadifferentstackframeusingarelativeoffset.
(gdb)up2
(gdb)down3
(lldb)frameselect--relative2
(lldb)
frs-r2
(lldb)frameselect--relative-3
(lldb)
frs-r
-3
Showthegeneral-purposeregistersforthecurrentthread.
(gdb)inforegisters
(lldb)
registerread
Writeanewdecimalvalue
123
tothecurrentthreadregister
rax
.
(gdb)p$rax=123
(lldb)
registerwrite
rax123
Skip8bytesaheadofthecurrentprogramcounter(instructionpointer).
(gdb)jump*$pc+8
(lldb)registerwritepc`$pc+8`
TheLLDBcommandusesbacktickstoevaluateanexpressionandinsertthescalarresult.
Showthegeneral-purposeregistersforthecurrentthreadformattedassigneddecimal.
(lldb)
registerread--formati
(lldb)
rer-fi
LLDBnowsupportstheGDBshorthandformatsyntax,butnospaceispermittedafterthecommand:
(lldb)
registerread/d
Note:LLDBtriestousethesameformatcharactersas
printf(3)
whenpossible.Type
helpformat
toseethefulllistofformatspecifiers.
Showallregistersinallregistersetsforthecurrentthread.
(gdb)infoall-registers
(lldb)
registerread--all
(lldb)
rer-a
Showthevaluesfortheregistersnamed
rax
,
rsp
and
rbp
inthecurrentthread.
(gdb)infoall-registersraxrsprbp
(lldb)
registerread
raxrsprbp
Showthevaluesfortheregisternamed
rax
inthecurrentthreadformattedasbinary.
(gdb)p/t$rax
(lldb)
registerread--formatbinary
rax
(lldb)
rer-fb
rax
LLDBnowsupportstheGDBshorthandformatsyntax,butnospaceispermittedafterthecommand:
(lldb)
registerread/t
rax
(lldb)
p/t
$rax
Readmemoryfromaddress
0xbffff3c0
andshowfourhex
uint32_t
values.
(gdb)x/4xw0xbffff3c0
(lldb)
memoryread--size4--formatx--count4
0xbffff3c0
(lldb)mer-s4-fx-c40xbffff3c0
(lldb)x-s4-fx-c40xbffff3c0
LLDBnowsupportstheGDBshorthandformatsyntax,butnospaceispermittedafterthecommand:
(lldb)
memoryread/4xw
0xbffff3c0
(lldb)x/4xw0xbffff3c0
(lldb)memoryread--gdb-format4xw0xbffff3c0
Readmemorystartingattheexpression
argv[0]
.
(gdb)xargv[0]
(lldb)memoryread`argv[0]`
Notethatanycommandcaninlineascalarexpressionresult(aslongasthetargetisstopped)usingbackticksaroundanyexpression:
(lldb)memoryread--size`sizeof(int)``argv[0]`
Read512bytesofmemoryfromaddress
0xbffff3c0
andsaveresultstoalocalfileastext.
(gdb)setloggingon
(gdb)setloggingfile/tmp/mem.txt
(gdb)x/512bx0xbffff3c0
(gdb)setloggingoff
(lldb)memoryread--outfile/tmp/mem.txt--count5120xbffff3c0
(lldb)mer-o/tmp/mem.txt-c5120xbffff3c0
(lldb)x/512bx-o/tmp/mem.txt0xbffff3c0
Savebinarymemorydatatoafilestartingat
0x1000
andendingat
0x2000
.
(gdb)dumpmemory/tmp/mem.bin0x10000x2000
(lldb)memoryread--outfile/tmp/mem.bin--binary0x10000x1200
(lldb)mer-o/tmp/mem.bin-b0x10000x1200
Disassemblethecurrentfunctionforthecurrentframe.
(gdb)disassemble
(lldb)
disassemble--frame
(lldb)di-f
Disassembleanyfunctionsnamed
main
.
(gdb)disassemblemain
(lldb)
disassemble--name
main
(例如)
disassemble--name
checkBtnAction:
(lldb)
di-n
main
Disassembleanaddressrange.
(gdb)disassemble0x1eb80x1ec3
(lldb)
disassemble--start-address
0x1eb8
--end-address
0x1ec3
(lldb)
di-s
0x1eb8
-e
0x1ec3
Disassemble20instructionsfromagivenaddress.
(gdb)x/20i0x1eb8
(lldb)
disassemble--start-address
0x1eb8
--count
20
(lldb)
di-s
0x1eb8
-c
20
Showmixedsourceanddisassemblyforthecurrentfunctionforthecurrentframe.
(lldb)
disassemble--frame--mixed
(lldb)di-f-m
Disassemblethecurrentfunctionforthecurrentframeandshowtheopcodebytes.
(lldb)
disassemble--frame--bytes
(lldb)di-f-b
Disassemblethecurrentsourcelineforthecurrentframe.
(lldb)disassemble--line
(lldb)di-l

ExecutableandSharedLibraryQueryCommands

GDBLLDB
Listthemainexecutableandalldependentsharedlibraries.
(gdb)infoshared
(lldb)
imagelist
Lookupinformationforarawaddressintheexecutableoranysharedlibraries.
(gdb)infosymbol0x1ec4
(lldb)
imagelookup--address
0x1ec4
(lldb)
imloo-a
0x1ec4
Lookupfunctionsmatchingaregularexpressioninabinary.
(gdb)infofunction<FUNC_REGEX>
Thisonefindsdebugsymbols:(区分大小写)
(lldb)
imagelookup-r-n
<FUNC_REGEX>
例如:
imagelookup-r-n
snapshotView
Thisonefindsnon-debugsymbols:
(lldb)
imagelookup-r-s
<FUNC_REGEX>
Providealistofbinariesasargumentstolimitthesearch.
Lookupinformationforanaddressin
a.out
only.
(lldb)
imagelookup--address
0x1ec4a.out
(lldb)
imloo-a
0x1ec4a.out
Lookupinformationforatype
Point
byname.
(gdb)ptypePoint
(lldb)
imagelookup--type
Point
例如
imagelookup--type
Rect
(lldb)imloo-tPoint
Dumpallsectionsfromthemainexecutableandanysharedlibraries.
(gdb)maintenanceinfosections
(lldb)imagedumpsections
Dumpallsectionsinthe
a.out
module.
(lldb)imagedumpsectionsa.out
Dumpallsymbolsfromthemainexecutableandanysharedlibraries.
(lldb)
imagedumpsymtab
Dumpallsymbolsin
a.out
and
liba.so
.
(lldb)imagedumpsymtaba.outliba.so

Miscellaneous

GDBLLDB
Echotexttothescreen.
(gdb)echoHereissometext\n
(lldb)
scriptprint
"Hereissometext"
Remapsourcefilepathnamesforthedebugsession.
(gdb)setpathname-substitutions/buildbot/path/my/path
(lldb)settingssettarget.source-map/buildbot/path/my/path
Note:Ifyoursourcefilesarenolongerlocatedinthesamelocationaswhentheprogramwasbuilt—maybetheprogramwasbuiltonadifferentcomputer—youneedtotellthedebuggerhowtofindthesourcesatthelocalfilepathinsteadofthebuildsystemfilepath.
Supplyacatchalldirectorytosearchforsourcefilesin.
(gdb)directory/my/path
(Noequivalentcommandyet.)
例如:(lldb)imagelookup-r-nsnapshotView11matchesfoundin/Users/pzh/Library/Developer/Xcode/iOSDeviceSupport/7.1.2(11D257)/Symbols/System/Library/Frameworks/UIKit.framework/UIKit:Address:UIKit[0x2fcf8410](UIKit.__TEXT.__text+522912)Summary:UIKit`-[UIViewsnapshotView]Address:UIKit[0x2fd4447c](UIKit.__TEXT.__text+834316)Summary:UIKit`-[UIInputViewTransitionsnapshotView]Address:UIKit[0x2fd44524](UIKit.__TEXT.__text+834484)Summary:UIKit`-[UIInputViewTransitionsnapshotViewBeginFrame]Address:UIKit[0x2fd458b8](UIKit.__TEXT.__text+839496)Summary:UIKit`-[UIInputViewTransitionsnapshotViewEndFrame]Address:UIKit[0x2ff17c70](UIKit.__TEXT.__text+2749184)Summary:UIKit`-[UIViewsnapshotViewAfterScreenUpdates:]Address:UIKit[0x2ff51e54](UIKit.__TEXT.__text+2987236)Summary:UIKit`-[UINavigationController_snapshotView]Address:UIKit[0x2ffcde2c](UIKit.__TEXT.__text+3495100)Summary:UIKit`-[UIScreen(UISnapshotting)snapshotViewAfterScreenUpdates:]Address:UIKit[0x2ffcdf80](UIKit.__TEXT.__text+3495440)Summary:UIKit`__59-[UIScreen(UISnapshotting)snapshotViewAfterScreenUpdates:]_block_invokeAddress:UIKit[0x2ffce038](UIKit.__TEXT.__text+3495624)Summary:UIKit`__59-[UIScreen(UISnapshotting)snapshotViewAfterScreenUpdates:]_block_invoke_2Address:UIKit[0x2ffce6d0](UIKit.__TEXT.__text+3497312)Summary:UIKit`-[UIScreen(UISnapshotting)snapshotView]Address:UIKit[0x300fc480](UIKit.__TEXT.__text+4733712)Summary:UIKit`-[UISnapshotView_snapshotView]2matchesfoundin/Users/pzh/Library/Developer/Xcode/iOSDeviceSupport/7.1.2(11D257)/Symbols/System/Library/Frameworks/QuickLook.framework/QuickLook:Address:QuickLook[0x2fa6d698](QuickLook.__TEXT.__text+205824)Summary:QuickLook`-[QLPreviewViewControllersnapshotView]Address:QuickLook[0x2fa6f86c](QuickLook.__TEXT.__text+214484)Summary:QuickLook`-[QLPreviewContentControllersnapshotView]1matchfoundin/Users/pzh/Library/Developer/Xcode/iOSDeviceSupport/7.1.2(11D257)/Symbols/System/Library/PrivateFrameworks/iTunesStoreUI.framework/iTunesStoreUI:Address:iTunesStoreUI[0x364fb6d8](iTunesStoreUI.__TEXT.__text+728568)Summary:iTunesStoreUI`-[SUSnapshotViewsnapshotView:usingIOSurface:](lldb)imagelookup--typeRectBestmatchfoundin/Users/pzh/Library/Developer/Xcode/DerivedData/JZH-bzgkjnlsuwbivkexxhazkliasuuu/Build/Products/Debug-iphoneos/JZH.app/JZH:id={0x00ce1117},name="Rect",byte-size=8,decl=MacTypes.h:546,clang_type="typedefRect"typedef'Rect':id={0x00ce1123},name="Rect",byte-size=8,decl=MacTypes.h:540,clang_type="structRect{shorttop;shortleft;shortbottom;shortright;}"(lldb)threadbacktrace*thread#1:tid=0x1e3f,0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:](self=0x07c91880,_cmd=0x00bf7d95,sender=0x07ca0060)+50atAddTopicViewController.m:371,queue='com.apple.main-thread',stopreason=breakpoint3.1*frame#0:0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:](self=0x07c91880,_cmd=0x00bf7d95,sender=0x07ca0060)+50atAddTopicViewController.m:371frame#1:0x309a5036UIKit`-[UIApplicationsendAction:to:from:forEvent:]+90frame#2:0x309a4fd6UIKit`-[UIApplicationsendAction:toTarget:fromSender:forEvent:]+30frame#3:0x309a4fb0UIKit`-[UIControlsendAction:to:forEvent:]+44frame#4:0x30990716UIKit`-[UIControl_sendActionsForEvents:withEvent:]+374frame#5:0x309a4a2eUIKit`-[UIControltouchesEnded:withEvent:]+590frame#6:0x30967f12UIKit`_UIGestureRecognizerUpdate+5522frame#7:0x3099fd48UIKit`-[UIWindow_sendGesturesForEvent:]+772frame#8:0x3099f66eUIKit`-[UIWindowsendEvent:]+666frame#9:0x309748ccUIKit`-[UIApplicationsendEvent:]+196frame#10:0x30972f76UIKit`_UIApplicationHandleEventQueue+7102frame#11:0x2e11e20aCoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+14frame#12:0x2e11d6daCoreFoundation`__CFRunLoopDoSources0+206frame#13:0x2e11beceCoreFoundation`__CFRunLoopRun+622frame#14:0x2e086ebeCoreFoundation`CFRunLoopRunSpecific+522frame#15:0x2e086ca2CoreFoundation`CFRunLoopRunInMode+106frame#16:0x32f8c662GraphicsServices`GSEventRunModal+138frame#17:0x309d314cUIKit`UIApplicationMain+1136frame#18:0x00063490JZH`main(argc=1,argv=0x27dffc88)+108atmain.m:15(lldb)threadbacktrace-c5*thread#1:tid=0x1e3f,0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:](self=0x07c91880,_cmd=0x00bf7d95,sender=0x07ca0060)+50atAddTopicViewController.m:371,queue='com.apple.main-thread',stopreason=breakpoint3.1*frame#0:0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:](self=0x07c91880,_cmd=0x00bf7d95,sender=0x07ca0060)+50atAddTopicViewController.m:371frame#1:0x309a5036UIKit`-[UIApplicationsendAction:to:from:forEvent:]+90frame#2:0x309a4fd6UIKit`-[UIApplicationsendAction:toTarget:fromSender:forEvent:]+30frame#3:0x309a4fb0UIKit`-[UIControlsendAction:to:forEvent:]+44frame#4:0x30990716UIKit`-[UIControl_sendActionsForEvents:withEvent:]+374(lldb)f0frame#0:0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:](self=0x07c91880,_cmd=0x00bf7d95,sender=0x07ca0060)+50atAddTopicViewController.m:371368369-(IBAction)checkBtnAction:(id)sender{370->371if(sender==self.privateBtn){372self.checkIndex=1;373UIImage*image=[UIImageimageNamed:@"radio_buttons_p"];374[self.privateBtnsetImage:imageforState:UIControlStateNormal];(lldb)f1frame#1:0x309a5036UIKit`-[UIApplicationsendAction:to:from:forEvent:]+90UIKit`-[UIApplicationsendAction:to:from:forEvent:]:0x309a5036<+90>:cmpr4,#0x00x309a5038<+92>:itne0x309a503a<+94>:movner4,#0x10x309a503c<+96>:movr0,r4(lldb)f3frame#3:0x309a4fb0UIKit`-[UIControlsendAction:to:forEvent:]+44UIKit`-[UIControlsendAction:to:forEvent:]:0x309a4fb0<+44>:addsp,#0x80x309a4fb2<+46>:pop{r4,r5,r7,pc}0x309a4fb4<+48>:movr8,r80x309a4fb6<+50>:movr8,r8(lldb)f0frame#0:0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:](self=0x07c91880,_cmd=0x00bf7d95,sender=0x07ca0060)+50atAddTopicViewController.m:371368369-(IBAction)checkBtnAction:(id)sender{370->371if(sender==self.privateBtn){372self.checkIndex=1;373UIImage*image=[UIImageimageNamed:@"radio_buttons_p"];374[self.privateBtnsetImage:imageforState:UIControlStateNormal];(lldb)frameinfoframe#0:0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:](self=0x07c91880,_cmd=0x00bf7d95,sender=0x07ca0060)+50atAddTopicViewController.m:371(lldb)f1frame#1:0x309a5036UIKit`-[UIApplicationsendAction:to:from:forEvent:]+90UIKit`-[UIApplicationsendAction:to:from:forEvent:]:0x309a5036<+90>:cmpr4,#0x00x309a5038<+92>:itne0x309a503a<+94>:movner4,#0x10x309a503c<+96>:movr0,r4(lldb)frameinfoframe#1:0x309a5036UIKit`-[UIApplicationsendAction:to:from:forEvent:]+90(lldb)registerreadGeneralPurposeRegisters:r0=0x3890d621libobjc.A.dylib`objc_msgSend+1r1=0x00d98210"privateBtn"r2=0x0000002ar3=0x00000000r4=0x07c91880r5=0x00bf7d95"checkBtnAction:"r6=0x07ca0060r7=0x27dfdf88r8=0x01b9db00r9=0x00000002r10=0x07cb7330r11=0x00000000r12=0x07ca0094sp=0x27dfdef4lr=0x0011c075JZH`-[AddTopicViewControllercheckBtnAction:]+29atAddTopicViewController.m:369pc=0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:]+50atAddTopicViewController.m:371cpsr=0x60000030(lldb)registerwriter69(lldb)registerreadGeneralPurposeRegisters:r0=0x3890d621libobjc.A.dylib`objc_msgSend+1r1=0x00d98210"privateBtn"r2=0x0000002ar3=0x00000000r4=0x07c91880r5=0x00bf7d95"checkBtnAction:"r6=0x00000009r7=0x27dfdf88r8=0x01b9db00r9=0x00000002r10=0x07cb7330r11=0x00000000r12=0x07ca0094sp=0x27dfdef4lr=0x0011c075JZH`-[AddTopicViewControllercheckBtnAction:]+29atAddTopicViewController.m:369pc=0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:]+50atAddTopicViewController.m:371cpsr=0x60000030(lldb)registerread--formatiGeneralPurposeRegisters:r0=invalidtargetlibobjc.A.dylib`objc_msgSend+1r1=invalidtarget"privateBtn"r2=invalidtargetr3=invalidtargetr4=invalidtargetr5=invalidtarget"checkBtnAction:"r6=invalidtargetr7=invalidtargetr8=invalidtargetr9=invalidtargetr10=invalidtargetr11=invalidtargetr12=invalidtargetsp=invalidtargetlr=invalidtargetJZH`-[AddTopicViewControllercheckBtnAction:]+29atAddTopicViewController.m:369pc=invalidtargetJZH`-[AddTopicViewControllercheckBtnAction:]+50atAddTopicViewController.m:371cpsr=invalidtarget[b](lldb)registerread/d[/b]GeneralPurposeRegisters:r0=949016097libobjc.A.dylib`objc_msgSend+1r1=14254608"privateBtn"r2=42r3=0r4=130619520r5=12549525"checkBtnAction:"r6=130581728r7=668983176r8=130195872r9=2r10=130367088r11=0r12=130581780sp=668983028lr=1163381JZH`-[AddTopicViewControllercheckBtnAction:]+29atAddTopicViewController.m:369pc=1163402JZH`-[AddTopicViewControllercheckBtnAction:]+50atAddTopicViewController.m:371cpsr=1610612784(lldb)registerread--allGeneralPurposeRegisters:r0=0x3890d621libobjc.A.dylib`objc_msgSend+1r1=0x00d98210"privateBtn"r2=0x0000002ar3=0x00000000r4=0x07c91880r5=0x00bf7d95"checkBtnAction:"r6=0x07c884e0r7=0x27dfdf88r8=0x07c2a1a0r9=0x00000002r10=0x07c53e70r11=0x00000000r12=0x07c88514sp=0x27dfdef4lr=0x0011c075JZH`-[AddTopicViewControllercheckBtnAction:]+29atAddTopicViewController.m:369pc=0x0011c08aJZH`-[AddTopicViewControllercheckBtnAction:]+50atAddTopicViewController.m:371cpsr=0x60000030FloatingPointRegisters:s0=0s1=0s2=0s3=0s4=0s5=0s6=0s7=0s8=0s9=0s10=0s11=0s12=0s13=0s14=0s15=0s16=0s17=0s18=0s19=0s20=0s21=0s22=0s23=0s24=0s25=0s26=0s27=0s28=0s29=0s30=0s31=0d0=0d1=0d2=0d3=0d4=0d5=0d6=1d7=1d8=0d9=0d10=0d11=0d12=0d13=0d14=0d15=0d16=18.3d17=18.3d18=2176.00148808956d19=2176.00148808956d20=0d21=0d22=0d23=0d24=-72d25=-72d26=-0d27=-0d28=0d29=0d30=1d31=1q0={0x000x000x000x000x000x000x000x000x000x000x000x000x000x000x000x00}q1={0x000x000x000x000x000x000x000x000x000x000x000x000x000x000x000x00}q2={0x000x000x000x000x000x000x000x000x000x000x8c0xc20x000x000x000x00}q3={0x000x000x000x000x000x000xf00x3f0x000x000x8c0xc20x000x000xf00x3f}q4={0x000x000x000x000x000x000x000x000x000x000x000x000x000x000x000x00}q5={0x000x000x000x000x000x000x000x000x000x000x000x000x000x000x000x00}q6={0x000x000x000x000x000x000x000x000x000x000x000x340x000x000x000x34}q7={0x000x000x000x000x000x000x000x000x000x000x000x000x000x000x000x00}q8={0xcd0xcc0xcc0xcc0xcc0x4c0x320x400x000x000x8c0xc20x000x000x8c0xc2}q9={0x000x000x0c0xc30x000x000xa10x400x000x000x000x000x000x000xf00x3f}q10={0x000x000x000x000x000x000x000x000x000x000x000x000x000x000x000x00}q11={0x000x000x000x000x000x000x000x000x000x000x000x000x000x000xf00x3f}q12={0x000x000x000x000x000x000x520xc00x000x000x000x000x000x000xf00x3f}q13={0x000x000x000x000x000x000x000x800x000x000x000x000x000x000x000x00}q14={0x000x000x000x000x000x000x000x000x000x000x000x000x000x000x000x00}q15={0x000x000x000x000x000x000xf00x3f0x000x000x000x000x000x000x000x00}fpscr=0x8b000095exception=0x00000000fsr=0x00000000far=0x00000000(lldb)registerreadr5r5=0x00bf7d95"checkBtnAction:"(lldb)registerread--formatbinaryr5r5=0b00000000101111110111110110010101"checkBtnAction:"(lldb)registerread/tr5r5=0b00000000101111110111110110010101"checkBtnAction:"(lldb)disassemble--namecheckBtnAction:JZH`-[AddTopicViewControllercheckBtnAction:]:0x11c058<+0>:push{r7,lr}0x11c05a<+2>:movr7,sp0x11c05c<+4>:subsp,#0x940x11c05e<+6>:addr3,sp,#0x880x11c060<+8>:movwr9,#0x00x11c064<+12>:strr0,[sp,#0x90]0x11c066<+14>:strr1,[sp,#0x8c]0x11c068<+16>:str.wr9,[sp,#0x88]0x11c06c<+20>:movr0,r30x11c06e<+22>:movr1,r20x11c070<+24>:blx0xb29fc8;symbolstubfor:objc_storeStrong(lldb)disassemble--start-address0x11c058--count20JZH`-[AddTopicViewControllercheckBtnAction:]:0x11c058<+0>:push{r7,lr}0x11c05a<+2>:movr7,sp0x11c05c<+4>:subsp,#0x940x11c05e<+6>:addr3,sp,#0x880x11c060<+8>:movwr9,#0x00x11c064<+12>:strr0,[sp,#0x90]0x11c066<+14>:strr1,[sp,#0x8c]0x11c068<+16>:str.wr9,[sp,#0x88]0x11c06c<+20>:movr0,r30x11c06e<+22>:movr1,r20x11c070<+24>:blx0xb29fc8;symbolstubfor:objc_storeStrong0x11c074<+28>:movwr0,#0x3f880x11c078<+32>:movtr0,#0xbb0x11c07c<+36>:addr0,pc0x11c07e<+38>:ldrr0,[r0]0x11c080<+40>:movwr1,#0xc1840x11c084<+44>:movtr1,#0xc70x11c088<+48>:addr1,pc->0x11c08a<+50>:ldrr2,[sp,#0x88]0x11c08c<+52>:ldrr3,[sp,#0x90](lldb)disassemble--frame--mixedJZH`-[AddTopicViewControllercheckBtnAction:]atAddTopicViewController.m:369368369-(IBAction)checkBtnAction:(id)sender{370JZH`-[AddTopicViewControllercheckBtnAction:]:0x11c058<+0>:push{r7,lr}0x11c05a<+2>:movr7,sp0x11c05c<+4>:subsp,#0x940x11c05e<+6>:addr3,sp,#0x880x11c060<+8>:movwr9,#0x00x11c064<+12>:strr0,[sp,#0x90]0x11c066<+14>:strr1,[sp,#0x8c]0x11c068<+16>:str.wr9,[sp,#0x88]0x11c06c<+20>:movr0,r30x11c06e<+22>:movr1,r20x11c070<+24>:blx0xb29fc8;symbolstubfor:objc_storeStrong0x11c074<+28>:movwr0,#0x3f880x11c078<+32>:movtr0,#0xbb0x11c07c<+36>:addr0,pc0x11c07e<+38>:ldrr0,[r0]0x11c080<+40>:movwr1,#0xc1840x11c084<+44>:movtr1,#0xc70x11c088<+48>:addr1,pcJZH`-[AddTopicViewControllercheckBtnAction:]+50atAddTopicViewController.m:371370->371if(sender==self.privateBtn){372self.checkIndex=1;->0x11c08a<+50>:ldrr2,[sp,#0x88]0x11c08c<+52>:ldrr3,[sp,#0x90]0x11c08e<+54>:ldrr1,[r1]0x11c090<+56>:strr0,[sp,#0x74]0x11c092<+58>:movr0,r30x11c094<+60>:ldrr3,[sp,#0x74]0x11c096<+62>:strr2,[sp,#0x70]0x11c098<+64>:blxr30x11c09a<+66>:movr7,r70x11c09c<+68>:blx0xb29f58;symbolstubfor:objc_retainAutoreleasedReturnValue0x11c0a0<+72>:movr1,r00x11c0a2<+74>:strr1,[sp,#0x6c]0x11c0a4<+76>:blx0xb29f18;symbolstubfor:objc_release0x11c0a8<+80>:ldrr0,[sp,#0x70]0x11c0aa<+82>:ldrr1,[sp,#0x6c]0x11c0ac<+84>:cmpr0,r10x11c0ae<+86>:bne.w0x11c22c;<+468>atAddTopicViewController.m:3790x11c0b2<+90>:movsr2,#0x10x11c0b4<+92>:movwr0,#0x3f480x11c0b8<+96>:movtr0,#0xbb0x11c0bc<+100>:addr0,pc0x11c0be<+102>:ldrr0,[r0]0x11c0c0<+104>:movwr1,#0xc1740x11c0c4<+108>:movtr1,#0xc70x11c0c8<+112>:addr1,pcJZH`-[AddTopicViewControllercheckBtnAction:]+114atAddTopicViewController.m:372371if(sender==self.privateBtn){372self.checkIndex=1;373UIImage*image=[UIImageimageNamed:@"radio_buttons_p"];0x11c0ca<+114>:ldrr3,[sp,#0x90]0x11c0cc<+116>:ldrr1,[r1]0x11c0ce<+118>:strr0,[sp,#0x68]0x11c0d0<+120>:movr0,r30x11c0d2<+122>:ldrr3,[sp,#0x68]0x11c0d4<+124>:blxr30x11c0d6<+126>:movwr0,#0xf53a0x11c0da<+130>:movtr0,#0xbd0x11c0de<+134>:addr0,pc0x11c0e0<+136>:movwr1,#0x3f1c0x11c0e4<+140>:movtr1,#0xbb0x11c0e8<+144>:addr1,pc0x11c0ea<+146>:ldrr1,[r1]0x11c0ec<+148>:movwr2,#0xa6c80x11c0f0<+152>:movtr2,#0xc70x11c0f4<+156>:addr2,pc0x11c0f6<+158>:movwr3,#0x33d60x11c0fa<+162>:movtr3,#0xc80x11c0fe<+166>:addr3,pc(lldb)disassemble--lineJZH`-[AddTopicViewControllercheckBtnAction:]+50atAddTopicViewController.m:371370->371if(sender==self.privateBtn){372self.checkIndex=1;JZH`-[AddTopicViewControllercheckBtnAction:]:->0x11c08a<+50>:ldrr2,[sp,#0x88]0x11c08c<+52>:ldrr3,[sp,#0x90]0x11c08e<+54>:ldrr1,[r1]0x11c090<+56>:strr0,[sp,#0x74]0x11c092<+58>:movr0,r30x11c094<+60>:ldrr3,[sp,#0x74]0x11c096<+62>:strr2,[sp,#0x70]0x11c098<+64>:blxr30x11c09a<+66>:movr7,r70x11c09c<+68>:blx0xb29f58;symbolstubfor:objc_retainAutoreleasedReturnValue0x11c0a0<+72>:movr1,r00x11c0a2<+74>:strr1,[sp,#0x6c]0x11c0a4<+76>:blx0xb29f18;symbolstubfor:objc_release0x11c0a8<+80>:ldrr0,[sp,#0x70]0x11c0aa<+82>:ldrr1,[sp,#0x6c]0x11c0ac<+84>:cmpr0,r10x11c0ae<+86>:bne.w0x11c22c;<+468>atAddTopicViewController.m:3790x11c0b2<+90>:movsr2,#0x10x11c0b4<+92>:movwr0,#0x3f480x11c0b8<+96>:movtr0,#0xbb0x11c0bc<+100>:addr0,pc0x11c0be<+102>:ldrr0,[r0]0x11c0c0<+104>:movwr1,#0xc1740x11c0c4<+108>:movtr1,#0xc70x11c0c8<+112>:addr1,pc(lldb)pinternalssender(UIButton)$48={UIControl={UIView={UIResponder={NSObject={isa=UIButton}}_layer=0x08458300_gestureInfo=nil_gestureRecognizers=nil_subviewCache=0x08402d30@"2objects"_charge=0_tag=2_viewDelegate=nil_backgroundColorSystemColorName=nil_countOfMotionEffectsInSubtree=0_countOfTraitChangeRespondersInDirectSubtree=3239186440_viewFlags={userInteractionDisabled=0implementsDrawRect=0implementsDidScroll=0implementsMouseTracking=1implementsIntrinsicContentSize=0hasBackgroundColor=0isOpaque=0becomeFirstResponderWhenCapable=0interceptMouseEvent=0deallocating=0debugFlash=0debugSkippedSetNeedsDisplay=0debugScheduledDisplayIsRequired=1isInAWindow=0isAncestorOfFirstResponder=0dontAutoresizeSubviews=0autoresizeMask=18patternBackground=0fixedBackgroundPattern=0dontAnimate=1superLayerIsView=0layerKitPatternDrawing=0multipleTouchEnabled=0exclusiveTouch=0hasViewController=0needsDidAppearOrDisappear=1gesturesEnabled=1deliversTouchesForGesturesToSuperview=0chargeEnabled=0skipsSubviewEnumeration=0needsDisplayOnBoundsChange=0hasTiledLayer=0hasLargeContent=0unused=0traversalMark=0appearanceIsInvalid=0monitorsSubtree=0hostsAutolayoutEngine=1constraintsAreClean=1subviewLayoutConstraintsAreClean=1intrinsicContentSizeConstraintsAreClean=0potentiallyHasDanglyConstraints=1doesNotTranslateAutoresizingMaskIntoConstraints=0autolayoutIsClean=0layoutFlushingDisabled=0layingOutFromConstraints=0wantsAutolayout=1subviewWantsAutolayout=0isApplyingValuesFromEngine=0isInAutolayout=0isSubviewUpdatingAutoresizingConstraints=0isUpdatingConstraints=0isHostingUpdateConstraintsPassDuringLayout=0isRunningEngineLevelConstraintsPass=0isUnsatisfiableConstraintsLoggingSuspended=0systemLayoutFittingSizeNeedsUpdate=0systemLayoutFittingSizeNeedsUpdateInWholeSubtree=0isCalculatingSystemLayoutFittingSize=0stayHiddenAwaitingReuse=0stayHiddenAfterReuse=0skippedLayoutWhileHiddenForReuse=0hasMaskView=0hasVisualAltitude=0hasBackdropMaskViews=0backdropMaskViewFlags=0delaysTouchesForSystemGestures=0subclassShouldDelayTouchForSystemGestures=0hasMotionEffects=1backdropOverlayMode=0tintAdjustmentMode=0isReferenceView=0hasUserInterfaceIdiom=0userInterfaceIdiom=0ancestorDefinesTintColor=0ancestorDefinesTintAdjustmentMode=0needsTraitCollectionDidChange=0coloredViewBounds=0coloredAlignmentRects=0coloredHighlightItems=0preservesSuperviewMargins=0hasGeometryObservers=0wantsGeometryChanges=0hasTraitStorageList=0dontUpdateInferredLayoutMargins=0}}_targetActions=nil_previousPoint=(x=0,y=0)_downTime=2001-01-0108:00:00CST_controlFlags={disabled=0tracking=0touchInside=0touchDragged=0requiresDisplayOnTracking=0highlighted=0dontHighlightOnTouchDown=0delayActions=0allowActionsToQueue=0pendingUnhighlight=0selected=0verticalAlignment=0horizontalAlignment=0wasLastHighlightSuccessful=0touchHasHighlighted=0}}}(lldb)pclasssenderUIButton|UIControl||UIView|||UIResponder||||NSObject(lldb)pdocspath/var/mobile/Applications/4E6E3F37-BE80-420D-9B6C-D332A314BEF6/Documents(lldb)helpvsInteractivelysearchforaviewbywalkingthehierarchy.Arguments:<view>;Type:UIView*;Theviewtoborder.Syntax:vs<view>ThiscommandisimplementedasFBViewSearchCommandin/usr/local/Cellar/chisel/1.3.0/libexec/commands/FBFlickerCommands.py.(LLDBaddsthenextline,sorry...)Syntax:vs(lldb)vssenderUsethefollowingand(q)toquit.(w)movetosuperview(s)movetofirstsubview(a)movetoprevioussibling(d)movetonextsibling(p)printthehierarchy<UIButton:0x824e1c0;frame=(17520;6040);opaque=NO;autoresize=RM+BM;tag=2;layer=<CALayer:0x824fe50>>w<UIScrollView:0x822fa40;frame=(-10-12;340358);clipsToBounds=YES;autoresize=RM+BM;gestureRecognizers=<NSArray:0x822d6b0>;layer=<CALayer:0x822fa10>;contentOffset:{0,0}>qIhope0x0822fa40waswhatyouwerelookingfor.Iputitonyourclipboard.《未完待续》
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iOS xcode 调试 LLDB