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 right place for this would be in the debugger, but I can't find the right setting.
我真的希望看到在iPhone模拟器中运行我的应用程序时调用/发送的每个方法,委托,通知等。我认为正确的地方是调试器,但我找不到合适的设置。
My target is to see all that is happening in the background while I, for example, add a row to a UITableView or push the 'back'-button from my UINavigationController.
我的目标是在后台看到所有发生的事情,例如,我向UITableView添加一行或从我的UINavigationController中按下“后退”按钮。
This would be a big help to figure out what delegate to use when something in the app is happening or when the user is pushing a button, changing a view, etc.
这将有助于弄清楚当应用程序中的某些内容发生时,或者当用户按下按钮,更改视图等时要使用的委托。
Is it possible to get this information?
是否有可能获得此信息?
3 个解决方案
#1
8
You can log out everything that is happening when your application is running using DTrace, a framework that lets you probe the inner workings of anything running on a modern Mac. We don't yet have DTrace on iOS, but it will work while you're running within the Simulator.
您可以使用DTrace注销应用程序运行时发生的所有事情,DTrace是一个框架,可让您探索在现代Mac上运行的任何内容的内部工作方式。我们在iOS上还没有DTrace,但是当你在模拟器中运行时它会工作。
I describe the fundamentals of DTrace in this article for MacResearch, then provide an example of a custom instrument you can build in Instruments using DTrace near the end of this article. That instrument logs out all methods called on all objects (even internal system ones) from the moment your application starts until it hits the end of -applicationDidFinishLaunching:
.
我在本文中为MacResearch描述了DTrace的基础知识,然后提供了一个自定义工具的示例,您可以使用DTrace在本文末尾附近构建。该应用程序从应用程序启动的那一刻开始记录所有对象(甚至是内部系统对象)上调用的所有方法,直到它到达-applicationDidFinishLaunching :.
To simplify this, you can simply create a custom instrument using the Instrument | Build New Instrument
menu item in instruments. Set up one of the probe descriptors to look like the following:
为简化此操作,您只需使用Instrument |创建自定义仪器即可在仪器中构建新仪器菜单项。设置其中一个探测描述符,如下所示:
only ignore the isInApplicationStart
and timestamp logging options. A simple probe responding to any Objective-C method in any class will log all of those messages to the Instruments console, which sounds like what you want for your debugging.
仅忽略isInApplicationStart和timestamp日志记录选项。在任何类中响应任何Objective-C方法的简单探测器都会将所有这些消息记录到Instruments控制台,这听起来就像您想要的调试一样。
#2
5
Assuming you're sure you want absolutely everything...
假设你确定你想要一切......
- Breakpoint
objc_msgSend
andobjc_msgSend_stret
. Almost all method calls use those two functions (mumble mumble IMP-cacheing). - Okay, now your app drops into the debugger all the time. So click the auto-continue box.
- But now you don't see very much happening, so edit the breakpoints and add the command "bt" to get a backtrace.
- Drown in debug spam.
断点objc_msgSend和objc_msgSend_stret。几乎所有的方法调用都使用这两个函数(mumble mumble IMP-cacheing)。
好的,现在你的应用程序一直都会进入调试器。所以单击自动继续框。
但是现在你看不到很多事情,所以编辑断点并添加命令“bt”以获得回溯。
淹没调试垃圾邮件。
This won't catch other C functions, of course.
当然,这不会捕获其他C函数。
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).
代表不会被打电话或发送;它们只是普通的Obj-C方法调用(严格来说是“消息发送”,但它没有相同的响铃)。
#3
0
If you put a breakpoint into your app, you can watch the call stack change while you step through the code. That's probably as close as you're going to come to what you have in mind.
如果在应用程序中放置断点,则可以在单步执行代码时观察调用堆栈的更改。这可能就像你要想到的那样接近你的想法。
#1
8
You can log out everything that is happening when your application is running using DTrace, a framework that lets you probe the inner workings of anything running on a modern Mac. We don't yet have DTrace on iOS, but it will work while you're running within the Simulator.
您可以使用DTrace注销应用程序运行时发生的所有事情,DTrace是一个框架,可让您探索在现代Mac上运行的任何内容的内部工作方式。我们在iOS上还没有DTrace,但是当你在模拟器中运行时它会工作。
I describe the fundamentals of DTrace in this article for MacResearch, then provide an example of a custom instrument you can build in Instruments using DTrace near the end of this article. That instrument logs out all methods called on all objects (even internal system ones) from the moment your application starts until it hits the end of -applicationDidFinishLaunching:
.
我在本文中为MacResearch描述了DTrace的基础知识,然后提供了一个自定义工具的示例,您可以使用DTrace在本文末尾附近构建。该应用程序从应用程序启动的那一刻开始记录所有对象(甚至是内部系统对象)上调用的所有方法,直到它到达-applicationDidFinishLaunching :.
To simplify this, you can simply create a custom instrument using the Instrument | Build New Instrument
menu item in instruments. Set up one of the probe descriptors to look like the following:
为简化此操作,您只需使用Instrument |创建自定义仪器即可在仪器中构建新仪器菜单项。设置其中一个探测描述符,如下所示:
only ignore the isInApplicationStart
and timestamp logging options. A simple probe responding to any Objective-C method in any class will log all of those messages to the Instruments console, which sounds like what you want for your debugging.
仅忽略isInApplicationStart和timestamp日志记录选项。在任何类中响应任何Objective-C方法的简单探测器都会将所有这些消息记录到Instruments控制台,这听起来就像您想要的调试一样。
#2
5
Assuming you're sure you want absolutely everything...
假设你确定你想要一切......
- Breakpoint
objc_msgSend
andobjc_msgSend_stret
. Almost all method calls use those two functions (mumble mumble IMP-cacheing). - Okay, now your app drops into the debugger all the time. So click the auto-continue box.
- But now you don't see very much happening, so edit the breakpoints and add the command "bt" to get a backtrace.
- Drown in debug spam.
断点objc_msgSend和objc_msgSend_stret。几乎所有的方法调用都使用这两个函数(mumble mumble IMP-cacheing)。
好的,现在你的应用程序一直都会进入调试器。所以单击自动继续框。
但是现在你看不到很多事情,所以编辑断点并添加命令“bt”以获得回溯。
淹没调试垃圾邮件。
This won't catch other C functions, of course.
当然,这不会捕获其他C函数。
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).
代表不会被打电话或发送;它们只是普通的Obj-C方法调用(严格来说是“消息发送”,但它没有相同的响铃)。
#3
0
If you put a breakpoint into your app, you can watch the call stack change while you step through the code. That's probably as close as you're going to come to what you have in mind.
如果在应用程序中放置断点,则可以在单步执行代码时观察调用堆栈的更改。这可能就像你要想到的那样接近你的想法。