Watchpoints

Watchpoints are used to monitor the value of a variable for changes; and to trigger a pause in the debugger when these changes happen. Hence, they can be very helpful in identifying state related problems in your program – that you might not know precisely how to track down.

Do it yourself

  1. Put a breakpoint in one of the methods; where you can print the value of the variable.
  2. Navigate to Variables View
  3. Expose the variable name (eg. by expanding self if it is an ivar)
  4. Right click on the variable name and select - Watch <name_of_your_var>

add-watchpoint.png

  1. Alternatively, you can also type in the LLDB console to set the watchpoint

watch set variable your_var_name

  1. A watchpoint watches for changes to the variable you specify. This means that when the variable’s value is set, the watchpoint will hit.

setter-watchpoint.png

  1. Change variables type to "All".
  2. Check "value" for new value of your variable.

observe-value.png

NOTE: Watchpoints are not saved between executions of your program.

Show Comments