X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Ftracefile.c;h=f1751514d51f85bf090665744596f1ade3bc7db6;hb=b333a76ba95c2cf818eda8d96a925f0e3712edb5;hp=925092645ea8cfa058d386154c46ca0b73d59bb8;hpb=8710c6c7ff79301b4802e595c25d2cdb43af8154;p=lttv.git diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index 92509264..f1751514 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -158,8 +158,8 @@ void ltt_tracefile_open_control(LttTrace *t, char * control_name) if(ev->event_id == TRACE_FACILITY_LOAD){ pos = ev->data; fLoad.name = (char*)pos; - fLoad.checksum = *(LttChecksum*)(pos + sizeof(pos)); - fLoad.base_code = *(uint32_t*)(pos + sizeof(pos) + sizeof(LttChecksum)); + fLoad.checksum = *(LttChecksum*)(pos + strlen(fLoad.name)); + fLoad.base_code = *(uint32_t*)(pos + strlen(fLoad.name) + sizeof(LttChecksum)); for(i=0;ifacility_number;i++){ f = (LttFacility*)g_ptr_array_index(t->facilities,i); @@ -477,15 +477,15 @@ LttTrace *ltt_trace_open(char *pathname) strcat(tmp,"system.xml"); getSystemInfo(sys_description, tmp); + //get facilities info + getFacilityInfo(t,eventdefs); + //get control tracefile info getControlFileInfo(t,control); //get cpu tracefile info getCpuFileInfo(t,cpu); - //get facilities info - getFacilityInfo(t,eventdefs); - return t; } @@ -790,7 +790,8 @@ LttEvent *ltt_tracefile_read(LttTracefile *t) //update the fields of the current event and go to the next event err = skipEvent(t); - if(err == ENOENT) return NULL; + if(err == ENOMEM) return NULL; + if(err == ENOENT) return lttEvent; if(err == ERANGE) g_error("event id is out of range\n"); if(err)g_error("Can not read tracefile\n"); @@ -904,7 +905,8 @@ void updateTracefile(LttTracefile * tf) * 0 : success * EINVAL : lseek fail * EIO : can not read from the file - * ENOENT : end of file + * ENOMEM : end of file + * ENOENT : last event * ERANGE : event id is out of range ****************************************************************************/ @@ -914,27 +916,51 @@ int skipEvent(LttTracefile * t) void * evData; LttEventType * evT; LttField * rootFld; + static int evCount = 0; + + if(evCount){ + if(t->which_block == t->block_number && + evCount == t->which_event){ + return ENOMEM; + }else evCount = 0; + } evId = (int)(*(uint16_t *)(t->cur_event_pos)); evData = t->cur_event_pos + EVENT_HEADER_SIZE; - evT = ltt_trace_eventtype_get(t->trace,(unsigned)evId); - if(evT) rootFld = evT->root_field; - else return ERANGE; + //regard BLOCK_START, END and HEARTBEAT as special case, there are buildin events + if(evId != TRACE_BLOCK_START && evId != TRACE_BLOCK_END && evId != TRACE_TIME_HEARTBEAT){ + evT = ltt_trace_eventtype_get(t->trace,(unsigned)evId); + + if(evT) rootFld = evT->root_field; + else return ERANGE; - //event has string/sequence or the last event is not the same event - if((evT->latest_block!=t->which_block || evT->latest_event!=t->which_event) - && rootFld->field_fixed == 0){ - setFieldsOffset(t, evT, evData, t->trace); + if(rootFld){ + //event has string/sequence or the last event is not the same event + if((evT->latest_block!=t->which_block || evT->latest_event!=t->which_event) + && rootFld->field_fixed == 0){ + setFieldsOffset(t, evT, evData, t->trace); + } + t->cur_event_pos += EVENT_HEADER_SIZE + rootFld->field_size; + }else t->cur_event_pos += EVENT_HEADER_SIZE; + + evT->latest_block = t->which_block; + evT->latest_event = t->which_event; + }else{ + if(evId == TRACE_BLOCK_START || evId == TRACE_BLOCK_END){ + t->cur_event_pos += sizeof(BlockStart) + EVENT_HEADER_SIZE; + }else{ + t->cur_event_pos += sizeof(TimeHeartbeat) + EVENT_HEADER_SIZE; + } } - t->cur_event_pos += EVENT_HEADER_SIZE + rootFld->field_size; - - evT->latest_block = t->which_block; - evT->latest_event = t->which_event; //the next event is in the next block if(evId == TRACE_BLOCK_END){ - if(t->which_block == t->block_number) return ENOENT; + if(t->which_block == t->block_number){ + t->which_event++; + evCount = t->which_event; + return ENOENT; + } err = readBlock(t, t->which_block + 1); if(err) return err; }else{ @@ -1112,7 +1138,7 @@ int getFieldtypeSize(LttTracefile * t, LttEventType * evT, int offsetRoot, if(fld->field_fixed == -1){ fld->field_fixed = 0; }else{//0: string - size = sizeof((char*)evD) + 1; //include end : '\0' + size = strlen((char*)evD) + 1; //include end : '\0' } }else if(type->type_class == LTT_STRUCT){