header missing
[lttv.git] / ltt / branches / poly / ltt / tracefile.c
CommitLineData
449cb9d7 1/* This file is part of the Linux Trace Toolkit viewer
57df94dd 2 * Copyright (C) 2003-2004 Xiangxiu Yang, Mathieu Desnoyers
449cb9d7 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
6cd62ccf 19#include <stdio.h>
20#include <fcntl.h>
8d1e6362 21#include <string.h>
22#include <dirent.h>
6cd62ccf 23#include <sys/stat.h>
24#include <sys/types.h>
8d1e6362 25#include <errno.h>
26#include <unistd.h>
42db9bf1 27#include <math.h>
cdf90f40 28#include <glib.h>
6cd62ccf 29
ef35d837 30// For realpath
31#include <limits.h>
32#include <stdlib.h>
33
34
6cd62ccf 35#include "parser.h"
a5dcde2f 36#include <ltt/ltt.h>
37#include "ltt-private.h"
963b5f2d 38#include <ltt/trace.h>
a5dcde2f 39#include <ltt/facility.h>
c02ea99f 40#include <ltt/event.h>
8d1e6362 41#include <ltt/type.h>
1a2ceb63 42#include <ltt/ltt-types.h>
6cd62ccf 43
86005ded 44#ifndef g_open
45#define g_open open
46#endif
47
48
963b5f2d 49#define DIR_NAME_SIZE 256
51b5991e 50#define __UNUSED__ __attribute__((__unused__))
6cd62ccf 51
a1062ddd 52#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
53#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
54
45e14832 55#define g_close close
8959a0c8 56
57/* obtain the time of an event */
58
59static inline LttTime getEventTime(LttTracefile * tf);
60
61
6cd62ccf 62/* set the offset of the fields belonging to the event,
63 need the information of the archecture */
40331ba8 64void setFieldsOffset(LttTracefile *tf,LttEventType *evT,void *evD,LttTrace *t);
6cd62ccf 65
66/* get the size of the field type according to the archtecture's
67 size and endian type(info of the archecture) */
21182d4a 68static inline gint getFieldtypeSize(LttTracefile * tf,
69 LttEventType * evT, gint offsetRoot,
70 gint offsetParent, LttField *fld, void *evD, LttTrace* t);
6cd62ccf 71
72/* read a fixed size or a block information from the file (fd) */
45e14832 73int readFile(int fd, void * buf, size_t size, gchar * mesg);
963b5f2d 74int readBlock(LttTracefile * tf, int whichBlock);
6cd62ccf 75
76/* calculate cycles per nsec for current block */
963b5f2d 77void getCyclePerNsec(LttTracefile * t);
6cd62ccf 78
79/* reinitialize the info of the block which is already in the buffer */
963b5f2d 80void updateTracefile(LttTracefile * tf);
6cd62ccf 81
82/* go to the next event */
963b5f2d 83int skipEvent(LttTracefile * t);
6cd62ccf 84
6cd62ccf 85
43da6a59 86/* Functions to parse system.xml file (using glib xml parser) */
51b5991e 87static void parser_start_element (GMarkupParseContext __UNUSED__ *context,
43da6a59 88 const gchar *element_name,
89 const gchar **attribute_names,
90 const gchar **attribute_values,
91 gpointer user_data,
92 GError **error)
93{
94 int i=0;
95 LttSystemDescription* des = (LttSystemDescription* )user_data;
96 if(strcmp("system", element_name)){
2a74fbf4 97 *error = g_error_new(G_MARKUP_ERROR,
98 G_LOG_LEVEL_WARNING,
99 "This is not system.xml file");
100 return;
43da6a59 101 }
102
103 while(attribute_names[i]){
104 if(strcmp("node_name", attribute_names[i])==0){
105 des->node_name = g_strdup(attribute_values[i]);
106 }else if(strcmp("domainname", attribute_names[i])==0){
107 des->domain_name = g_strdup(attribute_values[i]);
108 }else if(strcmp("cpu", attribute_names[i])==0){
109 des->nb_cpu = atoi(attribute_values[i]);
110 }else if(strcmp("arch_size", attribute_names[i])==0){
111 if(strcmp(attribute_values[i],"LP32") == 0) des->size = LTT_LP32;
112 else if(strcmp(attribute_values[i],"ILP32") == 0) des->size = LTT_ILP32;
113 else if(strcmp(attribute_values[i],"LP64") == 0) des->size = LTT_LP64;
114 else if(strcmp(attribute_values[i],"ILP64") == 0) des->size = LTT_ILP64;
115 else if(strcmp(attribute_values[i],"UNKNOWN") == 0) des->size = LTT_UNKNOWN;
116 }else if(strcmp("endian", attribute_names[i])==0){
117 if(strcmp(attribute_values[i],"LITTLE_ENDIAN") == 0)
118 des->endian = LTT_LITTLE_ENDIAN;
119 else if(strcmp(attribute_values[i],"BIG_ENDIAN") == 0)
120 des->endian = LTT_BIG_ENDIAN;
121 }else if(strcmp("kernel_name", attribute_names[i])==0){
122 des->kernel_name = g_strdup(attribute_values[i]);
123 }else if(strcmp("kernel_release", attribute_names[i])==0){
124 des->kernel_release = g_strdup(attribute_values[i]);
125 }else if(strcmp("kernel_version", attribute_names[i])==0){
126 des->kernel_version = g_strdup(attribute_values[i]);
127 }else if(strcmp("machine", attribute_names[i])==0){
128 des->machine = g_strdup(attribute_values[i]);
129 }else if(strcmp("processor", attribute_names[i])==0){
130 des->processor = g_strdup(attribute_values[i]);
131 }else if(strcmp("hardware_platform", attribute_names[i])==0){
132 des->hardware_platform = g_strdup(attribute_values[i]);
133 }else if(strcmp("operating_system", attribute_names[i])==0){
134 des->operating_system = g_strdup(attribute_values[i]);
135 }else if(strcmp("ltt_major_version", attribute_names[i])==0){
136 des->ltt_major_version = atoi(attribute_values[i]);
137 }else if(strcmp("ltt_minor_version", attribute_names[i])==0){
138 des->ltt_minor_version = atoi(attribute_values[i]);
139 }else if(strcmp("ltt_block_size", attribute_names[i])==0){
140 des->ltt_block_size = atoi(attribute_values[i]);
141 }else{
2a74fbf4 142 *error = g_error_new(G_MARKUP_ERROR,
143 G_LOG_LEVEL_WARNING,
144 "Not a valid attribute");
145 return;
43da6a59 146 }
147 i++;
148 }
149}
150
51b5991e 151static void parser_characters (GMarkupParseContext __UNUSED__ *context,
43da6a59 152 const gchar *text,
51b5991e 153 gsize __UNUSED__ text_len,
43da6a59 154 gpointer user_data,
51b5991e 155 GError __UNUSED__ **error)
43da6a59 156{
157 LttSystemDescription* des = (LttSystemDescription* )user_data;
158 des->description = g_strdup(text);
159}
160
161
6cd62ccf 162/*****************************************************************************
163 *Function name
963b5f2d 164 * ltt_tracefile_open : open a trace file, construct a LttTracefile
6cd62ccf 165 *Input params
963b5f2d 166 * t : the trace containing the tracefile
167 * fileName : path name of the trace file
6cd62ccf 168 *Return value
963b5f2d 169 * : a pointer to a tracefile
6cd62ccf 170 ****************************************************************************/
171
45e14832 172LttTracefile* ltt_tracefile_open(LttTrace * t, gchar * fileName)
6cd62ccf 173{
963b5f2d 174 LttTracefile * tf;
175 struct stat lTDFStat; /* Trace data file status */
6cd62ccf 176
963b5f2d 177 tf = g_new(LttTracefile, 1);
6cd62ccf 178
179 //open the file
963b5f2d 180 tf->name = g_strdup(fileName);
181 tf->trace = t;
45e14832 182 tf->fd = g_open(fileName, O_RDONLY, 0);
6cd62ccf 183 if(tf->fd < 0){
2a74fbf4 184 g_warning("Unable to open input data file %s\n", fileName);
185 g_free(tf->name);
186 g_free(tf);
187 return NULL;
6cd62ccf 188 }
189
190 // Get the file's status
191 if(fstat(tf->fd, &lTDFStat) < 0){
2a74fbf4 192 g_warning("Unable to get the status of the input data file %s\n", fileName);
193 g_free(tf->name);
45e14832 194 g_close(tf->fd);
2a74fbf4 195 g_free(tf);
196 return NULL;
6cd62ccf 197 }
198
199 // Is the file large enough to contain a trace
8d1e6362 200 if(lTDFStat.st_size < (off_t)(sizeof(BlockStart) + EVENT_HEADER_SIZE)){
8710c6c7 201 g_print("The input data file %s does not contain a trace\n", fileName);
663bd9ff 202 g_free(tf->name);
45e14832 203 g_close(tf->fd);
663bd9ff 204 g_free(tf);
8710c6c7 205 return NULL;
6cd62ccf 206 }
207
208 //store the size of the file
209 tf->file_size = lTDFStat.st_size;
963b5f2d 210 tf->block_size = t->system_description->ltt_block_size;
211 tf->block_number = tf->file_size / tf->block_size;
212 tf->which_block = 0;
6cd62ccf 213
214 //allocate memory to contain the info of a block
45e14832 215 tf->buffer = (void *) g_new(gchar, t->system_description->ltt_block_size);
6cd62ccf 216
963b5f2d 217 //read the first block
218 if(readBlock(tf,1)) exit(1);
6cd62ccf 219
220 return tf;
221}
222
6cd62ccf 223
224/*****************************************************************************
963b5f2d 225 *Open control and per cpu tracefiles
6cd62ccf 226 ****************************************************************************/
227
45e14832 228void ltt_tracefile_open_cpu(LttTrace *t, gchar * tracefile_name)
6cd62ccf 229{
963b5f2d 230 LttTracefile * tf;
231 tf = ltt_tracefile_open(t,tracefile_name);
4a6c8e36 232 if(!tf) return;
963b5f2d 233 t->per_cpu_tracefile_number++;
234 g_ptr_array_add(t->per_cpu_tracefiles, tf);
6cd62ccf 235}
236
45e14832 237gint ltt_tracefile_open_control(LttTrace *t, gchar * control_name)
6cd62ccf 238{
963b5f2d 239 LttTracefile * tf;
c02ea99f 240 LttEvent ev;
963b5f2d 241 LttFacility * f;
963b5f2d 242 void * pos;
243 FacilityLoad fLoad;
8d1e6362 244 unsigned int i;
963b5f2d 245
246 tf = ltt_tracefile_open(t,control_name);
2a74fbf4 247 if(!tf) {
248 g_warning("ltt_tracefile_open_control : bad file descriptor");
249 return -1;
250 }
963b5f2d 251 t->control_tracefile_number++;
252 g_ptr_array_add(t->control_tracefiles,tf);
253
254 //parse facilities tracefile to get base_id
542ceddd 255 if(strcmp(&control_name[strlen(control_name)-10],"facilities") ==0){
963b5f2d 256 while(1){
c02ea99f 257 if(!ltt_tracefile_read(tf,&ev)) return 0; // end of file
40331ba8 258
c02ea99f 259 if(ev.event_id == TRACE_FACILITY_LOAD){
260 pos = ev.data;
45e14832 261 fLoad.name = (gchar*)pos;
47a166fc 262 fLoad.checksum = *(LttChecksum*)(pos + strlen(fLoad.name));
cbd41522 263 fLoad.base_code = *(guint32 *)(pos + strlen(fLoad.name) + sizeof(LttChecksum));
963b5f2d 264
265 for(i=0;i<t->facility_number;i++){
266 f = (LttFacility*)g_ptr_array_index(t->facilities,i);
267 if(strcmp(f->name,fLoad.name)==0 && fLoad.checksum==f->checksum){
268 f->base_id = fLoad.base_code;
269 break;
270 }
271 }
2a74fbf4 272 if(i==t->facility_number) {
8d1e6362 273 g_warning("Facility: %s, checksum: %u is not found",
274 fLoad.name,(unsigned int)fLoad.checksum);
2a74fbf4 275 return -1;
276 }
c02ea99f 277 }else if(ev.event_id == TRACE_BLOCK_START){
40331ba8 278 continue;
c02ea99f 279 }else if(ev.event_id == TRACE_BLOCK_END){
40331ba8 280 break;
2a74fbf4 281 }else {
8d1e6362 282 g_warning("Not valid facilities trace file");
2a74fbf4 283 return -1;
284 }
963b5f2d 285 }
286 }
2a74fbf4 287 return 0;
6cd62ccf 288}
289
290/*****************************************************************************
291 *Function name
963b5f2d 292 * ltt_tracefile_close: close a trace file,
6cd62ccf 293 *Input params
963b5f2d 294 * t : tracefile which will be closed
6cd62ccf 295 ****************************************************************************/
296
963b5f2d 297void ltt_tracefile_close(LttTracefile *t)
6cd62ccf 298{
963b5f2d 299 g_free(t->name);
300 g_free(t->buffer);
663bd9ff 301 close(t->fd);
963b5f2d 302 g_free(t);
303}
6cd62ccf 304
6cd62ccf 305
963b5f2d 306/*****************************************************************************
307 *Get system information
308 ****************************************************************************/
45e14832 309gint getSystemInfo(LttSystemDescription* des, gchar * pathname)
963b5f2d 310{
45e14832 311 int fd;
312 GIOChannel *iochan;
313 gchar *buf = NULL;
314 gsize length;
43da6a59 315
316 GMarkupParseContext * context;
2a74fbf4 317 GError * error = NULL;
43da6a59 318 GMarkupParser markup_parser =
319 {
320 parser_start_element,
8d1e6362 321 NULL,
43da6a59 322 parser_characters,
323 NULL, /* passthrough */
324 NULL /* error */
325 };
963b5f2d 326
45e14832 327 fd = g_open(pathname, O_RDONLY, 0);
328 if(fd == -1){
2a74fbf4 329 g_warning("Can not open file : %s\n", pathname);
330 return -1;
6cd62ccf 331 }
963b5f2d 332
45e14832 333 iochan = g_io_channel_unix_new(fd);
334
43da6a59 335 context = g_markup_parse_context_new(&markup_parser, 0, des,NULL);
6cd62ccf 336
45e14832 337 //while(fgets(buf,DIR_NAME_SIZE, fp) != NULL){
338 while(g_io_channel_read_line(iochan, &buf, &length, NULL, &error)
339 != G_IO_STATUS_EOF) {
340
341 if(error != NULL) {
342 g_warning("Can not read xml file: \n%s\n", error->message);
343 g_error_free(error);
344 }
345 if(!g_markup_parse_context_parse(context, buf, length, &error)){
2a74fbf4 346 if(error != NULL) {
347 g_warning("Can not parse xml file: \n%s\n", error->message);
348 g_error_free(error);
349 }
350 g_markup_parse_context_free(context);
45e14832 351
352 g_io_channel_shutdown(iochan, FALSE, &error); /* No flush */
353 if(error != NULL) {
354 g_warning("Can not close file: \n%s\n", error->message);
355 g_error_free(error);
356 }
357
358 close(fd);
2a74fbf4 359 return -1;
43da6a59 360 }
963b5f2d 361 }
2a74fbf4 362 g_markup_parse_context_free(context);
45e14832 363
364 g_io_channel_shutdown(iochan, FALSE, &error); /* No flush */
365 if(error != NULL) {
366 g_warning("Can not close file: \n%s\n", error->message);
367 g_error_free(error);
368 }
369
370 g_close(fd);
371
372 g_free(buf);
2a74fbf4 373 return 0;
6cd62ccf 374}
375
376/*****************************************************************************
963b5f2d 377 *The following functions get facility/tracefile information
6cd62ccf 378 ****************************************************************************/
379
45e14832 380gint getFacilityInfo(LttTrace *t, gchar* eventdefs)
6cd62ccf 381{
45e14832 382 GDir * dir;
383 const gchar * name;
8d1e6362 384 unsigned int i,j;
963b5f2d 385 LttFacility * f;
386 LttEventType * et;
45e14832 387 gchar fullname[DIR_NAME_SIZE];
388 GError * error = NULL;
389
390 dir = g_dir_open(eventdefs, 0, &error);
963b5f2d 391
45e14832 392 if(error != NULL) {
393 g_warning("Can not open directory: %s, %s\n", eventdefs, error->message);
394 g_error_free(error);
2a74fbf4 395 return -1;
396 }
963b5f2d 397
45e14832 398 while((name = g_dir_read_name(dir)) != NULL){
399 if(!g_pattern_match_simple("*.xml", name)) continue;
400 strcpy(fullname,eventdefs);
401 strcat(fullname,name);
402 ltt_facility_open(t,fullname);
403 }
404 g_dir_close(dir);
963b5f2d 405
963b5f2d 406 for(j=0;j<t->facility_number;j++){
8710c6c7 407 f = (LttFacility*)g_ptr_array_index(t->facilities, j);
963b5f2d 408 for(i=0; i<f->event_number; i++){
409 et = f->events[i];
40331ba8 410 setFieldsOffset(NULL, et, NULL, t);
963b5f2d 411 }
412 }
2a74fbf4 413 return 0;
963b5f2d 414}
6cd62ccf 415
45e14832 416gint getControlFileInfo(LttTrace *t, gchar* control)
6cd62ccf 417{
45e14832 418 GDir * dir;
419 const gchar *name;
420 gchar fullname[DIR_NAME_SIZE];
421 GError * error = NULL;
422
423 dir = g_dir_open(control, 0, &error);
963b5f2d 424
45e14832 425 if(error != NULL) {
426 g_warning("Can not open directory: %s, %s\n", control, error->message);
427 g_error_free(error);
2a74fbf4 428 return -1;
429 }
963b5f2d 430
45e14832 431 while((name = g_dir_read_name(dir)) != NULL){
432 if(strcmp(name,"facilities") != 0 &&
433 strcmp(name,"interrupts") != 0 &&
434 strcmp(name,"processes") != 0) continue;
963b5f2d 435
45e14832 436 strcpy(fullname,control);
437 strcat(fullname,name);
438 if(ltt_tracefile_open_control(t,fullname)) {
439 g_dir_close(dir);
2a74fbf4 440 return -1;
45e14832 441 }
963b5f2d 442 }
45e14832 443 g_dir_close(dir);
2a74fbf4 444 return 0;
6cd62ccf 445}
446
2a74fbf4 447gint getCpuFileInfo(LttTrace *t, char* cpu)
6cd62ccf 448{
45e14832 449 GDir * dir;
450 const gchar * name;
451 gchar fullname[DIR_NAME_SIZE];
452 GError * error = NULL;
453
454 dir = g_dir_open(cpu, 0, &error);
963b5f2d 455
45e14832 456 if(error != NULL) {
457 g_warning("Can not open directory: %s, %s\n", cpu, error->message);
458 g_error_free(error);
2a74fbf4 459 return -1;
460 }
963b5f2d 461
45e14832 462 while((name = g_dir_read_name(dir)) != NULL){
463 if(strcmp(name,".svn") != 0){ /* . and .. already excluded */
464 strcpy(fullname,cpu);
465 strcat(fullname,name);
466 ltt_tracefile_open_cpu(t,fullname);
963b5f2d 467 }else continue;
468 }
45e14832 469 g_dir_close(dir);
2a74fbf4 470 return 0;
6cd62ccf 471}
472
963b5f2d 473/*****************************************************************************
474 *A trace is specified as a pathname to the directory containing all the
475 *associated data (control tracefiles, per cpu tracefiles, event
476 *descriptions...).
477 *
478 *When a trace is closed, all the associated facilities, types and fields
479 *are released as well.
8d1e6362 480 */
481
482
483/****************************************************************************
484 * get_absolute_pathname
803229fa 485 *
8d1e6362 486 * return the unique pathname in the system
487 *
ef35d837 488 * MD : Fixed this function so it uses realpath, dealing well with
489 * forgotten cases (.. were not used correctly before).
803229fa 490 *
963b5f2d 491 ****************************************************************************/
45e14832 492void get_absolute_pathname(const gchar *pathname, gchar * abs_pathname)
9f797243 493{
9f797243 494 abs_pathname[0] = '\0';
803229fa 495
ef35d837 496 if ( realpath (pathname, abs_pathname) != NULL)
497 return;
498 else
499 {
8d1e6362 500 /* error, return the original path unmodified */
ef35d837 501 strcpy(abs_pathname, pathname);
9f797243 502 return;
503 }
ef35d837 504 return;
9f797243 505}
506
45e14832 507LttTrace *ltt_trace_open(const gchar *pathname)
6cd62ccf 508{
963b5f2d 509 LttTrace * t;
510 LttSystemDescription * sys_description;
45e14832 511 gchar eventdefs[DIR_NAME_SIZE];
512 gchar info[DIR_NAME_SIZE];
513 gchar control[DIR_NAME_SIZE];
514 gchar cpu[DIR_NAME_SIZE];
515 gchar tmp[DIR_NAME_SIZE];
516 gchar abs_path[DIR_NAME_SIZE];
963b5f2d 517 gboolean has_slash = FALSE;
518
9f797243 519 get_absolute_pathname(pathname, abs_path);
963b5f2d 520 //establish the pathname to different directories
9f797243 521 if(abs_path[strlen(abs_path)-1] == '/')has_slash = TRUE;
522 strcpy(eventdefs,abs_path);
963b5f2d 523 if(!has_slash)strcat(eventdefs,"/");
524 strcat(eventdefs,"eventdefs/");
525
9f797243 526 strcpy(info,abs_path);
963b5f2d 527 if(!has_slash)strcat(info,"/");
528 strcat(info,"info/");
529
9f797243 530 strcpy(control,abs_path);
963b5f2d 531 if(!has_slash)strcat(control,"/");
532 strcat(control,"control/");
533
9f797243 534 strcpy(cpu,abs_path);
963b5f2d 535 if(!has_slash)strcat(cpu,"/");
536 strcat(cpu,"cpu/");
537
538 //new trace
963b5f2d 539 sys_description = g_new(LttSystemDescription, 1);
2a74fbf4 540 t = g_new(LttTrace, 1);
9f797243 541 t->pathname = g_strdup(abs_path);
963b5f2d 542 t->facility_number = 0;
543 t->control_tracefile_number = 0;
544 t->per_cpu_tracefile_number = 0;
545 t->system_description = sys_description;
546 t->control_tracefiles = g_ptr_array_new();
547 t->per_cpu_tracefiles = g_ptr_array_new();
548 t->facilities = g_ptr_array_new();
1a2ceb63 549 //getDataEndianType(&(t->my_arch_size), &(t->my_arch_endian));
550
963b5f2d 551 //get system description
552 strcpy(tmp,info);
553 strcat(tmp,"system.xml");
2a74fbf4 554 if(getSystemInfo(sys_description, tmp)) {
555 g_ptr_array_free(t->facilities, TRUE);
556 g_ptr_array_free(t->per_cpu_tracefiles, TRUE);
557 g_ptr_array_free(t->control_tracefiles, TRUE);
558 g_free(sys_description);
559 g_free(t->pathname);
560 g_free(t);
561 return NULL;
562 }
1a2ceb63 563
564 /* Set the reverse byte order between trace and reader */
565 if(sys_description->endian == LTT_LITTLE_ENDIAN
566 && G_BYTE_ORDER != G_LITTLE_ENDIAN) {
0f7f40c1 567 t->reverse_byte_order = 1;
1a2ceb63 568 } else if(sys_description->endian == LTT_BIG_ENDIAN
569 && G_BYTE_ORDER != G_BIG_ENDIAN) {
0f7f40c1 570 t->reverse_byte_order = 1;
571 } else t->reverse_byte_order = 0;
963b5f2d 572
b333a76b 573 //get facilities info
2a74fbf4 574 if(getFacilityInfo(t,eventdefs)) {
575 g_ptr_array_free(t->facilities, TRUE);
576 g_ptr_array_free(t->per_cpu_tracefiles, TRUE);
577 g_ptr_array_free(t->control_tracefiles, TRUE);
578 g_free(sys_description);
579 g_free(t->pathname);
580 g_free(t);
581 return NULL;
582 }
b333a76b 583
963b5f2d 584 //get control tracefile info
a00149f6 585 getControlFileInfo(t,control);
586 /*
2a74fbf4 587 if(getControlFileInfo(t,control)) {
588 g_ptr_array_free(t->facilities, TRUE);
589 g_ptr_array_free(t->per_cpu_tracefiles, TRUE);
590 g_ptr_array_free(t->control_tracefiles, TRUE);
591 g_free(sys_description);
592 g_free(t->pathname);
593 g_free(t);
594 return NULL;
a00149f6 595 }*/ // With fatal error
963b5f2d 596
597 //get cpu tracefile info
2a74fbf4 598 if(getCpuFileInfo(t,cpu)) {
599 g_ptr_array_free(t->facilities, TRUE);
600 g_ptr_array_free(t->per_cpu_tracefiles, TRUE);
601 g_ptr_array_free(t->control_tracefiles, TRUE);
602 g_free(sys_description);
603 g_free(t->pathname);
604 g_free(t);
605 return NULL;
606 }
963b5f2d 607
963b5f2d 608 return t;
6cd62ccf 609}
610
49bf71b5 611char * ltt_trace_name(LttTrace *t)
612{
613 return t->pathname;
614}
615
616
f7afe191 617/******************************************************************************
618 * When we copy a trace, we want all the opening actions to happen again :
619 * the trace will be reopened and totally independant from the original.
620 * That's why we call ltt_trace_open.
621 *****************************************************************************/
622LttTrace *ltt_trace_copy(LttTrace *self)
623{
624 return ltt_trace_open(self->pathname);
625}
626
963b5f2d 627void ltt_trace_close(LttTrace *t)
6cd62ccf 628{
8d1e6362 629 unsigned int i;
963b5f2d 630 LttTracefile * tf;
631 LttFacility * f;
632
633 g_free(t->pathname);
634
635 //free system_description
636 g_free(t->system_description->description);
637 g_free(t->system_description->node_name);
638 g_free(t->system_description->domain_name);
639 g_free(t->system_description->kernel_name);
640 g_free(t->system_description->kernel_release);
641 g_free(t->system_description->kernel_version);
642 g_free(t->system_description->machine);
643 g_free(t->system_description->processor);
644 g_free(t->system_description->hardware_platform);
645 g_free(t->system_description->operating_system);
646 g_free(t->system_description);
647
648 //free control_tracefiles
649 for(i=0;i<t->control_tracefile_number;i++){
650 tf = (LttTracefile*)g_ptr_array_index(t->control_tracefiles,i);
651 ltt_tracefile_close(tf);
652 }
09ad4797 653 g_ptr_array_free(t->control_tracefiles, TRUE);
963b5f2d 654
655 //free per_cpu_tracefiles
656 for(i=0;i<t->per_cpu_tracefile_number;i++){
657 tf = (LttTracefile*)g_ptr_array_index(t->per_cpu_tracefiles,i);
658 ltt_tracefile_close(tf);
659 }
09ad4797 660 g_ptr_array_free(t->per_cpu_tracefiles, TRUE);
963b5f2d 661
662 //free facilities
663 for(i=0;i<t->facility_number;i++){
664 f = (LttFacility*)g_ptr_array_index(t->facilities,i);
665 ltt_facility_close(f);
666 }
09ad4797 667 g_ptr_array_free(t->facilities, TRUE);
963b5f2d 668
669 g_free(t);
09ad4797 670
671 g_blow_chunks();
6cd62ccf 672}
673
963b5f2d 674
6cd62ccf 675/*****************************************************************************
963b5f2d 676 *Get the system description of the trace
6cd62ccf 677 ****************************************************************************/
678
963b5f2d 679LttSystemDescription *ltt_trace_system_description(LttTrace *t)
6cd62ccf 680{
963b5f2d 681 return t->system_description;
6cd62ccf 682}
683
684/*****************************************************************************
963b5f2d 685 * The following functions discover the facilities of the trace
6cd62ccf 686 ****************************************************************************/
687
963b5f2d 688unsigned ltt_trace_facility_number(LttTrace *t)
689{
690 return (unsigned)(t->facility_number);
691}
692
693LttFacility *ltt_trace_facility_get(LttTrace *t, unsigned i)
6cd62ccf 694{
963b5f2d 695 return (LttFacility*)g_ptr_array_index(t->facilities, i);
6cd62ccf 696}
697
698/*****************************************************************************
699 *Function name
963b5f2d 700 * ltt_trace_facility_find : find facilities in the trace
6cd62ccf 701 *Input params
963b5f2d 702 * t : the trace
703 * name : facility name
704 *Output params
705 * position : position of the facility in the trace
6cd62ccf 706 *Return value
963b5f2d 707 * : the number of facilities
6cd62ccf 708 ****************************************************************************/
709
963b5f2d 710unsigned ltt_trace_facility_find(LttTrace *t, char *name, unsigned *position)
6cd62ccf 711{
8d1e6362 712 unsigned int i, count=0;
963b5f2d 713 LttFacility * f;
8a3005f3 714 for(i=0;i<t->facility_number;i++){
963b5f2d 715 f = (LttFacility*)g_ptr_array_index(t->facilities, i);
716 if(strcmp(f->name,name)==0){
717 count++;
718 if(count==1) *position = i;
719 }else{
720 if(count) break;
721 }
722 }
723 return count;
6cd62ccf 724}
725
726/*****************************************************************************
963b5f2d 727 * Functions to discover all the event types in the trace
6cd62ccf 728 ****************************************************************************/
729
963b5f2d 730unsigned ltt_trace_eventtype_number(LttTrace *t)
6cd62ccf 731{
8d1e6362 732 unsigned int i;
963b5f2d 733 unsigned count = 0;
dc1cad90 734 unsigned int num = t->facility_number;
963b5f2d 735 LttFacility * f;
dc1cad90 736
737 for(i=0;i<num;i++){
963b5f2d 738 f = (LttFacility*)g_ptr_array_index(t->facilities, i);
739 count += f->event_number;
740 }
741 return count;
6cd62ccf 742}
743
155a7b0a 744/* FIXME : performances could be improved with a better design for this
6e8c19d4 745 * function : sequential search through a container has never been the
746 * best on the critical path. */
963b5f2d 747LttFacility * ltt_trace_facility_by_id(LttTrace * trace, unsigned id)
6cd62ccf 748{
cf74a6f1 749 LttFacility * facility = NULL;
8d1e6362 750 unsigned int i;
dc1cad90 751 unsigned int num = trace->facility_number;
752 GPtrArray *facilities = trace->facilities;
cf74a6f1 753
dc1cad90 754 for(i=0;unlikely(i<num);){
cf74a6f1 755 LttFacility *iter_facility =
dc1cad90 756 (LttFacility*) g_ptr_array_index(facilities,i);
757 unsigned base_id = iter_facility->base_id;
758
759 if(likely(id >= base_id &&
760 id < base_id + iter_facility->event_number)) {
cf74a6f1 761 facility = iter_facility;
963b5f2d 762 break;
dc1cad90 763 } else {
764 i++;
cf74a6f1 765 }
963b5f2d 766 }
dc1cad90 767
cf74a6f1 768 return facility;
6cd62ccf 769}
770
963b5f2d 771LttEventType *ltt_trace_eventtype_get(LttTrace *t, unsigned evId)
6cd62ccf 772{
6e8c19d4 773 LttEventType *event_type;
774
963b5f2d 775 LttFacility * f;
776 f = ltt_trace_facility_by_id(t,evId);
6e8c19d4 777
778 if(unlikely(!f)) event_type = NULL;
779 else event_type = f->events[evId - f->base_id];
780
781 return event_type;
6cd62ccf 782}
783
784/*****************************************************************************
963b5f2d 785 *There is one "per cpu" tracefile for each CPU, numbered from 0 to
786 *the maximum number of CPU in the system. When the number of CPU installed
787 *is less than the maximum, some positions are unused. There are also a
788 *number of "control" tracefiles (facilities, interrupts...).
6cd62ccf 789 ****************************************************************************/
963b5f2d 790unsigned ltt_trace_control_tracefile_number(LttTrace *t)
6cd62ccf 791{
963b5f2d 792 return t->control_tracefile_number;
6cd62ccf 793}
794
963b5f2d 795unsigned ltt_trace_per_cpu_tracefile_number(LttTrace *t)
6cd62ccf 796{
963b5f2d 797 return t->per_cpu_tracefile_number;
6cd62ccf 798}
799
800/*****************************************************************************
963b5f2d 801 *It is possible to search for the tracefiles by name or by CPU position.
802 *The index within the tracefiles of the same type is returned if found
803 *and a negative value otherwise.
6cd62ccf 804 ****************************************************************************/
805
8d1e6362 806int ltt_trace_control_tracefile_find(LttTrace *t, const gchar *name)
6cd62ccf 807{
963b5f2d 808 LttTracefile * tracefile;
8d1e6362 809 unsigned int i;
963b5f2d 810 for(i=0;i<t->control_tracefile_number;i++){
811 tracefile = (LttTracefile*)g_ptr_array_index(t->control_tracefiles, i);
812 if(strcmp(tracefile->name, name)==0)break;
813 }
814 if(i == t->control_tracefile_number) return -1;
815 return i;
6cd62ccf 816}
817
8d1e6362 818/* not really useful. We just have to know that cpu tracefiles
819 * comes before control tracefiles.
820 */
821int ltt_trace_per_cpu_tracefile_find(LttTrace *t, const gchar *name)
6cd62ccf 822{
963b5f2d 823 LttTracefile * tracefile;
8d1e6362 824 unsigned int i;
825 for(i=0;i<t->per_cpu_tracefile_number;i++){
826 tracefile = (LttTracefile*)g_ptr_array_index(t->per_cpu_tracefiles, i);
827 if(strcmp(tracefile->name, name)==0)break;
963b5f2d 828 }
8d1e6362 829 if(i == t->per_cpu_tracefile_number) return -1;
830 return i;
6cd62ccf 831}
832
833/*****************************************************************************
963b5f2d 834 *Get a specific tracefile
6cd62ccf 835 ****************************************************************************/
836
963b5f2d 837LttTracefile *ltt_trace_control_tracefile_get(LttTrace *t, unsigned i)
6cd62ccf 838{
5598cfe3 839 return (LttTracefile*)g_ptr_array_index(t->control_tracefiles, i);
963b5f2d 840}
841
842LttTracefile *ltt_trace_per_cpu_tracefile_get(LttTrace *t, unsigned i)
843{
844 return (LttTracefile*)g_ptr_array_index(t->per_cpu_tracefiles, i);
6cd62ccf 845}
846
487ad181 847/*****************************************************************************
848 * Get the start time and end time of the trace
849 ****************************************************************************/
850
851void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end)
852{
853 LttTime startSmall, startTmp, endBig, endTmp;
8d1e6362 854 unsigned int i, j=0;
487ad181 855 LttTracefile * tf;
856
857 for(i=0;i<t->control_tracefile_number;i++){
858 tf = g_ptr_array_index(t->control_tracefiles, i);
859 readBlock(tf,1);
01bb5763 860 startTmp = ltt_get_time(t->reverse_byte_order, &tf->a_block_start->time);
487ad181 861 readBlock(tf,tf->block_number);
01bb5763 862 endTmp = ltt_get_time(t->reverse_byte_order, &tf->a_block_end->time);
487ad181 863 if(i==0){
864 startSmall = startTmp;
865 endBig = endTmp;
866 j = 1;
867 continue;
868 }
308711e5 869 if(ltt_time_compare(startSmall,startTmp) > 0) startSmall = startTmp;
870 if(ltt_time_compare(endBig,endTmp) < 0) endBig = endTmp;
487ad181 871 }
872
873 for(i=0;i<t->per_cpu_tracefile_number;i++){
874 tf = g_ptr_array_index(t->per_cpu_tracefiles, i);
875 readBlock(tf,1);
01bb5763 876 startTmp = ltt_get_time(t->reverse_byte_order, &tf->a_block_start->time);
487ad181 877 readBlock(tf,tf->block_number);
01bb5763 878 endTmp = ltt_get_time(t->reverse_byte_order, &tf->a_block_end->time);
487ad181 879 if(j == 0 && i==0){
880 startSmall = startTmp;
881 endBig = endTmp;
882 continue;
883 }
308711e5 884 if(ltt_time_compare(startSmall,startTmp) > 0) startSmall = startTmp;
885 if(ltt_time_compare(endBig,endTmp) < 0) endBig = endTmp;
487ad181 886 }
887
c02ea99f 888 if(start != NULL) *start = startSmall;
889 if(end != NULL) *end = endBig;
487ad181 890}
891
892
6cd62ccf 893/*****************************************************************************
963b5f2d 894 *Get the name of a tracefile
6cd62ccf 895 ****************************************************************************/
896
963b5f2d 897char *ltt_tracefile_name(LttTracefile *tf)
6cd62ccf 898{
963b5f2d 899 return tf->name;
6cd62ccf 900}
901
80da81ad 902/*****************************************************************************
903 * Get the number of blocks in the tracefile
904 ****************************************************************************/
905
906unsigned ltt_tracefile_block_number(LttTracefile *tf)
907{
908 return tf->block_number;
909}
910
6cd62ccf 911/*****************************************************************************
912 *Function name
913 * ltt_tracefile_seek_time: seek to the first event of the trace with time
914 * larger or equal to time
915 *Input params
916 * t : tracefile
917 * time : criteria of the time
6cd62ccf 918 ****************************************************************************/
caf7a67a 919void ltt_tracefile_find_time_block(LttTracefile *t, LttTime time,
920 int start_block, int end_block)
921{
922 int err, tmp_block, s, e;
923 int headTime;
924 int tailTime;
925
926 err=readBlock(t,start_block);
927 if(err) g_error("Can not read tracefile: %s\n", t->name);
928 if(start_block == end_block)return;
929
01bb5763 930 tailTime = ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
931 &t->a_block_end->time), time);
caf7a67a 932 if(tailTime >= 0) return;
933
934 err=readBlock(t,end_block);
935 if(err) g_error("Can not read tracefile: %s\n", t->name);
936 if(start_block+1 == end_block)return;
937
01bb5763 938 headTime = ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
939 &t->a_block_start->time), time);
caf7a67a 940 if(headTime <= 0 ) return;
941
942 tmp_block = (end_block + start_block)/2;
943 err=readBlock(t,tmp_block);
944 if(err) g_error("Can not read tracefile: %s\n", t->name);
945
01bb5763 946 headTime = ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
947 &t->a_block_start->time), time);
948 tailTime = ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
949 &t->a_block_end->time), time);
caf7a67a 950 if(headTime <= 0 && tailTime >= 0) return;
951
952 if(headTime > 0){
953 s = start_block + 1;
954 e = tmp_block - 1;
955 if(s <= e)
956 ltt_tracefile_find_time_block(t, time, s, e);
957 else return;
958 }
959
960 if(tailTime < 0){
961 s = tmp_block + 1;
962 e = end_block - 1;
963 if(s <= e)
964 ltt_tracefile_find_time_block(t, time, s, e);
965 else return;
966 }
967}
968
969void ltt_tracefile_backward_find_time_block(LttTracefile *t, LttTime time)
970{
971 int t_time, h_time, err;
972 err=readBlock(t,t->which_block-1);
973 if(err) g_error("Can not read tracefile: %s\n", t->name);
01bb5763 974 h_time = ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
975 &t->a_block_start->time), time);
976 t_time = ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
977 &t->a_block_end->time), time);
caf7a67a 978 if(h_time == 0){
979 int tmp;
980 if(t->which_block == 1) return;
981 err=readBlock(t,t->which_block-1);
982 if(err) g_error("Can not read tracefile: %s\n", t->name);
01bb5763 983 tmp = ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
984 &t->a_block_end->time), time);
caf7a67a 985 if(tmp == 0) return ltt_tracefile_seek_time(t, time);
986 err=readBlock(t,t->which_block+1);
987 if(err) g_error("Can not read tracefile: %s\n", t->name);
988 }else if(h_time > 0){
989 ltt_tracefile_find_time_block(t, time, 1, t->which_block);
990 return ltt_tracefile_seek_time(t, time) ;
991 }else{
992 if(t_time >= 0) return ltt_tracefile_seek_time(t, time);
993 err=readBlock(t,t->which_block+1);
994 if(err) g_error("Can not read tracefile: %s\n", t->name);
995 }
996}
6cd62ccf 997
963b5f2d 998void ltt_tracefile_seek_time(LttTracefile *t, LttTime time)
6cd62ccf 999{
1000 int err;
963b5f2d 1001 LttTime lttTime;
01bb5763 1002 int headTime = ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
1003 &t->a_block_start->time), time);
1004 int tailTime = ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
1005 &t->a_block_end->time), time);
c02ea99f 1006 LttEvent ev;
62e55dd6 1007
6cd62ccf 1008 if(headTime < 0 && tailTime > 0){
01bb5763 1009 if(ltt_time_compare(ltt_get_time(t->trace->reverse_byte_order,
1010 &t->a_block_end->time),
1011 t->current_event_time) !=0) {
db55eaae 1012 lttTime = getEventTime(t);
308711e5 1013 err = ltt_time_compare(lttTime, time);
db55eaae 1014 if(err > 0){
8d1e6362 1015 if(t->which_event==2 || ltt_time_compare(t->prev_event_time,time)<0){
1a3b8cbd 1016 return;
db55eaae 1017 }else{
1018 updateTracefile(t);
1019 return ltt_tracefile_seek_time(t, time);
1a3b8cbd 1020 }
db55eaae 1021 }else if(err < 0){
1022 while(1){
c02ea99f 1023 if(ltt_tracefile_read(t,&ev) == NULL) {
db55eaae 1024 g_print("End of file\n");
1025 return;
1026 }
1027 lttTime = getEventTime(t);
308711e5 1028 err = ltt_time_compare(lttTime, time);
db55eaae 1029 if(err >= 0)return;
1030 }
1031 }else return;
1032 }else{//we are at the end of the block
1033 updateTracefile(t);
1034 return ltt_tracefile_seek_time(t, time);
1035 }
e37c1372 1036 }else if(headTime >= 0){
6cd62ccf 1037 if(t->which_block == 1){
1038 updateTracefile(t);
1039 }else{
1ee6a9af 1040 if(ltt_time_compare(t->prev_block_end_time, time) >= 0 ||
1041 (t->prev_block_end_time.tv_sec == 0 &&
1042 t->prev_block_end_time.tv_nsec == 0 )){
caf7a67a 1043 ltt_tracefile_backward_find_time_block(t, time);
6cd62ccf 1044 }else{
1045 updateTracefile(t);
1046 }
1047 }
40331ba8 1048 }else if(tailTime < 0){
6cd62ccf 1049 if(t->which_block != t->block_number){
caf7a67a 1050 ltt_tracefile_find_time_block(t, time, t->which_block+1, t->block_number);
1051 return ltt_tracefile_seek_time(t, time);
963b5f2d 1052 }else {
a8c0f09d 1053 t->cur_event_pos = t->buffer + t->block_size;
1054 g_print("End of file\n");
963b5f2d 1055 return;
1056 }
40331ba8 1057 }else if(tailTime == 0){
e37c1372 1058 t->cur_event_pos = t->last_event_pos;
62e55dd6 1059 t->current_event_time = time;
1060 t->cur_heart_beat_number = 0;
1061 t->prev_event_time.tv_sec = 0;
1062 t->prev_event_time.tv_nsec = 0;
40331ba8 1063 return;
6cd62ccf 1064 }
6cd62ccf 1065}
1066
80da81ad 1067/*****************************************************************************
1068 * Seek to the first event with position equal or larger to ep
18206708 1069 *
1070 * Modified by Mathieu Desnoyers to used faster offset position instead of
1071 * re-reading the whole buffer.
80da81ad 1072 ****************************************************************************/
1073
04b44e05 1074void ltt_tracefile_seek_position(LttTracefile *t, const LttEventPosition *ep)
80da81ad 1075{
1076 //if we are at the right place, just return
155a7b0a 1077 if(likely(t->which_block == ep->block_num && t->which_event == ep->event_num))
80da81ad 1078 return;
1079
155a7b0a 1080 if(likely(t->which_block == ep->block_num)) updateTracefile(t);
80da81ad 1081 else readBlock(t,ep->block_num);
18206708 1082 //event offset is available
155a7b0a 1083 if(likely(ep->old_position)){
18206708 1084 int err;
1085
1086 t->which_event = ep->event_num;
80da81ad 1087 t->cur_event_pos = t->buffer + ep->event_offset;
18206708 1088 t->prev_event_time = ep->event_time;
1089 t->current_event_time = ep->event_time;
1090 t->cur_heart_beat_number = ep->heart_beat_number;
1091 t->cur_cycle_count = ep->event_cycle_count;
1092
1093 /* This is a workaround for fast position seek */
1094 t->last_event_pos = ep->last_event_pos;
1095 t->prev_block_end_time = ep->prev_block_end_time;
1096 t->prev_event_time = ep->prev_event_time;
1097 t->pre_cycle_count = ep->pre_cycle_count;
1098 t->count = ep->count;
2dee981d 1099 t->overflow_nsec = ep->overflow_nsec;
dfb73233 1100 t->last_heartbeat = ep->last_heartbeat;
18206708 1101 /* end of workaround */
1102
1103 //update the fields of the current event and go to the next event
1104 err = skipEvent(t);
155a7b0a 1105 if(unlikely(err == ERANGE)) g_error("event id is out of range\n");
18206708 1106
80da81ad 1107 return;
1108 }
1109
18206708 1110 //only block number and event index are available
1111 //MD: warning : this is slow!
1112 g_warning("using slow O(n) tracefile seek position");
1113
c02ea99f 1114 LttEvent event;
155a7b0a 1115 while(likely(t->which_event < ep->event_num)) ltt_tracefile_read(t, &event);
80da81ad 1116
1117 return;
1118}
1119
6cd62ccf 1120/*****************************************************************************
1121 *Function name
40331ba8 1122 * ltt_tracefile_read : read the current event, set the pointer to the next
6cd62ccf 1123 *Input params
1124 * t : tracefile
1125 *Return value
963b5f2d 1126 * LttEvent * : an event to be processed
6cd62ccf 1127 ****************************************************************************/
1128
c02ea99f 1129LttEvent *ltt_tracefile_read(LttTracefile *t, LttEvent *event)
6cd62ccf 1130{
963b5f2d 1131 int err;
6cd62ccf 1132
155a7b0a 1133 if(unlikely(t->cur_event_pos == t->buffer + t->block_size)){
1134 if(unlikely(t->which_block == t->block_number)){
bdc36259 1135 return NULL;
1136 }
1137 err = readBlock(t, t->which_block + 1);
155a7b0a 1138 if(unlikely(err))g_error("Can not read tracefile");
bdc36259 1139 }
1140
0f7f40c1 1141 event->event_id = ltt_get_uint16(t->trace->reverse_byte_order, t->cur_event_pos);
155a7b0a 1142 if(unlikely(event->event_id == TRACE_TIME_HEARTBEAT))
963b5f2d 1143 t->cur_heart_beat_number++;
6cd62ccf 1144
40331ba8 1145 t->prev_event_time = t->current_event_time;
62e55dd6 1146 // t->current_event_time = getEventTime(t);
6cd62ccf 1147
0f7f40c1 1148 event->time_delta = ltt_get_uint32(t->trace->reverse_byte_order, t->cur_event_pos + EVENT_ID_SIZE);
c02ea99f 1149 event->event_time = t->current_event_time;
1150 event->event_cycle_count = t->cur_cycle_count;
963b5f2d 1151
c02ea99f 1152 event->tracefile = t;
1a2ceb63 1153 event->data = t->cur_event_pos + EVENT_HEADER_SIZE;
c02ea99f 1154 event->which_block = t->which_block;
1155 event->which_event = t->which_event;
6cd62ccf 1156
18206708 1157 /* This is a workaround for fast position seek */
c02ea99f 1158 event->last_event_pos = t->last_event_pos;
1159 event->prev_block_end_time = t->prev_block_end_time;
1160 event->prev_event_time = t->prev_event_time;
1161 event->pre_cycle_count = t->pre_cycle_count;
1162 event->count = t->count;
2dee981d 1163 event->overflow_nsec = t->overflow_nsec;
dfb73233 1164 event->last_heartbeat = t->last_heartbeat;
2dee981d 1165
18206708 1166 /* end of workaround */
1167
1168
1169
40331ba8 1170 //update the fields of the current event and go to the next event
1171 err = skipEvent(t);
155a7b0a 1172 if(unlikely(err == ERANGE)) g_error("event id is out of range\n");
40331ba8 1173
c02ea99f 1174 return event;
6cd62ccf 1175}
1176
1177/****************************************************************************
1178 *Function name
1179 * readFile : wrap function to read from a file
1180 *Input Params
1181 * fd : file descriptor
1182 * buf : buf to contain the content
1183 * size : number of bytes to be read
1184 * mesg : message to be printed if some thing goes wrong
1185 *return value
1186 * 0 : success
1187 * EIO : can not read from the file
1188 ****************************************************************************/
1189
1190int readFile(int fd, void * buf, size_t size, char * mesg)
1191{
8d1e6362 1192 ssize_t nbBytes = read(fd, buf, size);
1193
1194 if((size_t)nbBytes != size) {
1195 if(nbBytes < 0) {
1196 perror("Error in readFile : ");
1197 } else {
1198 g_warning("%s",mesg);
1199 }
6cd62ccf 1200 return EIO;
1201 }
1202 return 0;
1203}
1204
507915ee 1205
6cd62ccf 1206/****************************************************************************
1207 *Function name
1208 * readBlock : read a block from the file
1209 *Input Params
1210 * lttdes : ltt trace file
1211 * whichBlock : the block which will be read
1212 *return value
1213 * 0 : success
1214 * EINVAL : lseek fail
1215 * EIO : can not read from the file
1216 ****************************************************************************/
1217
963b5f2d 1218int readBlock(LttTracefile * tf, int whichBlock)
6cd62ccf 1219{
1220 off_t nbBytes;
cbd41522 1221 guint32 lostSize;
6cd62ccf 1222
ac849774 1223 /* same block already opened requested */
1224 if((guint)whichBlock == tf->which_block) return 0;
1225
155a7b0a 1226 if(likely(whichBlock - tf->which_block == 1 && tf->which_block != 0)){
01bb5763 1227 tf->prev_block_end_time = ltt_get_time(tf->trace->reverse_byte_order,
1228 &tf->a_block_end->time);
1229 tf->prev_event_time = ltt_get_time(tf->trace->reverse_byte_order,
1230 &tf->a_block_end->time);
6cd62ccf 1231 }else{
1232 tf->prev_block_end_time.tv_sec = 0;
1233 tf->prev_block_end_time.tv_nsec = 0;
40331ba8 1234 tf->prev_event_time.tv_sec = 0;
1235 tf->prev_event_time.tv_nsec = 0;
6cd62ccf 1236 }
6cd62ccf 1237
963b5f2d 1238 nbBytes=lseek(tf->fd,(off_t)((whichBlock-1)*tf->block_size), SEEK_SET);
155a7b0a 1239 if(unlikely(nbBytes == -1)) return EINVAL;
6cd62ccf 1240
155a7b0a 1241 if(unlikely(readFile(tf->fd,tf->buffer,tf->block_size,"Unable to read a block")))
963b5f2d 1242 return EIO;
6cd62ccf 1243
963b5f2d 1244 tf->a_block_start=(BlockStart *) (tf->buffer + EVENT_HEADER_SIZE);
cbd41522 1245 lostSize = *(guint32 *)(tf->buffer + tf->block_size - sizeof(guint32));
63c35f6c 1246 tf->a_block_end=(BlockEnd *)(tf->buffer + tf->block_size
1247 - sizeof(guint32) - lostSize - sizeof(BlockEnd));
1248 tf->last_event_pos = tf->buffer + tf->block_size -
1249 sizeof(guint32) - lostSize
1250 - sizeof(BlockEnd) - EVENT_HEADER_SIZE;
6cd62ccf 1251
6cd62ccf 1252 tf->which_block = whichBlock;
963b5f2d 1253 tf->which_event = 1;
40331ba8 1254 tf->cur_event_pos = tf->buffer;//the beginning of the block, block start ev
6cd62ccf 1255 tf->cur_heart_beat_number = 0;
dfb73233 1256 tf->last_heartbeat = NULL;
507915ee 1257
1258 /* read the whole block to precalculate total of cycles in it */
1259 tf->count = 0;
1260 tf->pre_cycle_count = 0;
0f7f40c1 1261 tf->cur_cycle_count = ltt_get_uint32(tf->trace->reverse_byte_order, tf->cur_event_pos + EVENT_ID_SIZE);
39ae3eed 1262
6cd62ccf 1263 getCyclePerNsec(tf);
2dee981d 1264
21ff84a0 1265 tf->overflow_nsec =
1a2ceb63 1266 (-((double)
01bb5763 1267 (ltt_get_uint64(tf->trace->reverse_byte_order,
0f7f40c1 1268 &tf->a_block_start->cycle_count)&0xFFFFFFFF))
21ff84a0 1269 * tf->nsec_per_cycle);
6cd62ccf 1270
62e55dd6 1271 tf->current_event_time = getEventTime(tf);
40331ba8 1272
6cd62ccf 1273 return 0;
1274}
1275
1276/*****************************************************************************
1277 *Function name
1278 * updateTracefile : reinitialize the info of the block which is already
1279 * in the buffer
1280 *Input params
1281 * tf : tracefile
1282 ****************************************************************************/
1283
963b5f2d 1284void updateTracefile(LttTracefile * tf)
6cd62ccf 1285{
963b5f2d 1286 tf->which_event = 1;
40331ba8 1287 tf->cur_event_pos = tf->buffer;
62e55dd6 1288 tf->current_event_time = getEventTime(tf);
6cd62ccf 1289 tf->cur_heart_beat_number = 0;
1290
1291 tf->prev_event_time.tv_sec = 0;
1292 tf->prev_event_time.tv_nsec = 0;
2dee981d 1293 tf->count = 0;
1294
1a2ceb63 1295 tf->overflow_nsec =
01bb5763 1296 (-((double)ltt_get_uint64(tf->trace->reverse_byte_order,
0f7f40c1 1297 &tf->a_block_start->cycle_count))
21ff84a0 1298 * tf->nsec_per_cycle);
2dee981d 1299
6cd62ccf 1300}
1301
1302/*****************************************************************************
1303 *Function name
1304 * skipEvent : go to the next event, update the fields of the current event
1305 *Input params
1306 * t : tracefile
1307 *return value
1308 * 0 : success
6cd62ccf 1309 * ERANGE : event id is out of range
1310 ****************************************************************************/
1311
963b5f2d 1312int skipEvent(LttTracefile * t)
6cd62ccf 1313{
8d1e6362 1314 int evId;
6cd62ccf 1315 void * evData;
963b5f2d 1316 LttEventType * evT;
1317 LttField * rootFld;
6cd62ccf 1318
0f7f40c1 1319 evId = ltt_get_uint16(t->trace->reverse_byte_order, t->cur_event_pos);
6cd62ccf 1320 evData = t->cur_event_pos + EVENT_HEADER_SIZE;
6cd62ccf 1321
908f42fa 1322 evT = ltt_trace_eventtype_get(t->trace,(unsigned)evId);
47a166fc 1323
1d1df11d 1324 if(likely(evT)) rootFld = evT->root_field;
908f42fa 1325 else return ERANGE;
6cd62ccf 1326
1d1df11d 1327 if(likely(rootFld)){
908f42fa 1328 //event has string/sequence or the last event is not the same event
1d1df11d 1329 if(likely((evT->latest_block!=t->which_block || evT->latest_event!=t->which_event)
1330 && rootFld->field_fixed == 0)){
908f42fa 1331 setFieldsOffset(t, evT, evData, t->trace);
47a166fc 1332 }
908f42fa 1333 t->cur_event_pos += EVENT_HEADER_SIZE + rootFld->field_size;
1334 }else t->cur_event_pos += EVENT_HEADER_SIZE;
1335
1336 evT->latest_block = t->which_block;
1337 evT->latest_event = t->which_event;
1338
6cd62ccf 1339 //the next event is in the next block
1d1df11d 1340 if(unlikely(evId == TRACE_BLOCK_END)){
bdc36259 1341 t->cur_event_pos = t->buffer + t->block_size;
6cd62ccf 1342 }else{
0f7f40c1 1343 t->cur_cycle_count = ltt_get_uint32(t->trace->reverse_byte_order,
1344 t->cur_event_pos + EVENT_ID_SIZE);
6cd62ccf 1345 t->which_event++;
62e55dd6 1346 t->current_event_time = getEventTime(t);
6cd62ccf 1347 }
1348
1349 return 0;
1350}
1351
18206708 1352
6cd62ccf 1353/*****************************************************************************
1354 *Function name
1355 * getCyclePerNsec : calculate cycles per nsec for current block
507915ee 1356 * MD: should have tracefile_read the whole block, so we know the
1357 * total of cycles in it before being called.
6cd62ccf 1358 *Input Params
1359 * t : tracefile
1360 ****************************************************************************/
1361
963b5f2d 1362void getCyclePerNsec(LttTracefile * t)
6cd62ccf 1363{
963b5f2d 1364 LttTime lBufTotalTime; /* Total time for this buffer */
887208b7 1365 double lBufTotalNSec; /* Total time for this buffer in nsecs */
8ee1c3d5 1366 LttCycleCount lBufTotalCycle;/* Total cycles for this buffer */
6cd62ccf 1367
1368 /* Calculate the total time for this buffer */
01bb5763 1369 lBufTotalTime = ltt_time_sub(
1370 ltt_get_time(t->trace->reverse_byte_order, &t->a_block_end->time),
1371 ltt_get_time(t->trace->reverse_byte_order, &t->a_block_start->time));
6cd62ccf 1372
1373 /* Calculate the total cycles for this bufffer */
01bb5763 1374 lBufTotalCycle = ltt_get_uint64(t->trace->reverse_byte_order,
0f7f40c1 1375 &t->a_block_end->cycle_count);
01bb5763 1376 lBufTotalCycle -= ltt_get_uint64(t->trace->reverse_byte_order,
0f7f40c1 1377 &t->a_block_start->cycle_count);
6cd62ccf 1378
8ee1c3d5 1379 /* Convert the total time to double */
887208b7 1380 lBufTotalNSec = ltt_time_to_double(lBufTotalTime);
6cd62ccf 1381
887208b7 1382 t->nsec_per_cycle = (double)lBufTotalNSec / (double)lBufTotalCycle;
8ee1c3d5 1383
2dee981d 1384 /* Pre-multiply one overflow (2^32 cycles) by nsec_per_cycle */
21ff84a0 1385 t->one_overflow_nsec = t->nsec_per_cycle * (double)0x100000000ULL;
2dee981d 1386
6cd62ccf 1387}
1388
1389/****************************************************************************
1390 *Function name
1391 * getEventTime : obtain the time of an event
887208b7 1392 * NOTE : this function _really_ is on critical path.
6cd62ccf 1393 *Input params
1394 * tf : tracefile
1395 *Return value
963b5f2d 1396 * LttTime : the time of the event
6cd62ccf 1397 ****************************************************************************/
1398
8959a0c8 1399static inline LttTime getEventTime(LttTracefile * tf)
6cd62ccf 1400{
963b5f2d 1401 LttTime time;
1402 LttCycleCount cycle_count; // cycle count for the current event
2dee981d 1403 //LttCycleCount lEventTotalCycle; // Total cycles from start for event
1404 gint64 lEventNSec; // Total nsecs from start for event
963b5f2d 1405 LttTime lTimeOffset; // Time offset in struct LttTime
cbd41522 1406 guint16 evId;
e4eced0f 1407
0f7f40c1 1408 evId = ltt_get_uint16(tf->trace->reverse_byte_order,
1409 tf->cur_event_pos);
ac849774 1410
0f7f40c1 1411 cycle_count = ltt_get_uint32(tf->trace->reverse_byte_order,
1412 tf->cur_event_pos + EVENT_ID_SIZE);
e4eced0f 1413
dfb73233 1414 gboolean comp_count = cycle_count < tf->pre_cycle_count;
bbf28e50 1415
dfb73233 1416 tf->pre_cycle_count = cycle_count;
1417
1418 if(unlikely(comp_count)) {
bbf28e50 1419 /* Overflow */
dfb73233 1420 tf->overflow_nsec += tf->one_overflow_nsec;
1421 tf->count++; //increment overflow count
1422 }
1423
1424 if(unlikely(evId == TRACE_BLOCK_START)) {
1425 lEventNSec = 0;
1426 } else if(unlikely(evId == TRACE_BLOCK_END)) {
21ff84a0 1427 lEventNSec = ((double)
01bb5763 1428 (ltt_get_uint64(tf->trace->reverse_byte_order,
0f7f40c1 1429 &tf->a_block_end->cycle_count)
01bb5763 1430 - ltt_get_uint64(tf->trace->reverse_byte_order,
0f7f40c1 1431 &tf->a_block_start->cycle_count))
21ff84a0 1432 * tf->nsec_per_cycle);
dfb73233 1433 }
dfb73233 1434#if 0
bbf28e50 1435 /* If you want to make heart beat a special case and use their own 64 bits
1436 * TSC, activate this.
1437 */
dfb73233 1438 else if(unlikely(evId == TRACE_TIME_HEARTBEAT)) {
1439
1440 tf->last_heartbeat = (TimeHeartbeat*)(tf->cur_event_pos+EVENT_HEADER_SIZE);
1441 lEventNSec = ((double)(tf->last_heartbeat->cycle_count
1442 - tf->a_block_start->cycle_count)
1443 * tf->nsec_per_cycle);
1444 }
1445#endif //0
1446 else {
21ff84a0 1447 lEventNSec = (gint64)((double)cycle_count * tf->nsec_per_cycle)
dfb73233 1448 +tf->overflow_nsec;
1449 }
1450
2dee981d 1451 lTimeOffset = ltt_time_from_uint64(lEventNSec);
1452
01bb5763 1453 time = ltt_time_add(ltt_get_time(tf->trace->reverse_byte_order,
1454 &tf->a_block_start->time), lTimeOffset);
e4eced0f 1455
6cd62ccf 1456 return time;
1457}
1458
1459/*****************************************************************************
1460 *Function name
1461 * setFieldsOffset : set offset of the fields
1462 *Input params
1463 * tracefile : opened trace file
1464 * evT : the event type
1465 * evD : event data, it may be NULL
1466 ****************************************************************************/
1467
40331ba8 1468void setFieldsOffset(LttTracefile *tf,LttEventType *evT,void *evD,LttTrace* t)
6cd62ccf 1469{
963b5f2d 1470 LttField * rootFld = evT->root_field;
6cd62ccf 1471 // rootFld->base_address = evD;
1472
1d1df11d 1473 if(likely(rootFld))
8710c6c7 1474 rootFld->field_size = getFieldtypeSize(tf, evT, 0,0,rootFld, evD,t);
6cd62ccf 1475}
1476
1477/*****************************************************************************
1478 *Function name
1479 * getFieldtypeSize: get the size of the field type (primitive type)
1480 *Input params
1481 * tracefile : opened trace file
1482 * evT : event type
1483 * offsetRoot : offset from the root
1484 * offsetParent : offset from the parrent
1485 * fld : field
1486 * evD : event data, it may be NULL
1487 *Return value
1488 * int : size of the field
1489 ****************************************************************************/
1490
21182d4a 1491static inline gint getFieldtypeSize(LttTracefile * t,
1492 LttEventType * evT, gint offsetRoot,
1493 gint offsetParent, LttField * fld, void *evD, LttTrace *trace)
6cd62ccf 1494{
21182d4a 1495 gint size, size1, element_number, i, offset1, offset2;
963b5f2d 1496 LttType * type = fld->field_type;
6cd62ccf 1497
21182d4a 1498 if(unlikely(t && evT->latest_block==t->which_block &&
1499 evT->latest_event==t->which_event)){
1500 size = fld->field_size;
1501 goto end_getFieldtypeSize;
a0d63196 1502 } else {
1503 /* This likely has been tested with gcov : half of them.. */
1504 if(unlikely(fld->field_fixed == 1)){
1505 /* tested : none */
1506 if(unlikely(fld == evT->root_field)) {
1507 size = fld->field_size;
1508 goto end_getFieldtypeSize;
1509 }
21182d4a 1510 }
6cd62ccf 1511
a0d63196 1512 /* From gcov profiling : half string, half struct, can we gain something
1513 * from that ? (Mathieu) */
1514 switch(type->type_class) {
1515 case LTT_ARRAY:
1516 element_number = (int) type->element_number;
1517 if(fld->field_fixed == -1){
1518 size = getFieldtypeSize(t, evT, offsetRoot,
1519 0,fld->child[0], NULL, trace);
1520 if(size == 0){ //has string or sequence
1521 fld->field_fixed = 0;
1522 }else{
1523 fld->field_fixed = 1;
1524 size *= element_number;
1525 }
1526 }else if(fld->field_fixed == 0){// has string or sequence
1527 size = 0;
1528 for(i=0;i<element_number;i++){
1529 size += getFieldtypeSize(t, evT, offsetRoot+size,size,
1530 fld->child[0], evD+size, trace);
1531 }
1532 }else size = fld->field_size;
1533 if(unlikely(!evD)){
1534 fld->fixed_root = (offsetRoot==-1) ? 0 : 1;
1535 fld->fixed_parent = (offsetParent==-1) ? 0 : 1;
1536 }
1537
1538 break;
1539
1540 case LTT_SEQUENCE:
1541 size1 = (int) ltt_type_size(trace, type);
1542 if(fld->field_fixed == -1){
1543 fld->sequ_number_size = size1;
cf74a6f1 1544 fld->field_fixed = 0;
a0d63196 1545 size = getFieldtypeSize(t, evT, offsetRoot,
1546 0,fld->child[0], NULL, trace);
1547 fld->element_size = size;
1548 }else{//0: sequence
0f7f40c1 1549 element_number = getIntNumber(t->trace->reverse_byte_order,size1,evD);
a0d63196 1550 type->element_number = element_number;
1551 if(fld->element_size > 0){
1552 size = element_number * fld->element_size;
1553 }else{//sequence has string or sequence
1554 size = 0;
1555 for(i=0;i<element_number;i++){
1556 size += getFieldtypeSize(t, evT, offsetRoot+size+size1,size+size1,
1557 fld->child[0], evD+size+size1, trace);
1558 }
1559 }
1560 size += size1;
cf74a6f1 1561 }
a0d63196 1562 if(unlikely(!evD)){
1563 fld->fixed_root = (offsetRoot==-1) ? 0 : 1;
1564 fld->fixed_parent = (offsetParent==-1) ? 0 : 1;
1565 }
1566
1567 break;
1568
1569 case LTT_STRING:
cf74a6f1 1570 size = 0;
a0d63196 1571 if(fld->field_fixed == -1){
1572 fld->field_fixed = 0;
1573 }else{//0: string
1574 /* Hope my implementation is faster than strlen (Mathieu) */
1575 char *ptr=(char*)evD;
1576 size = 1;
1577 /* from gcov : many many strings are empty, make it the common case.*/
1578 while(unlikely(*ptr != '\0')) { size++; ptr++; }
1579 //size = ptr - (char*)evD + 1; //include end : '\0'
cf74a6f1 1580 }
a0d63196 1581 fld->fixed_root = (offsetRoot==-1) ? 0 : 1;
1582 fld->fixed_parent = (offsetParent==-1) ? 0 : 1;
cf74a6f1 1583
a0d63196 1584 break;
1585
1586 case LTT_STRUCT:
1587 element_number = (int) type->element_number;
1588 size = 0;
1589 /* tested with gcov */
1590 if(unlikely(fld->field_fixed == -1)){
1591 offset1 = offsetRoot;
1592 offset2 = 0;
cf74a6f1 1593 for(i=0;i<element_number;i++){
a0d63196 1594 size1=getFieldtypeSize(t, evT,offset1,offset2,
1595 fld->child[i], NULL, trace);
1596 if(likely(size1 > 0 && size >= 0)){
1597 size += size1;
1598 if(likely(offset1 >= 0)) offset1 += size1;
1599 offset2 += size1;
1600 }else{
1601 size = -1;
1602 offset1 = -1;
1603 offset2 = -1;
1604 }
cf74a6f1 1605 }
a0d63196 1606 if(unlikely(size == -1)){
1607 fld->field_fixed = 0;
1608 size = 0;
1609 }else fld->field_fixed = 1;
1610 }else if(likely(fld->field_fixed == 0)){
1611 offset1 = offsetRoot;
1612 offset2 = 0;
1613 for(i=0;unlikely(i<element_number);i++){
1614 size=getFieldtypeSize(t,evT,offset1,offset2,
1615 fld->child[i],evD+offset2, trace);
1616 offset1 += size;
1617 offset2 += size;
1618 }
1619 size = offset2;
1620 }else size = fld->field_size;
d37b2aaa 1621 fld->fixed_root = (offsetRoot==-1) ? 0 : 1;
1622 fld->fixed_parent = (offsetParent==-1) ? 0 : 1;
a0d63196 1623 break;
cf74a6f1 1624
a0d63196 1625 default:
1626 if(unlikely(fld->field_fixed == -1)){
1627 size = (int) ltt_type_size(trace, type);
1628 fld->field_fixed = 1;
1629 }else size = fld->field_size;
1630 if(unlikely(!evD)){
1631 fld->fixed_root = (offsetRoot==-1) ? 0 : 1;
1632 fld->fixed_parent = (offsetParent==-1) ? 0 : 1;
1633 }
1634 break;
1635 }
cf74a6f1 1636 }
1637
6cd62ccf 1638 fld->offset_root = offsetRoot;
1639 fld->offset_parent = offsetParent;
6cd62ccf 1640 fld->field_size = size;
1641
21182d4a 1642end_getFieldtypeSize:
1643
6cd62ccf 1644 return size;
1645}
1646
6cd62ccf 1647
1648/*****************************************************************************
1649 *Function name
1650 * getIntNumber : get an integer number
1651 *Input params
1652 * size : the size of the integer
1653 * evD : the event data
1654 *Return value
cf74a6f1 1655 * gint64 : a 64 bits integer
6cd62ccf 1656 ****************************************************************************/
1657
0f7f40c1 1658gint64 getIntNumber(gboolean reverse_byte_order, int size, void *evD)
6cd62ccf 1659{
cbd41522 1660 gint64 i;
cf74a6f1 1661
1662 switch(size) {
1a2ceb63 1663 case 1: i = *((gint8*)evD); break;
0f7f40c1 1664 case 2: i = ltt_get_int16(reverse_byte_order, evD); break;
1665 case 4: i = ltt_get_int32(reverse_byte_order, evD); break;
1666 case 8: i = ltt_get_int64(reverse_byte_order, evD); break;
1667 default: i = ltt_get_int64(reverse_byte_order, evD);
cf74a6f1 1668 g_critical("getIntNumber : integer size %d unknown", size);
1669 break;
1670 }
1671
1a2ceb63 1672 return i;
6cd62ccf 1673}
0f7f40c1 1674#if 0
6cd62ccf 1675/*****************************************************************************
1676 *Function name
1677 * getDataEndianType : get the data type size and endian type of the local
1678 * machine
1679 *Input params
1680 * size : size of data type
1681 * endian : endian type, little or big
1682 ****************************************************************************/
1683
963b5f2d 1684void getDataEndianType(LttArchSize * size, LttArchEndian * endian)
6cd62ccf 1685{
1686 int i = 1;
1687 char c = (char) i;
1688 int sizeInt=sizeof(int), sizeLong=sizeof(long), sizePointer=sizeof(void *);
1689
1690 if(c == 1) *endian = LTT_LITTLE_ENDIAN;
1691 else *endian = LTT_BIG_ENDIAN;
1692
1693 if(sizeInt == 2 && sizeLong == 4 && sizePointer == 4)
1694 *size = LTT_LP32;
1695 else if(sizeInt == 4 && sizeLong == 4 && sizePointer == 4)
1696 *size = LTT_ILP32;
1697 else if(sizeInt == 4 && sizeLong == 8 && sizePointer == 8)
1698 *size = LTT_LP64;
1699 else if(sizeInt == 8 && sizeLong == 8 && sizePointer == 8)
1700 *size = LTT_ILP64;
1701 else *size = LTT_UNKNOWN;
1702}
0f7f40c1 1703#endif //0
a5dcde2f 1704/* get the node name of the system */
1705
1706char * ltt_trace_system_description_node_name (LttSystemDescription * s)
1707{
1708 return s->node_name;
1709}
1710
1711
1712/* get the domain name of the system */
1713
1714char * ltt_trace_system_description_domain_name (LttSystemDescription * s)
1715{
1716 return s->domain_name;
1717}
1718
1719
1720/* get the description of the system */
1721
1722char * ltt_trace_system_description_description (LttSystemDescription * s)
1723{
1724 return s->description;
1725}
1726
1727
1728/* get the start time of the trace */
1729
1730LttTime ltt_trace_system_description_trace_start_time(LttSystemDescription *s)
1731{
1732 return s->trace_start;
1733}
1734
18206708 1735
1736LttTracefile *ltt_tracefile_new()
1737{
1738 return g_new(LttTracefile, 1);
1739}
1740
1741void ltt_tracefile_destroy(LttTracefile *tf)
1742{
1743 g_free(tf);
1744}
1745
1746void ltt_tracefile_copy(LttTracefile *dest, const LttTracefile *src)
1747{
1748 *dest = *src;
1749}
1750
This page took 0.12541 seconds and 4 git commands to generate.