{
ssize_t nbBytes = read(fd, buf, size);
- if(nbBytes < 0) {
- perror("Error in readFile : ");
- exit(1);
- } else if((size_t)nbBytes != size) {
- printf("%s\n",mesg);
+ if((size_t)nbBytes != size) {
+ if(nbBytes < 0) {
+ perror("Error in readFile : ");
+ } else {
+ printf("%s\n",mesg);
+ }
exit(1);
}
return 0;
*/
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
#include <asm/types.h>
#include <linux/byteorder/swab.h>
{
unsigned element_number;
LttField *fld;
- int k, size;
+ unsigned int k;
+ int size;
void *evD;
if(f->field_type->type_class != LTT_ARRAY &&
return ;
element_number = ltt_event_field_element_number(e,f);
- if((element_number-1) < i || i < 0) return;
+ /* Sanity check for i : 1..n only, and must be lower or equal element_number
+ */
+ if(element_number < i || i == 0) return;
fld = f->child[0];
for(k=0;k<i;k++){
size += ltt_event_refresh_fields(f->offset_root+size,size, fld, evD+size);
}
-
f->current_element = i - 1;
}
else
return (unsigned int) (revFlag ? GUINT64_FROM_LE(x): x);
}
+ g_critical("ltt_event_get_unsigned : field size %i unknown", f->field_size);
+ return 0;
}
int ltt_event_get_int(LttEvent *e, LttField *f)
else
return (int) (revFlag ? GINT64_FROM_LE(x): x);
}
+ g_critical("ltt_event_get_int : field size %i unknown", f->field_size);
+ return 0;
}
unsigned long ltt_event_get_long_unsigned(LttEvent *e, LttField *f)
else
return (unsigned long) (revFlag ? GUINT64_FROM_LE(x): x);
}
+ g_critical("ltt_event_get_long_unsigned : field size %i unknown", f->field_size);
+ return 0;
}
long int ltt_event_get_long_int(LttEvent *e, LttField *f)
else
return (long) (revFlag ? GINT64_FROM_LE(x): x);
}
+ g_critical("ltt_event_get_long_int : field size %i unknown", f->field_size);
+ return 0;
}
float ltt_event_get_float(LttEvent *e, LttField *f)
LttField * fld);
/* generate the facility according to the events belongin to it */
-void generateFacility(LttFacility * f, facility * fac,
+void generateFacility(LttFacility * f, facility_t * fac,
LttChecksum checksum);
/* functions to release the memory occupied by a facility */
char *token;
parse_file in;
char buffer[BUFFER_SIZE];
- facility * fac;
+ facility_t * fac;
LttFacility * f;
LttChecksum checksum;
token = getName(&in);
if(strcmp("facility",token) == 0) {
- fac = g_new(facility, 1);
+ fac = g_new(facility_t, 1);
fac->name = NULL;
fac->description = NULL;
sequence_init(&(fac->events));
* checksum : checksum of the facility
****************************************************************************/
-void generateFacility(LttFacility *f, facility *fac,LttChecksum checksum)
+void generateFacility(LttFacility *f, facility_t *fac,LttChecksum checksum)
{
char * facilityName = fac->name;
sequence * events = &fac->events;
evType = g_new(LttEventType,1);
f->events[i] = evType;
- evType->name = g_strdup(((event*)(events->array[i]))->name);
- evType->description=g_strdup(((event*)(events->array[i]))->description);
+ evType->name = g_strdup(((event_t*)(events->array[i]))->name);
+ evType->description=g_strdup(((event_t*)(events->array[i]))->description);
field = g_new(LttField, 1);
evType->root_field = field;
evType->facility = f;
evType->index = i;
- if(((event*)(events->array[i]))->type != NULL){
+ if(((event_t*)(events->array[i]))->type != NULL){
field->field_pos = 0;
- type = lookup_named_type(f,((event*)(events->array[i]))->type);
+ type = lookup_named_type(f,((event_t*)(events->array[i]))->type);
field->field_type = type;
field->offset_root = 0;
field->fixed_root = 1;
field->current_element = 0;
//construct field tree and type graph
- constructTypeAndFields(f,((event*)(events->array[i]))->type,field);
+ constructTypeAndFields(f,((event_t*)(events->array[i]))->type,field);
}else{
evType->root_field = NULL;
g_free(field);
fld->child = g_new(LttField*, td->fields.position);
for(i=0;i<td->fields.position;i++){
- tmpTd = ((field*)(td->fields.array[i]))->type;
+ tmpTd = ((type_fields*)(td->fields.array[i]))->type;
if(flag)
fld->field_type->element_type[i] = lookup_named_type(fac, tmpTd);
if(flag){
fld->child[i]->field_type->element_name
- = g_strdup(((field*)(td->fields.array[i]))->name);
+ = g_strdup(((type_fields*)(td->fields.array[i]))->name);
}
fld->child[i]->offset_root = -1;
LttType * lookup_named_type(LttFacility *fac, type_descriptor * td)
{
LttType * lttType = NULL;
- int i;
+ unsigned int i;
char * name;
if(td->type_name){
for(i=0;i<fac->named_types_number; i++){
void freeFacility(LttFacility * fac)
{
- int i;
+ unsigned int i;
g_free(fac->name); //free facility name
//free event types
void freeLttNamedType(LttType * type)
{
- int i;
g_free(type->type_name);
type->type_name = NULL;
freeLttType(&type);
void freeLttType(LttType ** type)
{
- int i;
+ unsigned int i;
if(*type == NULL) return;
if((*type)->type_name){
return; //this is a named type
unsigned ltt_facility_eventtype_number(LttFacility *f)
{
- return (unsigned)(f->event_number);
+ return (f->event_number);
}
/*****************************************************************************
LttEventType *ltt_facility_eventtype_get_by_name(LttFacility *f, char *name)
{
- int i;
+ unsigned int i;
LttEventType * ev;
for(i=0;i<f->event_number;i++){
ev = f->events[i];
LttEventType *ltt_facility_eventtype_get_by_name(LttFacility *f, char *name);
+int ltt_facility_close(LttFacility *f);
+
#endif // FACILITY_H
char * type_name; //type name if it is a named type
char * element_name; //elements name of the struct
char * fmt;
- int size;
+ unsigned int size;
LttTypeEnum type_class; //which type
char ** enum_strings; //for enum labels
struct _LttType ** element_type; //for array, sequence and struct
int index; //id of the event type within the facility
LttFacility * facility; //the facility that contains the event type
LttField * root_field; //root field
- int latest_block; //the latest block using the event type
- int latest_event; //the latest event using the event type
+ unsigned int latest_block; //the latest block using the event type
+ unsigned int latest_event; //the latest event using the event type
};
struct _LttEvent{
LttCycleCount event_cycle_count;
LttTracefile * tracefile;
void * data; //event data
- int which_block; //the current block of the event
- int which_event; //the position of the event
+ unsigned int which_block; //the current block of the event
+ unsigned int which_event; //the position of the event
/* This is a workaround for fast position seek */
void * last_event_pos;
struct _LttFacility{
char * name; //facility name
- int event_number; //number of events in the facility
+ unsigned int event_number; //number of events in the facility
LttChecksum checksum; //checksum of the facility
guint32 base_id; //base id of the facility
LttEventType ** events; //array of event types
LttType ** named_types;
- int named_types_number;
+ unsigned int named_types_number;
};
struct _LttTracefile{
int fd; //file descriptor
off_t file_size; //file size
unsigned block_size; //block_size
- int block_number; //number of blocks in the file
- int which_block; //which block the current block is
- int which_event; //which event of the current block
+ unsigned int block_number; //number of blocks in the file
+ unsigned int which_block; //which block the current block is
+ unsigned int which_event; //which event of the current block
//is currently processed
LttTime current_event_time; //time of the current event
BlockStart * a_block_start; //block start of the block
LttTime prev_block_end_time; //the end time of previous block
LttTime prev_event_time; //the time of the previous event
LttCycleCount pre_cycle_count; //previous cycle count of the event
- int count; //the number of overflow of cycle count
+ unsigned int count; //the number of overflow of cycle count
};
struct _LttTrace{
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
+#include <ctype.h>
#include <linux/errno.h>
int getSizeAttribute(parse_file *in)
{
- char * token;
+ /* skip name and equal */
getName(in);
getEqual(in);
int getValueAttribute(parse_file *in)
{
- char * token;
+ /* skip name and equal */
getName(in);
getEqual(in);
* fac : facility filled with event list
****************************************************************************/
-void parseFacility(parse_file *in, facility * fac)
+void parseFacility(parse_file *in, facility_t * fac)
{
char * token;
- event *ev;
+ event_t *ev;
fac->name = allocAndCopy(getNameAttribute(in));
getRAnglebracket(in);
in->error(in,"the definition of the facility is not finished");
if(strcmp("event",token) == 0){
- ev = (event*) memAlloc(sizeof(event));
+ ev = (event_t*) memAlloc(sizeof(event_t));
sequence_push(&(fac->events),ev);
parseEvent(in,ev, &(fac->unnamed_types), &(fac->named_types));
}else if(strcmp("type",token) == 0){
* ev : new event (parameters are passed to it)
****************************************************************************/
-void parseEvent(parse_file *in, event * ev, sequence * unnamed_types,
+void parseEvent(parse_file *in, event_t * ev, sequence * unnamed_types,
table * named_types)
{
char *token;
- type_descriptor *t;
//<event name=eventtype_name>
ev->name = allocAndCopy(getNameAttribute(in));
table * named_types)
{
char * token;
- field *f;
+ type_fields *f;
- f = (field *)memAlloc(sizeof(field));
+ f = (type_fields *)memAlloc(sizeof(type_fields));
sequence_push(&(t->fields),f);
//<field name=field_name> <description> <type> </field>
if(car == EOF)ungetc(car, in->fp);
}
-int isalpha(char c)
-{
- int i,j;
- if(c == '_')return 1;
- i = c - 'a';
- j = c - 'A';
- if((i>=0 && i<26) || (j>=0 && j<26)) return 1;
- return 0;
-}
-
-int isalnum(char c)
-{
- return (isalpha(c) || isdigit(c));
-}
-
/*****************************************************************************
*Function name
* checkNamedTypesImplemented : check if all named types have definition
{
unsigned long crc ;
int pos;
- event * ev;
+ event_t * ev;
char str[256];
crc = crc32(facName);
for(pos = 0; pos < events->position; pos++){
- ev = (event *)(events->array[pos]);
+ ev = (event_t *)(events->array[pos]);
crc = partial_crc32(ev->name,crc);
if(!ev->type) continue; //event without type
if(ev->type->type != STRUCT){
unsigned long crc = aCrc;
char * str = NULL, buf[16];
int flag = 0, pos;
- field * fld;
+ type_fields * fld;
switch(type->type){
case INT:
flag = 1;
break;
case ARRAY:
- sprintf(buf,"%d\0",type->size);
+ sprintf(buf,"%d",type->size);
str = appendString("array ",buf);
flag = 1;
break;
case SEQUENCE:
- sprintf(buf,"%d\0",type->size);
+ sprintf(buf,"%d",type->size);
str = appendString("sequence ",buf);
flag = 1;
break;
crc = getTypeChecksum(crc,type->nested_type);
}else if(type->type == STRUCT || type->type == UNION){
for(pos =0; pos < type->fields.position; pos++){
- fld = (field *) type->fields.array[pos];
+ fld = (type_fields *) type->fields.array[pos];
crc = partial_crc32(fld->name,crc);
crc = getTypeChecksum(crc, fld->type);
}
void freeType(type_descriptor * tp)
{
int pos2;
- field *f;
+ type_fields *f;
if(tp->fmt != NULL) free(tp->fmt);
if(tp->type == ENUM) {
}
if(tp->type == STRUCT) {
for(pos2 = 0; pos2 < tp->fields.position; pos2++) {
- f = (field *) tp->fields.array[pos2];
+ f = (type_fields *) tp->fields.array[pos2];
free(f->name);
free(f->description);
free(f);
void freeTypes(sequence *t)
{
- int pos, pos2;
+ int pos;
type_descriptor *tp;
- field *f;
for(pos = 0 ; pos < t->position; pos++) {
tp = (type_descriptor *)t->array[pos];
void freeEvents(sequence *t)
{
int pos;
- event *ev;
+ event_t *ev;
for(pos = 0 ; pos < t->position; pos++) {
- ev = (event *) t->array[pos];
+ ev = (event_t *) t->array[pos];
free(ev->name);
free(ev->description);
free(ev);
void skipComment(parse_file * in);
void skipEOL(parse_file * in);
-int isalpha(char car);
-int isalnum(char car);
/* Some constants */
/* Fields within types */
-typedef struct _field{
+typedef struct _type_fields{
char *name;
char *description;
type_descriptor *type;
-} field;
+} type_fields;
/* Events definitions */
-typedef struct _event {
+typedef struct _event_t {
char *name;
char *description;
type_descriptor *type;
-} event;
+} event_t;
-typedef struct _facility {
+typedef struct _facility_t {
char * name;
char * description;
sequence events;
sequence unnamed_types;
table named_types;
-} facility;
+} facility_t;
int getSize(parse_file *in);
unsigned long getTypeChecksum(unsigned long aCrc, type_descriptor * type);
-void parseFacility(parse_file *in, facility * fac);
-void parseEvent(parse_file *in, event *ev, sequence * unnamed_types, table * named_types);
+void parseFacility(parse_file *in, facility_t * fac);
+void parseEvent(parse_file *in, event_t *ev, sequence * unnamed_types, table * named_types);
void parseTypeDefinition(parse_file *in, sequence * unnamed_types, table * named_types);
type_descriptor *parseType(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types);
void parseFields(parse_file *in, type_descriptor *t, sequence * unnamed_types, table * named_types);
}
-static inline LttTime ltt_time_mul(LttTime t1, float f)
-{
- LttTime res;
- float d;
- double sec;
-
- if(f == 0.0){
- res.tv_sec = 0;
- res.tv_nsec = 0;
- }else{
- d = 1.0/f;
- sec = t1.tv_sec / (double)d;
- res.tv_sec = sec;
- res.tv_nsec = t1.tv_nsec / (double)d + (sec - res.tv_sec) *
- NANOSECONDS_PER_SECOND;
- res.tv_sec += res.tv_nsec / NANOSECONDS_PER_SECOND;
- res.tv_nsec %= NANOSECONDS_PER_SECOND;
- }
- return res;
-}
-
-
-static inline LttTime ltt_time_div(LttTime t1, float f)
-{
- double sec;
- LttTime res;
-
- sec = t1.tv_sec / (double)f;
- res.tv_sec = sec;
- res.tv_nsec = t1.tv_nsec / (double)f + (sec - res.tv_sec) *
- NANOSECONDS_PER_SECOND;
- res.tv_sec += res.tv_nsec / NANOSECONDS_PER_SECOND;
- res.tv_nsec %= NANOSECONDS_PER_SECOND;
- return res;
-}
-
-
static inline int ltt_time_compare(LttTime t1, LttTime t2)
{
if(t1.tv_sec > t2.tv_sec) return 1;
return res;
}
+/* Use ltt_time_to_double and ltt_time_from_double to check for lack
+ * of precision.
+ */
+static inline LttTime ltt_time_mul(LttTime t1, double d)
+{
+ LttTime res;
+
+ double time_double = ltt_time_to_double(t1);
+
+ time_double = time_double * d;
+
+ res = ltt_time_from_double(time_double);
+
+ return res;
+
+#if 0
+ /* What is that ? (Mathieu) */
+ if(f == 0.0){
+ res.tv_sec = 0;
+ res.tv_nsec = 0;
+ }else{
+ double d;
+ d = 1.0/f;
+ sec = t1.tv_sec / (double)d;
+ res.tv_sec = sec;
+ res.tv_nsec = t1.tv_nsec / (double)d + (sec - res.tv_sec) *
+ NANOSECONDS_PER_SECOND;
+ res.tv_sec += res.tv_nsec / NANOSECONDS_PER_SECOND;
+ res.tv_nsec %= NANOSECONDS_PER_SECOND;
+ }
+ return res;
+#endif //0
+}
+
+
+/* Use ltt_time_to_double and ltt_time_from_double to check for lack
+ * of precision.
+ */
+static inline LttTime ltt_time_div(LttTime t1, double d)
+{
+ LttTime res;
+
+ double time_double = ltt_time_to_double(t1);
+
+ time_double = time_double / d;
+
+ res = ltt_time_from_double(time_double);
+
+ return res;
+
+
+#if 0
+ double sec;
+ LttTime res;
+
+ sec = t1.tv_sec / (double)f;
+ res.tv_sec = sec;
+ res.tv_nsec = t1.tv_nsec / (double)f + (sec - res.tv_sec) *
+ NANOSECONDS_PER_SECOND;
+ res.tv_sec += res.tv_nsec / NANOSECONDS_PER_SECOND;
+ res.tv_nsec %= NANOSECONDS_PER_SECOND;
+ return res;
+#endif //0
+}
+
+
#endif // LTT_TIME_H
unsigned ltt_trace_per_cpu_tracefile_number(LttTrace *t);
-/* It is possible to search for the tracefiles by name or by CPU position.
- The index within the tracefiles of the same type is returned if found
- and a negative value otherwise. */
+/* It is possible to search for the tracefiles by name or by CPU tracefile
+ * name.
+ * The index within the tracefiles of the same type is returned if found
+ * and a negative value otherwise.
+ */
-int ltt_trace_control_tracefile_find(LttTrace *t, char *name);
+int ltt_trace_control_tracefile_find(LttTrace *t, const gchar *name);
-int ltt_trace_per_cpu_tracefile_find(LttTrace *t, unsigned i);
+int ltt_trace_per_cpu_tracefile_find(LttTrace *t, const gchar *name);
/* Get a specific tracefile */
#include <stdio.h>
#include <fcntl.h>
+#include <string.h>
+#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <dirent.h>
-#include <linux/errno.h>
+#include <errno.h>
+#include <unistd.h>
// For realpath
#include <limits.h>
#include <ltt/trace.h>
#include <ltt/facility.h>
#include <ltt/event.h>
+#include <ltt/type.h>
#define DIR_NAME_SIZE 256
+#define UNUSED __attribute__((__unused__))
/* set the offset of the fields belonging to the event,
need the information of the archecture */
/* Functions to parse system.xml file (using glib xml parser) */
-static void parser_start_element (GMarkupParseContext *context,
+static void parser_start_element (GMarkupParseContext UNUSED *context,
const gchar *element_name,
const gchar **attribute_names,
const gchar **attribute_values,
}
}
-static void parser_end_element (GMarkupParseContext *context,
- const gchar *element_name,
- gpointer user_data,
- GError **error)
-{
-}
-
-static void parser_characters (GMarkupParseContext *context,
+static void parser_characters (GMarkupParseContext UNUSED *context,
const gchar *text,
- gsize text_len,
+ gsize UNUSED text_len,
gpointer user_data,
- GError **error)
+ GError UNUSED **error)
{
LttSystemDescription* des = (LttSystemDescription* )user_data;
des->description = g_strdup(text);
{
LttTracefile * tf;
struct stat lTDFStat; /* Trace data file status */
- BlockStart a_block_start;
tf = g_new(LttTracefile, 1);
}
// Is the file large enough to contain a trace
- if(lTDFStat.st_size < sizeof(BlockStart) + EVENT_HEADER_SIZE){
+ if(lTDFStat.st_size < (off_t)(sizeof(BlockStart) + EVENT_HEADER_SIZE)){
g_print("The input data file %s does not contain a trace\n", fileName);
g_free(tf->name);
close(tf->fd);
LttTracefile * tf;
LttEvent ev;
LttFacility * f;
- guint16 evId;
void * pos;
FacilityLoad fLoad;
- int i;
+ unsigned int i;
tf = ltt_tracefile_open(t,control_name);
if(!tf) {
}
}
if(i==t->facility_number) {
- g_warning("Facility: %s, checksum: %d is not found\n",
- fLoad.name,fLoad.checksum);
+ g_warning("Facility: %s, checksum: %u is not found",
+ fLoad.name,(unsigned int)fLoad.checksum);
return -1;
}
}else if(ev.event_id == TRACE_BLOCK_START){
}else if(ev.event_id == TRACE_BLOCK_END){
break;
}else {
- g_warning("Not valid facilities trace file\n");
+ g_warning("Not valid facilities trace file");
return -1;
}
}
{
FILE * fp;
char buf[DIR_NAME_SIZE];
- char description[4*DIR_NAME_SIZE];
GMarkupParseContext * context;
GError * error = NULL;
GMarkupParser markup_parser =
{
parser_start_element,
- parser_end_element,
+ NULL,
parser_characters,
NULL, /* passthrough */
NULL /* error */
DIR * dir;
struct dirent *entry;
char * ptr;
- int i,j;
+ unsigned int i,j;
LttFacility * f;
LttEventType * et;
char name[DIR_NAME_SIZE];
*
*When a trace is closed, all the associated facilities, types and fields
*are released as well.
+ */
+
+
+/****************************************************************************
+ * get_absolute_pathname
*
+ * return the unique pathname in the system
+ *
* MD : Fixed this function so it uses realpath, dealing well with
* forgotten cases (.. were not used correctly before).
*
****************************************************************************/
-
void get_absolute_pathname(const char *pathname, char * abs_pathname)
{
- char * ptr, *ptr1;
- size_t size = DIR_NAME_SIZE;
abs_pathname[0] = '\0';
if ( realpath (pathname, abs_pathname) != NULL)
return;
else
{
- // FIXME : Path is wrong, is it ok to return the pathname unmodified ?
+ /* error, return the original path unmodified */
strcpy(abs_pathname, pathname);
return;
}
-
return;
-
}
LttTrace *ltt_trace_open(const char *pathname)
void ltt_trace_close(LttTrace *t)
{
- int i;
+ unsigned int i;
LttTracefile * tf;
LttFacility * f;
unsigned ltt_trace_facility_find(LttTrace *t, char *name, unsigned *position)
{
- int i, count=0;
+ unsigned int i, count=0;
LttFacility * f;
for(i=0;i<t->facility_number;i++){
f = (LttFacility*)g_ptr_array_index(t->facilities, i);
unsigned ltt_trace_eventtype_number(LttTrace *t)
{
- int i;
+ unsigned int i;
unsigned count = 0;
LttFacility * f;
for(i=0;i<t->facility_number;i++){
LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id)
{
LttFacility * facility;
- int i;
+ unsigned int i;
for(i=0;i<trace->facility_number;i++){
facility = (LttFacility*) g_ptr_array_index(trace->facilities,i);
if(id >= facility->base_id &&
*and a negative value otherwise.
****************************************************************************/
-int ltt_trace_control_tracefile_find(LttTrace *t, char *name)
+int ltt_trace_control_tracefile_find(LttTrace *t, const gchar *name)
{
LttTracefile * tracefile;
- int i;
+ unsigned int i;
for(i=0;i<t->control_tracefile_number;i++){
tracefile = (LttTracefile*)g_ptr_array_index(t->control_tracefiles, i);
if(strcmp(tracefile->name, name)==0)break;
return i;
}
-int ltt_trace_per_cpu_tracefile_find(LttTrace *t, unsigned i)
+/* not really useful. We just have to know that cpu tracefiles
+ * comes before control tracefiles.
+ */
+int ltt_trace_per_cpu_tracefile_find(LttTrace *t, const gchar *name)
{
LttTracefile * tracefile;
- int j, name;
- for(j=0;j<t->per_cpu_tracefile_number;j++){
- tracefile = (LttTracefile*)g_ptr_array_index(t->per_cpu_tracefiles, j);
- name = atoi(tracefile->name);
- if(name == (int)i)break;
+ unsigned int i;
+ for(i=0;i<t->per_cpu_tracefile_number;i++){
+ tracefile = (LttTracefile*)g_ptr_array_index(t->per_cpu_tracefiles, i);
+ if(strcmp(tracefile->name, name)==0)break;
}
- if(j == t->per_cpu_tracefile_number) return -1;
- return j;
+ if(i == t->per_cpu_tracefile_number) return -1;
+ return i;
}
/*****************************************************************************
void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end)
{
LttTime startSmall, startTmp, endBig, endTmp;
- int i, j=0;
+ unsigned int i, j=0;
LttTracefile * tf;
for(i=0;i<t->control_tracefile_number;i++){
lttTime = getEventTime(t);
err = ltt_time_compare(lttTime, time);
if(err > 0){
- if(t->which_event==2 || (&t->prev_event_time,&time)<0){
+ if(t->which_event==2 || ltt_time_compare(t->prev_event_time,time)<0){
return;
}else{
updateTracefile(t);
int readFile(int fd, void * buf, size_t size, char * mesg)
{
- ssize_t nbBytes;
- nbBytes = read(fd, buf, size);
- if(nbBytes != size){
- printf("%s\n",mesg);
+ ssize_t nbBytes = read(fd, buf, size);
+
+ if((size_t)nbBytes != size) {
+ if(nbBytes < 0) {
+ perror("Error in readFile : ");
+ } else {
+ g_warning("%s",mesg);
+ }
return EIO;
}
return 0;
int skipEvent(LttTracefile * t)
{
- int evId, err;
+ int evId;
void * evData;
LttEventType * evT;
LttField * rootFld;
* t : a type
*Return value
* unsigned : the type size
+ * returns 0 if erroneous, and show a critical warning message.
****************************************************************************/
unsigned ltt_type_size(LttTrace * trace, LttType *t)
else{
LttArchSize size = trace->system_description->size;
if(size == LTT_LP32){
- if(t->size == 5)return sizeof(int16_t);
- else return sizeof(int32_t);
+ if(t->size == 5)return sizeof(int16_t);
+ else return sizeof(int32_t);
}
else if(size == LTT_ILP32 || size == LTT_LP64){
- if(t->size == 5)return sizeof(int32_t);
- else{
- if(size == LTT_ILP32) return sizeof(int32_t);
- else return sizeof(int64_t);
- }
+ if(t->size == 5)return sizeof(int32_t);
+ else{
+ if(size == LTT_ILP32) return sizeof(int32_t);
+ else return sizeof(int64_t);
+ }
}
else if(size == LTT_ILP64)return sizeof(int64_t);
}
}
+
+ g_critical("ltt_type_size : Type size %u unknown", t->size);
+ return 0;
}
/*****************************************************************************
LttType *ltt_type_member_type(LttType *t, unsigned i, char ** name)
{
- if(t->type_class != LTT_STRUCT){*name == NULL; return NULL;}
- if(i >= t->element_number || i < 0 ){*name = NULL; return NULL;}
+ if(t->type_class != LTT_STRUCT){*name = NULL; return NULL;}
+ if(i >= t->element_number){*name = NULL; return NULL;}
*name = t->element_type[i]->element_name;
return t->element_type[i];
}
char *ltt_enum_string_get(LttType *t, unsigned i)
{
if(t->type_class != LTT_ENUM) return NULL;
- if(i >= t->element_number || i < 0 ) return NULL;
+ if(i >= t->element_number) return NULL;
return t->enum_strings[i];
}
LttField *ltt_field_member(LttField *f, unsigned i)
{
if(f->field_type->type_class != LTT_STRUCT) return NULL;
- if(i < 0 || i >= f->field_type->element_number) return NULL;
+ if(i >= f->field_type->element_number) return NULL;
return f->child[i];
}