Am 22.08.2014 um 19:48 schrieb Dan Liew: > The documentation [1] doesn't define these very clearly. The grammar > for ``JumpSpecification`` doesn't seem to be specified properly.
Oops, indeed. Thanks for the notification. > * 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. The "target position" is a "SubPositionList" in the grammar, the same as in the beginning of a CostLine. The "positions:" header line defines which subpositions there are, and in your example there are two: "instr line". The first number is an address for the machine code, and the second number is the line in a source file. Subpositions can be specified to be relative to the a subposition given directly before, by prefixing it with "-" or "+". > 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 Why not just "positions: line" ? The instruction address you specify below is always the same as the line number. That makes not much sense. The instruction address is needed for KCachegrind to show annotated machine code, using "objdump <binary>", but your example does not specify a binary file using "ob=" anyway. > 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 "+1" is not a dummy offset, but is the instruction address of the jump target, which is relative to the previous position specifed in your example in the line above, ie. the first two numbers of "14 14 9". Thus, your line is the same as "jump=5 15 19" or "jump=5 +1 +5". > 14 14 Yes. Similar to calls, "jump="/"jcnd=" lines need to be followed by a line specifying the source position of the jump. By the way, if your jump crosses a source file or a function, you may specify the source file of the jump target with "jfi=" and the target function name with "jfn=" before a the "jump="/"jcnd" line. > jcnd=<followed_count>/<total_count> <target> <target_line> > <position> Better: ============= jcnd=<followed_count>/<total_count> <jump target position> <jump source position> ============== where a <position> is one or two numbers, depending on the "positions:" header line. If source line numbers are enough for you, just do ============== positions: line .... # jump 2 of 8 times, from line 10 to 20 jcnd=1/8 20 10 ... =============== Cheers, Josef > ``` > > 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, > ------------------------------------------------------------------------------ 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