int latest_event; //the latest event using the event type
};
+struct _LttEvent{
+ guint16 event_id;
+ guint32 time_delta;
+ LttTime event_time;
+ LttCycleCount event_cycle_count;
+ LttTracefile * tracefile;
+ void * data; //event data
+ int which_block; //the current block of the event
+ int which_event; //the position of the event
+ /* This is a workaround for fast position seek */
+ void * last_event_pos;
+
+ LttTime prev_block_end_time; //the end time of previous block
+ LttTime prev_event_time; //the time of the previous event
+ LttCycleCount pre_cycle_count; //previous cycle count of the event
+ int count; //the number of overflow of cycle count
+ /* end of workaround */
+};
+
+
struct _LttField{
unsigned field_pos; //field position within its parent
LttType * field_type; //field type, if it is root field
unsigned current_element; //which element is currently processed
};
-struct _LttEvent{
- guint16 event_id;
- guint32 time_delta;
- LttTime event_time;
- LttCycleCount event_cycle_count;
- LttTracefile * tracefile;
- void * data; //event data
- int which_block; //the current block of the event
- int which_event; //the position of the event
- /* This is a workaround for fast position seek */
- void * last_event_pos;
-
- LttTime prev_block_end_time; //the end time of previous block
- LttTime prev_event_time; //the time of the previous event
- LttCycleCount pre_cycle_count; //previous cycle count of the event
- int count; //the number of overflow of cycle count
- /* end of workaround */
-};
struct _LttFacility{
char * name; //facility name
LttTime prev_block_end_time; //the end time of previous block
LttTime prev_event_time; //the time of the previous event
- LttEvent an_event;
LttCycleCount pre_cycle_count; //previous cycle count of the event
int count; //the number of overflow of cycle count
};
LttTime prev_block_end_time; //the end time of previous block
LttTime prev_event_time; //the time of the previous event
- LttEvent an_event;
LttCycleCount pre_cycle_count; //previous cycle count of the event
int count; //the number of overflow of cycle count
/* end of workaround */
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
-#include <linux/errno.h>
+#include <linux/errno.h>
// For realpath
#include <limits.h>
#include "ltt-private.h"
#include <ltt/trace.h>
#include <ltt/facility.h>
+#include <ltt/event.h>
#define DIR_NAME_SIZE 256
gint ltt_tracefile_open_control(LttTrace *t, char * control_name)
{
LttTracefile * tf;
- LttEvent * ev;
+ LttEvent ev;
LttFacility * f;
guint16 evId;
void * pos;
//parse facilities tracefile to get base_id
if(strcmp(&control_name[strlen(control_name)-10],"facilities") ==0){
while(1){
- ev = ltt_tracefile_read(tf);
- if(!ev)return 0; // end of file
+ if(!ltt_tracefile_read(tf,&ev)) return 0; // end of file
- if(ev->event_id == TRACE_FACILITY_LOAD){
- pos = ev->data;
+ if(ev.event_id == TRACE_FACILITY_LOAD){
+ pos = ev.data;
fLoad.name = (char*)pos;
fLoad.checksum = *(LttChecksum*)(pos + strlen(fLoad.name));
fLoad.base_code = *(guint32 *)(pos + strlen(fLoad.name) + sizeof(LttChecksum));
fLoad.name,fLoad.checksum);
return -1;
}
- }else if(ev->event_id == TRACE_BLOCK_START){
+ }else if(ev.event_id == TRACE_BLOCK_START){
continue;
- }else if(ev->event_id == TRACE_BLOCK_END){
+ }else if(ev.event_id == TRACE_BLOCK_END){
break;
}else {
g_warning("Not valid facilities trace file\n");
if(ltt_time_compare(endBig,endTmp) < 0) endBig = endTmp;
}
- *start = startSmall;
- *end = endBig;
+ if(start != NULL) *start = startSmall;
+ if(end != NULL) *end = endBig;
}
LttTime lttTime;
int headTime = ltt_time_compare(t->a_block_start->time, time);
int tailTime = ltt_time_compare(t->a_block_end->time, time);
- LttEvent * ev;
+ LttEvent ev;
if(headTime < 0 && tailTime > 0){
if(ltt_time_compare(t->a_block_end->time, t->current_event_time) !=0) {
}
}else if(err < 0){
while(1){
- ev = ltt_tracefile_read(t);
- if(ev == NULL){
+ if(ltt_tracefile_read(t,&ev) == NULL) {
g_print("End of file\n");
return;
}
//MD: warning : this is slow!
g_warning("using slow O(n) tracefile seek position");
- while(t->which_event < ep->event_num) ltt_tracefile_read(t);
+ LttEvent event;
+ while(t->which_event < ep->event_num) ltt_tracefile_read(t, &event);
return;
}
* LttEvent * : an event to be processed
****************************************************************************/
-LttEvent *ltt_tracefile_read(LttTracefile *t)
+LttEvent *ltt_tracefile_read(LttTracefile *t, LttEvent *event)
{
- LttEvent * lttEvent = &t->an_event;
int err;
if(t->cur_event_pos == t->buffer + t->block_size){
if(err)g_error("Can not read tracefile");
}
- lttEvent->event_id = (int)(*(guint16 *)(t->cur_event_pos));
- if(lttEvent->event_id == TRACE_TIME_HEARTBEAT)
+ event->event_id = (int)(*(guint16 *)(t->cur_event_pos));
+ if(event->event_id == TRACE_TIME_HEARTBEAT)
t->cur_heart_beat_number++;
t->prev_event_time = t->current_event_time;
// t->current_event_time = getEventTime(t);
- lttEvent->time_delta = *(guint32 *)(t->cur_event_pos + EVENT_ID_SIZE);
- lttEvent->event_time = t->current_event_time;
- lttEvent->event_cycle_count = t->cur_cycle_count;
+ event->time_delta = *(guint32 *)(t->cur_event_pos + EVENT_ID_SIZE);
+ event->event_time = t->current_event_time;
+ event->event_cycle_count = t->cur_cycle_count;
- lttEvent->tracefile = t;
- lttEvent->data = t->cur_event_pos + EVENT_HEADER_SIZE;
- lttEvent->which_block = t->which_block;
- lttEvent->which_event = t->which_event;
+ event->tracefile = t;
+ event->data = t->cur_event_pos + EVENT_HEADER_SIZE;
+ event->which_block = t->which_block;
+ event->which_event = t->which_event;
/* This is a workaround for fast position seek */
- lttEvent->last_event_pos = t->last_event_pos;
- lttEvent->prev_block_end_time = t->prev_block_end_time;
- lttEvent->prev_event_time = t->prev_event_time;
- lttEvent->pre_cycle_count = t->pre_cycle_count;
- lttEvent->count = t->count;
+ event->last_event_pos = t->last_event_pos;
+ event->prev_block_end_time = t->prev_block_end_time;
+ event->prev_event_time = t->prev_event_time;
+ event->pre_cycle_count = t->pre_cycle_count;
+ event->count = t->count;
/* end of workaround */
err = skipEvent(t);
if(err == ERANGE) g_error("event id is out of range\n");
- return lttEvent;
+ return event;
}
/****************************************************************************