Re: oprofile callgraph support missing for common cpus
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2011-12-05 09:01:49
On Mon, 2011-12-05 at 09:50 +0100, Joakim Tjernlund wrote:
Benjamin Herrenschmidt [off-list ref] wrote on 2011/11/25 06:24:32:quoted
On Fri, 2011-11-18 at 09:22 +0100, Joakim Tjernlund wrote:quoted
I forgot to ask, oprofile mentions setting -no-omit-framepointer to get correct backtrace but I cannot turn on frame pointers for the ppc kernel. Isn't frame pointers needed for pcc? what about user space?PowerPC always has frame pointers, ignore that :-)A bit late but consider this:
.../... Right I wasn't clear. We do have frame pointers for non-leaf functions, and we can trace from LR when we are on a leaf function, we can use __builtin_return_address as well. We also explicitely prevent -fno-omit-frame-pointer, iirc, due to a bug with older versions of gcc which could cause miscompiles under some circumstances (though I don't remember the details). Cheers, Ben.
int leaf(int x)
{
return x+3;
}
which yields(with gcc -O2 -S):
.file "leaf.c"
.section ".text"
.align 2
.globl leaf
.type leaf, @function
leaf:
addi 3,3,3
blr
.size leaf, .-leaf
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.4.6 (Gentoo 3.4.6-r2, ssp-3.4.6-1.0, pie-8.7.9)"
Here there is with frame pointer(I guess that the messing around with r11 and r31 is a defect?):
(With gcc -O2 -S -fno-omit-frame-pointer)
.file "leaf.c"
.section ".text"
.align 2
.globl leaf
.type leaf, @function
leaf:
stwu 1,-16(1)
addi 3,3,3
lwz 11,0(1)
stw 31,12(1)
mr 31,1
lwz 31,-4(11)
mr 1,11
blr
.size leaf, .-leaf
.section .note.GNU-stack,"",@progbits
.ident "GCC: (GNU) 3.4.6 (Gentoo 3.4.6-r2, ssp-3.4.6-1.0, pie-8.7.9)"