Conditional breakpoint in lldb by value in memory?

What is the syntax for setting a conditional breakpoint in lldb according to the value in memory?

Sort of:

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

Alternatively, I think I could set the breakpoint command to continue if the condition is false, but I also could not find the syntax for this :)

+3
source share
1 answer
Argument

breakpoint modify --condition takes a C ++ expression, evaluates it when a breakpoint is hit, and if the result is non-zero (true), the breakpoint stops.

(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) 

The bracket around $esp+4is to preserve pointer arithmetic from size-of- int *. Without these brackets, the expression will dereference $esp+16.

, (x86_64, armv7, arm64 ), lldb , $arg1, $arg2 .., .

+8

All Articles