From b8b006881f98b1193db5c45ef8f2d054f6b02f39 Mon Sep 17 00:00:00 2001 From: compudj Date: Wed, 25 Jan 2006 21:21:29 +0000 Subject: [PATCH] initial usertrace syscall and signal git-svn-id: http://ltt.polymtl.ca/svn@1491 04897980-b3bd-0310-b5e0-8ef037075253 --- usertrace/Makefile | 8 +++++++ usertrace/lttng_usertrace.c | 48 +++++++++++++++++++++++++++++++++++++ usertrace/lttng_usertrace.h | 31 ++++++++++++++++++++++++ usertrace/test.c | 13 ++++++++++ 4 files changed, 100 insertions(+) create mode 100644 usertrace/Makefile create mode 100644 usertrace/lttng_usertrace.c create mode 100644 usertrace/lttng_usertrace.h create mode 100644 usertrace/test.c diff --git a/usertrace/Makefile b/usertrace/Makefile new file mode 100644 index 00000000..049c44bf --- /dev/null +++ b/usertrace/Makefile @@ -0,0 +1,8 @@ + +test: test.c lttng_usertrace.c + $(CC) $(CFLAGS) -o $@ $^ + +.PHONY : clean + +clean: + rm -fr *.o *~ test diff --git a/usertrace/lttng_usertrace.c b/usertrace/lttng_usertrace.c new file mode 100644 index 00000000..b4de2676 --- /dev/null +++ b/usertrace/lttng_usertrace.c @@ -0,0 +1,48 @@ + +/* LTTng user-space tracing code + * + * Copyright 2006 Mathieu Desnoyers + * + */ + + +#include +#include +#include +#include +#include +#include + +#include "lttng_usertrace.h" + +/* signal handler */ +void __lttng_sig_trace_handler(int signo) +{ + printf("LTTng Sig handler : pid : %lu\n", getpid()); +} + + + +void __attribute__((constructor)) __lttng_user_init(void) +{ + static struct sigaction act; + int err; + + printf("LTTng user init\n"); + + /* Activate the signal */ + act.sa_handler = __lttng_sig_trace_handler; + err = sigemptyset(&(act.sa_mask)); + if(err) perror("Error with sigemptyset"); + err = sigaddset(&(act.sa_mask), SIGRTMIN+3); + if(err) perror("Error with sigaddset"); + err = sigaction(SIGRTMIN+3, &act, NULL); + if(err) perror("Error with sigaction"); + + /* Make the first ltt_update system call */ + err = ltt_update(1, NULL, NULL); + if(err) { + printf("Error in ltt_update system call\n"); + exit(1); + } +} diff --git a/usertrace/lttng_usertrace.h b/usertrace/lttng_usertrace.h new file mode 100644 index 00000000..c16aa781 --- /dev/null +++ b/usertrace/lttng_usertrace.h @@ -0,0 +1,31 @@ + +/* LTTng user-space tracing header + * + * Copyright 2006 Mathieu Desnoyers + * + */ + +#ifndef _LTTNG_USERTRACE_H +#define _LTTNG_USERTRACE_H + +#include +#include + +//Put in asm-i486/unistd.h +#define __NR_ltt_update 294 +#define __NR_ltt_switch 295 + +#undef NR_syscalls +#define NR_syscalls 296 + +#ifndef _LIBC +// Put in bits/syscall.h +#define SYS_ltt_update __NR_ltt_update +#define SYS_ltt_switch __NR_ltt_switch +#endif + +void __lttng_sig_trace_handler(int signo); + +static inline _syscall3(int, ltt_update, unsigned long, addr, int *, active, int *, filter) + +#endif //_LTTNG_USERTRACE_H diff --git a/usertrace/test.c b/usertrace/test.c new file mode 100644 index 00000000..0154f3ca --- /dev/null +++ b/usertrace/test.c @@ -0,0 +1,13 @@ + +#include "lttng_usertrace.h" + +int main() +{ + + while(1) + { + + } + + return 0; +} -- 2.34.1