iOS_Xcode_LLDB调试常用命令

结构

命令结构:

// 命令结构:
<command> [<subcommand> [<subcommand>...]] <action> [-options [optionvalue]] [argument [argument...]]
命令 子命令 命令操作 命令选项 命令参数

常用命令:

expression:表达式
thread backtrace:堆栈
thread:线程
frame:栈帧
breakpoint:符号断点
watchpoint:内存断点
image:镜像
register:寄存器
memory:内存

continue:继续
next:下一步
step:跳进
finish:跳出

call:执行方法

查看帮助:help <command> [<subcommand>]

查看命令具体帮助:apropos <command>


流程控制:
在这里插入图片描述

1、流程控制:

  • 源码级别 source level:
// 单步运行
thread step-in / step / s // 会进入函数内部
thread step-over / next / n // 不会进入函数内部
  • 指令级别 instruction level:

需要设置:Debug → Debug workflow → Always Show Disassembly

// 在汇编页面
thread step-inst / stepi / si  // 会进入函数内部
thread step-inst-over / ni  // 不会进入函数内部
  • 继续、退出
// 从一个函数跳出(若没有执行s/si, 会跳到汇编指令bl的下一条位置)
thread step-out / finish / f
// 要从嵌套的 step-out 中退出,可执行 c 跳转到下一个断点
process continue / continue / c

2、常用命令

// 执行表达式
expression / expr / p

// 打印1:print = p
p person
(Person *) $0 = 0x000000010053b7f0

// 打印2:expression -o / expr -o / po 
po person
<Person: 0x10053b7f0>
// 若接受到的对象是一个指针,会调用它的 description 方法打印
// 若接受到的对象是 CoreFoundation 对象,会调用它的 CFShow 方法打印
// 其他情况同 p

// 修改背景色
expr tableView.backgroundColor = UIColor.red

// 查看变量类型结构
fr v -R a
(Swift.Int) a = {
  _value = 10
}

3、进程信息:

thread list # 线程列表
// 堆栈
thread backtrace all # 所有线程堆栈
thread backtrace # 当前线程堆栈
thread backtrace 2 # 线程2堆栈

// 跳出当前执行的方法(后面的不执行)
thread return
thread return 20

// 栈帧
frame info // 栈帧信息
frame variable // 帧变量列表
frame select 0 // 选择帧
// 移动帧:up:序号+1 down:序号-1

4、寄存器:register

register read
register write rax 123

5、镜像:image

// 依赖库列表
image list
// 查找模块
image lookup -type class // 查看class所有属性和成员变量
image lookup -name '方法名' // 查找方法来源
image lookup -address 地址 // 查找崩溃位置

6、内存:memory

memory read/数量+格式+字节数 内存地址
// 格式:x为16进制,f位浮点数,d为10进制
// 字节数:b为1个字节,h为2个字节,w为4个字节,g为8个字节

// 例:
x/4xg 0x00006000001600b0
memory read 0x00006000001600b0
memory read/3xg 0x00006000001600b0
memory read/8xg 0x00006000001600b0
memory read/8xw 0x00006000001600b0
memory read/3dw 0x00006000001600b0
memory read/3fw 0x00006000001600b0

// 写内存
memory write 内存地址 述职

7、符号断点:breakpoint

// 列出所有断点
breakpoint list
// 设置断点
breakpoint set -address 0x000000 // 函数地址
breakpoint set -name "viewDidLoad" // 函数名

breakpoint disable 断点编号 // 禁用断点
breakpoint enable 断点编号 // 启用断点
breakpoint delete 断点编号 // 删除断点

8、内存断点:watchpoint

watchpoint set variable 变量
watchpoint set expression 地址
watchpoint list
watchpoint diable 断点编号
watchpoint enable 断点编号
watchpoint delete 断点编号
watchpoint command add 断点编号
watchpoint command list 断点编号
watchpoint command delete 断点编号

9、Tips:

反引号:a,会用表达式解析器运行该值的文本,将值替换为该文本

memory read -c len 0x12345

当参数以-开头,前面需要用- -隔开:

process launch --stop-at-entry -- -program_arg value


参考:

官网:https://lldb.llvm.org/
官方教程:https://lldb.llvm.org/use/tutorial.html

lldb常用命令与调试技巧

iOS开发之LLDB常用命令

相关推荐

  1. 调试工具gdb的命令总结

    2024-01-29 14:36:02       43 阅读
  2. Kubernetes 命令

    2024-01-29 14:36:02       35 阅读
  3. Pgsql命令

    2024-01-29 14:36:02       32 阅读
  4. git命令

    2024-01-29 14:36:02       45 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-29 14:36:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-29 14:36:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-29 14:36:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-29 14:36:02       20 阅读

热门阅读

  1. C51 单片机学习(文章链接汇总)

    2024-01-29 14:36:02       37 阅读
  2. 一个最小的振动分析系统设计

    2024-01-29 14:36:02       33 阅读
  3. 龙哥风向标 2023.1.5 GPT拆解

    2024-01-29 14:36:02       44 阅读
  4. KY98 棋盘游戏

    2024-01-29 14:36:02       33 阅读
  5. 图的邻接矩阵表示

    2024-01-29 14:36:02       34 阅读
  6. Python运算符:从入门到精通,探索无限可能!

    2024-01-29 14:36:02       26 阅读
  7. 计算机网络之ARP协议

    2024-01-29 14:36:02       40 阅读
  8. stm32 - SPI

    2024-01-29 14:36:02       40 阅读