Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode not stopping on breakpoint in method called from LLDB

  • XCode 7.2.1
  • iPad Retina iOS 9.2 Simulator

I have several breakpoints set in a particular class in an XCode project. Everything I discuss below takes place in this one class file.

I set the breakpoints on -(int16_t)areaNbr by clicking in the gutter, and set no conditions or anything on them. I confirmed they existed as far as LLDB is concerned by running breakpoint list from the LLDB prompt.

The project scheme is set to build for debugging, not release.

I run the project in the simulator, and stop at a breakpoint in a different method than the one in question, at which time I want to go to the LLDB prompt and call po [self areaNbr] and step through areaNbr.

Please note, as this may be quite relevant, I have NO code in the project itself that calls
-(int16_t)areaNbr

Now, I CAN get this to stop at my breakpoints on -(int16_t)areaNbr if I add some code to the project that calls the method.
For example, if I add something like NSLog(@"... %d", [self areaNbr])

I know the issue has nothing to do with compiling away the method simply because nothing calls it, because if that were true, then my call to po [self areaNbr] wouldn't be spitting out the result to the debugger window as pictured below. So the method is being compiled, and certainly recognized as existing by the debugger for execution purposes... just not for stepping purposes.

FYI, [self area] is returning "Area01"

enter image description here

Calling breakpoint list in LLDB returns the following

enter image description here

like image 427
Logicsaurus Rex Avatar asked Mar 13 '23 00:03

Logicsaurus Rex


1 Answers

By default, lldb does not stop at breakpoints in hand-called code. The majority of folks use expr & expr -O -- i.e. po to print values & objects and were annoyed if they stopped at breakpoints they had set for other purposes.

However, it is easy to control this behavior, just use:

(lldb) expr -i 0 -- [self areaNbr]

Then you will stop at your breakpoint.

In this example, I left out the -O which is the object printing part, since if you just want to call this method, you likely don't care about calling description on the result after the expression is evaluated.

You can see all the options for expression evaluation by doing:

(lldb) help expr
like image 131
Jim Ingham Avatar answered Apr 25 '23 18:04

Jim Ingham