* the time passed in parameter.
*
* If the time parameter is outside the tracefile time span, seek to the first
- * or the last event of the tracefile.
+ * 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, get the last event.
+ * 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.
* 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.
*
* */
* 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 */
}
goto fail;
}
- /* If the time is after the end of the trace, get the last event. */
- if(ltt_time_compare(time, tf->buffer.end.timestamp) >= 0) {
- /* While the ltt_tracefile_read doesn't return ERANGE or EPERM,
- * continue reading.
- */
- while(1) {
- ret = ltt_tracefile_read(tf);
- if(ret == ERANGE) goto found; /* ERANGE or EPERM */
- else if(ret) 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 */
* (or in the next buffer first event) */
while(1) {
ret = ltt_tracefile_read(tf);
- if(ret == ERANGE) goto found; /* ERANGE or EPERM */
+ if(ret == ERANGE) goto range; /* ERANGE or EPERM */
else if(ret) goto fail;
if(ltt_time_compare(time, tf->event.event_time) >= 0)
break;
}
- } if(ltt_time_compare(time, tf->buffer.begin.timestamp) < 0) {
+ } else if(ltt_time_compare(time, tf->buffer.begin.timestamp) < 0) {
/* go to lower part */
high = block_num;
} else if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) {
} else {/* The event is right in the buffer!
(or in the next buffer first event) */
while(1) {
- ltt_tracefile_read(tf);
- if(ret == ERANGE) goto found; /* ERANGE or EPERM */
+ 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)
found:
return 0;
+range:
+ return ERANGE;
/* Error handling */
fail:
g_quark_to_string(tf->name));
goto event_type_error;
}
+
+ if(event_type->root_field)
+ size = get_field_type_size(tf, event_type,
+ 0, 0, event_type->root_field, tf->event.data);
+ else
+ size = 0;
- size = get_field_type_size(tf, event_type,
- 0, 0, event_type->root_field, tf->event.data);
g_debug("Event root field : f.e %hhu.%hhu size %lu", tf->event.facility_id,
tf->event.event_id, size);
}
field->child[0]);
field->fixed_size = FIELD_VARIABLE;
field->field_size = 0;
+ *fixed_root = FIELD_VARIABLE;
+ *fixed_parent = FIELD_VARIABLE;
break;
case LTT_STRING:
field->fixed_size = FIELD_VARIABLE;
field->field_size = 0;
+ *fixed_root = FIELD_VARIABLE;
+ *fixed_parent = FIELD_VARIABLE;
break;
case LTT_ARRAY:
local_fixed_root = FIELD_VARIABLE;
&local_fixed_root, &local_fixed_parent,
field->child[0]);
field->fixed_size = field->child[0]->fixed_size;
- if(field->fixed_size == FIELD_FIXED)
+ if(field->fixed_size == FIELD_FIXED) {
field->field_size = type->element_number * field->child[0]->field_size;
- else
+ } else {
field->field_size = 0;
+ *fixed_root = FIELD_VARIABLE;
+ *fixed_parent = FIELD_VARIABLE;
+ }
break;
case LTT_STRUCT:
current_root_offset = field->offset_root;