2014-02-18 67 views
3

根据内存中的值在lldb中设置条件断点的语法是什么?根据内存中的值,lldb中的条件断点?

喜欢的东西:

breakpoint modify -c "memory read -Gx $esp+4 == 0"

另外,我想我可以设置断点命令继续,如果条件是假的,但我没能找到该语法以及:)

回答

8

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是保持指针运算被大小OF- int *。如果没有这些括号,表达式会解除引用$esp+16

在其中参数在寄存器(x86_64的,ARMv7的,arm64对于一些数量的参数)传递平台,LLDB提供便利寄存器别名,$arg1$arg2等,它们是很方便的对这些种断点条件。

+0

感谢您分享有关$ args的提示! – Danra

+0

Oh dang,感谢'$ args'提示:D – Qix