1.增加断点
给方法增加断点
2.查看堆栈信息
//通过bt查看信息
bt
//通过bt后,出现的信息是通过frame进行标号的。
frame
//通过up查看上一条调用信息
up
//通过down查看下一条调用信息
down
frame命令
//查看对应frame的信息
frame select 2
//查看方法的所有变量
frame variable
流程控制命令
//程序继续执行
c = continue
//单步运行,把子函数当做一整部,不会跳进子函数
n = next
//单步运行,会跳进子函数
s = setp in
//代码回滚,下面的代码就不会再执行了
thread return
增加内存断点
//设置属性断点
watchpoint set variable p->_name
//设置内存断点
watchpoint set expression 0x000060400002a568
增加断点出的指令
//向断点标号为1的位置,增加一些指令
break command add 1
//查看1断点处的指令
breakpoint command list 1
//删除1断点处的指令
breakpoint command delete 1
stop-hook
每次执行的时候去执行一些指令,只对breakpoint和watchpoint生效
//添加一条stophook指令
target stop-hook add -o "frame variable"
//添加一条stophook指令
target stop-hook add -o "p self.view"
//查看stophook指令
target stop-hook list
//删除stophook指令
target stop-hook delete
//是某个hook指令失效,2代表标号
undisplay 2
.lldbinit文件,增加hook指令
- 文件目录在磁盘/用户/家目录/.lldbinit文件。
- 如果不存在这个文件,在改目录下新建即可。
- 在该文件中增加hook指令即可。