LLDB

工作原理

使用目标
  • 能够快速定位代码
  • 减少程序运行次数
命令结构

<command> [<subcommand>[<subcommand>]] <action> [-options[option-value]] [argument [argument]]

  • command 命令
  • subcommand 子命令
  • action 动作
  • -options[option-value] 可选项及参数
  • argument [argument] 命令参数

格式

LLDB 命令行在解析操作执行命令之前完成。上面的这些元素之间通过空格来分割,如果某一元素自身含有空格,则可以使用双引号。而如果元素中又包含双引号,则可以使用反斜杠;或者元素使用单引号。

(lldb) command [subcommand] -option "some "inside" string"

(lldb) command [subcommand] -option 'some "inside" string'

一、breakpoint

  • 1.set : 设置断点
  • 2.modify:修改断点
  • 3.delete/clear:删除断点
  • 4.list :查看断点

1.breakpoint set

  • 设置条件断点:
    整数相等

breakpoint set -f BreakpointVC.m -l 29 -c 'i == 5’

字符串相等

breakpoint set -f BreakpointVC.m -l 30 -c '[self.strName isEqualToString:@"我4"]'

  • other breakpoint set option

-f 文件名
-l 行数
-d 失效
-i 跳过次数
breakpoint set -f RetHomeViewController.m -F breakPointClear -i 2
-o 运行一次后删除
-a 16位的物理地址
breakpoint set -a 0x10dcc0446
-T 线程名
-q 队列名称
-t 线程id
-x 线程位置
-C 添加command
breakpoint set -F breakPointClear -C bt
-G 运行完command是否断住
breakpoint set -F breakPointClear -G false
-N 添加别名
breakpoint set -n breakPointClear -N tao

2.breakpoint modify

  • 修改断点条件:

breakpoint modify -c ‘i == 5' 2

  • other breakpoint modify option

执行到command是否自动断住 默认断住,false不断住
breakpoint modify -G true 2
-T 线程名

-t 线程tid

-q 线程队列
-x 线程位置
修改断点有效或者无效
-d/-e
breakpoint modify -c 'i == 5' -e 3
-i 断点次数
-o 一次断点

3.breakpoint delete/clear option

breakpoint clear
删除特定行断点

breakpoint clear -f RetHomeViewController.m -l 36

删除顺序中断点
breakpoint delete - D 2
删除所有断点
breakpoint delete -f

4.breakpoint list option

-b 断点信息
-f 全部信息
-i
-v

一、watchpoint

观察变量

  • 1.set : 设置观察
  • 2.modify:修改观察
  • 3.delete:删除观察
  • 4.list :查看观察

1.watchpoint set

设置观察

watchpoint set variable self->_city

地址观察属性

p & _city
watchpoint set expression 0x00007ffc80e100c8

2.watchpoint modify

观察某个属性特定的值:

watchpoint modify -c ‘self->_age==10’ 1

3.watchpoint delete/list
删除观察

watchpoint delete

查看观察

watchpoint list

三、thread

  • 线程执行操作

线程跳转
thread jump -f RetHomeViewController.m -l 39
线程返回
thread return
顺序线程跳过断点
thread continue 1
选中线程
thread select 1
进入
thread step-in
退出
thread step-out
step-over
指令单步
step-inst
执行到行数
thread until -t 1 68

  • 线程执行操作

线程跳转
thread jump -f RetHomeViewController.m -l 39
线程返回
thread return
顺序线程跳过断点
thread continue 1
选中线程
thread select 1
进入
thread step-in
退出
thread step-out
step-over
指令单步
step-inst
执行到行数
thread until -t 1 68

  • 线程信息

线程栈 bt
thread backtrace
当前线程栈信息
thread info
当前所有线程
thread list

四、expression option

-O po 命令
expression -O -- self
修改变量值
expression self.age = 3
expression self.type = (ExpressionVCType)1
改变背景色
expression self.view.backgroundColor = [UIColor redColor]
expression [CATransaction flush]
-F 变量地址
expression -F -- self
-L 变量位置
expression -L — self

创建变量
e NSString string = (NSString *)@“aaa" e NSIntegernumber = (NSInteger)22

参考
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  •   LLDB的Xcode默认的调试器,它与LLVM编译器一起,带给我们更丰富的流程控制和数据检测的调试功能。平时用...
    Thinkdifferents阅读 5,752评论 1 4
  • Xcode Debugging 你的代码,或者任何人的代码中总会有bug存在,你可以把调试看做是更好地理解代码的一...
    吃蘑菇De大灰狼阅读 7,194评论 0 2
  • [转]浅谈LLDB调试器文章来源于:http://www.cocoachina.com/ios/20150126/...
    loveobjc阅读 7,468评论 2 6
  • LLDB 是一个有着 REPL 的特性和 C++ ,Python 插件的开源调试器。LLDB 绑定在 Xcode ...
    高思阳阅读 3,130评论 0 0
  • 随着Xcode 5的发布,LLDB调试器已经取代了GDB,成为了Xcode工程中默认的调试器。它与LLVM编译器一...
    随风飘荡的小逗逼阅读 5,225评论 0 0