Xcode LLDB watchpoints
Asked Answered
D

2

22

Is there any way to watch a variable in Xcode using LLDB ? Or is this only possible with GDB ? I'm trying to use the command watchpoint set variable but I get the message:

invalid command 'watchpoint set'

Dietary answered 26/6, 2012 at 0:49 Comment(0)
O
31

Watchpoints are supported for iOS and Mac OS X debugging as of Xcode 4.5. To set a breakpoint on a variable named foo, do

(lldb) watchpoint set variable foo

you can always use the shortest unambiguous name for commands in the lldb console so

(lldb) w s v foo

would also work here.

In Xcode, in the locals window you can right-click/control-click on variables and you'll have an option to set a watchpoint on it.

The current arm and x86 cpus only support 4 watchpoints being active at the same time.

Oruntha answered 17/10, 2012 at 2:17 Comment(3)
Thank you for letting us know that they have been activated . I have checked on XCode 4.5 and it works!Dietary
and where can these watched variables be seen?Coequal
watch list will list all watched variables. See help watch for other supported subcommands.Oruntha
D
2

Try using

frame variable -w

instead. The 'watchpoint set' command is in lldb's development branch, and will likely make it in to a future version of Xcode.

For example:

frame variable -w write myvar

EDIT: The watch set variable syntax mentioned in the original post is now supported in lldb in XCode 4.4 and greater.

Digenesis answered 10/7, 2012 at 6:32 Comment(1)
A reverence which includes the watch set var -w write global_var format: lldb.llvm.org/lldb-gdb.htmlStalinism

© 2022 - 2024 — McMap. All rights reserved.