LLDB
LLDB(Low Lever Debug)
默认内置于Xcode中的动态调试工具。标准的 LLDB 提供了一组广泛的命令,旨在与老版本的 GDB 命令兼容。 除了使用标准配置外,还可以很容易地自定义 LLDB 以满足实际需要。
设置断点
设置断点
$breakpoint set -n XXX
set 是子命令
-n 是选项 是--name 的缩写!
breakpoint set - n action //给action下断点
breakpoint set - n "[ClassName action]" - n "[ClassName action1]" - n "[ClassName action1]" //设置三个方法 会被归为一组
breakpoint set --selector touchesBegain:withEvent: //给所有的 touchesBegain:withEvent方法下断点
breakpoint set --file ViewController.m --selector touchesBegain:withEvent: //给ViewController.m的 touchesBegain:withEvent方法下断点
breakpoint -a 0xxxxxxx //通过函数地址给函数下断点
b -a 0xxxxxxx //通过函数地址给函数下断点
遍历整个项目中满足looha:这个字符的所有方法
$breakpoint set -r looha: //给所有looha字段的地方下断点
简写
b set -r looha
b -r looha
查看断点列表
$breakpoint list
删除
$breakpoint delete 组号
breakpoint delete 1 //删除第一组,只能删除某个组
breakpoint delete //删除所有
禁用/启用
$breakpoint disable 禁用
breakpoint disable 1.1 //禁用第一组的第一个方法
$breakpoint enable 启用
breakpoint enable 1.1 //禁用第一组的第一个方法
//简写
break dis
break enable
断点后继续
$c
c
-
函数地址下断点
image.png
LLDB执行
expression
expression self 查看self
p 是 expression
p self
po self 调用object的description方法
p [self.arr addObject:@"1"]
p self.arr[0]
//多行代码
p Model *m = [Model alloc] init]; // alt + 回车
p Model *m1 = [Model alloc] init];
p Model *m = [Model alloc] init]; p Model *m1 = [Model alloc] init]; p Model *m2 = [Model alloc] init]; // com + 回车

查看堆栈信息
$ bt 调用堆栈
bt

$ up 向上跟
up
$ frame select 1(组) // 查看具体方法
$ frame variable //frame select 进入后 查看方法参数

更改参数
$ frame variable
p parameter = xxx;

回滚
$ thread return //回滚之后直接返回 下面代码不会执行
finish 返回上层调用栈
$ finish
LLDB 指令
继续执行
$continue c
单步运行,将子函数当做整体一步执行
$n next 源码层级
$ni 汇编层级
单步运行,遇到子函数会进去
$s 源码层级
$si 汇编层级
stop-hook
让你在每次stop的时候去执行一些命令,只对breadpoint,watchpoint
其他命令
image list
p
b -[xxx xxx]
x
register read
po
内存断点
给p1的name 属性设置断点,内存断点
watchpoint set variable p1->_name
//通过内存地址设置内存断点
watchpoint set expression 0xxxxxxxxxx
p &pa->_name
//通过内存地址设置内存断点

command 指令
breakpoint command add 1 给断点1 添加命名
> po self
> p self.view
> DONE
查看
breakpoint command list 2
删除
breakpoint command delete 2 //删除
给断点1 加命名

target stop-hook
target stop-hook add 添加
target stop-hook add -o"frame variable" //每次断点时都查看参数
target stop-hook list
target stop-hook delete
LLDB 初始化文件 很目录
.lldbinit
target stop-hook add -o"frame variable"
image指令
image lookup 0xxxxxxxxxx
image lookup -t Person 查看类的信息 快速查看文件
image list 所有加载库
register read 读取寄存器
register write 写入寄存器
Memory read 读取内存值
image list 查看某块列表
ps : arrWithCapacity: 节省内存,不够成倍扩增
网友评论