LLDB速查

断点

  • 设置断点
$breakpoint set -n XXX
set 是子命令
-n 是选项 是--name 的缩写!
  • 查看断点列表
$breakpoint list
  • 删除
$breakpoint delete 组号
  • 禁用/启用
$breakpoint disable 禁用
$breakpoint enable  启用
  • 遍历整个项目中满足Game:这个字符的所有方法
$breakpoint set -r Game:
在包含有Game:字段的方法设置断点
  • 给某个属性添加断点
$watchpotint set variable object->attribute
object->attribute 某个对象的某个属性
  • 给某个内存添加断点
$watchpoint set expression 内存地址
  • 查看堆栈信息
$bt

运行代码

流程控制
  • 继续执行
$continue c
可简写为
$c
  • 单步运行,将子函数当做整体一步执行
$n next
  • 单步运行,遇到子函数会进去
$s
  • 上一步
$up
  • 下一步
$down
  • 回滚上一步,取消执行下面的代码
$thread return
  • 查看当前语境下的对象地址与属性
$frame variable
  • 跳转到指定某一步代码
$frame select #1(编号)
  • 添加多行代码
$p id object =  [object method];
object.attribute = "";
@[object];
control+enter进行换行

断点其他操作

* 给断点添加指令
$break command add 断点编号
>
>
>DONE(结束符号)
  • 查看添加指令列表
$break command list
  • 删除添加的指令
$break command delete 编号

stop-hook

让你在每次stop的时候去执行一些命令,只对breadpoint,watchpoint

e.g :
$target stop-hook add -o "frame variable"
  • 给LLDB加一些初始化指令
/**
1.Finder->lldbinit(command + shift + .显示隐藏的文件)
如果没有发现.lldbinit
可先安装一个chisel(facebook团队对LLDB的扩展,如果不需要,可以不安装,直接创建.lldbinit)
*/
$brew install chisel
// 创建.lldbinit文件
$touch ~/.lldbinit
// 在.lldbinit添加代码
target stop-hook -o "frame variable"

常用命令

  • 查看崩溃定位
$image lookup -a 内存地址
e.g:
NSArray *objects = @[@"1", @"2", @"3", @"4", @"5"];
for (int i =0; i < 10; i++) {
    id object = objects[i];
    NSLog(@"%@", object);
}

error message:
*** Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘*** -[__NSArrayI objectAtIndexedSubscript:]: index 5 beyond bounds [0 … 4]’
*** First throw call stack:
(0x1c3c23ef8 0x1c2df1a40 0x1c3b9985c 0x1c3b29bbc 0x100972718 0x1f05e1380 0x1f05e17b0 0x1f0bdc2d0 0x1f0bdc878 0x1f0bed86c 0x1f0b9d480 0x1f0ba2e1c 0x1f0443c18 0x1f044c6f0 0x1f0443894 0x1f0444234 0x1f0442334 0x1f0441fe0 0x1f04471a0 0x1f0448100 0x1f0447058 0x1f044bd9c 0x1f0ba1314 0x1f078cc34 0x1c6653890 0x1c665e658 0x1c665dd50 0x100c5cde4 0x100c60a2c 0x1c6692640 0x1c66922cc 0x1c66928e8 0x1c3bb25b8 0x1c3bb2538 0x1c3bb1e1c 0x1c3bacce8 0x1c3bac5b8 0x1c5e20584 0x1f0ba4bc8 0x100972818 0x1c366cb94)
libc++abi.dylib: terminating with uncaught exception of type NSException
image lookup -a 0x100972718

  • 快速查看某个类(提取头文件内容)
$image lookup -t Class
// 常用指令
$image list 
$p
$b -[xxx xxx]
$x 
$register read
$po
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值