int rel_path_len;
char rel_path[PATH_MAX];
char *rel_path_ptr;
+ LttTracefile tmp_tf;
if(dir == NULL) {
perror(root_path);
ret = open_tracefiles(trace, path, rel_path);
if(ret < 0) continue;
} else if(S_ISREG(stat_buf.st_mode)) {
- g_debug("Opening file.\n");
-
GQuark name;
guint num;
GArray *group;
if(get_tracefile_name_number(rel_path, &name, &num))
continue; /* invalid name */
+ g_debug("Opening file.\n");
+ if(ltt_tracefile_open(trace, path, &tmp_tf)) {
+ g_info("Error opening tracefile %s", path);
+
+ continue; /* error opening the tracefile : bad magic number ? */
+ }
+
g_debug("Tracefile name is %s and number is %u",
g_quark_to_string(name), num);
+ tmp_tf.cpu_online = 1;
+ tmp_tf.cpu_num = num;
+
group = g_datalist_id_get_data(&trace->tracefiles, name);
if(group == NULL) {
/* Elements are automatically cleared when the array is allocated.
g_datalist_id_set_data_full(&trace->tracefiles, name,
group, ltt_tracefile_group_destroy);
}
+
/* Add the per cpu tracefile to the named group */
unsigned int old_len = group->len;
if(num+1 > old_len)
group = g_array_set_size(group, num+1);
- tf = &g_array_index (group, LttTracefile, num);
-
- if(ltt_tracefile_open(trace, path, tf)) {
- g_info("Error opening tracefile %s", path);
- g_array_set_size(group, old_len);
+ g_array_index (group, LttTracefile, num) = tmp_tf;
- if(!ltt_tracefile_group_has_cpu_online(group))
- g_datalist_id_remove_data(&trace->tracefiles, name);
-
- continue; /* error opening the tracefile : bad magic number ? */
- }
- tf->cpu_online = 1;
- tf->cpu_num = num;
}
}
const gchar *text;
guint textlen;
gint err;
- int i, j;
- LttEventType *et;
text = g_quark_to_string(t->pathname);
textlen = strlen(text);
err = ltt_facility_open(f, t, desc_file_name);
if(err) goto facility_error;
-
- for(i=0;i<t->facilities_by_num->len;i++){
- f = &g_array_index(t->facilities_by_num, LttFacility, i);
- if(f->exists) {
- for(j=0; j<f->events->len; j++){
- et = &g_array_index(f->events, LttEventType, j);
- set_fields_offsets(fac_tf, et);
- }
- }
- }
-
return 0;
static void ltt_fac_ids_destroy(gpointer data)
{
GArray *fac_ids = (GArray *)data;
- int i;
- LttFacility *fac;
-
- for(i=0; i<fac_ids->len; i++) {
- fac = &g_array_index (fac_ids, LttFacility, i);
- ltt_facility_close(fac);
- }
g_array_free(fac_ids, TRUE);
}
int err;
LttFacility *fac;
GArray *fac_ids;
+ guint i;
+ LttEventType *et;
while(1) {
err = ltt_tracefile_read_seek(tf);
fac->id = ltt_get_uint32(LTT_GET_BO(tf), &fac_load_data->id);
fac->pointer_size = ltt_get_uint32(LTT_GET_BO(tf),
&fac_load_data->pointer_size);
+ fac->long_size = ltt_get_uint32(LTT_GET_BO(tf),
+ &fac_load_data->long_size);
fac->size_t_size = ltt_get_uint32(LTT_GET_BO(tf),
&fac_load_data->size_t_size);
fac->alignment = ltt_get_uint32(LTT_GET_BO(tf),
&fac_load_data->alignment);
if(ltt_get_facility_description(fac, tf->trace, tf))
- goto facility_error;
+ continue; /* error opening description */
fac->trace = tf->trace;
+
+ /* Preset the field offsets */
+ for(i=0; i<fac->events->len; i++){
+ et = &g_array_index(fac->events, LttEventType, i);
+ set_fields_offsets(tf, et);
+ }
+
fac->exists = 1;
fac_ids = g_datalist_id_get_data(&tf->trace->facilities_by_name,
fac->id = fac_state_dump_load_data->id;
fac->pointer_size = ltt_get_uint32(LTT_GET_BO(tf),
&fac_state_dump_load_data->pointer_size);
+ fac->long_size = ltt_get_uint32(LTT_GET_BO(tf),
+ &fac_state_dump_load_data->long_size);
fac->size_t_size = ltt_get_uint32(LTT_GET_BO(tf),
&fac_state_dump_load_data->size_t_size);
fac->alignment = ltt_get_uint32(LTT_GET_BO(tf),
&fac_state_dump_load_data->alignment);
if(ltt_get_facility_description(fac, tf->trace, tf))
- goto facility_error;
+ continue; /* error opening description */
fac->trace = tf->trace;
+ /* Preset the field offsets */
+ for(i=0; i<fac->events->len; i++){
+ et = &g_array_index(fac->events, LttEventType, i);
+ set_fields_offsets(tf, et);
+ }
+
fac->exists = 1;
fac_ids = g_datalist_id_get_data(&tf->trace->facilities_by_name,
void ltt_trace_close(LttTrace *t)
{
+ guint i;
+ LttFacility *fac;
+
+ for(i=0; i<t->facilities_by_num->len; i++) {
+ fac = &g_array_index (t->facilities_by_num, LttFacility, i);
+ if(fac->exists)
+ ltt_facility_close(fac);
+ }
+
g_datalist_clear(&t->facilities_by_name);
g_array_free(t->facilities_by_num, TRUE);
g_datalist_clear(&t->tracefiles);
}
- if(tf->event.offset == tf->block_size - tf->buffer.lost_size) {
- ret = ERANGE;
- goto found;
- }
-
pos = tf->event.data;
if(tf->event.data_size < 0) goto error;
pos += (size_t)tf->event.data_size;
tf->event.offset = pos - tf->buffer.head;
+
+ if(tf->event.offset == tf->block_size - tf->buffer.lost_size) {
+ ret = ERANGE;
+ goto found;
+ }
found:
return ret;
break;
case LTT_LONG:
case LTT_ULONG:
- field->field_size = (off_t)event_type->facility->pointer_size;
+ field->field_size = (off_t)event_type->facility->long_size;
field->fixed_size = FIELD_FIXED;
break;
case LTT_SIZE_T: