X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Fltt%2Ftracefile.c;h=f28a1b21e25c5414ae798739a4a8498c15c161dc;hb=83e160f2269f77a175b026a4b008a6dd18533d93;hp=a1e19a7fae56871a6d0889a6101c35ce8f760780;hpb=9d7e0c255f8df252a67f60bbb3ddd8c6b4dde0d9;p=lttv.git diff --git a/ltt/branches/poly/ltt/tracefile.c b/ltt/branches/poly/ltt/tracefile.c index a1e19a7f..f28a1b21 100644 --- a/ltt/branches/poly/ltt/tracefile.c +++ b/ltt/branches/poly/ltt/tracefile.c @@ -232,7 +232,6 @@ int parse_trace_header(void *header, LttTracefile *tf, LttTrace *t) t->ltt_minor_version = any->minor_version; t->flight_recorder = any->flight_recorder; t->has_heartbeat = any->has_heartbeat; - t->freq_scale = any->freq_scale; } @@ -260,6 +259,8 @@ int parse_trace_header(void *header, LttTracefile *tf, LttTrace *t) if(t) { t->start_freq = ltt_get_uint64(LTT_GET_BO(tf), &vheader->start_freq); + t->freq_scale = ltt_get_uint32(LTT_GET_BO(tf), + &vheader->freq_scale); t->start_tsc = ltt_get_uint64(LTT_GET_BO(tf), &vheader->start_tsc); t->start_monotonic = ltt_get_uint64(LTT_GET_BO(tf), @@ -642,9 +643,12 @@ void get_absolute_pathname(const gchar *pathname, gchar * abs_pathname) * The left side is the name, the right side is the number. */ -int get_tracefile_name_number(const gchar *raw_name, +int get_tracefile_name_number(gchar *raw_name, GQuark *name, - guint *num) + guint *num, + guint *tid, + guint *pgid, + guint64 *creation) { guint raw_name_len = strlen(raw_name); gchar char_name[PATH_MAX]; @@ -652,27 +656,84 @@ int get_tracefile_name_number(const gchar *raw_name, int underscore_pos; long int cpu_num; gchar *endptr; + gchar *tmpptr; for(i=raw_name_len-1;i>=0;i--) { if(raw_name[i] == '_') break; } - if(i==0) /* Either not found or name length is 0 */ - return -1; - underscore_pos = i; + if(i==-1) { /* Either not found or name length is 0 */ + /* This is a userspace tracefile */ + strncpy(char_name, raw_name, raw_name_len); + *name = g_quark_from_string(char_name); + *num = 0; /* unknown cpu */ + for(i=0;itracefiles, name); if(group == NULL) { @@ -928,6 +994,12 @@ static int ltt_get_facility_description(LttFacility *f, case LTT_ARCH_TYPE_X86_64: text = "_x86_64"; break; + case LTT_ARCH_TYPE_C2: + text = "_c2"; + break; + case LTT_ARCH_TYPE_POWERPC: + text = "_powerpc"; + break; default: g_error("Trace from unsupported architecture."); } @@ -1022,8 +1094,8 @@ static int ltt_process_facility_tracefile(LttTracefile *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->int_size = ltt_get_uint32(LTT_GET_BO(tf), - &fac_load_data->int_size); + fac->int_size = ltt_get_uint32(LTT_GET_BO(tf), + &fac_load_data->int_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), @@ -1079,8 +1151,8 @@ static int ltt_process_facility_tracefile(LttTracefile *tf) &fac_state_dump_load_data->id); fac->pointer_size = ltt_get_uint32(LTT_GET_BO(tf), &fac_state_dump_load_data->pointer_size); - fac->int_size = ltt_get_uint32(LTT_GET_BO(tf), - &fac_state_dump_load_data->int_size); + fac->int_size = ltt_get_uint32(LTT_GET_BO(tf), + &fac_state_dump_load_data->int_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), @@ -1427,11 +1499,25 @@ GQuark ltt_tracefile_long_name(const LttTracefile *tf) -guint ltt_tracefile_num(LttTracefile *tf) +guint ltt_tracefile_cpu(LttTracefile *tf) { return tf->cpu_num; } +guint ltt_tracefile_tid(LttTracefile *tf) +{ + return tf->tid; +} + +guint ltt_tracefile_pgid(LttTracefile *tf) +{ + return tf->pgid; +} + +guint64 ltt_tracefile_creation(LttTracefile *tf) +{ + return tf->creation; +} /***************************************************************************** * Get the number of blocks in the tracefile ****************************************************************************/ @@ -1599,23 +1685,32 @@ fail: return 1; } -/* Calculate the real event time based on the buffer boundaries */ -LttTime ltt_interpolate_time(LttTracefile *tf, LttEvent *event) +LttTime ltt_interpolate_time_from_tsc(LttTracefile *tf, guint64 tsc) { LttTime time; - -// time = ltt_time_from_uint64( -// cycles_2_ns(tf, (guint64)(tf->buffer.tsc - tf->buffer.begin.cycle_count))); - time = ltt_time_from_uint64( - (double)(tf->buffer.tsc - tf->trace->start_tsc) - * (1000000000.0 / tf->trace->freq_scale) - / (double)tf->trace->start_freq); - //time = ltt_time_add(tf->buffer.begin.timestamp, time); - time = ltt_time_add(tf->trace->start_time_from_tsc, time); - + + if(tsc > tf->trace->start_tsc) { + time = ltt_time_from_uint64( + (double)(tsc - tf->trace->start_tsc) + * (1000000000.0 / tf->trace->freq_scale) + / (double)tf->trace->start_freq); + time = ltt_time_add(tf->trace->start_time_from_tsc, time); + } else { + time = ltt_time_from_uint64( + (double)(tf->trace->start_tsc - tsc) + * (1000000000.0 / tf->trace->freq_scale) + / (double)tf->trace->start_freq); + time = ltt_time_sub(tf->trace->start_time_from_tsc, time); + } return time; } +/* Calculate the real event time based on the buffer boundaries */ +LttTime ltt_interpolate_time(LttTracefile *tf, LttEvent *event) +{ + return ltt_interpolate_time_from_tsc(tf, tf->buffer.tsc); +} + /* Get the current event of the tracefile : valid until the next read */ LttEvent *ltt_tracefile_get_event(LttTracefile *tf) @@ -1830,12 +1925,19 @@ static gint map_block(LttTracefile * tf, guint block_num) &header->begin.cycle_count); tf->buffer.begin.freq = ltt_get_uint64(LTT_GET_BO(tf), &header->begin.freq); - tf->buffer.begin.timestamp = ltt_time_add( + if(tf->buffer.begin.freq == 0) + tf->buffer.begin.freq = tf->trace->start_freq; + + tf->buffer.begin.timestamp = ltt_interpolate_time_from_tsc(tf, + tf->buffer.begin.cycle_count); +#if 0 + ltt_time_add( ltt_time_from_uint64( (double)(tf->buffer.begin.cycle_count - tf->trace->start_tsc) * 1000000.0 / (double)tf->trace->start_freq), - tf->trace->start_time_from_tsc); + tf->trace->start_time_from_tsc); +#endif //0 #if 0 tf->buffer.end.timestamp = ltt_time_add( @@ -1851,15 +1953,21 @@ static gint map_block(LttTracefile * tf, guint block_num) &header->end.cycle_count); tf->buffer.end.freq = ltt_get_uint64(LTT_GET_BO(tf), &header->end.freq); + if(tf->buffer.end.freq == 0) + tf->buffer.end.freq = tf->trace->start_freq; + tf->buffer.lost_size = ltt_get_uint32(LTT_GET_BO(tf), &header->lost_size); - tf->buffer.end.timestamp = ltt_time_add( + tf->buffer.end.timestamp = ltt_interpolate_time_from_tsc(tf, + tf->buffer.end.cycle_count); +#if 0 + ltt_time_add( ltt_time_from_uint64( (double)(tf->buffer.end.cycle_count - tf->trace->start_tsc) * 1000000.0 / (double)tf->trace->start_freq), tf->trace->start_time_from_tsc); - +#endif //0 tf->buffer.tsc = tf->buffer.begin.cycle_count; tf->event.tsc = tf->buffer.tsc; tf->buffer.freq = tf->buffer.begin.freq; @@ -2123,10 +2231,11 @@ off_t get_alignment(LttField *field) case LTT_FLOAT: case LTT_ENUM: /* Align offset on type size */ + g_assert(field->field_size != 0); return field->field_size; break; case LTT_STRING: - return 0; + return 1; break; case LTT_ARRAY: g_assert(type->fields->len == 1); @@ -2138,7 +2247,7 @@ off_t get_alignment(LttField *field) case LTT_SEQUENCE: g_assert(type->fields->len == 2); { - off_t localign = 0; + off_t localign = 1; LttField *child = &g_array_index(type->fields, LttField, 0); localign = max(localign, get_alignment(child)); @@ -2153,7 +2262,7 @@ off_t get_alignment(LttField *field) case LTT_UNION: { guint i; - off_t localign = 0; + off_t localign = 1; for(i=0; ifields->len; i++) { LttField *child = &g_array_index(type->fields, LttField, i); @@ -2165,8 +2274,8 @@ off_t get_alignment(LttField *field) case LTT_NONE: default: g_error("get_alignment : unknown type"); + return -1; } - } /***************************************************************************** @@ -2509,6 +2618,12 @@ void preset_field_type_size(LttTracefile *tf, LttEventType *event_type, size_t max_size; switch(type->type_class) { + case LTT_INT_FIXED: + case LTT_UINT_FIXED: + case LTT_CHAR: + case LTT_UCHAR: + case LTT_SHORT: + case LTT_USHORT: case LTT_INT: case LTT_UINT: case LTT_FLOAT: @@ -2620,6 +2735,9 @@ void preset_field_type_size(LttTracefile *tf, LttEventType *event_type, field->fixed_size = FIELD_FIXED; } break; + case LTT_NONE: + g_error("unexpected type NONE"); + break; } } @@ -2787,6 +2905,13 @@ gint check_fields_compatibility(LttEventType *event_type1, } switch(type1->type_class) { + case LTT_INT_FIXED: + case LTT_UINT_FIXED: + case LTT_POINTER: + case LTT_CHAR: + case LTT_UCHAR: + case LTT_SHORT: + case LTT_USHORT: case LTT_INT: case LTT_UINT: case LTT_FLOAT: