Commit 230c77a5 authored by Guo Ren's avatar Guo Ren
Browse files

csky: basic ftrace supported



When gcc with -pg, it'll add _mcount stub in every function. We need
implement the _mcount in kernel and ftrace depends on stackstrace.

To do: call-graph, dynamic ftrace

Signed-off-by: default avatarGuo Ren <ren_guo@c-sky.com>
parent 17a68777
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ config CSKY
	select GENERIC_SCHED_CLOCK
	select GENERIC_SMP_IDLE_THREAD
	select HAVE_ARCH_TRACEHOOK
	select HAVE_FUNCTION_TRACER
	select HAVE_GENERIC_DMA_COHERENT
	select HAVE_KERNEL_GZIP
	select HAVE_KERNEL_LZO
+1 −0
Original line number Diff line number Diff line
@@ -8,3 +8,4 @@ obj-y += strcmp.o
obj-y				+= strcpy.o
obj-y				+= strlen.o
obj-y				+= strksyms.o
obj-$(CONFIG_FUNCTION_TRACER)	+= mcount.o
+24 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#include <linux/linkage.h>

ENTRY (_mcount)
	subi	sp, 20
	stw	a0, (sp, 0)
	stw	a1, (sp, 4)
	stw	a2, (sp, 8)
	stw	a3, (sp, 12)
	stw	lr, (sp, 16)
	mov	a1, lr
	ldw	a0, (sp, 20)
	jsri    csky_mcount
	ldw	a0, (sp, 0)
	ldw	a1, (sp, 4)
	ldw	a2, (sp, 8)
	ldw	a3, (sp, 12)
	ldw	t1, (sp, 16)
	ldw	lr, (sp, 20)
	addi	sp, 24
	jmp	t1
END (_mcount)
+9 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.

#ifndef __ASM_CSKY_FTRACE_H
#define __ASM_CSKY_FTRACE_H

extern void _mcount(unsigned long from_pc);

#endif /* __ASM_CSKY_FTRACE_H */
+5 −0
Original line number Diff line number Diff line
@@ -6,4 +6,9 @@ obj-y += process.o cpu-probe.o ptrace.o dumpstack.o

obj-$(CONFIG_MODULES)			+= module.o
obj-$(CONFIG_SMP)			+= smp.o
obj-$(CONFIG_FUNCTION_TRACER)		+= ftrace.o
obj-$(CONFIG_STACKTRACE)		+= stacktrace.o

ifdef CONFIG_FUNCTION_TRACER
CFLAGS_REMOVE_ftrace.o = $(CC_FLAGS_FTRACE)
endif
Loading