【发布时间】:2014-03-18 12:21:53
【问题描述】:
根据内存中的值在lldb中设置条件断点的语法是什么?
类似:
breakpoint modify -c "memory read -Gx $esp+4 == 0"
或者,如果条件为假,我想我可以设置一个断点命令以继续,但我也找不到它的语法:)
【问题讨论】:
标签: breakpoints lldb conditional-breakpoint
根据内存中的值在lldb中设置条件断点的语法是什么?
类似:
breakpoint modify -c "memory read -Gx $esp+4 == 0"
或者,如果条件为假,我想我可以设置一个断点命令以继续,但我也找不到它的语法:)
【问题讨论】:
标签: breakpoints lldb conditional-breakpoint
breakpoint modify 的--condition 参数采用 C++ 表达式,在遇到断点时对其求值,如果结果为非零 (true),则断点停止。
(lldb) br s -n foo
Breakpoint 1: where = a.out`foo, address = 0x00001f30
(lldb) br mod -c '*(int*) ($esp+4) == 10'
(lldb) r
Process 11102 launched: '/private/tmp/a.out' (i386)
Process 11102 stopped
* thread #1: tid = 0x42c6f9, 0x00001f30 a.out`foo, queue = 'com.apple.main-thread, stop reason = breakpoint 1.1
#0: 0x00001f30 a.out`foo
a.out`foo:
-> 0x1f30: pushl %ebp
0x1f31: movl %esp, %ebp
0x1f33: pushl %eax
0x1f34: movl 8(%ebp), %eax
(lldb) x/x $esp+4
0xbffffbf0: 0x0000000a
(lldb)
$esp+4 周围的括号是为了防止指针算术大小为int *。如果没有这些括号,表达式将取消引用 $esp+16。
在参数在寄存器中传递的平台上(x86_64、armv7、arm64 用于某些数量的参数),lldb 提供了方便的寄存器别名,$arg1、$arg2 等,这对于这些类型的断点条件非常方便。
【讨论】: