> John Lamb wrote:
>> cincaipatron(a)gmx.net wrote:
>>> how to get the assembly-instructions profile of a program
>>> in Linux (or Unix in general), similar with what gprof
>>> does, just that gprof is in higher-language (C/C++) level?
>> I'm not entirely sure what you mean, but g++/gcc -S might be what you
>> want. It creates a file 'file.s' with the assembly instructions in it.
> Well, seems that I need more than what gcc -S provides, because
> it's like producing the "source code" in assembly languages.
> What I'm looking for is something similar with what gprof does,
> such as which instruction is called most often, how many times,
> etc., or maybe the assembly-instruction is part of which function
> (in C/C++).
If you have already narrowed down your search to a handful of
instructions, you can use gdb to do this. Just place a breakpoint on
each instruction you are interested in, and set a large "ignore" count
on the breakpoints. Then when the program is done, or a breakpoint
counts down to zero and triggers, you can use "info breakpoints" to
see how many times each breakpoint has been hit.
If you are looking for hotpoints in an entire program, you might want
to look into hacking an emulator to maintain a counter for every
instruction byte -- incrementing it every time the program counter
> So far I know two types of profiling tools: gprof and memory
> profiler (valgrind and friends); I don't know if what I mentioned
> is available or people have ever done it.
What exactly is it that you want to do with the tool that you cannot
do with gprof and gdb? Perhaps if you explained what you feel you
need it for, people could point you to a ready made solution to the
problem. If you are just looking for a project that has not been done
before (to our knowledge), then hacking an existing emulator to count
instruction usage, and perhaps even keeping track of pipeline stalls
caused by bad instruction order, is a project worth doing in my