Sharon said:
Thanks for your reply Jeronen.
I know profilers can monitor method calls at runtime.
But how is it done?
There are two main approaches: instrumented, and sampling.
An instrumented profiler injects code at the entry and exit for each
method that you want profiled. A sampling profiler simply inspects the
instruction pointer of the executing program at regular intervals.
The former gives you much more precise information, at the expense of
overhead. A sampling profile can disturb the execution of the program
much less, but can only provide broad statistics regarding execution.
It's not uncommon to find a single profiler that supports both approaches.
I need it for security features.
That seems unlikely. Usually, when someone posts here saying they need
some unusual introspective feature in their code "for security features"
what they really mean is that they are trying to implement some copy
protection scheme. All copy protection schemes are doomed to failure
from the outset.
If you have some other "security feature" in mind, you should be more
specific so that you can get better advice. If you are in fact thinking
of a copy protection scheme, do yourself a favor and don't waste any
more time on trying to implement this particular approach. Even if it
works, you will spend far more time implementing it than some hacker
will breaking it.
Pete