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