work in prog
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 8 Mar 2006 18:29:31 +0000 (18:29 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Wed, 8 Mar 2006 18:29:31 +0000 (18:29 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1619 04897980-b3bd-0310-b5e0-8ef037075253

usertrace-fast/Makefile
usertrace-fast/ltt-facility-loader-user_generic.c [new file with mode: 0644]
usertrace-fast/ltt-facility-loader-user_generic.h [new file with mode: 0644]
usertrace-fast/ltt-instrument-functions.c [new file with mode: 0644]
usertrace-fast/ltt-usertrace-fast.c
usertrace-fast/ltt-usertrace-fast.h
usertrace-fast/sample-instrument-fct.c [new file with mode: 0644]

index 6cfaec6ab9f6e57c112ce699ef757fb694ae28f9..ced8f6fbeed2ae76fb6a4fa15b063a0efee76c65 100644 (file)
@@ -1,11 +1,33 @@
 
+RANLIB=ranlib
 
 CC=gcc
 
+all: test sample-instrument-fct libltt-instrument-functions.a libltt-instrument-functions.so.0
+
 test: test.c ltt-usertrace-fast.c
        $(CC) $(CFLAGS) -lpthread -o $@ $^
 
-.PHONY : clean
+
+sample-instrument-fct: sample-instrument-fct.c
+       $(CC) $(CFLAGS) -L. -g -finstrument-functions -lltt-instrument-functions -o $@ $^
+
+libltt-instrument-functions.a: ltt-instrument-functions.o ltt-facility-loader-user_generic.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
+       @rm -f libltt-instrument-functions.so libltt-instrument-functions.so.0
+       $(CC) $(CFLAGS) -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
+       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
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/usertrace-fast/ltt-facility-loader-user_generic.h b/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/usertrace-fast/ltt-instrument-functions.c b/usertrace-fast/ltt-instrument-functions.c
new file mode 100644 (file)
index 0000000..28c7c8e
--- /dev/null
@@ -0,0 +1,28 @@
+/****************************************************************************
+ * ltt-instrument-functions.c
+ *
+ * Mathieu Desnoyers
+ * March 2006
+ */
+
+#define LTT_TRACE
+#define LTT_TRACE_FAST
+#include "ltt-usertrace-fast.h"
+#include <ltt/ltt-facility-user_generic.h>
+
+void __attribute__((no_instrument_function)) __cyg_profile_func_enter (
+               void *this_fn,
+               void *call_site)
+{
+       /* don't care about the return value */
+       trace_user_generic_function_entry(this_fn, call_site);
+}
+
+void __attribute__((no_instrument_function)) __cyg_profile_func_exit (
+               void *this_fn,
+               void *call_site)
+{
+       /* don't care about the return value */
+       trace_user_generic_function_exit(this_fn, call_site);
+}
+
index b56e3b5294377008933d4c956675d24fe9faf56d..55ba880ab8684f9038bc05f3f9ba4fba64fe0edf 100644 (file)
@@ -42,6 +42,7 @@
  */
 
 #define _GNU_SOURCE
+#define LTT_TRACE
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/param.h>
 #include <sys/time.h>
+#include <errno.h>
 
 #include <asm/atomic.h>
 #include <asm/timex.h> //for get_cycles()
 
+_syscall0(pid_t,gettid)
+
 #include "ltt-usertrace-fast.h"
 
 enum force_switch_mode { FORCE_ACTIVE, FORCE_FLUSH };
index 5f7915306171e82278af1e0447d5d35a7467bbec..e4930d730c9c40ab919377fb33b239f5b29cc5bd 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef _LTT_USERTRACE_FAST_H
 #define _LTT_USERTRACE_FAST_H
 
+#ifdef LTT_TRACE
+
 #include <errno.h>
 #include <asm/atomic.h>
 #include <pthread.h>
@@ -15,6 +17,9 @@
 #include <syscall.h>
 #include <linux/futex.h>
 
+#include <ltt/ltt-facility-id-user_generic.h>
+#include <ltt/ltt-generic.h>
+
 #ifndef futex
 static inline __attribute__((no_instrument_function))
        _syscall6(long, futex, unsigned long, uaddr, int, op, int, val,
@@ -121,7 +126,7 @@ struct ltt_trace_info {
        int init;
        int filter;
        pid_t daemon_id;
-       atomic_t nesting;
+       int nesting;
        struct {
                struct ltt_buf facilities;
                struct ltt_buf cpu;
@@ -145,27 +150,6 @@ void ltt_thread_init(void);
 void __attribute__((no_instrument_function))
        ltt_usertrace_fast_buffer_switch(void);
 
-#ifndef LTT_PACK
-/* Calculate the offset needed to align the type */
-static inline unsigned int __attribute__((no_instrument_function))
-                            ltt_align(size_t align_drift,
-                                      size_t size_of_type)
-{
-  size_t alignment = min(sizeof(void*), size_of_type);
-
-  return ((alignment - align_drift) & (alignment-1));
-}
-#define LTT_ALIGN
-#else
-static inline unsigned int __attribute__((no_instrument_function))
-                            ltt_align(size_t align_drift,
-                                      size_t size_of_type)
-{
-  return 0;
-}
-#define LTT_ALIGN __attribute__((packed))
-#endif //LTT_PACK
-
 /* Get the offset of the channel in the ltt_trace_struct */
 #define GET_CHANNEL_INDEX(chan) \
   (unsigned int)&((struct ltt_trace_info*)NULL)->channel.chan
@@ -186,17 +170,6 @@ static inline unsigned int __attribute__((no_instrument_function))
                ltt_get_index_from_facility(ltt_facility_t fID,
                                                                                                                                uint8_t eID)
 {
-
-       if(fID == ltt_facility_core) {
-               switch(eID) {
-                       case event_core_facility_load:
-                       case event_core_facility_unload:
-                       case event_core_state_dump_facility_load:
-                               return GET_CHANNEL_INDEX(facilities);
-                       default:
-                               return GET_CHANNEL_INDEX(cpu);
-               }
-       }
        return GET_CHANNEL_INDEX(cpu);
 }
 
@@ -658,7 +631,7 @@ static inline void __attribute__((no_instrument_function)) ltt_commit_slot(
 }
        
 
-
+#endif //LTT_TRACE
 
 
 #endif //_LTT_USERTRACE_FAST_H
diff --git a/usertrace-fast/sample-instrument-fct.c b/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;
+}
+
This page took 0.027734 seconds and 4 git commands to generate.