根据内存中的值在 lldb 中设置条件断点的语法是什么?
就像是:
breakpoint modify -c "memory read -Gx $esp+4 == 0"
或者,我想如果条件为假,我可以设置断点命令以继续,但我也找不到它的语法:)
根据内存中的值在 lldb 中设置条件断点的语法是什么?
就像是:
breakpoint modify -c "memory read -Gx $esp+4 == 0"
或者,我想如果条件为假,我可以设置断点命令以继续,但我也找不到它的语法:)
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
,这对于这些类型的断点条件很方便。