Xcode - break in exception but unused characters

I need help finding the magic spell needed to get useful information in LLDB.

I have weird behavior that I am trying to debug, and I can reliably reproduce the problem, but I still do not understand the reason. I noticed that an exception was thrown, so I added an exception checkpoint for Xcode.

An exception:

CoreData: Error: A serious application error. Excluded. from the NSFetchedResultsController delegate during a call to -controllerDidChangeContent :. *** - [__ NSArrayM objectAtIndex:]: index 2 outside for an empty array with userInfo (null)

So, with my breakpoint, I get the following stack trace:

Stacktrace

It looks very useful! It looks like there is some funkiness for reusable headers in UICollectionViewFlowLayout ... now I just need ... oh. shit. Wait. what?

How to check this array in frame 1 of a stack trace that is called using a linked index? Can I po <some memory address> in the console to check it? I cannot use frame variable in LLDB console if frames 11-1 () are selected.

As I read this stack trace:

  • (Box 14) The selected results controller takes a change in the context of the managed entity and calls it the delegate
  • (Box 13) The FRC delegate, an instance of FHMemberDirectory , sends the -memberDirectoryDidChangeContent:completion: message to the FHMemberDirectoryViewController , which is a subclass of UICollectionViewController
  • (Frame 12) The view controller calls -performBatchUpdates:completion: on it is an instance of UICollectionView
  • (Box 10 - 1). Apple's private things are trying to create a collection layout on the screen; I think!

... Please let me know if I missed something obvious! This question is about debugging, and I hope that a different set of eyes or more experience can enlighten me.

To my unprepared eye, this seems like an error similar to the Apple code, but I still need to figure out how to get around it. This essence of my problem is understanding how to get useful information from the LLDB console in code that is not under my direct control.

+4
source share
1 answer

From my experiments and research, the answer is:

Only with LLDB you cannot get useful characters or memory addresses for checking.

However, you can use the Objective-C runtime to implement the swizzle method and go into a deep stack trace, therefore providing you with a handle to the arguments and return values.

stack trace with methods swizzled in

Now I have access to the arguments passed in frames 3 and 5!

(It turns out that the argument ...usingData: is Apple's private class. I managed to learn more about the class here , but nothing super useful. At the end of the day, I filed radar and asked for help with the DTS).

+1
source

Source: https://habr.com/ru/post/1481542/


All Articles