Hikarus
Hikarus

Reputation: 335

Set a conditional breakpoint on XCode that watches a global variable

I'm trying to set a breakpoint that triggers anywhere within the scope of a viewController when a global variable takes certain value. So far I haven't found a way to do it because line breakpoints break at specific lines, symbolic breakpoints break at specific methods, and exception breakpoints break at, well, exceptions. But I just want the execution to stop at any point in the code without having to set a breakpoint at every line where I think it could happen. Any ideas?

Upvotes: 3

Views: 896

Answers (2)

Flex Monkey
Flex Monkey

Reputation: 3643

Could you add a didSet observer to your variable and add a break-point inside that?

Simon

Upvotes: 2

matt
matt

Reputation: 535606

You are describing a watchpoint, not a breakpoint. There is no user interface for setting a watchpoint on a global; you'll have to pause your running app and set it at the LLDB command-line:

(lldb) watch set variable myGlobalVariable

Upvotes: 3

Related Questions