new ltt-usertrace
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 9 Mar 2006 21:31:33 +0000 (21:31 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 9 Mar 2006 21:31:33 +0000 (21:31 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1649 04897980-b3bd-0310-b5e0-8ef037075253

ltt-usertrace/Makefile
ltt-usertrace/README
ltt-usertrace/sample-printf.c
ltt-usertrace/sample-thread-fast.c
ltt-usertrace/sample-thread-slow.c
ltt-usertrace/sample.c

index c3daad73f734f03723968dd6c55a2dfb68475609..aebde690e65b33669afc7456d15fd960dca2b142 100644 (file)
@@ -4,8 +4,7 @@ INCLUDE_DIR=/usr/include
 LIB_DIR=/usr/lib
 RANLIB=ranlib
 
-CFLAGS=-I. -O3
-LDFLAGS=-L.
+CFLAGS=-I. -O3 -L.
 
 #For testing lib ltt-usertrace-fast
 #CFLAGS+=-DLTT_SUBBUF_SIZE_CPU=134217728
@@ -22,19 +21,19 @@ sample: sample.c ltt-facility-loader-user_generic.c
        $(CC) $(CFLAGS) -o $@ $^
        
 sample-highspeed: sample-highspeed.c ltt-facility-loader-user_generic.c
-       $(CC) $(CFLAGS) -L. -lltt-usertrace-fast -o $@ $^
+       $(CC) $(CFLAGS) -lltt-usertrace-fast -o $@ $^
 
 sample-printf: sample-printf.c ltt-facility-loader-user_generic.c
        $(CC) $(CFLAGS) -o $@ $^
 
 sample-instrument-fct: sample-instrument-fct.c
-       $(CC) $(CFLAGS) -L. -g -finstrument-functions -lltt-instrument-functions -o $@ $^
+       $(CC) $(CFLAGS) -g -finstrument-functions -lltt-instrument-functions -o $@ $^
 
 sample-thread-slow: sample-thread-slow.c ltt-facility-loader-user_generic.c
        $(CC) $(CFLAGS) -lpthread -o $@ $^
 
 sample-thread-fast: sample-thread-fast.c ltt-facility-loader-user_generic.c
-       $(CC) $(CFLAGS) -lpthread -o $@ $^
+       $(CC) $(CFLAGS) -lpthread -lltt-usertrace-fast -o $@ $^
 
 
 #LIBRAIRIES
index b9ac1fb431c5a0861a43d9aaea08a54a0d955e31..4bdbf293739b43e8410f93f2e8b03f572f3fd6dd 100644 (file)
@@ -1,5 +1,5 @@
 
-LTTng usertrace generic package
+LTTng usertrace package
 
 Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
 March 2006
@@ -10,8 +10,8 @@ short quickstart guide of it.
 
 Here are the currently supported architectures :
 x86
-(please add the ltt_* system calls to other architectures as you need them : it
-will work magically)
+(please add the ltt_trace_generic and ltt_register_generic system calls to
+other architectures as you need them : it will work magically)
 
 * Compile your kernel with the latest LTTng patch. Make sure the option 
   "Allow tracing from userspace" is _active_!
@@ -19,19 +19,23 @@ will work magically)
   setup a working tracer and viewer. See the genevent installation step : it is
   required for method #2 below.
   
-* Extract the latest usertrace-generic archive :
+* Extract the latest ltt-usertrace archive :
 su
 cd /usr/src
-wget http://ltt.polymtl.ca/packages/usertrace-generic-x.x.tar.gz
-gzip -cd usertrace-generic-x.x.tar.gz | tar xvof -
+wget http://ltt.polymtl.ca/packages/ltt-usertrace-x.x.tar.gz
+gzip -cd ltt-usertrace-x.x.tar.gz | tar xvof -
 
-* Build the sample programs and install the headers into your system :
+* Build the sample programs and install the headers and librairies into your
+system :
 su
 cd /usr/src/usertrace-generic
 make
 make install
 
-* There are two ways to trace information from your application :
+Feel free to look at the sample programs and the Makefile : they demonstrate
+very well the features of the usertrace package and how to use them.
+
+* There are three ways to trace information from your application :
 
 1) Easy way, but slow (printf style)
   See sample-printf.c for code example.
