char hardware_platform[BUFFER_SIZE];
char operating_system[BUFFER_SIZE];
int cpu;
- int ltt_block_size;
- int ltt_major_version;
- int ltt_minor_version;
+ int ltt_block_size=0;
+ int ltt_major_version=0;
+ int ltt_minor_version=0;
int ltt_log_cpu;
char buf[BUFFER_SIZE];
int i, k;
int size, size1, element_number, i, offset1, offset2;
LttType * type = fld->field_type;
+ switch(type->type_class) {
+ case LTT_ARRAY:
+ element_number = (int) type->element_number;
+ if(fld->field_fixed == 0){// has string or sequence
+ size = 0;
+ for(i=0;i<element_number;i++){
+ size += ltt_event_refresh_fields(offsetRoot+size,size,
+ fld->child[0], evD+size);
+ }
+ }else size = fld->field_size;
+ break;
+
+ case LTT_SEQUENCE:
+ size1 = fld->sequ_number_size;
+ element_number = getIntNumber(size1,evD);
+ type->element_number = element_number;
+ if(fld->element_size > 0){
+ size = element_number * fld->element_size;
+ }else{//sequence has string or sequence
+ size = 0;
+ for(i=0;i<element_number;i++){
+ size += ltt_event_refresh_fields(offsetRoot+size+size1,size+size1,
+ fld->child[0], evD+size+size1);
+ }
+ size += size1;
+ }
+ break;
+
+ case LTT_STRING:
+ size = strlen((char*)evD) + 1; //include end : '\0'
+ break;
+
+ case LTT_STRUCT:
+ element_number = (int) type->element_number;
+ if(fld->field_fixed == 0){
+ offset1 = offsetRoot;
+ offset2 = 0;
+ for(i=0;i<element_number;i++){
+ size=ltt_event_refresh_fields(offset1,offset2,
+ fld->child[i],evD+offset2);
+ offset1 += size;
+ offset2 += size;
+ }
+ size = offset2;
+ }else size = fld->field_size;
+ break;
+
+ default:
+ size = fld->field_size;
+ }
+
+#if 0
if(type->type_class != LTT_STRUCT && type->type_class != LTT_ARRAY &&
type->type_class != LTT_SEQUENCE && type->type_class != LTT_STRING){
size = fld->field_size;
if(fld->field_fixed == 0){// has string or sequence
size = 0;
for(i=0;i<element_number;i++){
- size += ltt_event_refresh_fields(offsetRoot+size,size,
+ size += ltt_event_refresh_fields(offsetRoot+size,size,
fld->child[0], evD+size);
- }
+ }
}else size = fld->field_size;
}else if(type->type_class == LTT_SEQUENCE){
size1 = fld->sequ_number_size;
}else{//sequence has string or sequence
size = 0;
for(i=0;i<element_number;i++){
- size += ltt_event_refresh_fields(offsetRoot+size+size1,size+size1,
- fld->child[0], evD+size+size1);
+ size += ltt_event_refresh_fields(offsetRoot+size+size1,size+size1,
+ fld->child[0], evD+size+size1);
}
size += size1;
}
offset1 = offsetRoot;
offset2 = 0;
for(i=0;i<element_number;i++){
- size=ltt_event_refresh_fields(offset1,offset2,fld->child[i],evD+offset2);
- offset1 += size;
- offset2 += size;
+ size=ltt_event_refresh_fields(offset1,offset2,
+ fld->child[i],evD+offset2);
+ offset1 += size;
+ offset2 += size;
}
size = offset2;
}else size = fld->field_size;
}
-
+#endif //0
fld->offset_root = offsetRoot;
fld->offset_parent = offsetParent;
fld->fixed_root = (offsetRoot==-1) ? 0 : 1;
guint32 aInt;
memcpy((void*)&aInt, e->data + f->offset_root, 4);
aInt = ___swab32(aInt);
- return *((float*)&aInt);
+ return ((float)aInt);
}
}
guint64 aInt;
memcpy((void*)&aInt, e->data + f->offset_root, 8);
aInt = ___swab64(aInt);
- return *((double *)&aInt);
+ return ((double)aInt);
}
}
LttType * lookup_named_type(LttFacility *fac, type_descriptor * td)
{
LttType * lttType = NULL;
- unsigned int i;
+ unsigned int i=0;
char * name;
+
if(td->type_name){
for(i=0;i<fac->named_types_number; i++){
if(fac->named_types[i] == NULL) break;
name = fac->named_types[i]->type_name;
if(strcmp(name, td->type_name)==0){
- lttType = fac->named_types[i];
+ lttType = fac->named_types[i];
// if(lttType->element_name) g_free(lttType->element_name);
// lttType->element_name = NULL;
- break;
+ break;
}
}
}
lttType->element_name = NULL;
if(td->type_name){
lttType->type_name = g_strdup(td->type_name);
- fac->named_types[i] = lttType;
+ fac->named_types[i] = lttType; /* i is initialized, checked. */
}
else{
lttType->type_name = NULL;
* : obtain the event type according to event name
* event name is unique in the facility
*Input params
- * f : the facility that will be closed
+ * f : the facility
* name : the name of the event
*Return value
* LttEventType * : the event type required
LttEventType *ltt_facility_eventtype_get_by_name(LttFacility *f, char *name)
{
unsigned int i;
- LttEventType * ev;
+ LttEventType * ev = NULL;
+
for(i=0;i<f->event_number;i++){
- ev = f->events[i];
- if(strcmp(ev->name, name) == 0)break;
+ LttEventType *iter_ev = f->events[i];
+ if(strcmp(iter_ev->name, name) == 0) {
+ ev = iter_ev;
+ break;
+ }
}
-
- if(i==f->event_number) return NULL;
- else return ev;
+ return ev;
}
/* get an integer number */
-int getIntNumber(int size1, void *evD);
+gint64 getIntNumber(int size1, void *evD);
/* get the node name of the system */
LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id)
{
- LttFacility * facility;
+ LttFacility * facility = NULL;
unsigned int i;
+
for(i=0;i<trace->facility_number;i++){
- facility = (LttFacility*) g_ptr_array_index(trace->facilities,i);
- if(id >= facility->base_id &&
- id < facility->base_id + facility->event_number)
+ LttFacility *iter_facility =
+ (LttFacility*) g_ptr_array_index(trace->facilities,i);
+ if(id >= iter_facility->base_id &&
+ id < iter_facility->base_id + iter_facility->event_number) {
+ facility = iter_facility;
break;
+ }
}
- if(i==trace->facility_number) return NULL;
- else return facility;
+
+ return facility;
}
LttEventType *ltt_trace_eventtype_get(LttTrace *t, unsigned evId)
if(fld == evT->root_field) return fld->field_size;
}
+ switch(type->type_class) {
+ case LTT_ARRAY:
+ element_number = (int) type->element_number;
+ if(fld->field_fixed == -1){
+ size = getFieldtypeSize(t, evT, offsetRoot,
+ 0,fld->child[0], NULL, trace);
+ if(size == 0){ //has string or sequence
+ fld->field_fixed = 0;
+ }else{
+ fld->field_fixed = 1;
+ size *= element_number;
+ }
+ }else if(fld->field_fixed == 0){// has string or sequence
+ size = 0;
+ for(i=0;i<element_number;i++){
+ size += getFieldtypeSize(t, evT, offsetRoot+size,size,
+ fld->child[0], evD+size, trace);
+ }
+ }else size = fld->field_size;
+ break;
+
+ case LTT_SEQUENCE:
+ size1 = (int) ltt_type_size(trace, type);
+ if(fld->field_fixed == -1){
+ fld->sequ_number_size = size1;
+ fld->field_fixed = 0;
+ size = getFieldtypeSize(t, evT, offsetRoot,
+ 0,fld->child[0], NULL, trace);
+ fld->element_size = size;
+ }else{//0: sequence
+ element_number = getIntNumber(size1,evD);
+ type->element_number = element_number;
+ if(fld->element_size > 0){
+ size = element_number * fld->element_size;
+ }else{//sequence has string or sequence
+ size = 0;
+ for(i=0;i<element_number;i++){
+ size += getFieldtypeSize(t, evT, offsetRoot+size+size1,size+size1,
+ fld->child[0], evD+size+size1, trace);
+ }
+ }
+ size += size1;
+ }
+ break;
+
+ case LTT_STRING:
+ size = 0;
+ if(fld->field_fixed == -1){
+ fld->field_fixed = 0;
+ }else{//0: string
+ size = strlen((char*)evD) + 1; //include end : '\0'
+ }
+ break;
+
+ case LTT_STRUCT:
+ element_number = (int) type->element_number;
+ size = 0;
+ if(fld->field_fixed == -1){
+ offset1 = offsetRoot;
+ offset2 = 0;
+ for(i=0;i<element_number;i++){
+ size1=getFieldtypeSize(t, evT,offset1,offset2,
+ fld->child[i], NULL, trace);
+ if(size1 > 0 && size >= 0){
+ size += size1;
+ if(offset1 >= 0) offset1 += size1;
+ offset2 += size1;
+ }else{
+ size = -1;
+ offset1 = -1;
+ offset2 = -1;
+ }
+ }
+ if(size == -1){
+ fld->field_fixed = 0;
+ size = 0;
+ }else fld->field_fixed = 1;
+ }else if(fld->field_fixed == 0){
+ offset1 = offsetRoot;
+ offset2 = 0;
+ for(i=0;i<element_number;i++){
+ size=getFieldtypeSize(t,evT,offset1,offset2,
+ fld->child[i],evD+offset2, trace);
+ offset1 += size;
+ offset2 += size;
+ }
+ size = offset2;
+ }else size = fld->field_size;
+ break;
+
+ default:
+ if(fld->field_fixed == -1){
+ size = (int) ltt_type_size(trace, type);
+ fld->field_fixed = 1;
+ }else size = fld->field_size;
+ break;
+ }
+
+
+
+#if 0
if(type->type_class != LTT_STRUCT && type->type_class != LTT_ARRAY &&
type->type_class != LTT_SEQUENCE && type->type_class != LTT_STRING){
if(fld->field_fixed == -1){
size = offset2;
}else size = fld->field_size;
}
+#endif //0
fld->offset_root = offsetRoot;
fld->offset_parent = offsetParent;
* size : the size of the integer
* evD : the event data
*Return value
- * int : an integer
+ * gint64 : a 64 bits integer
****************************************************************************/
-int getIntNumber(int size, void *evD)
+gint64 getIntNumber(int size, void *evD)
{
gint64 i;
+
+ switch(size) {
+ case 1: i = *(gint8 *)evD; break;
+ case 2: i = *(gint16 *)evD; break;
+ case 4: i = *(gint32 *)evD; break;
+ case 8: i = *(gint64 *)evD; break;
+ default: i = *(gint64 *)evD;
+ g_critical("getIntNumber : integer size %d unknown", size);
+ break;
+ }
+
+#if 0
if(size == 1) i = *(gint8 *)evD;
else if(size == 2) i = *(gint16 *)evD;
else if(size == 4) i = *(gint32 *)evD;
else if(size == 8) i = *(gint64 *)evD;
-
- return (int) i;
+#endif //0
+
+ return (gint64)i;
}
/*****************************************************************************