From: compudj Date: Wed, 21 Jan 2009 22:24:26 +0000 (+0000) Subject: move test marker-loader to attic X-Git-Tag: v0.12.20~246 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7a7f673795d642df5730e96ac899f0ab5b54ff77;p=lttv.git move test marker-loader to attic git-svn-id: http://ltt.polymtl.ca/svn@3243 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/trunk/attic/marker-loader/Makefile b/trunk/attic/marker-loader/Makefile new file mode 100644 index 00000000..40ff6da0 --- /dev/null +++ b/trunk/attic/marker-loader/Makefile @@ -0,0 +1,31 @@ + +export MARKER_CFLAGS + +MARKER_CFLAGS := -DCALL="__mark_$(TARGET)_call" -DJUMP_OVER="__mark_$(TARGET)_jump_over" +MARKER_CFLAGS += -DJUMP_CALL="__mark_$(TARGET)_jump_call" -DJUMP_INLINE="__mark_$(TARGET)_jump_inline" + +EXTRA_CFLAGS += $(MARKER_CFLAGS) + +ifneq ($(KERNELRELEASE),) + +obj-m += marker-loader.o + +else + KERNELDIR ?= /lib/modules/$(shell uname -r)/build + PWD := $(shell pwd) + KERNELRELEASE = $(shell cat $(KERNELDIR)/$(KBUILD_OUTPUT)/include/linux/version.h | sed -n 's/.*UTS_RELEASE.*\"\(.*\)\".*/\1/p') +ifneq ($(INSTALL_MOD_PATH),) + DEPMOD_OPT := -b $(INSTALL_MOD_PATH) +endif + +default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules + +modules_install: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install + if [ -f $(KERNELDIR)/$(KBUILD_OUTPUT)/System.map ] ; then /sbin/depmod -ae -F $(KERNELDIR)/$(KBUILD_OUTPUT)/System.map $(DEPMOD_OPT) $(KERNELRELEASE) ; fi + + +clean: + $(MAKE) -C $(KERNELDIR) M=$(PWD) clean +endif diff --git a/trunk/attic/marker-loader/marker-loader.c b/trunk/attic/marker-loader/marker-loader.c new file mode 100644 index 00000000..b02e6b56 --- /dev/null +++ b/trunk/attic/marker-loader/marker-loader.c @@ -0,0 +1,84 @@ +/* marker-loader.c + * + * Marker Loader + * + * Loads a function at a marker call site. + * + * (C) Copyright 2006 Mathieu Desnoyers + * + * This file is released under the GPLv2. + * See the file COPYING for more details. + */ + +#include +#include +#include + +/* function to install */ +void do_mark1(const char *format, int value) +{ + printk("value is %d\n", value); +} + +static void *saved_over; + +static void **target_mark_call; +static void **target_mark_jump_over; +static void **target_mark_jump_call; +static void **target_mark_jump_inline; + +void show_symbol_pointers(void) +{ + printk("Marker loader : Loading symbols...\n"); + printk(" %s %p %p\n", __stringify(CALL), target_mark_call, + target_mark_call?*target_mark_call:0x0); + printk(" %s %p %p\n", __stringify(JUMP_OVER), target_mark_jump_over, + target_mark_jump_over?*target_mark_jump_over:0x0); + printk(" %s %p %p\n", __stringify(JUMP_CALL), target_mark_jump_call, + target_mark_jump_call?*target_mark_jump_call:0x0); + printk(" %s %p %p\n", __stringify(JUMP_INLINE), target_mark_jump_inline, + target_mark_jump_inline?*target_mark_jump_inline:0x0); +} + +int mark_install_hook(void) +{ + target_mark_call = (void**)kallsyms_lookup_name(__stringify(CALL)); + target_mark_jump_over = (void**)kallsyms_lookup_name(__stringify(JUMP_OVER)); + target_mark_jump_call = (void**)kallsyms_lookup_name(__stringify(JUMP_CALL)); + target_mark_jump_inline = (void**)kallsyms_lookup_name(__stringify(JUMP_INLINE)); + + show_symbol_pointers(); + + if(!(target_mark_call && target_mark_jump_over && target_mark_jump_call && + target_mark_jump_inline)) { + printk("Target symbols missing in kallsyms.\n"); + return -EPERM; + } + + printk("Installing hook\n"); + *target_mark_call = (void*)do_mark1; + saved_over = *target_mark_jump_over; + *target_mark_jump_over = *target_mark_jump_call; + + return 0; +} + +int init_module(void) +{ + return mark_install_hook(); +} + +void cleanup_module(void) +{ + printk("Removing hook\n"); + *target_mark_jump_over = saved_over; + *target_mark_call = __mark_empty_function; + + /* Wait for instrumentation functions to return before quitting */ + synchronize_sched(); +} + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Mathieu Desnoyers"); +MODULE_DESCRIPTION("Marker Loader"); + diff --git a/trunk/marker-loader/Makefile b/trunk/marker-loader/Makefile deleted file mode 100644 index 40ff6da0..00000000 --- a/trunk/marker-loader/Makefile +++ /dev/null @@ -1,31 +0,0 @@ - -export MARKER_CFLAGS - -MARKER_CFLAGS := -DCALL="__mark_$(TARGET)_call" -DJUMP_OVER="__mark_$(TARGET)_jump_over" -MARKER_CFLAGS += -DJUMP_CALL="__mark_$(TARGET)_jump_call" -DJUMP_INLINE="__mark_$(TARGET)_jump_inline" - -EXTRA_CFLAGS += $(MARKER_CFLAGS) - -ifneq ($(KERNELRELEASE),) - -obj-m += marker-loader.o - -else - KERNELDIR ?= /lib/modules/$(shell uname -r)/build - PWD := $(shell pwd) - KERNELRELEASE = $(shell cat $(KERNELDIR)/$(KBUILD_OUTPUT)/include/linux/version.h | sed -n 's/.*UTS_RELEASE.*\"\(.*\)\".*/\1/p') -ifneq ($(INSTALL_MOD_PATH),) - DEPMOD_OPT := -b $(INSTALL_MOD_PATH) -endif - -default: - $(MAKE) -C $(KERNELDIR) M=$(PWD) modules - -modules_install: - $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install - if [ -f $(KERNELDIR)/$(KBUILD_OUTPUT)/System.map ] ; then /sbin/depmod -ae -F $(KERNELDIR)/$(KBUILD_OUTPUT)/System.map $(DEPMOD_OPT) $(KERNELRELEASE) ; fi - - -clean: - $(MAKE) -C $(KERNELDIR) M=$(PWD) clean -endif diff --git a/trunk/marker-loader/marker-loader.c b/trunk/marker-loader/marker-loader.c deleted file mode 100644 index b02e6b56..00000000 --- a/trunk/marker-loader/marker-loader.c +++ /dev/null @@ -1,84 +0,0 @@ -/* marker-loader.c - * - * Marker Loader - * - * Loads a function at a marker call site. - * - * (C) Copyright 2006 Mathieu Desnoyers - * - * This file is released under the GPLv2. - * See the file COPYING for more details. - */ - -#include -#include -#include - -/* function to install */ -void do_mark1(const char *format, int value) -{ - printk("value is %d\n", value); -} - -static void *saved_over; - -static void **target_mark_call; -static void **target_mark_jump_over; -static void **target_mark_jump_call; -static void **target_mark_jump_inline; - -void show_symbol_pointers(void) -{ - printk("Marker loader : Loading symbols...\n"); - printk(" %s %p %p\n", __stringify(CALL), target_mark_call, - target_mark_call?*target_mark_call:0x0); - printk(" %s %p %p\n", __stringify(JUMP_OVER), target_mark_jump_over, - target_mark_jump_over?*target_mark_jump_over:0x0); - printk(" %s %p %p\n", __stringify(JUMP_CALL), target_mark_jump_call, - target_mark_jump_call?*target_mark_jump_call:0x0); - printk(" %s %p %p\n", __stringify(JUMP_INLINE), target_mark_jump_inline, - target_mark_jump_inline?*target_mark_jump_inline:0x0); -} - -int mark_install_hook(void) -{ - target_mark_call = (void**)kallsyms_lookup_name(__stringify(CALL)); - target_mark_jump_over = (void**)kallsyms_lookup_name(__stringify(JUMP_OVER)); - target_mark_jump_call = (void**)kallsyms_lookup_name(__stringify(JUMP_CALL)); - target_mark_jump_inline = (void**)kallsyms_lookup_name(__stringify(JUMP_INLINE)); - - show_symbol_pointers(); - - if(!(target_mark_call && target_mark_jump_over && target_mark_jump_call && - target_mark_jump_inline)) { - printk("Target symbols missing in kallsyms.\n"); - return -EPERM; - } - - printk("Installing hook\n"); - *target_mark_call = (void*)do_mark1; - saved_over = *target_mark_jump_over; - *target_mark_jump_over = *target_mark_jump_call; - - return 0; -} - -int init_module(void) -{ - return mark_install_hook(); -} - -void cleanup_module(void) -{ - printk("Removing hook\n"); - *target_mark_jump_over = saved_over; - *target_mark_call = __mark_empty_function; - - /* Wait for instrumentation functions to return before quitting */ - synchronize_sched(); -} - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Mathieu Desnoyers"); -MODULE_DESCRIPTION("Marker Loader"); -