--- /dev/null
+
+CC=gcc
+INCLUDE_DIR=/usr/include
+LIB_DIR=/usr/lib
+RANLIB=ranlib
+
+all: libltt-instrument-functions.a libltt-instrument-functions.so.0 sample-thread sample sample-highspeed sample-printf sample-instrument-fct
+
+sample-thread: sample-thread.c ltt-facility-loader-user_generic.c
+ $(CC) $(CFLAGS) -lpthread -o $@ $^
+
+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) -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 $@ $^
+
+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
+
+.PHONY : clean install
+
+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)
+
+clean:
+ rm -fr *.o *~ sample-thread sample sample-highspeed sample-printf sample-instrument-fct libltt-instrument-functions.so* libltt-instrument-functions.a
+
--- /dev/null
+
+LTTng usertrace generic package
+
+Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
+March 2006
+
+This package contains all the user space headers and c files necessary to make
+your application and library trace through an active LTTng tracer. Here is a
+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)
+
+* Compile your kernel with the latest LTTng patch. Make sure the option
+ "Allow tracing from userspace" is _active_!
+ See the QUICKSTART guide at http://ltt.polymtl.ca/ for details about how to
+ setup a working tracer and viewer. See the genevent installation step : it is
+ required for method #2 below.
+
+* Extract the latest usertrace-generic 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 -
+
+* Build the sample programs and install the headers into your system :
+su
+cd /usr/src/usertrace-generic
+make
+make install
+
+* There are two ways to trace information from your application :
+
+1) Easy way, but slow (printf style)
+ See sample-printf.c for code example.
+
+- Add the following statements to your program source (the define must come
+ _before_ the includes!) :
+
+#define LTT_TRACE
+#define LTT_BLOCKING 1
+#include <ltt/ltt-facility-user_generic.h>
+#include <ltt/ltt-facility-custom-user_generic.h>
+
+Note the define of LTT_BLOCKING to 1 : if a trace buffer is full, your
+application will block. The default of this parameter is 0 (non blocking) :
+events are lost when trace buffer is full. The choice is up to you.
+
+- Add something like the following sample line in your code. Note that this is a
+ very standard format string, this is only a suggested presentation.
+
+trace_user_generic_slow_printf("in: %s at: %s:%d: Counter value is: %u.",
+ __FILE__, __func__, __LINE__, count);
+
+- Compile your application with at least these parameters to gcc (it is splitted
+ on two lines, joined by a "\") :
+gcc -D LTT_SHOW_DEBUG -I /usr/src/usertrace-generic -o myapp myapp.c \
+ /usr/src/usertrace-generic/ltt-facility-loader-user_generic.c
+
+To see what the final result looks like :
+- Start tracing
+- Start your application
+ ** You should see the following message when your program starts and the
+ LTT_SHOW_DEBUG is defined :
+ "LTT : ltt-facility-user_generic init in userspace"
+ If you don't then you forgot to compile the facility loader in your
+ application. If you find this output annoying, you can remove the
+ "-D LTT_SHOW_DEBUG" gcc parameter, which will make the facility loader
+ silent.
+- Stop tracing
+Then, to see only the user_generic events :
+lttv -m textDump -t /tmp/trace1 -e "event.facility=user_generic"
+
+It will show :
+user_generic.slow_printf: 35885.922829472 (/cpu_0), 15521, 7453, SYSCALL { "in: sample-printf.c at: main:18: Counter value is: 0." }
+user_generic.slow_printf: 35886.925685289 (/cpu_0), 15521, 7453, SYSCALL { "in: sample-printf.c at: main:18: Counter value is: 1." }
+...
+
+
+
+2) The second way to log events is still easy, yet faster. It requires creating
+ your own XML description of your data structures. It will make it easier to
+ identify your data in the trace. Please read the comments in method 1)
+ explained previously, as they are not repeated here.
+ See sample.c for code example.
+
+- Go to the usertrace-generic directory
+su
+cd /usr/src/usertrace-generic
+
+- Create your own facility (i.e. user_myfacility.xml).
+ See the ones available in /usr/share/LinuxTraceToolkitViewer/facilities for
+ examples.
+ You facility _must_ be named following this standard : "user_*", where * is
+ whatever you like. If it is not, it will be rejected by the kernel with a
+ Operation not permitted (can be seen with the -D LTT_SHOW_DEBUG compilation
+ parameter).
+
+user_myfacility.xml:
+
+<facility name="user_myfacility">
+ <description>Sample facility</description>
+ <event name="myevent">
+ <description>Sample event</description>
+ <field name="file"><string></field>
+ <field name="function"><string></field>
+ <field name="line"><int></field>
+ <field name="firstval"><long></field>
+ <field name="secondval"><pointer></field>
+ </event>
+</facility>
+
+- AN IMPORTANT STEP FOLLOWS :
+ *copy* the user_myfacility.xml file in your system :
+su
+cp user_myfacility.xml /usr/share/LinuxTraceToolkitViewer/facilities
+
+- Use genevent to create the c code and headers :
+su
+cd /tmp
+mkdir genevent
+cd genevent
+for a in /usr/share/LinuxTraceToolkitViewer/facilities/user_*.xml;
+ do /usr/local/bin/genevent $a;
+done
+cd /usr/src/usertrace-generic
+cp /tmp/genevent/*load* .
+cd ltt
+cp /tmp/genevent/ltt-facility-id-user_myfacility.h .
+cp /tmp/genevent/ltt-facility-user_myfacility.h .
+cd ..
+make install
+
+- Add the following statements to your program source (the define must come
+ _before_ the includes!) :
+
+#define LTT_TRACE
+#define LTT_BLOCKING 1
+#include <ltt/ltt-facility-user_myfacility.h>
+
+- Add a call following the trace_user_myfacility_myevent function found in
+ /usr/include/ltt/ltt-facility-user_myfacility.h in your program.
+For instance :
+trace_user_myfacility_myevent(__FILE__, __func__, __LINE__, 1234, (void*)0xF0F0F0F0);
+
+- Compile your application with at least these parameters to gcc (it is splitted
+ on two lines, joined by a "\") :
+gcc -I /usr/src/usertrace-generic -o myapp myapp.c \
+ /usr/src/usertrace-generic/ltt-facility-loader-user_myfacility.c
+
+To see what the final result looks like :
+- Start tracing
+- Start your application
+- Stop tracing
+Then, to see only the user_myfacility events :
+lttv -m textDump -t /tmp/trace1 -e "event.facility=user_myfacility"
+
+It will show, for example :
+user_myfacility.myevent: 39507.805584526 (/cpu_1), 15829, 15736, SYSCALL { "myapp.c", "main", 8, 1234, 0xf0f0f0f0 }
+
+
+* Fun feature : function instrumentation
+
+Here is how to generate a full trace of you program function calls.
+See the sample-instrument-fct.c example program.
+
+- Compile your application with at least these parameters to gcc (it is splitted
+ on two lines, joined by a "\") :
+gcc -g -finstrument-functions \
+ -lltt-instrument-functions -o myapp myapp.c
+
+To see what the final result looks like :
+- Start tracing
+- Start your application
+- Stop tracing
+Then, to see only the function_entry and function_exit events :
+lttv -m textDump -t /tmp/trace1 -e "event.facility=user_generic & (event.name=function_entry & event.name=function_exit)"
+
+It will show, for example :
+user_generic.function_entry: 59329.709939111 (/cpu_0), 19250, 18581, SYSCALL { 0x8048454, 0x80484c2 }
+user_generic.function_exit: 59329.709944613 (/cpu_0), 19250, 18581, SYSCALL { 0x8048454, 0x80484c2 }
+
+you can then use (from the binutils package)
+addr2line -e sample-instrument-fct -i -f 0x8048454
+Which shows :
+test_function
+/usr/src/usertrace-generic/sample-instrument-fct.c:12
+
+The lookup in LTTV through libbfd has not been implemented yet.
+
+
--- /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_BLOCKING 1
+#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);
+}
+
--- /dev/null
+#ifndef _LTT_FACILITY_CUSTOM_USER_GENERIC_H_
+#define _LTT_FACILITY_CUSTOM_USER_GENERIC_H_
+
+#include <sys/types.h>
+#include <ltt/ltt-facility-id-user_generic.h>
+#include <ltt/ltt-generic.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+static inline int trace_user_generic_slow_printf(
+ const char *fmt, ...)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ /* Guess we need no more than 100 bytes. */
+ int n, size = 100;
+ char *p, *np;
+ va_list ap;
+ int ret;
+
+ if ((p = malloc (size)) == NULL)
+ return -1;
+
+ while (1) {
+ /* Try to print in the allocated space. */
+ va_start(ap, fmt);
+ n = vsnprintf (p, size, fmt, ap);
+ va_end(ap);
+ /* If that worked, trace the string. */
+ if (n > -1 && n < size) {
+ ret = trace_user_generic_slow_printf_param_buffer(p, n+1);
+ free(p);
+ return ret;
+ }
+ /* Else try again with more space. */
+ if (n > -1) /* glibc 2.1 */
+ size = n+1; /* precisely what is needed */
+ else /* glibc 2.0 */
+ size *= 2; /* twice the old size */
+ if ((np = realloc (p, size)) == NULL) {
+ free(p);
+ return -1;
+ } else {
+ p = np;
+ }
+ }
+}
+#endif //LTT_TRACE
+
+#endif //_LTT_FACILITY_CUSTOM_USER_GENERIC_H_
--- /dev/null
+#ifndef _LTT_FACILITY_ID_USER_GENERIC_H_
+#define _LTT_FACILITY_ID_USER_GENERIC_H_
+
+#ifdef LTT_TRACE
+#include <ltt/ltt-generic.h>
+
+/**** facility handle ****/
+
+extern ltt_facility_t ltt_facility_user_generic_F583779E;
+extern ltt_facility_t ltt_facility_user_generic;
+
+
+/**** event index ****/
+
+enum user_generic_event {
+ event_user_generic_string,
+ event_user_generic_string_pointer,
+ event_user_generic_slow_printf,
+ event_user_generic_function_entry,
+ event_user_generic_function_exit,
+ facility_user_generic_num_events
+};
+
+#endif //LTT_TRACE
+#endif //_LTT_FACILITY_ID_USER_GENERIC_H_
--- /dev/null
+#ifndef _LTT_FACILITY_USER_GENERIC_H_
+#define _LTT_FACILITY_USER_GENERIC_H_
+
+#include <sys/types.h>
+#include <ltt/ltt-facility-id-user_generic.h>
+#include <ltt/ltt-generic.h>
+
+/* Named types */
+
+/* Event string structures */
+static inline void lttng_write_string_user_generic_string_data(
+ void *buffer,
+ size_t *to_base,
+ size_t *to,
+ const void **from,
+ size_t *len,
+ const char * obj)
+{
+ size_t size;
+ size_t align;
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ if(buffer != NULL)
+ memcpy(buffer+*to_base+*to, *from, *len);
+ }
+ *to += *len;
+ *len = 0;
+
+ align = sizeof(char);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ /* Contains variable sized fields : must explode the structure */
+
+ size = strlen(obj) + 1; /* Include final NULL char. */
+ if(buffer != NULL)
+ memcpy(buffer+*to_base+*to, obj, size);
+ *to += size;
+
+ /* Realign the *to_base on arch size, set *to to 0 */
+ *to += ltt_align(*to, sizeof(void *));
+ *to_base = *to_base+*to;
+ *to = 0;
+
+ /* Put source *from just after the C string */
+ *from += size;
+}
+
+
+/* Event string logging function */
+#ifndef LTT_TRACE_FAST
+static inline int trace_user_generic_string(
+ const char * lttng_param_data)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ int ret = 0;
+ void *buffer = NULL;
+ size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
+ size_t *to_base = &real_to_base;
+ size_t real_to = 0;
+ size_t *to = &real_to;
+ size_t real_len = 0;
+ size_t *len = &real_len;
+ size_t reserve_size;
+ size_t slot_size;
+ const void *real_from;
+ const void **from = &real_from;
+ /* For each field, calculate the field size. */
+ /* size = *to_base + *to + *len */
+ /* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+
+ *from = lttng_param_data;
+ lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
+
+ reserve_size = *to_base + *to + *len;
+ {
+ char stack_buffer[reserve_size];
+ buffer = stack_buffer;
+
+ *to_base = *to = *len = 0;
+
+ *from = lttng_param_data;
+ lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_string, buffer, reserve_size, LTT_BLOCKING);
+ }
+
+ return ret;
+
+}
+#endif //LTT_TRACE
+#endif //!LTT_TRACE_FAST
+
+#ifdef LTT_TRACE_FAST
+static inline int trace_user_generic_string(
+ const char * lttng_param_data)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ unsigned int index;
+ struct ltt_trace_info *trace = thread_trace_info;
+ struct ltt_buf *ltt_buf;
+ void *buffer = NULL;
+ size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
+ size_t *to_base = &real_to_base;
+ size_t real_to = 0;
+ size_t *to = &real_to;
+ size_t real_len = 0;
+ size_t *len = &real_len;
+ size_t reserve_size;
+ size_t slot_size;
+ const void *real_from;
+ const void **from = &real_from;
+ uint64_t tsc;
+ size_t before_hdr_pad, after_hdr_pad, header_size;
+
+ if(!trace) {
+ ltt_thread_init();
+ trace = thread_trace_info;
+ }
+
+
+ /* For each field, calculate the field size. */
+ /* size = *to_base + *to + *len */
+ /* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+
+ *from = lttng_param_data;
+ lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
+
+ reserve_size = *to_base + *to + *len;
+ trace->nesting++;
+ index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
+ event_user_generic_string);
+
+ {
+ ltt_buf = ltt_get_channel_from_index(trace, index);
+ slot_size = 0;
+ buffer = ltt_reserve_slot(trace, ltt_buf,
+ reserve_size, &slot_size, &tsc,
+ &before_hdr_pad, &after_hdr_pad, &header_size);
+ if(!buffer) goto end; /* buffer full */
+
+ *to_base = *to = *len = 0;
+
+ ltt_write_event_header(trace, ltt_buf, buffer,
+ ltt_facility_user_generic_F583779E, event_user_generic_string,
+ reserve_size, before_hdr_pad, tsc);
+ *to_base += before_hdr_pad + after_hdr_pad + header_size;
+
+ *from = lttng_param_data;
+ lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ ltt_commit_slot(ltt_buf, buffer, slot_size);
+
+}
+
+end:
+ trace->nesting--;
+}
+#endif //LTT_TRACE
+#endif //LTT_TRACE_FAST
+
+/* Event string_pointer structures */
+static inline void lttng_write_string_user_generic_string_pointer_string(
+ void *buffer,
+ size_t *to_base,
+ size_t *to,
+ const void **from,
+ size_t *len,
+ const char * obj)
+{
+ size_t size;
+ size_t align;
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ if(buffer != NULL)
+ memcpy(buffer+*to_base+*to, *from, *len);
+ }
+ *to += *len;
+ *len = 0;
+
+ align = sizeof(char);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ /* Contains variable sized fields : must explode the structure */
+
+ size = strlen(obj) + 1; /* Include final NULL char. */
+ if(buffer != NULL)
+ memcpy(buffer+*to_base+*to, obj, size);
+ *to += size;
+
+ /* Realign the *to_base on arch size, set *to to 0 */
+ *to += ltt_align(*to, sizeof(void *));
+ *to_base = *to_base+*to;
+ *to = 0;
+
+ /* Put source *from just after the C string */
+ *from += size;
+}
+
+
+/* Event string_pointer logging function */
+#ifndef LTT_TRACE_FAST
+static inline int trace_user_generic_string_pointer(
+ const char * lttng_param_string,
+ const void * lttng_param_pointer)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ int ret = 0;
+ void *buffer = NULL;
+ size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
+ size_t *to_base = &real_to_base;
+ size_t real_to = 0;
+ size_t *to = &real_to;
+ size_t real_len = 0;
+ size_t *len = &real_len;
+ size_t reserve_size;
+ size_t slot_size;
+ size_t align;
+ const void *real_from;
+ const void **from = &real_from;
+ /* For each field, calculate the field size. */
+ /* size = *to_base + *to + *len */
+ /* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+
+ *from = lttng_param_string;
+ lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
+
+ *from = <tng_param_pointer;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ reserve_size = *to_base + *to + *len;
+ {
+ char stack_buffer[reserve_size];
+ buffer = stack_buffer;
+
+ *to_base = *to = *len = 0;
+
+ *from = lttng_param_string;
+ lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ *from = <tng_param_pointer;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_string_pointer, buffer, reserve_size, LTT_BLOCKING);
+ }
+
+ return ret;
+
+}
+#endif //LTT_TRACE
+#endif //!LTT_TRACE_FAST
+
+#ifdef LTT_TRACE_FAST
+static inline int trace_user_generic_string_pointer(
+ const char * lttng_param_string,
+ const void * lttng_param_pointer)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ unsigned int index;
+ struct ltt_trace_info *trace = thread_trace_info;
+ struct ltt_buf *ltt_buf;
+ void *buffer = NULL;
+ size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
+ size_t *to_base = &real_to_base;
+ size_t real_to = 0;
+ size_t *to = &real_to;
+ size_t real_len = 0;
+ size_t *len = &real_len;
+ size_t reserve_size;
+ size_t slot_size;
+ size_t align;
+ const void *real_from;
+ const void **from = &real_from;
+ uint64_t tsc;
+ size_t before_hdr_pad, after_hdr_pad, header_size;
+
+ if(!trace) {
+ ltt_thread_init();
+ trace = thread_trace_info;
+ }
+
+
+ /* For each field, calculate the field size. */
+ /* size = *to_base + *to + *len */
+ /* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+
+ *from = lttng_param_string;
+ lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
+
+ *from = <tng_param_pointer;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ reserve_size = *to_base + *to + *len;
+ trace->nesting++;
+ index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
+ event_user_generic_string_pointer);
+
+ {
+ ltt_buf = ltt_get_channel_from_index(trace, index);
+ slot_size = 0;
+ buffer = ltt_reserve_slot(trace, ltt_buf,
+ reserve_size, &slot_size, &tsc,
+ &before_hdr_pad, &after_hdr_pad, &header_size);
+ if(!buffer) goto end; /* buffer full */
+
+ *to_base = *to = *len = 0;
+
+ ltt_write_event_header(trace, ltt_buf, buffer,
+ ltt_facility_user_generic_F583779E, event_user_generic_string_pointer,
+ reserve_size, before_hdr_pad, tsc);
+ *to_base += before_hdr_pad + after_hdr_pad + header_size;
+
+ *from = lttng_param_string;
+ lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ *from = <tng_param_pointer;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ ltt_commit_slot(ltt_buf, buffer, slot_size);
+
+}
+
+end:
+ trace->nesting--;
+}
+#endif //LTT_TRACE
+#endif //LTT_TRACE_FAST
+
+/* Event slow_printf structures */
+static inline void lttng_write_string_user_generic_slow_printf_string(
+ void *buffer,
+ size_t *to_base,
+ size_t *to,
+ const void **from,
+ size_t *len,
+ const char * obj)
+{
+ size_t size;
+ size_t align;
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ if(buffer != NULL)
+ memcpy(buffer+*to_base+*to, *from, *len);
+ }
+ *to += *len;
+ *len = 0;
+
+ align = sizeof(char);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ /* Contains variable sized fields : must explode the structure */
+
+ size = strlen(obj) + 1; /* Include final NULL char. */
+ if(buffer != NULL)
+ memcpy(buffer+*to_base+*to, obj, size);
+ *to += size;
+
+ /* Realign the *to_base on arch size, set *to to 0 */
+ *to += ltt_align(*to, sizeof(void *));
+ *to_base = *to_base+*to;
+ *to = 0;
+
+ /* Put source *from just after the C string */
+ *from += size;
+}
+
+
+/* Event slow_printf logging function */
+#ifndef LTT_TRACE_FAST
+static inline int trace_user_generic_slow_printf_param_buffer(
+ void *buffer,
+ size_t reserve_size)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ int ret = 0;
+ reserve_size = ltt_align(reserve_size, sizeof(void *));
+ {
+ ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_slow_printf, buffer, reserve_size, LTT_BLOCKING);
+ }
+
+ return ret;
+
+}
+#endif //LTT_TRACE
+#endif //!LTT_TRACE_FAST
+
+#ifdef LTT_TRACE_FAST
+static inline int trace_user_generic_slow_printf(
+ const char * lttng_param_string)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ unsigned int index;
+ struct ltt_trace_info *trace = thread_trace_info;
+ struct ltt_buf *ltt_buf;
+ void *buffer = NULL;
+ size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
+ size_t *to_base = &real_to_base;
+ size_t real_to = 0;
+ size_t *to = &real_to;
+ size_t real_len = 0;
+ size_t *len = &real_len;
+ size_t reserve_size;
+ size_t slot_size;
+ const void *real_from;
+ const void **from = &real_from;
+ uint64_t tsc;
+ size_t before_hdr_pad, after_hdr_pad, header_size;
+
+ if(!trace) {
+ ltt_thread_init();
+ trace = thread_trace_info;
+ }
+
+
+ /* For each field, calculate the field size. */
+ /* size = *to_base + *to + *len */
+ /* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+
+ *from = lttng_param_string;
+ lttng_write_string_user_generic_slow_printf_string(buffer, to_base, to, from, len, lttng_param_string);
+
+ reserve_size = *to_base + *to + *len;
+ trace->nesting++;
+ index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
+ event_user_generic_slow_printf);
+
+ {
+ ltt_buf = ltt_get_channel_from_index(trace, index);
+ slot_size = 0;
+ buffer = ltt_reserve_slot(trace, ltt_buf,
+ reserve_size, &slot_size, &tsc,
+ &before_hdr_pad, &after_hdr_pad, &header_size);
+ if(!buffer) goto end; /* buffer full */
+
+ *to_base = *to = *len = 0;
+
+ ltt_write_event_header(trace, ltt_buf, buffer,
+ ltt_facility_user_generic_F583779E, event_user_generic_slow_printf,
+ reserve_size, before_hdr_pad, tsc);
+ *to_base += before_hdr_pad + after_hdr_pad + header_size;
+
+ *from = lttng_param_string;
+ lttng_write_string_user_generic_slow_printf_string(buffer, to_base, to, from, len, lttng_param_string);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ ltt_commit_slot(ltt_buf, buffer, slot_size);
+
+}
+
+end:
+ trace->nesting--;
+}
+#endif //LTT_TRACE
+#endif //LTT_TRACE_FAST
+
+/* Event function_entry structures */
+
+/* Event function_entry logging function */
+#ifndef LTT_TRACE_FAST
+static inline __attribute__((no_instrument_function)) int trace_user_generic_function_entry(
+ const void * lttng_param_this_fn,
+ const void * lttng_param_call_site)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ int ret = 0;
+ void *buffer = NULL;
+ size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
+ size_t *to_base = &real_to_base;
+ size_t real_to = 0;
+ size_t *to = &real_to;
+ size_t real_len = 0;
+ size_t *len = &real_len;
+ size_t reserve_size;
+ size_t slot_size;
+ size_t align;
+ const void *real_from;
+ const void **from = &real_from;
+ /* For each field, calculate the field size. */
+ /* size = *to_base + *to + *len */
+ /* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+
+ *from = <tng_param_this_fn;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ *from = <tng_param_call_site;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ reserve_size = *to_base + *to + *len;
+ {
+ char stack_buffer[reserve_size];
+ buffer = stack_buffer;
+
+ *to_base = *to = *len = 0;
+
+ *from = <tng_param_this_fn;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ *from = <tng_param_call_site;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_function_entry, buffer, reserve_size, LTT_BLOCKING);
+ }
+
+ return ret;
+
+}
+#endif //LTT_TRACE
+#endif //!LTT_TRACE_FAST
+
+#ifdef LTT_TRACE_FAST
+static inline __attribute__((no_instrument_function)) int trace_user_generic_function_entry(
+ const void * lttng_param_this_fn,
+ const void * lttng_param_call_site)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ unsigned int index;
+ struct ltt_trace_info *trace = thread_trace_info;
+ struct ltt_buf *ltt_buf;
+ void *buffer = NULL;
+ size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
+ size_t *to_base = &real_to_base;
+ size_t real_to = 0;
+ size_t *to = &real_to;
+ size_t real_len = 0;
+ size_t *len = &real_len;
+ size_t reserve_size;
+ size_t slot_size;
+ size_t align;
+ const void *real_from;
+ const void **from = &real_from;
+ uint64_t tsc;
+ size_t before_hdr_pad, after_hdr_pad, header_size;
+
+ if(!trace) {
+ ltt_thread_init();
+ trace = thread_trace_info;
+ }
+
+
+ /* For each field, calculate the field size. */
+ /* size = *to_base + *to + *len */
+ /* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+
+ *from = <tng_param_this_fn;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ *from = <tng_param_call_site;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ reserve_size = *to_base + *to + *len;
+ trace->nesting++;
+ index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
+ event_user_generic_function_entry);
+
+ {
+ ltt_buf = ltt_get_channel_from_index(trace, index);
+ slot_size = 0;
+ buffer = ltt_reserve_slot(trace, ltt_buf,
+ reserve_size, &slot_size, &tsc,
+ &before_hdr_pad, &after_hdr_pad, &header_size);
+ if(!buffer) goto end; /* buffer full */
+
+ *to_base = *to = *len = 0;
+
+ ltt_write_event_header(trace, ltt_buf, buffer,
+ ltt_facility_user_generic_F583779E, event_user_generic_function_entry,
+ reserve_size, before_hdr_pad, tsc);
+ *to_base += before_hdr_pad + after_hdr_pad + header_size;
+
+ *from = <tng_param_this_fn;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ *from = <tng_param_call_site;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ ltt_commit_slot(ltt_buf, buffer, slot_size);
+
+}
+
+end:
+ trace->nesting--;
+}
+#endif //LTT_TRACE
+#endif //LTT_TRACE_FAST
+
+/* Event function_exit structures */
+
+/* Event function_exit logging function */
+#ifndef LTT_TRACE_FAST
+static inline __attribute__((no_instrument_function)) int trace_user_generic_function_exit(
+ const void * lttng_param_this_fn,
+ const void * lttng_param_call_site)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ int ret = 0;
+ void *buffer = NULL;
+ size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
+ size_t *to_base = &real_to_base;
+ size_t real_to = 0;
+ size_t *to = &real_to;
+ size_t real_len = 0;
+ size_t *len = &real_len;
+ size_t reserve_size;
+ size_t slot_size;
+ size_t align;
+ const void *real_from;
+ const void **from = &real_from;
+ /* For each field, calculate the field size. */
+ /* size = *to_base + *to + *len */
+ /* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+
+ *from = <tng_param_this_fn;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ *from = <tng_param_call_site;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ reserve_size = *to_base + *to + *len;
+ {
+ char stack_buffer[reserve_size];
+ buffer = stack_buffer;
+
+ *to_base = *to = *len = 0;
+
+ *from = <tng_param_this_fn;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ *from = <tng_param_call_site;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_function_exit, buffer, reserve_size, LTT_BLOCKING);
+ }
+
+ return ret;
+
+}
+#endif //LTT_TRACE
+#endif //!LTT_TRACE_FAST
+
+#ifdef LTT_TRACE_FAST
+static inline __attribute__((no_instrument_function)) int trace_user_generic_function_exit(
+ const void * lttng_param_this_fn,
+ const void * lttng_param_call_site)
+#ifndef LTT_TRACE
+{
+}
+#else
+{
+ unsigned int index;
+ struct ltt_trace_info *trace = thread_trace_info;
+ struct ltt_buf *ltt_buf;
+ void *buffer = NULL;
+ size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
+ size_t *to_base = &real_to_base;
+ size_t real_to = 0;
+ size_t *to = &real_to;
+ size_t real_len = 0;
+ size_t *len = &real_len;
+ size_t reserve_size;
+ size_t slot_size;
+ size_t align;
+ const void *real_from;
+ const void **from = &real_from;
+ uint64_t tsc;
+ size_t before_hdr_pad, after_hdr_pad, header_size;
+
+ if(!trace) {
+ ltt_thread_init();
+ trace = thread_trace_info;
+ }
+
+
+ /* For each field, calculate the field size. */
+ /* size = *to_base + *to + *len */
+ /* Assume that the padding for alignment starts at a
+ * sizeof(void *) address. */
+
+ *from = <tng_param_this_fn;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ *from = <tng_param_call_site;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ reserve_size = *to_base + *to + *len;
+ trace->nesting++;
+ index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
+ event_user_generic_function_exit);
+
+ {
+ ltt_buf = ltt_get_channel_from_index(trace, index);
+ slot_size = 0;
+ buffer = ltt_reserve_slot(trace, ltt_buf,
+ reserve_size, &slot_size, &tsc,
+ &before_hdr_pad, &after_hdr_pad, &header_size);
+ if(!buffer) goto end; /* buffer full */
+
+ *to_base = *to = *len = 0;
+
+ ltt_write_event_header(trace, ltt_buf, buffer,
+ ltt_facility_user_generic_F583779E, event_user_generic_function_exit,
+ reserve_size, before_hdr_pad, tsc);
+ *to_base += before_hdr_pad + after_hdr_pad + header_size;
+
+ *from = <tng_param_this_fn;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ *from = <tng_param_call_site;
+ align = sizeof(const void *);
+
+ if(*len == 0) {
+ *to += ltt_align(*to, align); /* align output */
+ } else {
+ *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
+ }
+
+ *len += sizeof(const void *);
+
+ /* Flush pending memcpy */
+ if(*len != 0) {
+ memcpy(buffer+*to_base+*to, *from, *len);
+ *to += *len;
+ *len = 0;
+ }
+
+ ltt_commit_slot(ltt_buf, buffer, slot_size);
+
+}
+
+end:
+ trace->nesting--;
+}
+#endif //LTT_TRACE
+#endif //LTT_TRACE_FAST
+
+#endif //_LTT_FACILITY_USER_GENERIC_H_
--- /dev/null
+/*****************************************************************************
+ * ltt-generic.h
+ *
+ * LTT generic userspace tracing header
+ *
+ * Mathieu Desnoyers, March 2006
+ */
+
+#ifndef _LTT_GENERIC_H
+#define _LTT_GENERIC_H
+
+#include <errno.h>
+#include <syscall.h>
+#include <linux/unistd.h>
+#include <asm/atomic.h>
+#include <string.h>
+#include <sys/types.h>
+#include <stdint.h>
+
+#ifndef min
+#define min(a,b) ((a)<(b)?(a):(b))
+#endif
+
+//Put in asm-i486/unistd.h
+#define __NR_ltt_trace_generic 294
+#define __NR_ltt_register_generic 295
+
+#undef NR_syscalls
+#define NR_syscalls 296
+
+//FIXME : setup for ARM
+//FIXME : setup for MIPS
+
+#ifndef _LIBC
+// Put in bits/syscall.h
+#define SYS_ltt_trace_generic __NR_ltt_trace_generic
+#define SYS_ltt_register_generic __NR_ltt_register_generic
+#endif
+
+#define FACNAME_LEN 32
+
+/* LTT userspace tracing is non blocking by default when buffers are full */
+#ifndef LTT_BLOCKING
+#define LTT_BLOCKING 0
+#endif //LTT_BLOCKING
+
+typedef unsigned int ltt_facility_t;
+
+struct user_facility_info {
+ char name[FACNAME_LEN];
+ unsigned int num_events;
+ size_t alignment;
+ uint32_t checksum;
+ size_t int_size;
+ size_t long_size;
+ size_t pointer_size;
+ size_t size_t_size;
+};
+
+static inline __attribute__((no_instrument_function))
+_syscall5(int, ltt_trace_generic, unsigned int, facility_id,
+ unsigned int, event_id, void *, data, size_t, data_size, int, blocking)
+static inline __attribute__((no_instrument_function))
+_syscall2(int, ltt_register_generic, unsigned int *, facility_id,
+ const struct user_facility_info *, info)
+
+#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
+
+#endif //_LTT_GENERIC_H
+
+
--- /dev/null
+
+#include <stdio.h>
+#include <unistd.h>
+
+#define LTT_TRACE
+#define LTT_BLOCKING 1
+#include <ltt/ltt-facility-user_generic.h>
+
+
+int main(int argc, char **argv)
+{
+ printf("Will trace the following string : Running fast! in a infinite loop.\n");
+
+ while(1) {
+ trace_user_generic_string("Running fast!");
+ }
+
+ return 0;
+}
+
--- /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;
+}
+
--- /dev/null
+
+#include <stdio.h>
+#include <unistd.h>
+
+#define LTT_TRACE
+#define LTT_BLOCKING 1
+#include <ltt/ltt-facility-user_generic.h>
+#include <ltt/ltt-facility-custom-user_generic.h>
+
+
+int main(int argc, char **argv)
+{
+ printf("Will trace a printf of an incrementing counter.\n");
+ unsigned int count = 0;
+
+ while(1) {
+ trace_user_generic_slow_printf("in: %s at: %s:%d: Counter value is: %u.",
+ __FILE__, __func__, __LINE__, count);
+ count++;
+ sleep(1);
+ }
+
+ return 0;
+}
+
--- /dev/null
+
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#define LTT_TRACE
+#include <ltt/ltt-facility-user_generic.h>
+
+
+void *thr1(void *arg)
+{
+ printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+
+ while(1) {
+ trace_user_generic_string("Hello world! Have a nice day.");
+ sleep(2);
+ }
+
+ return ((void*)1);
+
+}
+
+void *thr2(void *arg)
+{
+ printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
+ sleep(1);
+ while(1) {
+ trace_user_generic_string("Hello world! Have a nice day.");
+ sleep(2);
+ }
+ return ((void*)2);
+}
+
+
+int main()
+{
+ int err;
+ pthread_t tid1, tid2;
+ void *tret;
+
+ printf("Will trace the following string : Hello world! Have a nice day.\n");
+ printf("Press CTRL-C to stop.\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);
+
+ 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(tid2, &tret);
+ if(err!= 0) exit(1);
+
+ return 0;
+}
--- /dev/null
+
+#include <stdio.h>
+#include <unistd.h>
+
+#define LTT_TRACE
+#define LTT_BLOCKING 1
+#include <ltt/ltt-facility-user_generic.h>
+
+
+int main(int argc, char **argv)
+{
+ printf("Will trace the following string : Hello world! Have a nice day.\n");
+
+ while(1) {
+ trace_user_generic_string("Hello world! Have a nice day.");
+ sleep(1);
+ }
+
+ return 0;
+}
+
--- /dev/null
+<facility name=user_generic>
+ <description>Generic user space facility</description>
+
+ <event name=string>
+ <description>Takes a string from user space</description>
+ <field name="data"><string/></field>
+ </event>
+
+ <event name=string_pointer>
+ <description>Takes a string and pointer from user space</description>
+ <field name="string"><string/></field>
+ <field name="pointer"><pointer/></field>
+ </event>
+
+ <event name=slow_printf param_buffer>
+ <description>Takes a buffer of variable size (written by printf) and log it.</description>
+ <field name="string"><string/></field>
+ </event>
+
+ <event name=function_entry no_instrument_function>
+ <description>Entry in a function</description>
+ <field name="this_fn"><pointer/></field>
+ <field name="call_site"><pointer/></field>
+ </event>
+
+ <event name=function_exit no_instrument_function>
+ <description>Exit from a function</description>
+ <field name="this_fn"><pointer/></field>
+ <field name="call_site"><pointer/></field>
+ </event>
+
+</facility>
+++ /dev/null
-
-CC=gcc
-INCLUDE_DIR=/usr/include
-LIB_DIR=/usr/lib
-RANLIB=ranlib
-
-all: libltt-instrument-functions.a libltt-instrument-functions.so.0 sample-thread sample sample-highspeed sample-printf sample-instrument-fct
-
-sample-thread: sample-thread.c ltt-facility-loader-user_generic.c
- $(CC) $(CFLAGS) -lpthread -o $@ $^
-
-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) -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 $@ $^
-
-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
-
-.PHONY : clean install
-
-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)
-
-clean:
- rm -fr *.o *~ sample-thread sample sample-highspeed sample-printf sample-instrument-fct libltt-instrument-functions.so* libltt-instrument-functions.a
-
+++ /dev/null
-
-LTTng usertrace generic package
-
-Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
-March 2006
-
-This package contains all the user space headers and c files necessary to make
-your application and library trace through an active LTTng tracer. Here is a
-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)
-
-* Compile your kernel with the latest LTTng patch. Make sure the option
- "Allow tracing from userspace" is _active_!
- See the QUICKSTART guide at http://ltt.polymtl.ca/ for details about how to
- setup a working tracer and viewer. See the genevent installation step : it is
- required for method #2 below.
-
-* Extract the latest usertrace-generic 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 -
-
-* Build the sample programs and install the headers into your system :
-su
-cd /usr/src/usertrace-generic
-make
-make install
-
-* There are two ways to trace information from your application :
-
-1) Easy way, but slow (printf style)
- See sample-printf.c for code example.
-
-- Add the following statements to your program source (the define must come
- _before_ the includes!) :
-
-#define LTT_TRACE
-#define LTT_BLOCKING 1
-#include <ltt/ltt-facility-user_generic.h>
-#include <ltt/ltt-facility-custom-user_generic.h>
-
-Note the define of LTT_BLOCKING to 1 : if a trace buffer is full, your
-application will block. The default of this parameter is 0 (non blocking) :
-events are lost when trace buffer is full. The choice is up to you.
-
-- Add something like the following sample line in your code. Note that this is a
- very standard format string, this is only a suggested presentation.
-
-trace_user_generic_slow_printf("in: %s at: %s:%d: Counter value is: %u.",
- __FILE__, __func__, __LINE__, count);
-
-- Compile your application with at least these parameters to gcc (it is splitted
- on two lines, joined by a "\") :
-gcc -D LTT_SHOW_DEBUG -I /usr/src/usertrace-generic -o myapp myapp.c \
- /usr/src/usertrace-generic/ltt-facility-loader-user_generic.c
-
-To see what the final result looks like :
-- Start tracing
-- Start your application
- ** You should see the following message when your program starts and the
- LTT_SHOW_DEBUG is defined :
- "LTT : ltt-facility-user_generic init in userspace"
- If you don't then you forgot to compile the facility loader in your
- application. If you find this output annoying, you can remove the
- "-D LTT_SHOW_DEBUG" gcc parameter, which will make the facility loader
- silent.
-- Stop tracing
-Then, to see only the user_generic events :
-lttv -m textDump -t /tmp/trace1 -e "event.facility=user_generic"
-
-It will show :
-user_generic.slow_printf: 35885.922829472 (/cpu_0), 15521, 7453, SYSCALL { "in: sample-printf.c at: main:18: Counter value is: 0." }
-user_generic.slow_printf: 35886.925685289 (/cpu_0), 15521, 7453, SYSCALL { "in: sample-printf.c at: main:18: Counter value is: 1." }
-...
-
-
-
-2) The second way to log events is still easy, yet faster. It requires creating
- your own XML description of your data structures. It will make it easier to
- identify your data in the trace. Please read the comments in method 1)
- explained previously, as they are not repeated here.
- See sample.c for code example.
-
-- Go to the usertrace-generic directory
-su
-cd /usr/src/usertrace-generic
-
-- Create your own facility (i.e. user_myfacility.xml).
- See the ones available in /usr/share/LinuxTraceToolkitViewer/facilities for
- examples.
- You facility _must_ be named following this standard : "user_*", where * is
- whatever you like. If it is not, it will be rejected by the kernel with a
- Operation not permitted (can be seen with the -D LTT_SHOW_DEBUG compilation
- parameter).
-
-user_myfacility.xml:
-
-<facility name="user_myfacility">
- <description>Sample facility</description>
- <event name="myevent">
- <description>Sample event</description>
- <field name="file"><string></field>
- <field name="function"><string></field>
- <field name="line"><int></field>
- <field name="firstval"><long></field>
- <field name="secondval"><pointer></field>
- </event>
-</facility>
-
-- AN IMPORTANT STEP FOLLOWS :
- *copy* the user_myfacility.xml file in your system :
-su
-cp user_myfacility.xml /usr/share/LinuxTraceToolkitViewer/facilities
-
-- Use genevent to create the c code and headers :
-su
-cd /tmp
-mkdir genevent
-cd genevent
-for a in /usr/share/LinuxTraceToolkitViewer/facilities/user_*.xml;
- do /usr/local/bin/genevent $a;
-done
-cd /usr/src/usertrace-generic
-cp /tmp/genevent/*load* .
-cd ltt
-cp /tmp/genevent/ltt-facility-id-user_myfacility.h .
-cp /tmp/genevent/ltt-facility-user_myfacility.h .
-cd ..
-make install
-
-- Add the following statements to your program source (the define must come
- _before_ the includes!) :
-
-#define LTT_TRACE
-#define LTT_BLOCKING 1
-#include <ltt/ltt-facility-user_myfacility.h>
-
-- Add a call following the trace_user_myfacility_myevent function found in
- /usr/include/ltt/ltt-facility-user_myfacility.h in your program.
-For instance :
-trace_user_myfacility_myevent(__FILE__, __func__, __LINE__, 1234, (void*)0xF0F0F0F0);
-
-- Compile your application with at least these parameters to gcc (it is splitted
- on two lines, joined by a "\") :
-gcc -I /usr/src/usertrace-generic -o myapp myapp.c \
- /usr/src/usertrace-generic/ltt-facility-loader-user_myfacility.c
-
-To see what the final result looks like :
-- Start tracing
-- Start your application
-- Stop tracing
-Then, to see only the user_myfacility events :
-lttv -m textDump -t /tmp/trace1 -e "event.facility=user_myfacility"
-
-It will show, for example :
-user_myfacility.myevent: 39507.805584526 (/cpu_1), 15829, 15736, SYSCALL { "myapp.c", "main", 8, 1234, 0xf0f0f0f0 }
-
-
-* Fun feature : function instrumentation
-
-Here is how to generate a full trace of you program function calls.
-See the sample-instrument-fct.c example program.
-
-- Compile your application with at least these parameters to gcc (it is splitted
- on two lines, joined by a "\") :
-gcc -g -finstrument-functions \
- -lltt-instrument-functions -o myapp myapp.c
-
-To see what the final result looks like :
-- Start tracing
-- Start your application
-- Stop tracing
-Then, to see only the function_entry and function_exit events :
-lttv -m textDump -t /tmp/trace1 -e "event.facility=user_generic & (event.name=function_entry & event.name=function_exit)"
-
-It will show, for example :
-user_generic.function_entry: 59329.709939111 (/cpu_0), 19250, 18581, SYSCALL { 0x8048454, 0x80484c2 }
-user_generic.function_exit: 59329.709944613 (/cpu_0), 19250, 18581, SYSCALL { 0x8048454, 0x80484c2 }
-
-you can then use (from the binutils package)
-addr2line -e sample-instrument-fct -i -f 0x8048454
-Which shows :
-test_function
-/usr/src/usertrace-generic/sample-instrument-fct.c:12
-
-The lookup in LTTV through libbfd has not been implemented yet.
-
-
+++ /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_BLOCKING 1
-#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);
-}
-
+++ /dev/null
-#ifndef _LTT_FACILITY_CUSTOM_USER_GENERIC_H_
-#define _LTT_FACILITY_CUSTOM_USER_GENERIC_H_
-
-#include <sys/types.h>
-#include <ltt/ltt-facility-id-user_generic.h>
-#include <ltt/ltt-generic.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-static inline int trace_user_generic_slow_printf(
- const char *fmt, ...)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- /* Guess we need no more than 100 bytes. */
- int n, size = 100;
- char *p, *np;
- va_list ap;
- int ret;
-
- if ((p = malloc (size)) == NULL)
- return -1;
-
- while (1) {
- /* Try to print in the allocated space. */
- va_start(ap, fmt);
- n = vsnprintf (p, size, fmt, ap);
- va_end(ap);
- /* If that worked, trace the string. */
- if (n > -1 && n < size) {
- ret = trace_user_generic_slow_printf_param_buffer(p, n+1);
- free(p);
- return ret;
- }
- /* Else try again with more space. */
- if (n > -1) /* glibc 2.1 */
- size = n+1; /* precisely what is needed */
- else /* glibc 2.0 */
- size *= 2; /* twice the old size */
- if ((np = realloc (p, size)) == NULL) {
- free(p);
- return -1;
- } else {
- p = np;
- }
- }
-}
-#endif //LTT_TRACE
-
-#endif //_LTT_FACILITY_CUSTOM_USER_GENERIC_H_
+++ /dev/null
-#ifndef _LTT_FACILITY_ID_USER_GENERIC_H_
-#define _LTT_FACILITY_ID_USER_GENERIC_H_
-
-#ifdef LTT_TRACE
-#include <ltt/ltt-generic.h>
-
-/**** facility handle ****/
-
-extern ltt_facility_t ltt_facility_user_generic_F583779E;
-extern ltt_facility_t ltt_facility_user_generic;
-
-
-/**** event index ****/
-
-enum user_generic_event {
- event_user_generic_string,
- event_user_generic_string_pointer,
- event_user_generic_slow_printf,
- event_user_generic_function_entry,
- event_user_generic_function_exit,
- facility_user_generic_num_events
-};
-
-#endif //LTT_TRACE
-#endif //_LTT_FACILITY_ID_USER_GENERIC_H_
+++ /dev/null
-#ifndef _LTT_FACILITY_USER_GENERIC_H_
-#define _LTT_FACILITY_USER_GENERIC_H_
-
-#include <sys/types.h>
-#include <ltt/ltt-facility-id-user_generic.h>
-#include <ltt/ltt-generic.h>
-
-/* Named types */
-
-/* Event string structures */
-static inline void lttng_write_string_user_generic_string_data(
- void *buffer,
- size_t *to_base,
- size_t *to,
- const void **from,
- size_t *len,
- const char * obj)
-{
- size_t size;
- size_t align;
-
- /* Flush pending memcpy */
- if(*len != 0) {
- if(buffer != NULL)
- memcpy(buffer+*to_base+*to, *from, *len);
- }
- *to += *len;
- *len = 0;
-
- align = sizeof(char);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- /* Contains variable sized fields : must explode the structure */
-
- size = strlen(obj) + 1; /* Include final NULL char. */
- if(buffer != NULL)
- memcpy(buffer+*to_base+*to, obj, size);
- *to += size;
-
- /* Realign the *to_base on arch size, set *to to 0 */
- *to += ltt_align(*to, sizeof(void *));
- *to_base = *to_base+*to;
- *to = 0;
-
- /* Put source *from just after the C string */
- *from += size;
-}
-
-
-/* Event string logging function */
-#ifndef LTT_TRACE_FAST
-static inline int trace_user_generic_string(
- const char * lttng_param_data)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- int ret = 0;
- void *buffer = NULL;
- size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
- size_t *to_base = &real_to_base;
- size_t real_to = 0;
- size_t *to = &real_to;
- size_t real_len = 0;
- size_t *len = &real_len;
- size_t reserve_size;
- size_t slot_size;
- const void *real_from;
- const void **from = &real_from;
- /* For each field, calculate the field size. */
- /* size = *to_base + *to + *len */
- /* Assume that the padding for alignment starts at a
- * sizeof(void *) address. */
-
- *from = lttng_param_data;
- lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
-
- reserve_size = *to_base + *to + *len;
- {
- char stack_buffer[reserve_size];
- buffer = stack_buffer;
-
- *to_base = *to = *len = 0;
-
- *from = lttng_param_data;
- lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_string, buffer, reserve_size, LTT_BLOCKING);
- }
-
- return ret;
-
-}
-#endif //LTT_TRACE
-#endif //!LTT_TRACE_FAST
-
-#ifdef LTT_TRACE_FAST
-static inline int trace_user_generic_string(
- const char * lttng_param_data)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- unsigned int index;
- struct ltt_trace_info *trace = thread_trace_info;
- struct ltt_buf *ltt_buf;
- void *buffer = NULL;
- size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
- size_t *to_base = &real_to_base;
- size_t real_to = 0;
- size_t *to = &real_to;
- size_t real_len = 0;
- size_t *len = &real_len;
- size_t reserve_size;
- size_t slot_size;
- const void *real_from;
- const void **from = &real_from;
- uint64_t tsc;
- size_t before_hdr_pad, after_hdr_pad, header_size;
-
- if(!trace) {
- ltt_thread_init();
- trace = thread_trace_info;
- }
-
-
- /* For each field, calculate the field size. */
- /* size = *to_base + *to + *len */
- /* Assume that the padding for alignment starts at a
- * sizeof(void *) address. */
-
- *from = lttng_param_data;
- lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
-
- reserve_size = *to_base + *to + *len;
- trace->nesting++;
- index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
- event_user_generic_string);
-
- {
- ltt_buf = ltt_get_channel_from_index(trace, index);
- slot_size = 0;
- buffer = ltt_reserve_slot(trace, ltt_buf,
- reserve_size, &slot_size, &tsc,
- &before_hdr_pad, &after_hdr_pad, &header_size);
- if(!buffer) goto end; /* buffer full */
-
- *to_base = *to = *len = 0;
-
- ltt_write_event_header(trace, ltt_buf, buffer,
- ltt_facility_user_generic_F583779E, event_user_generic_string,
- reserve_size, before_hdr_pad, tsc);
- *to_base += before_hdr_pad + after_hdr_pad + header_size;
-
- *from = lttng_param_data;
- lttng_write_string_user_generic_string_data(buffer, to_base, to, from, len, lttng_param_data);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- ltt_commit_slot(ltt_buf, buffer, slot_size);
-
-}
-
-end:
- trace->nesting--;
-}
-#endif //LTT_TRACE
-#endif //LTT_TRACE_FAST
-
-/* Event string_pointer structures */
-static inline void lttng_write_string_user_generic_string_pointer_string(
- void *buffer,
- size_t *to_base,
- size_t *to,
- const void **from,
- size_t *len,
- const char * obj)
-{
- size_t size;
- size_t align;
-
- /* Flush pending memcpy */
- if(*len != 0) {
- if(buffer != NULL)
- memcpy(buffer+*to_base+*to, *from, *len);
- }
- *to += *len;
- *len = 0;
-
- align = sizeof(char);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- /* Contains variable sized fields : must explode the structure */
-
- size = strlen(obj) + 1; /* Include final NULL char. */
- if(buffer != NULL)
- memcpy(buffer+*to_base+*to, obj, size);
- *to += size;
-
- /* Realign the *to_base on arch size, set *to to 0 */
- *to += ltt_align(*to, sizeof(void *));
- *to_base = *to_base+*to;
- *to = 0;
-
- /* Put source *from just after the C string */
- *from += size;
-}
-
-
-/* Event string_pointer logging function */
-#ifndef LTT_TRACE_FAST
-static inline int trace_user_generic_string_pointer(
- const char * lttng_param_string,
- const void * lttng_param_pointer)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- int ret = 0;
- void *buffer = NULL;
- size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
- size_t *to_base = &real_to_base;
- size_t real_to = 0;
- size_t *to = &real_to;
- size_t real_len = 0;
- size_t *len = &real_len;
- size_t reserve_size;
- size_t slot_size;
- size_t align;
- const void *real_from;
- const void **from = &real_from;
- /* For each field, calculate the field size. */
- /* size = *to_base + *to + *len */
- /* Assume that the padding for alignment starts at a
- * sizeof(void *) address. */
-
- *from = lttng_param_string;
- lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
-
- *from = <tng_param_pointer;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- reserve_size = *to_base + *to + *len;
- {
- char stack_buffer[reserve_size];
- buffer = stack_buffer;
-
- *to_base = *to = *len = 0;
-
- *from = lttng_param_string;
- lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- *from = <tng_param_pointer;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_string_pointer, buffer, reserve_size, LTT_BLOCKING);
- }
-
- return ret;
-
-}
-#endif //LTT_TRACE
-#endif //!LTT_TRACE_FAST
-
-#ifdef LTT_TRACE_FAST
-static inline int trace_user_generic_string_pointer(
- const char * lttng_param_string,
- const void * lttng_param_pointer)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- unsigned int index;
- struct ltt_trace_info *trace = thread_trace_info;
- struct ltt_buf *ltt_buf;
- void *buffer = NULL;
- size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
- size_t *to_base = &real_to_base;
- size_t real_to = 0;
- size_t *to = &real_to;
- size_t real_len = 0;
- size_t *len = &real_len;
- size_t reserve_size;
- size_t slot_size;
- size_t align;
- const void *real_from;
- const void **from = &real_from;
- uint64_t tsc;
- size_t before_hdr_pad, after_hdr_pad, header_size;
-
- if(!trace) {
- ltt_thread_init();
- trace = thread_trace_info;
- }
-
-
- /* For each field, calculate the field size. */
- /* size = *to_base + *to + *len */
- /* Assume that the padding for alignment starts at a
- * sizeof(void *) address. */
-
- *from = lttng_param_string;
- lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
-
- *from = <tng_param_pointer;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- reserve_size = *to_base + *to + *len;
- trace->nesting++;
- index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
- event_user_generic_string_pointer);
-
- {
- ltt_buf = ltt_get_channel_from_index(trace, index);
- slot_size = 0;
- buffer = ltt_reserve_slot(trace, ltt_buf,
- reserve_size, &slot_size, &tsc,
- &before_hdr_pad, &after_hdr_pad, &header_size);
- if(!buffer) goto end; /* buffer full */
-
- *to_base = *to = *len = 0;
-
- ltt_write_event_header(trace, ltt_buf, buffer,
- ltt_facility_user_generic_F583779E, event_user_generic_string_pointer,
- reserve_size, before_hdr_pad, tsc);
- *to_base += before_hdr_pad + after_hdr_pad + header_size;
-
- *from = lttng_param_string;
- lttng_write_string_user_generic_string_pointer_string(buffer, to_base, to, from, len, lttng_param_string);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- *from = <tng_param_pointer;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- ltt_commit_slot(ltt_buf, buffer, slot_size);
-
-}
-
-end:
- trace->nesting--;
-}
-#endif //LTT_TRACE
-#endif //LTT_TRACE_FAST
-
-/* Event slow_printf structures */
-static inline void lttng_write_string_user_generic_slow_printf_string(
- void *buffer,
- size_t *to_base,
- size_t *to,
- const void **from,
- size_t *len,
- const char * obj)
-{
- size_t size;
- size_t align;
-
- /* Flush pending memcpy */
- if(*len != 0) {
- if(buffer != NULL)
- memcpy(buffer+*to_base+*to, *from, *len);
- }
- *to += *len;
- *len = 0;
-
- align = sizeof(char);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- /* Contains variable sized fields : must explode the structure */
-
- size = strlen(obj) + 1; /* Include final NULL char. */
- if(buffer != NULL)
- memcpy(buffer+*to_base+*to, obj, size);
- *to += size;
-
- /* Realign the *to_base on arch size, set *to to 0 */
- *to += ltt_align(*to, sizeof(void *));
- *to_base = *to_base+*to;
- *to = 0;
-
- /* Put source *from just after the C string */
- *from += size;
-}
-
-
-/* Event slow_printf logging function */
-#ifndef LTT_TRACE_FAST
-static inline int trace_user_generic_slow_printf_param_buffer(
- void *buffer,
- size_t reserve_size)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- int ret = 0;
- reserve_size = ltt_align(reserve_size, sizeof(void *));
- {
- ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_slow_printf, buffer, reserve_size, LTT_BLOCKING);
- }
-
- return ret;
-
-}
-#endif //LTT_TRACE
-#endif //!LTT_TRACE_FAST
-
-#ifdef LTT_TRACE_FAST
-static inline int trace_user_generic_slow_printf(
- const char * lttng_param_string)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- unsigned int index;
- struct ltt_trace_info *trace = thread_trace_info;
- struct ltt_buf *ltt_buf;
- void *buffer = NULL;
- size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
- size_t *to_base = &real_to_base;
- size_t real_to = 0;
- size_t *to = &real_to;
- size_t real_len = 0;
- size_t *len = &real_len;
- size_t reserve_size;
- size_t slot_size;
- const void *real_from;
- const void **from = &real_from;
- uint64_t tsc;
- size_t before_hdr_pad, after_hdr_pad, header_size;
-
- if(!trace) {
- ltt_thread_init();
- trace = thread_trace_info;
- }
-
-
- /* For each field, calculate the field size. */
- /* size = *to_base + *to + *len */
- /* Assume that the padding for alignment starts at a
- * sizeof(void *) address. */
-
- *from = lttng_param_string;
- lttng_write_string_user_generic_slow_printf_string(buffer, to_base, to, from, len, lttng_param_string);
-
- reserve_size = *to_base + *to + *len;
- trace->nesting++;
- index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
- event_user_generic_slow_printf);
-
- {
- ltt_buf = ltt_get_channel_from_index(trace, index);
- slot_size = 0;
- buffer = ltt_reserve_slot(trace, ltt_buf,
- reserve_size, &slot_size, &tsc,
- &before_hdr_pad, &after_hdr_pad, &header_size);
- if(!buffer) goto end; /* buffer full */
-
- *to_base = *to = *len = 0;
-
- ltt_write_event_header(trace, ltt_buf, buffer,
- ltt_facility_user_generic_F583779E, event_user_generic_slow_printf,
- reserve_size, before_hdr_pad, tsc);
- *to_base += before_hdr_pad + after_hdr_pad + header_size;
-
- *from = lttng_param_string;
- lttng_write_string_user_generic_slow_printf_string(buffer, to_base, to, from, len, lttng_param_string);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- ltt_commit_slot(ltt_buf, buffer, slot_size);
-
-}
-
-end:
- trace->nesting--;
-}
-#endif //LTT_TRACE
-#endif //LTT_TRACE_FAST
-
-/* Event function_entry structures */
-
-/* Event function_entry logging function */
-#ifndef LTT_TRACE_FAST
-static inline __attribute__((no_instrument_function)) int trace_user_generic_function_entry(
- const void * lttng_param_this_fn,
- const void * lttng_param_call_site)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- int ret = 0;
- void *buffer = NULL;
- size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
- size_t *to_base = &real_to_base;
- size_t real_to = 0;
- size_t *to = &real_to;
- size_t real_len = 0;
- size_t *len = &real_len;
- size_t reserve_size;
- size_t slot_size;
- size_t align;
- const void *real_from;
- const void **from = &real_from;
- /* For each field, calculate the field size. */
- /* size = *to_base + *to + *len */
- /* Assume that the padding for alignment starts at a
- * sizeof(void *) address. */
-
- *from = <tng_param_this_fn;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- *from = <tng_param_call_site;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- reserve_size = *to_base + *to + *len;
- {
- char stack_buffer[reserve_size];
- buffer = stack_buffer;
-
- *to_base = *to = *len = 0;
-
- *from = <tng_param_this_fn;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- *from = <tng_param_call_site;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_function_entry, buffer, reserve_size, LTT_BLOCKING);
- }
-
- return ret;
-
-}
-#endif //LTT_TRACE
-#endif //!LTT_TRACE_FAST
-
-#ifdef LTT_TRACE_FAST
-static inline __attribute__((no_instrument_function)) int trace_user_generic_function_entry(
- const void * lttng_param_this_fn,
- const void * lttng_param_call_site)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- unsigned int index;
- struct ltt_trace_info *trace = thread_trace_info;
- struct ltt_buf *ltt_buf;
- void *buffer = NULL;
- size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
- size_t *to_base = &real_to_base;
- size_t real_to = 0;
- size_t *to = &real_to;
- size_t real_len = 0;
- size_t *len = &real_len;
- size_t reserve_size;
- size_t slot_size;
- size_t align;
- const void *real_from;
- const void **from = &real_from;
- uint64_t tsc;
- size_t before_hdr_pad, after_hdr_pad, header_size;
-
- if(!trace) {
- ltt_thread_init();
- trace = thread_trace_info;
- }
-
-
- /* For each field, calculate the field size. */
- /* size = *to_base + *to + *len */
- /* Assume that the padding for alignment starts at a
- * sizeof(void *) address. */
-
- *from = <tng_param_this_fn;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- *from = <tng_param_call_site;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- reserve_size = *to_base + *to + *len;
- trace->nesting++;
- index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
- event_user_generic_function_entry);
-
- {
- ltt_buf = ltt_get_channel_from_index(trace, index);
- slot_size = 0;
- buffer = ltt_reserve_slot(trace, ltt_buf,
- reserve_size, &slot_size, &tsc,
- &before_hdr_pad, &after_hdr_pad, &header_size);
- if(!buffer) goto end; /* buffer full */
-
- *to_base = *to = *len = 0;
-
- ltt_write_event_header(trace, ltt_buf, buffer,
- ltt_facility_user_generic_F583779E, event_user_generic_function_entry,
- reserve_size, before_hdr_pad, tsc);
- *to_base += before_hdr_pad + after_hdr_pad + header_size;
-
- *from = <tng_param_this_fn;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- *from = <tng_param_call_site;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- ltt_commit_slot(ltt_buf, buffer, slot_size);
-
-}
-
-end:
- trace->nesting--;
-}
-#endif //LTT_TRACE
-#endif //LTT_TRACE_FAST
-
-/* Event function_exit structures */
-
-/* Event function_exit logging function */
-#ifndef LTT_TRACE_FAST
-static inline __attribute__((no_instrument_function)) int trace_user_generic_function_exit(
- const void * lttng_param_this_fn,
- const void * lttng_param_call_site)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- int ret = 0;
- void *buffer = NULL;
- size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
- size_t *to_base = &real_to_base;
- size_t real_to = 0;
- size_t *to = &real_to;
- size_t real_len = 0;
- size_t *len = &real_len;
- size_t reserve_size;
- size_t slot_size;
- size_t align;
- const void *real_from;
- const void **from = &real_from;
- /* For each field, calculate the field size. */
- /* size = *to_base + *to + *len */
- /* Assume that the padding for alignment starts at a
- * sizeof(void *) address. */
-
- *from = <tng_param_this_fn;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- *from = <tng_param_call_site;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- reserve_size = *to_base + *to + *len;
- {
- char stack_buffer[reserve_size];
- buffer = stack_buffer;
-
- *to_base = *to = *len = 0;
-
- *from = <tng_param_this_fn;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- *from = <tng_param_call_site;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- ret = ltt_trace_generic(ltt_facility_user_generic_F583779E, event_user_generic_function_exit, buffer, reserve_size, LTT_BLOCKING);
- }
-
- return ret;
-
-}
-#endif //LTT_TRACE
-#endif //!LTT_TRACE_FAST
-
-#ifdef LTT_TRACE_FAST
-static inline __attribute__((no_instrument_function)) int trace_user_generic_function_exit(
- const void * lttng_param_this_fn,
- const void * lttng_param_call_site)
-#ifndef LTT_TRACE
-{
-}
-#else
-{
- unsigned int index;
- struct ltt_trace_info *trace = thread_trace_info;
- struct ltt_buf *ltt_buf;
- void *buffer = NULL;
- size_t real_to_base = 0; /* The buffer is allocated on arch_size alignment */
- size_t *to_base = &real_to_base;
- size_t real_to = 0;
- size_t *to = &real_to;
- size_t real_len = 0;
- size_t *len = &real_len;
- size_t reserve_size;
- size_t slot_size;
- size_t align;
- const void *real_from;
- const void **from = &real_from;
- uint64_t tsc;
- size_t before_hdr_pad, after_hdr_pad, header_size;
-
- if(!trace) {
- ltt_thread_init();
- trace = thread_trace_info;
- }
-
-
- /* For each field, calculate the field size. */
- /* size = *to_base + *to + *len */
- /* Assume that the padding for alignment starts at a
- * sizeof(void *) address. */
-
- *from = <tng_param_this_fn;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- *from = <tng_param_call_site;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- reserve_size = *to_base + *to + *len;
- trace->nesting++;
- index = ltt_get_index_from_facility(ltt_facility_user_generic_F583779E,
- event_user_generic_function_exit);
-
- {
- ltt_buf = ltt_get_channel_from_index(trace, index);
- slot_size = 0;
- buffer = ltt_reserve_slot(trace, ltt_buf,
- reserve_size, &slot_size, &tsc,
- &before_hdr_pad, &after_hdr_pad, &header_size);
- if(!buffer) goto end; /* buffer full */
-
- *to_base = *to = *len = 0;
-
- ltt_write_event_header(trace, ltt_buf, buffer,
- ltt_facility_user_generic_F583779E, event_user_generic_function_exit,
- reserve_size, before_hdr_pad, tsc);
- *to_base += before_hdr_pad + after_hdr_pad + header_size;
-
- *from = <tng_param_this_fn;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- *from = <tng_param_call_site;
- align = sizeof(const void *);
-
- if(*len == 0) {
- *to += ltt_align(*to, align); /* align output */
- } else {
- *len += ltt_align(*to+*len, align); /* alignment, ok to do a memcpy of it */
- }
-
- *len += sizeof(const void *);
-
- /* Flush pending memcpy */
- if(*len != 0) {
- memcpy(buffer+*to_base+*to, *from, *len);
- *to += *len;
- *len = 0;
- }
-
- ltt_commit_slot(ltt_buf, buffer, slot_size);
-
-}
-
-end:
- trace->nesting--;
-}
-#endif //LTT_TRACE
-#endif //LTT_TRACE_FAST
-
-#endif //_LTT_FACILITY_USER_GENERIC_H_
+++ /dev/null
-/*****************************************************************************
- * ltt-generic.h
- *
- * LTT generic userspace tracing header
- *
- * Mathieu Desnoyers, March 2006
- */
-
-#ifndef _LTT_GENERIC_H
-#define _LTT_GENERIC_H
-
-#include <errno.h>
-#include <syscall.h>
-#include <linux/unistd.h>
-#include <asm/atomic.h>
-#include <string.h>
-#include <sys/types.h>
-#include <stdint.h>
-
-#ifndef min
-#define min(a,b) ((a)<(b)?(a):(b))
-#endif
-
-//Put in asm-i486/unistd.h
-#define __NR_ltt_trace_generic 294
-#define __NR_ltt_register_generic 295
-
-#undef NR_syscalls
-#define NR_syscalls 296
-
-//FIXME : setup for ARM
-//FIXME : setup for MIPS
-
-#ifndef _LIBC
-// Put in bits/syscall.h
-#define SYS_ltt_trace_generic __NR_ltt_trace_generic
-#define SYS_ltt_register_generic __NR_ltt_register_generic
-#endif
-
-#define FACNAME_LEN 32
-
-/* LTT userspace tracing is non blocking by default when buffers are full */
-#ifndef LTT_BLOCKING
-#define LTT_BLOCKING 0
-#endif //LTT_BLOCKING
-
-typedef unsigned int ltt_facility_t;
-
-struct user_facility_info {
- char name[FACNAME_LEN];
- unsigned int num_events;
- size_t alignment;
- uint32_t checksum;
- size_t int_size;
- size_t long_size;
- size_t pointer_size;
- size_t size_t_size;
-};
-
-static inline __attribute__((no_instrument_function))
-_syscall5(int, ltt_trace_generic, unsigned int, facility_id,
- unsigned int, event_id, void *, data, size_t, data_size, int, blocking)
-static inline __attribute__((no_instrument_function))
-_syscall2(int, ltt_register_generic, unsigned int *, facility_id,
- const struct user_facility_info *, info)
-
-#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
-
-#endif //_LTT_GENERIC_H
-
-
+++ /dev/null
-
-#include <stdio.h>
-#include <unistd.h>
-
-#define LTT_TRACE
-#define LTT_BLOCKING 1
-#include <ltt/ltt-facility-user_generic.h>
-
-
-int main(int argc, char **argv)
-{
- printf("Will trace the following string : Running fast! in a infinite loop.\n");
-
- while(1) {
- trace_user_generic_string("Running fast!");
- }
-
- return 0;
-}
-
+++ /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;
-}
-
+++ /dev/null
-
-#include <stdio.h>
-#include <unistd.h>
-
-#define LTT_TRACE
-#define LTT_BLOCKING 1
-#include <ltt/ltt-facility-user_generic.h>
-#include <ltt/ltt-facility-custom-user_generic.h>
-
-
-int main(int argc, char **argv)
-{
- printf("Will trace a printf of an incrementing counter.\n");
- unsigned int count = 0;
-
- while(1) {
- trace_user_generic_slow_printf("in: %s at: %s:%d: Counter value is: %u.",
- __FILE__, __func__, __LINE__, count);
- count++;
- sleep(1);
- }
-
- return 0;
-}
-
+++ /dev/null
-
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#define LTT_TRACE
-#include <ltt/ltt-facility-user_generic.h>
-
-
-void *thr1(void *arg)
-{
- printf("thread 1, thread id : %lu, pid %lu\n", pthread_self(), getpid());
-
- while(1) {
- trace_user_generic_string("Hello world! Have a nice day.");
- sleep(2);
- }
-
- return ((void*)1);
-
-}
-
-void *thr2(void *arg)
-{
- printf("thread 2, thread id : %lu, pid %lu\n", pthread_self(), getpid());
- sleep(1);
- while(1) {
- trace_user_generic_string("Hello world! Have a nice day.");
- sleep(2);
- }
- return ((void*)2);
-}
-
-
-int main()
-{
- int err;
- pthread_t tid1, tid2;
- void *tret;
-
- printf("Will trace the following string : Hello world! Have a nice day.\n");
- printf("Press CTRL-C to stop.\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);
-
- 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(tid2, &tret);
- if(err!= 0) exit(1);
-
- return 0;
-}
+++ /dev/null
-
-#include <stdio.h>
-#include <unistd.h>
-
-#define LTT_TRACE
-#define LTT_BLOCKING 1
-#include <ltt/ltt-facility-user_generic.h>
-
-
-int main(int argc, char **argv)
-{
- printf("Will trace the following string : Hello world! Have a nice day.\n");
-
- while(1) {
- trace_user_generic_string("Hello world! Have a nice day.");
- sleep(1);
- }
-
- return 0;
-}
-
+++ /dev/null
-<facility name=user_generic>
- <description>Generic user space facility</description>
-
- <event name=string>
- <description>Takes a string from user space</description>
- <field name="data"><string/></field>
- </event>
-
- <event name=string_pointer>
- <description>Takes a string and pointer from user space</description>
- <field name="string"><string/></field>
- <field name="pointer"><pointer/></field>
- </event>
-
- <event name=slow_printf param_buffer>
- <description>Takes a buffer of variable size (written by printf) and log it.</description>
- <field name="string"><string/></field>
- </event>
-
- <event name=function_entry no_instrument_function>
- <description>Entry in a function</description>
- <field name="this_fn"><pointer/></field>
- <field name="call_site"><pointer/></field>
- </event>
-
- <event name=function_exit no_instrument_function>
- <description>Exit from a function</description>
- <field name="this_fn"><pointer/></field>
- <field name="call_site"><pointer/></field>
- </event>
-
-</facility>