Hi, I'm hoping to use the callgrind profile file format for an interpreter I'm working on so I can visualise various parameters using KCacheGrind.
So far this has looked very promising but I've run into an issue with jumps (jump= and jcnd=) The documentation [1] doesn't define these very clearly. The grammar for ``JumpSpecification`` doesn't seem to be specified properly. Later on the docs note the following. ``` * jump=count target position [Callgrind] Unconditional jump, executed count times, to the given target position. * jcnd=exe.count jumpcount target position [Callgrind] Conditional jump, executed exe.count times with jumpcount jumps to the given target position. ``` It's not defined what ``target`` is but after looking at what callgrind produces it seems that is some sort of offset (e.g. +5). What I see produced by callgrind doesn't really seem to match the above. After playing around with a simple profile file and KCacheGrind it seemed that to get what I want (KCachegrind to show jump arrows for my source code without emitting parser warnings) that I had to do this ``` positions: instr line events: Instructions fl=s.bpl fn=main # Specify cost for jump 14 14 9 # Unconditional jump happens 5 times, +1 is a dummy offset, to line 19 jump=5 +1 19 14 14 # Specify cost for unconditional jump 21 21 9 # Conditional jump to line 25 happens 1 out of 2 times (+1 is dummy offset) jcnd=1/2 +1 25 21 21 # Conditional jump to line 27 happens 1 out of 2 times (+1 is dummy offset) jcnd=1/2 +1 27 21 21 ``` So it seems jump the syntax is **actually** something like... ``` jump=<count> <target> <target_line> <position> ``` Where: <target> is ??? <target_line> is the line that we will jump to <position> is the location of the jump instruction. Note it's on the next line after jump= and for jcnd the syntax is **actually** something like... ``` jcnd=<followed_count>/<total_count> <target> <target_line> <position> ``` Where: <followed_count> - Number of times <target> was followed from this jump <total_count> - Number of times this jump was executed <target> is ??? <target_line> - line that this branch from the jump instruction jumps to <position> is location of the jump instruction. Note it's on the next line after jcnd= Is what I've guessed about the syntax correct? [1] http://valgrind.org/docs/manual/cl-format.html Thanks, -- Dan Liew PhD Student - Imperial College London ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users