加入收藏 | 设为首页 | 会员中心 | 我要投稿 河北网 (https://www.hebeiwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 业界 > 正文

iOS常用调试方法:LLDB命令

发布时间:2019-04-27 06:33:25 所属栏目:业界 来源:360技术
导读:在iOS项目开拓进程中,常用到静态说明(Analyze)、断点(BreakPoint)和节制台(Console)举办代码调试。本篇文章先容Xcode常用调试要领之LLDB呼吁。 本文来自360奇舞团QiShare团队投稿。 相干阅读: 《iOS 常用调试要领:静态说明》 《iOS 常用调试要领:断点
副问题[/!--empirenews.page--]

在iOS项目开拓进程中,常用到静态说明(Analyze)、断点(BreakPoint)和节制台(Console)举办代码调试。本篇文章先容Xcode常用调试要领之”LLDB呼吁“。

本文来自360奇舞团QiShare团队投稿。

iOS常用调试要领:LLDB呼吁

相干阅读:

  • 《iOS 常用调试要领:静态说明》
  • 《iOS 常用调试要领:断点调试》

1.简介

LLDB是新一代高机能调试器。它构建为一组可重用的组件,可以高度操作较大的LLVM项目中的现有库,譬喻Clang表达式理会器和LLVM反汇编措施。

LLDB是Mac OS X上Xcode的默认调试器,支持在桌面和iOS装备和模仿器上调试C,Objective-C和C ++。

LLDB项目中的全部代码都是在尺度LLVM容许证下提供的,这是一种开源的“BSD气魄威风凛凛”容许证。

2.辅佐

LLDB呼吁名目如下:

  1. <呼吁名称> <呼吁举措> [-可选项 [可选项的值]] [参数1 [参数2...]] 

LLDB呼吁的各部门由空格支解,假如参数中包括空格,则必要行使双引号括起参数,假如参数中包括双引号可能反斜杠,则必要行使反斜杠举办转义。

LLDB呼吁有很是多的成果,完全背下来不太轻易,也没须要。开拓者可以行使help呼吁查察相干呼吁的用法,乃至可以查察help呼吁的用法。

  1. (lldb) help help 
  2.      Show a list of all debugger commands, or give details about a specific 
  3.      command. 
  4.  
  5. Syntax: help [<cmd-name>] 
  6.  
  7. Command Options Usage: 
  8.   help [-ahu] [<cmd-name> [<cmd-name> [...]]] 
  9.  
  10.        -a ( --hide-aliases ) 
  11.             Hide aliases in the command list. 
  12.  
  13.        -h ( --show-hidden-commands ) 
  14.             Include commands prefixed with an underscore. 
  15.  
  16.        -u ( --hide-user-commands ) 
  17.             Hide user-defined commands from the list. 
  18.       
  19.      This command takes options and free-form arguments.  If your arguments 
  20.      resemble option specifiers (i.e., they start with a - or --), you must use 
  21.      ' -- ' between the end of the command options and the beginning of the 
  22.      arguments. 

3. 执行

在LLDB中,执行呼吁expression是最基本的呼吁,简写为expr可能e,语法为:expression -- ,它的浸染是执行一个表达式,并输出表达式返回的功效。示譬喻下:

  1. //! 输出count的值 
  2. (lldb) expression count 
  3. (NSUInteger) $0 = 10 
  4.  
  5. //! 执行string的拼接字符串要领 
  6. (lldb) expression [string stringByAppendingString:@"732"] 
  7. (__NSCFString *) $1 = 0x00006000006ac870 @"QiShare732" 
  8.  
  9. //! 修改view的颜色 
  10. (lldb) expression self.view.backgroundColor = [UIColor redColor] 
  11. (UICachedDeviceRGBColor *) $2 = 0x0000600001d74780 
  12. (lldb) expression [CATransaction flush] 
  13. //!< 由于断点会终止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用来挪用某个要领。示譬喻下:

  1. (lldb) expression -- self.view 
  2. (UIView *) $4 = 0x00007f8ca8401690 
  3.  
  4. (lldb) e self.view 
  5. (UIView *) $5 = 0x00007f8ca8401690 
  6.  
  7. (lldb) p self.view 
  8. (UIView *) $6 = 0x00007f8ca8401690 
  9.  
  10. (lldb) po self.view 
  11. <UIView: 0x7f8ca8401690; frame = (0 0; 375 812); autoresize = W+H; layer = <CALayer: 0x6000008a1dc0>> 
  12.  
  13. (lldb) call self.view 
  14. (UIView *) $8 = 0x00007f8ca8401690 

(编辑:河北网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读