|
From: Jiayuan M. <jer...@gm...> - 2012-01-07 21:33:07
|
Dear all, I am trying to collect stats using callgrind for assembly code (I followed the steps for assembly instrumentation, and I was successful in obtaining assembly-line level event counts). valgrind --tool=callgrind --I1=32768,64,32 --D1=32768,64,32 --LL=8388608,64,128 --cache-sim=yes --branch-sim=no --simulate-wb=no --simulate-hwpref=yes --cacheuse=no --compress-strings=no --compress-pos=no -v my_program However, after using callgrind_annotate --auto=yes, there is no information for a particular function, say, "foo". The name of "foo" in the assembly is "_Z10foo". I checked and evidence show that this function, which is the core computational part, should be executed, so there should be some stats for it. I then trying to enforce callgrind to gather info for this function by adding "--toggle-collect=foo", after using callgrind_annotate, the result show empty stats. I also tried "--toggle-collect=_Z10foo", but it ends up the same result. Any suggestions? Thanks, Jiayuan |
|
From: John R. <jr...@bi...> - 2012-01-07 21:59:10
|
> However, after using callgrind_annotate --auto=yes, there is no information for a particular function, say, "foo". The name of "foo" in the assembly is "_Z10foo". I checked and evidence show that this function, which is the core computational part, should be executed, so there should be some stats
> for it.
What does the symbol table entry for _Z10foo say?
--- foo.S
foo: .globl foo
movl $5,%eax
ret
bar: .globl bar
.type bar,@function
movl $7,%eax
ret
.size bar,.-bar
---
$ gcc -c foo.S
$ readelf --symbols foo.o # readelf is in the binutils package
Num: Value Size Type Bind Vis Ndx Name
4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 foo
5: 0000000000000006 6 FUNC GLOBAL DEFAULT 1 bar
---
valgrind tools will ignore 'foo', but 'bar' will be measured.
Remember to insert ".type _Z10foo,@function" and ".size _Z10foo,.-_Z10foo"
into the source code.
--
|
|
From: Josef W. <Jos...@gm...> - 2012-01-09 19:17:50
|
On 07.01.2012 22:59, John Reiser wrote: >> However, after using callgrind_annotate --auto=yes, there is no information for a particular function, say, "foo". The name of "foo" in the assembly is "_Z10foo". I checked and evidence show that this function, which is the core computational part, should be executed, so there should be some stats >> for it. > Remember to insert ".type _Z10foo,@function" and ".size _Z10foo,.-_Z10foo" > into the source code. Did this help? In any case, the cost should be attributed to some function, which probably just has the hex address of the entry as name. But you will miss the instruction-wise annotation. "callgrind_annotate" only can annotate source, ie. for assembly you have to compile the assembly as source, as you found out. However, this is not needed for the GUI kcachegrind. If you add "--dump-instr=yes" to callgrind, kcachegrind can show you annotated assembly (it's running objdump on its own on the binary or shared lib). If KDE is too heavy as dependence, you can compile qcachegrind from sources (see kcachegrind.sf.net), which only needs Qt4.x Josef |