some compile fix
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 24 Sep 2007 00:06:24 +0000 (00:06 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Mon, 24 Sep 2007 00:06:24 +0000 (00:06 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@2601 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt/Makefile.am
ltt/branches/poly/ltt/event.c
ltt/branches/poly/ltt/event.h
ltt/branches/poly/ltt/ltt-private.h
ltt/branches/poly/ltt/ltt.h
ltt/branches/poly/ltt/markers.h
ltt/branches/poly/ltt/trace.h
ltt/branches/poly/ltt/tracefile.c
ltt/branches/poly/lttv/lttv/batchtest.c
ltt/branches/poly/lttv/lttv/tracecontext.h

index 6fc70e3196dd26464a7fbb25f8527df0e7b9bac4..ba8efaed4852b8a83ed8aace3ee15ab48d92d6e2 100644 (file)
@@ -10,7 +10,7 @@ AM_CFLAGS = $(GLIB_CFLAGS)
 LIBS += $(GLIB_LIBS)
 
 lib_LTLIBRARIES = liblttvtraceread.la
-liblttvtraceread_la_SOURCES = tracefile.c markers.c
+liblttvtraceread_la_SOURCES = tracefile.c markers.c event.c
 noinst_HEADERS = ltt-private.h
 #event.c parser.c type.c
 #parser.h
index 0e87646e258c41d03500884144f2f76f0b709fc2..bcb013f172e94ef575033bd3e1f3f8b6ee7daeff 100644 (file)
@@ -1,115 +1,5 @@
-/* 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.
- */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <glib.h>
-
-#include <asm/types.h>
-#include <byteswap.h>
-
-#include "parser.h"
-#include <ltt/ltt.h>
-#include "ltt-private.h"
 #include <ltt/event.h>
-#include <ltt/trace.h>
-#include <ltt/ltt-types.h>
-#include <ltt/markers.h>
-
-
-void compute_fields_offsets(LttTracefile *tf,
-    LttFacility *fac, LttField *field, off_t *offset, void *root,
-    guint is_compact);
-
-
-LttEvent *ltt_event_new()
-{
-  return g_new(LttEvent, 1);
-}
-
-void ltt_event_destroy(LttEvent *event)
-{
-  g_free(event);
-}
-
-
-/*****************************************************************************
- *Function name
- *    ltt_event_eventtype_id: get event type id 
- *                            (base id + position of the event)
- *Input params
- *    e                     : an instance of an event type   
- *Return value
- *    unsigned              : event type id
- ****************************************************************************/
-
-uint16_t ltt_event_eventtype_id(const LttEvent *e)
-{
-  return e->event_id;
-}
-
-/*****************************************************************************
- *Function name
- *    ltt_event_facility : get the facility of the event
- *Input params
- *    e                  : an instance of an event type   
- *Return value
- *    struct marker_info *: the marker associated with the event
- ****************************************************************************/
-
-struct marker_info *ltt_event_marker(const LttEvent *e)
-{
-  return marker_get_info_from_id(e->tracefile->trace, e->event_id);
-}
-
-/*****************************************************************************
- *Function name
- *    ltt_event_time : get the time of the event
- *Input params
- *    e              : an instance of an event type   
- *Return value
- *    LttTime       : the time of the event
- ****************************************************************************/
-
-LttTime ltt_event_time(const LttEvent *e)
-{
-  return e->event_time;
-}
-
-/*****************************************************************************
- *Function name
- *    ltt_event_time : get the cycle count of the event
- *Input params
- *    e              : an instance of an event type   
- *Return value
- *    LttCycleCount  : the cycle count of the event
- ****************************************************************************/
-
-LttCycleCount ltt_event_cycle_count(const LttEvent *e)
-{
-  return e->tsc;
-}
 
 /*****************************************************************************
  *Function name
@@ -227,514 +117,3 @@ LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep)
   return ep->tracefile;
 }
 
-/*****************************************************************************
- *Function name
- *    ltt_event_cpu_i: get the cpu id where the event happens
- *Input params
- *    e              : an instance of an event type   
- *Return value
- *    unsigned       : the cpu id
- ****************************************************************************/
-
-unsigned ltt_event_cpu_id(LttEvent *e)
-{
-  return e->tracefile->cpu_num;
-}
-
-/*****************************************************************************
- *Function name
- *    ltt_event_data : get the raw data for the event
- *Input params
- *    e              : an instance of an event type   
- *Return value
- *    void *         : pointer to the raw data for the event
- ****************************************************************************/
-
-void *ltt_event_data(LttEvent *e)
-{
-  return e->data;
-}
-
-/*****************************************************************************
- *Function name
- *    ltt_event_field_element_number
- *                   : The number of elements in a sequence field is specific
- *                     to each event. This function returns the number of 
- *                     elements for an array or sequence field in an event.
- *Input params
- *    e              : an instance of an event type
- *    f              : a field of the instance
- *Return value
- *    unsigned       : the number of elements for an array/sequence field
- ****************************************************************************/
-guint64 ltt_event_field_element_number(LttEvent *e, LttField *f)
-{
-  if(f->field_type.type_class != LTT_ARRAY &&
-     f->field_type.type_class != LTT_SEQUENCE)
-    return 0;
-  
-  if(f->field_type.type_class == LTT_ARRAY)
-    return f->field_type.size;
-  return ltt_event_get_long_unsigned(e, &g_array_index(f->field_type.fields,
-                                                 LttField, 0));
-}
-
-/*****************************************************************************
- *Function name
- *    ltt_event_field_element_select
- *                   : Set the currently selected element for a sequence or
- *                     array field
- *                     O(1) because of offset array.
- *Input params
- *    e              : an instance of an event type
- *    f              : a field of the instance
- *    i              : the ith element (0, ...)
- *returns : the child field, at the right index, updated.
- ****************************************************************************/
-LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i)
-{
-  gulong element_number;
-  LttField *field;
-  unsigned int k;
-  size_t size;
-  LttEventType *event_type;
-  off_t new_offset;
-  if(f->field_type.type_class != LTT_ARRAY &&
-     f->field_type.type_class != LTT_SEQUENCE)
-    return NULL;
-
-  element_number  = ltt_event_field_element_number(e,f);
-  event_type = ltt_event_eventtype(e);
-  /* Sanity check for i : 0..n-1 only, and must be lower or equal element_number
-   */
-  if(i >= element_number) return NULL;
-  if(f->field_type.type_class == LTT_ARRAY) {
-   field = &g_array_index(f->field_type.fields, LttField, 0);
-  } else {
-   field = &g_array_index(f->field_type.fields, LttField, 1);
-  }
-
-  if(field->field_size != 0) {
-    if(f->array_offset + (i * field->field_size) == field->offset_root)
-      return field; /* fixed length child, already at the right offset */
-    else
-      new_offset = f->array_offset + (i * field->field_size);
-  } else {
-    /* Var. len. child */
-    new_offset = g_array_index(f->dynamic_offsets, off_t, i);
-  }
-  compute_fields_offsets(e->tracefile, 
-      ltt_event_facility(e), field, &new_offset, e->data, 0);
-
-  return field;
-}
-
-
-off_t ltt_event_field_offset(LttEvent *e, LttField *f)
-{
-  return f->offset_root;
-}
-
-
-
-/*****************************************************************************
- * These functions extract data from an event after architecture specific
- * conversions
- ****************************************************************************/
-guint32 ltt_event_get_unsigned(LttEvent *e, LttField *f)
-{
-  gboolean reverse_byte_order;
-  if(unlikely(f->field_type.network)) {
-    reverse_byte_order = (g_ntohs(0x1) != 0x1);
-  } else {
-    reverse_byte_order = LTT_GET_BO(e->tracefile);
-  }
-
-  switch(f->field_size) {
-  case 1:
-    {
-      guint8 x = *(guint8 *)(e->data + f->offset_root);
-      return (guint32) x;    
-    }
-    break;
-  case 2:
-    return (guint32)ltt_get_uint16(reverse_byte_order, e->data + f->offset_root);
-    break;
-  case 4:
-    return (guint32)ltt_get_uint32(reverse_byte_order, e->data + f->offset_root);
-    break;
-  case 8:
-  default:
-    g_critical("ltt_event_get_unsigned : field size %i unknown", f->field_size);
-    return 0;
-    break;
-  }
-}
-
-gint32 ltt_event_get_int(LttEvent *e, LttField *f)
-{
-  gboolean reverse_byte_order;
-  if(unlikely(f->field_type.network)) {
-    reverse_byte_order = (g_ntohs(0x1) != 0x1);
-  } else {
-    reverse_byte_order = LTT_GET_BO(e->tracefile);
-  }
-
-  switch(f->field_size) {
-  case 1:
-    {
-      gint8 x = *(gint8 *)(e->data + f->offset_root);
-      return (gint32) x;    
-    }
-    break;
-  case 2:
-    return (gint32)ltt_get_int16(reverse_byte_order, e->data + f->offset_root);
-    break;
-  case 4:
-    return (gint32)ltt_get_int32(reverse_byte_order, e->data + f->offset_root);
-    break;
-  case 8:
-  default:
-    g_critical("ltt_event_get_int : field size %i unknown", f->field_size);
-    return 0;
-    break;
-  }
-}
-
-guint64 ltt_event_get_long_unsigned(LttEvent *e, LttField *f)
-{
-  gboolean reverse_byte_order;
-  if(unlikely(f->field_type.network)) {
-    reverse_byte_order = (g_ntohs(0x1) != 0x1);
-  } else {
-    reverse_byte_order = LTT_GET_BO(e->tracefile);
-  }
-  
-  switch(f->field_size) {
-  case 1:
-    {
-      guint8 x = *(guint8 *)(e->data + f->offset_root);
-      return (guint64) x;    
-    }
-    break;
-  case 2:
-    return (guint64)ltt_get_uint16(reverse_byte_order, e->data + f->offset_root);
-    break;
-  case 4:
-    return (guint64)ltt_get_uint32(reverse_byte_order, e->data + f->offset_root);
-    break;
-  case 8:
-    return ltt_get_uint64(reverse_byte_order, e->data + f->offset_root);
-    break;
-  default:
-    g_critical("ltt_event_get_long_unsigned : field size %i unknown", f->field_size);
-    return 0;
-    break;
-  }
-}
-
-gint64 ltt_event_get_long_int(LttEvent *e, LttField *f)
-{
-  gboolean reverse_byte_order;
-  if(unlikely(f->field_type.network)) {
-    reverse_byte_order = (g_ntohs(0x1) != 0x1);
-  } else {
-    reverse_byte_order = LTT_GET_BO(e->tracefile);
-  }
-  
-  switch(f->field_size) {
-  case 1:
-    {
-      gint8 x = *(gint8 *)(e->data + f->offset_root);
-      return (gint64) x;    
-    }
-    break;
-  case 2:
-    return (gint64)ltt_get_int16(reverse_byte_order, e->data + f->offset_root);
-    break;
-  case 4:
-    return (gint64)ltt_get_int32(reverse_byte_order, e->data + f->offset_root);
-    break;
-  case 8:
-    return ltt_get_int64(reverse_byte_order, e->data + f->offset_root);
-    break;
-  default:
-    g_critical("ltt_event_get_long_int : field size %i unknown", f->field_size);
-    return 0;
-    break;
-  }
-}
-
-float ltt_event_get_float(LttEvent *e, LttField *f)
-{
-  gboolean reverse_byte_order;
-  if(unlikely(f->field_type.network)) {
-    reverse_byte_order = (g_ntohs(0x1) != 0x1);
-  } else {
-    g_assert(LTT_HAS_FLOAT(e->tracefile));
-    reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
-  }
-
-  g_assert(f->field_type.type_class == LTT_FLOAT && f->field_size == 4);
-
-  if(reverse_byte_order == 0) return *(float *)(e->data + f->offset_root);
-  else{
-    void *ptr = e->data + f->offset_root;
-    guint32 value = bswap_32(*(guint32*)ptr);
-    return *(float*)&value;
-  }
-}
-
-double ltt_event_get_double(LttEvent *e, LttField *f)
-{
-  gboolean reverse_byte_order;
-  if(unlikely(f->field_type.network)) {
-    reverse_byte_order = (g_ntohs(0x1) != 0x1);
-  } else {
-    g_assert(LTT_HAS_FLOAT(e->tracefile));
-    reverse_byte_order = LTT_GET_FLOAT_BO(e->tracefile);
-  }
-
-  if(f->field_size == 4)
-    return ltt_event_get_float(e, f);
-    
-  g_assert(f->field_type.type_class == LTT_FLOAT && f->field_size == 8);
-
-  if(reverse_byte_order == 0) return *(double *)(e->data + f->offset_root);
-  else {
-    void *ptr = e->data + f->offset_root;
-    guint64 value = bswap_64(*(guint64*)ptr);
-    return *(double*)&value;
-  }
-}
-
-/*****************************************************************************
- * The string obtained is only valid until the next read from
- * the same tracefile.
- ****************************************************************************/
-char *ltt_event_get_string(LttEvent *e, LttField *f)
-{
-  g_assert(f->field_type.type_class == LTT_STRING);
-
-  return (gchar*)g_strdup((gchar*)(e->data + f->offset_root));
-}
-
-/*****************************************************************************
- *Function name
- *    compute_fields_offsets : set the precomputable offset of the fields
- *Input params 
- *    fac : facility
- *    field : the field
- *    offset : pointer to the current offset, must be incremented
- ****************************************************************************/
-
-#if 0
-void compute_fields_offsets(LttTracefile *tf, 
-    LttFacility *fac, LttField *field, off_t *offset, void *root, guint is_compact)
-{
-  LttType *type = &field->field_type;
-
-  if(unlikely(is_compact)) {
-    g_assert(field->field_size != 0);
-    /* FIXME THIS IS A HUUUUUGE hack :
-     * offset is between the compact_data field in struct LttEvent
-     * and the address of the field root in the memory map.
-     * ark. Both will stay at the same addresses while the event
-     * is readable, so it's ok.
-     */
-    field->offset_root = (unsigned long)(&tf->event.compact_data)
-                               - (unsigned long)root;
-    field->fixed_root = FIELD_FIXED;
-    return;
-  }
-
-  switch(type->type_class) {
-    case LTT_INT_FIXED:
-    case LTT_UINT_FIXED:
-    case LTT_POINTER:
-    case LTT_CHAR:
-    case LTT_UCHAR:
-    case LTT_SHORT:
-    case LTT_USHORT:
-    case LTT_INT:
-    case LTT_UINT:
-    case LTT_LONG:
-    case LTT_ULONG:
-    case LTT_SIZE_T:
-    case LTT_SSIZE_T:
-    case LTT_OFF_T:
-    case LTT_FLOAT:
-    case LTT_ENUM:
-      if(field->fixed_root == FIELD_VARIABLE) {
-        /* Align offset on type size */
-        *offset += ltt_align(*offset, get_alignment(field),
-                             fac->alignment);
-        /* remember offset */
-        field->offset_root = *offset;
-        /* Increment offset */
-        *offset += field->field_size;
-      } else {
-        //g_debug("type before offset : %llu %llu %u\n", *offset,
-        //    field->offset_root,
-        //    field->field_size);
-        *offset = field->offset_root;
-        *offset += field->field_size;
-        //g_debug("type after offset : %llu\n", *offset);
-      }
-      break;
-    case LTT_STRING:
-      if(field->fixed_root == FIELD_VARIABLE) {
-        field->offset_root = *offset;
-      }
-      *offset += strlen((gchar*)(root+*offset)) + 1;
-      /* Realign the data */
-      *offset += ltt_align(*offset, fac->pointer_size,
-                           fac->alignment);
-      break;
-    case LTT_ARRAY:
-      g_assert(type->fields->len == 1);
-      {
-        off_t local_offset;
-        LttField *child = &g_array_index(type->fields, LttField, 0);
-        if(field->fixed_root == FIELD_VARIABLE) {
-          *offset += ltt_align(*offset, get_alignment(field),
-                              fac->alignment);
-          /* remember offset */
-          field->offset_root = *offset;
-          field->array_offset = *offset;
-        }
-     
-        if(field->field_size != 0) {
-          /* Increment offset */
-          /* field_size is the array size in bytes */
-          *offset = field->offset_root + field->field_size;
-        } else {
-          guint i;
-          *offset = field->array_offset;
-          field->dynamic_offsets = g_array_set_size(field->dynamic_offsets,
-                                                    0);
-          for(i=0; i<type->size; i++) {
-            g_array_append_val(field->dynamic_offsets, *offset);
-            compute_fields_offsets(tf, fac, child, offset, root, is_compact);
-          }
-        }
-  //      local_offset = field->array_offset;
-  //      /* Set the offset at position 0 */
-  //      compute_fields_offsets(tf, fac, child, &local_offset, root);
-      }
-      break;
-    case LTT_SEQUENCE:
-      g_assert(type->fields->len == 2);
-      {
-        off_t local_offset;
-        LttField *child;
-        guint i;
-        guint num_elem;
-        if(field->fixed_root == FIELD_VARIABLE) {
-          *offset += ltt_align(*offset, get_alignment(field),
-                              fac->alignment);
-          /* remember offset */
-          field->offset_root = *offset;
-
-          child = &g_array_index(type->fields, LttField, 0);
-          compute_fields_offsets(tf, fac, child, offset, root, is_compact);
-          child = &g_array_index(type->fields, LttField, 1);
-          *offset += ltt_align(*offset, get_alignment(child),
-                               fac->alignment);
-          field->array_offset = *offset;
-
-        } else {
-          child = &g_array_index(type->fields, LttField, 1);
-        }
-        *offset = field->array_offset;
-        field->dynamic_offsets = g_array_set_size(field->dynamic_offsets,
-                                                  0);
-        num_elem = ltt_event_field_element_number(&tf->event, field);
-        for(i=0; i<num_elem; i++) {
-          g_array_append_val(field->dynamic_offsets, *offset);
-          compute_fields_offsets(tf, fac, child, offset, root, is_compact);
-        }
-        g_assert(num_elem == field->dynamic_offsets->len);
-
-        /* Realign the data */
-        *offset += ltt_align(*offset, fac->pointer_size,
-                             fac->alignment);
-        
- //       local_offset = field->array_offset;
- //       /* Set the offset at position 0 */
- //       compute_fields_offsets(tf, fac, child, &local_offset, root);
-      }
-      break;
-    case LTT_STRUCT:
-      { 
-        LttField *child;
-        guint i;
-        gint ret=0;
-        if(field->fixed_root == FIELD_VARIABLE) {
-          *offset += ltt_align(*offset, get_alignment(field),
-                               fac->alignment);
-          /* remember offset */
-          field->offset_root = *offset;
-        } else {
-          *offset = field->offset_root;
-        }
-        for(i=0; i<type->fields->len; i++) {
-          child = &g_array_index(type->fields, LttField, i);
-          compute_fields_offsets(tf, fac, child, offset, root, is_compact);
-        }
-      }
-      break;
-    case LTT_UNION:
-      { 
-        LttField *child;
-        guint i;
-        gint ret=0;
-        if(field->fixed_root == FIELD_VARIABLE) {
-          *offset += ltt_align(*offset, get_alignment(field),
-                               fac->alignment);
-          /* remember offset */
-          field->offset_root = *offset;
-        }
-        for(i=0; i<type->fields->len; i++) {
-          *offset = field->offset_root;
-          child = &g_array_index(type->fields, LttField, i);
-          compute_fields_offsets(tf, fac, child, offset, root, is_compact);
-        }
-        *offset = field->offset_root + field->field_size;
-      }
-      break;
-    case LTT_NONE:
-    default:
-      g_error("compute_fields_offsets : unknown type");
-  }
-
-}
-
-
-/*****************************************************************************
- *Function name
- *    compute_offsets : set the dynamically computable offsets of an event type
- *Input params 
- *    tf : tracefile
- *    event : event type
- *
- ****************************************************************************/
-void compute_offsets(LttTracefile *tf, LttFacility *fac,
-    LttEventType *event, off_t *offset, void *root)
-{
-  guint i;
-
-  /* compute all variable offsets */
-  for(i=0; i<event->fields->len; i++) {
-    //g_debug("computing offset %u of %u\n", i, event->fields->len-1);
-    LttField *field = &g_array_index(event->fields, LttField, i);
-    if(event->has_compact_data && i == 0)
-           compute_fields_offsets(tf, fac, field, offset, root, 1);
-    else
-           compute_fields_offsets(tf, fac, field, offset, root, 0);
-  }
-
-}
-#endif //0
index 79ceed5288df68e1dd00974deeceb3f35b3c1611..b45595d9150c2bb4194f6317fc6c28509720aec5 100644 (file)
@@ -1,54 +1,61 @@
-/* This file is part of the Linux Trace Toolkit trace reading library
- * Copyright (C) 2003-2004 Michel Dagenais
- *               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 EVENT_H
-#define EVENT_H
+#ifndef _LTT_EVENT_H
+#define _LTT_EVENT_H
 
+#include <ltt/time.h>
 #include <glib.h>
-#include <ltt/ltt.h>
+#include <stdint.h>
 #include <sys/types.h>
-#include <ltt/markers.h>
-
-LttEvent *ltt_event_new();
-
-void ltt_event_destroy(LttEvent *event);
-
-/* Events and their content, including the raw data, are only valid 
-   until reading another event from the same tracefile. 
-   Indeed, since event reading is critical to the performance, 
-   the memory associated with an event may be reused at each read. */
-
-/* Obtain the trace unique integer id associated with the type of 
-   this event */
-
-uint16_t ltt_event_eventtype_id(const LttEvent *e);
-
-struct marker_info *ltt_event_marker(const LttEvent *e);
-
-LttEventType *ltt_event_eventtype(const LttEvent *e);
-
-/* Time and cycle count for the event */
-
-LttTime ltt_event_time(const LttEvent *e);
-
-LttCycleCount ltt_event_cycle_count(const LttEvent *e);
+#include <ltt/ltt.h>
+#include <endian.h>
 
+/*
+ * 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 */
+       guint data_size;
+       guint event_size;       /* event_size field of the header :
+                                  used to verify data_size from facility. */
+       uint32_t compact_data;
+
+       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(struct LttEvent *event)
+{
+       return event->event_id;
+}
+
+static inline LttTime ltt_event_time(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
@@ -75,59 +82,4 @@ void ltt_event_position_copy(LttEventPosition *dest,
 
 LttTracefile *ltt_event_position_tracefile(LttEventPosition *ep);
 
-/* CPU id of the event */
-
-unsigned ltt_event_cpu_id(LttEvent *e);
-
-
-/* Pointer to the raw data for the event. This should not be used directly
-   unless prepared to do all the architecture specific conversions. */
-
-void *ltt_event_data(LttEvent *e);
-
-
-/* The number of elements in a sequence field is specific to each event 
-   instance. This function returns the number of elements for an array or 
-   sequence field in an event. */
-
-guint64 ltt_event_field_element_number(LttEvent *e, LttField *f);
-
-
-/* Set the currently selected element for a sequence or array field. */
-
-LttField *ltt_event_field_element_select(LttEvent *e, LttField *f, gulong i);
-
-off_t ltt_event_field_offset(LttEvent *e, LttField *f);
-
-/* A union is like a structure except that only a single member at a time
-   is present depending on the specific event instance. This function tells
-   the active member for a union field in an event. */
-
-unsigned ltt_event_field_union_member(LttEvent *e, LttField *f);
-
-
-/* These functions extract data from an event after architecture specific
-   conversions. */
-
-guint32 ltt_event_get_unsigned(LttEvent *e, LttField *f);
-
-gint32 ltt_event_get_int(LttEvent *e, LttField *f);
-
-guint64 ltt_event_get_long_unsigned(LttEvent *e, LttField *f);
-
-gint64 ltt_event_get_long_int(LttEvent *e, LttField *f);
-
-float ltt_event_get_float(LttEvent *e, LttField *f);
-
-double ltt_event_get_double(LttEvent *e, LttField *f);
-
-
-/* The string obtained is only valid until the next read from
-   the same tracefile. */
-
-gchar *ltt_event_get_string(LttEvent *e, LttField *f);
-
-void compute_offsets(LttTracefile *tf, LttFacility *fac,
-    LttEventType *event, off_t *offset, void *root);
-
-#endif // EVENT_H
+#endif //_LTT_EVENT_H
index 91ee9347b59d97a0e65190e2f0df203bdd3a76bb..c37fd0b0fc7e0811875b5e4beb10da783f8e892f 100644 (file)
@@ -24,6 +24,9 @@
 #include <sys/types.h>
 #include <ltt/ltt.h>
 #include <endian.h>
+#include <ltt/event.h>
+#include <ltt/markers.h>
+#include <ltt/trace.h>
 
 #ifndef max
 #define max(a,b) ((a)>(b)?(a):(b))
@@ -233,46 +236,6 @@ struct _LttEventType{
 };
 #endif //0
 
-/* 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
-  guint  data_size;
-  guint  event_size;         //event_size field of the header : 
-                             //used to verify data_size from facility.
-  uint32_t compact_data;
-
-  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 */
-};
-
-
 enum field_status { FIELD_UNKNOWN, FIELD_VARIABLE, FIELD_FIXED };
 
 #if 0
@@ -341,7 +304,7 @@ typedef struct _LttBuffer {
   guint32                 cyc2ns_scale;
 } LttBuffer;
 
-struct _LttTracefile{
+struct LttTracefile {
   gboolean cpu_online;               //is the cpu online ?
   GQuark long_name;                  //tracefile complete filename
   GQuark name;                       //tracefile name
@@ -388,40 +351,10 @@ struct _LttTracefile{
   //LttCycleCount pre_cycle_count;     //previous cycle count of the event
 };
 
-struct _LttTrace{
-  GQuark pathname;                          //the pathname of the trace
-  //LttSystemDescription * system_description;//system description 
-
-  GArray *facilities_by_num;            /* fac_id as index in array */
-  GData *facilities_by_name;            /* fac name (GQuark) as index */
-                                        /* Points to array of fac_id of all the
-                                        * facilities that has this name. */
-  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;
-  LttTime   start_time;
-  LttTime   start_time_from_tsc;
-  uint8_t   compact_event_bits;
-
-  GData     *tracefiles;                    //tracefiles groups
-  /* Support for markers */
-  GArray    *markers;                       //indexed by marker ID
-  GHashTable *markers_hash;                 //indexed by name hash
-};
-
 /* The characteristics of the system on which the trace was obtained
    is described in a LttSystemDescription structure. */
 
-struct _LttSystemDescription {
+struct LttSystemDescription {
   gchar *description;
   gchar *node_name;
   gchar *domain_name;
@@ -449,7 +382,7 @@ struct _LttSystemDescription {
 //#define EVENT_HEADER_SIZE (TIMESTAMP_SIZE + EVENT_ID_SIZE)
 
 
-off_t get_alignment(LttField *field);
+//off_t get_alignment(LttField *field);
 
 /* Calculate the offset needed to align the type.
  * If has_alignment is 0, alignment is disactivated.
index 357500109239b3e4f9ab78f73f20dd0076e00f61..423d7cd276729fbc456e1b171fb2ba37c752d53c 100644 (file)
 #define FACILITIES_BITS 8
 #define AVG_EVENTS_PER_FACILITIES 10
 
-typedef struct _LttTrace LttTrace;
+typedef struct LttTrace LttTrace;
 
-typedef struct _LttTracefile LttTracefile;
+typedef struct LttTracefile LttTracefile;
 
-typedef struct _LttFacility LttFacility;
-
-typedef struct _LttEventType LttEventType;
-
-typedef struct _LttType LttType;
-
-typedef struct _LttField LttField;
-
-typedef struct _LttEvent LttEvent;
-
-typedef struct _LttSystemDescription LttSystemDescription;
+typedef struct LttSystemDescription LttSystemDescription;
 
+typedef struct LttEvent LttEvent;
 
 /* Checksums are used to differentiate facilities which have the same name
    but differ. */
@@ -110,11 +101,10 @@ typedef struct _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;
+typedef struct LttEventPosition LttEventPosition;
 
 
 /* Differences between architectures include word sizes, endianess,
index be2f847ed93c3c5e4dee05cc50f1d4c3a648f435..48bbd5bd5128d0c65df1f3f06141d5fbdbd7ce5f 100644 (file)
@@ -11,8 +11,8 @@
 #include <glib.h>
 #include <ltt/trace.h>
 #include <ltt/compiler.h>
-#include <ltt/ltt-private.h>
 #include <ltt/markers-field.h>
+#include <ltt/trace.h>
 
 #define LTT_ATTRIBUTE_COMPACT (1<<0)
 #define LTT_ATTRIBUTE_NETWORK_BYTE_ORDER (1<<1)
index 85dfe866506c4aa00688b4f9dbfbfa948b3fa340..5266b227b023de0965ead98240c42d90b8aa5e60 100644 (file)
 #define TRACE_H
 
 #include <ltt/ltt.h>
+#include <stdint.h>
+#include <glib.h>
+
+struct LttTrace {
+  GQuark pathname;                          //the pathname of the trace
+  //LttSystemDescription * system_description;//system description 
+
+  GArray *facilities_by_num;            /* fac_id as index in array */
+  GData *facilities_by_name;            /* fac name (GQuark) as index */
+                                        /* Points to array of fac_id of all the
+                                        * facilities that has this name. */
+  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;
+  LttTime   start_time;
+  LttTime   start_time_from_tsc;
+  uint8_t   compact_event_bits;
+
+  GData     *tracefiles;                    //tracefiles groups
+  /* Support for markers */
+  GArray    *markers;                       //indexed by marker ID
+  GHashTable *markers_hash;                 //indexed by name hash
+};
+
+
 
 extern GQuark LTT_FACILITY_NAME_HEARTBEAT,
               LTT_EVENT_NAME_HEARTBEAT,
@@ -59,18 +93,18 @@ LttSystemDescription *ltt_trace_system_description(LttTrace *t);
    versions of a facility (same name, different checksum) have consecutive
    positions. */
 
-unsigned ltt_trace_facility_number(LttTrace *t);
+//unsigned ltt_trace_facility_number(LttTrace *t);
 
-LttFacility * ltt_trace_facility_by_id(LttTrace * trace, guint8 id);
+//LttFacility * ltt_trace_facility_by_id(LttTrace * trace, guint8 id);
 
 /* Returns an array of indexes (guint) that matches the facility name */
-GArray *ltt_trace_facility_get_by_name(LttTrace *t, GQuark name);
+//GArray *ltt_trace_facility_get_by_name(LttTrace *t, GQuark name);
 
 /* Functions to discover all the event types in the trace */
 
-unsigned ltt_trace_eventtype_number(LttTrace *t);
+//unsigned ltt_trace_eventtype_number(LttTrace *t);
 
-LttEventType *ltt_trace_eventtype_get(LttTrace *t, unsigned i);
+//LttEventType *ltt_trace_eventtype_get(LttTrace *t, unsigned i);
 
 
 /* Get the start time and end time of the trace */
@@ -177,12 +211,12 @@ void compute_tracefile_group(GQuark key_id,
                              GArray *group,
                              struct compute_tracefile_group_args *args);
 
-LttFacility *ltt_trace_get_facility_by_num(LttTrace *t, guint num);
+//LttFacility *ltt_trace_get_facility_by_num(LttTrace *t, guint num);
 
 
-gint check_fields_compatibility(LttEventType *event_type1,
-    LttEventType *event_type2,
-    LttField *field1, LttField *field2);
+//gint check_fields_compatibility(LttEventType *event_type1,
+//    LttEventType *event_type2,
+//    LttField *field1, LttField *field2);
 
 gint64 ltt_get_int(gboolean reverse_byte_order, gint size, void *data);
 
index d58ef3eb8e34fa01c837b92b1dd70727f8053684..df02f4be3b2860c1706d068af955b37dc63a5601 100644 (file)
@@ -45,9 +45,8 @@
 #include <ltt/ltt.h>
 #include "ltt-private.h"
 #include <ltt/trace.h>
-#include <ltt/facility.h>
 #include <ltt/event.h>
-#include <ltt/type.h>
+//#include <ltt/type.h>
 #include <ltt/ltt-types.h>
 #include <ltt/markers.h>
 
@@ -1058,10 +1057,10 @@ static void ltt_fac_ids_destroy(gpointer data)
 int ltt_process_facility_tracefile(LttTracefile *tf)
 {
   int err;
-  LttFacility *fac;
-  GArray *fac_ids;
+  //LttFacility *fac;
+  //GArray *fac_ids;
   guint i;
-  LttEventType *et;
+  //LttEventType *et;
   
   while(1) {
     err = ltt_tracefile_read_seek(tf);
index 0a0c519beff2ac8b2647f480870fc56dc0803e0c..ba4e00a96750972b25655a87521623039d34835c 100644 (file)
@@ -35,8 +35,6 @@
 #include <lttv/stats.h>
 #include <ltt/trace.h>
 #include <ltt/event.h>
-#include <ltt/type.h>
-#include <ltt/facility.h>
 
 #define __UNUSED__ __attribute__((__unused__))
 
@@ -173,7 +171,8 @@ gboolean trace_event(void __UNUSED__ *hook_data, void *call_data)
   ltt_event_position(e, a_event_position);
   ltt_event_position_get(a_event_position, &tf, &nb_block, &offset, &tsc);
   fprintf(stderr,"Event %s %lu.%09lu [%u 0x%x tsc %llu]\n",
-      g_quark_to_string(ltt_eventtype_name(ltt_event_eventtype(e))),
+      g_quark_to_string(marker_get_info_from_id(ltt_tracefile_get_trace(tf),
+                       ltt_event_id(e))->name),
       tfs->parent.timestamp.tv_sec, tfs->parent.timestamp.tv_nsec,
       nb_block, offset, tsc);
   return FALSE;
@@ -298,7 +297,8 @@ static void compute_tracefile(LttTracefile *tracefile, void *hook_data)
   FILE *fp;
   LttTime time, previous_time;
   LttEvent *event = ltt_tracefile_get_event(tracefile);
-  LttEventType *event_type;
+  //LttEventType *event_type;
+  struct marker_info *minfo;
   int err;
   gchar mod_name[PATH_MAX];
 
@@ -327,14 +327,15 @@ static void compute_tracefile(LttTracefile *tracefile, void *hook_data)
 
   do {
     LttTracefile *tf_pos;
-    event_type = ltt_event_eventtype(event);
+    //event_type = ltt_event_eventtype(event);
+    minfo = marker_get_info_from_id(ltt_tracefile_get_trace(tracefile),
+                                       ltt_event_id(event));
     time = ltt_event_time(event);
     ltt_event_position(event, a_event_position);
     ltt_event_position_get(a_event_position, &tf_pos, &nb_block, &offset, &tsc);
     //fprintf(fp,"%s.%s: %llu %lu.%09lu position %u/%u\n", 
-    fprintf(fp, "%s.%s: %llu %lu.%09lu position %u/%u, tracefile %s\n", 
-        g_quark_to_string(ltt_facility_name(facility)),
-        g_quark_to_string(ltt_eventtype_name(event_type)),
+    fprintf(fp, "%s: %llu %lu.%09lu position %u/%u, tracefile %s\n", 
+       g_quark_to_string(minfo->name),
         tsc, (unsigned long)time.tv_sec, 
         (unsigned long)time.tv_nsec, 
         nb_block, offset,
@@ -373,7 +374,8 @@ static void compute_tracefile(LttTracefile *tracefile, void *hook_data)
     }
     else {
 #endif //0
-      if(ltt_time_compare(time, previous_time) == 0) nb_equal++;
+      if(ltt_time_compare(time, previous_time) == 0)
+       nb_equal++;
       else if(nb_equal > 0) {
         g_warning("Consecutive %d events with time %lu.%09lu",
                    nb_equal + 1, previous_time.tv_sec, previous_time.tv_nsec);
index c279116903918827259a67b382b2006bbdf048fb..4413a5230cc49ca417a899b9a76a1bb2deeafbfb 100644 (file)
@@ -275,9 +275,9 @@ void lttv_tracefile_context_remove_hooks_by_id(LttvTracefileContext *self,
 typedef struct _LttvTraceHook {
   LttvHook h;
   guint id;
-  LttField *f1;
-  LttField *f2;
-  LttField *f3;
+  struct marker_field *f1;
+  struct marker_field *f2;
+  struct marker_field *f3;
   gpointer hook_data;
 } LttvTraceHook;
 
This page took 0.037925 seconds and 4 git commands to generate.