index 9b2292a7ba61e650b52e0cc10b1de03b3b89d6e7..a513e3b6538a28a289afaa55b017e637caebece0 100644 (file)
@@ -13,9 +13,9 @@
 int main(int argc, char **argv)
 {
        printf("Will trace a printf of an incrementing counter.\n");
-  printf("Abort with CTRL-C.\n");
-  printf("No file is created with this example : it logs through a kernel\n");
-  printf("system call. See the LTTng lttctl command to start tracing.\n");
+       printf("Abort with CTRL-C.\n");
+       printf("No file is created with this example : it logs through a kernel\n");
+       printf("system call. See the LTTng lttctl command to start tracing.\n");
 
        unsigned int count = 0;
 
index d98c86f5487fdc91c55b5a87ca5f923de2955ac7..69f1cf890c4770bb88e2297ede7bcf30fa1ec2b5 100644 (file)
@@ -5,32 +5,39 @@
 #include <stdlib.h>
 
 #define LTT_TRACE
-//this one is a non blocking sample (not #define LTT_BLOCKING 1)
+#define LTT_TRACE_FAST
 #include <ltt/ltt-facility-user_generic.h>
 
 
 void *thr1(void *arg)
 {
-  printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+       ltt_thread_init();      /* This init is not required : it will be done
+                                                                                                automatically anyways at the first tracing call site */
+       printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
 
-  while(1) {
+       while(1) {
                trace_user_generic_string("Hello world! Have a nice day.");
                sleep(2);
        }
-
-  return ((void*)1);
-
+       pthread_exit((void*)1);
 }
 
+
+/* Example of a _bad_ thread, which still works with the tracing */
 void *thr2(void *arg)
 {
-  printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+       /* See ? no init */
+       printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
        sleep(1);
-  while(1) {
+       while(1) {
                trace_user_generic_string("Hello world! Have a nice day.");
-    sleep(2);
-  }
-  return ((void*)2);
+               sleep(2);
+       }
+       /* This thread is a bad citizen : returning like this will cause its cancel
+        * routines not to be executed. This is still detected by the tracer, but only
+        * when the complete process dies. This is not recommended if you create a
+        * huge amount of threads */
+       return ((void*)2);
 }
 
 
@@ -42,21 +49,21 @@ int main()
 
        printf("Will trace the following string : Hello world! Have a nice day.\n");
        printf("Press CTRL-C to stop.\n");
-  printf("No file is created with this example : it logs through a kernel\n");
-  printf("system call. See the LTTng lttctl command to start tracing.\n\n");
+       printf("No file is created with this example : it logs through a kernel\n");
+       printf("system call. See the LTTng lttctl command to start tracing.\n\n");
 
-  printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid());
-  err = pthread_create(&tid1, NULL, thr1, NULL);
-  if(err!=0) exit(1);
+       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);
+       err = pthread_create(&tid2, NULL, thr2, NULL);
+       if(err!=0) exit(1);
 
-  err = pthread_join(tid1, &tret);
-  if(err!= 0) exit(1);
+       err = pthread_join(tid1, &tret);
+       if(err!= 0) exit(1);
 
-  err = pthread_join(tid2, &tret);
-  if(err!= 0) exit(1);
-  
-  return 0;
+       err = pthread_join(tid2, &tret);
+       if(err!= 0) exit(1);
+       
+       return 0;
 }
index d98c86f5487fdc91c55b5a87ca5f923de2955ac7..343332f7d44c0ca82908ebe953e8548524e0704f 100644 (file)
 
 void *thr1(void *arg)
 {
-  printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+       printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
 
-  while(1) {
+       while(1) {
                trace_user_generic_string("Hello world! Have a nice day.");
                sleep(2);
        }
-
-  return ((void*)1);
-
+       pthread_exit((void*)1);
 }
 
+
+/* Example of a _bad_ thread, which still works with the tracing */
 void *thr2(void *arg)
 {
-  printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+       printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
        sleep(1);
-  while(1) {
+       while(1) {
                trace_user_generic_string("Hello world! Have a nice day.");
-    sleep(2);
-  }
-  return ((void*)2);
+               sleep(2);
+       }
+       return ((void*)2);
 }
 
 
@@ -42,21 +42,21 @@ int main()
 
        printf("Will trace the following string : Hello world! Have a nice day.\n");
        printf("Press CTRL-C to stop.\n");
-  printf("No file is created with this example : it logs through a kernel\n");
-  printf("system call. See the LTTng lttctl command to start tracing.\n\n");
+       printf("No file is created with this example : it logs through a kernel\n");
+       printf("system call. See the LTTng lttctl command to start tracing.\n\n");
 
-  printf("thread main, thread id : %lu, pid %lu\n", pthread_self(), getpid());
-  err = pthread_create(&tid1, NULL, thr1, NULL);
-  if(err!=0) exit(1);
+       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);
+       err = pthread_create(&tid2, NULL, thr2, NULL);
+       if(err!=0) exit(1);
 
-  err = pthread_join(tid1, &tret);
-  if(err!= 0) exit(1);
+       err = pthread_join(tid1, &tret);
+       if(err!= 0) exit(1);
 
-  err = pthread_join(tid2, &tret);
-  if(err!= 0) exit(1);
-  
-  return 0;
+       err = pthread_join(tid2, &tret);
+       if(err!= 0) exit(1);
+       
+       return 0;
 }
index b5ef44923740f34ab0899dfc225853ceb9479210..70bb8a2e84947eb48049415aa7635527196bf4dc 100644 (file)
@@ -11,9 +11,9 @@ int main(int argc, char **argv)
 {
        printf("Will trace the following string : \"Hello world! Have a nice day.\"\n");
        printf("every second.\n");
-  printf("Abort with CTRL-C.\n");
-  printf("No file is created with this example : it logs through a kernel\n");
-  printf("system call. See the LTTng lttctl command to start tracing.\n");
+       printf("Abort with CTRL-C.\n");
+       printf("No file is created with this example : it logs through a kernel\n");
+       printf("system call. See the LTTng lttctl command to start tracing.\n");
 
        while(1) {
                trace_user_generic_string("Hello world! Have a nice day.");
This page took 0.031671 seconds and 4 git commands to generate.