Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c63a1642 authored by Jovi Zhangwei's avatar Jovi Zhangwei Committed by Greg Kroah-Hartman
Browse files

staging: ktap: add to the kernel tree

This patch introduces ktap to staging tree.

ktap is a new script-based dynamic tracing tool for Linux,
it uses a scripting language and lets users trace the
Linux kernel dynamically. ktap is designed to give
operational insights with interoperability that allow
users to tune, troubleshoot and extend kernel and application.
It's similar with Linux Systemtap and Solaris Dtrace.

ktap have different design principles from Linux mainstream
dynamic tracing language in that it's based on bytecode,
so it doesn't depend upon GCC, doesn't require compiling
kernel module for each script, safe to use in production
environment, fulfilling the embedded ecosystem's tracing needs.

See ktap tutorial for more information:
    http://www.ktap.org/doc/tutorial.html



The merit of putting this software in staging tree is
to make it more possible to get feedback from users
and thus polish the code.

Signed-off-by: default avatarJovi Zhangwei <jovi.zhangwei@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 67aa4acb
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -4748,6 +4748,13 @@ S: Maintained
F:	Documentation/hwmon/k8temp
F:	drivers/hwmon/k8temp.c

KTAP
M:	zhangwei(Jovi) <jovi.zhangwei@gmail.com>
W:	http://www.ktap.org
L:	ktap@freelists.org
S:	Maintained
F:	drivers/staging/ktap/

KCONFIG
M:	Michal Marek <mmarek@suse.cz>
L:	linux-kbuild@vger.kernel.org
+2 −0
Original line number Diff line number Diff line
@@ -150,4 +150,6 @@ source "drivers/staging/dgnc/Kconfig"

source "drivers/staging/dgap/Kconfig"

source "drivers/staging/ktap/Kconfig"

endif # STAGING
+1 −0
Original line number Diff line number Diff line
@@ -67,3 +67,4 @@ obj-$(CONFIG_XILLYBUS) += xillybus/
obj-$(CONFIG_DGNC)			+= dgnc/
obj-$(CONFIG_DGAP)			+= dgap/
obj-$(CONFIG_MTD_SPINAND_MT29F)	+= mt29f_spinand/
obj-$(CONFIG_KTAP)		+= ktap/
+21 −0
Original line number Diff line number Diff line
config KTAP
	tristate "a programable dynamic tracing tool for Linux"
	depends on PERF_EVENTS && EVENT_TRACING
	default n
	help
	  ktap is a new script-based dynamic tracing tool for Linux,
	  it uses a scripting language and lets users trace the
	  Linux kernel dynamically. ktap is designed to give
	  operational insights with interoperability that allow
	  users to tune, troubleshoot and extend kernel and application.
	  It's similar with Linux Systemtap and Solaris Dtrace.

	  ktap have different design principles from Linux mainstream
	  dynamic tracing language in that it's based on bytecode,
	  so it doesn't depend upon GCC, doesn't require compiling
	  kernel module for each script, safe to use in production
	  environment, fulfilling the embedded ecosystem's tracing needs.

	  See ktap tutorial for more information:
	      http://www.ktap.org/doc/tutorial.html
+101 −0
Original line number Diff line number Diff line

# Do not instrument the tracer itself:
ifdef CONFIG_FUNCTION_TRACER
ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS))
endif

all: mod ktap

INTP = interpreter

LIBDIR = $(INTP)/library

LIB_OBJS += $(LIBDIR)/baselib.o $(LIBDIR)/kdebug.o $(LIBDIR)/timer.o \
		$(LIBDIR)/ansilib.o

INTP_OBJS += $(INTP)/ktap.o $(INTP)/loader.o $(INTP)/object.o \
		$(INTP)/tstring.o $(INTP)/table.o $(INTP)/vm.o \
		$(INTP)/opcode.o $(INTP)/strfmt.o $(INTP)/transport.o \
		$(LIB_OBJS)

obj-m		+= ktapvm.o
ktapvm-y	:= $(INTP_OBJS)

KVERSION ?= $(shell uname -r)
KERNEL_SRC ?= /lib/modules/$(KVERSION)/build
mod:
	$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules

modules_install:
	$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install

KTAPC_CFLAGS = -Wall -O2

UDIR = userspace

$(UDIR)/lex.o: $(UDIR)/lex.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/parser.o: $(UDIR)/parser.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/code.o: $(UDIR)/code.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/dump.o: $(UDIR)/dump.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/main.o: $(UDIR)/main.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/util.o: $(UDIR)/util.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/ktapio.o: $(UDIR)/ktapio.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/eventdef.o: $(UDIR)/eventdef.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/opcode.o: $(INTP)/opcode.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/table.o: $(INTP)/table.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/tstring.o: $(INTP)/tstring.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<
$(UDIR)/object.o: $(INTP)/object.c
	$(QUIET_CC)$(CC) $(DEBUGINFO_FLAG) $(KTAPC_CFLAGS) -o $@ -c $<

KTAPOBJS =
KTAPOBJS += $(UDIR)/lex.o
KTAPOBJS += $(UDIR)/parser.o
KTAPOBJS += $(UDIR)/code.o
KTAPOBJS += $(UDIR)/dump.o
KTAPOBJS += $(UDIR)/main.o
KTAPOBJS += $(UDIR)/util.o
KTAPOBJS += $(UDIR)/ktapio.o
KTAPOBJS += $(UDIR)/eventdef.o
KTAPOBJS += $(UDIR)/opcode.o
KTAPOBJS += $(UDIR)/table.o
KTAPOBJS += $(UDIR)/tstring.o
KTAPOBJS += $(UDIR)/object.o

ktap: $(KTAPOBJS)
	$(QUIET_LINK)$(CC) $(KTAPC_CFLAGS) -o $@ $(KTAPOBJS) -lpthread

KMISC := /lib/modules/$(KVERSION)/ktapvm/

install: mod ktap
	install -d $(KMISC)
	install -m 644 -c *.ko /lib/modules/$(KVERSION)/ktapvm/
	/sbin/depmod -a

load:
	insmod ktapvm.ko

unload:
	rmmod ktapvm

test: FORCE
	cd test; sh ./run_test.sh; cd -

clean:
	$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
	$(RM) ktap

PHONY += FORCE
FORCE:
Loading