美文网首页
iOS 常用LLDB指令

iOS 常用LLDB指令

作者: 大冯宇宙 | 来源:发表于2019-03-02 12:08 被阅读0次
print、p指令

打印内存地址,基础类型一般都是用这个指令。

(lldb) p a
(int) $0 = 10
(lldb) p obj
(NSObject *) $1 = 0x0000000100573f70
(lldb) print obj
(NSObject *) $2 = 0x0000000100573f70
po打印对象
(lldb) po a
10
(lldb) po obj
<NSObject: 0x100573f70>
memory read 读取内存

memory read 内存地址

<NSObject: 0x100573f70>
(lldb) memory read 0x100573f70
0x100573f70: 41 d1 a9 8d ff ff 1d 00 00 00 00 00 00 00 00 00  A...............
0x100573f80: 50 40 57 00 01 00 00 00 90 42 57 00 01 00 00 00  P@W......BW.....

memory read后边可以增加数量、格式、字节数三个参数,
格式:x是16进制,f是浮点,d是10进制
字节大小:b:byte 1字节,h:half word 2字节,w:word 4字节,g:giant word 8字节

(lldb) memory read/4xg 0x100573f70
0x100573f70: 0x001dffff8da9d141 0x0000000000000000
0x100573f80: 0x0000000100574050 0x0000000100574290

memory read 等价于x

(lldb) x 0x100573f70
0x100573f70: 41 d1 a9 8d ff ff 1d 00 00 00 00 00 00 00 00 00  A...............
0x100573f80: 50 40 57 00 01 00 00 00 90 42 57 00 01 00 00 00  P@W......BW.....
memory write 修改内存中的值

memory write 内存地址 数值

(lldb) memory write 0x100573f79 9
(lldb) x 0x100573f70
0x100573f70: 41 d1 a9 8d ff ff 1d 00 00 09 00 00 00 00 00 00  A...............
0x100573f80: 50 40 57 00 01 00 00 00 90 42 57 00 01 00 00 00  P@W......BW.....
直观的展示内存地址
Xcode
输入地址

相关文章

网友评论

      本文标题:iOS 常用LLDB指令

      本文链接:https://www.haomeiwen.com/subject/gddeuqtx.html