Hi,
thank you for answering.
I am looking for a portable solution concerning the OS but for now, windows
and/or linux (preferred linux) would be sufficient. And I'm using Intel
CPUs.
Could you post a link to such a profiler library?
As far as i found out, telling the cpu to automatically trigger a software
interrupt is possible. I think it is possible to catch this interrupt but
the only question is how to tell the cpu to do so. Perhaps, i should check a
debuggers source code :-/
The instruction pointer would only help me if the software made a break
after each command.......
I would be thankful for further help...
Regards,
- Jo
"Jacek Dziedzic" <jacek@no_spam.tygrys.no_spam.netschrieb im Newsbeitrag
news:82**************************@news.chello.pl.. .
Johannes Röckert wrote:
Hi,
can anyone help me on how to develop a program in c++ which does single
step execution using a callback between the asm commands? I need something
like debuggers do - a callback function should be called after each
command.
I think the resulting code could be fairly small and look somehow like
this:
static int numCommands = 0; // Var which stores the number of commands
void callback()
{
numCommands++; // Increase the command count
}
int main()
{
enable_single_step_execution(callback); // Enable single step feature
and set callback
for (int i = 0; i < 100; i++); // callback() should be now called after
each asm command
disable_single_step_execution(); // Disable feature
cout << "The loop consisted of " << numCommands << " asm commands!" <<
endl;
}
This cannot be done in a portable manner, so you'll
need a platform-specific solution. Unfortunately you
forgot to tell what platform and operating system
you are interested in.
I'd say such thing would be rather difficult to accomplish,
why not use a profiler instead? Some platforms, like most
of the newel Intels have hardware instruction counters,
maybe these will provide the functionality you're after?
HTH,
- J.