1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Xiangxiu Yang, Mathieu Desnoyers
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24 #include <sys/types.h>
36 #include "ltt-private.h"
37 #include <ltt/trace.h>
38 #include <ltt/facility.h>
39 #include <ltt/event.h>
42 #define DIR_NAME_SIZE 256
43 #define __UNUSED__ __attribute__((__unused__))
45 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
46 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
49 /* obtain the time of an event */
51 static inline LttTime
getEventTime(LttTracefile
* tf
);
54 /* set the offset of the fields belonging to the event,
55 need the information of the archecture */
56 void setFieldsOffset(LttTracefile
*tf
,LttEventType
*evT
,void *evD
,LttTrace
*t
);
58 /* get the size of the field type according to the archtecture's
59 size and endian type(info of the archecture) */
60 static inline gint
getFieldtypeSize(LttTracefile
* tf
,
61 LttEventType
* evT
, gint offsetRoot
,
62 gint offsetParent
, LttField
*fld
, void *evD
, LttTrace
* t
);
64 /* read a fixed size or a block information from the file (fd) */
65 int readFile(int fd
, void * buf
, size_t size
, char * mesg
);
66 int readBlock(LttTracefile
* tf
, int whichBlock
);
68 /* calculate cycles per nsec for current block */
69 void getCyclePerNsec(LttTracefile
* t
);
71 /* reinitialize the info of the block which is already in the buffer */
72 void updateTracefile(LttTracefile
* tf
);
74 /* go to the next event */
75 int skipEvent(LttTracefile
* t
);
78 /* Functions to parse system.xml file (using glib xml parser) */
79 static void parser_start_element (GMarkupParseContext __UNUSED__
*context
,
80 const gchar
*element_name
,
81 const gchar
**attribute_names
,
82 const gchar
**attribute_values
,
87 LttSystemDescription
* des
= (LttSystemDescription
* )user_data
;
88 if(strcmp("system", element_name
)){
89 *error
= g_error_new(G_MARKUP_ERROR
,
91 "This is not system.xml file");
95 while(attribute_names
[i
]){
96 if(strcmp("node_name", attribute_names
[i
])==0){
97 des
->node_name
= g_strdup(attribute_values
[i
]);
98 }else if(strcmp("domainname", attribute_names
[i
])==0){
99 des
->domain_name
= g_strdup(attribute_values
[i
]);
100 }else if(strcmp("cpu", attribute_names
[i
])==0){
101 des
->nb_cpu
= atoi(attribute_values
[i
]);
102 }else if(strcmp("arch_size", attribute_names
[i
])==0){
103 if(strcmp(attribute_values
[i
],"LP32") == 0) des
->size
= LTT_LP32
;
104 else if(strcmp(attribute_values
[i
],"ILP32") == 0) des
->size
= LTT_ILP32
;
105 else if(strcmp(attribute_values
[i
],"LP64") == 0) des
->size
= LTT_LP64
;
106 else if(strcmp(attribute_values
[i
],"ILP64") == 0) des
->size
= LTT_ILP64
;
107 else if(strcmp(attribute_values
[i
],"UNKNOWN") == 0) des
->size
= LTT_UNKNOWN
;
108 }else if(strcmp("endian", attribute_names
[i
])==0){
109 if(strcmp(attribute_values
[i
],"LITTLE_ENDIAN") == 0)
110 des
->endian
= LTT_LITTLE_ENDIAN
;
111 else if(strcmp(attribute_values
[i
],"BIG_ENDIAN") == 0)
112 des
->endian
= LTT_BIG_ENDIAN
;
113 }else if(strcmp("kernel_name", attribute_names
[i
])==0){
114 des
->kernel_name
= g_strdup(attribute_values
[i
]);
115 }else if(strcmp("kernel_release", attribute_names
[i
])==0){
116 des
->kernel_release
= g_strdup(attribute_values
[i
]);
117 }else if(strcmp("kernel_version", attribute_names
[i
])==0){
118 des
->kernel_version
= g_strdup(attribute_values
[i
]);
119 }else if(strcmp("machine", attribute_names
[i
])==0){
120 des
->machine
= g_strdup(attribute_values
[i
]);
121 }else if(strcmp("processor", attribute_names
[i
])==0){
122 des
->processor
= g_strdup(attribute_values
[i
]);
123 }else if(strcmp("hardware_platform", attribute_names
[i
])==0){
124 des
->hardware_platform
= g_strdup(attribute_values
[i
]);
125 }else if(strcmp("operating_system", attribute_names
[i
])==0){
126 des
->operating_system
= g_strdup(attribute_values
[i
]);
127 }else if(strcmp("ltt_major_version", attribute_names
[i
])==0){
128 des
->ltt_major_version
= atoi(attribute_values
[i
]);
129 }else if(strcmp("ltt_minor_version", attribute_names
[i
])==0){
130 des
->ltt_minor_version
= atoi(attribute_values
[i
]);
131 }else if(strcmp("ltt_block_size", attribute_names
[i
])==0){
132 des
->ltt_block_size
= atoi(attribute_values
[i
]);
134 *error
= g_error_new(G_MARKUP_ERROR
,
136 "Not a valid attribute");
143 static void parser_characters (GMarkupParseContext __UNUSED__
*context
,
145 gsize __UNUSED__ text_len
,
147 GError __UNUSED__
**error
)
149 LttSystemDescription
* des
= (LttSystemDescription
* )user_data
;
150 des
->description
= g_strdup(text
);
154 /*****************************************************************************
156 * ltt_tracefile_open : open a trace file, construct a LttTracefile
158 * t : the trace containing the tracefile
159 * fileName : path name of the trace file
161 * : a pointer to a tracefile
162 ****************************************************************************/
164 LttTracefile
* ltt_tracefile_open(LttTrace
* t
, char * fileName
)
167 struct stat lTDFStat
; /* Trace data file status */
169 tf
= g_new(LttTracefile
, 1);
172 tf
->name
= g_strdup(fileName
);
174 tf
->fd
= open(fileName
, O_RDONLY
, 0);
176 g_warning("Unable to open input data file %s\n", fileName
);
182 // Get the file's status
183 if(fstat(tf
->fd
, &lTDFStat
) < 0){
184 g_warning("Unable to get the status of the input data file %s\n", fileName
);
191 // Is the file large enough to contain a trace
192 if(lTDFStat
.st_size
< (off_t
)(sizeof(BlockStart
) + EVENT_HEADER_SIZE
)){
193 g_print("The input data file %s does not contain a trace\n", fileName
);
200 //store the size of the file
201 tf
->file_size
= lTDFStat
.st_size
;
202 tf
->block_size
= t
->system_description
->ltt_block_size
;
203 tf
->block_number
= tf
->file_size
/ tf
->block_size
;
206 //allocate memory to contain the info of a block
207 tf
->buffer
= (void *) g_new(char, t
->system_description
->ltt_block_size
);
209 //read the first block
210 if(readBlock(tf
,1)) exit(1);
216 /*****************************************************************************
217 *Open control and per cpu tracefiles
218 ****************************************************************************/
220 void ltt_tracefile_open_cpu(LttTrace
*t
, char * tracefile_name
)
223 tf
= ltt_tracefile_open(t
,tracefile_name
);
225 t
->per_cpu_tracefile_number
++;
226 g_ptr_array_add(t
->per_cpu_tracefiles
, tf
);
229 gint
ltt_tracefile_open_control(LttTrace
*t
, char * control_name
)
238 tf
= ltt_tracefile_open(t
,control_name
);
240 g_warning("ltt_tracefile_open_control : bad file descriptor");
243 t
->control_tracefile_number
++;
244 g_ptr_array_add(t
->control_tracefiles
,tf
);
246 //parse facilities tracefile to get base_id
247 if(strcmp(&control_name
[strlen(control_name
)-10],"facilities") ==0){
249 if(!ltt_tracefile_read(tf
,&ev
)) return 0; // end of file
251 if(ev
.event_id
== TRACE_FACILITY_LOAD
){
253 fLoad
.name
= (char*)pos
;
254 fLoad
.checksum
= *(LttChecksum
*)(pos
+ strlen(fLoad
.name
));
255 fLoad
.base_code
= *(guint32
*)(pos
+ strlen(fLoad
.name
) + sizeof(LttChecksum
));
257 for(i
=0;i
<t
->facility_number
;i
++){
258 f
= (LttFacility
*)g_ptr_array_index(t
->facilities
,i
);
259 if(strcmp(f
->name
,fLoad
.name
)==0 && fLoad
.checksum
==f
->checksum
){
260 f
->base_id
= fLoad
.base_code
;
264 if(i
==t
->facility_number
) {
265 g_warning("Facility: %s, checksum: %u is not found",
266 fLoad
.name
,(unsigned int)fLoad
.checksum
);
269 }else if(ev
.event_id
== TRACE_BLOCK_START
){
271 }else if(ev
.event_id
== TRACE_BLOCK_END
){
274 g_warning("Not valid facilities trace file");
282 /*****************************************************************************
284 * ltt_tracefile_close: close a trace file,
286 * t : tracefile which will be closed
287 ****************************************************************************/
289 void ltt_tracefile_close(LttTracefile
*t
)
298 /*****************************************************************************
299 *Get system information
300 ****************************************************************************/
301 gint
getSystemInfo(LttSystemDescription
* des
, char * pathname
)
304 char buf
[DIR_NAME_SIZE
];
306 GMarkupParseContext
* context
;
307 GError
* error
= NULL
;
308 GMarkupParser markup_parser
=
310 parser_start_element
,
313 NULL
, /* passthrough */
317 fp
= fopen(pathname
,"r");
319 g_warning("Can not open file : %s\n", pathname
);
323 context
= g_markup_parse_context_new(&markup_parser
, 0, des
,NULL
);
325 while(fgets(buf
,DIR_NAME_SIZE
, fp
) != NULL
){
326 if(!g_markup_parse_context_parse(context
, buf
, DIR_NAME_SIZE
, &error
)){
328 g_warning("Can not parse xml file: \n%s\n", error
->message
);
331 g_markup_parse_context_free(context
);
336 g_markup_parse_context_free(context
);
341 /*****************************************************************************
342 *The following functions get facility/tracefile information
343 ****************************************************************************/
345 gint
getFacilityInfo(LttTrace
*t
, char* eventdefs
)
348 struct dirent
*entry
;
353 char name
[DIR_NAME_SIZE
];
355 dir
= opendir(eventdefs
);
357 g_warning("Can not open directory: %s\n", eventdefs
);
361 while((entry
= readdir(dir
)) != NULL
){
362 ptr
= &entry
->d_name
[strlen(entry
->d_name
)-4];
363 if(strcmp(ptr
,".xml") != 0) continue;
364 strcpy(name
,eventdefs
);
365 strcat(name
,entry
->d_name
);
366 ltt_facility_open(t
,name
);
370 for(j
=0;j
<t
->facility_number
;j
++){
371 f
= (LttFacility
*)g_ptr_array_index(t
->facilities
, j
);
372 for(i
=0; i
<f
->event_number
; i
++){
374 setFieldsOffset(NULL
, et
, NULL
, t
);
380 gint
getControlFileInfo(LttTrace
*t
, char* control
)
383 struct dirent
*entry
;
384 char name
[DIR_NAME_SIZE
];
386 dir
= opendir(control
);
388 g_warning("Can not open directory: %s\n", control
);
392 while((entry
= readdir(dir
)) != NULL
){
393 if(strcmp(entry
->d_name
,"facilities") != 0 &&
394 strcmp(entry
->d_name
,"interrupts") != 0 &&
395 strcmp(entry
->d_name
,"processes") != 0) continue;
397 strcpy(name
,control
);
398 strcat(name
,entry
->d_name
);
399 if(ltt_tracefile_open_control(t
,name
))
406 gint
getCpuFileInfo(LttTrace
*t
, char* cpu
)
409 struct dirent
*entry
;
410 char name
[DIR_NAME_SIZE
];
414 g_warning("Can not open directory: %s\n", cpu
);
418 while((entry
= readdir(dir
)) != NULL
){
419 if(strcmp(entry
->d_name
,".") != 0 &&
420 strcmp(entry
->d_name
,"..") != 0 &&
421 strcmp(entry
->d_name
,".svn") != 0){
423 strcat(name
,entry
->d_name
);
424 ltt_tracefile_open_cpu(t
,name
);
431 /*****************************************************************************
432 *A trace is specified as a pathname to the directory containing all the
433 *associated data (control tracefiles, per cpu tracefiles, event
436 *When a trace is closed, all the associated facilities, types and fields
437 *are released as well.
441 /****************************************************************************
442 * get_absolute_pathname
444 * return the unique pathname in the system
446 * MD : Fixed this function so it uses realpath, dealing well with
447 * forgotten cases (.. were not used correctly before).
449 ****************************************************************************/
450 void get_absolute_pathname(const char *pathname
, char * abs_pathname
)
452 abs_pathname
[0] = '\0';
454 if ( realpath (pathname
, abs_pathname
) != NULL
)
458 /* error, return the original path unmodified */
459 strcpy(abs_pathname
, pathname
);
465 LttTrace
*ltt_trace_open(const char *pathname
)
468 LttSystemDescription
* sys_description
;
469 char eventdefs
[DIR_NAME_SIZE
];
470 char info
[DIR_NAME_SIZE
];
471 char control
[DIR_NAME_SIZE
];
472 char cpu
[DIR_NAME_SIZE
];
473 char tmp
[DIR_NAME_SIZE
];
474 char abs_path
[DIR_NAME_SIZE
];
475 gboolean has_slash
= FALSE
;
477 get_absolute_pathname(pathname
, abs_path
);
478 //establish the pathname to different directories
479 if(abs_path
[strlen(abs_path
)-1] == '/')has_slash
= TRUE
;
480 strcpy(eventdefs
,abs_path
);
481 if(!has_slash
)strcat(eventdefs
,"/");
482 strcat(eventdefs
,"eventdefs/");
484 strcpy(info
,abs_path
);
485 if(!has_slash
)strcat(info
,"/");
486 strcat(info
,"info/");
488 strcpy(control
,abs_path
);
489 if(!has_slash
)strcat(control
,"/");
490 strcat(control
,"control/");
492 strcpy(cpu
,abs_path
);
493 if(!has_slash
)strcat(cpu
,"/");
497 sys_description
= g_new(LttSystemDescription
, 1);
498 t
= g_new(LttTrace
, 1);
499 t
->pathname
= g_strdup(abs_path
);
500 t
->facility_number
= 0;
501 t
->control_tracefile_number
= 0;
502 t
->per_cpu_tracefile_number
= 0;
503 t
->system_description
= sys_description
;
504 t
->control_tracefiles
= g_ptr_array_new();
505 t
->per_cpu_tracefiles
= g_ptr_array_new();
506 t
->facilities
= g_ptr_array_new();
507 getDataEndianType(&(t
->my_arch_size
), &(t
->my_arch_endian
));
509 //get system description
511 strcat(tmp
,"system.xml");
512 if(getSystemInfo(sys_description
, tmp
)) {
513 g_ptr_array_free(t
->facilities
, TRUE
);
514 g_ptr_array_free(t
->per_cpu_tracefiles
, TRUE
);
515 g_ptr_array_free(t
->control_tracefiles
, TRUE
);
516 g_free(sys_description
);
524 //get facilities info
525 if(getFacilityInfo(t
,eventdefs
)) {
526 g_ptr_array_free(t
->facilities
, TRUE
);
527 g_ptr_array_free(t
->per_cpu_tracefiles
, TRUE
);
528 g_ptr_array_free(t
->control_tracefiles
, TRUE
);
529 g_free(sys_description
);
535 //get control tracefile info
536 getControlFileInfo(t
,control
);
538 if(getControlFileInfo(t,control)) {
539 g_ptr_array_free(t->facilities, TRUE);
540 g_ptr_array_free(t->per_cpu_tracefiles, TRUE);
541 g_ptr_array_free(t->control_tracefiles, TRUE);
542 g_free(sys_description);
546 }*/ // With fatal error
548 //get cpu tracefile info
549 if(getCpuFileInfo(t
,cpu
)) {
550 g_ptr_array_free(t
->facilities
, TRUE
);
551 g_ptr_array_free(t
->per_cpu_tracefiles
, TRUE
);
552 g_ptr_array_free(t
->control_tracefiles
, TRUE
);
553 g_free(sys_description
);
562 char * ltt_trace_name(LttTrace
*t
)
568 /******************************************************************************
569 * When we copy a trace, we want all the opening actions to happen again :
570 * the trace will be reopened and totally independant from the original.
571 * That's why we call ltt_trace_open.
572 *****************************************************************************/
573 LttTrace
*ltt_trace_copy(LttTrace
*self
)
575 return ltt_trace_open(self
->pathname
);
578 void ltt_trace_close(LttTrace
*t
)
586 //free system_description
587 g_free(t
->system_description
->description
);
588 g_free(t
->system_description
->node_name
);
589 g_free(t
->system_description
->domain_name
);
590 g_free(t
->system_description
->kernel_name
);
591 g_free(t
->system_description
->kernel_release
);
592 g_free(t
->system_description
->kernel_version
);
593 g_free(t
->system_description
->machine
);
594 g_free(t
->system_description
->processor
);
595 g_free(t
->system_description
->hardware_platform
);
596 g_free(t
->system_description
->operating_system
);
597 g_free(t
->system_description
);
599 //free control_tracefiles
600 for(i
=0;i
<t
->control_tracefile_number
;i
++){
601 tf
= (LttTracefile
*)g_ptr_array_index(t
->control_tracefiles
,i
);
602 ltt_tracefile_close(tf
);
604 g_ptr_array_free(t
->control_tracefiles
, TRUE
);
606 //free per_cpu_tracefiles
607 for(i
=0;i
<t
->per_cpu_tracefile_number
;i
++){
608 tf
= (LttTracefile
*)g_ptr_array_index(t
->per_cpu_tracefiles
,i
);
609 ltt_tracefile_close(tf
);
611 g_ptr_array_free(t
->per_cpu_tracefiles
, TRUE
);
614 for(i
=0;i
<t
->facility_number
;i
++){
615 f
= (LttFacility
*)g_ptr_array_index(t
->facilities
,i
);
616 ltt_facility_close(f
);
618 g_ptr_array_free(t
->facilities
, TRUE
);
626 /*****************************************************************************
627 *Get the system description of the trace
628 ****************************************************************************/
630 LttSystemDescription
*ltt_trace_system_description(LttTrace
*t
)
632 return t
->system_description
;
635 /*****************************************************************************
636 * The following functions discover the facilities of the trace
637 ****************************************************************************/
639 unsigned ltt_trace_facility_number(LttTrace
*t
)
641 return (unsigned)(t
->facility_number
);
644 LttFacility
*ltt_trace_facility_get(LttTrace
*t
, unsigned i
)
646 return (LttFacility
*)g_ptr_array_index(t
->facilities
, i
);
649 /*****************************************************************************
651 * ltt_trace_facility_find : find facilities in the trace
654 * name : facility name
656 * position : position of the facility in the trace
658 * : the number of facilities
659 ****************************************************************************/
661 unsigned ltt_trace_facility_find(LttTrace
*t
, char *name
, unsigned *position
)
663 unsigned int i
, count
=0;
665 for(i
=0;i
<t
->facility_number
;i
++){
666 f
= (LttFacility
*)g_ptr_array_index(t
->facilities
, i
);
667 if(strcmp(f
->name
,name
)==0){
669 if(count
==1) *position
= i
;
677 /*****************************************************************************
678 * Functions to discover all the event types in the trace
679 ****************************************************************************/
681 unsigned ltt_trace_eventtype_number(LttTrace
*t
)
685 unsigned int num
= t
->facility_number
;
689 f
= (LttFacility
*)g_ptr_array_index(t
->facilities
, i
);
690 count
+= f
->event_number
;
695 /* FIXME : performances could be improved with a better design for this
696 * function : sequential search through a container has never been the
697 * best on the critical path. */
698 LttFacility
* ltt_trace_facility_by_id(LttTrace
* trace
, unsigned id
)
700 LttFacility
* facility
= NULL
;
702 unsigned int num
= trace
->facility_number
;
703 GPtrArray
*facilities
= trace
->facilities
;
705 for(i
=0;unlikely(i
<num
);){
706 LttFacility
*iter_facility
=
707 (LttFacility
*) g_ptr_array_index(facilities
,i
);
708 unsigned base_id
= iter_facility
->base_id
;
710 if(likely(id
>= base_id
&&
711 id
< base_id
+ iter_facility
->event_number
)) {
712 facility
= iter_facility
;
722 LttEventType
*ltt_trace_eventtype_get(LttTrace
*t
, unsigned evId
)
724 LttEventType
*event_type
;
727 f
= ltt_trace_facility_by_id(t
,evId
);
729 if(unlikely(!f
)) event_type
= NULL
;
730 else event_type
= f
->events
[evId
- f
->base_id
];
735 /*****************************************************************************
736 *There is one "per cpu" tracefile for each CPU, numbered from 0 to
737 *the maximum number of CPU in the system. When the number of CPU installed
738 *is less than the maximum, some positions are unused. There are also a
739 *number of "control" tracefiles (facilities, interrupts...).
740 ****************************************************************************/
741 unsigned ltt_trace_control_tracefile_number(LttTrace
*t
)
743 return t
->control_tracefile_number
;
746 unsigned ltt_trace_per_cpu_tracefile_number(LttTrace
*t
)
748 return t
->per_cpu_tracefile_number
;
751 /*****************************************************************************
752 *It is possible to search for the tracefiles by name or by CPU position.
753 *The index within the tracefiles of the same type is returned if found
754 *and a negative value otherwise.
755 ****************************************************************************/
757 int ltt_trace_control_tracefile_find(LttTrace
*t
, const gchar
*name
)
759 LttTracefile
* tracefile
;
761 for(i
=0;i
<t
->control_tracefile_number
;i
++){
762 tracefile
= (LttTracefile
*)g_ptr_array_index(t
->control_tracefiles
, i
);
763 if(strcmp(tracefile
->name
, name
)==0)break;
765 if(i
== t
->control_tracefile_number
) return -1;
769 /* not really useful. We just have to know that cpu tracefiles
770 * comes before control tracefiles.
772 int ltt_trace_per_cpu_tracefile_find(LttTrace
*t
, const gchar
*name
)
774 LttTracefile
* tracefile
;
776 for(i
=0;i
<t
->per_cpu_tracefile_number
;i
++){
777 tracefile
= (LttTracefile
*)g_ptr_array_index(t
->per_cpu_tracefiles
, i
);
778 if(strcmp(tracefile
->name
, name
)==0)break;
780 if(i
== t
->per_cpu_tracefile_number
) return -1;
784 /*****************************************************************************
785 *Get a specific tracefile
786 ****************************************************************************/
788 LttTracefile
*ltt_trace_control_tracefile_get(LttTrace
*t
, unsigned i
)
790 return (LttTracefile
*)g_ptr_array_index(t
->control_tracefiles
, i
);
793 LttTracefile
*ltt_trace_per_cpu_tracefile_get(LttTrace
*t
, unsigned i
)
795 return (LttTracefile
*)g_ptr_array_index(t
->per_cpu_tracefiles
, i
);
798 /*****************************************************************************
799 * Get the start time and end time of the trace
800 ****************************************************************************/
802 void ltt_trace_time_span_get(LttTrace
*t
, LttTime
*start
, LttTime
*end
)
804 LttTime startSmall
, startTmp
, endBig
, endTmp
;
808 for(i
=0;i
<t
->control_tracefile_number
;i
++){
809 tf
= g_ptr_array_index(t
->control_tracefiles
, i
);
811 startTmp
= tf
->a_block_start
->time
;
812 readBlock(tf
,tf
->block_number
);
813 endTmp
= tf
->a_block_end
->time
;
815 startSmall
= startTmp
;
820 if(ltt_time_compare(startSmall
,startTmp
) > 0) startSmall
= startTmp
;
821 if(ltt_time_compare(endBig
,endTmp
) < 0) endBig
= endTmp
;
824 for(i
=0;i
<t
->per_cpu_tracefile_number
;i
++){
825 tf
= g_ptr_array_index(t
->per_cpu_tracefiles
, i
);
827 startTmp
= tf
->a_block_start
->time
;
828 readBlock(tf
,tf
->block_number
);
829 endTmp
= tf
->a_block_end
->time
;
831 startSmall
= startTmp
;
835 if(ltt_time_compare(startSmall
,startTmp
) > 0) startSmall
= startTmp
;
836 if(ltt_time_compare(endBig
,endTmp
) < 0) endBig
= endTmp
;
839 if(start
!= NULL
) *start
= startSmall
;
840 if(end
!= NULL
) *end
= endBig
;
844 /*****************************************************************************
845 *Get the name of a tracefile
846 ****************************************************************************/
848 char *ltt_tracefile_name(LttTracefile
*tf
)
853 /*****************************************************************************
854 * Get the number of blocks in the tracefile
855 ****************************************************************************/
857 unsigned ltt_tracefile_block_number(LttTracefile
*tf
)
859 return tf
->block_number
;
862 /*****************************************************************************
864 * ltt_tracefile_seek_time: seek to the first event of the trace with time
865 * larger or equal to time
868 * time : criteria of the time
869 ****************************************************************************/
870 void ltt_tracefile_find_time_block(LttTracefile
*t
, LttTime time
,
871 int start_block
, int end_block
)
873 int err
, tmp_block
, s
, e
;
877 err
=readBlock(t
,start_block
);
878 if(err
) g_error("Can not read tracefile: %s\n", t
->name
);
879 if(start_block
== end_block
)return;
881 tailTime
= ltt_time_compare(t
->a_block_end
->time
, time
);
882 if(tailTime
>= 0) return;
884 err
=readBlock(t
,end_block
);
885 if(err
) g_error("Can not read tracefile: %s\n", t
->name
);
886 if(start_block
+1 == end_block
)return;
888 headTime
= ltt_time_compare(t
->a_block_start
->time
, time
);
889 if(headTime
<= 0 ) return;
891 tmp_block
= (end_block
+ start_block
)/2;
892 err
=readBlock(t
,tmp_block
);
893 if(err
) g_error("Can not read tracefile: %s\n", t
->name
);
895 headTime
= ltt_time_compare(t
->a_block_start
->time
, time
);
896 tailTime
= ltt_time_compare(t
->a_block_end
->time
, time
);
897 if(headTime
<= 0 && tailTime
>= 0) return;
903 ltt_tracefile_find_time_block(t
, time
, s
, e
);
911 ltt_tracefile_find_time_block(t
, time
, s
, e
);
916 void ltt_tracefile_backward_find_time_block(LttTracefile
*t
, LttTime time
)
918 int t_time
, h_time
, err
;
919 err
=readBlock(t
,t
->which_block
-1);
920 if(err
) g_error("Can not read tracefile: %s\n", t
->name
);
921 h_time
= ltt_time_compare(t
->a_block_start
->time
, time
);
922 t_time
= ltt_time_compare(t
->a_block_end
->time
, time
);
925 if(t
->which_block
== 1) return;
926 err
=readBlock(t
,t
->which_block
-1);
927 if(err
) g_error("Can not read tracefile: %s\n", t
->name
);
928 tmp
= ltt_time_compare(t
->a_block_end
->time
, time
);
929 if(tmp
== 0) return ltt_tracefile_seek_time(t
, time
);
930 err
=readBlock(t
,t
->which_block
+1);
931 if(err
) g_error("Can not read tracefile: %s\n", t
->name
);
932 }else if(h_time
> 0){
933 ltt_tracefile_find_time_block(t
, time
, 1, t
->which_block
);
934 return ltt_tracefile_seek_time(t
, time
) ;
936 if(t_time
>= 0) return ltt_tracefile_seek_time(t
, time
);
937 err
=readBlock(t
,t
->which_block
+1);
938 if(err
) g_error("Can not read tracefile: %s\n", t
->name
);
942 void ltt_tracefile_seek_time(LttTracefile
*t
, LttTime time
)
946 int headTime
= ltt_time_compare(t
->a_block_start
->time
, time
);
947 int tailTime
= ltt_time_compare(t
->a_block_end
->time
, time
);
950 if(headTime
< 0 && tailTime
> 0){
951 if(ltt_time_compare(t
->a_block_end
->time
, t
->current_event_time
) !=0) {
952 lttTime
= getEventTime(t
);
953 err
= ltt_time_compare(lttTime
, time
);
955 if(t
->which_event
==2 || ltt_time_compare(t
->prev_event_time
,time
)<0){
959 return ltt_tracefile_seek_time(t
, time
);
963 if(ltt_tracefile_read(t
,&ev
) == NULL
) {
964 g_print("End of file\n");
967 lttTime
= getEventTime(t
);
968 err
= ltt_time_compare(lttTime
, time
);
972 }else{//we are at the end of the block
974 return ltt_tracefile_seek_time(t
, time
);
976 }else if(headTime
>= 0){
977 if(t
->which_block
== 1){
980 if(ltt_time_compare(t
->prev_block_end_time
, time
) >= 0 ||
981 (t
->prev_block_end_time
.tv_sec
== 0 &&
982 t
->prev_block_end_time
.tv_nsec
== 0 )){
983 ltt_tracefile_backward_find_time_block(t
, time
);
988 }else if(tailTime
< 0){
989 if(t
->which_block
!= t
->block_number
){
990 ltt_tracefile_find_time_block(t
, time
, t
->which_block
+1, t
->block_number
);
991 return ltt_tracefile_seek_time(t
, time
);
993 t
->cur_event_pos
= t
->buffer
+ t
->block_size
;
994 g_print("End of file\n");
997 }else if(tailTime
== 0){
998 t
->cur_event_pos
= t
->last_event_pos
;
999 t
->current_event_time
= time
;
1000 t
->cur_heart_beat_number
= 0;
1001 t
->prev_event_time
.tv_sec
= 0;
1002 t
->prev_event_time
.tv_nsec
= 0;
1007 /*****************************************************************************
1008 * Seek to the first event with position equal or larger to ep
1010 * Modified by Mathieu Desnoyers to used faster offset position instead of
1011 * re-reading the whole buffer.
1012 ****************************************************************************/
1014 void ltt_tracefile_seek_position(LttTracefile
*t
, const LttEventPosition
*ep
)
1016 //if we are at the right place, just return
1017 if(likely(t
->which_block
== ep
->block_num
&& t
->which_event
== ep
->event_num
))
1020 if(likely(t
->which_block
== ep
->block_num
)) updateTracefile(t
);
1021 else readBlock(t
,ep
->block_num
);
1022 //event offset is available
1023 if(likely(ep
->old_position
)){
1026 t
->which_event
= ep
->event_num
;
1027 t
->cur_event_pos
= t
->buffer
+ ep
->event_offset
;
1028 t
->prev_event_time
= ep
->event_time
;
1029 t
->current_event_time
= ep
->event_time
;
1030 t
->cur_heart_beat_number
= ep
->heart_beat_number
;
1031 t
->cur_cycle_count
= ep
->event_cycle_count
;
1033 /* This is a workaround for fast position seek */
1034 t
->last_event_pos
= ep
->last_event_pos
;
1035 t
->prev_block_end_time
= ep
->prev_block_end_time
;
1036 t
->prev_event_time
= ep
->prev_event_time
;
1037 t
->pre_cycle_count
= ep
->pre_cycle_count
;
1038 t
->count
= ep
->count
;
1039 t
->overflow_nsec
= ep
->overflow_nsec
;
1040 t
->last_heartbeat
= ep
->last_heartbeat
;
1041 /* end of workaround */
1043 //update the fields of the current event and go to the next event
1045 if(unlikely(err
== ERANGE
)) g_error("event id is out of range\n");
1050 //only block number and event index are available
1051 //MD: warning : this is slow!
1052 g_warning("using slow O(n) tracefile seek position");
1055 while(likely(t
->which_event
< ep
->event_num
)) ltt_tracefile_read(t
, &event
);
1060 /*****************************************************************************
1062 * ltt_tracefile_read : read the current event, set the pointer to the next
1066 * LttEvent * : an event to be processed
1067 ****************************************************************************/
1069 LttEvent
*ltt_tracefile_read(LttTracefile
*t
, LttEvent
*event
)
1073 if(unlikely(t
->cur_event_pos
== t
->buffer
+ t
->block_size
)){
1074 if(unlikely(t
->which_block
== t
->block_number
)){
1077 err
= readBlock(t
, t
->which_block
+ 1);
1078 if(unlikely(err
))g_error("Can not read tracefile");
1081 event
->event_id
= (int)(*(guint16
*)(t
->cur_event_pos
));
1082 if(unlikely(event
->event_id
== TRACE_TIME_HEARTBEAT
))
1083 t
->cur_heart_beat_number
++;
1085 t
->prev_event_time
= t
->current_event_time
;
1086 // t->current_event_time = getEventTime(t);
1088 event
->time_delta
= *(guint32
*)(t
->cur_event_pos
+ EVENT_ID_SIZE
);
1089 event
->event_time
= t
->current_event_time
;
1090 event
->event_cycle_count
= t
->cur_cycle_count
;
1092 event
->tracefile
= t
;
1093 event
->data
= t
->cur_event_pos
+ EVENT_HEADER_SIZE
;
1094 event
->which_block
= t
->which_block
;
1095 event
->which_event
= t
->which_event
;
1097 /* This is a workaround for fast position seek */
1098 event
->last_event_pos
= t
->last_event_pos
;
1099 event
->prev_block_end_time
= t
->prev_block_end_time
;
1100 event
->prev_event_time
= t
->prev_event_time
;
1101 event
->pre_cycle_count
= t
->pre_cycle_count
;
1102 event
->count
= t
->count
;
1103 event
->overflow_nsec
= t
->overflow_nsec
;
1104 event
->last_heartbeat
= t
->last_heartbeat
;
1106 /* end of workaround */
1110 //update the fields of the current event and go to the next event
1112 if(unlikely(err
== ERANGE
)) g_error("event id is out of range\n");
1117 /****************************************************************************
1119 * readFile : wrap function to read from a file
1121 * fd : file descriptor
1122 * buf : buf to contain the content
1123 * size : number of bytes to be read
1124 * mesg : message to be printed if some thing goes wrong
1127 * EIO : can not read from the file
1128 ****************************************************************************/
1130 int readFile(int fd
, void * buf
, size_t size
, char * mesg
)
1132 ssize_t nbBytes
= read(fd
, buf
, size
);
1134 if((size_t)nbBytes
!= size
) {
1136 perror("Error in readFile : ");
1138 g_warning("%s",mesg
);
1146 /****************************************************************************
1148 * readBlock : read a block from the file
1150 * lttdes : ltt trace file
1151 * whichBlock : the block which will be read
1154 * EINVAL : lseek fail
1155 * EIO : can not read from the file
1156 ****************************************************************************/
1158 int readBlock(LttTracefile
* tf
, int whichBlock
)
1163 /* same block already opened requested */
1164 if((guint
)whichBlock
== tf
->which_block
) return 0;
1166 if(likely(whichBlock
- tf
->which_block
== 1 && tf
->which_block
!= 0)){
1167 tf
->prev_block_end_time
= tf
->a_block_end
->time
;
1168 tf
->prev_event_time
= tf
->a_block_end
->time
;
1170 tf
->prev_block_end_time
.tv_sec
= 0;
1171 tf
->prev_block_end_time
.tv_nsec
= 0;
1172 tf
->prev_event_time
.tv_sec
= 0;
1173 tf
->prev_event_time
.tv_nsec
= 0;
1176 nbBytes
=lseek(tf
->fd
,(off_t
)((whichBlock
-1)*tf
->block_size
), SEEK_SET
);
1177 if(unlikely(nbBytes
== -1)) return EINVAL
;
1179 if(unlikely(readFile(tf
->fd
,tf
->buffer
,tf
->block_size
,"Unable to read a block")))
1182 tf
->a_block_start
=(BlockStart
*) (tf
->buffer
+ EVENT_HEADER_SIZE
);
1183 lostSize
= *(guint32
*)(tf
->buffer
+ tf
->block_size
- sizeof(guint32
));
1184 tf
->a_block_end
=(BlockEnd
*)(tf
->buffer
+ tf
->block_size
1185 - sizeof(guint32
) - lostSize
- sizeof(BlockEnd
));
1186 tf
->last_event_pos
= tf
->buffer
+ tf
->block_size
-
1187 sizeof(guint32
) - lostSize
1188 - sizeof(BlockEnd
) - EVENT_HEADER_SIZE
;
1190 tf
->which_block
= whichBlock
;
1191 tf
->which_event
= 1;
1192 tf
->cur_event_pos
= tf
->buffer
;//the beginning of the block, block start ev
1193 tf
->cur_heart_beat_number
= 0;
1194 tf
->last_heartbeat
= NULL
;
1196 /* read the whole block to precalculate total of cycles in it */
1198 tf
->pre_cycle_count
= 0;
1199 tf
->cur_cycle_count
= 0;
1201 getCyclePerNsec(tf
);
1204 (-((double)(tf
->a_block_start
->cycle_count
&0xFFFFFFFF))
1205 * tf
->nsec_per_cycle
);
1207 tf
->current_event_time
= getEventTime(tf
);
1212 /*****************************************************************************
1214 * updateTracefile : reinitialize the info of the block which is already
1218 ****************************************************************************/
1220 void updateTracefile(LttTracefile
* tf
)
1222 tf
->which_event
= 1;
1223 tf
->cur_event_pos
= tf
->buffer
;
1224 tf
->current_event_time
= getEventTime(tf
);
1225 tf
->cur_heart_beat_number
= 0;
1227 tf
->prev_event_time
.tv_sec
= 0;
1228 tf
->prev_event_time
.tv_nsec
= 0;
1231 tf
->overflow_nsec
= (-((double)tf
->a_block_start
->cycle_count
)
1232 * tf
->nsec_per_cycle
);
1236 /*****************************************************************************
1238 * skipEvent : go to the next event, update the fields of the current event
1243 * ERANGE : event id is out of range
1244 ****************************************************************************/
1246 int skipEvent(LttTracefile
* t
)
1253 evId
= (int)(*(guint16
*)(t
->cur_event_pos
));
1254 evData
= t
->cur_event_pos
+ EVENT_HEADER_SIZE
;
1256 evT
= ltt_trace_eventtype_get(t
->trace
,(unsigned)evId
);
1258 if(likely(evT
)) rootFld
= evT
->root_field
;
1261 if(likely(rootFld
)){
1262 //event has string/sequence or the last event is not the same event
1263 if(likely((evT
->latest_block
!=t
->which_block
|| evT
->latest_event
!=t
->which_event
)
1264 && rootFld
->field_fixed
== 0)){
1265 setFieldsOffset(t
, evT
, evData
, t
->trace
);
1267 t
->cur_event_pos
+= EVENT_HEADER_SIZE
+ rootFld
->field_size
;
1268 }else t
->cur_event_pos
+= EVENT_HEADER_SIZE
;
1270 evT
->latest_block
= t
->which_block
;
1271 evT
->latest_event
= t
->which_event
;
1273 //the next event is in the next block
1274 if(unlikely(evId
== TRACE_BLOCK_END
)){
1275 t
->cur_event_pos
= t
->buffer
+ t
->block_size
;
1278 t
->current_event_time
= getEventTime(t
);
1285 /*****************************************************************************
1287 * getCyclePerNsec : calculate cycles per nsec for current block
1288 * MD: should have tracefile_read the whole block, so we know the
1289 * total of cycles in it before being called.
1292 ****************************************************************************/
1294 void getCyclePerNsec(LttTracefile
* t
)
1296 LttTime lBufTotalTime
; /* Total time for this buffer */
1297 double lBufTotalNSec
; /* Total time for this buffer in nsecs */
1298 LttCycleCount lBufTotalCycle
;/* Total cycles for this buffer */
1300 /* Calculate the total time for this buffer */
1301 lBufTotalTime
= ltt_time_sub(t
->a_block_end
->time
, t
->a_block_start
->time
);
1303 /* Calculate the total cycles for this bufffer */
1304 lBufTotalCycle
= t
->a_block_end
->cycle_count
;
1305 lBufTotalCycle
-= t
->a_block_start
->cycle_count
;
1307 /* Convert the total time to double */
1308 lBufTotalNSec
= ltt_time_to_double(lBufTotalTime
);
1310 t
->nsec_per_cycle
= (double)lBufTotalNSec
/ (double)lBufTotalCycle
;
1312 /* Pre-multiply one overflow (2^32 cycles) by nsec_per_cycle */
1313 t
->one_overflow_nsec
= t
->nsec_per_cycle
* (double)0x100000000ULL
;
1317 /****************************************************************************
1319 * getEventTime : obtain the time of an event
1320 * NOTE : this function _really_ is on critical path.
1324 * LttTime : the time of the event
1325 ****************************************************************************/
1327 static inline LttTime
getEventTime(LttTracefile
* tf
)
1330 LttCycleCount cycle_count
; // cycle count for the current event
1331 //LttCycleCount lEventTotalCycle; // Total cycles from start for event
1332 gint64 lEventNSec
; // Total nsecs from start for event
1333 LttTime lTimeOffset
; // Time offset in struct LttTime
1336 evId
= *(guint16
*)tf
->cur_event_pos
;
1338 cycle_count
= (LttCycleCount
)*(guint32
*)(tf
->cur_event_pos
+ EVENT_ID_SIZE
);
1340 gboolean comp_count
= cycle_count
< tf
->pre_cycle_count
;
1342 tf
->pre_cycle_count
= cycle_count
;
1344 if(unlikely(comp_count
)) {
1346 tf
->overflow_nsec
+= tf
->one_overflow_nsec
;
1347 tf
->count
++; //increment overflow count
1350 if(unlikely(evId
== TRACE_BLOCK_START
)) {
1352 } else if(unlikely(evId
== TRACE_BLOCK_END
)) {
1353 lEventNSec
= ((double)
1354 (tf
->a_block_end
->cycle_count
- tf
->a_block_start
->cycle_count
)
1355 * tf
->nsec_per_cycle
);
1358 /* If you want to make heart beat a special case and use their own 64 bits
1359 * TSC, activate this.
1361 else if(unlikely(evId
== TRACE_TIME_HEARTBEAT
)) {
1363 tf
->last_heartbeat
= (TimeHeartbeat
*)(tf
->cur_event_pos
+EVENT_HEADER_SIZE
);
1364 lEventNSec
= ((double)(tf
->last_heartbeat
->cycle_count
1365 - tf
->a_block_start
->cycle_count
)
1366 * tf
->nsec_per_cycle
);
1370 lEventNSec
= (gint64
)((double)cycle_count
* tf
->nsec_per_cycle
)
1374 lTimeOffset
= ltt_time_from_uint64(lEventNSec
);
1376 time
= ltt_time_add(tf
->a_block_start
->time
, lTimeOffset
);
1381 /*****************************************************************************
1383 * setFieldsOffset : set offset of the fields
1385 * tracefile : opened trace file
1386 * evT : the event type
1387 * evD : event data, it may be NULL
1388 ****************************************************************************/
1390 void setFieldsOffset(LttTracefile
*tf
,LttEventType
*evT
,void *evD
,LttTrace
* t
)
1392 LttField
* rootFld
= evT
->root_field
;
1393 // rootFld->base_address = evD;
1396 rootFld
->field_size
= getFieldtypeSize(tf
, evT
, 0,0,rootFld
, evD
,t
);
1399 /*****************************************************************************
1401 * getFieldtypeSize: get the size of the field type (primitive type)
1403 * tracefile : opened trace file
1405 * offsetRoot : offset from the root
1406 * offsetParent : offset from the parrent
1408 * evD : event data, it may be NULL
1410 * int : size of the field
1411 ****************************************************************************/
1413 static inline gint
getFieldtypeSize(LttTracefile
* t
,
1414 LttEventType
* evT
, gint offsetRoot
,
1415 gint offsetParent
, LttField
* fld
, void *evD
, LttTrace
*trace
)
1417 gint size
, size1
, element_number
, i
, offset1
, offset2
;
1418 LttType
* type
= fld
->field_type
;
1420 if(unlikely(t
&& evT
->latest_block
==t
->which_block
&&
1421 evT
->latest_event
==t
->which_event
)){
1422 size
= fld
->field_size
;
1423 goto end_getFieldtypeSize
;
1425 /* This likely has been tested with gcov : half of them.. */
1426 if(unlikely(fld
->field_fixed
== 1)){
1428 if(unlikely(fld
== evT
->root_field
)) {
1429 size
= fld
->field_size
;
1430 goto end_getFieldtypeSize
;
1434 /* From gcov profiling : half string, half struct, can we gain something
1435 * from that ? (Mathieu) */
1436 switch(type
->type_class
) {
1438 element_number
= (int) type
->element_number
;
1439 if(fld
->field_fixed
== -1){
1440 size
= getFieldtypeSize(t
, evT
, offsetRoot
,
1441 0,fld
->child
[0], NULL
, trace
);
1442 if(size
== 0){ //has string or sequence
1443 fld
->field_fixed
= 0;
1445 fld
->field_fixed
= 1;
1446 size
*= element_number
;
1448 }else if(fld
->field_fixed
== 0){// has string or sequence
1450 for(i
=0;i
<element_number
;i
++){
1451 size
+= getFieldtypeSize(t
, evT
, offsetRoot
+size
,size
,
1452 fld
->child
[0], evD
+size
, trace
);
1454 }else size
= fld
->field_size
;
1456 fld
->fixed_root
= (offsetRoot
==-1) ? 0 : 1;
1457 fld
->fixed_parent
= (offsetParent
==-1) ? 0 : 1;
1463 size1
= (int) ltt_type_size(trace
, type
);
1464 if(fld
->field_fixed
== -1){
1465 fld
->sequ_number_size
= size1
;
1466 fld
->field_fixed
= 0;
1467 size
= getFieldtypeSize(t
, evT
, offsetRoot
,
1468 0,fld
->child
[0], NULL
, trace
);
1469 fld
->element_size
= size
;
1471 element_number
= getIntNumber(size1
,evD
);
1472 type
->element_number
= element_number
;
1473 if(fld
->element_size
> 0){
1474 size
= element_number
* fld
->element_size
;
1475 }else{//sequence has string or sequence
1477 for(i
=0;i
<element_number
;i
++){
1478 size
+= getFieldtypeSize(t
, evT
, offsetRoot
+size
+size1
,size
+size1
,
1479 fld
->child
[0], evD
+size
+size1
, trace
);
1485 fld
->fixed_root
= (offsetRoot
==-1) ? 0 : 1;
1486 fld
->fixed_parent
= (offsetParent
==-1) ? 0 : 1;
1493 if(fld
->field_fixed
== -1){
1494 fld
->field_fixed
= 0;
1496 /* Hope my implementation is faster than strlen (Mathieu) */
1497 char *ptr
=(char*)evD
;
1499 /* from gcov : many many strings are empty, make it the common case.*/
1500 while(unlikely(*ptr
!= '\0')) { size
++; ptr
++; }
1501 //size = ptr - (char*)evD + 1; //include end : '\0'
1503 fld
->fixed_root
= (offsetRoot
==-1) ? 0 : 1;
1504 fld
->fixed_parent
= (offsetParent
==-1) ? 0 : 1;
1509 element_number
= (int) type
->element_number
;
1511 /* tested with gcov */
1512 if(unlikely(fld
->field_fixed
== -1)){
1513 offset1
= offsetRoot
;
1515 for(i
=0;i
<element_number
;i
++){
1516 size1
=getFieldtypeSize(t
, evT
,offset1
,offset2
,
1517 fld
->child
[i
], NULL
, trace
);
1518 if(likely(size1
> 0 && size
>= 0)){
1520 if(likely(offset1
>= 0)) offset1
+= size1
;
1528 if(unlikely(size
== -1)){
1529 fld
->field_fixed
= 0;
1531 }else fld
->field_fixed
= 1;
1532 }else if(likely(fld
->field_fixed
== 0)){
1533 offset1
= offsetRoot
;
1535 for(i
=0;unlikely(i
<element_number
);i
++){
1536 size
=getFieldtypeSize(t
,evT
,offset1
,offset2
,
1537 fld
->child
[i
],evD
+offset2
, trace
);
1542 }else size
= fld
->field_size
;
1543 fld
->fixed_root
= (offsetRoot
==-1) ? 0 : 1;
1544 fld
->fixed_parent
= (offsetParent
==-1) ? 0 : 1;
1548 if(unlikely(fld
->field_fixed
== -1)){
1549 size
= (int) ltt_type_size(trace
, type
);
1550 fld
->field_fixed
= 1;
1551 }else size
= fld
->field_size
;
1553 fld
->fixed_root
= (offsetRoot
==-1) ? 0 : 1;
1554 fld
->fixed_parent
= (offsetParent
==-1) ? 0 : 1;
1560 fld
->offset_root
= offsetRoot
;
1561 fld
->offset_parent
= offsetParent
;
1562 fld
->field_size
= size
;
1564 end_getFieldtypeSize
:
1570 /*****************************************************************************
1572 * getIntNumber : get an integer number
1574 * size : the size of the integer
1575 * evD : the event data
1577 * gint64 : a 64 bits integer
1578 ****************************************************************************/
1580 gint64
getIntNumber(int size
, void *evD
)
1585 case 1: i
= *(gint8
*)evD
; break;
1586 case 2: i
= *(gint16
*)evD
; break;
1587 case 4: i
= *(gint32
*)evD
; break;
1588 case 8: i
= *(gint64
*)evD
; break;
1589 default: i
= *(gint64
*)evD
;
1590 g_critical("getIntNumber : integer size %d unknown", size
);
1597 /*****************************************************************************
1599 * getDataEndianType : get the data type size and endian type of the local
1602 * size : size of data type
1603 * endian : endian type, little or big
1604 ****************************************************************************/
1606 void getDataEndianType(LttArchSize
* size
, LttArchEndian
* endian
)
1610 int sizeInt
=sizeof(int), sizeLong
=sizeof(long), sizePointer
=sizeof(void *);
1612 if(c
== 1) *endian
= LTT_LITTLE_ENDIAN
;
1613 else *endian
= LTT_BIG_ENDIAN
;
1615 if(sizeInt
== 2 && sizeLong
== 4 && sizePointer
== 4)
1617 else if(sizeInt
== 4 && sizeLong
== 4 && sizePointer
== 4)
1619 else if(sizeInt
== 4 && sizeLong
== 8 && sizePointer
== 8)
1621 else if(sizeInt
== 8 && sizeLong
== 8 && sizePointer
== 8)
1623 else *size
= LTT_UNKNOWN
;
1626 /* get the node name of the system */
1628 char * ltt_trace_system_description_node_name (LttSystemDescription
* s
)
1630 return s
->node_name
;
1634 /* get the domain name of the system */
1636 char * ltt_trace_system_description_domain_name (LttSystemDescription
* s
)
1638 return s
->domain_name
;
1642 /* get the description of the system */
1644 char * ltt_trace_system_description_description (LttSystemDescription
* s
)
1646 return s
->description
;
1650 /* get the start time of the trace */
1652 LttTime
ltt_trace_system_description_trace_start_time(LttSystemDescription
*s
)
1654 return s
->trace_start
;
1658 LttTracefile
*ltt_tracefile_new()
1660 return g_new(LttTracefile
, 1);
1663 void ltt_tracefile_destroy(LttTracefile
*tf
)
1668 void ltt_tracefile_copy(LttTracefile
*dest
, const LttTracefile
*src
)