+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*
--- /dev/null
+/*
+ * 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(<T_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
+ }
+}
+
--- /dev/null
+#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_
--- /dev/null
+/****************************************************************************
+ * 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);
+}
+
*/
#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 };
#ifndef _LTT_USERTRACE_FAST_H
#define _LTT_USERTRACE_FAST_H
+#ifdef LTT_TRACE
+
#include <errno.h>
#include <asm/atomic.h>
#include <pthread.h>
#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,
int init;
int filter;
pid_t daemon_id;
- atomic_t nesting;
+ int nesting;
struct {
struct ltt_buf facilities;
struct ltt_buf cpu;
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
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);
}
}
-
+#endif //LTT_TRACE
#endif //_LTT_USERTRACE_FAST_H
--- /dev/null
+
+
+#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;
+}
+