From abfc20167f6cf648f80e35b88d2d4e02b9da991e Mon Sep 17 00:00:00 2001 From: compudj Date: Fri, 22 Sep 2006 21:24:35 +0000 Subject: [PATCH] update probe git-svn-id: http://ltt.polymtl.ca/svn@2135 04897980-b3bd-0310-b5e0-8ef037075253 --- tests/kernel/Makefile | 4 ++++ tests/kernel/probe.c | 42 +++++++++++++++++++++++++++++++++++----- tests/kernel/test-mark.c | 12 +++++++++--- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/tests/kernel/Makefile b/tests/kernel/Makefile index 60b38403..1b71f936 100644 --- a/tests/kernel/Makefile +++ b/tests/kernel/Makefile @@ -20,9 +20,13 @@ endif #obj-m += test-printk.o #obj-m += test-debugfs.o obj-m += test-mark.o + obj-m += test-mark-instrumented.o obj-m += probe.o #obj-m += marker-loader.o #obj-m += test-linuxtrace.o + + CFLAGS_test-mark-instrumented.o += -DFORCE_MARK_JUMP_INLINE + CFLAGS_test-mark.o += -funroll-all-loops else KERNELDIR ?= /lib/modules/$(shell uname -r)/build PWD := $(shell pwd) diff --git a/tests/kernel/probe.c b/tests/kernel/probe.c index 4651fc77..6c6b28d4 100644 --- a/tests/kernel/probe.c +++ b/tests/kernel/probe.c @@ -20,17 +20,49 @@ asmlinkage void do_mark1(const char *format, int value) printk("value is %d\n", value); } +#define DO_MARK2_FORMAT "%d %s" +asmlinkage void do_mark2(const char *format, int value, const char *string) +{ + __mark_check_format(DO_MARK2_FORMAT, value, string); + printk("value is %d %s\n", value, string); +} + +#define DO_MARK3_FORMAT "%d %s %s" +asmlinkage void do_mark3(const char *format, int value, const char *s1, + const char *s2) +{ + __mark_check_format(DO_MARK3_FORMAT, value, s1, s2); + printk("value is %d %s %s\n", value, s1, s2); +} + int init_module(void) { - return marker_set_probe("subsys_mark1", DO_MARK1_FORMAT, - (marker_probe_func*)do_mark1, - MARKER_CALL); + int result; + result = marker_set_probe("subsys_mark1", DO_MARK1_FORMAT, + (marker_probe_func*)do_mark1); + if(result) goto end; + result = marker_set_probe("subsys_mark2", DO_MARK2_FORMAT, + (marker_probe_func*)do_mark2); + if(result) goto cleanup1; + result = marker_set_probe("subsys_mark3", DO_MARK3_FORMAT, + (marker_probe_func*)do_mark3); + if(result) goto cleanup2; + + return -result; + +cleanup2: + marker_disable_probe("subsys_mark2", (marker_probe_func*)do_mark2); +cleanup1: + marker_disable_probe("subsys_mark1", (marker_probe_func*)do_mark1); +end: + return -result; } void cleanup_module(void) { - marker_disable_probe("subsys_mark1", (marker_probe_func*)do_mark1, - MARKER_CALL); + marker_disable_probe("subsys_mark1", (marker_probe_func*)do_mark1); + marker_disable_probe("subsys_mark2", (marker_probe_func*)do_mark2); + marker_disable_probe("subsys_mark3", (marker_probe_func*)do_mark3); } MODULE_LICENSE("GPL"); diff --git a/tests/kernel/test-mark.c b/tests/kernel/test-mark.c index a2ce7e12..72874fa4 100644 --- a/tests/kernel/test-mark.c +++ b/tests/kernel/test-mark.c @@ -7,15 +7,21 @@ #include #include -int x=7; +volatile int x=7; struct proc_dir_entry *pentry = NULL; static int my_open(struct inode *inode, struct file *file) { - MARK(subsys_mark1, "%d", 1); + unsigned int i; + + for(i=0; i<2; i++) { + MARK(subsys_mark1, "%d", 1); + x=i; + barrier(); + } MARK(subsys_mark2, "%d %s", 2, "blah2"); - MARK(subsys_mark3, "%d %s", x, "blah3"); + MARK(subsys_mark3, "%d %s %s", x, "blah3", "blah5"); return -EPERM; } -- 2.34.1