/* from marker.c */
extern long marker_update_fields_offsets(struct marker_info *info, const char *data);
+extern void marker_update_event_fields_offsets(GArray *fields_offsets,
+ struct marker_info *info);
/* Tracefile names used in this file */
perror("Cannot map block for tracefile");
goto close_file;
}
-
+
+ /* Create fields offset table */
+ tf->event.fields_offsets = g_array_sized_new(FALSE, FALSE,
+ sizeof(struct LttField), 1);
+ if (!tf->event.fields_offsets)
+ goto close_file;
+
return 0;
/* Error */
close(t->fd);
if (t->buf_index)
g_array_free(t->buf_index, TRUE);
+ g_array_free(t->event.fields_offsets, TRUE);
}
/****************************************************************************
unsigned int i;
LttTracefile *tf;
+ if (group->len > 0)
+ destroy_marker_data(g_array_index (group, LttTracefile, 0).mdata);
for(i=0; i<group->len; i++) {
tf = &g_array_index (group, LttTracefile, i);
- if(tf->cpu_online) {
- destroy_marker_data(tf->mdata);
+ if(tf->cpu_online)
ltt_tracefile_close(tf);
- }
}
g_array_free(group, TRUE);
}
DIR *dir = opendir(root_path);
struct dirent *entry;
struct stat stat_buf;
- int ret;
+ int ret, i;
+ struct marker_data *mdata;
gchar path[PATH_MAX];
int path_len;
gchar rel_path[PATH_MAX];
gchar *rel_path_ptr;
LttTracefile tmp_tf;
- struct marker_data **mdata;
if(dir == NULL) {
perror(root_path);
g_debug("Tracefile name is %s and number is %u",
g_quark_to_string(name), num);
+ mdata = NULL;
tmp_tf.cpu_online = 1;
tmp_tf.cpu_num = num;
tmp_tf.name = name;
group = g_array_sized_new (FALSE, TRUE, sizeof(LttTracefile), 10);
g_datalist_id_set_data_full(&trace->tracefiles, name,
group, ltt_tracefile_group_destroy);
+ mdata = allocate_marker_data();
+ if (!mdata)
+ g_error("Error in allocating marker data");
}
/* Add the per cpu tracefile to the named group */
if(num+1 > old_len)
group = g_array_set_size(group, num+1);
+ g_assert(group->len > 0);
+ if (!mdata)
+ mdata = g_array_index (group, LttTracefile, 0).mdata;
+
g_array_index (group, LttTracefile, num) = tmp_tf;
g_array_index (group, LttTracefile, num).event.tracefile =
&g_array_index (group, LttTracefile, num);
- mdata = &g_array_index (group, LttTracefile, num).mdata;
- *mdata = allocate_marker_data();
- if (!*mdata)
- g_error("Error in allocating marker data");
+ for (i = 0; i < group->len; i++)
+ g_array_index (group, LttTracefile, i).mdata = mdata;
}
}
}
} else if(ltt_time_compare(time, tf->buffer.begin.timestamp) < 0) {
- /* go to lower part */
- high = block_num - 1;
+ /*
+ * Go to lower part. We don't want block_num - 1 since block_num
+ * can equal low , in which case high < low.
+ */
+ high = block_num;
} else if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) {
/* go to higher part */
low = block_num + 1;
if (info->size != -1)
size = info->size;
else
- size = marker_update_fields_offsets(marker_get_info_from_id(tf->mdata,
- tf->event.event_id), tf->event.data);
+ size = marker_update_fields_offsets(info, tf->event.data);
+ /* Update per-tracefile offsets */
+ marker_update_event_fields_offsets(tf->event.fields_offsets, info);
}
tf->event.data_size = size;