Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
I am trying to debug an application I'm building. This bug appears to be causing one of my methods to fire prematurely, and I'd like to know why. So, I'll use a breakpoint. I want the debugger to stop at the very line where that method is invoked.

Suppose, for example, that I have a class with just three methods, defined as follows:

Code:
-(void)methodThatWorks
{
// do something productive
}

-(void)someMethod
{
if (X)
{
[self methodThatWorks];
}
}
-(void)someOtherMethod
{
if (Y)
{
[self methodThatWorks];
}
}

If someMethod causes methodThatWorks to be invoked, I want the program to stop execution at the [self methodThatWorks] line in someMethod. Likewise, if someOtherMethod causes methodThatWorks to be invoked, I want the program to stop execution at the [self methodThatWorks] line in someOtherMethod.

I thought setting a symbolic breakpoint would do the trick, but what really happens is the debugger puts the breakpoint in the method that is called.

Edit: Here's a screenshot to illustrate what's happening. Note that this screenshot is not from the app I'm building - it's from a project I just built today:
Tlg0O1hCArXjHsGD5GZ3uU-c4BTduoyANQgNaoEtqzw=w655-h579-no
 
Last edited:

mfram

Contributor
Jan 23, 2010
1,345
386
San Diego, CA USA
Put a breakpoint in the first line of methodThatWorks, then change your context in the debugger up a level in the call stack when the breakpoint hits.
 

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
Update: Apparently, what you see in the screenshot is exactly what Apple wanted the symbolic breakpoint to do. However, there is a way to see the line of code in which a method was invoked while your app is paused by a breakpoint in that method. In the Debug Navigator, in the stack trace, will be the name of the method that caused the aforementioned method to fire. Click on it, and Xcode will highlight the line in which the method the breakpoint fired in is invoked. Here's a screenshot, from this related Apple Support Communities thread:
Screen+Shot+2015-06-06+at+2.34.22+PM.png
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.