You can use DTrace to monitor a running application to see the methods and the classes that are called. You can easily monitor an iOS app running in the Simulator using DTrace on the command line, First you will need to find the PID of the application using ps
and then you can run a DTrace probe like the following:
sudo dtrace -q -n 'objc1234:::entry { printf("%s %s\n", probemod, probefunc); }'
where 1234 is the process ID of the app.
This will produce output that looks like the following:
UIStatusBarItemView -isVisible
UIStatusBarLayoutManager -_positionAfterPlacingItemView:startPosition:
UIView(Geometry) -frame
CALayer -frame
UIStatusBarLayoutManager -_startPosition
UIView(Geometry) -bounds
CALayer -bounds
UIStatusBarItemView -standardPadding
UIStatusBarItem -appearsOnLeft
UIStatusBarItem -leftOrder
If you are only interested in tracing a single class, UIView
for example, you could use:
sudo dtrace -q -n 'objc1234:UIView::entry { printf("%s %s\n", probemod, probefunc); }'
If you wanted to trace all calls to dealloc
on all classes, you would use:
sudo dtrace -q -n 'objc1234::-dealloc:entry { printf("%s %s\n", probemod, probefunc); }'
Obviously, you could combine these to only see UIView
dealloc
s:
sudo dtrace -q -n 'objc1234:UIView:-dealloc:entry { printf("%s %s\n", probemod, probefunc); }'
If you want to be able to distinguish a specific object of a class you could also print the memory address of the object (self
) using the following:
sudo dtrace -q -n 'objc1234:UIView:-dealloc:entry { printf("%s (0x%p) %s\n", probemod, arg0, probefunc); }'
DTrace is extremely powerful and can do considerably more than I've shown here.