I am hoping to find something similar to strace which will yield the instructions used by the CPU. For example, I have a simple loop which calculates a sum and prints out every tenth iteration
float fsum = 0.0;
for(int i = 0; i < 1000; i++) {
if(i%10==0) {
fprintf(stderr, "%10.5f%%\n", 100.0*float(i)/float(1000));
}
fsum += 1.0/float(i);
}
Now, strace will give information about the fprintf statement since that is a write(2 statement, but it gives no information about the summation steps. If I want to get information about a currently running program including the CPU instructions used, is there a way to do that?
NOTE: I know about tools such as gprof which require prior compilation. I am searching for a way to find the same information that gprof might give you, but with a CURRENTLY running program which may or may not have been compiled with profiling in mind.