To get a stack trace in the middle of the app, you don’t need to make it crash. Simply call
[NSThread callStackSymbols] in e.g. an
NSLog and you’ll see the relevant trace without having to crash the app.
Another trick is to do this on a symbolic breakpoint. Recently I was debugging a crash and I needed to know where the latest
tableView reloadData was coming from. Simply doing an
NSLog(@"%@",[NSThread callStackSymbols]) did not cut it, because the reload was not in the stack trace.
What I did was to add a symbolic breakpoint on all
UITableView reloadData calls, then add the stack trace as a breakpoint action. Like this.
And then I made the breakpoint not stop, but print the stack trace.
After replicating the crash, we could now easily go through all of the log to find the relevant code that was causing the reload.
Yes, a search for
reloadData could’ve led us here as well. But due to some code around this, this code looked just fine and had worked well except for a very specific case, in the end there were some small animation code around it that messed something up.