CC=gcc
INCLUDE_DIR=/usr/include
-LIB_DIR=/usr/lib
+LIB_DIR?=/usr/lib
RANLIB=ranlib
-CFLAGS=-I. -O2 -L.
+LTT_CFLAGS=-I. -O2 -L.
#For testing lib ltt-usertrace-fast
#CFLAGS+=-DLTT_SUBBUF_SIZE_CPU=134217728
sample-instrument-fct sample-thread-slow sample-thread-fast
sample: sample.c ltt-facility-loader-user_generic.c
- $(CC) $(CFLAGS) -o $@ $^
+ $(CC) $(LTT_CFLAGS) $(CFLAGS) -o $@ $^
sample-highspeed: sample-highspeed.c ltt-facility-loader-user_generic.c
- $(CC) $(CFLAGS) -lltt-usertrace-fast -o $@ $^
+ $(CC) $(LTT_CFLAGS) $(CFLAGS) -lltt-usertrace-fast -o $@ $^
sample-printf: sample-printf.c ltt-facility-loader-user_generic.c
- $(CC) $(CFLAGS) -o $@ $^
+ $(CC) $(LTT_CFLAGS) $(CFLAGS) -o $@ $^
sample-instrument-fct: sample-instrument-fct.c
- $(CC) $(CFLAGS) -g -finstrument-functions -lltt-instrument-functions -o $@ $^
+ $(CC) $(LTT_CFLAGS) $(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 $@ $^
+ $(CC) $(LTT_CFLAGS) $(CFLAGS) -lpthread -o $@ $^
sample-thread-fast: sample-thread-fast.c ltt-facility-loader-user_generic.c
- $(CC) $(CFLAGS) -lpthread -lltt-usertrace-fast -o $@ $^
+ $(CC) $(LTT_CFLAGS) $(CFLAGS) -lpthread -lltt-usertrace-fast -o $@ $^
#LIBRAIRIES
libltt-usertrace-fast.so.0: ltt-usertrace-fast.o
@rm -f libltt-usertrace-fast.so libltt-usertrace-fast.so.0
- $(CC) $(CFLAGS) -lpthread -shared -Wl,-soname,libltt-usertrace-fast.so -o $@ $^
+ $(CC) $(LTT_CFLAGS) $(CFLAGS) -lpthread -shared -Wl,-soname,libltt-usertrace-fast.so -o $@ $^
ln -s libltt-usertrace-fast.so.0 libltt-usertrace-fast.so
libltt-instrument-functions.a: ltt-instrument-functions.o ltt-facility-loader-user_generic.o ltt-usertrace-fast.o
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 $@ $^
+ $(CC) $(LTT_CFLAGS) $(CFLAGS) -lpthread -shared -Wl,-soname,libltt-instrument-functions.so -o $@ $^
ln -s libltt-instrument-functions.so.0 libltt-instrument-functions.so
-.PHONY : clean install libs samples
+%.o: %.c
+ $(CC) $(LTT_CFLAGS) $(CFLAGS) -c -o $@ $+
-install:
+.PHONY : clean install libs install_libs install_headers samples
+
+install_headers:
if [ ! -e "$(INCLUDE_DIR)/ltt" ] ; then mkdir $(INCLUDE_DIR)/ltt ; fi
cp -f ltt/*.h $(INCLUDE_DIR)/ltt
+
+install_libs:
cp -df libltt-instrument-functions.so* libltt-instrument-functions.a $(LIB_DIR)
cp -df libltt-usertrace-fast.so* libltt-usertrace-fast.a $(LIB_DIR)
+install: install_headers libs install_libs
+
clean:
rm -fr *.o *~ sample-thread sample sample-highspeed sample-printf sample-instrument-fct libltt-instrument-functions.so* libltt-instrument-functions.a libltt-usertrace-fast.a libltt-usertrace-fast.so* sample-thread-slow sample-thread-fast
* Build the sample programs and install the headers and librairies into your
system :
+(32 bits)
su
cd /usr/src/ltt-usertrace
+make clean
+make install (will build and install headers and libraries)
make
-make install
+(64 bits)
+su
+cd /usr/src/ltt-usertrace
+make clean
+LIB_DIR=/usr/lib64 make install CFLAGS=-m64
+make CFLAGS=-m64
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.
#include <stdlib.h>
#include <stdarg.h>
-static inline int trace_user_generic_slow_printf(
+static int trace_user_generic_slow_printf(
const char *fmt, ...)
#ifndef LTT_TRACE
{
#include <pthread.h>
#include <stdint.h>
#include <syscall.h>
-#include <asm/timex.h>
#include <semaphore.h>
#include <signal.h>
#define __LTT_USERTRACE_PPC_H
#ifdef __powerpc64__
-#include "ltt/atomic-ppc64.h"
-#include "ltt/system-ppc64.h"
+#include <ltt/atomic-ppc64.h>
+#include <ltt/system-ppc64.h>
#else
-#include "ltt/ppc_asm-ppc.h"
-#include "ltt/atomic-ppc.h"
-#include "ltt/system-ppc.h"
+#include <ltt/ppc_asm-ppc.h>
+#include <ltt/atomic-ppc.h>
+#include <ltt/system-ppc.h>
+#include <ltt/timex-ppc.h>
#endif
-#define CPU_FTR_601 0x00000100
-
-#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
-
-typedef uint64_t cycles_t;
-
-/* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */
-static inline unsigned long get_tbl(void)
-{
- unsigned long tbl;
-
-//#if defined(CONFIG_403GCX)
-// asm volatile("mfspr %0, 0x3dd" : "=r" (tbl));
-//#else
- asm volatile("mftb %0" : "=r" (tbl));
-//#endif
- return tbl;
-}
-
-static inline unsigned int get_tbu(void)
-{
- unsigned int tbu;
-
-//#if defined(CONFIG_403GCX)
-// asm volatile("mfspr %0, 0x3dc" : "=r" (tbu));
-//#else
- asm volatile("mftbu %0" : "=r" (tbu));
-//#endif
- return tbu;
-}
-
-
-#ifdef __powerpc64__
-static inline uint64_t get_tb(void)
-{
- return mftb();
-}
-#else
-static inline uint64_t get_tb(void)
-{
- unsigned int tbhi, tblo, tbhi2;
-
- do {
- tbhi = get_tbu();
- tblo = get_tbl();
- tbhi2 = get_tbu();
- } while (tbhi != tbhi2);
-
- return ((uint64_t)tbhi << 32) | tblo;
-}
-#endif
-
-static inline cycles_t get_cycles(void)
-{
- return get_tb();
-}
-
#endif /* __LTT_USERTRACE_PPC_H */
#include <stdint.h>
#include <sys/types.h>
#include <linux/unistd.h>
+
+#define inline inline __attribute__((always_inline))
+
#if defined(__powerpc__) || defined(__powerpc64__)
-#include "ltt/ltt-usertrace-ppc.h"
+#ifdef __powerpc64__
+#include <ltt/atomic-ppc64.h>
+#include <ltt/system-ppc64.h>
+#include <asm/timex.h>
+#else
+#include <ltt/ppc_asm-ppc.h>
+#include <ltt/atomic-ppc.h>
+#include <ltt/system-ppc.h>
+#include <ltt/timex-ppc.h>
+#endif
#else
+#include <asm/timex.h>
#include <asm/atomic.h>
#endif
#define NR_syscalls 313
#endif
-#ifdef powerpc
+#ifdef __powerpc__
+#define __NR_ltt_trace_generic 283
+#define __NR_ltt_register_generic 284
+#undef NR_syscalls
+#define NR_syscalls 285
+#endif
+
+#ifdef __powerpc64__
#define __NR_ltt_trace_generic 283
#define __NR_ltt_register_generic 284
#undef NR_syscalls
#define NR_syscalls 285
#endif
+
+
//FIXME : setup for ARM
//FIXME : setup for MIPS
#define smp_read_barrier_depends() do { } while(0)
#endif /* CONFIG_SMP */
-static __inline__ unsigned long
+static inline unsigned long
xchg_u32(volatile void *p, unsigned long val)
{
unsigned long prev;
#define __HAVE_ARCH_CMPXCHG 1
-static __inline__ unsigned long
+static inline unsigned long
__cmpxchg_u32(volatile unsigned int *p, unsigned int old, unsigned int new)
{
unsigned int prev;
if something tries to do an invalid cmpxchg(). */
extern void __cmpxchg_called_with_bad_pointer(void);
-static __inline__ unsigned long
+static inline unsigned long
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
{
switch (size) {
* Inline asm pulled from arch/ppc/kernel/misc.S so ppc64
* is more like most of the other architectures.
*/
-static __inline__ unsigned long
+static inline unsigned long
__xchg_u32(volatile int *m, unsigned long val)
{
unsigned long dummy;
return (dummy);
}
-static __inline__ unsigned long
+static inline unsigned long
__xchg_u64(volatile long *m, unsigned long val)
{
unsigned long dummy;
*/
extern void __xchg_called_with_bad_pointer(void);
-static __inline__ unsigned long
+static inline unsigned long
__xchg(volatile void *ptr, unsigned long x, int size)
{
switch (size) {
#define __HAVE_ARCH_CMPXCHG 1
-static __inline__ unsigned long
+static inline unsigned long
__cmpxchg_u32(volatile int *p, int old, int new)
{
unsigned int prev;
return prev;
}
-static __inline__ unsigned long
+static inline unsigned long
__cmpxchg_u64(volatile long *p, unsigned long old, unsigned long new)
{
unsigned long prev;
if something tries to do an invalid cmpxchg(). */
extern void __cmpxchg_called_with_bad_pointer(void);
-static __inline__ unsigned long
+static inline unsigned long
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
{
switch (size) {
--- /dev/null
+#ifndef __TIMEX_PPC_H
+#define __TIMEX_PPC_H
+
+#define CPU_FTR_601 0x00000100
+
+#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
+
+typedef uint64_t cycles_t;
+
+/* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */
+static inline unsigned long get_tbl(void)
+{
+ unsigned long tbl;
+
+//#if defined(CONFIG_403GCX)
+// asm volatile("mfspr %0, 0x3dd" : "=r" (tbl));
+//#else
+ asm volatile("mftb %0" : "=r" (tbl));
+//#endif
+ return tbl;
+}
+
+static inline unsigned int get_tbu(void)
+{
+ unsigned int tbu;
+
+//#if defined(CONFIG_403GCX)
+// asm volatile("mfspr %0, 0x3dc" : "=r" (tbu));
+//#else
+ asm volatile("mftbu %0" : "=r" (tbu));
+//#endif
+ return tbu;
+}
+
+static inline uint64_t get_tb(void)
+{
+ unsigned int tbhi, tblo, tbhi2;
+
+ do {
+ tbhi = get_tbu();
+ tblo = get_tbl();
+ tbhi2 = get_tbu();
+ } while (tbhi != tbhi2);
+
+ return ((uint64_t)tbhi << 32) | tblo;
+}
+
+static inline cycles_t get_cycles(void)
+{
+ return get_tb();
+}
+
+#endif //__TIMEX_PPC_H