https://sourceware.org/bugzilla/show_bug.cgi?id=32886
Bug ID: 32886
Summary: wrong mapping from instruction to line number
Product: binutils
Version: 2.44
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gprofng
Assignee: vladimir.mezentsev at oracle dot com
Reporter: bruno at clisp dot org
Target Milestone: ---
Created attachment 16032
--> https://sourceware.org/bugzilla/attachment.cgi?id=16032&action=edit
gprofng-gui screenshot
I'm using GNU binutils 2.44 with GNU gprofng-gui 2.0 on x86_64. In the "Lines",
"Source", and "Source/Disassembly" views of the GUI, the counts on each line
and the line highlighting are misleading, because program counter (%rip) values
found on the stack are mapped to wrong line numbers.
Here's an example (but the problem occurs throughout the program!):
This code accesses the first element of a linked list. In the "experiment",
there are many long such linked lists.
=============================================
/* Access to first element of list. */
template <class KT>
INLINE KT *
Keyword_List<KT>::first () const
{
return _car;
}
=============================================
Find attached (gui.png) the Source/Disassembly view.
In both view parts (Source and Disassembly) view, the line that is highlighted
as consuming 7% of the Total CPU time is the instruction "pop %rbp",
corresponding to the function exit of method 'Keyword_List<KT>::first ()
const'.
But this is nonsense. A "pop %rbp" instruction executes quickly, because it's
done entirely within CPU and L1 cache. The instruction that takes 7% of the
Total CPU Time is instead the *previous* one, "mov 0x8(%rax),%rax". This is the
instruction that fetches the '_car' member of the class instance (linked list
node). That is because a linked-list representation of a list has bad cache
locality; in other words, there are many L1 or L2 cache misses at this point.
Therefore, the line that should be attributed with 7% of Total CPU Time and
with the yellow/orange highlight colour is
- in the Instruction part: mov 0x8(%rax),%rax
- in the Source part: return _car;
--
You are receiving this mail because:
You are on the CC list for the bug.