initial usertrace syscall and signal
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 25 Jan 2006 21:21:29 +0000 (21:21 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 25 Jan 2006 21:21:29 +0000 (21:21 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1491 04897980-b3bd-0310-b5e0-8ef037075253

usertrace/Makefile [new file with mode: 0644]
usertrace/lttng_usertrace.c [new file with mode: 0644]
usertrace/lttng_usertrace.h [new file with mode: 0644]
usertrace/test.c [new file with mode: 0644]

diff --git a/usertrace/Makefile b/usertrace/Makefile
new file mode 100644 (file)
index 0000000..049c44b
--- /dev/null
@@ -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 (file)
index 0000000..b4de267
--- /dev/null
@@ -0,0 +1,48 @@
+
+/* LTTng user-space tracing code
+ *
+ * Copyright 2006 Mathieu Desnoyers
+ *
+ */
+
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
+#include <syscall.h>
+
+#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 (file)
index 0000000..c16aa78
--- /dev/null
@@ -0,0 +1,31 @@
+
+/* LTTng user-space tracing header
+ *
+ * Copyright 2006 Mathieu Desnoyers
+ *
+ */
+
+#ifndef _LTTNG_USERTRACE_H
+#define _LTTNG_USERTRACE_H
+
+#include <errno.h>
+#include <syscall.h>
+
+//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 (file)
index 0000000..0154f3c
--- /dev/null
@@ -0,0 +1,13 @@
+
+#include "lttng_usertrace.h"
+
+int main()
+{
+
+  while(1)
+  {
+    
+  }
+  
+  return 0;
+}
This page took 0.028215 seconds and 4 git commands to generate.