Observe memory points

With the new change from gdb to lldb, I cannot find a way to set watchpoints on some memory addresses.

In gdb, I used this

watch -location *0x123456 

Doing the same in lldb

 wse *0x123456 

Not working for me. So what can I use to run the same command in lldb?

+7
debugging xcode lldb gdb
source share
1 answer

Omit the "dereference operator" * when setting the watchpoint in lldb, just go to:

 watchpoint set expression -- 0x123456 # short form: wse -- 0x123456 

sets the observation point in memory location 0x123456 . You can optionally set the number of bytes to view with --size . Short example:

 wse -s 2 -- 0x123456 

You can also set a watchpoint for a variable:

 watchpoint set variable <variable> # short form: wsv <variable> 

Example: with the following code and breakpoint set on the second line:

 int x = 2; x = 5; 

I did this in the Xcode debugger console:

  (lldb) p & x
 (int *) $ 0 = 0xbfffcbd8
 (lldb) wse - 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)

Simply put, I could set the observation point using

  (lldb) wsvx
 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'
+16
source share

All Articles