Hacker News new | ask | show | jobs
by krickle 4898 days ago
This kind of stuff is awesome. I made a profiler for ObjC that did a similar thing, but by programmatically creating a new subclass and only profiling certain instances.

On your prevent instrumentation proxy methods; if the original method references ivars without using self.x or [self x] do you notice weird results?

1 comments

Seems to work fine since we're dropping in the exact same implementation instructions as would have been there otherwise, and using the same object too. That way, any ivar references still correspond to the same positions in memory.
I misread you as running the original method on the proxy object. But if you don't, aren't you missing methods you do want to track called from methods you don't?
The trick is that we use the same original object at the same address in memory and overwrite what class it thinks it is (as opposed to wrapping it). So in a way it becomes a proxy to itself.
I see, I thought you were using the proxy as normal and had programmatically made new classes also. But you are creating an object and then setting its class to the proxy. Neat.