2

Does anyone know a good tool that would give me x86 instruction execution count. I have looked at gcov, but would like to look at other option that might help me. My Ultimate goal is to be able to call this function and give it the function I am interested in emulating/profiling and it would return the number of times each assembly line executed. Any suggestions are welcome :) Thanks

1

4 Answers 4

1

Qemu could help, but any way this kind of profiling will ruin your cache/pipeline profile and won't be useful.

7
  • Qemu requires modifications. I want something simple that would for example generate something like: 25 add %eax, 12(%esp) 25 j test 1 lea %ebx,16(%eax) were add and j are executed 25 times and lea is executed only once! i once came upon a scripting code that did such a thing, but accidently closed the webpage Dec 16, 2010 at 18:15
  • @Syntax_Error: it's not useful at all, and hardly could be called profiling. In most cases speed will depend of cache and pipeline, and not on these stats. Is it for a school project?
    – ruslik
    Dec 16, 2010 at 18:19
  • @ruslik: you are absolutely right, that is why I am not using the data for the speed. I just want to detect the most executing instruction in a function. Dec 16, 2010 at 18:22
  • @Syntax_Error: then use an emulator. Profilers do something completely different.
    – ruslik
    Dec 16, 2010 at 18:25
  • @ruslik: Im up to anything that can do so. are there any emulators that do it without the need of modifying the source code? Dec 16, 2010 at 18:31
0

If you are looking for instructions that account for a significant percent of time, and if you can run it under a debugger, then this will work. It will isolate code points that are responsible for significant time, whether they are terminal instructions or function call instructions, even if they cause I/O.

Tools that will do this are Zoom, if you are on Linux, or LTProf if on Windows.

On the other hand, if you are looking for time measurement and execution counting, you will need something else, like an emulator (Valgrind?).

2
  • Thanks Mike. However I am doing tests on benchmarks so I dont have the flexibility of modifying the source code so I can't manually do it for such kernels. My ultimate goal is to be able to call this function and give it assembly files and it will emulate or profile the specific function and give me each instruction execution count. Do you know of any? Dec 16, 2010 at 18:42
  • @Syntax_Error: You shouldn't have to modify the source code, but nevertheless, since you're more interesting in timing than in speedups, an emulator like Valgrind might be able to do what you need. Good luck. Dec 16, 2010 at 22:23
0

AMD's code analyst should be able to do this using instruction based sampling, I can't remember if it gives percentages or flat numbers for execution counts though.

0

You could slap together a program like that pretty easily on Linux, just use ptrace in combination with objdump and some logic, should be easy to write in asm.

I got the idea from How to code debuggers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.