打断点
breakpoint set -n test1
breakpoint set -n "-[ViewController save:]" -n "-[ViewController pauseGame:]"
breakpoint list
breakpoint disable 1
breakpoint delete 1
Breakpoint set --selector touchesBegan:withEvent:
Breakpoint set --file ViewController.m --selector touchesBegan:withEvent:
Breakpoint set -r Game:
Breakpoint set --file ViewController.m -r Game:
b -f Viewcontroller.m -r Game:
执行
p self.view.backgroundColor = [UIColor redColor];
p $5.name = @"jimmy"
1.KVC方式修改
P [(Person *)$5 setValue:@"Jimmy" forKey:@"name"]
P Person *p = [[Person alloc] init];p.name = @"jimmy";p.age = 10;
继续执行
c=continue
//调用栈往上走
Up
//调用栈往下走
Down
//调用栈走一个方法
n
//调用栈走一步(汇编)
ni
//单步执行,遇到子函数会进去
S
//汇编走一步
Si
执行往回滚,但是往回滚完后不 继续 执行一开始滚的方法了
thread return
//每次stop的时候执行一些命令
breakpoint stop-hook
watchpoint stop-hook
//选择调用栈
frame select 1
//打印方法局部变量
frame variable
ASLR是指随机加载地址空间,让恶意程序无法事先知道一些敏感数据(操作系统内核),以致难以攻击
PIC是位置代码独立的意思,machO文件会预留一段空间来准备符号表内容,data段(可读可写),苹果设计成这样是为了让自己的共享缓存库API可以动态的加载和绑定,从而达到节省内存和提高效率的效果,但是像fishhook这些就可以通过读取machO文件当中的symbol表来达到hook系统库的C语言函数的作用,这是操作系统设计的利与弊
查看项目依赖所有的库,主要获取主程序machO文件初始的内存地址加上方法或者变量的偏移地址,然后内存断点断住方法或者变量
image list
//查看person头文件
image lookup -t Person
x
//读取寄存器地址内容
register read
内存断点
//name值被赋值(值变化)是会触发断点,并提供old value和new value
watchpoint set variable p1->_name
//通过内存地址打断点
watchpoint set expression 0x00001384738
相当于po,比po高效
vo
给第一组断点加命令,以 DONE 结束
breakpoint command add 1
>po self
>p self.view
>DONE
列出第一组断点命令
breakpoint command list 1
触发断点就会执行命令 -o --one-line
target stop-hook add -o "frame variable"
打开Xcode会执行隐藏文件 .lldbinit ,没有自己 vi 创建,里面可以放一些lldb命令,意思是lldb初始化就会执行,比如可以添加 target stop-hook add -o "frame variable" 程序走到断点时自动打印局部变量,更高级的用法就比如facebook的chisel和LLDB,也就是把chisel的fblldb.py封装好的lldb指令导入到.lldbinit而已。作用域是整个lldb环境,而不是某个项目