【问题标题】:Conditional breakpoint in lldb according to value in memory?根据内存中的值在lldb中设置条件断点?
【发布时间】:2014-03-18 12:21:53
【问题描述】:

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

类似:

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

或者,如果条件为假,我想我可以设置一个断点命令以继续,但我也找不到它的语法:)

【问题讨论】:

    标签: breakpoints lldb conditional-breakpoint


    【解决方案1】:

    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 等,这对于这些类型的断点条件非常方便。

    【讨论】:

    • 感谢您分享有关 $args 的提示!
    猜你喜欢
    • 2019-12-18
    • 2013-02-24
    • 2014-09-28
    • 1970-01-01
    • 2013-01-02
    • 1970-01-01
    • 2015-08-15
    • 2014-08-29
    • 2016-09-09
    相关资源
    最近更新 更多