With the new change from gdb to lldb , I can\'t find a way how to set watch points on some memory addresses .
In gdb I used this
watch -location *0x1234
Omit the "dereferencing operator" *
when setting the watch point in lldb, just pass the address:
watchpoint set expression -- 0x123456
# short form:
w s e -- 0x123456
sets a watchpoint at the memory location 0x123456
. Optionally you can set the number of bytes to watch with --size
. Example in short form:
w s e -s 2 -- 0x123456
You can also set a watchpoint on a variable:
watchpoint set variable
# short form:
w s v
Example: With the following code and a breakpoint set at the second line:
int x = 2;
x = 5;
I did this in the Xcode debugger console:
(lldb) p &x (int *) $0 = 0xbfffcbd8 (lldb) w s e -- 0xbfffcbd8 Watchpoint created: Watchpoint 1: addr = 0xbfffcbd8 size = 4 state = enabled type = w new value: 2 (lldb) n Watchpoint 1 hit: old value: 2 new value: 5 (lldb)
More simply, I could have set the watchpoint with
(lldb) w s v x Watchpoint created: Watchpoint 1: addr = 0x7fff5fbff7dc size = 4 state = enabled type = w declare @ '/Users/martin/Documents/tmpprojects/watcher/watcher/main.c:16' watchpoint spec = 'x'