From c604f8bf7748c424c3b4e5cb2f41f9860648123b Mon Sep 17 00:00:00 2001 From: compudj Date: Sun, 3 Feb 2008 18:35:20 +0000 Subject: [PATCH] in progress... git-svn-id: http://ltt.polymtl.ca/svn@2812 04897980-b3bd-0310-b5e0-8ef037075253 --- markers-userspace/Makefile | 2 +- markers-userspace/kernel-api.h | 17 +++++++++++++++++ markers-userspace/marker-lib.c | 8 +++++++- markers-userspace/testprog.c | 6 +++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/markers-userspace/Makefile b/markers-userspace/Makefile index 1c9bd849..e770d737 100644 --- a/markers-userspace/Makefile +++ b/markers-userspace/Makefile @@ -15,4 +15,4 @@ testprog.S: testprog.c marker.h .PHONY: clean clean: - rm -f testprog testprog.S + rm -f testprog testprog.S marker-lib.o diff --git a/markers-userspace/kernel-api.h b/markers-userspace/kernel-api.h index ccdc2dc3..cb11aecd 100644 --- a/markers-userspace/kernel-api.h +++ b/markers-userspace/kernel-api.h @@ -5,6 +5,15 @@ #ifndef __KERNEL_API #define __KERNEL_API +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + #define DECLARE_IMV(type, name) extern __typeof__(type) name##__imv #define DEFINE_IMV(type, name) __typeof__(type) name##__imv @@ -28,4 +37,12 @@ */ #define _imv_read(name) (name##__imv) +#define __NR_marker 326 + +#define sys_marker(...) syscall(__NR_marker, __VA_ARGS__) + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif + #endif diff --git a/markers-userspace/marker-lib.c b/markers-userspace/marker-lib.c index d690e527..739c7580 100644 --- a/markers-userspace/marker-lib.c +++ b/markers-userspace/marker-lib.c @@ -1,6 +1,7 @@ #include "marker.h" #include +#include extern struct marker __start___markers[]; extern struct marker __stop___markers[]; @@ -33,16 +34,21 @@ void __mark_empty_function(void *probe_private, void *call_private, void marker_probe_cb(const struct marker *mdata, void *call_private, const char *fmt, ...) { + static unsigned int count = 0; - + printf("Test probe function %u\n", count++); } __attribute__((constructor)) void marker_init(void) { struct marker *iter; + int ret; printf("Marker section : from %p to %p\n", __start___markers, __stop___markers); + ret = sys_marker(__start___markers, __stop___markers); + if (ret) + perror("Error connecting markers"); for (iter = __start___markers; iter < __stop___markers; iter++) { printf("Marker : %s\n", iter->name); } diff --git a/markers-userspace/testprog.c b/markers-userspace/testprog.c index 037e1c19..5f25e830 100644 --- a/markers-userspace/testprog.c +++ b/markers-userspace/testprog.c @@ -1,4 +1,5 @@ #include +#include #include "marker.h" int main(int argc, char **argv) @@ -6,6 +7,9 @@ int main(int argc, char **argv) void *ptr; unsigned long val; - trace_mark(test_marker, "ptr %p val %lu", ptr, val); + while (1) { + trace_mark(test_marker, "ptr %p val %lu", ptr, val); + sleep(2); + } return 0; } -- 2.34.1