-liblttvtraceread (ltt/ directory) is distributed under the GNU LGPL v2.1.
-
-The rest of the LTTV package is distributed under the GNU GPL v2.
+The LTTV package is distributed under the GNU GPL v2.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/time.h unistd.h pthread.h])
-# Check for JNI header files if requested
-AC_ARG_WITH(jni-interface,
- AS_HELP_STRING([--with-jni-interface],
- [build JNI interface between C and Java. Needs JNI header file. [[default=no]]]),
- [with_jni_interface="$withval"],
- [with_jni_interface="no"])
-
-AS_IF([test "x$with_jni_interface" = "xyes"],[
- AC_CHECK_HEADERS([jni.h], [], AC_MSG_ERROR([missing jni.h
-Make sure Sun Java or OpenJDK or GCJ is installed and that this header file exists in the system path.
-Use CFLAGS=-I/path/ to specify a non-standard path or disable the JNI interface.]))
-])
-AM_CONDITIONAL([BUILD_JNI_INTERFACE], [ test "$with_jni_interface" = "yes" ] )
-
# If we want the gui, we need additionnal flags for GTK
AS_IF([test "x$with_lttv_gui" = "xyes"],[
lttvlibdir="${libdir}/lttv"
lttvplugindir="${lttvlibdir}/plugins"
-#lttlibdir="${libdir}/ltt"
top_lttvdir="\$(top_srcdir)/lttv"
top_lttvwindowdir="\$(top_srcdir)/lttv/modules/gui/lttvwindow"
DEFAULT_INCLUDES="-I\$(top_srcdir) -I\$(top_builddir) -I\$(top_lttvdir) -I\$(top_lttvwindowdir)"
-lttincludedir="${includedir}/ltt"
lttvincludedir="${includedir}/lttv"
lttvwindowincludedir="${includedir}/lttvwindow"
lttctlincludedir="${includedir}/liblttctl"
AC_SUBST(lttvlibdir)
AC_SUBST(lttvplugindir)
-#AC_SUBST(lttlibdir)
AC_SUBST(top_lttvdir)
AC_SUBST(top_lttvwindowdir)
AC_SUBST(DEFAULT_INCLUDES)
-AC_SUBST(lttincludedir)
AC_SUBST(lttvincludedir)
AC_SUBST(lttvwindowincludedir)
AC_SUBST(lttctlincludedir)
# Report on what will be built
AS_ECHO()
AS_ECHO("The following components will be built:")
-AS_ECHO("LTT trace reading library: Enabled") # It's always enabled!
AS_ECHO_N("LTTV command line tool: ")
AS_IF([test "x$with_lttv" = "xyes"],[AS_ECHO("Enabled")],[AS_ECHO("Disabled")])
AS_ECHO_N("Trace synchronization: ")
AS_IF([test "x$with_trace_sync" = "xyes"],[AS_ECHO("Enabled")],[AS_ECHO("Disabled")])
-AS_ECHO_N("Java (JNI) interface: ")
-AS_IF([test "x$with_jni_interface" = "xyes"],[AS_ECHO("Enabled")],[AS_ECHO("Disabled")])
-
AS_ECHO()
AS_ECHO_N("Statically linked executable: ")
AS_IF([test "x$lttvstatic" = "xyes"],[AS_ECHO("Yes")],[AS_ECHO("No")])
+++ /dev/null
-#
-# Makefile for LTT New generation user interface : plugins.
-#
-# Created by Mathieu Desnoyers on May 6, 2003
-#
-
-#libdir = ${lttlibdir}
-
-AM_CFLAGS = $(PACKAGE_CFLAGS)
-
-if BUILD_JNI_INTERFACE
-lib_LTLIBRARIES = liblttvtraceread.la liblttvtraceread_loader.la
-liblttvtraceread_la_SOURCES = jni_interface.c tracefile.c marker.c event.c
-liblttvtraceread_loader_la_SOURCES= lttvtraceread_loader.c
-else
-lib_LTLIBRARIES = liblttvtraceread.la
-liblttvtraceread_la_SOURCES = tracefile.c marker.c event.c
-endif
-
-liblttvtraceread_la_LDFLAGS = -release 2.6
-liblttvtraceread_loader_la_LDFLAGS = -release 2.6
-
-noinst_HEADERS = ltt-private.h
-
-lttinclude_HEADERS = \
- compiler.h\
- marker.h\
- marker-field.h\
- ltt.h\
- ltt-private.h\
- time.h\
- trace.h\
- event.h\
- marker-desc.h\
- ltt-types.h
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit trace reading library
- * Copyright (C) 2003-2004 Mathieu Desnoyers
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef COMPILER_H
-#define COMPILER_H
-
-#error "Using old ltt/"
-
-/* Fast prediction if likely branches */
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
-
-
-/*
- * Check at compile time that something is of a particular type.
- * Always evaluates to 1 so you may use it easily in comparisons.
- */
-#define typecheck(type,x) \
-({ type __dummy; \
- typeof(x) __dummy2; \
- (void)(&__dummy == &__dummy2); \
- 1; \
-})
-
-/* Deal with 32 wrap correctly */
-#define guint32_after(a,b) \
- (typecheck(guint32, a) && \
- typecheck(guint32, b) && \
- ((gint32)(b) - (gint32)(a) < 0))
-#define guint32_before(a,b) guint32_after(b,a)
-
-#define guint32_after_eq(a,b) \
- (typecheck(guint32, a) && \
- typecheck(guint32, b) && \
- ((gint32)(b) - (gint32)(a) <= 0))
-#define guint32_before_eq(a,b) guint32_after_eq(b,a)
-
-#define __EXPORT __attribute__ ((visibility ("default")))
-
-#endif //COMPILER_H
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2007 Mathieu Desnoyers
- *
- * Complete rewrite from the original version made by XangXiu Yang.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-
-#include <ltt/event.h>
-#include <ltt/ltt-types.h>
-#include <ltt/ltt-private.h>
-#include <ltt/marker.h>
-#include <ltt/marker-field.h>
-
-/*****************************************************************************
- *Function name
- * ltt_event_position_get : get the event position data
- *Input params
- * e : an instance of an event type
- * ep : a pointer to event's position structure
- * tf : tracefile pointer
- * block : current block
- * offset : current offset
- * tsc : current tsc
- ****************************************************************************/
-void ltt_event_position_get(LttEventPosition *ep, LttTracefile **tf,
- guint *block, guint *offset, guint64 *tsc)
-{
- *tf = ep->tracefile;
- *block = ep->block;
- *offset = ep->offset;
- *tsc = ep->tsc;
-}
-
-
-void ltt_event_position_set(LttEventPosition *ep, LttTracefile *tf,
- guint block, guint offset, guint64 tsc)
-{
- ep->tracefile = tf;
- ep->block = block;
- ep->offset = offset;
- ep->tsc = tsc;
-}
-
-
-/*****************************************************************************
- *Function name
- * ltt_event_position : get the event's position
- *Input params
- * e : an instance of an event type
- * ep : a pointer to event's position structure
- ****************************************************************************/
-
-void ltt_event_position(const LttEvent *e, LttEventPosition *ep)
-{
- ep->tracefile = e->tracefile;
- ep->block = e->block;
- ep->offset = e->offset;
- ep->tsc = e->tsc;
-}
-
-LttEventPosition * ltt_event_position_new()
-{
- return g_new(LttEventPosition, 1);
-}
-
-
-/*****************************************************************************
- * Function name
- * ltt_event_position_compare : compare two positions
- * A NULL value is infinite.
- * Input params
- * ep1 : a pointer to event's position structure
- * ep2 : a pointer to event's position structure
- * Return
- * -1 is ep1 < ep2
- * 1 if ep1 > ep2
- * 0 if ep1 == ep2
- ****************************************************************************/
-
-
-gint ltt_event_position_compare(const LttEventPosition *ep1,
- const LttEventPosition *ep2)
-{
- if(ep1 == NULL && ep2 == NULL)
- return 0;
- if(ep1 != NULL && ep2 == NULL)
- return -1;
- if(ep1 == NULL && ep2 != NULL)
- return 1;
-
- if(ep1->tracefile != ep2->tracefile)
- g_error("ltt_event_position_compare on different tracefiles makes no sense");
-
- if(ep1->block < ep2->block)
- return -1;
- if(ep1->block > ep2->block)
- return 1;
- if(ep1->offset < ep2->offset)
- return -1;
- if(ep1->offset > ep2->offset)
- return 1;
- return 0;
-}
-
-/*****************************************************************************
- * Function name
- * ltt_event_position_copy : copy position
- * Input params
- * src : a pointer to event's position structure source
- * dest : a pointer to event's position structure dest
- * Return
- * void
- ****************************************************************************/
-void ltt_event_position_copy(LttEventPosition *dest,
- const LttEventPosition *src)
-{
- if(src == NULL)
- dest = NULL;
- else
- *dest = *src;
-}
-
-
-
-LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep)
-{
- return ep->tracefile;
-}
-
-/*****************************************************************************
- * These functions extract data from an event after architecture specific
- * conversions
- ****************************************************************************/
-guint32 ltt_event_get_unsigned(LttEvent *e, struct marker_field *f)
-{
- gboolean reverse_byte_order;
- struct LttField *eventfield;
- int offset, size;
-
- if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
- reverse_byte_order = (g_ntohs(0x1) != 0x1);
- } else {
- reverse_byte_order = LTT_GET_BO(e->tracefile);
- }
-
- eventfield = ltt_event_field(e, marker_field_get_index(f));
- offset = eventfield->offset;
- size = eventfield->size;
- switch(size) {
- case 1:
- {
- guint8 x = *(guint8 *)(e->data + offset);
- return (guint32) x;
- }
- break;
- case 2:
- return (guint32)ltt_get_uint16(reverse_byte_order, e->data + offset);
- break;
- case 4:
- return (guint32)ltt_get_uint32(reverse_byte_order, e->data + offset);
- break;
- case 8:
- default:
- g_critical("ltt_event_get_unsigned : field size %i unknown", size);
- return 0;
- break;
- }
-}
-
-gint32 ltt_event_get_int(LttEvent *e, struct marker_field *f)
-{
- gboolean reverse_byte_order;
- struct LttField *eventfield;
- int offset, size;
-
- if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
- reverse_byte_order = (g_ntohs(0x1) != 0x1);
- } else {
- reverse_byte_order = LTT_GET_BO(e->tracefile);
- }
-
- eventfield = ltt_event_field(e, marker_field_get_index(f));
- offset = eventfield->offset;
- size = eventfield->size;
- switch(size) {
- case 1:
- {
- gint8 x = *(gint8 *)(e->data + offset);
- return (gint32) x;
- }
- break;
- case 2:
- return (gint32)ltt_get_int16(reverse_byte_order, e->data + offset);
- break;
- case 4:
- return (gint32)ltt_get_int32(reverse_byte_order, e->data + offset);
- break;
- case 8:
- default:
- g_critical("ltt_event_get_int : field size %i unknown", size);
- return 0;
- break;
- }
-}
-
-guint64 ltt_event_get_long_unsigned(LttEvent *e, struct marker_field *f)
-{
- gboolean reverse_byte_order;
- struct LttField *eventfield;
- int offset, size;
-
- if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
- reverse_byte_order = (g_ntohs(0x1) != 0x1);
- } else {
- reverse_byte_order = LTT_GET_BO(e->tracefile);
- }
-
- eventfield = ltt_event_field(e, marker_field_get_index(f));
- offset = eventfield->offset;
- size = eventfield->size;
- switch(size) {
- case 1:
- {
- guint8 x = *(guint8 *)(e->data + offset);
- return (guint64) x;
- }
- break;
- case 2:
- return (guint64)ltt_get_uint16(reverse_byte_order, e->data + offset);
- break;
- case 4:
- return (guint64)ltt_get_uint32(reverse_byte_order, e->data + offset);
- break;
- case 8:
- return ltt_get_uint64(reverse_byte_order, e->data + offset);
- break;
- default:
- g_critical("ltt_event_get_long_unsigned : field size %i unknown", size);
- return 0;
- break;
- }
-}
-
-gint64 ltt_event_get_long_int(LttEvent *e, struct marker_field *f)
-{
- gboolean reverse_byte_order;
- struct LttField *eventfield;
- int offset, size;
-
- if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
- reverse_byte_order = (g_ntohs(0x1) != 0x1);
- } else {
- reverse_byte_order = LTT_GET_BO(e->tracefile);
- }
-
- eventfield = ltt_event_field(e, marker_field_get_index(f));
- offset = eventfield->offset;
- size = eventfield->size;
- switch(size) {
- case 1:
- {
- gint8 x = *(gint8 *)(e->data + offset);
- return (gint64) x;
- }
- break;
- case 2:
- return (gint64)ltt_get_int16(reverse_byte_order, e->data + offset);
- break;
- case 4:
- return (gint64)ltt_get_int32(reverse_byte_order, e->data + offset);
- break;
- case 8:
- return ltt_get_int64(reverse_byte_order, e->data + offset);
- break;
- default:
- g_critical("ltt_event_get_long_int : field size %i unknown", size);
- return 0;
- break;
- }
-}
-
-#if 0
-float ltt_event_get_float(LttEvent *e, struct marker_field *f)
-{
- gboolean reverse_byte_order;
- struct LttField *eventfield;
- int offset, size;
-
- if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
- reverse_byte_order = (g_ntohs(0x1) != 0x1);
- } else {
- g_assert(LTT_HAS_FLOAT(e->tracefile));
- reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
- }
-
- eventfield = ltt_event_field(e, marker_field_get_index(f));
- offset = eventfield->offset;
- size = eventfield->size;
- g_assert(f->field_type.type_class == LTT_FLOAT && size == 4);
-
- if(reverse_byte_order == 0) return *(float *)(e->data + offset);
- else{
- void *ptr = e->data + offset;
- guint32 value = bswap_32(*(guint32*)ptr);
- return *(float*)&value;
- }
-}
-
-double ltt_event_get_double(LttEvent *e, struct marker_field *f)
-{
- gboolean reverse_byte_order;
- struct LttField *eventfield;
- int offset, size;
-
- if(unlikely(f->attributes & LTT_ATTRIBUTE_NETWORK_BYTE_ORDER)) {
- reverse_byte_order = (g_ntohs(0x1) != 0x1);
- } else {
- g_assert(LTT_HAS_FLOAT(e->tracefile));
- reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
- }
-
- eventfield = ltt_event_field(e, marker_field_get_index(f));
- offset = eventfield->offset;
- size = eventfield->size;
- if(size == 4)
- return ltt_event_get_float(e, f);
-
- g_assert(f->field_type.type_class == LTT_FLOAT && size == 8);
-
- if(reverse_byte_order == 0) return *(double *)(e->data + offset);
- else {
- void *ptr = e->data + offset;
- guint64 value = bswap_64(*(guint64*)ptr);
- return *(double*)&value;
- }
-}
-#endif
-
-/*****************************************************************************
- * The string obtained is only valid until the next read from
- * the same tracefile. We reference directly the buffers.
- ****************************************************************************/
-gchar *ltt_event_get_string(LttEvent *e, struct marker_field *f)
-{
- struct LttField *eventfield;
- int offset;
-
- g_assert(f->type == LTT_TYPE_STRING);
-
- //caused memory leaks
- //return (gchar*)g_strdup((gchar*)(e->data + f->offset));
- eventfield = ltt_event_field(e, marker_field_get_index(f));
- offset = eventfield->offset;
- return (gchar*)(e->data + offset);
-}
-
-
+++ /dev/null
-#ifndef _LTT_EVENT_H
-#define _LTT_EVENT_H
-
-#include <glib.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <endian.h>
-#include <ltt/ltt.h>
-#include <ltt/time.h>
-
-struct marker_field;
-
-struct LttField {
- int offset;
- int size;
-};
-
-/*
- * Structure LttEvent and LttEventPosition must begin with the _exact_ same
- * fields in the exact same order. LttEventPosition is a parent of LttEvent.
- */
-struct LttEvent {
- /* Begin of LttEventPosition fields */
- LttTracefile *tracefile;
- unsigned int block;
- unsigned int offset;
-
- /* Timekeeping */
- uint64_t tsc; /* Current timestamp counter */
-
- /* End of LttEventPosition fields */
- guint32 timestamp; /* truncated timestamp */
-
- guint16 event_id;
-
- LttTime event_time;
-
- void *data; /* event data */
- GArray *fields_offsets; /* current field offsets table */
- guint data_size;
- guint event_size; /* event_size field of the header :
- used to verify data_size from marker. */
- int count; /* the number of overflow of cycle count */
- gint64 overflow_nsec; /* precalculated nsec for overflows */
-};
-
-struct LttEventPosition {
- LttTracefile *tracefile;
- unsigned int block;
- unsigned int offset;
-
- /* Timekeeping */
- uint64_t tsc; /* Current timestamp counter */
-};
-
-static inline guint16 ltt_event_id(const struct LttEvent *event)
-{
- return event->event_id;
-}
-
-static inline LttTime ltt_event_time(const struct LttEvent *event)
-{
- return event->event_time;
-}
-
-/* Obtain the position of the event within the tracefile. This
- is used to seek back to this position later or to seek to another
- position, computed relative to this position. The event position
- structure is opaque and contains several fields, only two
- of which are user accessible: block number and event index
- within the block. */
-
-void ltt_event_position(const LttEvent *e, LttEventPosition *ep);
-
-LttEventPosition * ltt_event_position_new();
-
-void ltt_event_position_get(LttEventPosition *ep, LttTracefile **tf,
- guint *block, guint *offset, guint64 *tsc);
-
-void ltt_event_position_set(LttEventPosition *ep, LttTracefile *tf,
- guint block, guint offset, guint64 tsc);
-
-gint ltt_event_position_compare(const LttEventPosition *ep1,
- const LttEventPosition *ep2);
-
-void ltt_event_position_copy(LttEventPosition *dest,
- const LttEventPosition *src);
-
-LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep);
-
-/* These functions extract data from an event after architecture specific
- * conversions. */
-
-guint32 ltt_event_get_unsigned(LttEvent *e, struct marker_field *f);
-
-gint32 ltt_event_get_int(LttEvent *e, struct marker_field *f);
-
-guint64 ltt_event_get_long_unsigned(LttEvent *e, struct marker_field *f);
-
-gint64 ltt_event_get_long_int(LttEvent *e, struct marker_field *f);
-
-float ltt_event_get_float(LttEvent *e, struct marker_field *f);
-
-double ltt_event_get_double(LttEvent *e, struct marker_field *f);
-
-
-/* The string obtained is only valid until the next read from
- * the same tracefile. */
-
-gchar *ltt_event_get_string(LttEvent *e, struct marker_field *f);
-
-static inline LttCycleCount ltt_event_cycle_count(const LttEvent *e)
-{
- return e->tsc;
-}
-
-static inline struct LttField *ltt_event_field(const LttEvent *e, int index)
-{
- return &g_array_index(e->fields_offsets, struct LttField, index);
-}
-
-#endif //_LTT_EVENT_H
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2010 William Bourque
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/* Important to get consistent size_t type */
-#define _FILE_OFFSET_BITS 64
-
-#include <jni.h>
-
-#include <ltt/trace.h>
-#include <ltt/time.h>
-#include <ltt/marker.h>
-#include <glib.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <errno.h>
-/*
-***FIXME***
-***HACK***
- We've got hell of a problem passing "unsigned int64" to java, as there is no equivalent type
- The closer we can use is "long" which is signed, so only 32 (or 63?) bits are valid
- Plus, even if we are within the "32 bits" capacity, java sometime screw itself trying to convert "unsigned 64 -> signed 64"
- This happen especially often when RETURNING a jlong
- So when returning a jlong, we should convert it like this : "unsigned 64"->"signed 64"->jlong
-*/
-#define CONVERT_UINT64_TO_JLONG(n) (jlong)(gint64)(n)
-#define CONVERT_INT64_TO_JLONG(n) (jlong)(gint64)(n)
-
-/* To ease calcul involving nano */
-#define BILLION 1000000000
-
-
-#if __WORDSIZE == 64
- #define CONVERT_JLONG_TO_PTR(p) (p)
- #define CONVERT_PTR_TO_JLONG(p) (jlong)(p)
- /* Define the "gint" type we should use for pointer. */
- #define GINT_TYPE_FOR_PTR gint64
-#else
- /* Conversion to int first to save warning */
- #define CONVERT_JLONG_TO_PTR(p) (int)(p)
- #define CONVERT_PTR_TO_JLONG(p) (jlong)(int)(p)
- /* Define the "gint" type we should use for pointer. */
- #define GINT_TYPE_FOR_PTR gint32
-#endif
-
-/* Structure to encapsulate java_data to pass as arguments */
-struct java_calling_data
-{
- JNIEnv *env;
- jobject jobj;
-};
-
-/* ***TODO***
- All these struct are used to call g_datalist_foreach()
- Find a better way! This is ugly!
-*/
-struct addMarkersArgs
-{
- struct java_calling_data *java_args;
- struct marker_data *mdata;
-};
-
-struct saveTimeArgs
-{
- GArray *saveTimeArray;
-};
-
-struct saveTimeAndTracefile
-{
- LttTime time;
- LttTracefile *tracefile;
-};
-
-/*
-### COMMON Methods ###
-#
-Empty method to turn off the debug (debug waste time while printing) */
-void ignore_and_drop_message(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) {
-}
-
-
-/* JNI method to call printf from the java side */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_Jni_1C_1Common_ltt_1printC(JNIEnv *env, jobject jobj, jstring new_string) {
- const char *c_msg = (*env)->GetStringUTFChars(env, new_string, 0);
-
- printf("%s", c_msg );
-
- (*env)->ReleaseStringUTFChars(env, new_string, c_msg);
-}
-
-/* Method to obtain a trace version number from its path */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_factory_JniTraceVersion_ltt_1getTraceVersion(JNIEnv *env, jobject jobj, jstring tracepath) {
-
- const gchar *c_pathname = (*env)->GetStringUTFChars(env, tracepath, 0);
- jint tmpMajorNumber = 0;
- jint tmpMinorNumber = 0;
-
- jclass accessClass = (*env)->GetObjectClass(env, jobj);
- jmethodID accessFunction = (*env)->GetMethodID(env, accessClass, "setTraceVersionFromC", "(II)V");
-
- struct LttTraceVersion version_number;
-
- if ( ltt_get_trace_version(c_pathname, &version_number) >= 0) {
- tmpMajorNumber = version_number.ltt_major_version;
- tmpMinorNumber = version_number.ltt_minor_version;
- }
-
- (*env)->CallVoidMethod(env, jobj, accessFunction, tmpMajorNumber, tmpMinorNumber );
-}
-/*
-#
-#### */
-
-
-/*
-### TRACE methods ###
-#
-JNI mapping of < LttTrace *ltt_trace_open(const gchar *pathname) > (trace.h) */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTrace(JNIEnv *env, jobject jobj, jstring pathname, jboolean show_debug) {
-
- if ( !show_debug) {
- /* Make sure we don't use any debug (speed up the read) */
- g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL);
- g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL);
- }
-
- const char *c_pathname = (*env)->GetStringUTFChars(env, pathname, 0);
- LttTrace *newPtr = ltt_trace_open(c_pathname);
-
- (*env)->ReleaseStringUTFChars(env, pathname, c_pathname);
-
- return CONVERT_PTR_TO_JLONG(newPtr);
-}
-
-/* JNI mapping of < LttTrace *ltt_trace_open_live(const gchar *pathname) > (trace.h) */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTraceLive(JNIEnv *env, jobject jobj, jstring pathname, jboolean show_debug) {
-
- if ( !show_debug) {
- /* Make sure we don't use any debug (speed up the read) */
- g_log_set_handler(NULL, G_LOG_LEVEL_INFO, ignore_and_drop_message, NULL);
- g_log_set_handler(NULL, G_LOG_LEVEL_DEBUG, ignore_and_drop_message, NULL);
- }
-
- const char *c_pathname = (*env)->GetStringUTFChars(env, pathname, 0);
- LttTrace *newPtr = ltt_trace_open_live(c_pathname);
-
- (*env)->ReleaseStringUTFChars(env, pathname, c_pathname);
-
- return CONVERT_PTR_TO_JLONG(newPtr);
-}
-
-/* JNI mapping of < void ltt_trace_close(LttTrace *t) > (trace.h) */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1closeTrace(JNIEnv *env, jobject jobj, jlong trace_ptr){
-
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- ltt_trace_close(newPtr);
-}
-
-/* Get the tracepath */
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getTracepath(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (*env)->NewStringUTF(env, g_quark_to_string( newPtr->pathname) );
-}
-
-
-/* Get of num_cpu */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getCpuNumber(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (jint)newPtr->num_cpu;
-}
-
-/* Get of arch_type */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchType(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (jlong)newPtr->arch_type;
-}
-
-/* Get of arch_variant */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchVariant(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (jlong)newPtr->arch_variant;
-}
-
-/* Get of arch_size */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchSize(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (jshort)newPtr->arch_size;
-}
-
-/* Get of ltt_major_version */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMajorVersion(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (jshort)newPtr->ltt_major_version;
-}
-
-/* Get of ltt_minor_version */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMinorVersion(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (jshort)newPtr->ltt_minor_version;
-}
-
-/* Get of flight_recorder */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFlightRecorder(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (jshort)newPtr->flight_recorder;
-}
-
-/* Get of freq_scale */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFreqScale(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (jlong)newPtr->freq_scale;
-}
-
-/* Get of start_freq */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartFreq(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->start_freq);
-}
-
-/* Get of start_tsc */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartTimestampCurrentCounter(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->start_tsc);
-}
-
-/* Get of start_monotonic */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartMonotonic(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->start_monotonic);
-}
-
-/* JNI mapping of < int ltt_trace_update(LttTrace *t) > (trace.h) */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1updateTrace(JNIEnv *env, jobject jobj, jlong trace_ptr){
-
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- return (jint)ltt_trace_update(newPtr);
-}
-
-/* Access to start_time */
-/* Note that we are calling the setTimeFromC function in Jaf_Time from here */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTime(JNIEnv *env, jobject jobj, jlong trace_ptr, jobject time_jobj) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- jclass accessClass = (*env)->GetObjectClass(env, time_jobj);
- jmethodID accessFunction = (*env)->GetMethodID(env, accessClass, "setTimeFromC", "(J)V");
-
- jlong fullTime = (CONVERT_UINT64_TO_JLONG(newPtr->start_time.tv_sec)*BILLION) + CONVERT_UINT64_TO_JLONG(newPtr->start_time.tv_nsec);
-
- (*env)->CallVoidMethod(env, time_jobj, accessFunction, fullTime );
-}
-
-/* Access to start_time_from_tsc */
-/* Note that we are calling the setTimeFromC function in Jaf_Time from here */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTimeFromTimestampCurrentCounter(JNIEnv *env, jobject jobj, jlong trace_ptr, jobject time_jobj) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- jclass accessClass = (*env)->GetObjectClass(env, time_jobj);
- jmethodID accessFunction = (*env)->GetMethodID(env, accessClass, "setTimeFromC", "(J)V");
-
- jlong fullTime = (CONVERT_UINT64_TO_JLONG(newPtr->start_time_from_tsc.tv_sec)*BILLION) + CONVERT_UINT64_TO_JLONG(newPtr->start_time_from_tsc.tv_nsec);
-
- (*env)->CallVoidMethod(env, time_jobj, accessFunction, fullTime);
-}
-
-
-/* g_list_data function for the "for_each" call in Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getAllTracefiles */
-void g_datalist_foreach_addTracefilesOfTrace(GQuark name, gpointer data, gpointer user_data) {
- struct java_calling_data *args = (struct java_calling_data*)user_data;
-
- jclass accessClass = (*args->env)->GetObjectClass(args->env, args->jobj);
- jmethodID accessFunction = (*args->env)->GetMethodID(args->env, accessClass, "addTracefileFromC", "(Ljava/lang/String;J)V");
-
- GArray *tracefile_array = (GArray*)data;
- LttTracefile *tracefile;
- jlong newPtr;
-
- unsigned int i;
- for (i=0; i<tracefile_array->len; i++) {
- tracefile = &g_array_index(tracefile_array, LttTracefile, i);
-
- newPtr = CONVERT_PTR_TO_JLONG(tracefile);
-
- (*args->env)->CallVoidMethod(args->env, args->jobj, accessFunction, (*args->env)->NewStringUTF(args->env, g_quark_to_string(tracefile->name) ), newPtr );
- }
-}
-
-/* Function to fill up the java map with the event type found in tracefile (the name) */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedAllTracefiles(JNIEnv *env, jobject jobj, jlong trace_ptr) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- struct java_calling_data args = { env, jobj };
-
- g_datalist_foreach(&newPtr->tracefiles, &g_datalist_foreach_addTracefilesOfTrace, &args);
-}
-
-
-/* g_list_data function for the "for_each" call in Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange */
-/* used to save the current timestamp for each tracefile */
-void g_datalist_foreach_saveTracefilesTime(GQuark name, gpointer data, gpointer user_data) {
- struct saveTimeArgs *args = (struct saveTimeArgs*)user_data;
-
- GArray *tracefile_array = (GArray*)data;
- GArray *save_array = args->saveTimeArray;
-
- LttTracefile *tracefile;
- struct saveTimeAndTracefile *savedData;
-
- unsigned int i;
- for (i=0; i<tracefile_array->len; i++) {
- tracefile = &g_array_index(tracefile_array, LttTracefile, i);
-
- /* Allocate a new LttTime for each tracefile (so it won't change if the tracefile seek somewhere else) */
- savedData = (struct saveTimeAndTracefile*)malloc( sizeof(struct saveTimeAndTracefile) );
- savedData->time.tv_sec = tracefile->event.event_time.tv_sec;
- savedData->time.tv_nsec = tracefile->event.event_time.tv_nsec;
- savedData->tracefile = tracefile;
- /* Append the saved data to the array */
- g_array_append_val(save_array, savedData);
- }
-}
-
-
-/* Obtain the range of the trace (i.e. "start time" and "end time") */
-/* Note : This function, unlike ltt_trace_time_span_get, is assured to return all tracefiles to their correct position after operation */
-/* NOTE : this method is quite heavy to use!!! */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange(JNIEnv *env, jobject jobj, jlong trace_ptr, jobject jstart_time, jobject jend_time) {
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- /* Allocate ourself a new array to save the data in */
- GArray *savedDataArray = g_array_new(FALSE, FALSE, sizeof(struct saveTimeAndTracefile*) );
- struct saveTimeArgs args = { savedDataArray };
- /* Call g_datalist_foreach_saveTracefilesTime for each element in the GData to save the time */
- g_datalist_foreach(&newPtr->tracefiles, &g_datalist_foreach_saveTracefilesTime, &args);
-
- /* Call to ltt_trace_time_span_get to find the current start and end time */
- /* NOTE : This WILL change the current block of the tracefile (i.e. its timestamp) */
- LttTime tmpStartTime = { 0, 0 };
- LttTime tmpEndTime = { 0, 0 };
- ltt_trace_time_span_get(newPtr, &tmpStartTime, &tmpEndTime);
-
- /* Seek back to the correct time for each tracefile and free the allocated memory */
- struct saveTimeAndTracefile *savedData;
- unsigned int i;
- for (i=0; i<savedDataArray->len; i++) {
- savedData = g_array_index(savedDataArray, struct saveTimeAndTracefile*, i);
- /* Seek back to the correct time */
- /* Some time will not be consistent here (i.e. unitialized data) */
- /* but the seek should work just fine with that */
- ltt_tracefile_seek_time(savedData->tracefile, savedData->time);
-
- /* Free the memory allocated for this saveTimeAndTracefile entry */
- free( savedData );
- }
- /* Free the memory allocated for the GArray */
- g_array_free(savedDataArray, TRUE);
-
- /* Send the start and end time back to the java */
- /* We do it last to make sure a problem won't leave us with unfred memory */
- jclass startAccessClass = (*env)->GetObjectClass(env, jstart_time);
- jmethodID startAccessFunction = (*env)->GetMethodID(env, startAccessClass, "setTimeFromC", "(J)V");
- jlong startTime = (CONVERT_UINT64_TO_JLONG(tmpStartTime.tv_sec)*BILLION) + CONVERT_UINT64_TO_JLONG(tmpStartTime.tv_nsec);
- (*env)->CallVoidMethod(env, jstart_time, startAccessFunction, startTime);
-
- jclass endAccessClass = (*env)->GetObjectClass(env, jend_time);
- jmethodID endAccessFunction = (*env)->GetMethodID(env, endAccessClass, "setTimeFromC", "(J)V");
- jlong endTime = (CONVERT_UINT64_TO_JLONG(tmpEndTime.tv_sec)*BILLION) + CONVERT_UINT64_TO_JLONG(tmpEndTime.tv_nsec);
- (*env)->CallVoidMethod(env, jend_time, endAccessFunction, endTime);
-}
-
-/* Function to print the content of a trace */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1printTrace(JNIEnv *env, jobject jobj, jlong trace_ptr) {
-
- LttTrace *newPtr = (LttTrace*)CONVERT_JLONG_TO_PTR(trace_ptr);
-
- printf("pathname : %s\n" ,g_quark_to_string(newPtr->pathname) );
- printf("num_cpu : %u\n" ,(unsigned int)(newPtr->num_cpu) );
- printf("arch_type : %u\n" ,(unsigned int)(newPtr->arch_type) );
- printf("arch_variant : %u\n" ,(unsigned int)(newPtr->arch_variant) );
- printf("arch_size : %u\n" ,(unsigned short)(newPtr->arch_size) );
- printf("ltt_major_version : %u\n" ,(unsigned short)(newPtr->ltt_major_version) );
- printf("ltt_minor_version : %u\n" ,(unsigned short)(newPtr->ltt_minor_version) );
- printf("flight_recorder : %u\n" ,(unsigned short)(newPtr->flight_recorder) );
- printf("freq_scale : %u\n" ,(unsigned int)(newPtr->freq_scale) );
- printf("start_freq : %lu\n" ,(long unsigned int)(newPtr->start_freq) );
- printf("start_tsc : %lu\n" ,(long unsigned int)(newPtr->start_tsc) );
- printf("start_monotonic : %lu\n" ,(long unsigned int)(newPtr->start_monotonic) );
- printf("start_time ptr : %p\n" ,&newPtr->start_time);
- printf(" tv_sec : %lu\n" ,(long unsigned int)(newPtr->start_time.tv_sec) );
- printf(" tv_nsec : %lu\n" ,(long unsigned int)(newPtr->start_time.tv_nsec) );
- printf("start_time_from_tsc ptr : %p\n" ,&newPtr->start_time_from_tsc);
- printf(" tv_sec : %lu\n" ,(long unsigned int)(newPtr->start_time_from_tsc.tv_sec) );
- printf(" tv_nsec : %lu\n" ,(long unsigned int)(newPtr->start_time_from_tsc.tv_nsec) );
- printf("tracefiles ptr : %p\n" ,newPtr->tracefiles);
- printf("\n");
-}
-/*
-#
-### */
-
-
-
-
-/*
-### TRACEFILE methods ###
-# */
-
-/* Get of cpu_online */
-JNIEXPORT jboolean JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsCpuOnline(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jboolean)newPtr->cpu_online;
-}
-
-/* Get of long_name */
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilepath(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (*env)->NewStringUTF(env, g_quark_to_string(newPtr->long_name) );
-}
-
-/* Get of name */
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilename(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (*env)->NewStringUTF(env, g_quark_to_string(newPtr->name) );
-}
-
-/* Get of cpu_num */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCpuNumber(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jlong)newPtr->cpu_num;
-}
-
-/* Get of tid */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTid(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jlong)newPtr->tid;
-}
-
-/* Get of pgid */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getPgid(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jlong)newPtr->pgid;
-}
-
-/* Get of creation */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCreation(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->creation);
-}
-
-/* Get of trace */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracePtr(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_PTR_TO_JLONG(newPtr->trace);
-}
-
-/* Get of mdata */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getMarkerDataPtr(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_PTR_TO_JLONG(newPtr->mdata);
-}
-
-/* Get of fd */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCFileDescriptor(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jint)newPtr->fd;
-}
-
-/* Get of file_size */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getFileSize(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->file_size);
-}
-
-/* Get of num_blocks */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBlockNumber(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jlong)newPtr->num_blocks;
-}
-
-/* Get of reverse_bo */
-JNIEXPORT jboolean JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsBytesOrderReversed(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jboolean)newPtr->reverse_bo;
-}
-
-/* Get of float_word_order */
-JNIEXPORT jboolean JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsFloatWordOrdered(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jboolean)newPtr->float_word_order;
-}
-
-/* Get of alignment */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getAlignement(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->alignment);
-}
-
-/* Get of buffer_header_size */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferHeaderSize(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->buffer_header_size);
-}
-
-/* Get of tscbits */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfCurrentTimestampCounter(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jint)newPtr->tscbits;
-}
-
-/* Get of eventbits */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfEvent(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jint)newPtr->eventbits;
-}
-
-/* Get of tsc_mask */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMask(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->tsc_mask);
-}
-
-/* Get of tsc_mask_next_bit */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMaskNextBit(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->tsc_mask_next_bit);
-}
-
-/* Get of events_lost */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventsLost(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jlong)newPtr->events_lost;
-}
-
-/* Get of subbuf_corrupt */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getSubBufferCorrupt(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jlong)newPtr->subbuf_corrupt;
-}
-
-/* Get of event */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventPtr(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_PTR_TO_JLONG(&newPtr->event);
-}
-
-/* Get of buffer */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferPtr(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return CONVERT_PTR_TO_JLONG(&newPtr->buffer);
-}
-
-/* Get of buffer size */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferSize(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- return (jlong)newPtr->buffer.size;
-}
-
-
-/* g_list_data function for the "for_each" call in Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getAllMarkers */
-void g_hash_table_foreach_addMarkersOfTracefile(gpointer key, gpointer data, gpointer user_data) {
- struct addMarkersArgs *args = (struct addMarkersArgs*)user_data;
- struct java_calling_data *jargs = (struct java_calling_data*)args->java_args;
-
- jclass accessClass = (*jargs->env)->GetObjectClass(jargs->env, jargs->jobj);
- jmethodID accessFunction = (*jargs->env)->GetMethodID(jargs->env, accessClass, "addMarkersFromC", "(IJ)V");
-
- unsigned long marker_id = (unsigned long)data;
-
- /* The hash table store an ID... we will use the ID to access the array. */
- GArray *marker = args->mdata->markers;
- struct marker_info *newPtr = &g_array_index(marker, struct marker_info, marker_id);
-
- (*jargs->env)->CallVoidMethod(jargs->env, jargs->jobj, accessFunction, marker_id, CONVERT_PTR_TO_JLONG(newPtr) );
-}
-
-/* Function to fill up the java map with the event type found in tracefile (the name) */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1feedAllMarkers(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- /* ***TODO***
- Find a better way! This is ugly! */
- struct java_calling_data java_args = { env, jobj };
- struct addMarkersArgs args = { &java_args, newPtr->mdata };
-
- g_hash_table_foreach( newPtr->mdata->markers_hash, &g_hash_table_foreach_addMarkersOfTracefile, &args);
-}
-
-
-/* Function to print the content of a tracefile */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1printTracefile(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
-
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
- printf("cpu_online : %i\n" ,(int)newPtr->cpu_online);
- printf("long_name : %s\n" ,g_quark_to_string(newPtr->long_name));
- printf("name : %s\n" ,g_quark_to_string(newPtr->name));
- printf("cpu_num : %u\n" ,(unsigned int)(newPtr->cpu_num));
- printf("tid : %u\n" ,(unsigned int)(newPtr->tid));
- printf("pgid : %u\n" ,(unsigned int)(newPtr->pgid));
- printf("creation : %lu\n" ,(long unsigned int)(newPtr->creation));
- printf("trace ptr : %p\n" ,newPtr->trace);
- printf("marker ptr : %p\n" ,newPtr->mdata);
- printf("fd : %i\n" ,(int)(newPtr->fd));
- printf("file_size : %u\n" ,(unsigned int)(newPtr->file_size));
- printf("num_blocks : %u\n" ,(unsigned int)(newPtr->num_blocks));
- printf("reverse_bo : %i\n" ,(int)newPtr->reverse_bo);
- printf("float_word_order : %i\n" ,(int)newPtr->float_word_order);
- printf("alignment : %i\n" ,(int)newPtr->alignment);
- printf("buffer_header_size : %i\n" ,(int)newPtr->buffer_header_size);
- printf("tscbits : %u\n" ,(unsigned short)newPtr->tscbits);
- printf("eventbits : %u\n" ,(unsigned short)newPtr->eventbits);
- printf("tsc_mask : %lu\n" ,(long unsigned int)newPtr->tsc_mask);
- printf("tsc_mask_next_bit : %lu\n" ,(long unsigned int)newPtr->tsc_mask_next_bit);
- printf("events_lost : %u\n" ,(unsigned int)newPtr->events_lost);
- printf("subbuf_corrupt : %u\n" ,(unsigned int)newPtr->subbuf_corrupt);
- printf("event ptr : %p\n" ,&newPtr->event);
- printf("buffer ptr : %p\n" ,&newPtr->buffer);
- printf("\n");
-}
-/*
-#
-### */
-
-
-
-/*
-### EVENT methods ###
-# */
-
-/* Method to get the read status */
-/* This method will read the next event and then seek back its initial position */
-/* Lttv assume that every tracefile have at least 1 event, but we have not guarantee after this one. */
-/* We will read the next event and return the status of that read */
-/* We will then seek back to our initial position */
-/* Note : this method is expensive and should not be used too often */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1positionToFirstEvent(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *tracefilePtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- /* Ask ltt to read the next events on the given tracefiles
- Returned value can be :
- 0 if everything went fine (EOK)
- ERANGE = 34 out of range, back to last event (might be system dependent?)
- EPERM = 1 error while reading (might be system dependent?) */
-
- if (tracefilePtr->trace == NULL) {
- return (jint) EPERM;
- }
-
- /* Seek to the start time... this will also read the first event, as we want. */
- int returnedValue = ltt_tracefile_seek_time(tracefilePtr, ((struct LttTrace)*(tracefilePtr->trace)).start_time_from_tsc);
-
- return (jint)returnedValue;
-}
-
-/* Method to read next event */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1readNextEvent(JNIEnv *env, jobject jobj, jlong tracefile_ptr) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- /* Ask ltt to read the next events on the given tracefiles
- Returned value can be :
- 0 if everything went fine (EOK)
- ERANGE = 34 out of range, back to last event (might be system dependent?)
- EPERM = 1 error while reading (might be system dependent?) */
-
-
- /* ***FIXME***
- This might fail on the FIRST event, as the timestamp before the first read is uninitialized
- However, LTT make the assumption that all tracefile have AT LEAST one event, so we got to run with it */
-
- /* Save "last time" before moving, to be able to get back if needed */
- LttTime lastTime = newPtr->event.event_time;
-
- int returnedValue = ltt_tracefile_read(newPtr);
-
- /* We need to get back to previous after an error to keep a sane state */
- if ( returnedValue != 0 ) {
- ltt_tracefile_seek_time(newPtr, lastTime);
- }
-
- return (jint)returnedValue;
-}
-
-/* Method to seek to a certain event */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1seekEvent(JNIEnv *env, jobject jobj, jlong tracefile_ptr, jobject time_jobj) {
- LttTracefile *newPtr = (LttTracefile*)CONVERT_JLONG_TO_PTR(tracefile_ptr);
-
- guint64 fullTime = 0;
-
- jclass accessClass = (*env)->GetObjectClass(env, time_jobj);
- jmethodID getTimeFunction = (*env)->GetMethodID(env, accessClass, "getTime", "()J");
- fullTime = (*env)->CallLongMethod(env, time_jobj, getTimeFunction);
-
- /* ***HACK***
- Conversion from jlong -> C long seems to be particularly sloppy
- Depending how and where (inlined a function or as a single operation) we do this, we might end up with wrong number
- The following asignation of guint64 seems to work well.
- MAKE SURE TO PERFORM SEVERAL TESTS IF YOU CHANGE THIS. */
- guint64 seconds = fullTime/BILLION;
- guint64 nanoSeconds = fullTime%BILLION;
-
- LttTime seekTime = { (unsigned long)seconds, (unsigned long)nanoSeconds };
-
- /* Ask ltt to read the next events on the given tracefiles
- Returned value can be :
- 0 if everything went fine (EOK)
- ERANGE = 34 out of range, back to last event (might be system dependent?)
- EPERM = 1 error while reading (might be system dependent?) */
-
- int returnedValue = ltt_tracefile_seek_time(newPtr, seekTime);
- return (jint)returnedValue;
-}
-
-/* Get of tracefile */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTracefilePtr(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return CONVERT_PTR_TO_JLONG(newPtr->tracefile);
-}
-
-/* Get of block */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getBlock(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return (jlong)newPtr->block;
-}
-
-/* Get of offset */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOffset(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return (jlong)newPtr->offset;
-}
-
-/* Get of tsc */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCurrentTimestampCounter(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->tsc);
-}
-
-/* Get of timestamp */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTimestamp(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return (jlong)newPtr->timestamp;
-}
-
-/* Get of event_id */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventMarkerId(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return (jint)newPtr->event_id;
-}
-
-/* Get time in nanoseconds */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getNanosencondsTime(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return (CONVERT_UINT64_TO_JLONG(newPtr->event_time.tv_sec)*BILLION) + CONVERT_UINT64_TO_JLONG(newPtr->event_time.tv_nsec);
-}
-
-/* Fill event_time into an object */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1feedEventTime(JNIEnv *env, jobject jobj, jlong event_ptr, jobject time_jobj) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- jclass accessClass = (*env)->GetObjectClass(env, time_jobj);
- jmethodID accessFunction = (*env)->GetMethodID(env, accessClass, "setTimeFromC", "(J)V");
-
- jlong fullTime = (CONVERT_UINT64_TO_JLONG(newPtr->event_time.tv_sec)*BILLION) + CONVERT_UINT64_TO_JLONG(newPtr->event_time.tv_nsec);
-
- (*env)->CallVoidMethod(env, time_jobj, accessFunction, fullTime);
-}
-
-/* Access method to the data */
-/* The data are in "byte" form */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getDataContent(JNIEnv *env, jobject jobj, jlong event_ptr, jlong data_size, jbyteArray dataArray) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- (*env)->SetByteArrayRegion(env, dataArray, 0, (jsize)data_size, newPtr->data);
-}
-
-/* Get of data_size */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventDataSize(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return (jlong)newPtr->data_size;
-}
-
-/* Get of event_size */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventSize(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return (jlong)newPtr->event_size;
-}
-
-/* Get of count */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCount(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return (jint)newPtr->count;
-}
-
-/* Get of overflow_nsec */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOverflowNanoSeconds(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->overflow_nsec);
-}
-
-
-/* Function to print the content of a event */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1printEvent(JNIEnv *env, jobject jobj, jlong event_ptr) {
- LttEvent *newPtr = (LttEvent*)CONVERT_JLONG_TO_PTR(event_ptr);
-
- printf("tracefile : %p\n" ,(void*)newPtr->tracefile );
- printf("block : %u\n" ,(unsigned int)newPtr->block );
- printf("offset : %u\n" ,(unsigned int)newPtr->offset );
- printf("tsc : %lu\n" ,(long unsigned int)newPtr->tsc );
- printf("timestamp : %u\n" ,(unsigned int)newPtr->timestamp );
- printf("event_id : %u\n" ,(unsigned short)newPtr->event_id );
- printf("event_time : %p\n" ,(void*) &newPtr->event_time );
- printf(" sec : %lu\n" ,(long unsigned int)(newPtr->event_time.tv_sec) );
- printf(" nsec : %lu\n" ,(long unsigned int)(newPtr->event_time.tv_nsec) );
- printf("data : %p\n" ,(void*) newPtr->data );
- printf("data_size : %u\n" ,(unsigned int)newPtr->data_size );
- printf("event_size : %u\n" ,(unsigned int)newPtr->event_size );
- printf("count : %d\n" ,(int)newPtr->count );
- printf("overflow_nsec : %ld\n" ,(long)newPtr->overflow_nsec );
- printf("\n");
-}
-/*
-#
-### */
-
-
-/*
-### MARKER method ###
-# */
-
-/* Get of name */
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getName(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return (*env)->NewStringUTF(env, g_quark_to_string(newPtr->name));
-}
-
-/* Get of format */
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getFormatOverview(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return (*env)->NewStringUTF(env, newPtr->format);
-}
-
-/* Get of size */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return (jlong)newPtr->size;
-}
-
-/* Method to get all markerField pointers */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAllMarkerFields(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- jclass accessClass = (*env)->GetObjectClass(env, jobj);
- jmethodID accessFunction = (*env)->GetMethodID(env, accessClass, "addMarkerFieldFromC", "(Ljava/lang/String;J)V");
-
- GArray *field_array = (GArray*)newPtr->fields;
- struct marker_field *field;
- jlong marker_field_ptr;
-
- unsigned int i;
- for (i=0; i<field_array->len; i++) {
- field = &g_array_index(field_array, struct marker_field, i);
-
- marker_field_ptr = CONVERT_PTR_TO_JLONG(field);
-
- (*env)->CallVoidMethod(env, jobj, accessFunction, (*env)->NewStringUTF(env, g_quark_to_string(field->name) ), marker_field_ptr );
- }
-}
-
-
-
-/* Get of largest_align */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLargestAlign(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return (jshort)newPtr->largest_align;
-}
-
-/* Get of int_size */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getIntSize(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return (jshort)newPtr->int_size;
-}
-
-/* Get of long_size */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLongSize(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return (jshort)newPtr->long_size;
-}
-
-/* Get of pointer_size */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getPointerSize(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return (jshort)newPtr->pointer_size;
-}
-
-/* Get of size_t_size */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize_1tSize(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return (jshort)newPtr->size_t_size;
-}
-
-/* Get of alignment */
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAlignement(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return (jshort)newPtr->alignment;
-}
-
-/* Get of next */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getNextMarkerPtr(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- return CONVERT_PTR_TO_JLONG(newPtr->next);
-}
-
-
-/* Function to print the content of a marker */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1printMarker(JNIEnv *env, jobject jobj, jlong marker_info_ptr) {
- struct marker_info *newPtr = (struct marker_info*)CONVERT_JLONG_TO_PTR(marker_info_ptr);
-
- printf("name : %s\n" ,g_quark_to_string(newPtr->name) );
- printf("format : %s\n" ,newPtr->format );
- printf("size : %li\n" ,(long int)newPtr->size );
- printf("largest_align : %u\n" ,(unsigned short)newPtr->largest_align );
- printf("fields : %p\n" ,newPtr->fields );
- printf("int_size : %u\n" ,(unsigned short)newPtr->int_size );
- printf("long_size : %u\n" ,(unsigned short)newPtr->long_size );
- printf("pointer_size : %u\n" ,(unsigned short)newPtr->pointer_size );
- printf("size_t_size : %u\n" ,(unsigned short)newPtr->size_t_size );
- printf("alignment : %u\n" ,(unsigned short)newPtr->alignment );
- printf("next : %p\n" ,newPtr->next );
- printf("\n");
-}
-/*
-#
-### */
-
-
-
-/*
-### MARKERFIELD Method
-# */
-
-/* Get of name */
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getField(JNIEnv *env, jobject jobj, jlong marker_field_ptr) {
- struct marker_field *newPtr = (struct marker_field*)CONVERT_JLONG_TO_PTR(marker_field_ptr);
-
- return (*env)->NewStringUTF(env, g_quark_to_string(newPtr->name));
-}
-
-/* Get of type */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getType(JNIEnv *env, jobject jobj, jlong marker_field_ptr) {
- struct marker_field *newPtr = (struct marker_field*)CONVERT_JLONG_TO_PTR(marker_field_ptr);
-
- return (jint)newPtr->type;
-}
-
-/* Get of alignment */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAlignment(JNIEnv *env, jobject jobj, jlong marker_field_ptr) {
- struct marker_field *newPtr = (struct marker_field*)CONVERT_JLONG_TO_PTR(marker_field_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->alignment);
-}
-
-/* Get of attributes */
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAttributes(JNIEnv *env, jobject jobj, jlong marker_field_ptr) {
- struct marker_field *newPtr = (struct marker_field*)CONVERT_JLONG_TO_PTR(marker_field_ptr);
-
- return CONVERT_UINT64_TO_JLONG(newPtr->attributes);
-}
-
-/* Get of static_offset */
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getStatic_1offset(JNIEnv *env, jobject jobj, jlong marker_field_ptr) {
- struct marker_field *newPtr = (struct marker_field*)CONVERT_JLONG_TO_PTR(marker_field_ptr);
-
- return (jint)newPtr->static_offset;
-}
-
-/* Get of fmt */
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getFormat(JNIEnv *env, jobject jobj, jlong marker_field_ptr) {
- struct marker_field *newPtr = (struct marker_field*)CONVERT_JLONG_TO_PTR(marker_field_ptr);
-
- return (*env)->NewStringUTF(env, newPtr->fmt->str);
-}
-
-/* Function to print the content of a marker_field */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1printMarkerField(JNIEnv *env, jobject jobj, jlong marker_field_ptr) {
- struct marker_field *newPtr = (struct marker_field*)CONVERT_JLONG_TO_PTR(marker_field_ptr);
-
- printf("name : %s\n" ,g_quark_to_string(newPtr->name) );
- printf("type : %i\n" ,(int)newPtr->type );
- printf("alignment : %lu\n" ,(long unsigned int)newPtr->alignment );
- printf("attributes : %lu\n" ,(long unsigned int)newPtr->attributes );
- printf("static_offset : %i\n" ,(int)newPtr->static_offset );
- printf("fmt : %s\n" ,newPtr->fmt->str );
- printf("\n");
-}
-/*
-#
-### */
-
-
-/*
-### PARSER Method
-# */
-
-/* This function will do the actual parsing */
-/* It will then call java to assign the parsed data to the object "javaObj" */
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniParser_ltt_1getParsedData(JNIEnv *env, jclass accessClass, jobject javaObj, jlong event_ptr, jlong marker_field_ptr) {
- LttEvent newEventPtr = *(LttEvent*)(CONVERT_JLONG_TO_PTR(event_ptr));
- struct marker_field *newMarkerFieldPtr = (struct marker_field*)CONVERT_JLONG_TO_PTR(marker_field_ptr);
- struct LttField *newLttFieldPtr = ltt_event_field(&newEventPtr, marker_field_get_index(newMarkerFieldPtr));
-
- jmethodID accessFunction = NULL;
-
-
- /*
- There is a very limited number of type in LTT
- We will switch on the type for this field and act accordingly
- NOTE : We will save all integer into "long" type, as there is no signed/unsigned in java */
-
- /* ***HACK***
- It seems the marker_field->type is absolutely not consistent, especially about pointer!
- Sometime pointer are saved in String, sometime as Int, sometime as pointer...
- We will do an extra check on type "LTT_TYPE_UNSIGNED_INT" to check if the marker_field->format is hint of a pointer */
- switch ( newMarkerFieldPtr->type ) {
- case LTT_TYPE_SIGNED_INT :
- accessFunction = (*env)->GetStaticMethodID(env, accessClass, "addLongToParsingFromC", "(Ljava/lang/Object;J)V");
- (*env)->CallStaticVoidMethod( env,
- accessClass,
- accessFunction,
- javaObj,
- ltt_event_get_long_int(&newEventPtr, newMarkerFieldPtr)
- );
-
- break;
-
- case LTT_TYPE_UNSIGNED_INT :
- /* If the format seems to be a pointer, add it as a pointer */
- if ( (strncmp(newMarkerFieldPtr->fmt->str, "0x%llX", newMarkerFieldPtr->fmt->len) == 0 ) || (strncmp(newMarkerFieldPtr->fmt->str, "%llX", newMarkerFieldPtr->fmt->len) == 0 ) ) {
- #if __WORDSIZE == 64
- accessFunction = (*env)->GetStaticMethodID(env, accessClass, "addLongPointerToParsingFromC", "(Ljava/lang/Object;J)V");
- #else
- accessFunction = (*env)->GetStaticMethodID(env, accessClass, "addIntPointerToParsingFromC", "(Ljava/lang/Object;J)V");
- #endif
- (*env)->CallStaticVoidMethod( env,
- accessClass,
- accessFunction,
- javaObj,
- CONVERT_PTR_TO_JLONG(ltt_event_get_long_unsigned(&newEventPtr, newMarkerFieldPtr) )
- );
- }
- /* Otherwise, add it as a number */
- else {
- accessFunction = (*env)->GetStaticMethodID(env, accessClass, "addLongToParsingFromC", "(Ljava/lang/Object;J)V");
- (*env)->CallStaticVoidMethod( env,
- accessClass,
- accessFunction,
- javaObj,
- ltt_event_get_long_unsigned(&newEventPtr, newMarkerFieldPtr)
- );
- }
-
- break;
-
- case LTT_TYPE_POINTER :
- #if __WORDSIZE == 64
- accessFunction = (*env)->GetStaticMethodID(env, accessClass, "addLongPointerToParsingFromC", "(Ljava/lang/Object;J)V");
- #else
- accessFunction = (*env)->GetStaticMethodID(env, accessClass, "addIntPointerToParsingFromC", "(Ljava/lang/Object;J)V");
- #endif
- (*env)->CallStaticVoidMethod( env,
- accessClass,
- accessFunction,
- javaObj,
- CONVERT_PTR_TO_JLONG(*(GINT_TYPE_FOR_PTR*)(newEventPtr.data + newLttFieldPtr->offset))
- );
- break;
-
- case LTT_TYPE_STRING :
- accessFunction = (*env)->GetStaticMethodID(env, accessClass, "addStringToParsingFromC", "(Ljava/lang/Object;Ljava/lang/String;)V");
- (*env)->CallStaticVoidMethod( env,
- accessClass,
- accessFunction,
- javaObj,
- (*env)->NewStringUTF(env, ltt_event_get_string(&newEventPtr, newMarkerFieldPtr) )
- );
- break;
-
- case LTT_TYPE_COMPACT :
- case LTT_TYPE_NONE :
- default :
- printf("Warning : Unrecognized format type! Skipping! (Java_org_eclipse_linuxtools_lttng_jni_JniParser_ltt_1getParsedData)");
- break;
- }
-
-}
-/*
-#
-### */
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2003-2004 Xiangxiu Yang
- * 2006 Mathieu Desnoyers
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef LTT_PRIVATE_H
-#define LTT_PRIVATE_H
-
-#include <glib.h>
-#include <sys/types.h>
-#include <ltt/ltt.h>
-#include <endian.h>
-#include <ltt/event.h>
-
-#ifndef max
-#define max(a,b) ((a)>(b)?(a):(b))
-#endif
-
-#ifndef min
-#define min(a,b) ((a)<(b)?(a):(b))
-#endif
-
-
-
-#define LTT_MAGIC_NUMBER 0x00D6B7ED
-#define LTT_REV_MAGIC_NUMBER 0xEDB7D600
-
-#define NSEC_PER_USEC 1000
-
-/* Byte ordering */
-#define LTT_GET_BO(t) ((t)->reverse_bo)
-
-#define LTT_HAS_FLOAT(t) ((t)->float_word_order ! =0)
-#define LTT_GET_FLOAT_BO(t) \
- (((t)->float_word_order == __BYTE_ORDER) ? 0 : 1)
-
-#define SEQUENCE_AVG_ELEMENTS 1000
-
-/*
- * offsetof taken from Linux kernel.
- */
-#undef offsetof
-#ifdef __compiler_offsetof
-#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
-#else
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
-typedef guint8 uint8_t;
-typedef guint16 uint16_t;
-typedef guint32 uint32_t;
-typedef guint64 uint64_t;
-
-/* Subbuffer header */
-struct ltt_subbuffer_header_2_6 {
- uint64_t cycle_count_begin; /* Cycle count at subbuffer start */
- uint64_t cycle_count_end; /* Cycle count at subbuffer end */
- uint32_t magic_number; /*
- * Trace magic number.
- * contains endianness information.
- */
- uint8_t major_version;
- uint8_t minor_version;
- uint8_t arch_size; /* Architecture pointer size */
- uint8_t alignment; /* LTT data alignment */
- uint64_t start_time_sec; /* NTP-corrected start time */
- uint64_t start_time_usec;
- uint64_t start_freq; /*
- * Frequency at trace start,
- * used all along the trace.
- */
- uint32_t freq_scale; /* Frequency scaling (divide freq) */
- uint32_t data_size; /* Size of data in subbuffer */
- uint32_t sb_size; /* Subbuffer size (page aligned) */
- uint32_t events_lost; /*
- * Events lost in this subbuffer since
- * the beginning of the trace.
- * (may overflow)
- */
- uint32_t subbuf_corrupt; /*
- * Corrupted (lost) subbuffers since
- * the begginig of the trace.
- * (may overflow)
- */
- char header_end[0]; /* End of header */
-};
-
-typedef struct ltt_subbuffer_header_2_6 ltt_subbuffer_header_t;
-
-/*
- * Return header size without padding after the structure. Don't use packed
- * structure because gcc generates inefficient code on some architectures
- * (powerpc, mips..)
- */
-static inline size_t ltt_subbuffer_header_size(void)
-{
- return offsetof(ltt_subbuffer_header_t, header_end);
-}
-
-enum field_status { FIELD_UNKNOWN, FIELD_VARIABLE, FIELD_FIXED };
-
-typedef struct _LttBuffer {
- void * head;
- guint64 offset; /* Offset of the current subbuffer */
- guint32 size; /* The size of the current subbuffer */
- unsigned int index;
- uint32_t data_size; /* Size of data in the subbuffer */
-
- struct {
- LttTime timestamp;
- uint64_t cycle_count;
- uint64_t freq; /* Frequency in khz */
- } begin;
- struct {
- LttTime timestamp;
- uint64_t cycle_count;
- uint64_t freq; /* Frequency in khz */
- } end;
-
- /* Timekeeping */
- uint64_t tsc; /* Current timestamp counter */
- uint64_t freq; /* Frequency in khz */
- guint32 cyc2ns_scale;
-} LttBuffer;
-
-struct LttTracefile {
- gboolean cpu_online; //is the cpu online ?
- GQuark long_name; //tracefile complete filename
- GQuark name; //tracefile name
- guint cpu_num; //cpu number of the tracefile
- guint tid; //Usertrace tid, else 0
- guint pgid; //Usertrace pgid, else 0
- guint64 creation; //Usertrace creation, else 0
- LttTrace * trace; //trace containing the tracefile
- struct marker_data *mdata; // marker id/name/fields mapping
- int fd; //file descriptor
- off_t file_size; //file size
- //unsigned block_size; //block_size
- guint num_blocks; //number of blocks in the file
- gboolean reverse_bo; //must we reverse byte order ?
- gboolean float_word_order; //what is the byte order of floats ?
- size_t alignment; //alignment of events in the tracefile.
- // 0 or the architecture size in bytes.
-
- size_t buffer_header_size;
- uint8_t tscbits;
- uint8_t eventbits;
- uint64_t tsc_mask;
- uint64_t tsc_mask_next_bit; //next MSB after the mask<
- uint32_t events_lost;
- uint32_t subbuf_corrupt;
-
- GArray *buf_index; /* index mapping buffer index to offset */
- uint64_t end_timestamp; /* Last timestamp of file */
- /* Current event */
- LttEvent event; //Event currently accessible in the trace
-
- /* Current block */
- LttBuffer buffer; //current buffer
-};
-
-/* The characteristics of the system on which the trace was obtained
- is described in a LttSystemDescription structure. */
-
-struct LttSystemDescription {
- gchar *description;
- gchar *node_name;
- gchar *domain_name;
- unsigned nb_cpu;
- LttArchSize size;
- LttArchEndian endian;
- gchar *kernel_name;
- gchar *kernel_release;
- gchar *kernel_version;
- gchar *machine;
- gchar *processor;
- gchar *hardware_platform;
- gchar *operating_system;
- LttTime trace_start;
- LttTime trace_end;
-};
-
-/*
- * Calculate the offset needed to align the type.
- * If alignment is 0, alignment is deactivated.
- * else, the function returns the offset needed to
- * align align_drift on the alignment value.
- *
- * align align_drift on the alignment value (should be
- * the size of the architecture).
- */
-static inline unsigned int ltt_align(size_t align_drift,
- size_t size_of_type,
- size_t alignment)
-{
- size_t align_offset = min(alignment, size_of_type);
-
- if(!alignment)
- return 0;
-
- g_assert(size_of_type != 0);
- return ((align_offset - align_drift) & (align_offset-1));
-}
-
-
-#endif /* LTT_PRIVATE_H */
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2004-2005 Mathieu Desnoyers
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef LTT_TYPES_H
-#define LTT_TYPES_H
-
-/* Set of functions to access the types portably, given the trace as parameter.
- * */
-
-#include <ltt/ltt.h>
-#include <glib.h>
-#include <ltt/time.h>
-
-
-/*****************************************************************************
- *Function name
- * ltt_get_int64 : get a 64 bits integer number
- *Input params
- * ptr : pointer to the integer
- *Return value
- * gint64 : a 64 bits integer
- *
- * Takes care of endianness
- *
- ****************************************************************************/
-
-static inline gint64 ltt_get_int64(gboolean reverse_byte_order, void *ptr)
-{
- guint64 value = *(guint64*)ptr;
- return (gint64) (reverse_byte_order ? GUINT64_SWAP_LE_BE(value): value);
-}
-
-
-static inline guint64 ltt_get_uint64(gboolean reverse_byte_order, void *ptr)
-{
- guint64 value = *(guint64*)ptr;
- return (guint64) (reverse_byte_order ? GUINT64_SWAP_LE_BE(value): value);
-}
-
-static inline gint32 ltt_get_int32(gboolean reverse_byte_order, void *ptr)
-{
- guint32 value = *(guint32*)ptr;
- return (gint32) (reverse_byte_order ? GUINT32_SWAP_LE_BE(value): value);
-}
-
-static inline guint32 ltt_get_uint32(gboolean reverse_byte_order, void *ptr)
-{
- guint32 value = *(guint32*)ptr;
- return (guint32) (reverse_byte_order ? GUINT32_SWAP_LE_BE(value): value);
-}
-
-static inline gint16 ltt_get_int16(gboolean reverse_byte_order, void *ptr)
-{
- guint16 value = *(guint16*)ptr;
- return (gint16) (reverse_byte_order ? GUINT16_SWAP_LE_BE(value): value);
-}
-
-static inline guint16 ltt_get_uint16(gboolean reverse_byte_order, void *ptr)
-{
- guint16 value = *(guint16*)ptr;
- return (guint16) (reverse_byte_order ? GUINT16_SWAP_LE_BE(value): value);
-}
-
-static inline LttTime ltt_get_time(gboolean reverse_byte_order, void *ptr)
-{
- LttTime output;
-
- output.tv_sec = ltt_get_uint32(reverse_byte_order, ptr);
- ptr += sizeof(guint32);
- output.tv_nsec = ltt_get_uint32(reverse_byte_order, ptr);
-
- return output;
-}
-
-#endif // LTT_TYPES_H
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit trace reading library
- * Copyright (C) 2003-2004 Michel Dagenais
- * 2005 Mathieu Desnoyers
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef LTT_H
-#define LTT_H
-
-#include <glib.h>
-#include <ltt/time.h>
-#include <ltt/compiler.h>
-
-/* A trace is associated with a tracing session run on a single, possibly
- multi-cpu, system. It is defined as a pathname to a directory containing
- all the relevant trace files. All the tracefiles for a trace were
- generated in a single system for the same time period by the same
- trace daemon. They simply contain different events. Typically control
- tracefiles contain the important events (process creations and registering
- tracing facilities) for all CPUs, and one file for each CPU contains all
- the events for that CPU. All the tracefiles within the same trace directory
- then use the exact same id numbers for event types.
-
- A tracefile (LttTracefile) contains a list of events (LttEvent) sorted
- by time for each CPU; events from different CPUs may be slightly out of
- order, especially using the (possibly drifting) cycle counters as
- time unit.
-
- A facility is a list of event types (LttEventType), declared in a special
- eventdefs file. A corresponding checksum differentiates different
- facilities which would have the same name but a different content
- (e.g., different versions). The files are stored within the trace
- directory and are accessed automatically upon opening a trace.
- The list of facilities (and associated checksum) used in a trace
- must be known in order to properly decode the contained events. An event
- is stored in the "facilities" control tracefile to denote each different
- facility used.
-
- Event types (LttEventType) refer to data types (LttType) describing
- their content. The data types supported are integer and unsigned integer
- (of various length), enumerations (a special form of unsigned integer),
- floating point (of various length), fixed size arrays, sequence
- (variable sized arrays), structures and null terminated strings.
- The elements of arrays and sequences, and the data members for
- structures, may be of any nested data type (LttType).
-
- An LttField is a special object to denote a specific, possibly nested,
- field within an event type. Suppose an event type socket_connect is a
- structure containing two data members, source and destination, of type
- socket_address. Type socket_address contains two unsigned integer
- data members, ip and port. An LttField is different from a data type
- structure member since it can denote a specific nested field, like the
- source port, and store associated access information (byte offset within
- the event data). The LttField objects are trace specific since the
- contained information (byte offsets) may vary with the architecture
- associated to the trace. */
-
-#define PREALLOC_EVENTS 28
-
-typedef struct LttTrace LttTrace;
-
-typedef struct LttTracefile LttTracefile;
-
-typedef struct LttSystemDescription LttSystemDescription;
-
-typedef struct LttEvent LttEvent;
-
-/* Checksums are used to differentiate facilities which have the same name
- but differ. */
-
-//typedef guint32 LttChecksum;
-
-
-/* Events are usually stored with the easily obtained CPU clock cycle count,
- ltt_cycle_count. This can be converted to the real time value, LttTime,
- using linear interpolation between regularly sampled values (e.g. a few
- times per second) of the real time clock with their corresponding
- cycle count values. */
-
-
-typedef struct _TimeInterval{
- LttTime start_time;
- LttTime end_time;
-} TimeInterval;
-
-
-typedef guint64 LttCycleCount;
-
-/* Event positions are used to seek within a tracefile based on
- the block number and event position within the block. */
-
-typedef struct LttEventPosition LttEventPosition;
-
-
-/* Differences between architectures include word sizes, endianess,
- alignment, floating point format and calling conventions. For a
- packed binary trace, endianess and size matter, assuming that the
- floating point format is standard (and is seldom used anyway). */
-
-typedef enum _LttArchSize
-{ LTT_LP32, LTT_ILP32, LTT_LP64, LTT_ILP64, LTT_UNKNOWN
-} LttArchSize;
-
-
-typedef enum _LttArchEndian
-{ LTT_LITTLE_ENDIAN, LTT_BIG_ENDIAN
-} LttArchEndian;
-
-typedef enum _LttTypeEnum
-{ LTT_INT_FIXED,
- LTT_UINT_FIXED,
- LTT_POINTER,
- LTT_CHAR,
- LTT_UCHAR,
- LTT_SHORT,
- LTT_USHORT,
- LTT_INT,
- LTT_UINT,
- LTT_LONG,
- LTT_ULONG,
- LTT_SIZE_T,
- LTT_SSIZE_T,
- LTT_OFF_T,
- LTT_FLOAT,
- LTT_STRING,
- LTT_ENUM,
- LTT_ARRAY,
- LTT_SEQUENCE,
- LTT_STRUCT,
- LTT_UNION,
- LTT_NONE
-} LttTypeEnum;
-
-
-/* Architecture types */
-#define LTT_ARCH_TYPE_I386 1
-#define LTT_ARCH_TYPE_PPC 2
-#define LTT_ARCH_TYPE_SH 3
-#define LTT_ARCH_TYPE_S390 4
-#define LTT_ARCH_TYPE_MIPS 5
-#define LTT_ARCH_TYPE_ARM 6
-#define LTT_ARCH_TYPE_PPC64 7
-#define LTT_ARCH_TYPE_X86_64 8
-#define LTT_ARCH_TYPE_C2 9
-#define LTT_ARCH_TYPE_POWERPC 10
-#define LTT_ARCH_TYPE_X86 11
-
-/* Standard definitions for variants */
-#define LTT_ARCH_VARIANT_NONE 0 /* Main architecture implementation */
-
-#endif // LTT_H
+++ /dev/null
-
-/* Important to get consistent size_t type */
-#define _FILE_OFFSET_BITS 64
-
-#include <jni.h>
-#include <ltt/trace.h>
-#include <ltt/time.h>
-#include <ltt/marker.h>
-#include <glib.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <dlfcn.h>
-
-int nb_id = 0;
-
-struct version_correlation {
- int id;
- char *libname;
- void *static_handle;
-};
-
-struct version_correlation *version_table = NULL;
-
-struct function_tables {
- void (*Java_org_eclipse_linuxtools_lttng_jni_Jni_1C_1Common_ltt_1printC)(JNIEnv *env, jobject jobj, jstring new_string);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTrace)(JNIEnv *env, jobject jobj, jstring pathname, jboolean show_debug);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTraceLive)(JNIEnv *env, jobject jobj, jstring pathname, jboolean show_debug);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1closeTrace)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jstring (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getTracepath)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getCpuNumber)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchType)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchVariant)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchSize)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMajorVersion)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMinorVersion)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFlightRecorder)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFreqScale)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartFreq)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartTimestampCurrentCounter)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartMonotonic)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1updateTrace)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTime)(JNIEnv *env, jobject jobj, jlong trace_ptr, jobject time_jobj);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTimeFromTimestampCurrentCounter)(JNIEnv *env, jobject jobj, jlong trace_ptr, jobject time_jobj);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedAllTracefiles)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange)(JNIEnv *env, jobject jobj, jlong trace_ptr, jobject jstart_time, jobject jend_time);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1printTrace)(JNIEnv *env, jobject jobj, jlong trace_ptr);
- jboolean (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsCpuOnline)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jstring (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilepath)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jstring (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilename)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCpuNumber)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTid)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getPgid)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCreation)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracePtr)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getMarkerDataPtr)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCFileDescriptor)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getFileSize)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBlockNumber)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jboolean (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsBytesOrderReversed)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jboolean (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsFloatWordOrdered)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getAlignement)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferHeaderSize)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfCurrentTimestampCounter)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfEvent)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMask)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMaskNextBit)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventsLost)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getSubBufferCorrupt)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventPtr)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferPtr)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferSize)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1feedAllMarkers)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1printTracefile)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1positionToFirstEvent)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1readNextEvent)(JNIEnv *env, jobject jobj, jlong tracefile_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1seekEvent)(JNIEnv *env, jobject jobj, jlong tracefile_ptr, jobject time_jobj);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTracefilePtr)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getBlock)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOffset)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCurrentTimestampCounter)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTimestamp)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventMarkerId)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getNanosencondsTime)(JNIEnv *env, jobject jobj, jlong event_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1feedEventTime)(JNIEnv *env, jobject jobj, jlong event_ptr, jobject time_jobj);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getDataContent)(JNIEnv *env, jobject jobj, jlong event_ptr, jlong data_size, jbyteArray dataArray);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventDataSize)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventSize)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCount)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOverflowNanoSeconds)(JNIEnv *env, jobject jobj, jlong event_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1printEvent)(JNIEnv *env, jobject jobj, jlong event_ptr);
- jstring (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getName)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jstring (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getFormatOverview)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAllMarkerFields)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLargestAlign)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getIntSize)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLongSize)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getPointerSize)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize_1tSize)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jshort (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAlignement)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getNextMarkerPtr)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1printMarker)(JNIEnv *env, jobject jobj, jlong marker_info_ptr);
- jstring (*Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getField)(JNIEnv *env, jobject jobj, jlong marker_field_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getType)(JNIEnv *env, jobject jobj, jlong marker_field_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getOffset)(JNIEnv *env, jobject jobj, jlong marker_field_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getSize)(JNIEnv *env, jobject jobj, jlong marker_field_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAlignment)(JNIEnv *env, jobject jobj, jlong marker_field_ptr);
- jlong (*Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAttributes)(JNIEnv *env, jobject jobj, jlong marker_field_ptr);
- jint (*Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getStatic_1offset)(JNIEnv *env, jobject jobj, jlong marker_field_ptr);
- jstring (*Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getFormat)(JNIEnv *env, jobject jobj, jlong marker_field_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1printMarkerField)(JNIEnv *env, jobject jobj, jlong marker_field_ptr);
- void (*Java_org_eclipse_linuxtools_lttng_jni_JniParser_ltt_1getParsedData)(JNIEnv *env, jclass accessClass, jobject javaObj, jlong event_ptr, jlong marker_field_ptr);
-};
-
-struct function_tables *version_functions_table = NULL;
-
-void ignore_and_drop_message(const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) {
-}
-
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_factory_JniTraceVersion_ltt_1getTraceVersion(JNIEnv *env, jobject jobj, jstring tracepath) {
-
- void *handle = dlopen("liblttvtraceread.so", RTLD_LAZY );
-
- if (!handle ) {
- printf ("WARNING : Failed to initialize library handle from %s!\n", "liblttvtraceread.so");
- }
- void (*functor)(JNIEnv *env, jobject jobj, jstring tracepath);
- functor=dlsym(handle, "Java_org_eclipse_linuxtools_lttng_jni_factory_JniTraceVersion_ltt_1getTraceVersion");
-
- char *error = dlerror();
- if ( error != NULL) {
- printf ("Call failed with : %s\n", error);
- }
- else {
- (*functor)(env, jobj, tracepath);
- }
-}
-
-void freeAllHandle() {
- if ( version_table != NULL ) {
- free(version_table);
- version_table = NULL;
- }
-
- if ( version_functions_table != NULL ) {
- free(version_functions_table);
- version_functions_table = NULL;
- }
-}
-
-void freeHandle(int handle_id) {
- if ( handle_id >= nb_id ) {
- if (version_table[handle_id].static_handle != NULL) {
- /* Memory will be freed by dlclose as well */
- dlclose(version_table[handle_id].static_handle);
- version_table[handle_id].static_handle = NULL;
- free(version_table[handle_id].libname);
- version_table[handle_id].libname = NULL;
- }
- }
-
- int isEmpty = 1;
- int n;
- for ( n=0; n<nb_id; n++) {
- if ( version_table[n].static_handle != NULL ) {
- isEmpty = 0;
- }
- }
-
- if ( isEmpty == 1 ) {
- freeAllHandle();
- }
-}
-
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1freeHandle(JNIEnv *env, jobject jobj, jint lib_id) {
- // Call function to free the memory
- freeHandle(lib_id);
-}
-
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1initializeHandle(JNIEnv *env, jobject jobj, jstring libname) {
-
- jint lib_id = -1;
- const char* c_path = (*env)->GetStringUTFChars(env, libname, 0);
-
- int isLoaded = 0;
- int n;
- for ( n=0; n<nb_id; n++) {
- if ( strncmp(version_table[n].libname, c_path, strlen(version_table[n].libname) ) == 0 ) {
- isLoaded = 1;
- lib_id = version_table[n].id;
- }
- }
-
- if ( isLoaded == 0 ) {
- void *new_handle = dlopen(c_path, RTLD_LAZY );
-
- if (!new_handle ) {
- printf ("WARNING : Failed to initialize library handle from %s!\n", c_path);
- }
- else {
- lib_id = nb_id;
- nb_id++;
-
- void* new_version_table = malloc(sizeof(struct version_correlation)*(nb_id) );
- void* new_function_tables = malloc(sizeof(struct function_tables)*(nb_id) );
-
- if ( nb_id > 1) {
- memcpy(new_version_table,version_table, sizeof(struct version_correlation)*(nb_id-1) );
- free( version_table );
-
- memcpy(new_function_tables,version_functions_table, sizeof(struct function_tables)*(nb_id-1) );
- free( version_functions_table) ;
- }
-
- version_table = (struct version_correlation *)new_version_table;
- version_table[lib_id].id = lib_id;
- version_table[lib_id].libname = (char*)malloc( strlen(c_path) );
- strncpy(version_table[lib_id].libname, c_path, strlen(c_path));
- version_table[lib_id].static_handle = new_handle;
-
- version_functions_table = (struct function_tables*)new_function_tables;
-
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_Jni_1C_1Common_ltt_1printC = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_Jni_1C_1Common_ltt_1printC");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTrace = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTrace");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTraceLive = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTraceLive");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1closeTrace = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1closeTrace");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getTracepath = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getTracepath");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getCpuNumber = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getCpuNumber");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchType = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchType");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchVariant = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchVariant");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMajorVersion = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMajorVersion");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMinorVersion = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMinorVersion");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFlightRecorder = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFlightRecorder");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFreqScale = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFreqScale");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartFreq = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartFreq");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartTimestampCurrentCounter = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartTimestampCurrentCounter");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartMonotonic = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartMonotonic");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1updateTrace = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1updateTrace");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTime = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTime");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTimeFromTimestampCurrentCounter = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTimeFromTimestampCurrentCounter");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedAllTracefiles = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedAllTracefiles");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1printTrace = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1printTrace");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsCpuOnline = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsCpuOnline");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilepath = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilepath");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilename = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilename");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCpuNumber = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCpuNumber");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTid = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTid");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getPgid = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getPgid");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCreation = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCreation");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracePtr = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracePtr");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getMarkerDataPtr = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getMarkerDataPtr");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCFileDescriptor = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCFileDescriptor");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getFileSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getFileSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBlockNumber = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBlockNumber");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsBytesOrderReversed = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsBytesOrderReversed");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsFloatWordOrdered = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsFloatWordOrdered");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getAlignement = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getAlignement");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferHeaderSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferHeaderSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfCurrentTimestampCounter = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfCurrentTimestampCounter");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfEvent = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfEvent");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMask = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMask");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMaskNextBit = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMaskNextBit");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventsLost = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventsLost");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getSubBufferCorrupt = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getSubBufferCorrupt");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventPtr = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventPtr");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferPtr = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferPtr");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1feedAllMarkers = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1feedAllMarkers");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1printTracefile = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1printTracefile");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1positionToFirstEvent = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1positionToFirstEvent");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1readNextEvent = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1readNextEvent");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1seekEvent = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1seekEvent");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTracefilePtr = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTracefilePtr");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getBlock = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getBlock");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOffset = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOffset");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCurrentTimestampCounter = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCurrentTimestampCounter");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTimestamp = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTimestamp");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventMarkerId = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventMarkerId");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getNanosencondsTime = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getNanosencondsTime");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1feedEventTime = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1feedEventTime");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getDataContent = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getDataContent");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventDataSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventDataSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCount = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCount");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOverflowNanoSeconds = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOverflowNanoSeconds");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1printEvent = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1printEvent");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getName = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getName");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getFormatOverview = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getFormatOverview");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAllMarkerFields = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAllMarkerFields");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLargestAlign = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLargestAlign");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getIntSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getIntSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLongSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLongSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getPointerSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getPointerSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize_1tSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize_1tSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAlignement = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAlignement");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getNextMarkerPtr = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getNextMarkerPtr");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1printMarker = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1printMarker");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getField = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getField");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getType = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getType");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getOffset = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getOffset");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getSize = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getSize");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAlignment = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAlignment");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAttributes = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAttributes");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getStatic_1offset = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getStatic_1offset");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getFormat = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getFormat");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1printMarkerField = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1printMarkerField");
- version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniParser_ltt_1getParsedData = dlsym(version_table[lib_id].static_handle, "Java_org_eclipse_linuxtools_lttng_jni_JniParser_ltt_1getParsedData");
- }
- }
-
- return lib_id;
-}
-
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_Jni_1C_1Common_ltt_1printC(JNIEnv *env, jobject jobj, jint lib_id, jstring new_string) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_Jni_1C_1Common_ltt_1printC)(env, jobj, new_string);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTrace(JNIEnv *env, jobject jobj, jint lib_id, jstring pathname, jboolean show_debug) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTrace)(env, jobj, pathname, show_debug);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTraceLive(JNIEnv *env, jobject jobj, jint lib_id, jstring pathname, jboolean show_debug) {
- if (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTraceLive == NULL) {
- return 0;
- }
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1openTraceLive)(env, jobj, pathname, show_debug);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1closeTrace(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1closeTrace)(env, jobj, trace_ptr);
-}
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getTracepath(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getTracepath)(env, jobj, trace_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getCpuNumber(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getCpuNumber)(env, jobj, trace_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchType(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchType)(env, jobj, trace_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchVariant(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchVariant)(env, jobj, trace_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchSize(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getArchSize)(env, jobj, trace_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMajorVersion(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMajorVersion)(env, jobj, trace_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMinorVersion(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getLttMinorVersion)(env, jobj, trace_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFlightRecorder(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFlightRecorder)(env, jobj, trace_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFreqScale(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getFreqScale)(env, jobj, trace_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartFreq(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartFreq)(env, jobj, trace_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartTimestampCurrentCounter(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartTimestampCurrentCounter)(env, jobj, trace_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartMonotonic(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1getStartMonotonic)(env, jobj, trace_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1updateTrace(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- if (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1updateTrace == NULL) {
- return;
- }
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1updateTrace)(env, jobj, trace_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTime(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr, jobject time_jobj) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTime)(env, jobj, trace_ptr, time_jobj);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTimeFromTimestampCurrentCounter(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr, jobject time_jobj) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedStartTimeFromTimestampCurrentCounter)(env, jobj, trace_ptr, time_jobj);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedAllTracefiles(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedAllTracefiles)(env, jobj, trace_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr, jobject jstart_time, jobject jend_time) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1feedTracefileTimeRange)(env, jobj, trace_ptr, jstart_time, jend_time);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1printTrace(JNIEnv *env, jobject jobj, jint lib_id, jlong trace_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTrace_ltt_1printTrace)(env, jobj, trace_ptr);
-}
-JNIEXPORT jboolean JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsCpuOnline(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsCpuOnline)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilepath(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilepath)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilename(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracefilename)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCpuNumber(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCpuNumber)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTid(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTid)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getPgid(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getPgid)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCreation(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCreation)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracePtr(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getTracePtr)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getMarkerDataPtr(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getMarkerDataPtr)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCFileDescriptor(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCFileDescriptor)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getFileSize(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getFileSize)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBlockNumber(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBlockNumber)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jboolean JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsBytesOrderReversed(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsBytesOrderReversed)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jboolean JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsFloatWordOrdered(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getIsFloatWordOrdered)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getAlignement(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getAlignement)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferHeaderSize(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferHeaderSize)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfCurrentTimestampCounter(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfCurrentTimestampCounter)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfEvent(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBitsOfEvent)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMask(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMask)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMaskNextBit(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getCurrentTimestampCounterMaskNextBit)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventsLost(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventsLost)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getSubBufferCorrupt(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getSubBufferCorrupt)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventPtr(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getEventPtr)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferPtr(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferPtr)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferSize(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1getBufferSize)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1feedAllMarkers(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1feedAllMarkers)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1printTracefile(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniTracefile_ltt_1printTracefile)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1positionToFirstEvent(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1positionToFirstEvent)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1readNextEvent(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1readNextEvent)(env, jobj, tracefile_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1seekEvent(JNIEnv *env, jobject jobj, jint lib_id, jlong tracefile_ptr, jobject time_jobj) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1seekEvent)(env, jobj, tracefile_ptr, time_jobj);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTracefilePtr(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTracefilePtr)(env, jobj, event_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getBlock(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getBlock)(env, jobj, event_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOffset(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOffset)(env, jobj, event_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCurrentTimestampCounter(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCurrentTimestampCounter)(env, jobj, event_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTimestamp(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getTimestamp)(env, jobj, event_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventMarkerId(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventMarkerId)(env, jobj, event_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getNanosencondsTime(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getNanosencondsTime)(env, jobj, event_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1feedEventTime(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr, jobject time_jobj) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1feedEventTime)(env, jobj, event_ptr, time_jobj);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getDataContent(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr, jlong data_size, jbyteArray dataArray) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getDataContent)(env, jobj, event_ptr, data_size, dataArray);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventDataSize(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventDataSize)(env, jobj, event_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventSize(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getEventSize)(env, jobj, event_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCount(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getCount)(env, jobj, event_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOverflowNanoSeconds(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1getOverflowNanoSeconds)(env, jobj, event_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1printEvent(JNIEnv *env, jobject jobj, jint lib_id, jlong event_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniEvent_ltt_1printEvent)(env, jobj, event_ptr);
-}
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getName(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getName)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getFormatOverview(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getFormatOverview)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAllMarkerFields(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAllMarkerFields)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLargestAlign(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLargestAlign)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getIntSize(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getIntSize)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLongSize(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getLongSize)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getPointerSize(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getPointerSize)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize_1tSize(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getSize_1tSize)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jshort JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAlignement(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getAlignement)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getNextMarkerPtr(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1getNextMarkerPtr)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1printMarker(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_info_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarker_ltt_1printMarker)(env, jobj, marker_info_ptr);
-}
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getField(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_field_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getField)(env, jobj, marker_field_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getType(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_field_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getType)(env, jobj, marker_field_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getOffset(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_field_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getOffset)(env, jobj, marker_field_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getSize(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_field_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getSize)(env, jobj, marker_field_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAlignment(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_field_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAlignment)(env, jobj, marker_field_ptr);
-}
-JNIEXPORT jlong JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAttributes(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_field_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getAttributes)(env, jobj, marker_field_ptr);
-}
-JNIEXPORT jint JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getStatic_1offset(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_field_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getStatic_1offset)(env, jobj, marker_field_ptr);
-}
-JNIEXPORT jstring JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getFormat(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_field_ptr) {
- return (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1getFormat)(env, jobj, marker_field_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1printMarkerField(JNIEnv *env, jobject jobj, jint lib_id, jlong marker_field_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniMarkerField_ltt_1printMarkerField)(env, jobj, marker_field_ptr);
-}
-JNIEXPORT void JNICALL Java_org_eclipse_linuxtools_lttng_jni_JniParser_ltt_1getParsedData(JNIEnv *env, jclass accessClass, jint lib_id, jobject javaObj, jlong event_ptr, jlong marker_field_ptr) {
- (version_functions_table[lib_id].Java_org_eclipse_linuxtools_lttng_jni_JniParser_ltt_1getParsedData)(env, accessClass, javaObj, event_ptr, marker_field_ptr);
-}
+++ /dev/null
-#ifndef _LTT_MARKER_DESC_H
-#define _LTT_MARKER_DESC_H
-
-/*
- * Marker description support header.
- *
- * Mathieu Desnoyers, August 2007
- * License: LGPL.
- */
-
-#include <stdio.h>
-#include <glib.h>
-#include <ltt/marker-field.h>
-
-//FIXME TEMP!
-static inline GQuark ltt_enum_string_get(struct marker_field *f,
- gulong value)
-{
- char tmp[1024] = "ENUM-";
- sprintf(&tmp[sizeof("ENUM-") - 1], "%lu", value);
- return g_quark_from_string(tmp);
-}
-
-#endif //_LTT_MARKER_DESC_H
+++ /dev/null
-#ifndef _LTT_MARKERS_FIELD_H
-#define _LTT_MARKERS_FIELD_H
-
-/*
- * Marker field support header.
- *
- * Mathieu Desnoyers, August 2007
- * License: LGPL.
- */
-
-#include <glib.h>
-
-enum ltt_type {
- LTT_TYPE_SIGNED_INT,
- LTT_TYPE_UNSIGNED_INT,
- LTT_TYPE_POINTER,
- LTT_TYPE_STRING,
- LTT_TYPE_COMPACT,
- LTT_TYPE_NONE,
-};
-
-/*
- * Fields "offset" and "size" below are only valid while the event is being
- * read. They are also being shared with events of the same type coming from
- * other per-cpu tracefiles. Therefore, the "LttEvent" fields_offsets offset and
- * size should be used rather than these.
- */
-struct marker_field {
- GQuark name;
- enum ltt_type type;
- unsigned int index; /* Field index within the event */
- unsigned long _offset; /* offset in the event data, USED ONLY INTERNALLY BY LIB */
- unsigned long _size; /* size of field. USED ONLY INTERNALLY BY LIB */
- unsigned long alignment;
- unsigned long attributes;
- int static_offset; /* boolean - private - is the field offset statically
- * known with the preceding types ? */
- GString *fmt;
-};
-
-static inline GQuark marker_field_get_name(struct marker_field *field)
-{
- return field->name;
-}
-
-static inline enum ltt_type marker_field_get_type(struct marker_field *field)
-{
- return field->type;
-}
-
-/*
- * Returns 0 if size is not known statically.
- */
-static inline long marker_field_get_size(struct marker_field *field)
-{
- return field->_size;
-}
-
-static inline unsigned int marker_field_get_index(struct marker_field *field)
-{
- return field->index;
-}
-
-#endif //_LTT_MARKERS_FIELD_H
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2007 Mathieu Desnoyers
- *
- * Complete rewrite from the original version made by XangXiu Yang.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <ltt/compiler.h>
-#include <ltt/marker.h>
-#include <ltt/ltt-private.h>
-
-#define DEFAULT_MARKERS_NUM 100
-#define DEFAULT_FIELDS_NUM 1
-#define MAX_NAME_LEN 1024
-
-static inline const char *parse_trace_type(struct marker_info *info,
- const char *fmt,
- char *trace_size, enum ltt_type *trace_type,
- unsigned long *attributes)
-{
- int qualifier; /* 'h', 'l', or 'L' for integer fields */
- /* 'z' support added 23/7/1999 S.H. */
- /* 'z' changed to 'Z' --davidm 1/25/99 */
- /* 't' added for ptrdiff_t */
-
- /* parse attributes. */
- repeat:
- switch (*fmt) {
- case 'n':
- *attributes |= LTT_ATTRIBUTE_NETWORK_BYTE_ORDER;
- ++fmt;
- goto repeat;
- }
-
- /* get the conversion qualifier */
- qualifier = -1;
- if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
- *fmt =='Z' || *fmt == 'z' || *fmt == 't' ||
- *fmt == 'S' || *fmt == '1' || *fmt == '2' ||
- *fmt == '4' || *fmt == '8') {
- qualifier = *fmt;
- ++fmt;
- if (qualifier == 'l' && *fmt == 'l') {
- qualifier = 'L';
- ++fmt;
- }
- }
-
- switch (*fmt) {
- case 'c':
- *trace_type = LTT_TYPE_UNSIGNED_INT;
- *trace_size = sizeof(char);
- goto parse_end;
- case 's':
- *trace_type = LTT_TYPE_STRING;
- goto parse_end;
- case 'p':
- *trace_type = LTT_TYPE_POINTER;
- *trace_size = info->pointer_size;
- goto parse_end;
- case 'd':
- case 'i':
- *trace_type = LTT_TYPE_SIGNED_INT;
- break;
- case 'o':
- case 'u':
- case 'x':
- case 'X':
- *trace_type = LTT_TYPE_UNSIGNED_INT;
- break;
- default:
- if (!*fmt)
- --fmt;
- goto parse_end;
- }
- switch (qualifier) {
- case 'L':
- *trace_size = sizeof(long long);
- break;
- case 'l':
- *trace_size = info->long_size;
- break;
- case 'Z':
- case 'z':
- *trace_size = info->size_t_size;
- break;
- case 't':
- *trace_size = info->pointer_size;
- break;
- case 'h':
- *trace_size = sizeof(short);
- break;
- case '1':
- *trace_size = sizeof(uint8_t);
- break;
- case '2':
- *trace_size = sizeof(guint16);
- break;
- case '4':
- *trace_size = sizeof(uint32_t);
- break;
- case '8':
- *trace_size = sizeof(uint64_t);
- break;
- default:
- *trace_size = info->int_size;
- }
-
-parse_end:
- return fmt;
-}
-
-/*
- * Restrictions:
- * Field width and precision are *not* supported.
- * %n not supported.
- */
-__attribute__((no_instrument_function))
-static inline const char *parse_c_type(struct marker_info *info,
- const char *fmt,
- char *c_size, enum ltt_type *c_type, GString *field_fmt)
-{
- int qualifier; /* 'h', 'l', or 'L' for integer fields */
- /* 'z' support added 23/7/1999 S.H. */
- /* 'z' changed to 'Z' --davidm 1/25/99 */
- /* 't' added for ptrdiff_t */
-
- /* process flags : ignore standard print formats for now. */
- repeat:
- switch (*fmt) {
- case '-':
- case '+':
- case ' ':
- case '#':
- case '0':
- g_string_append_c(field_fmt, *fmt);
- ++fmt;
- goto repeat;
- }
-
- /* get the conversion qualifier */
- qualifier = -1;
- if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' ||
- *fmt =='Z' || *fmt == 'z' || *fmt == 't' ||
- *fmt == 'S') {
- qualifier = *fmt;
- ++fmt;
- if (qualifier == 'l' && *fmt == 'l') {
- qualifier = 'L';
- ++fmt;
- }
- }
-
- switch (*fmt) {
- case 'c':
- *c_type = LTT_TYPE_UNSIGNED_INT;
- *c_size = sizeof(unsigned char);
- g_string_append_c(field_fmt, *fmt);
- goto parse_end;
- case 's':
- *c_type = LTT_TYPE_STRING;
- goto parse_end;
- case 'p':
- *c_type = LTT_TYPE_POINTER;
- *c_size = info->pointer_size;
- goto parse_end;
- case 'd':
- case 'i':
- *c_type = LTT_TYPE_SIGNED_INT;
- g_string_append_c(field_fmt, 'l');
- g_string_append_c(field_fmt, 'l');
- g_string_append_c(field_fmt, *fmt);
- break;
- case 'o':
- case 'u':
- case 'x':
- case 'X':
- g_string_append_c(field_fmt, 'l');
- g_string_append_c(field_fmt, 'l');
- g_string_append_c(field_fmt, *fmt);
- *c_type = LTT_TYPE_UNSIGNED_INT;
- break;
- default:
- if (!*fmt)
- --fmt;
- goto parse_end;
- }
- switch (qualifier) {
- case 'L':
- *c_size = sizeof(long long);
- break;
- case 'l':
- *c_size = info->long_size;
- break;
- case 'Z':
- case 'z':
- *c_size = info->size_t_size;
- break;
- case 't':
- *c_size = info->pointer_size;
- break;
- case 'h':
- *c_size = sizeof(short);
- break;
- default:
- *c_size = info->int_size;
- }
-
-parse_end:
- return fmt;
-}
-
-static inline long add_type(struct marker_info *info,
- long offset, const char *name,
- char trace_size, enum ltt_type trace_type,
- char c_size, enum ltt_type c_type, unsigned long attributes,
- unsigned int field_count, GString *field_fmt)
-{
- struct marker_field *field;
- char tmpname[MAX_NAME_LEN];
-
- info->fields = g_array_set_size(info->fields, info->fields->len+1);
- field = &g_array_index(info->fields, struct marker_field,
- info->fields->len-1);
- if (name)
- field->name = g_quark_from_string(name);
- else {
- snprintf(tmpname, MAX_NAME_LEN-1, "field %u", field_count);
- field->name = g_quark_from_string(tmpname);
- }
- field->type = trace_type;
- field->index = info->fields->len-1;
- field->fmt = g_string_new(field_fmt->str);
-
- switch (trace_type) {
- case LTT_TYPE_SIGNED_INT:
- case LTT_TYPE_UNSIGNED_INT:
- case LTT_TYPE_POINTER:
- field->_size = trace_size;
- field->alignment = trace_size;
- info->largest_align = max((guint8)field->alignment,
- (guint8)info->largest_align);
- field->attributes = attributes;
- if (offset == -1) {
- field->_offset = -1;
- field->static_offset = 0;
- return -1;
- } else {
- field->_offset = offset + ltt_align(offset, field->alignment,
- info->alignment);
- field->static_offset = 1;
- return field->_offset + trace_size;
- }
- case LTT_TYPE_STRING:
- field->_offset = offset;
- field->_size = 0; /* Variable length, size is 0 */
- field->alignment = 1;
- if (offset == -1)
- field->static_offset = 0;
- else
- field->static_offset = 1;
- return -1;
- default:
- g_error("Unexpected type");
- return 0;
- }
-}
-
-long marker_update_fields_offsets(struct marker_info *info, const char *data)
-{
- struct marker_field *field;
- unsigned int i;
- long offset = 0;
-
- /* Find the last field with a static offset, then update from there. */
- for (i = info->fields->len - 1; i >= 0; i--) {
- field = &g_array_index(info->fields, struct marker_field, i);
- if (field->static_offset) {
- offset = field->_offset;
- break;
- }
- }
-
- for (; i < info->fields->len; i++) {
- field = &g_array_index(info->fields, struct marker_field, i);
-
- switch (field->type) {
- case LTT_TYPE_SIGNED_INT:
- case LTT_TYPE_UNSIGNED_INT:
- case LTT_TYPE_POINTER:
- field->_offset = offset + ltt_align(offset, field->alignment,
- info->alignment);
- offset = field->_offset + field->_size;
- break;
- case LTT_TYPE_STRING:
- field->_offset = offset;
- offset = offset + strlen(&data[offset]) + 1;
- // not aligning on pointer size, breaking genevent backward compatibility.
- break;
- default:
- g_error("Unexpected type");
- return -1;
- }
- }
- return offset;
-}
-
-void marker_update_event_fields_offsets(GArray *fields_offsets,
- struct marker_info *info)
-{
- unsigned int i;
-
- g_array_set_size(fields_offsets, info->fields->len);
- for (i = 0; i < info->fields->len; i++) {
- struct marker_field *mfield =
- &g_array_index(info->fields, struct marker_field, i);
- struct LttField *eventfield =
- &g_array_index(fields_offsets, struct LttField, i);
- eventfield->offset = mfield->_offset;
- eventfield->size = mfield->_size;
- g_assert(eventfield->offset != -1);
- g_assert(eventfield->size != -1);
- }
-}
-
-static void format_parse(const char *fmt, struct marker_info *info)
-{
- char trace_size = 0, c_size = 0; /*
- * 0 (unset), 1, 2, 4, 8 bytes.
- */
- enum ltt_type trace_type = LTT_TYPE_NONE, c_type = LTT_TYPE_NONE;
- unsigned long attributes = 0;
- long offset = 0;
- const char *name_begin = NULL, *name_end = NULL;
- char *name = NULL;
- unsigned int field_count = 1;
- GString *field_fmt = g_string_new("");
-
- name_begin = fmt;
- for (; *fmt ; ++fmt) {
- switch (*fmt) {
- case '#':
- /* tracetypes (#) */
- ++fmt; /* skip first '#' */
- if (*fmt == '#') { /* Escaped ## */
- g_string_append_c(field_fmt, *fmt);
- g_string_append_c(field_fmt, *fmt);
- break;
- }
- attributes = 0;
- fmt = parse_trace_type(info, fmt, &trace_size, &trace_type,
- &attributes);
- break;
- case '%':
- /* c types (%) */
- g_string_append_c(field_fmt, *fmt);
- ++fmt; /* skip first '%' */
- if (*fmt == '%') { /* Escaped %% */
- g_string_append_c(field_fmt, *fmt);
- break;
- }
- fmt = parse_c_type(info, fmt, &c_size, &c_type, field_fmt);
- /*
- * Output c types if no trace types has been
- * specified.
- */
- if (!trace_size)
- trace_size = c_size;
- if (trace_type == LTT_TYPE_NONE)
- trace_type = c_type;
- if (c_type == LTT_TYPE_STRING)
- trace_type = LTT_TYPE_STRING;
- /* perform trace write */
- offset = add_type(info, offset, name, trace_size,
- trace_type, c_size, c_type, attributes, field_count++,
- field_fmt);
- trace_size = c_size = 0;
- trace_type = c_size = LTT_TYPE_NONE;
- g_string_truncate(field_fmt, 0);
- attributes = 0;
- name_begin = NULL;
- if (name) {
- g_free(name);
- name = NULL;
- }
- break;
- case ' ':
- g_string_truncate(field_fmt, 0);
- if (!name_end && name_begin) {
- name_end = fmt;
- if (name)
- g_free(name);
- name = g_new(char, name_end - name_begin + 1);
- memcpy(name, name_begin, name_end - name_begin);
- name[name_end - name_begin] = '\0';
- }
- break; /* Skip white spaces */
- default:
- g_string_append_c(field_fmt, *fmt);
- if (!name_begin) {
- name_begin = fmt;
- name_end = NULL;
- }
- }
- }
- info->size = offset;
- if (name)
- g_free(name);
- g_string_free(field_fmt, TRUE);
-}
-
-int marker_parse_format(const char *format, struct marker_info *info)
-{
- if (info->fields)
- g_array_free(info->fields, TRUE);
- info->fields = g_array_sized_new(FALSE, TRUE,
- sizeof(struct marker_field), DEFAULT_FIELDS_NUM);
- format_parse(format, info);
- return 0;
-}
-
-int marker_format_event(LttTrace *trace, GQuark channel, GQuark name,
- const char *format)
-{
- struct marker_info *info;
- struct marker_data *mdata;
- char *fquery;
- char *fcopy;
- GArray *group;
-
- group = g_datalist_id_get_data(&trace->tracefiles, channel);
- if (!group)
- return -ENOENT;
- g_assert(group->len > 0);
- mdata = g_array_index (group, LttTracefile, 0).mdata;
-
- fquery = marker_get_format_from_name(mdata, name);
- if (fquery) {
- if (strcmp(fquery, format) != 0)
- g_error("Marker format mismatch \"%s\" vs \"%s\" for marker %s.%s. "
- "Kernel issue.", fquery, format,
- g_quark_to_string(channel), g_quark_to_string(name));
- else
- return 0; /* Already exists. Nothing to do. */
- }
- fcopy = g_new(char, strlen(format)+1);
- strcpy(fcopy, format);
- g_hash_table_insert(mdata->markers_format_hash, (gpointer)(gulong)name,
- (gpointer)fcopy);
-
- info = marker_get_info_from_name(mdata, name);
- for (; info != NULL; info = info->next) {
- info->format = fcopy;
- if (marker_parse_format(format, info))
- g_error("Error parsing marker format \"%s\" for marker \"%.s.%s\"",
- format, g_quark_to_string(channel), g_quark_to_string(name));
- }
- return 0;
-}
-
-int marker_id_event(LttTrace *trace, GQuark channel, GQuark name, guint16 id,
- uint8_t int_size, uint8_t long_size, uint8_t pointer_size,
- uint8_t size_t_size, uint8_t alignment)
-{
- struct marker_data *mdata;
- struct marker_info *info, *head;
- int found = 0;
- GArray *group;
-
- g_debug("Add channel %s event %s %hu\n", g_quark_to_string(channel),
- g_quark_to_string(name), id);
-
- group = g_datalist_id_get_data(&trace->tracefiles, channel);
- if (!group)
- return -ENOENT;
- g_assert(group->len > 0);
- mdata = g_array_index (group, LttTracefile, 0).mdata;
-
- if (mdata->markers->len <= id)
- mdata->markers = g_array_set_size(mdata->markers,
- max(mdata->markers->len * 2, id + 1));
- info = &g_array_index(mdata->markers, struct marker_info, id);
- info->name = name;
- info->int_size = int_size;
- info->long_size = long_size;
- info->pointer_size = pointer_size;
- info->size_t_size = size_t_size;
- info->alignment = alignment;
- info->fields = NULL;
- info->next = NULL;
- info->format = marker_get_format_from_name(mdata, name);
- info->largest_align = 1;
- if (info->format && marker_parse_format(info->format, info))
- g_error("Error parsing marker format \"%s\" for marker \"%s.%s\"",
- info->format, g_quark_to_string(channel), g_quark_to_string(name));
- head = marker_get_info_from_name(mdata, name);
- if (!head)
- g_hash_table_insert(mdata->markers_hash, (gpointer)(gulong)name,
- (gpointer)(gulong)id);
- else {
- struct marker_info *iter;
- for (iter = head; iter != NULL; iter = iter->next)
- if (iter->name == name)
- found = 1;
- if (!found) {
- g_hash_table_replace(mdata->markers_hash, (gpointer)(gulong)name,
- (gpointer)(gulong)id);
- info->next = head;
- }
- }
- return 0;
-}
-
-struct marker_data *allocate_marker_data(void)
-{
- struct marker_data *data;
-
- data = g_new(struct marker_data, 1);
- /* Init array to 0 */
- data->markers = g_array_sized_new(FALSE, TRUE,
- sizeof(struct marker_info), DEFAULT_MARKERS_NUM);
- if (!data->markers)
- goto free_data;
- data->markers_hash = g_hash_table_new(g_direct_hash, g_direct_equal);
- if (!data->markers_hash)
- goto free_markers;
- data->markers_format_hash = g_hash_table_new_full(g_direct_hash,
- g_direct_equal, NULL, g_free);
- if (!data->markers_format_hash)
- goto free_markers_hash;
- return data;
-
- /* error handling */
-free_markers_hash:
- g_hash_table_destroy(data->markers_hash);
-free_markers:
- g_array_free(data->markers, TRUE);
-free_data:
- g_free(data);
- return NULL;
-}
-
-void destroy_marker_data(struct marker_data *data)
-{
- unsigned int i, j;
- struct marker_info *info;
- struct marker_field *field;
-
- for (i=0; i<data->markers->len; i++) {
- info = &g_array_index(data->markers, struct marker_info, i);
- if (info->fields) {
- for (j = 0; j < info->fields->len; j++) {
- field = &g_array_index(info->fields, struct marker_field, j);
- g_string_free(field->fmt, TRUE);
- }
- g_array_free(info->fields, TRUE);
- }
- }
- g_hash_table_destroy(data->markers_format_hash);
- g_hash_table_destroy(data->markers_hash);
- g_array_free(data->markers, TRUE);
- g_free(data);
-}
+++ /dev/null
-#ifndef _LTT_MARKERS_H
-#define _LTT_MARKERS_H
-
-/*
- * Marker support header.
- *
- * Mathieu Desnoyers, August 2007
- * License: LGPL.
- */
-
-#include <glib.h>
-#include <ltt/trace.h>
-#include <ltt/compiler.h>
-#include <ltt/marker-field.h>
-#include <ltt/trace.h>
-
-#define LTT_ATTRIBUTE_NETWORK_BYTE_ORDER (1<<1)
-
-/* static ids 0-7 reserved for internal use. */
-#define MARKER_CORE_IDS 8
-
-struct marker_info;
-
-struct marker_info {
- GQuark name;
- char *format;
- long size; /* size if known statically, else -1 */
- guint8 largest_align; /* Size of the largest alignment needed in the
- payload. */
- GArray *fields; /* Array of struct marker_field */
- guint8 int_size, long_size, pointer_size, size_t_size;
- guint8 alignment; /* Size on which the architecture alignment must be
- done. Useful to encapsulate x86_32 events on
- x86_64 kernels. */
- struct marker_info *next; /* Linked list of markers with the same name */
-};
-
-struct marker_data {
- GArray *markers; //indexed by marker id
- GHashTable *markers_hash; //indexed by name hash
- GHashTable *markers_format_hash; //indexed by name hash
-};
-
-enum marker_id {
- MARKER_ID_SET_MARKER_ID = 0, /* Static IDs available (range 0-7) */
- MARKER_ID_SET_MARKER_FORMAT,
-};
-
-static inline guint16 marker_get_id_from_info(struct marker_data *data,
- struct marker_info *info)
-{
- return ((unsigned long)info - (unsigned long)data->markers->data)
- / sizeof(struct marker_info);
-}
-
-static inline struct marker_info *marker_get_info_from_id(
- struct marker_data *data, guint16 id)
-{
- if (unlikely(data->markers->len <= id))
- return NULL;
- return &g_array_index(data->markers, struct marker_info, id);
-}
-
-/*
- * Returns the head of the marker info list for that name.
- */
-static inline struct marker_info *marker_get_info_from_name(
- struct marker_data *data, GQuark name)
-{
- gpointer orig_key, value;
- int res;
-
- res = g_hash_table_lookup_extended(data->markers_hash,
- (gconstpointer)(gulong)name, &orig_key, &value);
- if (!res)
- return NULL;
- return marker_get_info_from_id(data, (guint16)(gulong)value);
-}
-
-static inline char *marker_get_format_from_name(struct marker_data *data,
- GQuark name)
-{
- gpointer orig_key, value;
- int res;
-
- res = g_hash_table_lookup_extended(data->markers_format_hash,
- (gconstpointer)(gulong)name, &orig_key, &value);
- if (!res)
- return NULL;
- return (char *)value;
-}
-
-static inline struct marker_field *marker_get_field(struct marker_info *info,
- guint i)
-{
- return &g_array_index(info->fields, struct marker_field, i);
-}
-
-static inline unsigned int marker_get_num_fields(struct marker_info *info)
-{
- return info->fields->len;
-}
-
-/*
- * for_each_marker_field - iterate over fields of a marker
- * @field: struct marker_field * to use as iterator
- * @info: marker info pointer
- */
-#define for_each_marker_field(field, info) \
- for (field = marker_get_field(info, 0); \
- field != marker_get_field(info, marker_get_num_fields(info)); \
- field++)
-
-int marker_format_event(LttTrace *trace, GQuark channel, GQuark name,
- const char *format);
-int marker_id_event(LttTrace *trace, GQuark channel, GQuark name, guint16 id,
- uint8_t int_size, uint8_t long_size, uint8_t pointer_size,
- uint8_t size_t_size, uint8_t alignment);
-struct marker_data *allocate_marker_data(void);
-void destroy_marker_data(struct marker_data *data);
-
-#endif //_LTT_MARKERS_H
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit trace reading library
- * Copyright (C) 2003-2004 Michel Dagenais
- * 2005 Mathieu Desnoyers
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef LTT_TIME_H
-#define LTT_TIME_H
-
-#include <glib.h>
-#include <lttv/compiler.h>
-#include <math.h>
-
-typedef struct _LttTime {
- unsigned long tv_sec;
- unsigned long tv_nsec;
-} LttTime;
-
-
-#define NANOSECONDS_PER_SECOND 1000000000
-
-/* We give the DIV and MUL constants so we can always multiply, for a
- * division as well as a multiplication of NANOSECONDS_PER_SECOND */
-/* 2^30/1.07374182400631629848 = 1000000000.0 */
-#define DOUBLE_SHIFT_CONST_DIV 1.07374182400631629848
-#define DOUBLE_SHIFT 30
-
-/* 2^30*0.93132257461547851562 = 1000000000.0000000000 */
-#define DOUBLE_SHIFT_CONST_MUL 0.93132257461547851562
-
-
-/* 1953125 * 2^9 = NANOSECONDS_PER_SECOND */
-#define LTT_TIME_UINT_SHIFT_CONST 1953125
-#define LTT_TIME_UINT_SHIFT 9
-
-
-static const LttTime ltt_time_zero = { 0, 0 };
-
-static const LttTime ltt_time_one = { 0, 1 };
-
-static const LttTime ltt_time_infinite = { G_MAXUINT, NANOSECONDS_PER_SECOND };
-
-static inline LttTime ltt_time_sub(LttTime t1, LttTime t2)
-{
- LttTime res;
- res.tv_sec = t1.tv_sec - t2.tv_sec;
- res.tv_nsec = t1.tv_nsec - t2.tv_nsec;
- /* unlikely : given equal chance to be anywhere in t1.tv_nsec, and
- * higher probability of low value for t2.tv_sec, we will habitually
- * not wrap.
- */
- if(unlikely(t1.tv_nsec < t2.tv_nsec)) {
- res.tv_sec--;
- res.tv_nsec += NANOSECONDS_PER_SECOND;
- }
- return res;
-}
-
-
-static inline LttTime ltt_time_add(LttTime t1, LttTime t2)
-{
- LttTime res;
- res.tv_nsec = t1.tv_nsec + t2.tv_nsec;
- res.tv_sec = t1.tv_sec + t2.tv_sec;
- /* unlikely : given equal chance to be anywhere in t1.tv_nsec, and
- * higher probability of low value for t2.tv_sec, we will habitually
- * not wrap.
- */
- if(unlikely(res.tv_nsec >= NANOSECONDS_PER_SECOND)) {
- res.tv_sec++;
- res.tv_nsec -= NANOSECONDS_PER_SECOND;
- }
- return res;
-}
-
-/* Fastest comparison : t1 > t2 */
-static inline int ltt_time_compare(LttTime t1, LttTime t2)
-{
- int ret=0;
- if(likely(t1.tv_sec > t2.tv_sec)) ret = 1;
- else if(unlikely(t1.tv_sec < t2.tv_sec)) ret = -1;
- else if(likely(t1.tv_nsec > t2.tv_nsec)) ret = 1;
- else if(unlikely(t1.tv_nsec < t2.tv_nsec)) ret = -1;
-
- return ret;
-}
-
-#define LTT_TIME_MIN(a,b) ((ltt_time_compare((a),(b)) < 0) ? (a) : (b))
-#define LTT_TIME_MAX(a,b) ((ltt_time_compare((a),(b)) > 0) ? (a) : (b))
-
-#define MAX_TV_SEC_TO_DOUBLE 0x7FFFFF
-static inline double ltt_time_to_double(LttTime t1)
-{
- /* We lose precision if tv_sec is > than (2^23)-1
- *
- * Max values that fits in a double (53 bits precision on normalised
- * mantissa):
- * tv_nsec : NANOSECONDS_PER_SECONDS : 2^30
- *
- * So we have 53-30 = 23 bits left for tv_sec.
- * */
-#ifdef EXTRA_CHECK
- g_assert(t1.tv_sec <= MAX_TV_SEC_TO_DOUBLE);
- if(t1.tv_sec > MAX_TV_SEC_TO_DOUBLE)
- g_warning("Precision loss in conversion LttTime to double");
-#endif //EXTRA_CHECK
- return ((double)((guint64)t1.tv_sec<<DOUBLE_SHIFT)
- * (double)DOUBLE_SHIFT_CONST_MUL)
- + (double)t1.tv_nsec;
-}
-
-
-static inline LttTime ltt_time_from_double(double t1)
-{
- /* We lose precision if tv_sec is > than (2^23)-1
- *
- * Max values that fits in a double (53 bits precision on normalised
- * mantissa):
- * tv_nsec : NANOSECONDS_PER_SECONDS : 2^30
- *
- * So we have 53-30 = 23 bits left for tv_sec.
- * */
-#ifdef EXTRA_CHECK
- g_assert(t1 <= MAX_TV_SEC_TO_DOUBLE);
- if(t1 > MAX_TV_SEC_TO_DOUBLE)
- g_warning("Conversion from non precise double to LttTime");
-#endif //EXTRA_CHECK
- LttTime res;
- //res.tv_sec = t1/(double)NANOSECONDS_PER_SECOND;
- res.tv_sec = (guint64)(t1 * DOUBLE_SHIFT_CONST_DIV) >> DOUBLE_SHIFT;
- res.tv_nsec = (t1 - (((guint64)res.tv_sec<<LTT_TIME_UINT_SHIFT))
- * LTT_TIME_UINT_SHIFT_CONST);
- return res;
-}
-
-/* Use ltt_time_to_double and ltt_time_from_double to check for lack
- * of precision.
- */
-static inline LttTime ltt_time_mul(LttTime t1, double d)
-{
- LttTime res;
-
- double time_double = ltt_time_to_double(t1);
-
- time_double = time_double * d;
-
- res = ltt_time_from_double(time_double);
-
- return res;
-
-#if 0
- /* What is that ? (Mathieu) */
- if(f == 0.0){
- res.tv_sec = 0;
- res.tv_nsec = 0;
- }else{
- double d;
- d = 1.0/f;
- sec = t1.tv_sec / (double)d;
- res.tv_sec = sec;
- res.tv_nsec = t1.tv_nsec / (double)d + (sec - res.tv_sec) *
- NANOSECONDS_PER_SECOND;
- res.tv_sec += res.tv_nsec / NANOSECONDS_PER_SECOND;
- res.tv_nsec %= NANOSECONDS_PER_SECOND;
- }
- return res;
-#endif //0
-}
-
-
-/* Use ltt_time_to_double and ltt_time_from_double to check for lack
- * of precision.
- */
-static inline LttTime ltt_time_div(LttTime t1, double d)
-{
- LttTime res;
-
- double time_double = ltt_time_to_double(t1);
-
- time_double = time_double / d;
-
- res = ltt_time_from_double(time_double);
-
- return res;
-
-
-#if 0
- double sec;
- LttTime res;
-
- sec = t1.tv_sec / (double)f;
- res.tv_sec = sec;
- res.tv_nsec = t1.tv_nsec / (double)f + (sec - res.tv_sec) *
- NANOSECONDS_PER_SECOND;
- res.tv_sec += res.tv_nsec / NANOSECONDS_PER_SECOND;
- res.tv_nsec %= NANOSECONDS_PER_SECOND;
- return res;
-#endif //0
-}
-
-
-static inline guint64 ltt_time_to_uint64(LttTime t1)
-{
- return (((guint64)t1.tv_sec*LTT_TIME_UINT_SHIFT_CONST) << LTT_TIME_UINT_SHIFT)
- + (guint64)t1.tv_nsec;
-}
-
-
-#define MAX_TV_SEC_TO_UINT64 0x3FFFFFFFFFFFFFFFULL
-
-/* The likely branch is with sec != 0, because most events in a bloc
- * will be over 1s from the block start. (see tracefile.c)
- */
-static inline LttTime ltt_time_from_uint64(guint64 t1)
-{
- /* We lose precision if tv_sec is > than (2^62)-1
- * */
-#ifdef EXTRA_CHECK
- g_assert(t1 <= MAX_TV_SEC_TO_UINT64);
- if(t1 > MAX_TV_SEC_TO_UINT64)
- g_warning("Conversion from uint64 to non precise LttTime");
-#endif //EXTRA_CHECK
- LttTime res;
- //if(unlikely(t1 >= NANOSECONDS_PER_SECOND)) {
- if(likely(t1>>LTT_TIME_UINT_SHIFT >= LTT_TIME_UINT_SHIFT_CONST)) {
- //res.tv_sec = t1/NANOSECONDS_PER_SECOND;
- res.tv_sec = (t1>>LTT_TIME_UINT_SHIFT)
- /LTT_TIME_UINT_SHIFT_CONST; // acceleration
- res.tv_nsec = (t1 - res.tv_sec*NANOSECONDS_PER_SECOND);
- } else {
- res.tv_sec = 0;
- res.tv_nsec = (guint32)t1;
- }
- return res;
-}
-
-#endif // LTT_TIME_H
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit trace reading library
- * Copyright (C) 2003-2004 Michel Dagenais
- * 2005 Mathieu Desnoyers
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef TRACE_H
-#define TRACE_H
-
-#include <ltt/ltt.h>
-#include <ltt/ltt-private.h>
-#include <stdint.h>
-#include <glib.h>
-
-struct LttTrace {
- GQuark pathname; //the pathname of the trace
- //LttSystemDescription * system_description;//system description
-
- guint num_cpu;
-
- guint32 arch_type;
- guint32 arch_variant;
- guint8 arch_size;
- guint8 ltt_major_version;
- guint8 ltt_minor_version;
- guint8 flight_recorder;
- guint32 freq_scale;
- uint64_t start_freq;
- uint64_t start_tsc;
- uint64_t start_monotonic;
- double drift;
- double offset;
- LttTime start_time;
- LttTime start_time_from_tsc;
- gboolean is_live; /* Flag indicating that read trace is currently being recorded */
- LttTime live_safe_timestamp; /* In a live trace, timestamp were all data should be readable */
-
- GData *tracefiles; /*tracefiles groups*/
-};
-
-static inline guint ltt_trace_get_num_cpu(LttTrace *t)
-{
- return t->num_cpu;
-}
-
-/* A trace is specified as a pathname to the directory containing all the
- associated data (control tracefiles, per cpu tracefiles, event
- descriptions...).
-
- When a trace is closed, all the associated facilities, types and fields
- are released as well.
-
- return value is NULL if there is an error when opening the trace.
-
- */
-
-LttTrace *ltt_trace_open(const gchar *pathname);
-
-/* Same as ltt_trace_open but open the trace in live mode */
-LttTrace *ltt_trace_open_live(const gchar *pathname);
-
-
-/* copy reopens a trace
- *
- * return value NULL if error while opening the trace
- */
-LttTrace *ltt_trace_copy(LttTrace *self);
-
-static inline GQuark ltt_trace_name(const LttTrace *t)
-{
- return t->pathname;
-}
-/* Update the informations concerning a trace, normally a live one */
-int ltt_trace_update(LttTrace *trace);
-
-void ltt_trace_close(LttTrace *t);
-
-LttSystemDescription *ltt_trace_system_description(LttTrace *t);
-
-
-/* Get the start time and end time of the trace */
-
-void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end);
-
-
-/* Get the name of a tracefile */
-
-static inline GQuark ltt_tracefile_name(const LttTracefile *tf)
-{
- return tf->name;
-}
-
-static inline GQuark ltt_tracefile_long_name(const LttTracefile *tf)
-{
- return tf->long_name;
-}
-
-/* get the cpu number of the tracefile */
-
-static inline guint ltt_tracefile_cpu(LttTracefile *tf)
-{
- return tf->cpu_num;
-}
-
-/* For usertrace */
-static inline guint ltt_tracefile_tid(LttTracefile *tf)
-{
- return tf->tid;
-}
-
-static inline guint ltt_tracefile_pgid(LttTracefile *tf)
-{
- return tf->pgid;
-}
-
-static inline guint64 ltt_tracefile_creation(LttTracefile *tf)
-{
- return tf->creation;
-}
-
-static inline LttTrace *ltt_tracefile_get_trace(LttTracefile *tf)
-{
- return tf->trace;
-}
-
-/* Get the number of blocks in the tracefile */
-
-static inline guint ltt_tracefile_block_number(LttTracefile *tf)
-{
- return tf->num_blocks;
-}
-
-
-/* Seek to the first event of the trace with time larger or equal to time */
-
-int ltt_tracefile_seek_time(LttTracefile *t, LttTime time);
-
-
-int ltt_tracefile_get_current_position(const LttTracefile *tf, LttEventPosition *ep);
-
-/* Seek to the first event with position equal or larger to ep */
-
-int ltt_tracefile_seek_position(LttTracefile *t,
- const LttEventPosition *ep);
-
-/* Read the next event */
-
-int ltt_tracefile_read(LttTracefile *t);
-
-/* ltt_tracefile_read cut down in pieces */
-int ltt_tracefile_read_seek(LttTracefile *t);
-int ltt_tracefile_read_update_event(LttTracefile *t);
-int ltt_tracefile_read_op(LttTracefile *t);
-
-/* Get the current event of the tracefile : valid until the next read */
-LttEvent *ltt_tracefile_get_event(LttTracefile *tf);
-
-/* get the data type size and endian type of the local machine */
-
-void getDataEndianType(LttArchSize * size, LttArchEndian * endian);
-
-/* get an integer number */
-gint64 get_int(gboolean reverse_byte_order, gint size, void *data);
-
-/* get the node name of the system */
-
-gchar * ltt_trace_system_description_node_name (LttSystemDescription * s);
-
-
-/* get the domain name of the system */
-
-gchar * ltt_trace_system_description_domain_name (LttSystemDescription * s);
-
-
-/* get the description of the system */
-
-gchar * ltt_trace_system_description_description (LttSystemDescription * s);
-
-
-/* get the NTP start time of the trace */
-
-LttTime ltt_trace_start_time(LttTrace *t);
-
-/* get the monotonic start time of the trace */
-
-LttTime ltt_trace_start_time_monotonic(LttTrace *t);
-
-void get_absolute_pathname(const gchar *pathname, gchar * abs_pathname);
-
-/* May return a NULL tracefile group */
-GData **ltt_trace_get_tracefiles_groups(LttTrace *trace);
-
-typedef void (*ForEachTraceFileFunc)(LttTracefile *tf, gpointer func_args);
-
-struct compute_tracefile_group_args {
- ForEachTraceFileFunc func;
- gpointer func_args;
-};
-
-void compute_tracefile_group(GQuark key_id,
- GArray *group,
- struct compute_tracefile_group_args *args);
-
-
-gint64 ltt_get_int(gboolean reverse_byte_order, gint size, void *data);
-
-guint64 ltt_get_uint(gboolean reverse_byte_order, gint size, void *data);
-
-guint64 tsc_to_uint64(guint32 freq_scale, uint64_t start_freq, guint64 tsc);
-
-LttTime ltt_interpolate_time_from_tsc(LttTracefile *tf, guint64 tsc);
-
-/* Set to enable event debugging output */
-void ltt_event_debug(int state);
-
-/* A structure representing the version number of the trace */
-struct LttTraceVersion {
- guint8 ltt_major_version;
- guint8 ltt_minor_version;
-};
-
-/* To get the version number of a trace */
-int ltt_get_trace_version(const gchar *pathname, struct LttTraceVersion * version_number);
-
-#endif // TRACE_H
+++ /dev/null
-/* This file is part of the Linux Trace Toolkit viewer
- * Copyright (C) 2005 Mathieu Desnoyers
- *
- * Complete rewrite from the original version made by XangXiu Yang.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License Version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <string.h>
-#include <dirent.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <unistd.h>
-#include <math.h>
-#include <glib.h>
-#include <glib/gprintf.h>
-#include <malloc.h>
-#include <sys/mman.h>
-#include <string.h>
-#include <ctype.h>
-#include <inttypes.h>
-
-// For realpath
-#include <limits.h>
-#include <stdlib.h>
-
-
-#include <ltt/ltt.h>
-#include "ltt-private.h"
-#include <ltt/trace.h>
-#include <ltt/event.h>
-#include <ltt/ltt-types.h>
-#include <ltt/marker.h>
-
-#define DEFAULT_N_BLOCKS 32
-
-/* from marker.c */
-extern long marker_update_fields_offsets(struct marker_info *info, const char *data);
-extern void marker_update_event_fields_offsets(GArray *fields_offsets,
- struct marker_info *info);
-
-/* Tracefile names used in this file */
-
-GQuark LTT_TRACEFILE_NAME_METADATA;
-
-#ifndef g_open
-#define g_open open
-#endif
-
-
-#define __UNUSED__ __attribute__((__unused__))
-
-#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
-
-#ifndef g_debug
-#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
-#endif
-
-#define g_close close
-
-/* Those macros must be called from within a function where page_size is a known
- * variable */
-#define PAGE_MASK (~(page_size-1))
-#define PAGE_ALIGN(addr) (((addr)+page_size-1)&PAGE_MASK)
-
-/* set the offset of the fields belonging to the event,
- need the information of the archecture */
-//void set_fields_offsets(LttTracefile *tf, LttEventType *event_type);
-//size_t get_fields_offsets(LttTracefile *tf, LttEventType *event_type, void *data);
-
-/* map a fixed size or a block information from the file (fd) */
-static gint map_block(LttTracefile * tf, guint block_num);
-
-/* calculate nsec per cycles for current block */
-#if 0
-static guint32 calc_nsecs_per_cycle(LttTracefile * t);
-static guint64 cycles_2_ns(LttTracefile *tf, guint64 cycles);
-#endif //0
-
-/* go to the next event */
-static int ltt_seek_next_event(LttTracefile *tf);
-
-static int open_tracefiles(LttTrace *trace, gchar *root_path,
- gchar *relative_path);
-static int ltt_process_metadata_tracefile(LttTracefile *tf);
-static void ltt_tracefile_time_span_get(LttTracefile *tf,
- LttTime *start, LttTime *end);
-static void group_time_span_get(GQuark name, gpointer data, gpointer user_data);
-static gint map_block(LttTracefile * tf, guint block_num);
-static void ltt_update_event_size(LttTracefile *tf);
-static LttTrace *_ltt_trace_open(const gchar *pathname, gboolean is_live);
-static int ltt_tracefile_update(LttTracefile *tf);
-static void update_tracefile_group(GQuark name, gpointer data, gpointer user_data);
-
-/* Enable event debugging */
-static int a_event_debug = 0;
-
-void ltt_event_debug(int state)
-{
- a_event_debug = state;
-}
-
-/* trace can be NULL
- *
- * Return value : 0 success, 1 bad tracefile
- */
-static int parse_trace_header(ltt_subbuffer_header_t *header,
- LttTracefile *tf, LttTrace *t)
-{
- if (header->magic_number == LTT_MAGIC_NUMBER)
- tf->reverse_bo = 0;
- else if(header->magic_number == LTT_REV_MAGIC_NUMBER)
- tf->reverse_bo = 1;
- else /* invalid magic number, bad tracefile ! */
- return 1;
-
- if(t) {
- t->ltt_major_version = header->major_version;
- t->ltt_minor_version = header->minor_version;
- t->arch_size = header->arch_size;
- }
- tf->alignment = header->alignment;
-
- /* Get float byte order : might be different from int byte order
- * (or is set to 0 if the trace has no float (kernel trace)) */
- tf->float_word_order = 0;
-
- switch(header->major_version) {
- case 0:
- case 1:
- g_warning("Unsupported trace version : %hhu.%hhu",
- header->major_version, header->minor_version);
- return 1;
- break;
- case 2:
- switch(header->minor_version) {
- case 6:
- {
- struct ltt_subbuffer_header_2_6 *vheader = header;
- tf->buffer_header_size = ltt_subbuffer_header_size();
- tf->tscbits = 27;
- tf->eventbits = 5;
- tf->tsc_mask = ((1ULL << tf->tscbits) - 1);
- tf->tsc_mask_next_bit = (1ULL << tf->tscbits);
-
- if(t) {
- t->start_freq = ltt_get_uint64(LTT_GET_BO(tf),
- &vheader->start_freq);
- t->freq_scale = ltt_get_uint32(LTT_GET_BO(tf),
- &vheader->freq_scale);
- t->start_tsc = ltt_get_uint64(LTT_GET_BO(tf),
- &vheader->cycle_count_begin);
- t->start_monotonic = 0;
- t->start_time.tv_sec = ltt_get_uint64(LTT_GET_BO(tf),
- &vheader->start_time_sec);
- t->start_time.tv_nsec = ltt_get_uint64(LTT_GET_BO(tf),
- &vheader->start_time_usec);
- t->start_time.tv_nsec *= 1000; /* microsec to nanosec */
-
- t->start_time_from_tsc =
- ltt_time_from_uint64(tsc_to_uint64(t->freq_scale,
- t->start_freq, t->start_tsc));
- }
- }
- break;
- default:
- g_warning("Unsupported trace version : %hhu.%hhu",
- header->major_version, header->minor_version);
- return 1;
- }
- break;
- default:
- g_warning("Unsupported trace version : %hhu.%hhu",
- header->major_version, header->minor_version);
- return 1;
- }
- return 0;
-}
-
-int get_block_offset_size(LttTracefile *tf, guint block_num,
- uint64_t *offset, uint32_t *size)
-{
- uint64_t offa, offb;
-
- if (unlikely(block_num >= tf->num_blocks))
- return -1;
-
- offa = g_array_index(tf->buf_index, uint64_t, block_num);
- if (likely(block_num < tf->num_blocks - 1))
- offb = g_array_index(tf->buf_index, uint64_t, block_num + 1);
- else
- offb = tf->file_size;
- *offset = offa;
- *size = offb - offa;
- return 0;
-}
-
-static int ltt_trace_update_block_index(LttTracefile *tf, uint64_t offset,
- unsigned long firstBlock)
-{
- int i = firstBlock;
- int page_size = getpagesize();
- unsigned int header_map_size = PAGE_ALIGN(ltt_subbuffer_header_size());
-
- g_assert(tf->buf_index->len == i);
- while (offset < tf->file_size) {
- ltt_subbuffer_header_t *header;
- uint64_t *off;
- uint64_t size;
-
- /* map block header */
- header = mmap(0, header_map_size, PROT_READ,
- MAP_PRIVATE, tf->fd, (off_t)offset);
- if(header == MAP_FAILED) {
- perror("Error in allocating memory for buffer of tracefile");
- return -1;
- }
-
- /* read len, offset += len */
- size = ltt_get_uint32(LTT_GET_BO(tf), &header->sb_size);
-
- /* Only index completly writen blocks */
- if (offset + size <= tf->file_size) {
-
- tf->buf_index = g_array_set_size(tf->buf_index, i + 1);
- off = &g_array_index(tf->buf_index, uint64_t, i);
- *off = offset;
-
- /* Store current buffer end cycle as the last file timestamp */
- /* TODO ybrosseau 2010-11-04: Might want to convert it to a LttTime */
- tf->end_timestamp = ltt_get_uint64(LTT_GET_BO(tf),
- &header->cycle_count_end);
-
- ++i;
- }
- offset += size;
- /* unmap block header */
- if(munmap(header, header_map_size)) {
- g_warning("unmap size : %u\n", header_map_size);
- perror("munmap error");
- return -1;
- }
- }
- tf->num_blocks = i;
-
- return 0;
-}
-
-/* parse the new information from the file and reajust the number of blocks.
- *
- * Return value : 0 success, -1 error
- */
-int ltt_trace_continue_block_index(LttTracefile *tf)
-{
- int ret;
- uint64_t offset;
- uint32_t last_block_size;
- unsigned long i = tf->num_blocks;
- int page_size = getpagesize();
- unsigned int header_map_size = PAGE_ALIGN(ltt_subbuffer_header_size());
-
- get_block_offset_size(tf, tf->num_blocks-1, &offset, &last_block_size);
-
- ltt_subbuffer_header_t *header_tmp = mmap(0, header_map_size, PROT_READ,
- MAP_PRIVATE, tf->fd, (off_t)offset);
- if(header_tmp == MAP_FAILED) {
- perror("Error in allocating memory for buffer of tracefile");
- return -1;
- }
-
- /* read len, offset += len */
- offset += ltt_get_uint32(LTT_GET_BO(tf), &header_tmp->sb_size);
-
- ret = ltt_trace_update_block_index(tf, offset, i);
-
- return ret;
-}
-
-int ltt_trace_create_block_index(LttTracefile *tf)
-{
- int ret;
- uint64_t offset = 0;
- unsigned long i = 0;
-
- tf->buf_index = g_array_sized_new(FALSE, TRUE, sizeof(uint64_t),
- DEFAULT_N_BLOCKS);
- if(!tf->buf_index)
- return -1;
- ret = ltt_trace_update_block_index(tf, offset, i);
- return ret;
-}
-
-/*
- Read file header and initialise buffer indexes
-
- Return value : 0 for success, -1 otherwise.
-*/
-static int ltt_tracefile_init(LttTracefile *tf)
-{
- ltt_subbuffer_header_t *header;
- int page_size = getpagesize();
-
- /* Temporarily map the buffer start header to get trace information */
- /* Multiple of pages aligned head */
- tf->buffer.head = mmap(0,
- PAGE_ALIGN(ltt_subbuffer_header_size()), PROT_READ,
- MAP_PRIVATE, tf->fd, 0);
- if(tf->buffer.head == MAP_FAILED) {
- perror("Error in allocating memory for buffer of tracefile");
- goto unmap_file;
- }
- g_assert( ( (gulong)tf->buffer.head&(8-1) ) == 0); // make sure it's aligned.
-
- header = (ltt_subbuffer_header_t *)tf->buffer.head;
-
- if(parse_trace_header(header, tf, tf->trace))
- {
- g_warning("parse_trace_header error");
- goto unmap_file;
- }
-
- if(munmap(tf->buffer.head,
- PAGE_ALIGN(ltt_subbuffer_header_size())))
- {
- g_warning("unmap size : %zu\n",
- PAGE_ALIGN(ltt_subbuffer_header_size()));
- perror("munmap error");
- g_assert(0);
- }
- tf->buffer.head = NULL;
-
- /* Create fields offset table */
- tf->event.fields_offsets = g_array_sized_new(FALSE, FALSE,
- sizeof(struct LttField), 1);
- if (!tf->event.fields_offsets) {
- g_warning("Cannot create fields offset table");
- goto unmap_file;
- }
-
- /* Create block index */
- ltt_trace_create_block_index(tf);
-
- if(map_block(tf,0))
- {
- perror("Cannot map block for tracefile");
- goto unmap_file;
- }
- return 0;
- /* Error */
-unmap_file:
- if(munmap(tf->buffer.head,
- PAGE_ALIGN(ltt_subbuffer_header_size()))) {
- g_warning("unmap size : %zu\n",
- PAGE_ALIGN(ltt_subbuffer_header_size()));
- perror("munmap error");
- g_assert(0);
- }
- return -1;
-}
-
-/*****************************************************************************
- *Function name
- * ltt_tracefile_open : open a trace file, construct a LttTracefile
- *Input params
- * t : the trace containing the tracefile
- * fileName : path name of the trace file
- * tf : the tracefile structure
- *Return value
- * : 0 for success, -1 otherwise.
- ****************************************************************************/
-static gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf)
-{
- struct stat lTDFStat; /* Trace data file status */
-
- //open the file
- tf->long_name = g_quark_from_string(fileName);
- tf->trace = t;
- tf->fd = open(fileName, O_RDONLY);
- tf->buf_index = NULL;
- tf->num_blocks = 0;
- if(tf->fd < 0){
- g_warning("Unable to open input data file %s\n", fileName);
- goto end;
- }
-
- // Get the file's status
- if(fstat(tf->fd, &lTDFStat) < 0){
- g_warning("Unable to get the status of the input data file %s\n", fileName);
- goto close_file;
- }
- //store the size of the file
- tf->file_size = lTDFStat.st_size;
- tf->events_lost = 0;
- tf->subbuf_corrupt = 0;
- tf->buffer.head = NULL;
- tf->event.fields_offsets = NULL;
-
- /* Is the file large enough to contain a trace */
- if(lTDFStat.st_size < (off_t)(ltt_subbuffer_header_size())){
- if (t->is_live) {
- /* It a live trace so the file can be empty at the start of the analysis */
- goto end;
- } else {
- g_print("The input data file %s does not contain a trace\n", fileName);
- goto close_file;
- }
- }
-
- if(ltt_tracefile_init(tf) < 0) {
- goto close_file;
- }
-
- return 0;
-
- /* Error */
-close_file:
- close(tf->fd);
-end:
- if (tf->buf_index)
- g_array_free(tf->buf_index, TRUE);
- return -1;
-}
-
-/*****************************************************************************
- *Function name
- * ltt_tracefile_close: close a trace file,
- *Input params
- * t : tracefile which will be closed
- ****************************************************************************/
-
-static void ltt_tracefile_close(LttTracefile *t)
-{
- int page_size = getpagesize();
-
- if(t->buffer.head != NULL)
- if(munmap(t->buffer.head, PAGE_ALIGN(t->buffer.size))) {
- g_warning("unmap size : %u\n",
- PAGE_ALIGN(t->buffer.size));
- perror("munmap error");
- g_assert(0);
- }
-
- close(t->fd);
- if (t->buf_index)
- g_array_free(t->buf_index, TRUE);
- if (t->event.fields_offsets) {
- g_array_free(t->event.fields_offsets, TRUE);
- }
-}
-
-/****************************************************************************
- * get_absolute_pathname
- *
- * return the unique pathname in the system
- *
- * MD : Fixed this function so it uses realpath, dealing well with
- * forgotten cases (.. were not used correctly before).
- *
- ****************************************************************************/
-void get_absolute_pathname(const gchar *pathname, gchar * abs_pathname)
-{
- abs_pathname[0] = '\0';
-
- if (realpath(pathname, abs_pathname) != NULL)
- return;
- else
- {
- /* error, return the original path unmodified */
- strcpy(abs_pathname, pathname);
- return;
- }
- return;
-}
-
-/* Search for something like : .*_.*
- *
- * The left side is the name, the right side is the number.
- * Exclude leading /.
- * Exclude flight- prefix.
- */
-
-static int get_tracefile_name_number(gchar *raw_name,
- GQuark *name,
- guint *num,
- gulong *tid,
- gulong *pgid,
- guint64 *creation)
-{
- guint raw_name_len = strlen(raw_name);
- gchar char_name[PATH_MAX];
- int i;
- int underscore_pos;
- long int cpu_num;
- gchar *endptr;
- gchar *tmpptr;
-
- /* skip leading / */
- for(i = 0; i < raw_name_len-1;i++) {
- if(raw_name[i] != '/')
- break;
- }
- raw_name = &raw_name[i];
- raw_name_len = strlen(raw_name);
-
- for(i=raw_name_len-1;i>=0;i--) {
- if(raw_name[i] == '_') break;
- }
- if(i==-1) { /* Either not found or name length is 0 */
- /* This is a userspace tracefile */
- strncpy(char_name, raw_name, raw_name_len);
- char_name[raw_name_len] = '\0';
- *name = g_quark_from_string(char_name);
- *num = 0; /* unknown cpu */
- for(i=0;i<raw_name_len;i++) {
- if(raw_name[i] == '/') {
- break;
- }
- }
- i++;
- for(;i<raw_name_len;i++) {
- if(raw_name[i] == '/') {
- break;
- }
- }
- i++;
- for(;i<raw_name_len;i++) {
- if(raw_name[i] == '-') {
- break;
- }
- }
- if(i == raw_name_len) return -1;
- i++;
- tmpptr = &raw_name[i];
- for(;i<raw_name_len;i++) {
- if(raw_name[i] == '.') {
- raw_name[i] = ' ';
- break;
- }
- }
- *tid = strtoul(tmpptr, &endptr, 10);
- if(endptr == tmpptr)
- return -1; /* No digit */
- if(*tid == ULONG_MAX)
- return -1; /* underflow / overflow */
- i++;
- tmpptr = &raw_name[i];
- for(;i<raw_name_len;i++) {
- if(raw_name[i] == '.') {
- raw_name[i] = ' ';
- break;
- }
- }
- *pgid = strtoul(tmpptr, &endptr, 10);
- if(endptr == tmpptr)
- return -1; /* No digit */
- if(*pgid == ULONG_MAX)
- return -1; /* underflow / overflow */
- i++;
- tmpptr = &raw_name[i];
- *creation = strtoull(tmpptr, &endptr, 10);
- if(endptr == tmpptr)
- return -1; /* No digit */
- if(*creation == G_MAXUINT64)
- return -1; /* underflow / overflow */
- } else {
- underscore_pos = i;
-
- cpu_num = strtol(raw_name+underscore_pos+1, &endptr, 10);
-
- if(endptr == raw_name+underscore_pos+1)
- return -1; /* No digit */
- if(cpu_num == LONG_MIN || cpu_num == LONG_MAX)
- return -1; /* underflow / overflow */
-
- if (!strncmp(raw_name, "flight-", sizeof("flight-") - 1)) {
- raw_name += sizeof("flight-") - 1;
- underscore_pos -= sizeof("flight-") - 1;
- }
- strncpy(char_name, raw_name, underscore_pos);
- char_name[underscore_pos] = '\0';
- *name = g_quark_from_string(char_name);
- *num = cpu_num;
- }
-
-
- return 0;
-}
-
-
-GData **ltt_trace_get_tracefiles_groups(LttTrace *trace)
-{
- return &trace->tracefiles;
-}
-
-
-void compute_tracefile_group(GQuark key_id,
- GArray *group,
- struct compute_tracefile_group_args *args)
-{
- unsigned int i;
- LttTracefile *tf;
-
- for(i=0; i<group->len; i++) {
- tf = &g_array_index (group, LttTracefile, i);
- if(tf->cpu_online)
- args->func(tf, args->func_args);
- }
-}
-
-
-static void ltt_tracefile_group_destroy(gpointer data)
-{
- GArray *group = (GArray *)data;
- unsigned int i;
- LttTracefile *tf;
-
- if (group->len > 0)
- destroy_marker_data(g_array_index (group, LttTracefile, 0).mdata);
- for(i=0; i<group->len; i++) {
- tf = &g_array_index (group, LttTracefile, i);
- if(tf->cpu_online)
- ltt_tracefile_close(tf);
- }
- g_array_free(group, TRUE);
-}
-
-static __attribute__ ((__unused__)) gboolean ltt_tracefile_group_has_cpu_online(gpointer data)
-{
- GArray *group = (GArray *)data;
- unsigned int i;
- LttTracefile *tf;
-
- for(i=0; i<group->len; i++) {
- tf = &g_array_index (group, LttTracefile, i);
- if(tf->cpu_online)
- return 1;
- }
- return 0;
-}
-
-
-/* Open each tracefile under a specific directory. Put them in a
- * GData : permits to access them using their tracefile group pathname.
- * i.e. access control/modules tracefile group by index :
- * "control/module".
- *
- * relative path is the path relative to the trace root
- * root path is the full path
- *
- * A tracefile group is simply an array where all the per cpu tracefiles sit.
- */
-
-static int open_tracefiles(LttTrace *trace, gchar *root_path, gchar *relative_path)
-{
- DIR *dir = opendir(root_path);
- struct dirent *entry;
- struct stat stat_buf;
- int ret, i;
- struct marker_data *mdata;
-
- gchar path[PATH_MAX];
- int path_len;
- gchar *path_ptr;
-
- int rel_path_len;
- gchar rel_path[PATH_MAX];
- gchar *rel_path_ptr;
- LttTracefile tmp_tf;
-
- if(dir == NULL) {
- perror(root_path);
- return ENOENT;
- }
-
- strncpy(path, root_path, PATH_MAX-1);
- path_len = strlen(path);
- path[path_len] = '/';
- path_len++;
- path_ptr = path + path_len;
-
- strncpy(rel_path, relative_path, PATH_MAX-1);
- rel_path_len = strlen(rel_path);
- rel_path[rel_path_len] = '/';
- rel_path_len++;
- rel_path_ptr = rel_path + rel_path_len;
-
- while((entry = readdir(dir)) != NULL) {
- if(entry->d_name[0] == '.') continue;
-
- strncpy(path_ptr, entry->d_name, PATH_MAX - path_len);
- strncpy(rel_path_ptr, entry->d_name, PATH_MAX - rel_path_len);
-
- ret = stat(path, &stat_buf);
- if(ret == -1) {
- perror(path);
- continue;
- }
-
- g_debug("Tracefile file or directory : %s\n", path);
-
- // if(strcmp(rel_path, "/eventdefs") == 0) continue;
-
- if(S_ISDIR(stat_buf.st_mode)) {
-
- g_debug("Entering subdirectory...\n");
- ret = open_tracefiles(trace, path, rel_path);
- if(ret < 0) continue;
- } else if(S_ISREG(stat_buf.st_mode)) {
- GQuark name;
- guint num;
- gulong tid, pgid;
- guint64 creation;
- GArray *group;
- num = 0;
- tid = pgid = 0;
- creation = 0;
- if(get_tracefile_name_number(rel_path, &name, &num, &tid, &pgid, &creation))
- continue; /* invalid name */
-
- g_debug("Opening file.\n");
- if(ltt_tracefile_open(trace, path, &tmp_tf)) {
- /* Only consider the error for non live trace */
- if (!trace->is_live) {
-
- g_info("Error opening tracefile %s", path);
- continue; /* error opening the tracefile : bad magic number ? */
- }
- }
-
- g_debug("Tracefile name is %s and number is %u",
- g_quark_to_string(name), num);
-
- mdata = NULL;
- tmp_tf.cpu_online = 1;
- tmp_tf.cpu_num = num;
- tmp_tf.name = name;
- tmp_tf.tid = tid;
- tmp_tf.pgid = pgid;
- tmp_tf.creation = creation;
- group = g_datalist_id_get_data(&trace->tracefiles, name);
- if(group == NULL) {
- /* Elements are automatically cleared when the array is allocated.
- * It makes the cpu_online variable set to 0 : cpu offline, by default.
- */
- group = g_array_sized_new (FALSE, TRUE, sizeof(LttTracefile), 10);
- g_datalist_id_set_data_full(&trace->tracefiles, name,
- group, ltt_tracefile_group_destroy);
- mdata = allocate_marker_data();
- if (!mdata)
- g_error("Error in allocating marker data");
- }
-
- /* Add the per cpu tracefile to the named group */
- unsigned int old_len = group->len;
- if(num+1 > old_len)
- group = g_array_set_size(group, num+1);
-
- g_assert(group->len > 0);
- if (!mdata)
- mdata = g_array_index (group, LttTracefile, 0).mdata;
-
- g_array_index (group, LttTracefile, num) = tmp_tf;
- g_array_index (group, LttTracefile, num).event.tracefile =
- &g_array_index (group, LttTracefile, num);
- for (i = 0; i < group->len; i++)
- g_array_index (group, LttTracefile, i).mdata = mdata;
- }
- }
-
- closedir(dir);
-
- return 0;
-}
-
-
-/* Presumes the tracefile is already seeked at the beginning. It makes sense,
- * because it must be done just after the opening */
-static int ltt_process_metadata_tracefile(LttTracefile *tf)
-{
- int err;
-
- while(1) {
- err = ltt_tracefile_read_seek(tf);
- if(err == EPERM) goto seek_error;
- else if(err == ERANGE) break; /* End of tracefile */
-
- err = ltt_tracefile_read_update_event(tf);
- if(err) goto update_error;
-
- /* The rules are :
- * It contains only core events :
- * 0 : set_marker_id
- * 1 : set_marker_format
- */
- if(tf->event.event_id >= MARKER_CORE_IDS) {
- /* Should only contain core events */
- g_warning("Error in processing metadata file %s, "
- "should not contain event id %u.", g_quark_to_string(tf->name),
- tf->event.event_id);
- err = EPERM;
- goto event_id_error;
- } else {
- char *pos;
- const char *channel_name, *marker_name, *format;
- uint16_t id;
- guint8 int_size, long_size, pointer_size, size_t_size, alignment;
-
- switch((enum marker_id)tf->event.event_id) {
- case MARKER_ID_SET_MARKER_ID:
- channel_name = pos = tf->event.data;
- pos += strlen(channel_name) + 1;
- marker_name = pos;
- g_debug("Doing MARKER_ID_SET_MARKER_ID of marker %s.%s",
- channel_name, marker_name);
- pos += strlen(marker_name) + 1;
- pos += ltt_align((size_t)pos, sizeof(guint16), tf->alignment);
- id = ltt_get_uint16(LTT_GET_BO(tf), pos);
- g_debug("In MARKER_ID_SET_MARKER_ID of marker %s.%s id %hu",
- channel_name, marker_name, id);
- pos += sizeof(guint16);
- int_size = *(guint8*)pos;
- pos += sizeof(guint8);
- long_size = *(guint8*)pos;
- pos += sizeof(guint8);
- pointer_size = *(guint8*)pos;
- pos += sizeof(guint8);
- size_t_size = *(guint8*)pos;
- pos += sizeof(guint8);
- alignment = *(guint8*)pos;
- pos += sizeof(guint8);
- marker_id_event(tf->trace,
- g_quark_from_string(channel_name),
- g_quark_from_string(marker_name),
- id, int_size, long_size,
- pointer_size, size_t_size, alignment);
- break;
- case MARKER_ID_SET_MARKER_FORMAT:
- channel_name = pos = tf->event.data;
- pos += strlen(channel_name) + 1;
- marker_name = pos;
- g_debug("Doing MARKER_ID_SET_MARKER_FORMAT of marker %s.%s",
- channel_name, marker_name);
- pos += strlen(marker_name) + 1;
- format = pos;
- pos += strlen(format) + 1;
- marker_format_event(tf->trace,
- g_quark_from_string(channel_name),
- g_quark_from_string(marker_name),
- format);
- /* get information from dictionary TODO */
- break;
- default:
- g_warning("Error in processing metadata file %s, "
- "unknown event id %hhu.",
- g_quark_to_string(tf->name),
- tf->event.event_id);
- err = EPERM;
- goto event_id_error;
- }
- }
- }
- return 0;
-
- /* Error handling */
-event_id_error:
-update_error:
-seek_error:
- g_warning("An error occured in metadata tracefile parsing");
- return err;
-}
-
-
-LttTrace *ltt_trace_open(const gchar *pathname)
-{
- return _ltt_trace_open(pathname, FALSE);
-}
-
-LttTrace *ltt_trace_open_live(const gchar *pathname)
-{
- return _ltt_trace_open(pathname, TRUE);
-}
-
-/*
- * Open a trace and return its LttTrace handle.
- *
- * pathname must be the directory of the trace
- */
-
-static LttTrace *_ltt_trace_open(const gchar *pathname, gboolean is_live)
-{
- gchar abs_path[PATH_MAX];
- LttTrace * t;
- LttTracefile *tf;
- GArray *group;
- unsigned int i;
- int ret;
- ltt_subbuffer_header_t *header;
- DIR *dir;
- struct dirent *entry;
- struct stat stat_buf;
- gchar path[PATH_MAX];
-
- t = g_new(LttTrace, 1);
- if(!t) goto alloc_error;
-
- get_absolute_pathname(pathname, abs_path);
- t->pathname = g_quark_from_string(abs_path);
-
- g_datalist_init(&t->tracefiles);
-
- /* Test to see if it looks like a trace */
- dir = opendir(abs_path);
- if(dir == NULL) {
- perror(abs_path);
- goto open_error;
- }
- while((entry = readdir(dir)) != NULL) {
- strcpy(path, abs_path);
- strcat(path, "/");
- strcat(path, entry->d_name);
- ret = stat(path, &stat_buf);
- if(ret == -1) {
- perror(path);
- continue;
- }
- }
- closedir(dir);
-
- t->is_live = is_live;
- t->live_safe_timestamp = ltt_time_zero;
-
- /* Open all the tracefiles */
- t->start_freq= 0;
- if(open_tracefiles(t, abs_path, "")) {
- g_warning("Error opening tracefile %s", abs_path);
- goto find_error;
- }
-
- /* Parse each trace metadata_N files : get runtime fac. info */
- group = g_datalist_id_get_data(&t->tracefiles, LTT_TRACEFILE_NAME_METADATA);
- if(group == NULL) {
- g_warning("Trace %s has no metadata tracefile", abs_path);
- goto find_error;
- }
-
- /*
- * Get the trace information for the first valid metadata tracefile.
- * In live trace mode, the metadata_0 might be empty
- * Getting a correct trace start_time and start_tsc is insured by the fact
- * that no subbuffers are supposed to be lost in the metadata channel.
- * Therefore, the first subbuffer contains the start_tsc timestamp in its
- * buffer header.
- */
- g_assert(group->len > 0);
- header = NULL;
- for(i=0; i<group->len; i++) {
- tf = &g_array_index (group, LttTracefile, i);
- header = (ltt_subbuffer_header_t *)tf->buffer.head;
- if (header) {
- break;
- }
- }
- if (header == NULL) {
- g_warning("Trace %s has not one valid metadata tracefile", abs_path);
- goto find_error;
- }
-
- ret = parse_trace_header(header, tf, t);
- g_assert(!ret);
-
- t->num_cpu = group->len;
- t->drift = 1.;
- t->offset = 0.;
-
- //ret = allocate_marker_data(t);
- //if (ret)
- // g_error("Error in allocating marker data");
-
- for(i=0; i<group->len; i++) {
- tf = &g_array_index (group, LttTracefile, i);
- if (tf->cpu_online && tf->buffer.head )
- if(ltt_process_metadata_tracefile(tf))
- goto find_error;
- // goto metadata_error;
- }
-
- return t;
-
- /* Error handling */
-//metadata_error:
-// destroy_marker_data(t);
-find_error:
- g_datalist_clear(&t->tracefiles);
-open_error:
- g_free(t);
-alloc_error:
- return NULL;
-
-}
-
-
-/*****************************************************************************
- Update the informations concerning the tracefile
-
- Must be called periodically to update trace file and file size
- information.
-
-Input params
- tf : the tracefile
-Return value
- : Number of tracefile with available events
- -1 on error.
- ****************************************************************************/
-int ltt_trace_update(LttTrace *trace)
-{
- int trace_updated_count = 0;
-
- /* Only update live traces */
- if(trace->is_live) {
-
- /* Iterate on all tracefiles */
- g_datalist_foreach(&trace->tracefiles,
- &update_tracefile_group,
- &trace_updated_count);
-
- return trace_updated_count;
- }
- return 0;
-
-}
-
-static void update_tracefile_group(GQuark name, gpointer data, gpointer user_data)
-{
- int *trace_updated_count = (int *)user_data;
- unsigned int i;
- LttTracefile *tf;
- GArray *group = (GArray *)data;
-
- g_debug("Updating tracefile group %s", g_quark_to_string(name));
- for(i=0; i<group->len; i++) {
- tf = &g_array_index (group, LttTracefile, i);
-
- /* Update safe timestamp */
- tf->trace->live_safe_timestamp =
- LTT_TIME_MAX(tf->trace->live_safe_timestamp,
- ltt_interpolate_time_from_tsc(tf,
- tf->end_timestamp));
-
- /* Update tracefile */
- int ret = ltt_tracefile_update(tf);
- if(ret < 0) {
- g_warning("LIVE: Cannot update tracefile %s",
- g_quark_to_string(ltt_tracefile_long_name(tf)));
- *trace_updated_count = -1;
- break;
- } else {
- *trace_updated_count += 1;
- }
- }
-}
-
-
-/*****************************************************************************
- *Function name
- * ltt_tracefile_update : Update the informations concerning a tracefile
- * Must be called periodically to update trace file and file size
- information.
- *Input params
- * tf : the tracefile
- *Return value
- * : 1 for success and an event is available
- 0 for success but no event available,
- * -1 on error.
- ****************************************************************************/
-static int ltt_tracefile_update(LttTracefile *tf)
-{
- struct stat lTDFStat; /* Trace data file status */
- if(fstat(tf->fd, &lTDFStat) < 0){
- perror("error in getting the tracefile informations.");
- }
-
-
- /* Process the file only on size change */
- if(tf->file_size < lTDFStat.st_size) {
- /* Update the size of the file */
- tf->file_size = lTDFStat.st_size;
- g_debug("Updating tracefile %s", g_quark_to_string(tf->long_name));
-
- if( tf->file_size >= (off_t)(ltt_subbuffer_header_size()) ) {
-
- if(tf->buf_index == NULL) {
- if(ltt_tracefile_init(tf) < 0) {
- return -1;
- }
- if(tf->name == LTT_TRACEFILE_NAME_METADATA) {
-
- LttTime start;
- start.tv_sec = 0;
- start.tv_nsec = 0;
- ltt_process_metadata_tracefile(tf);
-
- ltt_tracefile_seek_time(tf, start);
- tf->event.offset = 0;
-
- }
- }
- else
- {
- /* Retrieve the new subbuffers and index them */
- ltt_trace_continue_block_index(tf);
-
- if(tf->name == LTT_TRACEFILE_NAME_METADATA) {
- LttEventPosition *pos = ltt_event_position_new();
- ltt_tracefile_get_current_position(tf, pos);
- ltt_process_metadata_tracefile(tf);
- ltt_tracefile_seek_position(tf, pos);
- g_free(pos);
-
- }
- }
-
- return 1;
- }
- }
-
- return 0;
-
-}
-
-/* Open another, completely independant, instance of a trace.
- *
- * A read on this new instance will read the first event of the trace.
- *
- * When we copy a trace, we want all the opening actions to happen again :
- * the trace will be reopened and totally independant from the original.
- * That's why we call ltt_trace_open.
- */
-LttTrace *ltt_trace_copy(LttTrace *self)
-{
- return _ltt_trace_open(g_quark_to_string(self->pathname), self->is_live);
-}
-
-/*
- * Close a trace
- */
-
-void ltt_trace_close(LttTrace *t)
-{
- g_datalist_clear(&t->tracefiles);
- g_free(t);
-}
-
-
-/*****************************************************************************
- * Get the start time and end time of the trace
- ****************************************************************************/
-
-void ltt_tracefile_time_span_get(LttTracefile *tf,
- LttTime *start, LttTime *end)
-{
- int err;
-
-
- err = map_block(tf, 0);
- /* Only empty live traces will return ERANGE */
- if(err == ERANGE) {
- *start = ltt_time_infinite;
- *end = ltt_time_zero;
- return;
- } else if(unlikely(err)) {
- g_error("Can not map block");
- *start = ltt_time_infinite;
- } else
- *start = tf->buffer.begin.timestamp;
-
- err = map_block(tf, tf->num_blocks - 1); /* Last block */
- if(unlikely(err)) {
- g_error("Can not map block");
- *end = ltt_time_zero;
- } else
- *end = tf->buffer.end.timestamp;
-
- g_assert(end->tv_sec <= G_MAXUINT);
-}
-
-struct tracefile_time_span_get_args {
- LttTrace *t;
- LttTime *start;
- LttTime *end;
-};
-
-static void group_time_span_get(GQuark name, gpointer data, gpointer user_data)
-{
- struct tracefile_time_span_get_args *args =
- (struct tracefile_time_span_get_args*)user_data;
-
- GArray *group = (GArray *)data;
- unsigned int i;
- LttTracefile *tf;
- LttTime tmp_start;
- LttTime tmp_end;
-
- for(i=0; i<group->len; i++) {
- tf = &g_array_index (group, LttTracefile, i);
- if(tf->cpu_online) {
- ltt_tracefile_time_span_get(tf, &tmp_start, &tmp_end);
- if(ltt_time_compare(*args->start, tmp_start)>0) *args->start = tmp_start;
- if(ltt_time_compare(*args->end, tmp_end)<0) *args->end = tmp_end;
- }
- }
-}
-
-/* return the start and end time of a trace */
-
-void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end)
-{
- LttTime min_start = ltt_time_infinite;
- LttTime max_end = ltt_time_zero;
- struct tracefile_time_span_get_args args = { t, &min_start, &max_end };
-
- g_datalist_foreach(&t->tracefiles, &group_time_span_get, &args);
-
- if(start != NULL) *start = min_start;
- if(end != NULL) *end = max_end;
-
-}
-
-
-/* Seek to the first event in a tracefile that has a time equal or greater than
- * the time passed in parameter.
- *
- * If the time parameter is outside the tracefile time span, seek to the first
- * event or if after, return ERANGE.
- *
- * If the time parameter is before the first event, we have to seek specially to
- * there.
- *
- * If the time is after the end of the trace, return ERANGE.
- *
- * Do a binary search to find the right block, then a sequential search in the
- * block to find the event.
- *
- * In the special case where the time requested fits inside a block that has no
- * event corresponding to the requested time, the first event of the next block
- * will be seeked.
- *
- * IMPORTANT NOTE : // FIXME everywhere...
- *
- * You MUST NOT do a ltt_tracefile_read right after a ltt_tracefile_seek_time :
- * you will jump over an event if you do.
- *
- * Return value : 0 : no error, the tf->event can be used
- * ERANGE : time if after the last event of the trace
- * otherwise : this is an error.
- *
- * */
-
-int ltt_tracefile_seek_time(LttTracefile *tf, LttTime time)
-{
- int ret = 0;
- int err;
- unsigned int block_num, high, low;
-
- /* seek at the beginning of trace */
- err = map_block(tf, 0); /* First block */
- if(unlikely(err == ERANGE)) {
- goto range;
- } else if(unlikely(err)) {
- g_error("Can not map block");
- goto fail;
- }
-
- /* If the time is lower or equal the beginning of the trace,
- * go to the first event. */
- if(ltt_time_compare(time, tf->buffer.begin.timestamp) <= 0) {
- ret = ltt_tracefile_read(tf);
- if(ret == ERANGE) goto range;
- else if (ret) goto fail;
- goto found; /* There is either no event in the trace or the event points
- to the first event in the trace */
- }
-
- err = map_block(tf, tf->num_blocks - 1); /* Last block */
- if(unlikely(err)) {
- g_error("Can not map block");
- goto fail;
- }
-
- /* If the time is after the end of the trace, return ERANGE. */
- if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) {
- goto range;
- }
-
- /* Binary search the block */
- high = tf->num_blocks - 1;
- low = 0;
-
- while(1) {
- block_num = ((high-low) / 2) + low;
-
- err = map_block(tf, block_num);
- if(unlikely(err)) {
- g_error("Can not map block");
- goto fail;
- }
- if(high == low) {
- /* We cannot divide anymore : this is what would happen if the time
- * requested was exactly between two consecutive buffers'end and start
- * timestamps. This is also what would happend if we didn't deal with out
- * of span cases prior in this function. */
- /* The event is right in the buffer!
- * (or in the next buffer first event) */
- while(1) {
- ret = ltt_tracefile_read(tf);
- if(ret == ERANGE) goto range; /* ERANGE or EPERM */
- else if(ret) goto fail;
-
- if(ltt_time_compare(time, tf->event.event_time) <= 0)
- goto found;
- }
-
- } else if(ltt_time_compare(time, tf->buffer.begin.timestamp) < 0) {
- /*
- * Go to lower part. We don't want block_num - 1 since block_num
- * can equal low , in which case high < low.
- */
- high = block_num;
- } else if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) {
- /* go to higher part */
- low = block_num + 1;
- } else {/* The event is right in the buffer!
- (or in the next buffer first event) */
- while(1) {
- ret = ltt_tracefile_read(tf);
- if(ret == ERANGE) goto range; /* ERANGE or EPERM */
- else if(ret) goto fail;
-
- if(ltt_time_compare(time, tf->event.event_time) <= 0)
- break;
- }
- goto found;
- }
- }
-
-found:
- return 0;
-range:
- return ERANGE;
-
- /* Error handling */
-fail:
- g_error("ltt_tracefile_seek_time failed on tracefile %s",
- g_quark_to_string(tf->name));
- return EPERM;
-}
-
-
-/* Save the current tracefile position in the passed position pointer */
-int ltt_tracefile_get_current_position(const LttTracefile *tf, LttEventPosition *ep)
-{
- /* TODO ybrosseau 2011-06-07: Maybe add some error checking
- (ex: check the validity of the arguments pointer) */
- ltt_event_position(&(tf->event), ep);
- return 0;
-}
-
-
-/* Seek to a position indicated by an LttEventPosition
- */
-
-int ltt_tracefile_seek_position(LttTracefile *tf, const LttEventPosition *ep)
-{
- int err;
-
- if(ep->tracefile != tf) {
- goto fail;
- }
-
- err = map_block(tf, ep->block);
- if(unlikely(err)) {
- g_error("Can not map block");
- goto fail;
- }
-
- tf->event.offset = ep->offset;
-
- /* Put back the event real tsc */
- tf->event.tsc = ep->tsc;
- tf->buffer.tsc = ep->tsc;
-
- err = ltt_tracefile_read_update_event(tf);
- if(err) goto fail;
-
- /* deactivate this, as it does nothing for now
- err = ltt_tracefile_read_op(tf);
- if(err) goto fail;
- */
-
- return 0;
-
-fail:
- g_error("ltt_tracefile_seek_time failed on tracefile %s",
- g_quark_to_string(tf->name));
- return 1;
-}
-
-/*
- * Convert a value in "TSC scale" to a value in nanoseconds
- */
-guint64 tsc_to_uint64(guint32 freq_scale, uint64_t start_freq, guint64 tsc)
-{
- return (double) tsc * NANOSECONDS_PER_SECOND * freq_scale / start_freq;
-}
-
-/* Given a TSC value, return the LttTime (seconds,nanoseconds) it
- * corresponds to.
- */
-LttTime ltt_interpolate_time_from_tsc(LttTracefile *tf, guint64 tsc)
-{
- return ltt_time_from_uint64(tsc_to_uint64(tf->trace->freq_scale,
- tf->trace->start_freq, tf->trace->drift * tsc +
- tf->trace->offset));
-}
-
-/* Calculate the real event time based on the buffer boundaries */
-LttTime ltt_interpolate_time(LttTracefile *tf, LttEvent *event)
-{
- return ltt_interpolate_time_from_tsc(tf, tf->buffer.tsc);
-}
-
-
-/* Get the current event of the tracefile : valid until the next read */
-LttEvent *ltt_tracefile_get_event(LttTracefile *tf)
-{
- return &tf->event;
-}
-
-/*****************************************************************************
- *Function name
- * ltt_tracefile_read : Read the next event in the tracefile
- *Input params
- * t : tracefile
- *Return value
- *
- * Returns 0 if an event can be used in tf->event.
- * Returns ERANGE on end of trace. The event in tf->event still can be used
- * (if the last block was not empty).
- * Returns EPERM on error.
- *
- * This function does make the tracefile event structure point to the event
- * currently pointed to by the tf->event.
- *
- * Note : you must call a ltt_tracefile_seek to the beginning of the trace to
- * reinitialize it after an error if you want results to be coherent.
- * It would be the case if a end of trace last buffer has no event : the end
- * of trace wouldn't be returned, but an error.
- * We make the assumption there is at least one event per buffer.
- ****************************************************************************/
-
-int ltt_tracefile_read(LttTracefile *tf)
-{
- int err;
-
- err = ltt_tracefile_read_seek(tf);
- if(err) return err;
- err = ltt_tracefile_read_update_event(tf);
- if(err) return err;
-
- /* deactivate this, as it does nothing for now
- err = ltt_tracefile_read_op(tf);
- if(err) return err;
- */
-
- return 0;
-}
-
-int ltt_tracefile_read_seek(LttTracefile *tf)
-{
- int err;
-
- /* Get next buffer until we finally have an event, or end of trace */
- while(1) {
- err = ltt_seek_next_event(tf);
- if(unlikely(err == ENOPROTOOPT)) {
- return EPERM;
- }
-
- /* Are we at the end of the buffer ? */
- if(err == ERANGE) {
- if(unlikely(tf->buffer.index == tf->num_blocks-1)){ /* end of trace ? */
- return ERANGE;
- } else {
- /* get next block */
- err = map_block(tf, tf->buffer.index + 1);
- if(unlikely(err)) {
- g_error("Can not map block");
- return EPERM;
- }
- }
- } else break; /* We found an event ! */
- }
-
- return 0;
-}
-
-/* do an operation when reading a new event */
-
-/* This function does nothing for now */
-#if 0
-int ltt_tracefile_read_op(LttTracefile *tf)
-{
- LttEvent *event;
-
- event = &tf->event;
-
- /* do event specific operation */
-
- /* nothing */
-
- return 0;
-}
-#endif
-
-static void print_debug_event_header(LttEvent *ev, void *start_pos, void *end_pos)
-{
- unsigned int offset = 0;
- int i, j;
-
- g_printf("Event header (tracefile %s offset %" PRIx64 "):\n",
- g_quark_to_string(ev->tracefile->long_name),
- (uint64_t)ev->tracefile->buffer.offset +
- (long)start_pos - (long)ev->tracefile->buffer.head);
-
- while (offset < (long)end_pos - (long)start_pos) {
- g_printf("%8lx", (long)start_pos - (long)ev->tracefile->buffer.head + offset);
- g_printf(" ");
-
- for (i = 0; i < 4 ; i++) {
- for (j = 0; j < 4; j++) {
- if (offset + ((i * 4) + j) <
- (long)end_pos - (long)start_pos)
- g_printf("%02hhX",
- ((char*)start_pos)[offset + ((i * 4) + j)]);
- else
- g_printf(" ");
- g_printf(" ");
- }
- if (i < 4)
- g_printf(" ");
- }
- offset+=16;
- g_printf("\n");
- }
-}
-
-
-/* same as ltt_tracefile_read, but does not seek to the next event nor call
- * event specific operation. */
-int ltt_tracefile_read_update_event(LttTracefile *tf)
-{
- void * pos;
- LttEvent *event;
- void *pos_aligned;
- guint16 packed_evid; /* event id reader from the 5 bits in header */
-
- event = &tf->event;
- pos = tf->buffer.head + event->offset;
-
- /* Read event header */
-
- /* Align the head */
- pos += ltt_align((size_t)pos, sizeof(guint32), tf->alignment);
- pos_aligned = pos;
-
- event->timestamp = ltt_get_uint32(LTT_GET_BO(tf), pos);
- event->event_id = packed_evid = event->timestamp >> tf->tscbits;
- event->timestamp = event->timestamp & tf->tsc_mask;
- pos += sizeof(guint32);
-
- switch (packed_evid) {
- case 29: /* LTT_RFLAG_ID_SIZE_TSC */
- event->event_id = ltt_get_uint16(LTT_GET_BO(tf), pos);
- pos += sizeof(guint16);
- event->event_size = ltt_get_uint16(LTT_GET_BO(tf), pos);
- pos += sizeof(guint16);
- if (event->event_size == 0xFFFF) {
- event->event_size = ltt_get_uint32(LTT_GET_BO(tf), pos);
- pos += sizeof(guint32);
- }
- pos += ltt_align((size_t)pos, sizeof(guint64), tf->alignment);
- tf->buffer.tsc = ltt_get_uint64(LTT_GET_BO(tf), pos);
- pos += sizeof(guint64);
- break;
- case 30: /* LTT_RFLAG_ID_SIZE */
- event->event_id = ltt_get_uint16(LTT_GET_BO(tf), pos);
- pos += sizeof(guint16);
- event->event_size = ltt_get_uint16(LTT_GET_BO(tf), pos);
- pos += sizeof(guint16);
- if (event->event_size == 0xFFFF) {
- event->event_size = ltt_get_uint32(LTT_GET_BO(tf), pos);
- pos += sizeof(guint32);
- }
- break;
- case 31: /* LTT_RFLAG_ID */
- event->event_id = ltt_get_uint16(LTT_GET_BO(tf), pos);
- pos += sizeof(guint16);
- event->event_size = G_MAXUINT;
- break;
- default:
- event->event_size = G_MAXUINT;
- break;
- }
-
- if (likely(packed_evid != 29)) {
- /* No extended timestamp */
- if (event->timestamp < (tf->buffer.tsc & tf->tsc_mask))
- tf->buffer.tsc = ((tf->buffer.tsc & ~tf->tsc_mask) /* overflow */
- + tf->tsc_mask_next_bit)
- | (guint64)event->timestamp;
- else
- tf->buffer.tsc = (tf->buffer.tsc & ~tf->tsc_mask) /* no overflow */
- | (guint64)event->timestamp;
- }
- event->tsc = tf->buffer.tsc;
-
- event->event_time = ltt_interpolate_time(tf, event);
-
- if (a_event_debug)
- print_debug_event_header(event, pos_aligned, pos);
-
- event->data = pos;
-
- /*
- * Let ltt_update_event_size update event->data according to the largest
- * alignment within the payload.
- * Get the data size and update the event fields with the current
- * information. */
- ltt_update_event_size(tf);
-
- return 0;
-}
-
-
-/****************************************************************************
- *Function name
- * map_block : map a block from the file
- *Input Params
- * lttdes : ltt trace file
- * whichBlock : the block which will be read
- *return value
- * 0 : success
- * EINVAL : lseek fail
- * EIO : can not read from the file
- ****************************************************************************/
-
-static gint map_block(LttTracefile * tf, guint block_num)
-{
- int page_size = getpagesize();
- ltt_subbuffer_header_t *header;
- uint64_t offset;
- uint32_t size;
- int ret;
-
- if(tf->num_blocks == 0) {
- errno = ERANGE;
- return ERANGE;
- }
-
- g_assert(block_num < tf->num_blocks);
-
- if(tf->buffer.head != NULL) {
- if(munmap(tf->buffer.head, PAGE_ALIGN(tf->buffer.size))) {
- g_warning("unmap size : %u\n",
- PAGE_ALIGN(tf->buffer.size));
- perror("munmap error");
- g_assert(0);
- }
- }
-
- ret = get_block_offset_size(tf, block_num, &offset, &size);
- g_assert(!ret);
-
- g_debug("Map block %u, offset %llu, size %u\n", block_num,
- (unsigned long long)offset, (unsigned int)size);
-
- /* Multiple of pages aligned head */
- tf->buffer.head = mmap(0, (size_t)size, PROT_READ, MAP_PRIVATE,
- tf->fd, (off_t)offset);
-
- if(tf->buffer.head == MAP_FAILED) {
- perror("Error in allocating memory for buffer of tracefile");
- g_assert(0);
- goto map_error;
- }
- g_assert( ( (gulong)tf->buffer.head&(8-1) ) == 0); // make sure it's aligned.
-
- tf->buffer.index = block_num;
-
- header = (ltt_subbuffer_header_t *)tf->buffer.head;
-
- tf->buffer.begin.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
- &header->cycle_count_begin);
- tf->buffer.end.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
- &header->cycle_count_end);
- tf->buffer.offset = offset;
- tf->buffer.size = ltt_get_uint32(LTT_GET_BO(tf),
- &header->sb_size);
- tf->buffer.data_size = ltt_get_uint32(LTT_GET_BO(tf),
- &header->data_size);
- tf->buffer.tsc = tf->buffer.begin.cycle_count;
- tf->event.tsc = tf->buffer.tsc;
- tf->buffer.freq = tf->buffer.begin.freq;
-
- g_assert(size == tf->buffer.size);
- g_assert(tf->buffer.data_size <= tf->buffer.size);
-
- if (tf->trace->start_freq)
- {
- tf->buffer.begin.freq = tf->trace->start_freq;
- tf->buffer.begin.timestamp = ltt_interpolate_time_from_tsc(tf,
- tf->buffer.begin.cycle_count);
- tf->buffer.end.freq = tf->trace->start_freq;
- tf->buffer.end.timestamp = ltt_interpolate_time_from_tsc(tf,
- tf->buffer.end.cycle_count);
- }
-
- /* Make the current event point to the beginning of the buffer :
- * it means that the event read must get the first event. */
- tf->event.tracefile = tf;
- tf->event.block = block_num;
- tf->event.offset = 0;
-
- if (header->events_lost) {
- g_warning("%d events lost so far in tracefile %s at block %u",
- (guint)header->events_lost,
- g_quark_to_string(tf->long_name),
- block_num);
- tf->events_lost = header->events_lost;
- }
- if (header->subbuf_corrupt) {
- g_warning("%d subbuffer(s) corrupted so far in tracefile %s at block %u",
- (guint)header->subbuf_corrupt,
- g_quark_to_string(tf->long_name),
- block_num);
- tf->subbuf_corrupt = header->subbuf_corrupt;
- }
-
- return 0;
-
-map_error:
- return -errno;
-}
-
-static void print_debug_event_data(LttEvent *ev)
-{
- unsigned int offset = 0;
- int i, j;
-
- if (!max(ev->event_size, ev->data_size))
- return;
-
- g_printf("Event data (tracefile %s offset %" PRIx64 "):\n",
- g_quark_to_string(ev->tracefile->long_name),
- (uint64_t)ev->tracefile->buffer.offset
- + (long)ev->data - (long)ev->tracefile->buffer.head);
-
- while (offset < max(ev->event_size, ev->data_size)) {
- g_printf("%8lx", (long)ev->data + offset
- - (long)ev->tracefile->buffer.head);
- g_printf(" ");
-
- for (i = 0; i < 4 ; i++) {
- for (j = 0; j < 4; j++) {
- if (offset + ((i * 4) + j) < max(ev->event_size, ev->data_size))
- g_printf("%02hhX", ((char*)ev->data)[offset + ((i * 4) + j)]);
- else
- g_printf(" ");
- g_printf(" ");
- }
- if (i < 4)
- g_printf(" ");
- }
-
- g_printf(" ");
-
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- if (offset + ((i * 4) + j) < max(ev->event_size, ev->data_size)) {
- if (isprint(((char*)ev->data)[offset + ((i * 4) + j)]))
- g_printf("%c", ((char*)ev->data)[offset + ((i * 4) + j)]);
- else
- g_printf(".");
- } else
- g_printf(" ");
- }
- }
- offset+=16;
- g_printf("\n");
- }
-}
-
-/* It will update the fields offsets too */
-void ltt_update_event_size(LttTracefile *tf)
-{
- off_t size = 0;
- struct marker_info *info;
-
- if (tf->name == LTT_TRACEFILE_NAME_METADATA) {
- switch((enum marker_id)tf->event.event_id) {
- case MARKER_ID_SET_MARKER_ID:
- size = strlen((char*)tf->event.data) + 1;
- g_debug("marker %s id set", (char*)tf->event.data + size);
- size += strlen((char*)tf->event.data + size) + 1;
- size += ltt_align(size, sizeof(guint16), tf->alignment);
- size += sizeof(guint16);
- size += sizeof(guint8);
- size += sizeof(guint8);
- size += sizeof(guint8);
- size += sizeof(guint8);
- size += sizeof(guint8);
- break;
- case MARKER_ID_SET_MARKER_FORMAT:
- size = strlen((char*)tf->event.data) + 1;
- g_debug("marker %s format set", (char*)tf->event.data);
- size += strlen((char*)tf->event.data + size) + 1;
- size += strlen((char*)tf->event.data + size) + 1;
- break;
- }
- }
-
- info = marker_get_info_from_id(tf->mdata, tf->event.event_id);
-
- if (tf->event.event_id >= MARKER_CORE_IDS)
- g_assert(info != NULL);
-
- /* Do not update field offsets of core markers when initially reading the
- * metadata tracefile when the infos about these markers do not exist yet.
- */
- if (likely(info && info->fields)) {
- /* alignment */
- tf->event.data += ltt_align((off_t)(unsigned long)tf->event.data,
- info->largest_align,
- info->alignment);
- /* size, dynamically computed */
- if (info->size != -1)
- size = info->size;
- else
- size = marker_update_fields_offsets(info, tf->event.data);
- /* Update per-tracefile offsets */
- marker_update_event_fields_offsets(tf->event.fields_offsets, info);
- }
-
- tf->event.data_size = size;
-
- /* Check consistency between kernel and LTTV structure sizes */
- if(tf->event.event_size == G_MAXUINT) {
- /* Event size too big to fit in the event size field */
- tf->event.event_size = tf->event.data_size;
- }
-
- if (a_event_debug)
- print_debug_event_data(&tf->event);
-
- if (tf->event.data_size != tf->event.event_size) {
- struct marker_info *info = marker_get_info_from_id(tf->mdata,
- tf->event.event_id);
- if (!info)
- g_error("Undescribed event %hhu in channel %s", tf->event.event_id,
- g_quark_to_string(tf->name));
- g_error("Kernel/LTTV event size differs for event %s: kernel %u, LTTV %u",
- g_quark_to_string(info->name),
- tf->event.event_size, tf->event.data_size);
- exit(-1);
- }
-}
-
-
-/* Take the tf current event offset and use the event id to figure out where is
- * the next event offset.
- *
- * This is an internal function not aiming at being used elsewhere : it will
- * not jump over the current block limits. Please consider using
- * ltt_tracefile_read to do this.
- *
- * Returns 0 on success
- * ERANGE if we are at the end of the buffer.
- * ENOPROTOOPT if an error occured when getting the current event size.
- */
-static int ltt_seek_next_event(LttTracefile *tf)
-{
- int ret = 0;
- void *pos;
-
- /* seek over the buffer header if we are at the buffer start */
- if(tf->event.offset == 0) {
- tf->event.offset += tf->buffer_header_size;
-
- if(tf->event.offset == tf->buffer.data_size) {
- ret = ERANGE;
- }
- goto found;
- }
-
- pos = tf->event.data;
-
- if(tf->event.data_size < 0) goto error;
-
- pos += (size_t)tf->event.data_size;
-
- tf->event.offset = pos - tf->buffer.head;
-
- if(tf->event.offset >= tf->buffer.data_size) {
- ret = ERANGE;
- goto found;
- }
- g_assert(tf->event.offset < tf->buffer.data_size);
-
-found:
- return ret;
-
-error:
- g_error("Error in ltt_seek_next_event for tracefile %s",
- g_quark_to_string(tf->name));
- return ENOPROTOOPT;
-}
-
-
-/*****************************************************************************
- *Function name
- * ltt_get_int : get an integer number
- *Input params
- * reverse_byte_order: must we reverse the byte order ?
- * size : the size of the integer
- * ptr : the data pointer
- *Return value
- * gint64 : a 64 bits integer
- ****************************************************************************/
-
-gint64 ltt_get_int(gboolean reverse_byte_order, gint size, void *data)
-{
- gint64 val;
-
- switch(size) {
- case 1: val = *((gint8*)data); break;
- case 2: val = ltt_get_int16(reverse_byte_order, data); break;
- case 4: val = ltt_get_int32(reverse_byte_order, data); break;
- case 8: val = ltt_get_int64(reverse_byte_order, data); break;
- default: val = ltt_get_int64(reverse_byte_order, data);
- g_critical("get_int : integer size %d unknown", size);
- break;
- }
-
- return val;
-}
-
-/*****************************************************************************
- *Function name
- * ltt_get_uint : get an unsigned integer number
- *Input params
- * reverse_byte_order: must we reverse the byte order ?
- * size : the size of the integer
- * ptr : the data pointer
- *Return value
- * guint64 : a 64 bits unsigned integer
- ****************************************************************************/
-
-guint64 ltt_get_uint(gboolean reverse_byte_order, gint size, void *data)
-{
- guint64 val;
-
- switch(size) {
- case 1: val = *((gint8*)data); break;
- case 2: val = ltt_get_uint16(reverse_byte_order, data); break;
- case 4: val = ltt_get_uint32(reverse_byte_order, data); break;
- case 8: val = ltt_get_uint64(reverse_byte_order, data); break;
- default: val = ltt_get_uint64(reverse_byte_order, data);
- g_critical("get_uint : unsigned integer size %d unknown",
- size);
- break;
- }
-
- return val;
-}
-
-
-/* get the node name of the system */
-
-char * ltt_trace_system_description_node_name (LttSystemDescription * s)
-{
- return s->node_name;
-}
-
-
-/* get the domain name of the system */
-
-char * ltt_trace_system_description_domain_name (LttSystemDescription * s)
-{
- return s->domain_name;
-}
-
-
-/* get the description of the system */
-
-char * ltt_trace_system_description_description (LttSystemDescription * s)
-{
- return s->description;
-}
-
-
-/* get the NTP corrected start time of the trace */
-LttTime ltt_trace_start_time(LttTrace *t)
-{
- return t->start_time;
-}
-
-/* get the monotonic start time of the trace */
-LttTime ltt_trace_start_time_monotonic(LttTrace *t)
-{
- return t->start_time_from_tsc;
-}
-
-static __attribute__ ((__unused__)) LttTracefile *ltt_tracefile_new()
-{
- LttTracefile *tf;
- tf = g_new(LttTracefile, 1);
- tf->event.tracefile = tf;
- return tf;
-}
-
-static __attribute__ ((__unused__)) void ltt_tracefile_destroy(LttTracefile *tf)
-{
- g_free(tf);
-}
-
-static __attribute__ ((__unused__)) void ltt_tracefile_copy(LttTracefile *dest, const LttTracefile *src)
-{
- *dest = *src;
-}
-
-/* Before library loading... */
-
-static __attribute__((constructor)) void init(void)
-{
- LTT_TRACEFILE_NAME_METADATA = g_quark_from_string("metadata");
-}
-
-/*****************************************************************************
- *Function name
- * ltt_tracefile_open_header : based on ltt_tracefile_open but it stops
- * when it gets the header
- *Input params
- * fileName : path to the tracefile
- * tf : the tracefile (metadata_0) where the header will be read
- *Return value
- * ltt_subbuffer_header_t : the header containing the version number
- ****************************************************************************/
-static ltt_subbuffer_header_t * ltt_tracefile_open_header(gchar *fileName, LttTracefile *tf)
-{
- struct stat lTDFStat; /* Trace data file status */
- ltt_subbuffer_header_t *header;
- int page_size = getpagesize();
-
- /* open the file */
- tf->long_name = g_quark_from_string(fileName);
- tf->fd = open(fileName, O_RDONLY);
- if(tf->fd < 0){
- g_warning("Unable to open input data file %s\n", fileName);
- goto end;
- }
-
- /* Get the file's status */
- if(fstat(tf->fd, &lTDFStat) < 0){
- g_warning("Unable to get the status of the input data file %s\n", fileName);
- goto close_file;
- }
-
- /* Is the file large enough to contain a trace */
- if(lTDFStat.st_size < (off_t)(ltt_subbuffer_header_size())) {
- g_print("The input data file %s does not contain a trace\n", fileName);
- goto close_file;
- }
-
- /* Temporarily map the buffer start header to get trace information */
- /* Multiple of pages aligned head */
- tf->buffer.head = mmap(0,PAGE_ALIGN(ltt_subbuffer_header_size()), PROT_READ, MAP_PRIVATE, tf->fd, 0);
-
- if(tf->buffer.head == MAP_FAILED) {
- perror("Error in allocating memory for buffer of tracefile");
- goto close_file;
- }
- g_assert( ( (gulong)tf->buffer.head&(8-1) ) == 0); // make sure it's aligned.
-
- header = (ltt_subbuffer_header_t *)tf->buffer.head;
-
- return header;
-
- close_file:
- close(tf->fd);
- end:
- return 0;
-}
-
-
-/*****************************************************************************
- *Function name
- * get_version : get the trace version from a metadata_0 trace file
- *Input params
- * pathname : path to the trace
- * version_number : the struct that will get the version number
- *Return value
- * int : 1 if succeed, -1 if error
- ****************************************************************************/
-int ltt_get_trace_version(const gchar *pathname, struct LttTraceVersion *version_number)
-{
- gchar abs_path[PATH_MAX];
- int ret = 0;
- DIR *dir;
- struct dirent *entry;
- struct stat stat_buf;
- gchar path[PATH_MAX];
-
- LttTracefile tmp_tf;
- LttTrace * t;
- ltt_subbuffer_header_t *header;
-
- t = g_new(LttTrace, 1);
-
- get_absolute_pathname(pathname, abs_path);
-
- /* Test to see if it looks like a trace */
- dir = opendir(abs_path);
-
- if(dir == NULL) {
- perror(abs_path);
- goto open_error;
- }
-
- while((entry = readdir(dir)) != NULL) {
- strcpy(path, abs_path);
- strcat(path, "/");
- strcat(path, entry->d_name);
- ret = stat(path, &stat_buf);
- if(ret == -1) {
- perror(path);
- continue;
- }
- }
-
- closedir(dir);
- dir = opendir(abs_path);
-
- while((entry = readdir(dir)) != NULL) {
- if(entry->d_name[0] == '.') continue;
- if(g_str_has_prefix(entry->d_name, "metadata_") != 0) continue;
-
- strcpy(path, abs_path);
- strcat(path, "/");
- strcat(path, entry->d_name);
- if(ret == -1) {
- perror(path);
- continue;
- }
-
- header = ltt_tracefile_open_header(path, &tmp_tf);
-
- if(header == NULL) {
- g_info("Error getting the header %s", path);
- continue; /* error opening the tracefile : bad magic number ? */
- }
-
- version_number->ltt_major_version = header->major_version;
- version_number->ltt_minor_version = header->minor_version;
-
- return 1;
- }
-
- return -1;
-
- open_error:
- g_free(t);
- return -1;
-}