Thanks for the prompt response :)

<snip>

>> 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 "+".

Thanks. That makes things significantly clearer.

>> 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 reason was that when I tried using just "positions: line" that the
jump= and jcnd= stopped being displayed in KCacheGrind.  Now that
you've explained that "target position" is "SubPositionList" in the
grammar I've managed to use jump= and jcnd= with only using lines and
it works fine :)

> 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=" anywayl

On a slightly related note is it possible to specify an assembly file
rather than an object file? For example If I had a C program (say
foo.c) and its corresponding LLVM IR (foo.ll). I would like to display
both the C source code and the foo.ll file. When I tried using
obj=foo.ll however KCachegrind tried using objdump on that file and
gave up because foo.ll is just text and not a binary.

>> 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".

Thanks for explaining that. My comment was actually trying to say I
was considering +1 to be a dummy offset because I didn't care what it
was set.

>> 14 14
>
> Yes. Similar to calls, "jump="/"jcnd=" lines need to be followed by a line
> specifying the source position of the jump.

That probably ought to be documented. It's not obvious that it is
needed. I'm also surprised that the position of the jump isn't
specified on the same line.

> 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.

Thanks. Like ``cfn=`` does that change the function that subsequent
cost lines are in?

I don't see these in the documentation either so it would be nice if
they were documented.

-- 
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

Reply via email to