//in.fd = g_open(in.name, O_RDONLY, 0);
//if(in.fd < 0 ) {
in.fp = fopen(in.name, "r");
- if(in.fp < 0 ) {
+ if(in.fp == NULL) {
g_warning("cannot open facility description file %s",
in.name);
return 1;
type_descriptor_t * tmpTd;
switch(td->type) {
- case LTT_ENUM:
- fld->field_type->element_number = td->labels.position;
- fld->field_type->enum_strings = g_new(GQuark,td->labels.position);
- for(i=0;i<td->labels.position;i++){
- fld->field_type->enum_strings[i]
- = g_quark_from_string(((char*)(td->labels.array[i])));
- }
- break;
- case LTT_ARRAY:
- fld->field_type->element_number = (unsigned)td->size;
- case LTT_SEQUENCE:
+ case INT:
+ case UINT:
+ case FLOAT:
+ fld->field_type->size = td->size;
+ break;
+ case POINTER:
+ case LONG:
+ case ULONG:
+ case SIZE_T:
+ case SSIZE_T:
+ case OFF_T:
+ fld->field_type->size = 0;
+ break;
+ case STRING:
+ fld->field_type->size = 0;
+ break;
+ case ENUM:
+ fld->field_type->element_number = td->labels.position;
+ fld->field_type->enum_strings = g_new(GQuark,td->labels.position);
+ for(i=0;i<td->labels.position;i++){
+ fld->field_type->enum_strings[i]
+ = g_quark_from_string(((char*)(td->labels.array[i])));
+ }
+ fld->field_type->size = td->size;
+ break;
+
+ case ARRAY:
+ fld->field_type->element_number = (unsigned)td->size;
+ case SEQUENCE:
fld->field_type->element_type = g_new(LttType*,1);
tmpTd = td->nested_type;
fld->field_type->element_type[0] = lookup_named_type(fac, tmpTd);
fld->child[0]->current_element = 0;
construct_types_and_fields(fac, tmpTd, fld->child[0]);
break;
- case LTT_STRUCT:
- case LTT_UNION:
+
+ case STRUCT:
+ case UNION:
fld->field_type->element_number = td->fields.position;
g_assert(fld->field_type->element_type == NULL);
fld->child[i]->current_element = 0;
construct_types_and_fields(fac, tmpTd, fld->child[i]);
}
-
break;
+
default:
g_error("construct_types_and_fields : unknown type");
}
LttType * lookup_named_type(LttFacility *fac, type_descriptor_t * td)
{
- GQuark name = g_quark_from_string(td->type_name);
+ LttType *type = NULL;
+ GQuark name = 0;
+
+ if(td->type_name != NULL) {
+ /* Named type */
+ name = g_quark_from_string(td->type_name);
+
+ type = g_datalist_id_get_data(&fac->named_types, name);
+ }
- LttType *type = g_datalist_id_get_data(&fac->named_types, name);
-
if(type == NULL){
+ /* Create the type */
type = g_new(LttType,1);
type->type_name = name;
- g_datalist_id_set_data_full(&fac->named_types, name,
- type, (GDestroyNotify)freeLttNamedType);
type->type_class = td->type;
if(td->fmt) type->fmt = g_strdup(td->fmt);
else type->fmt = NULL;
type->enum_strings = NULL;
type->element_type = NULL;
type->element_number = 0;
+
+ if(td->type_name != NULL)
+ g_datalist_id_set_data_full(&fac->named_types, name,
+ type, (GDestroyNotify)freeLttNamedType);
}
-
return type;
}
{
unsigned int i;
if(*type == NULL) return;
+ if((*type)->type_name != 0) return; //this is a named type.
//if((*type)->type_name){
// return; //this is a named type
//}
LttEventType *ltt_facility_eventtype_get_by_name(LttFacility *f, GQuark name)
{
- LttEventType *et = g_datalist_get_data(&f->events_by_name, name);
+ LttEventType *et = g_datalist_id_get_data(&f->events_by_name, name);
}
guint32 id; //id of the facility
guint32 pointer_size;
+ guint32 long_size;
guint32 size_t_size;
guint32 alignment;
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:
void lttv_fatal(void *hook_data)
{
- //g_log_set_always_fatal(G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
- g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
+ g_log_set_always_fatal(G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
+ //g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
g_info("Critical log from glib will abort execution");
}
for(i = 0 ; i < nb_tracefile ; i++) {
tfcs =
- LTTV_TRACEFILE_STATE(&g_array_index(self->parent.tracefiles,
- LttvTracefileContext, i));
+ LTTV_TRACEFILE_STATE(g_array_index(self->parent.tracefiles,
+ LttvTracefileContext*, i));
ltt_trace_time_span_get(self->parent.t, &tfcs->parent.timestamp, NULL);
// tfcs->saved_position = 0;
tfcs->process = lttv_state_create_process(tfcs, NULL,0);
for(j = 0 ; j < nb_tracefile ; j++) {
tfcs =
- LTTV_TRACEFILE_STATE(&g_array_index(tc->tracefiles,
- LttvTracefileContext, j));
+ LTTV_TRACEFILE_STATE(g_array_index(tc->tracefiles,
+ LttvTracefileContext*, j));
tfcs->cpu_name = ltt_tracefile_name(tfcs->parent.tf);
}
tcs->processes = NULL;
for(i = 0 ; i < nb_tracefile ; i++) {
tfcs =
- LTTV_TRACEFILE_STATE(&g_array_index(self->parent.tracefiles,
- LttvTracefileContext, i));
+ LTTV_TRACEFILE_STATE(g_array_index(self->parent.tracefiles,
+ LttvTracefileContext*, i));
fprintf(fp, " <TRACEFILE PID=%u TIMESTAMP_S=%lu TIMESTAMP_NS=%lu",
tfcs->process->pid, tfcs->parent.timestamp.tv_sec,
tfcs->parent.timestamp.tv_nsec);
for(i = 0 ; i < nb_tracefile ; i++) {
tfcs =
- LTTV_TRACEFILE_STATE(&g_array_index(self->parent.tracefiles,
- LttvTracefileContext, i));
+ LTTV_TRACEFILE_STATE(g_array_index(self->parent.tracefiles,
+ LttvTracefileContext*, i));
tracefile_tree = g_object_new(LTTV_ATTRIBUTE_TYPE, NULL);
value = lttv_attribute_add(tracefiles_tree, i,
LTTV_GOBJECT);
for(i = 0 ; i < nb_tracefile ; i++) {
tfcs =
- LTTV_TRACEFILE_STATE(&g_array_index(self->parent.tracefiles,
- LttvTracefileContext, i));
+ LTTV_TRACEFILE_STATE(g_array_index(self->parent.tracefiles,
+ LttvTracefileContext*, i));
type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
g_assert(type == LTTV_GOBJECT);
tracefile_tree = *((LttvAttribute **)(value.v_gobject));
for(i = 0 ; i < nb_tracefile ; i++) {
tfcs =
- LTTV_TRACEFILE_STATE(&g_array_index(self->parent.tracefiles,
- LttvTracefileContext, i));
+ LTTV_TRACEFILE_STATE(g_array_index(self->parent.tracefiles,
+ LttvTracefileContext*, i));
type = lttv_attribute_get(tracefiles_tree, i, &name, &value);
g_assert(type == LTTV_GOBJECT);
tracefile_tree = *((LttvAttribute **)(value.v_gobject));
process->pid = pid;
process->last_cpu = tfs->cpu_name;
process->last_cpu_index = ((LttvTracefileContext*)tfs)->index;
- g_warning("Process %u, core %p", process->pid, process);
+ g_info("Process %u, core %p", process->pid, process);
g_hash_table_insert(tcs->processes, process, process);
if(parent) {
for(j = 0 ; j < nb_tracefile ; j++) {
tfs =
- LTTV_TRACEFILE_STATE(&g_array_index(ts->parent.tracefiles,
- LttvTracefileContext, j));
+ LTTV_TRACEFILE_STATE(g_array_index(ts->parent.tracefiles,
+ LttvTracefileContext*, j));
for(k = 0 ; k < hooks->len ; k++) {
hook = &g_array_index(hooks, LttvTraceHook, k);
for(j = 0 ; j < nb_tracefile ; j++) {
tfs =
- LTTV_TRACEFILE_STATE(&g_array_index(ts->parent.tracefiles,
- LttvTracefileContext, j));
+ LTTV_TRACEFILE_STATE(g_array_index(ts->parent.tracefiles,
+ LttvTracefileContext*, j));
lttv_hooks_add(tfs->parent.event,
state_save_event_hook,
event_count,
for(j = 0 ; j < nb_tracefile ; j++) {
tfs =
- LTTV_TRACEFILE_STATE(&g_array_index(ts->parent.tracefiles,
- LttvTracefileContext, j));
+ LTTV_TRACEFILE_STATE(g_array_index(ts->parent.tracefiles,
+ LttvTracefileContext*, j));
event_count = lttv_hooks_remove(tfs->parent.event,
state_save_event_hook);
g_free(event_count);
nb_tracefile = tc->tracefiles->len;
for(j = 0 ; j < nb_tracefile ; j++) {
- tfcs = LTTV_TRACEFILE_STATS(&g_array_index(tc->tracefiles,
- LttvTracefileContext, j));
+ tfcs = LTTV_TRACEFILE_STATS(g_array_index(tc->tracefiles,
+ LttvTracefileContext*, j));
tfcs->stats = lttv_attribute_find_subdir(tracefiles_stats,
tfcs->parent.cpu_name);
find_event_tree(tfcs, LTTV_STATS_PROCESS_UNKNOWN,
nb_tracefile = tc->tracefiles->len;
for(j = 0 ; j < nb_tracefile ; j++) {
- tfc = &g_array_index(tc->tracefiles,
- LttvTracefileContext, j);
+ tfc = g_array_index(tc->tracefiles,
+ LttvTracefileContext*, j);
tfcs = (LttvTracefileStats *)tfc;
tfcs->stats = NULL;
tfcs->current_events_tree = NULL;
nb_tracefile = ts->parent.parent.tracefiles->len;
for(j = 0 ; j < nb_tracefile ; j++) {
- tfs = LTTV_TRACEFILE_STATS(&g_array_index(ts->parent.parent.tracefiles,
- LttvTracefileContext, j));
+ tfs = LTTV_TRACEFILE_STATS(g_array_index(ts->parent.parent.tracefiles,
+ LttvTracefileContext*, j));
lttv_hooks_remove_data(tfs->parent.parent.event, every_event,
NULL);
nb_tracefile = self->tracefiles->len;
for(i = 0 ; i < nb_tracefile ; i++) {
- tfc = &g_array_index(self->tracefiles, LttvTracefileContext, i);
+ tfc = g_array_index(self->tracefiles, LttvTracefileContext*, i);
lttv_tracefile_context_add_hooks(tfc,
before_tracefile,
event,
nb_tracefile = self->tracefiles->len;
for(i = 0 ; i < nb_tracefile ; i++) {
- tfc = &g_array_index(self->tracefiles, LttvTracefileContext, i);
+ tfc = g_array_index(self->tracefiles, LttvTracefileContext*, i);
lttv_tracefile_context_remove_hooks(tfc,
after_tracefile,
event,
fac_id = g_array_index(facilities, guint, 0);
f = ltt_trace_get_facility_by_num(t, fac_id);
- et = ltt_facility_eventtype_get_by_name(f, ltt_eventtype_name(et));
+ et = ltt_facility_eventtype_get_by_name(f, event);
if(unlikely(et == NULL)) goto event_error;
thf = &g_array_index(th->fac_index, LttvTraceHookByFacility, fac_id);