2

Setting a watchpoint using (lldb) watchpoint set var myvar will pause the program whenever the variable is written to and print out the change of value to the debugging console.

From using this in the Xcode GUI, I know that it is possible to set breakpoints that execute an action and automatically continue the program afterwards.

Is a similar behaviour possible with watchpoints? Can I set a watchpoint that only prints the change and automatically continues the program execution afterwards?

Tim Bodeit
  • 9,673
  • 3
  • 27
  • 57

2 Answers2

2

You're looking for the watch command add command in lldb. The watchpoint commands are not as mature / tested as the breakpoint commands in lldb -- I just did some quick tests and what you want to do doesn't work right now with Xcode 6. Ideally you'd do something like watchpoint command add --script-type command -one-liner "continue" or watchpoint command add --script-type python -one-liner "return True" (of course the shortest unambiguous command can be used, e.g. wa c add -e python -o "return True", I'm spelling out the full commands to be clearer). When you add a command to a watchpoint it doesn't look like the "old value / new value" output is produced. I don't think that should be its current behavior but I'll ask a few other people to see if they strongly disagree.

Jason Molenda
  • 14,835
  • 1
  • 59
  • 61
2

I actually used a solution close to what Jason described above. It worked for me in XCode 6 and is described in details there: In XCode 6 how can you set a watchpoint without stopping execution?.
Hope this helps.

Community
  • 1
  • 1
DrMad
  • 490
  • 3
  • 12