put files into attic
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 6 Apr 2006 23:15:46 +0000 (23:15 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 6 Apr 2006 23:15:46 +0000 (23:15 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1762 04897980-b3bd-0310-b5e0-8ef037075253

18 files changed:
attic/usertrace-attic/Makefile [new file with mode: 0644]
attic/usertrace-attic/lttng_usertrace.c [new file with mode: 0644]
attic/usertrace-attic/lttng_usertrace.h [new file with mode: 0644]
attic/usertrace-attic/test.c [new file with mode: 0644]
attic/usertrace-fast/Makefile [new file with mode: 0644]
attic/usertrace-fast/ltt-facility-loader-user_generic.c [new file with mode: 0644]
attic/usertrace-fast/ltt-facility-loader-user_generic.h [new file with mode: 0644]
attic/usertrace-fast/sample-instrument-fct.c [new file with mode: 0644]
attic/usertrace-fast/test.c [new file with mode: 0644]
usertrace-attic/Makefile [deleted file]
usertrace-attic/lttng_usertrace.c [deleted file]
usertrace-attic/lttng_usertrace.h [deleted file]
usertrace-attic/test.c [deleted file]
usertrace-fast/Makefile [deleted file]
usertrace-fast/ltt-facility-loader-user_generic.c [deleted file]
usertrace-fast/ltt-facility-loader-user_generic.h [deleted file]
usertrace-fast/sample-instrument-fct.c [deleted file]
usertrace-fast/test.c [deleted file]

diff --git a/attic/usertrace-attic/Makefile b/attic/usertrace-attic/Makefile
new file mode 100644 (file)
index 0000000..83c3b89
--- /dev/null
@@ -0,0 +1,11 @@
+
+
+CC=gcc
+
+test: test.c lttng_usertrace.c
+       $(CC) $(CFLAGS) -lpthread -o $@ $^
+
+.PHONY : clean
+
+clean:
+       rm -fr *.o *~ test
diff --git a/attic/usertrace-attic/lttng_usertrace.c b/attic/usertrace-attic/lttng_usertrace.c
new file mode 100644 (file)
index 0000000..5e32b0c
--- /dev/null
@@ -0,0 +1,252 @@
+
+/* LTTng user-space tracing code
+ *
+ * Copyright 2006 Mathieu Desnoyers
+ *
+ */
+
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <signal.h>
+#include <syscall.h>
+#include <features.h>
+#include <pthread.h>
+#include <malloc.h>
+#include <string.h>
+
+#include "lttng_usertrace.h"
+
+#define MAX_TRACES 16
+
+
+/*
+ * Notes :
+ *
+ * ltt_update :
+ *
+ * it should send the information on the traces that has their status MODIFIED.
+ * It's a necessary assumption to have a correct lttng_free_trace_info, which
+ * would not be reentrant otherwise.
+ */
+
+
+/* TLS for the trace info
+ * http://www.dis.com/gnu/gcc/C--98-Thread-Local-Edits.html
+ *
+ * Add after paragraph 4
+ *
+ *     The storage for an object of thread storage duration shall be statically
+ *     initialized before the first statement of the thread startup function. An
+ *     object of thread storage duration shall not require dynamic
+ *     initialization.
+ * GCC extention permits init of a range.
+ */
+
+static __thread struct lttng_trace_info lttng_trace_info[MAX_TRACES] =
+{      [ 0 ... MAX_TRACES-1 ].active = 0,
+       [ 0 ... MAX_TRACES-1 ].filter = 0,
+       [ 0 ... MAX_TRACES-1 ].destroy = 0,
+       [ 0 ... MAX_TRACES-1 ].nesting = ATOMIC_INIT(0),
+       [ 0 ... MAX_TRACES-1 ].channel = 
+               { NULL,
+                       0,
+                       ATOMIC_INIT(0),
+                       ATOMIC_INIT(0),
+                       ATOMIC_INIT(0),
+                       ATOMIC_INIT(0),
+                       ATOMIC_INIT(0)
+               }
+};
+
+
+/* Must be called we sure nobody else is using the info.
+ * It implies that the trace should have been previously stopped
+ * and that every writer has finished.
+ *
+ * Writers should always check if the trace must be destroyed when they
+ * finish writing and the nesting level is 0.
+ */
+void lttng_free_trace_info(struct lttng_trace_info *info)
+{
+       int ret;
+       
+       if(info->active) {
+               printf(
+               "LTTng ERROR : lttng_free_trace_info should be called on inactive trace\n");
+               exit(1);
+       }
+       if(!info->destroy) {
+               printf(
+               "LTTng ERROR : lttng_free_trace_info should be called on destroyed trace\n");
+               exit(1);
+       }
+       if(atomic_read(&info->nesting) > 0) {
+               printf(
+               "LTTng ERROR : lttng_free_trace_info should not be nested on tracing\n");
+               exit(1);
+       }
+       
+       /* Remove the maps */
+       ret = munmap(info->channel.cpu.start, info->channel.cpu.length);
+       if(ret) {
+               perror("LTTNG : error in munmap");
+       }
+       ret = munmap(info->channel.facilities.start, info->channel.facilities.length);
+       if(ret) {
+               perror("LTTNG : error in munmap");
+       }
+       
+       /* Zero the structure */
+       memset(info, 0, sizeof(struct lttng_trace_info));
+}
+
+
+static struct lttng_trace_info* find_info(unsigned long cpu_addr,
+               unsigned long fac_addr, unsigned int *first_empty)
+{
+       struct lttng_trace_info *found = NULL;
+       unsigned int i;
+
+       *first_empty = MAX_TRACES;
+
+       /* Try to find the trace */
+       for(i=0;i<MAX_TRACES;i++) {
+               if(i<*first_empty && !lttng_trace_info[i].channel.cpu.start)
+                       *first_empty = i;
+               if(cpu_addr == 
+                               (unsigned long)lttng_trace_info[i].channel.cpu.start &&
+                        fac_addr == 
+                               (unsigned long)lttng_trace_info[i].channel.facilities.start) {
+                       /* Found */
+                       found = &lttng_trace_info[i];
+                       break;
+               }
+       }
+       return found;
+}
+
+
+static void lttng_get_new_info(void)
+{
+       unsigned long cpu_addr, fac_addr;
+       unsigned int i, first_empty;
+       int active, filter, destroy;
+       int ret;
+       struct lttng_trace_info *info;
+       sigset_t set, oldset;
+
+       /* Disable signals */
+       ret = sigfillset(&set);
+       if(ret) {
+               printf("Error in sigfillset\n");
+               exit(1);
+       }
+       
+       ret = pthread_sigmask(SIG_BLOCK, &set, &oldset);
+       if(ret) {
+               printf("Error in sigprocmask\n");
+               exit(1);
+       }
+
+       /* Get all the new traces */
+       while(1) {
+               cpu_addr = fac_addr = 0;
+               active = filter = destroy = 0;
+               ret = ltt_update(&cpu_addr, &fac_addr, &active, &filter, &destroy);
+               if(ret) {
+                       printf("LTTng : error in ltt_update\n");
+                       exit(1);
+               }
+               
+               if(!cpu_addr || !fac_addr) break;
+               
+               info = find_info(cpu_addr, fac_addr, &first_empty);
+               if(info) {
+                       info->filter = filter;
+                       info->active = active;
+                       info->destroy = destroy;
+                       if(destroy && !atomic_read(&info->nesting))
+                               lttng_free_trace_info(info);
+               } else {
+                       /* Not found. Must take an empty slot */
+                       if(first_empty == MAX_TRACES) {
+                               printf(
+                               "LTTng WARNING : too many traces requested for pid %d by the kernel.\n"
+                               "                Compilation defined maximum is %u\n",
+                                       getpid(), MAX_TRACES);
+
+                       } else {
+                               info = &lttng_trace_info[first_empty];
+                               info->channel.cpu.start = (void*)cpu_addr;
+                               info->channel.cpu.length = PAGE_SIZE;
+                               info->channel.facilities.start = (void*)fac_addr;
+                               info->channel.facilities.length = PAGE_SIZE;
+                               info->filter = filter;
+                               info->active = active;
+                               info->destroy = destroy;
+                               if(destroy && !atomic_read(&info->nesting))
+                                       lttng_free_trace_info(info);
+                       }
+               }
+       }
+
+       /* Enable signals */
+       ret = pthread_sigmask(SIG_SETMASK, &oldset, NULL);
+       if(ret) {
+               printf("Error in sigprocmask\n");
+               exit(1);
+       }
+}
+
+
+/* signal handler */
+void __lttng_sig_trace_handler(int signo)
+{
+  printf("LTTng signal handler : thread id : %lu, pid %lu\n", pthread_self(), getpid());
+       lttng_get_new_info();
+}
+
+
+static void thread_init(void)
+{
+       int err;
+       lttng_get_new_info();
+
+       /* Make some ltt_switch syscalls */
+       err = ltt_switch((unsigned long)NULL);
+       if(err) {
+               printf("Error in ltt_switch system call\n");
+               exit(1);
+       }
+}
+
+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");
+
+       thread_init();
+}
+
+
+void lttng_thread_init(void)
+{
+       thread_init();
+}
+
+
diff --git a/attic/usertrace-attic/lttng_usertrace.h b/attic/usertrace-attic/lttng_usertrace.h
new file mode 100644 (file)
index 0000000..600be4f
--- /dev/null
@@ -0,0 +1,61 @@
+
+/* LTTng user-space tracing header
+ *
+ * Copyright 2006 Mathieu Desnoyers
+ *
+ */
+
+#ifndef _LTTNG_USERTRACE_H
+#define _LTTNG_USERTRACE_H
+
+#include <errno.h>
+#include <syscall.h>
+
+#include <asm/atomic.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
+
+struct ltt_buf {
+       void *start;
+       size_t length;
+       atomic_t        offset;
+       atomic_t        reserve_count;
+       atomic_t        commit_count;
+
+       atomic_t        events_lost;
+};
+
+struct lttng_trace_info {
+       int     active:1;
+       int destroy:1;
+       int filter;
+       atomic_t nesting;
+       struct {
+               struct ltt_buf facilities;
+               struct ltt_buf cpu;
+       } channel;
+};
+
+
+void __lttng_sig_trace_handler(int signo);
+
+/* Call this at the beginning of a new thread, except for the main() */
+void lttng_thread_init(void);
+
+void lttng_free_trace_info(struct lttng_trace_info *info);
+
+static inline _syscall1(int, ltt_switch, unsigned long, addr)
+static inline _syscall5(int, ltt_update, unsigned long *, cpu_addr, unsigned long *, fac_addr, int *, active, int *, filter, int *, destroy)
+
+#endif //_LTTNG_USERTRACE_H
diff --git a/attic/usertrace-attic/test.c b/attic/usertrace-attic/test.c
new file mode 100644 (file)
index 0000000..a0509a2
--- /dev/null
@@ -0,0 +1,59 @@
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include "lttng_usertrace.h"
+
+
+
+void *thr1(void *arg)
+{
+       lttng_thread_init();
+  printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+
+  while(1) {}
+
+  return ((void*)1);
+
+}
+
+void *thr2(void *arg)
+{
+       lttng_thread_init();
+
+  while(1) {
+    printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+    sleep(2);
+  }
+  return ((void*)2);
+}
+
+
+int main()
+{
+       int err;
+       pthread_t tid1, tid2;
+       void *tret;
+
+  printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+  err = pthread_create(&tid1, NULL, thr1, NULL);
+  if(err!=0) exit(1);
+
+  err = pthread_create(&tid2, NULL, thr2, NULL);
+  if(err!=0) exit(1);
+
+  while(1)
+  {
+    
+  }
+
+  err = pthread_join(tid1, &tret);
+  if(err!= 0) exit(1);
+
+  err = pthread_join(tid2, &tret);
+  if(err!= 0) exit(1);
+  
+  return 0;
+}
diff --git a/attic/usertrace-fast/Makefile b/attic/usertrace-fast/Makefile
new file mode 100644 (file)
index 0000000..d63a964
--- /dev/null
@@ -0,0 +1,42 @@
+
+LIB_DIR=/usr/lib
+INCLUDE_DIR=/usr/include
+
+RANLIB=ranlib
+
+CC=gcc
+CFLAGS=-I. -O3
+#CFLAGS+=-DLTT_SUBBUF_SIZE_CPU=134217728
+#CFLAGS+=-DLTT_NULL_OUTPUT_TEST
+
+all: test sample-instrument-fct libltt-instrument-functions.a libltt-instrument-functions.so.0 sample-loop
+
+test: test.c ltt-usertrace-fast.c
+       $(CC) $(CFLAGS) -I. -lpthread -o $@ $^
+
+
+sample-instrument-fct: sample-instrument-fct.c
+       $(CC) $(CFLAGS) -L. -g -finstrument-functions -lltt-instrument-functions -o $@ $^
+
+sample-loop: sample-loop.c ltt-usertrace-fast.o ltt-facility-loader-user_generic.o
+       $(CC) $(CFLAGS) -L. -lpthread -g -o $@ $^
+
+libltt-instrument-functions.a: ltt-instrument-functions.o ltt-facility-loader-user_generic.o ltt-usertrace-fast.o
+       @rm -f libltt-instrument-functions.a
+       $(AR) rc $@ $^
+       $(RANLIB) $@
+
+libltt-instrument-functions.so.0: ltt-instrument-functions.o ltt-facility-loader-user_generic.o ltt-usertrace-fast.o
+       @rm -f libltt-instrument-functions.so libltt-instrument-functions.so.0
+       $(CC) $(CFLAGS) -lpthread -shared -Wl,-soname,libltt-instrument-functions.so -o $@ $^
+       ln -s libltt-instrument-functions.so.0 libltt-instrument-functions.so
+
+install:
+       if [ ! -e "$(INCLUDE_DIR)/ltt" ] ; then mkdir $(INCLUDE_DIR)/ltt ; fi
+       cp -f ltt/*.h $(INCLUDE_DIR)/ltt
+       cp -df libltt-instrument-functions.so* libltt-instrument-functions.a $(LIB_DIR)
+
+.PHONY : clean install
+
+clean:
+       rm -fr *.o *~ test sample-instrument-fct libltt-instrument-functions.a libltt-instrument-functions.so*
diff --git a/attic/usertrace-fast/ltt-facility-loader-user_generic.c b/attic/usertrace-fast/ltt-facility-loader-user_generic.c
new file mode 100644 (file)
index 0000000..8cdb076
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * ltt-facility-loader-user_generic.c
+ *
+ * (C) Copyright  2005 - 
+ *          Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
+ *
+ * Contains the LTT user space facility loader.
+ *
+ */
+
+
+#define LTT_TRACE
+#include <error.h>
+#include <stdio.h>
+#include <ltt/ltt-generic.h>
+#include "ltt-facility-loader-user_generic.h"
+
+static struct user_facility_info facility = {
+       .name = LTT_FACILITY_NAME,
+       .num_events = LTT_FACILITY_NUM_EVENTS,
+#ifndef LTT_PACK
+       .alignment = sizeof(void*),
+#else
+       .alignment = 0,
+#endif //LTT_PACK
+       .checksum = LTT_FACILITY_CHECKSUM,
+       .int_size = sizeof(int),
+       .long_size = sizeof(long),
+       .pointer_size = sizeof(void*),
+       .size_t_size = sizeof(size_t)
+};
+
+static void __attribute__((constructor)) __ltt_user_init(void)
+{
+       int err;
+#ifdef LTT_SHOW_DEBUG
+       printf("LTT : ltt-facility-user_generic init in userspace\n");
+#endif //LTT_SHOW_DEBUG
+
+       err = ltt_register_generic(&LTT_FACILITY_SYMBOL, &facility);
+       LTT_FACILITY_CHECKSUM_SYMBOL = LTT_FACILITY_SYMBOL;
+       
+       if(err) {
+#ifdef LTT_SHOW_DEBUG
+               perror("Error in ltt_register_generic");
+#endif //LTT_SHOW_DEBUG
+       }
+}
+
diff --git a/attic/usertrace-fast/ltt-facility-loader-user_generic.h b/attic/usertrace-fast/ltt-facility-loader-user_generic.h
new file mode 100644 (file)
index 0000000..1f93d1e
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef _LTT_FACILITY_LOADER_USER_GENERIC_H_
+#define _LTT_FACILITY_LOADER_USER_GENERIC_H_
+
+#include <ltt/ltt-generic.h>
+#include <ltt/ltt-facility-id-user_generic.h>
+
+ltt_facility_t ltt_facility_user_generic;
+ltt_facility_t ltt_facility_user_generic_F583779E;
+
+#define LTT_FACILITY_SYMBOL                                                    ltt_facility_user_generic
+#define LTT_FACILITY_CHECKSUM_SYMBOL           ltt_facility_user_generic_F583779E
+#define LTT_FACILITY_CHECKSUM                                          0xF583779E
+#define LTT_FACILITY_NAME                                                              "user_generic"
+#define LTT_FACILITY_NUM_EVENTS                                        facility_user_generic_num_events
+
+#endif //_LTT_FACILITY_LOADER_USER_GENERIC_H_
diff --git a/attic/usertrace-fast/sample-instrument-fct.c b/attic/usertrace-fast/sample-instrument-fct.c
new file mode 100644 (file)
index 0000000..37140da
--- /dev/null
@@ -0,0 +1,26 @@
+
+
+#include <stdio.h>
+#include <unistd.h>
+
+#define LTT_TRACE
+#define LTT_BLOCKING 1
+#include <ltt/ltt-facility-user_generic.h>
+
+
+void test_function(void)
+{
+       printf("we are in a test function\n");
+}
+
+
+int main(int argc, char **argv)
+{
+       while(1) {
+               test_function();
+               sleep(1);
+       }
+       
+       return 0;
+}
+
diff --git a/attic/usertrace-fast/test.c b/attic/usertrace-fast/test.c
new file mode 100644 (file)
index 0000000..4960c0b
--- /dev/null
@@ -0,0 +1,72 @@
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <ltt/ltt-usertrace-fast.h>
+
+
+
+void *thr1(void *arg)
+{
+       int i;
+       ltt_thread_init();
+  printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+
+  //while(1) {}
+       for(i=0; i<5; i++) {
+       //      ltt_usertrace_fast_buffer_switch();
+               sleep(1);
+       }
+
+  //return ((void*)1);
+       pthread_exit((void*)1);
+}
+
+void *thr2(void *arg)
+{
+       int i;
+       ltt_thread_init();
+  //while(1) {
+    printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+    sleep(2);
+  //}
+       for(i=0; i<2; i++) {
+       //      ltt_usertrace_fast_buffer_switch();
+               sleep(3);
+       }
+
+
+  return ((void*)2);   /* testing "die" */
+       //pthread_exit((void*)2);
+}
+
+
+int main()
+{
+       int i;
+       int err;
+       pthread_t tid1, tid2;
+       void *tret;
+
+  printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+  err = pthread_create(&tid1, NULL, thr1, NULL);
+  if(err!=0) exit(1);
+
+  err = pthread_create(&tid2, NULL, thr2, NULL);
+  if(err!=0) exit(1);
+
+       for(i=0; i<2; i++) {
+       //      ltt_usertrace_fast_buffer_switch();
+               sleep(3);
+       }
+
+  err = pthread_join(tid1, &tret);
+  if(err!= 0) exit(1);
+
+  err = pthread_join(tid2, &tret);
+  if(err!= 0) exit(1);
+  
+  return 0;
+}
diff --git a/usertrace-attic/Makefile b/usertrace-attic/Makefile
deleted file mode 100644 (file)
index 83c3b89..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-CC=gcc
-
-test: test.c lttng_usertrace.c
-       $(CC) $(CFLAGS) -lpthread -o $@ $^
-
-.PHONY : clean
-
-clean:
-       rm -fr *.o *~ test
diff --git a/usertrace-attic/lttng_usertrace.c b/usertrace-attic/lttng_usertrace.c
deleted file mode 100644 (file)
index 5e32b0c..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-
-/* LTTng user-space tracing code
- *
- * Copyright 2006 Mathieu Desnoyers
- *
- */
-
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <signal.h>
-#include <syscall.h>
-#include <features.h>
-#include <pthread.h>
-#include <malloc.h>
-#include <string.h>
-
-#include "lttng_usertrace.h"
-
-#define MAX_TRACES 16
-
-
-/*
- * Notes :
- *
- * ltt_update :
- *
- * it should send the information on the traces that has their status MODIFIED.
- * It's a necessary assumption to have a correct lttng_free_trace_info, which
- * would not be reentrant otherwise.
- */
-
-
-/* TLS for the trace info
- * http://www.dis.com/gnu/gcc/C--98-Thread-Local-Edits.html
- *
- * Add after paragraph 4
- *
- *     The storage for an object of thread storage duration shall be statically
- *     initialized before the first statement of the thread startup function. An
- *     object of thread storage duration shall not require dynamic
- *     initialization.
- * GCC extention permits init of a range.
- */
-
-static __thread struct lttng_trace_info lttng_trace_info[MAX_TRACES] =
-{      [ 0 ... MAX_TRACES-1 ].active = 0,
-       [ 0 ... MAX_TRACES-1 ].filter = 0,
-       [ 0 ... MAX_TRACES-1 ].destroy = 0,
-       [ 0 ... MAX_TRACES-1 ].nesting = ATOMIC_INIT(0),
-       [ 0 ... MAX_TRACES-1 ].channel = 
-               { NULL,
-                       0,
-                       ATOMIC_INIT(0),
-                       ATOMIC_INIT(0),
-                       ATOMIC_INIT(0),
-                       ATOMIC_INIT(0),
-                       ATOMIC_INIT(0)
-               }
-};
-
-
-/* Must be called we sure nobody else is using the info.
- * It implies that the trace should have been previously stopped
- * and that every writer has finished.
- *
- * Writers should always check if the trace must be destroyed when they
- * finish writing and the nesting level is 0.
- */
-void lttng_free_trace_info(struct lttng_trace_info *info)
-{
-       int ret;
-       
-       if(info->active) {
-               printf(
-               "LTTng ERROR : lttng_free_trace_info should be called on inactive trace\n");
-               exit(1);
-       }
-       if(!info->destroy) {
-               printf(
-               "LTTng ERROR : lttng_free_trace_info should be called on destroyed trace\n");
-               exit(1);
-       }
-       if(atomic_read(&info->nesting) > 0) {
-               printf(
-               "LTTng ERROR : lttng_free_trace_info should not be nested on tracing\n");
-               exit(1);
-       }
-       
-       /* Remove the maps */
-       ret = munmap(info->channel.cpu.start, info->channel.cpu.length);
-       if(ret) {
-               perror("LTTNG : error in munmap");
-       }
-       ret = munmap(info->channel.facilities.start, info->channel.facilities.length);
-       if(ret) {
-               perror("LTTNG : error in munmap");
-       }
-       
-       /* Zero the structure */
-       memset(info, 0, sizeof(struct lttng_trace_info));
-}
-
-
-static struct lttng_trace_info* find_info(unsigned long cpu_addr,
-               unsigned long fac_addr, unsigned int *first_empty)
-{
-       struct lttng_trace_info *found = NULL;
-       unsigned int i;
-
-       *first_empty = MAX_TRACES;
-
-       /* Try to find the trace */
-       for(i=0;i<MAX_TRACES;i++) {
-               if(i<*first_empty && !lttng_trace_info[i].channel.cpu.start)
-                       *first_empty = i;
-               if(cpu_addr == 
-                               (unsigned long)lttng_trace_info[i].channel.cpu.start &&
-                        fac_addr == 
-                               (unsigned long)lttng_trace_info[i].channel.facilities.start) {
-                       /* Found */
-                       found = &lttng_trace_info[i];
-                       break;
-               }
-       }
-       return found;
-}
-
-
-static void lttng_get_new_info(void)
-{
-       unsigned long cpu_addr, fac_addr;
-       unsigned int i, first_empty;
-       int active, filter, destroy;
-       int ret;
-       struct lttng_trace_info *info;
-       sigset_t set, oldset;
-
-       /* Disable signals */
-       ret = sigfillset(&set);
-       if(ret) {
-               printf("Error in sigfillset\n");
-               exit(1);
-       }
-       
-       ret = pthread_sigmask(SIG_BLOCK, &set, &oldset);
-       if(ret) {
-               printf("Error in sigprocmask\n");
-               exit(1);
-       }
-
-       /* Get all the new traces */
-       while(1) {
-               cpu_addr = fac_addr = 0;
-               active = filter = destroy = 0;
-               ret = ltt_update(&cpu_addr, &fac_addr, &active, &filter, &destroy);
-               if(ret) {
-                       printf("LTTng : error in ltt_update\n");
-                       exit(1);
-               }
-               
-               if(!cpu_addr || !fac_addr) break;
-               
-               info = find_info(cpu_addr, fac_addr, &first_empty);
-               if(info) {
-                       info->filter = filter;
-                       info->active = active;
-                       info->destroy = destroy;
-                       if(destroy && !atomic_read(&info->nesting))
-                               lttng_free_trace_info(info);
-               } else {
-                       /* Not found. Must take an empty slot */
-                       if(first_empty == MAX_TRACES) {
-                               printf(
-                               "LTTng WARNING : too many traces requested for pid %d by the kernel.\n"
-                               "                Compilation defined maximum is %u\n",
-                                       getpid(), MAX_TRACES);
-
-                       } else {
-                               info = &lttng_trace_info[first_empty];
-                               info->channel.cpu.start = (void*)cpu_addr;
-                               info->channel.cpu.length = PAGE_SIZE;
-                               info->channel.facilities.start = (void*)fac_addr;
-                               info->channel.facilities.length = PAGE_SIZE;
-                               info->filter = filter;
-                               info->active = active;
-                               info->destroy = destroy;
-                               if(destroy && !atomic_read(&info->nesting))
-                                       lttng_free_trace_info(info);
-                       }
-               }
-       }
-
-       /* Enable signals */
-       ret = pthread_sigmask(SIG_SETMASK, &oldset, NULL);
-       if(ret) {
-               printf("Error in sigprocmask\n");
-               exit(1);
-       }
-}
-
-
-/* signal handler */
-void __lttng_sig_trace_handler(int signo)
-{
-  printf("LTTng signal handler : thread id : %lu, pid %lu\n", pthread_self(), getpid());
-       lttng_get_new_info();
-}
-
-
-static void thread_init(void)
-{
-       int err;
-       lttng_get_new_info();
-
-       /* Make some ltt_switch syscalls */
-       err = ltt_switch((unsigned long)NULL);
-       if(err) {
-               printf("Error in ltt_switch system call\n");
-               exit(1);
-       }
-}
-
-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");
-
-       thread_init();
-}
-
-
-void lttng_thread_init(void)
-{
-       thread_init();
-}
-
-
diff --git a/usertrace-attic/lttng_usertrace.h b/usertrace-attic/lttng_usertrace.h
deleted file mode 100644 (file)
index 600be4f..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-
-/* LTTng user-space tracing header
- *
- * Copyright 2006 Mathieu Desnoyers
- *
- */
-
-#ifndef _LTTNG_USERTRACE_H
-#define _LTTNG_USERTRACE_H
-
-#include <errno.h>
-#include <syscall.h>
-
-#include <asm/atomic.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
-
-struct ltt_buf {
-       void *start;
-       size_t length;
-       atomic_t        offset;
-       atomic_t        reserve_count;
-       atomic_t        commit_count;
-
-       atomic_t        events_lost;
-};
-
-struct lttng_trace_info {
-       int     active:1;
-       int destroy:1;
-       int filter;
-       atomic_t nesting;
-       struct {
-               struct ltt_buf facilities;
-               struct ltt_buf cpu;
-       } channel;
-};
-
-
-void __lttng_sig_trace_handler(int signo);
-
-/* Call this at the beginning of a new thread, except for the main() */
-void lttng_thread_init(void);
-
-void lttng_free_trace_info(struct lttng_trace_info *info);
-
-static inline _syscall1(int, ltt_switch, unsigned long, addr)
-static inline _syscall5(int, ltt_update, unsigned long *, cpu_addr, unsigned long *, fac_addr, int *, active, int *, filter, int *, destroy)
-
-#endif //_LTTNG_USERTRACE_H
diff --git a/usertrace-attic/test.c b/usertrace-attic/test.c
deleted file mode 100644 (file)
index a0509a2..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "lttng_usertrace.h"
-
-
-
-void *thr1(void *arg)
-{
-       lttng_thread_init();
-  printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
-
-  while(1) {}
-
-  return ((void*)1);
-
-}
-
-void *thr2(void *arg)
-{
-       lttng_thread_init();
-
-  while(1) {
-    printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
-    sleep(2);
-  }
-  return ((void*)2);
-}
-
-
-int main()
-{
-       int err;
-       pthread_t tid1, tid2;
-       void *tret;
-
-  printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid());
-  err = pthread_create(&tid1, NULL, thr1, NULL);
-  if(err!=0) exit(1);
-
-  err = pthread_create(&tid2, NULL, thr2, NULL);
-  if(err!=0) exit(1);
-
-  while(1)
-  {
-    
-  }
-
-  err = pthread_join(tid1, &tret);
-  if(err!= 0) exit(1);
-
-  err = pthread_join(tid2, &tret);
-  if(err!= 0) exit(1);
-  
-  return 0;
-}
diff --git a/usertrace-fast/Makefile b/usertrace-fast/Makefile
deleted file mode 100644 (file)
index d63a964..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-
-LIB_DIR=/usr/lib
-INCLUDE_DIR=/usr/include
-
-RANLIB=ranlib
-
-CC=gcc
-CFLAGS=-I. -O3
-#CFLAGS+=-DLTT_SUBBUF_SIZE_CPU=134217728
-#CFLAGS+=-DLTT_NULL_OUTPUT_TEST
-
-all: test sample-instrument-fct libltt-instrument-functions.a libltt-instrument-functions.so.0 sample-loop
-
-test: test.c ltt-usertrace-fast.c
-       $(CC) $(CFLAGS) -I. -lpthread -o $@ $^
-
-
-sample-instrument-fct: sample-instrument-fct.c
-       $(CC) $(CFLAGS) -L. -g -finstrument-functions -lltt-instrument-functions -o $@ $^
-
-sample-loop: sample-loop.c ltt-usertrace-fast.o ltt-facility-loader-user_generic.o
-       $(CC) $(CFLAGS) -L. -lpthread -g -o $@ $^
-
-libltt-instrument-functions.a: ltt-instrument-functions.o ltt-facility-loader-user_generic.o ltt-usertrace-fast.o
-       @rm -f libltt-instrument-functions.a
-       $(AR) rc $@ $^
-       $(RANLIB) $@
-
-libltt-instrument-functions.so.0: ltt-instrument-functions.o ltt-facility-loader-user_generic.o ltt-usertrace-fast.o
-       @rm -f libltt-instrument-functions.so libltt-instrument-functions.so.0
-       $(CC) $(CFLAGS) -lpthread -shared -Wl,-soname,libltt-instrument-functions.so -o $@ $^
-       ln -s libltt-instrument-functions.so.0 libltt-instrument-functions.so
-
-install:
-       if [ ! -e "$(INCLUDE_DIR)/ltt" ] ; then mkdir $(INCLUDE_DIR)/ltt ; fi
-       cp -f ltt/*.h $(INCLUDE_DIR)/ltt
-       cp -df libltt-instrument-functions.so* libltt-instrument-functions.a $(LIB_DIR)
-
-.PHONY : clean install
-
-clean:
-       rm -fr *.o *~ test sample-instrument-fct libltt-instrument-functions.a libltt-instrument-functions.so*
diff --git a/usertrace-fast/ltt-facility-loader-user_generic.c b/usertrace-fast/ltt-facility-loader-user_generic.c
deleted file mode 100644 (file)
index 8cdb076..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * ltt-facility-loader-user_generic.c
- *
- * (C) Copyright  2005 - 
- *          Mathieu Desnoyers (mathieu.desnoyers@polymtl.ca)
- *
- * Contains the LTT user space facility loader.
- *
- */
-
-
-#define LTT_TRACE
-#include <error.h>
-#include <stdio.h>
-#include <ltt/ltt-generic.h>
-#include "ltt-facility-loader-user_generic.h"
-
-static struct user_facility_info facility = {
-       .name = LTT_FACILITY_NAME,
-       .num_events = LTT_FACILITY_NUM_EVENTS,
-#ifndef LTT_PACK
-       .alignment = sizeof(void*),
-#else
-       .alignment = 0,
-#endif //LTT_PACK
-       .checksum = LTT_FACILITY_CHECKSUM,
-       .int_size = sizeof(int),
-       .long_size = sizeof(long),
-       .pointer_size = sizeof(void*),
-       .size_t_size = sizeof(size_t)
-};
-
-static void __attribute__((constructor)) __ltt_user_init(void)
-{
-       int err;
-#ifdef LTT_SHOW_DEBUG
-       printf("LTT : ltt-facility-user_generic init in userspace\n");
-#endif //LTT_SHOW_DEBUG
-
-       err = ltt_register_generic(&LTT_FACILITY_SYMBOL, &facility);
-       LTT_FACILITY_CHECKSUM_SYMBOL = LTT_FACILITY_SYMBOL;
-       
-       if(err) {
-#ifdef LTT_SHOW_DEBUG
-               perror("Error in ltt_register_generic");
-#endif //LTT_SHOW_DEBUG
-       }
-}
-
diff --git a/usertrace-fast/ltt-facility-loader-user_generic.h b/usertrace-fast/ltt-facility-loader-user_generic.h
deleted file mode 100644 (file)
index 1f93d1e..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef _LTT_FACILITY_LOADER_USER_GENERIC_H_
-#define _LTT_FACILITY_LOADER_USER_GENERIC_H_
-
-#include <ltt/ltt-generic.h>
-#include <ltt/ltt-facility-id-user_generic.h>
-
-ltt_facility_t ltt_facility_user_generic;
-ltt_facility_t ltt_facility_user_generic_F583779E;
-
-#define LTT_FACILITY_SYMBOL                                                    ltt_facility_user_generic
-#define LTT_FACILITY_CHECKSUM_SYMBOL           ltt_facility_user_generic_F583779E
-#define LTT_FACILITY_CHECKSUM                                          0xF583779E
-#define LTT_FACILITY_NAME                                                              "user_generic"
-#define LTT_FACILITY_NUM_EVENTS                                        facility_user_generic_num_events
-
-#endif //_LTT_FACILITY_LOADER_USER_GENERIC_H_
diff --git a/usertrace-fast/sample-instrument-fct.c b/usertrace-fast/sample-instrument-fct.c
deleted file mode 100644 (file)
index 37140da..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-#include <stdio.h>
-#include <unistd.h>
-
-#define LTT_TRACE
-#define LTT_BLOCKING 1
-#include <ltt/ltt-facility-user_generic.h>
-
-
-void test_function(void)
-{
-       printf("we are in a test function\n");
-}
-
-
-int main(int argc, char **argv)
-{
-       while(1) {
-               test_function();
-               sleep(1);
-       }
-       
-       return 0;
-}
-
diff --git a/usertrace-fast/test.c b/usertrace-fast/test.c
deleted file mode 100644 (file)
index 4960c0b..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include <ltt/ltt-usertrace-fast.h>
-
-
-
-void *thr1(void *arg)
-{
-       int i;
-       ltt_thread_init();
-  printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
-
-  //while(1) {}
-       for(i=0; i<5; i++) {
-       //      ltt_usertrace_fast_buffer_switch();
-               sleep(1);
-       }
-
-  //return ((void*)1);
-       pthread_exit((void*)1);
-}
-
-void *thr2(void *arg)
-{
-       int i;
-       ltt_thread_init();
-  //while(1) {
-    printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
-    sleep(2);
-  //}
-       for(i=0; i<2; i++) {
-       //      ltt_usertrace_fast_buffer_switch();
-               sleep(3);
-       }
-
-
-  return ((void*)2);   /* testing "die" */
-       //pthread_exit((void*)2);
-}
-
-
-int main()
-{
-       int i;
-       int err;
-       pthread_t tid1, tid2;
-       void *tret;
-
-  printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid());
-  err = pthread_create(&tid1, NULL, thr1, NULL);
-  if(err!=0) exit(1);
-
-  err = pthread_create(&tid2, NULL, thr2, NULL);
-  if(err!=0) exit(1);
-
-       for(i=0; i<2; i++) {
-       //      ltt_usertrace_fast_buffer_switch();
-               sleep(3);
-       }
-
-  err = pthread_join(tid1, &tret);
-  if(err!= 0) exit(1);
-
-  err = pthread_join(tid2, &tret);
-  if(err!= 0) exit(1);
-  
-  return 0;
-}
This page took 0.044148 seconds and 4 git commands to generate.