added const
[lttv.git] / ltt / branches / poly / ltt / tracefile.c
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 Xiangxiu Yang
3 *
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;
7 *
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.
12 *
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,
16 * MA 02111-1307, USA.
17 */
18
19 #include <stdio.h>
20 #include <fcntl.h>
21 #include <sys/stat.h>
22 #include <sys/types.h>
23 #include <dirent.h>
24 #include <linux/errno.h>
25
26 // For realpath
27 #include <limits.h>
28 #include <stdlib.h>
29
30
31 #include "parser.h"
32 #include <ltt/ltt.h>
33 #include "ltt-private.h"
34 #include <ltt/trace.h>
35 #include <ltt/facility.h>
36
37 #define DIR_NAME_SIZE 256
38
39 /* set the offset of the fields belonging to the event,
40 need the information of the archecture */
41 void setFieldsOffset(LttTracefile *tf,LttEventType *evT,void *evD,LttTrace *t);
42
43 /* get the size of the field type according to the archtecture's
44 size and endian type(info of the archecture) */
45 int getFieldtypeSize(LttTracefile * tf, LttEventType * evT, int offsetRoot,
46 int offsetParent, LttField *fld, void *evD, LttTrace* t);
47
48 /* read a fixed size or a block information from the file (fd) */
49 int readFile(int fd, void * buf, size_t size, char * mesg);
50 int readBlock(LttTracefile * tf, int whichBlock);
51
52 /* calculate cycles per nsec for current block */
53 void getCyclePerNsec(LttTracefile * t);
54
55 /* reinitialize the info of the block which is already in the buffer */
56 void updateTracefile(LttTracefile * tf);
57
58 /* go to the next event */
59 int skipEvent(LttTracefile * t);
60
61
62 /* Functions to parse system.xml file (using glib xml parser) */
63 static void parser_start_element (GMarkupParseContext *context,
64 const gchar *element_name,
65 const gchar **attribute_names,
66 const gchar **attribute_values,
67 gpointer user_data,
68 GError **error)
69 {
70 int i=0;
71 LttSystemDescription* des = (LttSystemDescription* )user_data;
72 if(strcmp("system", element_name)){
73 g_warning("This is not system.xml file\n");
74 exit(1);
75 }
76
77 while(attribute_names[i]){
78 if(strcmp("node_name", attribute_names[i])==0){
79 des->node_name = g_strdup(attribute_values[i]);
80 }else if(strcmp("domainname", attribute_names[i])==0){
81 des->domain_name = g_strdup(attribute_values[i]);
82 }else if(strcmp("cpu", attribute_names[i])==0){
83 des->nb_cpu = atoi(attribute_values[i]);
84 }else if(strcmp("arch_size", attribute_names[i])==0){
85 if(strcmp(attribute_values[i],"LP32") == 0) des->size = LTT_LP32;
86 else if(strcmp(attribute_values[i],"ILP32") == 0) des->size = LTT_ILP32;
87 else if(strcmp(attribute_values[i],"LP64") == 0) des->size = LTT_LP64;
88 else if(strcmp(attribute_values[i],"ILP64") == 0) des->size = LTT_ILP64;
89 else if(strcmp(attribute_values[i],"UNKNOWN") == 0) des->size = LTT_UNKNOWN;
90 }else if(strcmp("endian", attribute_names[i])==0){
91 if(strcmp(attribute_values[i],"LITTLE_ENDIAN") == 0)
92 des->endian = LTT_LITTLE_ENDIAN;
93 else if(strcmp(attribute_values[i],"BIG_ENDIAN") == 0)
94 des->endian = LTT_BIG_ENDIAN;
95 }else if(strcmp("kernel_name", attribute_names[i])==0){
96 des->kernel_name = g_strdup(attribute_values[i]);
97 }else if(strcmp("kernel_release", attribute_names[i])==0){
98 des->kernel_release = g_strdup(attribute_values[i]);
99 }else if(strcmp("kernel_version", attribute_names[i])==0){
100 des->kernel_version = g_strdup(attribute_values[i]);
101 }else if(strcmp("machine", attribute_names[i])==0){
102 des->machine = g_strdup(attribute_values[i]);
103 }else if(strcmp("processor", attribute_names[i])==0){
104 des->processor = g_strdup(attribute_values[i]);
105 }else if(strcmp("hardware_platform", attribute_names[i])==0){
106 des->hardware_platform = g_strdup(attribute_values[i]);
107 }else if(strcmp("operating_system", attribute_names[i])==0){
108 des->operating_system = g_strdup(attribute_values[i]);
109 }else if(strcmp("ltt_major_version", attribute_names[i])==0){
110 des->ltt_major_version = atoi(attribute_values[i]);
111 }else if(strcmp("ltt_minor_version", attribute_names[i])==0){
112 des->ltt_minor_version = atoi(attribute_values[i]);
113 }else if(strcmp("ltt_block_size", attribute_names[i])==0){
114 des->ltt_block_size = atoi(attribute_values[i]);
115 }else{
116 g_warning("Not a valid attribute\n");
117 exit(1);
118 }
119 i++;
120 }
121 }
122
123 static void parser_end_element (GMarkupParseContext *context,
124 const gchar *element_name,
125 gpointer user_data,
126 GError **error)
127 {
128 }
129
130 static void parser_characters (GMarkupParseContext *context,
131 const gchar *text,
132 gsize text_len,
133 gpointer user_data,
134 GError **error)
135 {
136 LttSystemDescription* des = (LttSystemDescription* )user_data;
137 des->description = g_strdup(text);
138 }
139
140
141 /*****************************************************************************
142 *Function name
143 * ltt_tracefile_open : open a trace file, construct a LttTracefile
144 *Input params
145 * t : the trace containing the tracefile
146 * fileName : path name of the trace file
147 *Return value
148 * : a pointer to a tracefile
149 ****************************************************************************/
150
151 LttTracefile* ltt_tracefile_open(LttTrace * t, char * fileName)
152 {
153 LttTracefile * tf;
154 struct stat lTDFStat; /* Trace data file status */
155 BlockStart a_block_start;
156
157 tf = g_new(LttTracefile, 1);
158
159 //open the file
160 tf->name = g_strdup(fileName);
161 tf->trace = t;
162 tf->fd = open(fileName, O_RDONLY, 0);
163 if(tf->fd < 0){
164 g_error("Unable to open input data file %s\n", fileName);
165 }
166
167 // Get the file's status
168 if(fstat(tf->fd, &lTDFStat) < 0){
169 g_error("Unable to get the status of the input data file %s\n", fileName);
170 }
171
172 // Is the file large enough to contain a trace
173 if(lTDFStat.st_size < sizeof(BlockStart) + EVENT_HEADER_SIZE){
174 g_print("The input data file %s does not contain a trace\n", fileName);
175 g_free(tf->name);
176 close(tf->fd);
177 g_free(tf);
178 return NULL;
179 }
180
181 //store the size of the file
182 tf->file_size = lTDFStat.st_size;
183 tf->block_size = t->system_description->ltt_block_size;
184 tf->block_number = tf->file_size / tf->block_size;
185 tf->which_block = 0;
186
187 //allocate memory to contain the info of a block
188 tf->buffer = (void *) g_new(char, t->system_description->ltt_block_size);
189
190 //read the first block
191 if(readBlock(tf,1)) exit(1);
192
193 return tf;
194 }
195
196
197 /*****************************************************************************
198 *Open control and per cpu tracefiles
199 ****************************************************************************/
200
201 void ltt_tracefile_open_cpu(LttTrace *t, char * tracefile_name)
202 {
203 LttTracefile * tf;
204 tf = ltt_tracefile_open(t,tracefile_name);
205 if(!tf) return;
206 t->per_cpu_tracefile_number++;
207 g_ptr_array_add(t->per_cpu_tracefiles, tf);
208 }
209
210 void ltt_tracefile_open_control(LttTrace *t, char * control_name)
211 {
212 LttTracefile * tf;
213 LttEvent * ev;
214 LttFacility * f;
215 guint16 evId;
216 void * pos;
217 FacilityLoad fLoad;
218 int i;
219
220 tf = ltt_tracefile_open(t,control_name);
221 if(!tf) return;
222 t->control_tracefile_number++;
223 g_ptr_array_add(t->control_tracefiles,tf);
224
225 //parse facilities tracefile to get base_id
226 if(strcmp(&control_name[strlen(control_name)-10],"facilities") ==0){
227 while(1){
228 ev = ltt_tracefile_read(tf);
229 if(!ev)return; // end of file
230
231 if(ev->event_id == TRACE_FACILITY_LOAD){
232 pos = ev->data;
233 fLoad.name = (char*)pos;
234 fLoad.checksum = *(LttChecksum*)(pos + strlen(fLoad.name));
235 fLoad.base_code = *(guint32 *)(pos + strlen(fLoad.name) + sizeof(LttChecksum));
236
237 for(i=0;i<t->facility_number;i++){
238 f = (LttFacility*)g_ptr_array_index(t->facilities,i);
239 if(strcmp(f->name,fLoad.name)==0 && fLoad.checksum==f->checksum){
240 f->base_id = fLoad.base_code;
241 break;
242 }
243 }
244 if(i==t->facility_number)
245 g_error("Facility: %s, checksum: %d is not founded\n",
246 fLoad.name,fLoad.checksum);
247 }else if(ev->event_id == TRACE_BLOCK_START){
248 continue;
249 }else if(ev->event_id == TRACE_BLOCK_END){
250 break;
251 }else g_error("Not valid facilities trace file\n");
252 }
253 }
254 }
255
256 /*****************************************************************************
257 *Function name
258 * ltt_tracefile_close: close a trace file,
259 *Input params
260 * t : tracefile which will be closed
261 ****************************************************************************/
262
263 void ltt_tracefile_close(LttTracefile *t)
264 {
265 g_free(t->name);
266 g_free(t->buffer);
267 close(t->fd);
268 g_free(t);
269 }
270
271
272 /*****************************************************************************
273 *Get system information
274 ****************************************************************************/
275 void getSystemInfo(LttSystemDescription* des, char * pathname)
276 {
277 FILE * fp;
278 char buf[DIR_NAME_SIZE];
279 char description[4*DIR_NAME_SIZE];
280
281 GMarkupParseContext * context;
282 GError * error;
283 GMarkupParser markup_parser =
284 {
285 parser_start_element,
286 parser_end_element,
287 parser_characters,
288 NULL, /* passthrough */
289 NULL /* error */
290 };
291
292 fp = fopen(pathname,"r");
293 if(!fp){
294 g_error("Can not open file : %s\n", pathname);
295 }
296
297 context = g_markup_parse_context_new(&markup_parser, 0, des,NULL);
298
299 while(fgets(buf,DIR_NAME_SIZE, fp) != NULL){
300 if(!g_markup_parse_context_parse(context, buf, DIR_NAME_SIZE, &error)){
301 g_warning("Can not parse xml file: \n%s\n", error->message);
302 exit(1);
303 }
304 }
305 fclose(fp);
306 }
307
308 /*****************************************************************************
309 *The following functions get facility/tracefile information
310 ****************************************************************************/
311
312 void getFacilityInfo(LttTrace *t, char* eventdefs)
313 {
314 DIR * dir;
315 struct dirent *entry;
316 char * ptr;
317 int i,j;
318 LttFacility * f;
319 LttEventType * et;
320 char name[DIR_NAME_SIZE];
321
322 dir = opendir(eventdefs);
323 if(!dir) g_error("Can not open directory: %s\n", eventdefs);
324
325 while((entry = readdir(dir)) != NULL){
326 ptr = &entry->d_name[strlen(entry->d_name)-4];
327 if(strcmp(ptr,".xml") != 0) continue;
328 strcpy(name,eventdefs);
329 strcat(name,entry->d_name);
330 ltt_facility_open(t,name);
331 }
332 closedir(dir);
333
334 for(j=0;j<t->facility_number;j++){
335 f = (LttFacility*)g_ptr_array_index(t->facilities, j);
336 for(i=0; i<f->event_number; i++){
337 et = f->events[i];
338 setFieldsOffset(NULL, et, NULL, t);
339 }
340 }
341 }
342
343 void getControlFileInfo(LttTrace *t, char* control)
344 {
345 DIR * dir;
346 struct dirent *entry;
347 char name[DIR_NAME_SIZE];
348
349 dir = opendir(control);
350 if(!dir) g_error("Can not open directory: %s\n", control);
351
352 while((entry = readdir(dir)) != NULL){
353 if(strcmp(entry->d_name,"facilities") != 0 &&
354 strcmp(entry->d_name,"interrupts") != 0 &&
355 strcmp(entry->d_name,"processes") != 0) continue;
356
357 strcpy(name,control);
358 strcat(name,entry->d_name);
359 ltt_tracefile_open_control(t,name);
360 }
361 closedir(dir);
362 }
363
364 void getCpuFileInfo(LttTrace *t, char* cpu)
365 {
366 DIR * dir;
367 struct dirent *entry;
368 char name[DIR_NAME_SIZE];
369
370 dir = opendir(cpu);
371 if(!dir) g_error("Can not open directory: %s\n", cpu);
372
373 while((entry = readdir(dir)) != NULL){
374 if(strcmp(entry->d_name,".") != 0 &&
375 strcmp(entry->d_name,"..") != 0 &&
376 strcmp(entry->d_name,".svn") != 0){
377 strcpy(name,cpu);
378 strcat(name,entry->d_name);
379 ltt_tracefile_open_cpu(t,name);
380 }else continue;
381 }
382 closedir(dir);
383 }
384
385 /*****************************************************************************
386 *A trace is specified as a pathname to the directory containing all the
387 *associated data (control tracefiles, per cpu tracefiles, event
388 *descriptions...).
389 *
390 *When a trace is closed, all the associated facilities, types and fields
391 *are released as well.
392 *
393 * MD : Fixed this function so it uses realpath, dealing well with
394 * forgotten cases (.. were not used correctly before).
395 *
396 ****************************************************************************/
397
398 void get_absolute_pathname(const char *pathname, char * abs_pathname)
399 {
400 char * ptr, *ptr1;
401 size_t size = DIR_NAME_SIZE;
402 abs_pathname[0] = '\0';
403
404 if ( realpath (pathname, abs_pathname) != NULL)
405 return;
406 else
407 {
408 // FIXME : Path is wrong, is it ok to return the pathname unmodified ?
409 strcpy(abs_pathname, pathname);
410 return;
411 }
412
413 return;
414
415 }
416
417 LttTrace *ltt_trace_open(const char *pathname)
418 {
419 LttTrace * t;
420 LttSystemDescription * sys_description;
421 char eventdefs[DIR_NAME_SIZE];
422 char info[DIR_NAME_SIZE];
423 char control[DIR_NAME_SIZE];
424 char cpu[DIR_NAME_SIZE];
425 char tmp[DIR_NAME_SIZE];
426 char abs_path[DIR_NAME_SIZE];
427 gboolean has_slash = FALSE;
428
429 get_absolute_pathname(pathname, abs_path);
430 //establish the pathname to different directories
431 if(abs_path[strlen(abs_path)-1] == '/')has_slash = TRUE;
432 strcpy(eventdefs,abs_path);
433 if(!has_slash)strcat(eventdefs,"/");
434 strcat(eventdefs,"eventdefs/");
435
436 strcpy(info,abs_path);
437 if(!has_slash)strcat(info,"/");
438 strcat(info,"info/");
439
440 strcpy(control,abs_path);
441 if(!has_slash)strcat(control,"/");
442 strcat(control,"control/");
443
444 strcpy(cpu,abs_path);
445 if(!has_slash)strcat(cpu,"/");
446 strcat(cpu,"cpu/");
447
448 //new trace
449 t = g_new(LttTrace, 1);
450 sys_description = g_new(LttSystemDescription, 1);
451 t->pathname = g_strdup(abs_path);
452 t->facility_number = 0;
453 t->control_tracefile_number = 0;
454 t->per_cpu_tracefile_number = 0;
455 t->system_description = sys_description;
456 t->control_tracefiles = g_ptr_array_new();
457 t->per_cpu_tracefiles = g_ptr_array_new();
458 t->facilities = g_ptr_array_new();
459 getDataEndianType(&(t->my_arch_size), &(t->my_arch_endian));
460
461 //get system description
462 strcpy(tmp,info);
463 strcat(tmp,"system.xml");
464 getSystemInfo(sys_description, tmp);
465
466 //get facilities info
467 getFacilityInfo(t,eventdefs);
468
469 //get control tracefile info
470 getControlFileInfo(t,control);
471
472 //get cpu tracefile info
473 getCpuFileInfo(t,cpu);
474
475 return t;
476 }
477
478 char * ltt_trace_name(LttTrace *t)
479 {
480 return t->pathname;
481 }
482
483
484 /******************************************************************************
485 * When we copy a trace, we want all the opening actions to happen again :
486 * the trace will be reopened and totally independant from the original.
487 * That's why we call ltt_trace_open.
488 *****************************************************************************/
489 LttTrace *ltt_trace_copy(LttTrace *self)
490 {
491 return ltt_trace_open(self->pathname);
492 }
493
494 void ltt_trace_close(LttTrace *t)
495 {
496 int i;
497 LttTracefile * tf;
498 LttFacility * f;
499
500 g_free(t->pathname);
501
502 //free system_description
503 g_free(t->system_description->description);
504 g_free(t->system_description->node_name);
505 g_free(t->system_description->domain_name);
506 g_free(t->system_description->kernel_name);
507 g_free(t->system_description->kernel_release);
508 g_free(t->system_description->kernel_version);
509 g_free(t->system_description->machine);
510 g_free(t->system_description->processor);
511 g_free(t->system_description->hardware_platform);
512 g_free(t->system_description->operating_system);
513 g_free(t->system_description);
514
515 //free control_tracefiles
516 for(i=0;i<t->control_tracefile_number;i++){
517 tf = (LttTracefile*)g_ptr_array_index(t->control_tracefiles,i);
518 ltt_tracefile_close(tf);
519 }
520 g_ptr_array_free(t->control_tracefiles, TRUE);
521
522 //free per_cpu_tracefiles
523 for(i=0;i<t->per_cpu_tracefile_number;i++){
524 tf = (LttTracefile*)g_ptr_array_index(t->per_cpu_tracefiles,i);
525 ltt_tracefile_close(tf);
526 }
527 g_ptr_array_free(t->per_cpu_tracefiles, TRUE);
528
529 //free facilities
530 for(i=0;i<t->facility_number;i++){
531 f = (LttFacility*)g_ptr_array_index(t->facilities,i);
532 ltt_facility_close(f);
533 }
534 g_ptr_array_free(t->facilities, TRUE);
535
536 g_free(t);
537
538 g_blow_chunks();
539 }
540
541
542 /*****************************************************************************
543 *Get the system description of the trace
544 ****************************************************************************/
545
546 LttSystemDescription *ltt_trace_system_description(LttTrace *t)
547 {
548 return t->system_description;
549 }
550
551 /*****************************************************************************
552 * The following functions discover the facilities of the trace
553 ****************************************************************************/
554
555 unsigned ltt_trace_facility_number(LttTrace *t)
556 {
557 return (unsigned)(t->facility_number);
558 }
559
560 LttFacility *ltt_trace_facility_get(LttTrace *t, unsigned i)
561 {
562 return (LttFacility*)g_ptr_array_index(t->facilities, i);
563 }
564
565 /*****************************************************************************
566 *Function name
567 * ltt_trace_facility_find : find facilities in the trace
568 *Input params
569 * t : the trace
570 * name : facility name
571 *Output params
572 * position : position of the facility in the trace
573 *Return value
574 * : the number of facilities
575 ****************************************************************************/
576
577 unsigned ltt_trace_facility_find(LttTrace *t, char *name, unsigned *position)
578 {
579 int i, count=0;
580 LttFacility * f;
581 for(i=0;i<t->facility_number;i++){
582 f = (LttFacility*)g_ptr_array_index(t->facilities, i);
583 if(strcmp(f->name,name)==0){
584 count++;
585 if(count==1) *position = i;
586 }else{
587 if(count) break;
588 }
589 }
590 return count;
591 }
592
593 /*****************************************************************************
594 * Functions to discover all the event types in the trace
595 ****************************************************************************/
596
597 unsigned ltt_trace_eventtype_number(LttTrace *t)
598 {
599 int i;
600 unsigned count = 0;
601 LttFacility * f;
602 for(i=0;i<t->facility_number;i++){
603 f = (LttFacility*)g_ptr_array_index(t->facilities, i);
604 count += f->event_number;
605 }
606 return count;
607 }
608
609 LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id)
610 {
611 LttFacility * facility;
612 int i;
613 for(i=0;i<trace->facility_number;i++){
614 facility = (LttFacility*) g_ptr_array_index(trace->facilities,i);
615 if(id >= facility->base_id &&
616 id < facility->base_id + facility->event_number)
617 break;
618 }
619 if(i==trace->facility_number) return NULL;
620 else return facility;
621 }
622
623 LttEventType *ltt_trace_eventtype_get(LttTrace *t, unsigned evId)
624 {
625 LttFacility * f;
626 f = ltt_trace_facility_by_id(t,evId);
627 if(!f) return NULL;
628 return f->events[evId - f->base_id];
629 }
630
631 /*****************************************************************************
632 *There is one "per cpu" tracefile for each CPU, numbered from 0 to
633 *the maximum number of CPU in the system. When the number of CPU installed
634 *is less than the maximum, some positions are unused. There are also a
635 *number of "control" tracefiles (facilities, interrupts...).
636 ****************************************************************************/
637 unsigned ltt_trace_control_tracefile_number(LttTrace *t)
638 {
639 return t->control_tracefile_number;
640 }
641
642 unsigned ltt_trace_per_cpu_tracefile_number(LttTrace *t)
643 {
644 return t->per_cpu_tracefile_number;
645 }
646
647 /*****************************************************************************
648 *It is possible to search for the tracefiles by name or by CPU position.
649 *The index within the tracefiles of the same type is returned if found
650 *and a negative value otherwise.
651 ****************************************************************************/
652
653 int ltt_trace_control_tracefile_find(LttTrace *t, char *name)
654 {
655 LttTracefile * tracefile;
656 int i;
657 for(i=0;i<t->control_tracefile_number;i++){
658 tracefile = (LttTracefile*)g_ptr_array_index(t->control_tracefiles, i);
659 if(strcmp(tracefile->name, name)==0)break;
660 }
661 if(i == t->control_tracefile_number) return -1;
662 return i;
663 }
664
665 int ltt_trace_per_cpu_tracefile_find(LttTrace *t, unsigned i)
666 {
667 LttTracefile * tracefile;
668 int j, name;
669 for(j=0;j<t->per_cpu_tracefile_number;j++){
670 tracefile = (LttTracefile*)g_ptr_array_index(t->per_cpu_tracefiles, j);
671 name = atoi(tracefile->name);
672 if(name == (int)i)break;
673 }
674 if(j == t->per_cpu_tracefile_number) return -1;
675 return j;
676 }
677
678 /*****************************************************************************
679 *Get a specific tracefile
680 ****************************************************************************/
681
682 LttTracefile *ltt_trace_control_tracefile_get(LttTrace *t, unsigned i)
683 {
684 return (LttTracefile*)g_ptr_array_index(t->control_tracefiles, i);
685 }
686
687 LttTracefile *ltt_trace_per_cpu_tracefile_get(LttTrace *t, unsigned i)
688 {
689 return (LttTracefile*)g_ptr_array_index(t->per_cpu_tracefiles, i);
690 }
691
692 /*****************************************************************************
693 * Get the start time and end time of the trace
694 ****************************************************************************/
695
696 void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end)
697 {
698 LttTime startSmall, startTmp, endBig, endTmp;
699 int i, j=0;
700 LttTracefile * tf;
701
702 for(i=0;i<t->control_tracefile_number;i++){
703 tf = g_ptr_array_index(t->control_tracefiles, i);
704 readBlock(tf,1);
705 startTmp = tf->a_block_start->time;
706 readBlock(tf,tf->block_number);
707 endTmp = tf->a_block_end->time;
708 if(i==0){
709 startSmall = startTmp;
710 endBig = endTmp;
711 j = 1;
712 continue;
713 }
714 if(ltt_time_compare(startSmall,startTmp) > 0) startSmall = startTmp;
715 if(ltt_time_compare(endBig,endTmp) < 0) endBig = endTmp;
716 }
717
718 for(i=0;i<t->per_cpu_tracefile_number;i++){
719 tf = g_ptr_array_index(t->per_cpu_tracefiles, i);
720 readBlock(tf,1);
721 startTmp = tf->a_block_start->time;
722 readBlock(tf,tf->block_number);
723 endTmp = tf->a_block_end->time;
724 if(j == 0 && i==0){
725 startSmall = startTmp;
726 endBig = endTmp;
727 continue;
728 }
729 if(ltt_time_compare(startSmall,startTmp) > 0) startSmall = startTmp;
730 if(ltt_time_compare(endBig,endTmp) < 0) endBig = endTmp;
731 }
732
733 *start = startSmall;
734 *end = endBig;
735 }
736
737
738 /*****************************************************************************
739 *Get the name of a tracefile
740 ****************************************************************************/
741
742 char *ltt_tracefile_name(LttTracefile *tf)
743 {
744 return tf->name;
745 }
746
747 /*****************************************************************************
748 * Get the number of blocks in the tracefile
749 ****************************************************************************/
750
751 unsigned ltt_tracefile_block_number(LttTracefile *tf)
752 {
753 return tf->block_number;
754 }
755
756 /*****************************************************************************
757 *Function name
758 * ltt_tracefile_seek_time: seek to the first event of the trace with time
759 * larger or equal to time
760 *Input params
761 * t : tracefile
762 * time : criteria of the time
763 ****************************************************************************/
764 void ltt_tracefile_find_time_block(LttTracefile *t, LttTime time,
765 int start_block, int end_block)
766 {
767 int err, tmp_block, s, e;
768 int headTime;
769 int tailTime;
770
771 err=readBlock(t,start_block);
772 if(err) g_error("Can not read tracefile: %s\n", t->name);
773 if(start_block == end_block)return;
774
775 tailTime = ltt_time_compare(t->a_block_end->time, time);
776 if(tailTime >= 0) return;
777
778 err=readBlock(t,end_block);
779 if(err) g_error("Can not read tracefile: %s\n", t->name);
780 if(start_block+1 == end_block)return;
781
782 headTime = ltt_time_compare(t->a_block_start->time, time);
783 if(headTime <= 0 ) return;
784
785 tmp_block = (end_block + start_block)/2;
786 err=readBlock(t,tmp_block);
787 if(err) g_error("Can not read tracefile: %s\n", t->name);
788
789 headTime = ltt_time_compare(t->a_block_start->time, time);
790 tailTime = ltt_time_compare(t->a_block_end->time, time);
791 if(headTime <= 0 && tailTime >= 0) return;
792
793 if(headTime > 0){
794 s = start_block + 1;
795 e = tmp_block - 1;
796 if(s <= e)
797 ltt_tracefile_find_time_block(t, time, s, e);
798 else return;
799 }
800
801 if(tailTime < 0){
802 s = tmp_block + 1;
803 e = end_block - 1;
804 if(s <= e)
805 ltt_tracefile_find_time_block(t, time, s, e);
806 else return;
807 }
808 }
809
810 void ltt_tracefile_backward_find_time_block(LttTracefile *t, LttTime time)
811 {
812 int t_time, h_time, err;
813 err=readBlock(t,t->which_block-1);
814 if(err) g_error("Can not read tracefile: %s\n", t->name);
815 h_time = ltt_time_compare(t->a_block_start->time, time);
816 t_time = ltt_time_compare(t->a_block_end->time, time);
817 if(h_time == 0){
818 int tmp;
819 if(t->which_block == 1) return;
820 err=readBlock(t,t->which_block-1);
821 if(err) g_error("Can not read tracefile: %s\n", t->name);
822 tmp = ltt_time_compare(t->a_block_end->time, time);
823 if(tmp == 0) return ltt_tracefile_seek_time(t, time);
824 err=readBlock(t,t->which_block+1);
825 if(err) g_error("Can not read tracefile: %s\n", t->name);
826 }else if(h_time > 0){
827 ltt_tracefile_find_time_block(t, time, 1, t->which_block);
828 return ltt_tracefile_seek_time(t, time) ;
829 }else{
830 if(t_time >= 0) return ltt_tracefile_seek_time(t, time);
831 err=readBlock(t,t->which_block+1);
832 if(err) g_error("Can not read tracefile: %s\n", t->name);
833 }
834 }
835
836 void ltt_tracefile_seek_time(LttTracefile *t, LttTime time)
837 {
838 int err;
839 LttTime lttTime;
840 int headTime = ltt_time_compare(t->a_block_start->time, time);
841 int tailTime = ltt_time_compare(t->a_block_end->time, time);
842 LttEvent * ev;
843
844 if(headTime < 0 && tailTime > 0){
845 if(ltt_time_compare(t->a_block_end->time, t->current_event_time) !=0) {
846 lttTime = getEventTime(t);
847 err = ltt_time_compare(lttTime, time);
848 if(err > 0){
849 if(t->which_event==2 || (&t->prev_event_time,&time)<0){
850 return;
851 }else{
852 updateTracefile(t);
853 return ltt_tracefile_seek_time(t, time);
854 }
855 }else if(err < 0){
856 while(1){
857 ev = ltt_tracefile_read(t);
858 if(ev == NULL){
859 g_print("End of file\n");
860 return;
861 }
862 lttTime = getEventTime(t);
863 err = ltt_time_compare(lttTime, time);
864 if(err >= 0)return;
865 }
866 }else return;
867 }else{//we are at the end of the block
868 updateTracefile(t);
869 return ltt_tracefile_seek_time(t, time);
870 }
871 }else if(headTime >= 0){
872 if(t->which_block == 1){
873 updateTracefile(t);
874 }else{
875 if(ltt_time_compare(t->prev_block_end_time, time) >= 0 ||
876 (t->prev_block_end_time.tv_sec == 0 &&
877 t->prev_block_end_time.tv_nsec == 0 )){
878 ltt_tracefile_backward_find_time_block(t, time);
879 }else{
880 updateTracefile(t);
881 }
882 }
883 }else if(tailTime < 0){
884 if(t->which_block != t->block_number){
885 ltt_tracefile_find_time_block(t, time, t->which_block+1, t->block_number);
886 return ltt_tracefile_seek_time(t, time);
887 }else {
888 t->cur_event_pos = t->buffer + t->block_size;
889 g_print("End of file\n");
890 return;
891 }
892 }else if(tailTime == 0){
893 t->cur_event_pos = t->last_event_pos;
894 t->current_event_time = time;
895 t->cur_heart_beat_number = 0;
896 t->prev_event_time.tv_sec = 0;
897 t->prev_event_time.tv_nsec = 0;
898 return;
899 }
900 }
901
902 /*****************************************************************************
903 * Seek to the first event with position equal or larger to ep
904 ****************************************************************************/
905
906 void ltt_tracefile_seek_position(LttTracefile *t, const LttEventPosition *ep)
907 {
908 //if we are at the right place, just return
909 if(t->which_block == ep->block_num && t->which_event == ep->event_num)
910 return;
911
912 if(t->which_block == ep->block_num) updateTracefile(t);
913 else readBlock(t,ep->block_num);
914
915 //event offset is availiable
916 if(ep->old_position){
917 t->cur_heart_beat_number = ep->heart_beat_number;
918 t->cur_event_pos = t->buffer + ep->event_offset;
919 return;
920 }
921
922 //only block number and event index are availiable
923 while(t->which_event < ep->event_num) ltt_tracefile_read(t);
924
925 return;
926 }
927
928 /*****************************************************************************
929 *Function name
930 * ltt_tracefile_read : read the current event, set the pointer to the next
931 *Input params
932 * t : tracefile
933 *Return value
934 * LttEvent * : an event to be processed
935 ****************************************************************************/
936
937 LttEvent *ltt_tracefile_read(LttTracefile *t)
938 {
939 LttEvent * lttEvent = &t->an_event;
940 int err;
941
942 if(t->cur_event_pos == t->buffer + t->block_size){
943 if(t->which_block == t->block_number){
944 return NULL;
945 }
946 err = readBlock(t, t->which_block + 1);
947 if(err)g_error("Can not read tracefile");
948 }
949
950 lttEvent->event_id = (int)(*(guint16 *)(t->cur_event_pos));
951 if(lttEvent->event_id == TRACE_TIME_HEARTBEAT)
952 t->cur_heart_beat_number++;
953
954 t->prev_event_time = t->current_event_time;
955 // t->current_event_time = getEventTime(t);
956
957 lttEvent->time_delta = *(guint32 *)(t->cur_event_pos + EVENT_ID_SIZE);
958 lttEvent->event_time = t->current_event_time;
959 lttEvent->event_cycle_count = t->cur_cycle_count;
960
961 lttEvent->tracefile = t;
962 lttEvent->data = t->cur_event_pos + EVENT_HEADER_SIZE;
963 lttEvent->which_block = t->which_block;
964 lttEvent->which_event = t->which_event;
965
966 //update the fields of the current event and go to the next event
967 err = skipEvent(t);
968 if(err == ERANGE) g_error("event id is out of range\n");
969
970 return lttEvent;
971 }
972
973 /****************************************************************************
974 *Function name
975 * readFile : wrap function to read from a file
976 *Input Params
977 * fd : file descriptor
978 * buf : buf to contain the content
979 * size : number of bytes to be read
980 * mesg : message to be printed if some thing goes wrong
981 *return value
982 * 0 : success
983 * EIO : can not read from the file
984 ****************************************************************************/
985
986 int readFile(int fd, void * buf, size_t size, char * mesg)
987 {
988 ssize_t nbBytes;
989 nbBytes = read(fd, buf, size);
990 if(nbBytes != size){
991 printf("%s\n",mesg);
992 return EIO;
993 }
994 return 0;
995 }
996
997 /****************************************************************************
998 *Function name
999 * readBlock : read a block from the file
1000 *Input Params
1001 * lttdes : ltt trace file
1002 * whichBlock : the block which will be read
1003 *return value
1004 * 0 : success
1005 * EINVAL : lseek fail
1006 * EIO : can not read from the file
1007 ****************************************************************************/
1008
1009 int readBlock(LttTracefile * tf, int whichBlock)
1010 {
1011 off_t nbBytes;
1012 guint32 lostSize;
1013
1014 if(whichBlock - tf->which_block == 1 && tf->which_block != 0){
1015 tf->prev_block_end_time = tf->a_block_end->time;
1016 tf->prev_event_time = tf->a_block_end->time;
1017 }else{
1018 tf->prev_block_end_time.tv_sec = 0;
1019 tf->prev_block_end_time.tv_nsec = 0;
1020 tf->prev_event_time.tv_sec = 0;
1021 tf->prev_event_time.tv_nsec = 0;
1022 }
1023
1024 nbBytes=lseek(tf->fd,(off_t)((whichBlock-1)*tf->block_size), SEEK_SET);
1025 if(nbBytes == -1) return EINVAL;
1026
1027 if(readFile(tf->fd,tf->buffer,tf->block_size,"Unable to read a block"))
1028 return EIO;
1029
1030 tf->a_block_start=(BlockStart *) (tf->buffer + EVENT_HEADER_SIZE);
1031 lostSize = *(guint32 *)(tf->buffer + tf->block_size - sizeof(guint32));
1032 tf->a_block_end=(BlockEnd *)(tf->buffer + tf->block_size -
1033 lostSize + EVENT_HEADER_SIZE);
1034 tf->last_event_pos = tf->buffer + tf->block_size - lostSize;
1035
1036 tf->which_block = whichBlock;
1037 tf->which_event = 1;
1038 tf->cur_event_pos = tf->buffer;//the beginning of the block, block start ev
1039 tf->cur_heart_beat_number = 0;
1040
1041 getCyclePerNsec(tf);
1042
1043 tf->current_event_time = getEventTime(tf);
1044
1045 return 0;
1046 }
1047
1048 /*****************************************************************************
1049 *Function name
1050 * updateTracefile : reinitialize the info of the block which is already
1051 * in the buffer
1052 *Input params
1053 * tf : tracefile
1054 ****************************************************************************/
1055
1056 void updateTracefile(LttTracefile * tf)
1057 {
1058 tf->which_event = 1;
1059 tf->cur_event_pos = tf->buffer;
1060 tf->current_event_time = getEventTime(tf);
1061 tf->cur_heart_beat_number = 0;
1062
1063 tf->prev_event_time.tv_sec = 0;
1064 tf->prev_event_time.tv_nsec = 0;
1065 }
1066
1067 /*****************************************************************************
1068 *Function name
1069 * skipEvent : go to the next event, update the fields of the current event
1070 *Input params
1071 * t : tracefile
1072 *return value
1073 * 0 : success
1074 * ERANGE : event id is out of range
1075 ****************************************************************************/
1076
1077 int skipEvent(LttTracefile * t)
1078 {
1079 int evId, err;
1080 void * evData;
1081 LttEventType * evT;
1082 LttField * rootFld;
1083
1084 evId = (int)(*(guint16 *)(t->cur_event_pos));
1085 evData = t->cur_event_pos + EVENT_HEADER_SIZE;
1086
1087 evT = ltt_trace_eventtype_get(t->trace,(unsigned)evId);
1088
1089 if(evT) rootFld = evT->root_field;
1090 else return ERANGE;
1091
1092 if(rootFld){
1093 //event has string/sequence or the last event is not the same event
1094 if((evT->latest_block!=t->which_block || evT->latest_event!=t->which_event)
1095 && rootFld->field_fixed == 0){
1096 setFieldsOffset(t, evT, evData, t->trace);
1097 }
1098 t->cur_event_pos += EVENT_HEADER_SIZE + rootFld->field_size;
1099 }else t->cur_event_pos += EVENT_HEADER_SIZE;
1100
1101 evT->latest_block = t->which_block;
1102 evT->latest_event = t->which_event;
1103
1104 //the next event is in the next block
1105 if(evId == TRACE_BLOCK_END){
1106 t->cur_event_pos = t->buffer + t->block_size;
1107 }else{
1108 t->which_event++;
1109 t->current_event_time = getEventTime(t);
1110 }
1111
1112 return 0;
1113 }
1114
1115 /*****************************************************************************
1116 *Function name
1117 * getCyclePerNsec : calculate cycles per nsec for current block
1118 *Input Params
1119 * t : tracefile
1120 ****************************************************************************/
1121
1122 void getCyclePerNsec(LttTracefile * t)
1123 {
1124 LttTime lBufTotalTime; /* Total time for this buffer */
1125 LttCycleCount lBufTotalNSec; /* Total time for this buffer in nsecs */
1126 LttCycleCount lBufTotalCycle;/* Total cycles for this buffer */
1127
1128 /* Calculate the total time for this buffer */
1129 lBufTotalTime = ltt_time_sub(t->a_block_end->time, t->a_block_start->time);
1130
1131 /* Calculate the total cycles for this bufffer */
1132 lBufTotalCycle = t->a_block_end->cycle_count;
1133 lBufTotalCycle -= t->a_block_start->cycle_count;
1134
1135 /* Convert the total time to nsecs */
1136 lBufTotalNSec = lBufTotalTime.tv_sec;
1137 lBufTotalNSec *= NANOSECONDS_PER_SECOND;
1138 lBufTotalNSec += lBufTotalTime.tv_nsec;
1139
1140 t->cycle_per_nsec = (double)lBufTotalCycle / (double)lBufTotalNSec;
1141 }
1142
1143 /****************************************************************************
1144 *Function name
1145 * getEventTime : obtain the time of an event
1146 *Input params
1147 * tf : tracefile
1148 *Return value
1149 * LttTime : the time of the event
1150 ****************************************************************************/
1151
1152 LttTime getEventTime(LttTracefile * tf)
1153 {
1154 LttTime time;
1155 LttCycleCount cycle_count; // cycle count for the current event
1156 LttCycleCount lEventTotalCycle; // Total cycles from start for event
1157 LttCycleCount lEventNSec; // Total usecs from start for event
1158 LttTime lTimeOffset; // Time offset in struct LttTime
1159 guint16 evId;
1160 LttCycleCount tmpCycleCount = (((LttCycleCount)1)<<32);
1161
1162 evId = *(guint16 *)tf->cur_event_pos;
1163 if(evId == TRACE_BLOCK_START){
1164 tf->count = 0;
1165 tf->pre_cycle_count = 0;
1166 tf->cur_cycle_count = tf->a_block_start->cycle_count;
1167 return tf->a_block_start->time;
1168 }else if(evId == TRACE_BLOCK_END){
1169 tf->count = 0;
1170 tf->pre_cycle_count = 0;
1171 tf->cur_cycle_count = tf->a_block_end->cycle_count;
1172 return tf->a_block_end->time;
1173 }
1174
1175 // Calculate total time in cycles from start of buffer for this event
1176 cycle_count = (LttCycleCount)*(guint32 *)(tf->cur_event_pos + EVENT_ID_SIZE);
1177
1178 if(cycle_count < tf->pre_cycle_count)tf->count++;
1179 tf->pre_cycle_count = cycle_count;
1180 cycle_count += tmpCycleCount * tf->count;
1181
1182 // if(tf->cur_heart_beat_number > tf->count)
1183 // cycle_count += tmpCycleCount * (tf->cur_heart_beat_number - tf->count);
1184
1185 tf->cur_cycle_count = cycle_count;
1186
1187 lEventTotalCycle = cycle_count;
1188 lEventTotalCycle -= tf->a_block_start->cycle_count;
1189
1190 // Convert it to nsecs
1191 lEventNSec = (double)lEventTotalCycle / (double)tf->cycle_per_nsec;
1192
1193 // Determine offset in struct LttTime
1194 lTimeOffset.tv_nsec = lEventNSec % NANOSECONDS_PER_SECOND;
1195 lTimeOffset.tv_sec = lEventNSec / NANOSECONDS_PER_SECOND;
1196
1197 time = ltt_time_add(tf->a_block_start->time, lTimeOffset);
1198
1199 return time;
1200 }
1201
1202 /*****************************************************************************
1203 *Function name
1204 * setFieldsOffset : set offset of the fields
1205 *Input params
1206 * tracefile : opened trace file
1207 * evT : the event type
1208 * evD : event data, it may be NULL
1209 ****************************************************************************/
1210
1211 void setFieldsOffset(LttTracefile *tf,LttEventType *evT,void *evD,LttTrace* t)
1212 {
1213 LttField * rootFld = evT->root_field;
1214 // rootFld->base_address = evD;
1215
1216 if(rootFld)
1217 rootFld->field_size = getFieldtypeSize(tf, evT, 0,0,rootFld, evD,t);
1218 }
1219
1220 /*****************************************************************************
1221 *Function name
1222 * getFieldtypeSize: get the size of the field type (primitive type)
1223 *Input params
1224 * tracefile : opened trace file
1225 * evT : event type
1226 * offsetRoot : offset from the root
1227 * offsetParent : offset from the parrent
1228 * fld : field
1229 * evD : event data, it may be NULL
1230 *Return value
1231 * int : size of the field
1232 ****************************************************************************/
1233
1234 int getFieldtypeSize(LttTracefile * t, LttEventType * evT, int offsetRoot,
1235 int offsetParent, LttField * fld, void *evD, LttTrace *trace)
1236 {
1237 int size, size1, element_number, i, offset1, offset2;
1238 LttType * type = fld->field_type;
1239
1240 if(t){
1241 if(evT->latest_block==t->which_block && evT->latest_event==t->which_event){
1242 return fld->field_size;
1243 }
1244 }
1245
1246 if(fld->field_fixed == 1){
1247 if(fld == evT->root_field) return fld->field_size;
1248 }
1249
1250 if(type->type_class != LTT_STRUCT && type->type_class != LTT_ARRAY &&
1251 type->type_class != LTT_SEQUENCE && type->type_class != LTT_STRING){
1252 if(fld->field_fixed == -1){
1253 size = (int) ltt_type_size(trace, type);
1254 fld->field_fixed = 1;
1255 }else size = fld->field_size;
1256
1257 }else if(type->type_class == LTT_ARRAY){
1258 element_number = (int) type->element_number;
1259 if(fld->field_fixed == -1){
1260 size = getFieldtypeSize(t, evT, offsetRoot,0,fld->child[0], NULL, trace);
1261 if(size == 0){ //has string or sequence
1262 fld->field_fixed = 0;
1263 }else{
1264 fld->field_fixed = 1;
1265 size *= element_number;
1266 }
1267 }else if(fld->field_fixed == 0){// has string or sequence
1268 size = 0;
1269 for(i=0;i<element_number;i++){
1270 size += getFieldtypeSize(t, evT, offsetRoot+size,size,
1271 fld->child[0], evD+size, trace);
1272 }
1273 }else size = fld->field_size;
1274
1275 }else if(type->type_class == LTT_SEQUENCE){
1276 size1 = (int) ltt_type_size(trace, type);
1277 if(fld->field_fixed == -1){
1278 fld->sequ_number_size = size1;
1279 fld->field_fixed = 0;
1280 size = getFieldtypeSize(t, evT, offsetRoot,0,fld->child[0], NULL, trace);
1281 fld->element_size = size;
1282 }else{//0: sequence
1283 element_number = getIntNumber(size1,evD);
1284 type->element_number = element_number;
1285 if(fld->element_size > 0){
1286 size = element_number * fld->element_size;
1287 }else{//sequence has string or sequence
1288 size = 0;
1289 for(i=0;i<element_number;i++){
1290 size += getFieldtypeSize(t, evT, offsetRoot+size+size1,size+size1,
1291 fld->child[0], evD+size+size1, trace);
1292 }
1293 }
1294 size += size1;
1295 }
1296
1297 }else if(type->type_class == LTT_STRING){
1298 size = 0;
1299 if(fld->field_fixed == -1){
1300 fld->field_fixed = 0;
1301 }else{//0: string
1302 size = strlen((char*)evD) + 1; //include end : '\0'
1303 }
1304
1305 }else if(type->type_class == LTT_STRUCT){
1306 element_number = (int) type->element_number;
1307 size = 0;
1308 if(fld->field_fixed == -1){
1309 offset1 = offsetRoot;
1310 offset2 = 0;
1311 for(i=0;i<element_number;i++){
1312 size1=getFieldtypeSize(t, evT,offset1,offset2, fld->child[i], NULL, trace);
1313 if(size1 > 0 && size >= 0){
1314 size += size1;
1315 if(offset1 >= 0) offset1 += size1;
1316 offset2 += size1;
1317 }else{
1318 size = -1;
1319 offset1 = -1;
1320 offset2 = -1;
1321 }
1322 }
1323 if(size == -1){
1324 fld->field_fixed = 0;
1325 size = 0;
1326 }else fld->field_fixed = 1;
1327 }else if(fld->field_fixed == 0){
1328 offset1 = offsetRoot;
1329 offset2 = 0;
1330 for(i=0;i<element_number;i++){
1331 size=getFieldtypeSize(t,evT,offset1,offset2,fld->child[i],evD+offset2, trace);
1332 offset1 += size;
1333 offset2 += size;
1334 }
1335 size = offset2;
1336 }else size = fld->field_size;
1337 }
1338
1339 fld->offset_root = offsetRoot;
1340 fld->offset_parent = offsetParent;
1341 if(!evD){
1342 fld->fixed_root = (offsetRoot==-1) ? 0 : 1;
1343 fld->fixed_parent = (offsetParent==-1) ? 0 : 1;
1344 }
1345 fld->field_size = size;
1346
1347 return size;
1348 }
1349
1350
1351 /*****************************************************************************
1352 *Function name
1353 * getIntNumber : get an integer number
1354 *Input params
1355 * size : the size of the integer
1356 * evD : the event data
1357 *Return value
1358 * int : an integer
1359 ****************************************************************************/
1360
1361 int getIntNumber(int size, void *evD)
1362 {
1363 gint64 i;
1364 if(size == 1) i = *(gint8 *)evD;
1365 else if(size == 2) i = *(gint16 *)evD;
1366 else if(size == 4) i = *(gint32 *)evD;
1367 else if(size == 8) i = *(gint64 *)evD;
1368
1369 return (int) i;
1370 }
1371
1372 /*****************************************************************************
1373 *Function name
1374 * getDataEndianType : get the data type size and endian type of the local
1375 * machine
1376 *Input params
1377 * size : size of data type
1378 * endian : endian type, little or big
1379 ****************************************************************************/
1380
1381 void getDataEndianType(LttArchSize * size, LttArchEndian * endian)
1382 {
1383 int i = 1;
1384 char c = (char) i;
1385 int sizeInt=sizeof(int), sizeLong=sizeof(long), sizePointer=sizeof(void *);
1386
1387 if(c == 1) *endian = LTT_LITTLE_ENDIAN;
1388 else *endian = LTT_BIG_ENDIAN;
1389
1390 if(sizeInt == 2 && sizeLong == 4 && sizePointer == 4)
1391 *size = LTT_LP32;
1392 else if(sizeInt == 4 && sizeLong == 4 && sizePointer == 4)
1393 *size = LTT_ILP32;
1394 else if(sizeInt == 4 && sizeLong == 8 && sizePointer == 8)
1395 *size = LTT_LP64;
1396 else if(sizeInt == 8 && sizeLong == 8 && sizePointer == 8)
1397 *size = LTT_ILP64;
1398 else *size = LTT_UNKNOWN;
1399 }
1400
1401 /* get the node name of the system */
1402
1403 char * ltt_trace_system_description_node_name (LttSystemDescription * s)
1404 {
1405 return s->node_name;
1406 }
1407
1408
1409 /* get the domain name of the system */
1410
1411 char * ltt_trace_system_description_domain_name (LttSystemDescription * s)
1412 {
1413 return s->domain_name;
1414 }
1415
1416
1417 /* get the description of the system */
1418
1419 char * ltt_trace_system_description_description (LttSystemDescription * s)
1420 {
1421 return s->description;
1422 }
1423
1424
1425 /* get the start time of the trace */
1426
1427 LttTime ltt_trace_system_description_trace_start_time(LttSystemDescription *s)
1428 {
1429 return s->trace_start;
1430 }
1431
This page took 0.070445 seconds and 4 git commands to generate.