csky/ftrace: Add dynamic function tracer (include graph tracer)
authorGuo Ren <ren_guo@c-sky.com>
Fri, 1 Mar 2019 00:50:36 +0000 (08:50 +0800)
committerGuo Ren <ren_guo@c-sky.com>
Mon, 22 Apr 2019 05:44:57 +0000 (13:44 +0800)
commit28bb030f93334495ddc64ade0bff18721bf7023d
treed0a4e4eaa36575adf490165f63d2bd6160653124
parent3dfc242f11d792535db774613c6fd1df565c2137
csky/ftrace: Add dynamic function tracer (include graph tracer)

Support dynamic ftrace including dynamic graph tracer. Gcc-csky with -pg
will produce call site in every function prologue and we can use these
call site to hook trace function.

gcc with -pg origin call site:
push lr
jbsr _mcount
nop32
nop32

If the (callee - caller)'s offset is in range of bsr instruction, we'll
modify code with:
push lr
bsr _mcount
nop32
nop32
Else if the (callee - caller)'s offset is out of bsr instrunction, we'll
modify code with:
push lr
movih r26, ...
ori r26, ...
jsr r26

(r26 is reserved for jsr link reg in csky abiv2 spec.)

Signed-off-by: Guo Ren <ren_guo@c-sky.com>
arch/csky/Kconfig
arch/csky/abiv2/mcount.S
arch/csky/include/asm/ftrace.h
arch/csky/kernel/ftrace.c
scripts/recordmcount.pl