How do I see every method called when I run my application in the iPhone Simulator?

前端 未结 3 433
天涯浪人
天涯浪人 2020-12-28 10:39

I would really like to see every method, delegate, notification, etc. which is called / sent while I run my app in the iPhone Simulator. I thought the righ

3条回答
  •  悲&欢浪女
    2020-12-28 11:06

    Assuming you're sure you want absolutely everything...

    1. Breakpoint objc_msgSend and objc_msgSend_stret. Almost all method calls use those two functions (mumble mumble IMP-cacheing).
    2. Okay, now your app drops into the debugger all the time. So click the auto-continue box.
    3. But now you don't see very much happening, so edit the breakpoints and add the command "bt" to get a backtrace.
    4. Drown in debug spam.

    This won't catch other C functions, of course.

    If you just want to catch notifications, you can do something like this (much less spammy):

    +(void)load
    {
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleEveryNotification:) name:nil object:nil];
    }
    
    +(void)handleEveryNotification:(NSNotification*)notification
    {
      CFShow(notification);
    }
    

    Of course, notifications are done with normal method calls, so the first method will also show them (albeit in a big pile of spam).

    Delegates are not called or sent; they are just normal Obj-C method calls (strictly "message-sends", but that doesn't have the same ring to it).

提交回复
热议问题