副问题[/!--empirenews.page--]
在iOS项目开拓进程中,常用到静态说明(Analyze)、断点(BreakPoint)和节制台(Console)举办代码调试。本篇文章先容Xcode常用调试要领之”LLDB呼吁“。
本文来自360奇舞团QiShare团队投稿。
相干阅读:
- 《iOS 常用调试要领:静态说明》
- 《iOS 常用调试要领:断点调试》
1.简介
LLDB是新一代高机能调试器。它构建为一组可重用的组件,可以高度操作较大的LLVM项目中的现有库,譬喻Clang表达式理会器和LLVM反汇编措施。
LLDB是Mac OS X上Xcode的默认调试器,支持在桌面和iOS装备和模仿器上调试C,Objective-C和C ++。
LLDB项目中的全部代码都是在尺度LLVM容许证下提供的,这是一种开源的“BSD气魄威风凛凛”容许证。
2.辅佐
LLDB呼吁名目如下:
- <呼吁名称> <呼吁举措> [-可选项 [可选项的值]] [参数1 [参数2...]]
LLDB呼吁的各部门由空格支解,假如参数中包括空格,则必要行使双引号括起参数,假如参数中包括双引号可能反斜杠,则必要行使反斜杠举办转义。
LLDB呼吁有很是多的成果,完全背下来不太轻易,也没须要。开拓者可以行使help呼吁查察相干呼吁的用法,乃至可以查察help呼吁的用法。
- (lldb) help help
- Show a list of all debugger commands, or give details about a specific
- command.
-
- Syntax: help [<cmd-name>]
-
- Command Options Usage:
- help [-ahu] [<cmd-name> [<cmd-name> [...]]]
-
- -a ( --hide-aliases )
- Hide aliases in the command list.
-
- -h ( --show-hidden-commands )
- Include commands prefixed with an underscore.
-
- -u ( --hide-user-commands )
- Hide user-defined commands from the list.
-
- This command takes options and free-form arguments. If your arguments
- resemble option specifiers (i.e., they start with a - or --), you must use
- ' -- ' between the end of the command options and the beginning of the
- arguments.
3. 执行
在LLDB中,执行呼吁expression是最基本的呼吁,简写为expr可能e,语法为:expression -- ,它的浸染是执行一个表达式,并输出表达式返回的功效。示譬喻下:
- //! 输出count的值
- (lldb) expression count
- (NSUInteger) $0 = 10
-
- //! 执行string的拼接字符串要领
- (lldb) expression [string stringByAppendingString:@"732"]
- (__NSCFString *) $1 = 0x00006000006ac870 @"QiShare732"
-
- //! 修改view的颜色
- (lldb) expression self.view.backgroundColor = [UIColor redColor]
- (UICachedDeviceRGBColor *) $2 = 0x0000600001d74780
- (lldb) expression [CATransaction flush]
- //!< 由于断点会终止UI线程,执行[CATransaction flush]呼吁可以渲染出修改后的界面
4. 打印
打印呼吁print是最常用的呼吁,简写为pri可能p,语法为:print ,它的浸染是打印变量可能表达式。通过help print会发明print着实是expression --呼吁的简写:'print' is an abbreviation for 'expression --',个中--标识选项的竣事和参数的开始。
同样常用的expression简写呼吁尚有po和call。个中po暗示print object,用来打印工具,call用来挪用某个要领。示譬喻下:
- (lldb) expression -- self.view
- (UIView *) $4 = 0x00007f8ca8401690
-
- (lldb) e self.view
- (UIView *) $5 = 0x00007f8ca8401690
-
- (lldb) p self.view
- (UIView *) $6 = 0x00007f8ca8401690
-
- (lldb) po self.view
- <UIView: 0x7f8ca8401690; frame = (0 0; 375 812); autoresize = W+H; layer = <CALayer: 0x6000008a1dc0>>
-
- (lldb) call self.view
- (UIView *) $8 = 0x00007f8ca8401690
(编辑:河北网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|