X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=ltt%2Ftracefile.c;h=0d8a248eb859900525e528445520119247ecc485;hb=1184dc3;hp=2dbbbcf119be2573dc1991afe5ad36fecf5ffc7a;hpb=f972ab5e81be30df0ef5d690a55a6876c27b1d40;p=lttv.git diff --git a/ltt/tracefile.c b/ltt/tracefile.c index 2dbbbcf1..0d8a248e 100644 --- a/ltt/tracefile.c +++ b/ltt/tracefile.c @@ -55,6 +55,8 @@ /* 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 */ @@ -333,7 +335,13 @@ static gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf) 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 */ @@ -376,6 +384,7 @@ static void ltt_tracefile_close(LttTracefile *t) close(t->fd); if (t->buf_index) g_array_free(t->buf_index, TRUE); + g_array_free(t->event.fields_offsets, TRUE); } /**************************************************************************** @@ -544,12 +553,12 @@ static void ltt_tracefile_group_destroy(gpointer data) unsigned int i; LttTracefile *tf; + if (group->len > 0) + destroy_marker_data(g_array_index (group, LttTracefile, 0).mdata); for(i=0; ilen; 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); } @@ -585,7 +594,8 @@ static int open_tracefiles(LttTrace *trace, gchar *root_path, gchar *relative_pa 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; @@ -595,7 +605,6 @@ static int open_tracefiles(LttTrace *trace, gchar *root_path, gchar *relative_pa gchar rel_path[PATH_MAX]; gchar *rel_path_ptr; LttTracefile tmp_tf; - struct marker_data **mdata; if(dir == NULL) { perror(root_path); @@ -658,6 +667,7 @@ static int open_tracefiles(LttTrace *trace, gchar *root_path, gchar *relative_pa 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; @@ -672,6 +682,9 @@ static int open_tracefiles(LttTrace *trace, gchar *root_path, gchar *relative_pa 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 */ @@ -679,13 +692,15 @@ static int open_tracefiles(LttTrace *trace, gchar *root_path, gchar *relative_pa 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; } } @@ -1587,8 +1602,9 @@ void ltt_update_event_size(LttTracefile *tf) 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;