liblttvtraceread: clean up by removing old commented code
[lttv.git] / ltt / branches / poly / ltt / tracefile.c
... / ...
CommitLineData
1/* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2005 Mathieu Desnoyers
3 *
4 * Complete rewrite from the original version made by XangXiu Yang.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License Version 2.1 as published by the Free Software Foundation.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
20
21#ifdef HAVE_CONFIG_H
22#include <config.h>
23#endif
24
25#include <stdio.h>
26#include <fcntl.h>
27#include <string.h>
28#include <dirent.h>
29#include <sys/stat.h>
30#include <sys/types.h>
31#include <errno.h>
32#include <unistd.h>
33#include <math.h>
34#include <glib.h>
35#include <malloc.h>
36#include <sys/mman.h>
37#include <string.h>
38
39// For realpath
40#include <limits.h>
41#include <stdlib.h>
42
43
44#include <ltt/ltt.h>
45#include "ltt-private.h"
46#include <ltt/trace.h>
47#include <ltt/event.h>
48#include <ltt/ltt-types.h>
49#include <ltt/marker.h>
50
51/* Facility names used in this file */
52
53GQuark LTT_FACILITY_NAME_HEARTBEAT,
54 LTT_EVENT_NAME_HEARTBEAT,
55 LTT_EVENT_NAME_HEARTBEAT_FULL;
56GQuark LTT_TRACEFILE_NAME_FACILITIES;
57
58#ifndef g_open
59#define g_open open
60#endif
61
62
63#define __UNUSED__ __attribute__((__unused__))
64
65#define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
66
67#ifndef g_debug
68#define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
69#endif
70
71#define g_close close
72
73/* Those macros must be called from within a function where page_size is a known
74 * variable */
75#define PAGE_MASK (~(page_size-1))
76#define PAGE_ALIGN(addr) (((addr)+page_size-1)&PAGE_MASK)
77
78LttTrace *father_trace = NULL;
79
80/* set the offset of the fields belonging to the event,
81 need the information of the archecture */
82//void set_fields_offsets(LttTracefile *tf, LttEventType *event_type);
83//size_t get_fields_offsets(LttTracefile *tf, LttEventType *event_type, void *data);
84
85/* get the size of the field type according to
86 * The facility size information. */
87#if 0
88static inline void preset_field_type_size(LttTracefile *tf,
89 LttEventType *event_type,
90 off_t offset_root, off_t offset_parent,
91 enum field_status *fixed_root, enum field_status *fixed_parent,
92 LttField *field);
93#endif //0
94
95/* map a fixed size or a block information from the file (fd) */
96static gint map_block(LttTracefile * tf, guint block_num);
97
98/* calculate nsec per cycles for current block */
99#if 0
100static guint32 calc_nsecs_per_cycle(LttTracefile * t);
101static guint64 cycles_2_ns(LttTracefile *tf, guint64 cycles);
102#endif //0
103
104/* go to the next event */
105static int ltt_seek_next_event(LttTracefile *tf);
106
107//void ltt_update_event_size(LttTracefile *tf);
108
109static int open_tracefiles(LttTrace *trace, gchar *root_path,
110 gchar *relative_path);
111static int ltt_process_facility_tracefile(LttTracefile *tf);
112static void ltt_tracefile_time_span_get(LttTracefile *tf,
113 LttTime *start, LttTime *end);
114static void group_time_span_get(GQuark name, gpointer data, gpointer user_data);
115static gint map_block(LttTracefile * tf, guint block_num);
116static int ltt_seek_next_event(LttTracefile *tf);
117static void __attribute__((constructor)) init(void);
118static void ltt_update_event_size(LttTracefile *tf);
119
120/* Enable event debugging */
121static int a_event_debug = 0;
122
123void ltt_event_debug(int state)
124{
125 a_event_debug = state;
126}
127
128guint ltt_trace_get_num_cpu(LttTrace *t)
129{
130 return t->num_cpu;
131}
132
133
134/* trace can be NULL
135 *
136 * Return value : 0 success, 1 bad tracefile
137 */
138int parse_trace_header(void *header, LttTracefile *tf, LttTrace *t)
139{
140 guint32 *magic_number = (guint32*)header;
141 struct ltt_trace_header_any *any = (struct ltt_trace_header_any *)header;
142
143 if(*magic_number == LTT_MAGIC_NUMBER)
144 tf->reverse_bo = 0;
145 else if(*magic_number == LTT_REV_MAGIC_NUMBER)
146 tf->reverse_bo = 1;
147 else /* invalid magic number, bad tracefile ! */
148 return 1;
149
150 /* Get float byte order : might be different from int byte order
151 * (or is set to 0 if the trace has no float (kernel trace)) */
152 tf->float_word_order = any->float_word_order;
153 tf->alignment = any->alignment;
154 tf->has_heartbeat = any->has_heartbeat;
155
156 if(t) {
157 t->arch_type = ltt_get_uint32(LTT_GET_BO(tf),
158 &any->arch_type);
159 t->arch_variant = ltt_get_uint32(LTT_GET_BO(tf),
160 &any->arch_variant);
161 t->arch_size = any->arch_size;
162 t->ltt_major_version = any->major_version;
163 t->ltt_minor_version = any->minor_version;
164 t->flight_recorder = any->flight_recorder;
165 // t->compact_facilities = NULL;
166 }
167
168 switch(any->major_version) {
169
170 case 0:
171 g_warning("Unsupported trace version : %hhu.%hhu",
172 any->major_version, any->minor_version);
173 return 1;
174 break;
175 case 1:
176 switch(any->minor_version) {
177 case 0:
178 {
179 struct ltt_trace_header_1_0 *vheader =
180 (struct ltt_trace_header_1_0 *)header;
181 tf->buffer_header_size =
182 sizeof(struct ltt_block_start_header)
183 + sizeof(struct ltt_trace_header_1_0);
184 tf->tsc_lsb_truncate = vheader->tsc_lsb_truncate;
185 tf->tscbits = vheader->tscbits;
186 tf->tsc_msb_cutoff = 32 - tf->tsc_lsb_truncate - tf->tscbits;
187 tf->compact_event_bits = 32 - vheader->compact_data_shift;
188 tf->tsc_mask = ((1ULL << (tf->tscbits))-1);
189 tf->tsc_mask = tf->tsc_mask << tf->tsc_lsb_truncate;
190 tf->tsc_mask_next_bit = (1ULL<<(tf->tscbits));
191 tf->tsc_mask_next_bit = tf->tsc_mask_next_bit << tf->tsc_lsb_truncate;
192 if(t) {
193 t->start_freq = ltt_get_uint64(LTT_GET_BO(tf),
194 &vheader->start_freq);
195 t->freq_scale = ltt_get_uint32(LTT_GET_BO(tf),
196 &vheader->freq_scale);
197 if(father_trace) {
198 t->start_freq = father_trace->start_freq;
199 t->freq_scale = father_trace->freq_scale;
200 }
201 else {
202 father_trace = t;
203 }
204 t->start_tsc = ltt_get_uint64(LTT_GET_BO(tf),
205 &vheader->start_tsc);
206 t->start_monotonic = ltt_get_uint64(LTT_GET_BO(tf),
207 &vheader->start_monotonic);
208 t->start_time.tv_sec = ltt_get_uint64(LTT_GET_BO(tf),
209 &vheader->start_time_sec);
210 t->start_time.tv_nsec = ltt_get_uint64(LTT_GET_BO(tf),
211 &vheader->start_time_usec);
212 t->start_time.tv_nsec *= 1000; /* microsec to nanosec */
213
214 t->start_time_from_tsc = ltt_time_from_uint64(
215 (double)t->start_tsc
216 * (1000000000.0 / tf->trace->freq_scale)
217 / (double)t->start_freq);
218 }
219 }
220 break;
221 default:
222 g_warning("Unsupported trace version : %hhu.%hhu",
223 any->major_version, any->minor_version);
224 return 1;
225 }
226 break;
227 default:
228 g_warning("Unsupported trace version : %hhu.%hhu",
229 any->major_version, any->minor_version);
230 return 1;
231 }
232
233
234 return 0;
235}
236
237
238
239/*****************************************************************************
240 *Function name
241 * ltt_tracefile_open : open a trace file, construct a LttTracefile
242 *Input params
243 * t : the trace containing the tracefile
244 * fileName : path name of the trace file
245 * tf : the tracefile structure
246 *Return value
247 * : 0 for success, -1 otherwise.
248 ****************************************************************************/
249
250gint ltt_tracefile_open(LttTrace *t, gchar * fileName, LttTracefile *tf)
251{
252 struct stat lTDFStat; /* Trace data file status */
253 struct ltt_block_start_header *header;
254 int page_size = getpagesize();
255
256 //open the file
257 tf->long_name = g_quark_from_string(fileName);
258 tf->trace = t;
259 tf->fd = open(fileName, O_RDONLY);
260 if(tf->fd < 0){
261 g_warning("Unable to open input data file %s\n", fileName);
262 goto end;
263 }
264
265 // Get the file's status
266 if(fstat(tf->fd, &lTDFStat) < 0){
267 g_warning("Unable to get the status of the input data file %s\n", fileName);
268 goto close_file;
269 }
270
271 // Is the file large enough to contain a trace
272 if(lTDFStat.st_size <
273 (off_t)(sizeof(struct ltt_block_start_header)
274 + sizeof(struct ltt_trace_header_any))){
275 g_print("The input data file %s does not contain a trace\n", fileName);
276 goto close_file;
277 }
278
279 /* Temporarily map the buffer start header to get trace information */
280 /* Multiple of pages aligned head */
281 tf->buffer.head = mmap(0,
282 PAGE_ALIGN(sizeof(struct ltt_block_start_header)
283 + sizeof(struct ltt_trace_header_any)), PROT_READ,
284 MAP_PRIVATE, tf->fd, 0);
285 if(tf->buffer.head == MAP_FAILED) {
286 perror("Error in allocating memory for buffer of tracefile");
287 goto close_file;
288 }
289 g_assert( ( (gulong)tf->buffer.head&(8-1) ) == 0); // make sure it's aligned.
290
291 header = (struct ltt_block_start_header*)tf->buffer.head;
292
293 if(parse_trace_header(header->trace, tf, NULL)) {
294 g_warning("parse_trace_header error");
295 goto unmap_file;
296 }
297
298 //store the size of the file
299 tf->file_size = lTDFStat.st_size;
300 tf->buf_size = ltt_get_uint32(LTT_GET_BO(tf), &header->buf_size);
301 tf->num_blocks = tf->file_size / tf->buf_size;
302
303 if(munmap(tf->buffer.head,
304 PAGE_ALIGN(sizeof(struct ltt_block_start_header)
305 + sizeof(struct ltt_trace_header_any)))) {
306 g_warning("unmap size : %u\n",
307 PAGE_ALIGN(sizeof(struct ltt_block_start_header)
308 + sizeof(struct ltt_trace_header_any)));
309 perror("munmap error");
310 g_assert(0);
311 }
312 tf->buffer.head = NULL;
313
314 //read the first block
315 if(map_block(tf,0)) {
316 perror("Cannot map block for tracefile");
317 goto close_file;
318 }
319
320 return 0;
321
322 /* Error */
323unmap_file:
324 if(munmap(tf->buffer.head,
325 PAGE_ALIGN(sizeof(struct ltt_block_start_header)
326 + sizeof(struct ltt_trace_header_any)))) {
327 g_warning("unmap size : %u\n",
328 PAGE_ALIGN(sizeof(struct ltt_block_start_header)
329 + sizeof(struct ltt_trace_header_any)));
330 perror("munmap error");
331 g_assert(0);
332 }
333close_file:
334 close(tf->fd);
335end:
336 return -1;
337}
338
339LttTrace *ltt_tracefile_get_trace(LttTracefile *tf)
340{
341 return tf->trace;
342}
343
344#if 0
345/*****************************************************************************
346 *Open control and per cpu tracefiles
347 ****************************************************************************/
348
349void ltt_tracefile_open_cpu(LttTrace *t, gchar * tracefile_name)
350{
351 LttTracefile * tf;
352 tf = ltt_tracefile_open(t,tracefile_name);
353 if(!tf) return;
354 t->per_cpu_tracefile_number++;
355 g_ptr_array_add(t->per_cpu_tracefiles, tf);
356}
357
358gint ltt_tracefile_open_control(LttTrace *t, gchar * control_name)
359{
360 LttTracefile * tf;
361 LttEvent ev;
362 LttFacility * f;
363 void * pos;
364 FacilityLoad fLoad;
365 unsigned int i;
366
367 tf = ltt_tracefile_open(t,control_name);
368 if(!tf) {
369 g_warning("ltt_tracefile_open_control : bad file descriptor");
370 return -1;
371 }
372 t->control_tracefile_number++;
373 g_ptr_array_add(t->control_tracefiles,tf);
374
375 //parse facilities tracefile to get base_id
376 if(strcmp(&control_name[strlen(control_name)-10],"facilities") ==0){
377 while(1){
378 if(!ltt_tracefile_read(tf,&ev)) return 0; // end of file
379
380 if(ev.event_id == TRACE_FACILITY_LOAD){
381 pos = ev.data;
382 fLoad.name = (gchar*)pos;
383 fLoad.checksum = *(LttChecksum*)(pos + strlen(fLoad.name));
384 fLoad.base_code = *(guint32 *)(pos + strlen(fLoad.name) + sizeof(LttChecksum));
385
386 for(i=0;i<t->facility_number;i++){
387 f = (LttFacility*)g_ptr_array_index(t->facilities,i);
388 if(strcmp(f->name,fLoad.name)==0 && fLoad.checksum==f->checksum){
389 f->base_id = fLoad.base_code;
390 break;
391 }
392 }
393 if(i==t->facility_number) {
394 g_warning("Facility: %s, checksum: %u is not found",
395 fLoad.name,(unsigned int)fLoad.checksum);
396 return -1;
397 }
398 }else if(ev.event_id == TRACE_BLOCK_START){
399 continue;
400 }else if(ev.event_id == TRACE_BLOCK_END){
401 break;
402 }else {
403 g_warning("Not valid facilities trace file");
404 return -1;
405 }
406 }
407 }
408 return 0;
409}
410#endif //0
411
412/*****************************************************************************
413 *Function name
414 * ltt_tracefile_close: close a trace file,
415 *Input params
416 * t : tracefile which will be closed
417 ****************************************************************************/
418
419void ltt_tracefile_close(LttTracefile *t)
420{
421 int page_size = getpagesize();
422
423 if(t->buffer.head != NULL)
424 if(munmap(t->buffer.head, PAGE_ALIGN(t->buf_size))) {
425 g_warning("unmap size : %u\n",
426 PAGE_ALIGN(t->buf_size));
427 perror("munmap error");
428 g_assert(0);
429 }
430
431 close(t->fd);
432}
433
434
435/*****************************************************************************
436 *Get system information
437 ****************************************************************************/
438#if 0
439gint getSystemInfo(LttSystemDescription* des, gchar * pathname)
440{
441 int fd;
442 GIOChannel *iochan;
443 gchar *buf = NULL;
444 gsize length;
445
446 GMarkupParseContext * context;
447 GError * error = NULL;
448 GMarkupParser markup_parser =
449 {
450 parser_start_element,
451 NULL,
452 parser_characters,
453 NULL, /* passthrough */
454 NULL /* error */
455 };
456
457 fd = g_open(pathname, O_RDONLY, 0);
458 if(fd == -1){
459 g_warning("Can not open file : %s\n", pathname);
460 return -1;
461 }
462
463 iochan = g_io_channel_unix_new(fd);
464
465 context = g_markup_parse_context_new(&markup_parser, 0, des,NULL);
466
467 //while(fgets(buf,DIR_NAME_SIZE, fp) != NULL){
468 while(g_io_channel_read_line(iochan, &buf, &length, NULL, &error)
469 != G_IO_STATUS_EOF) {
470
471 if(error != NULL) {
472 g_warning("Can not read xml file: \n%s\n", error->message);
473 g_error_free(error);
474 }
475 if(!g_markup_parse_context_parse(context, buf, length, &error)){
476 if(error != NULL) {
477 g_warning("Can not parse xml file: \n%s\n", error->message);
478 g_error_free(error);
479 }
480 g_markup_parse_context_free(context);
481
482 g_io_channel_shutdown(iochan, FALSE, &error); /* No flush */
483 if(error != NULL) {
484 g_warning("Can not close file: \n%s\n", error->message);
485 g_error_free(error);
486 }
487
488 close(fd);
489 return -1;
490 }
491 }
492 g_markup_parse_context_free(context);
493
494 g_io_channel_shutdown(iochan, FALSE, &error); /* No flush */
495 if(error != NULL) {
496 g_warning("Can not close file: \n%s\n", error->message);
497 g_error_free(error);
498 }
499
500 g_close(fd);
501
502 g_free(buf);
503 return 0;
504}
505#endif //0
506
507/*****************************************************************************
508 *The following functions get facility/tracefile information
509 ****************************************************************************/
510#if 0
511gint getFacilityInfo(LttTrace *t, gchar* eventdefs)
512{
513 GDir * dir;
514 const gchar * name;
515 unsigned int i,j;
516 LttFacility * f;
517 LttEventType * et;
518 gchar fullname[DIR_NAME_SIZE];
519 GError * error = NULL;
520
521 dir = g_dir_open(eventdefs, 0, &error);
522
523 if(error != NULL) {
524 g_warning("Can not open directory: %s, %s\n", eventdefs, error->message);
525 g_error_free(error);
526 return -1;
527 }
528
529 while((name = g_dir_read_name(dir)) != NULL){
530 if(!g_pattern_match_simple("*.xml", name)) continue;
531 strcpy(fullname,eventdefs);
532 strcat(fullname,name);
533 ltt_facility_open(t,fullname);
534 }
535 g_dir_close(dir);
536
537 for(j=0;j<t->facility_number;j++){
538 f = (LttFacility*)g_ptr_array_index(t->facilities, j);
539 for(i=0; i<f->event_number; i++){
540 et = f->events[i];
541 setFieldsOffset(NULL, et, NULL, t);
542 }
543 }
544 return 0;
545}
546#endif //0
547
548/*****************************************************************************
549 *A trace is specified as a pathname to the directory containing all the
550 *associated data (control tracefiles, per cpu tracefiles, event
551 *descriptions...).
552 *
553 *When a trace is closed, all the associated facilities, types and fields
554 *are released as well.
555 */
556
557
558/****************************************************************************
559 * get_absolute_pathname
560 *
561 * return the unique pathname in the system
562 *
563 * MD : Fixed this function so it uses realpath, dealing well with
564 * forgotten cases (.. were not used correctly before).
565 *
566 ****************************************************************************/
567void get_absolute_pathname(const gchar *pathname, gchar * abs_pathname)
568{
569 abs_pathname[0] = '\0';
570
571 if ( realpath (pathname, abs_pathname) != NULL)
572 return;
573 else
574 {
575 /* error, return the original path unmodified */
576 strcpy(abs_pathname, pathname);
577 return;
578 }
579 return;
580}
581
582/* Search for something like : .*_.*
583 *
584 * The left side is the name, the right side is the number.
585 */
586
587int get_tracefile_name_number(gchar *raw_name,
588 GQuark *name,
589 guint *num,
590 gulong *tid,
591 gulong *pgid,
592 guint64 *creation)
593{
594 guint raw_name_len = strlen(raw_name);
595 gchar char_name[PATH_MAX];
596 int i;
597 int underscore_pos;
598 long int cpu_num;
599 gchar *endptr;
600 gchar *tmpptr;
601
602 for(i=raw_name_len-1;i>=0;i--) {
603 if(raw_name[i] == '_') break;
604 }
605 if(i==-1) { /* Either not found or name length is 0 */
606 /* This is a userspace tracefile */
607 strncpy(char_name, raw_name, raw_name_len);
608 char_name[raw_name_len] = '\0';
609 *name = g_quark_from_string(char_name);
610 *num = 0; /* unknown cpu */
611 for(i=0;i<raw_name_len;i++) {
612 if(raw_name[i] == '/') {
613 break;
614 }
615 }
616 i++;
617 for(;i<raw_name_len;i++) {
618 if(raw_name[i] == '/') {
619 break;
620 }
621 }
622 i++;
623 for(;i<raw_name_len;i++) {
624 if(raw_name[i] == '-') {
625 break;
626 }
627 }
628 if(i == raw_name_len) return -1;
629 i++;
630 tmpptr = &raw_name[i];
631 for(;i<raw_name_len;i++) {
632 if(raw_name[i] == '.') {
633 raw_name[i] = ' ';
634 break;
635 }
636 }
637 *tid = strtoul(tmpptr, &endptr, 10);
638 if(endptr == tmpptr)
639 return -1; /* No digit */
640 if(*tid == ULONG_MAX)
641 return -1; /* underflow / overflow */
642 i++;
643 tmpptr = &raw_name[i];
644 for(;i<raw_name_len;i++) {
645 if(raw_name[i] == '.') {
646 raw_name[i] = ' ';
647 break;
648 }
649 }
650 *pgid = strtoul(tmpptr, &endptr, 10);
651 if(endptr == tmpptr)
652 return -1; /* No digit */
653 if(*pgid == ULONG_MAX)
654 return -1; /* underflow / overflow */
655 i++;
656 tmpptr = &raw_name[i];
657 *creation = strtoull(tmpptr, &endptr, 10);
658 if(endptr == tmpptr)
659 return -1; /* No digit */
660 if(*creation == G_MAXUINT64)
661 return -1; /* underflow / overflow */
662 } else {
663 underscore_pos = i;
664
665 cpu_num = strtol(raw_name+underscore_pos+1, &endptr, 10);
666
667 if(endptr == raw_name+underscore_pos+1)
668 return -1; /* No digit */
669 if(cpu_num == LONG_MIN || cpu_num == LONG_MAX)
670 return -1; /* underflow / overflow */
671
672 strncpy(char_name, raw_name, underscore_pos);
673 char_name[underscore_pos] = '\0';
674
675 *name = g_quark_from_string(char_name);
676 *num = cpu_num;
677 }
678
679
680 return 0;
681}
682
683
684GData **ltt_trace_get_tracefiles_groups(LttTrace *trace)
685{
686 return &trace->tracefiles;
687}
688
689
690void compute_tracefile_group(GQuark key_id,
691 GArray *group,
692 struct compute_tracefile_group_args *args)
693{
694 int i;
695 LttTracefile *tf;
696
697 for(i=0; i<group->len; i++) {
698 tf = &g_array_index (group, LttTracefile, i);
699 if(tf->cpu_online)
700 args->func(tf, args->func_args);
701 }
702}
703
704
705void ltt_tracefile_group_destroy(gpointer data)
706{
707 GArray *group = (GArray *)data;
708 int i;
709 LttTracefile *tf;
710
711 for(i=0; i<group->len; i++) {
712 tf = &g_array_index (group, LttTracefile, i);
713 if(tf->cpu_online)
714 ltt_tracefile_close(tf);
715 }
716 g_array_free(group, TRUE);
717}
718
719gboolean ltt_tracefile_group_has_cpu_online(gpointer data)
720{
721 GArray *group = (GArray *)data;
722 int i;
723 LttTracefile *tf;
724
725 for(i=0; i<group->len; i++) {
726 tf = &g_array_index (group, LttTracefile, i);
727 if(tf->cpu_online)
728 return 1;
729 }
730 return 0;
731}
732
733
734/* Open each tracefile under a specific directory. Put them in a
735 * GData : permits to access them using their tracefile group pathname.
736 * i.e. access control/modules tracefile group by index :
737 * "control/module".
738 *
739 * relative path is the path relative to the trace root
740 * root path is the full path
741 *
742 * A tracefile group is simply an array where all the per cpu tracefiles sit.
743 */
744
745int open_tracefiles(LttTrace *trace, gchar *root_path, gchar *relative_path)
746{
747 DIR *dir = opendir(root_path);
748 struct dirent *entry;
749 struct stat stat_buf;
750 int ret;
751
752 gchar path[PATH_MAX];
753 int path_len;
754 gchar *path_ptr;
755
756 int rel_path_len;
757 gchar rel_path[PATH_MAX];
758 gchar *rel_path_ptr;
759 LttTracefile tmp_tf;
760
761 if(dir == NULL) {
762 perror(root_path);
763 return ENOENT;
764 }
765
766 strncpy(path, root_path, PATH_MAX-1);
767 path_len = strlen(path);
768 path[path_len] = '/';
769 path_len++;
770 path_ptr = path + path_len;
771
772 strncpy(rel_path, relative_path, PATH_MAX-1);
773 rel_path_len = strlen(rel_path);
774 rel_path[rel_path_len] = '/';
775 rel_path_len++;
776 rel_path_ptr = rel_path + rel_path_len;
777
778 while((entry = readdir(dir)) != NULL) {
779
780 if(entry->d_name[0] == '.') continue;
781
782 strncpy(path_ptr, entry->d_name, PATH_MAX - path_len);
783 strncpy(rel_path_ptr, entry->d_name, PATH_MAX - rel_path_len);
784
785 ret = stat(path, &stat_buf);
786 if(ret == -1) {
787 perror(path);
788 continue;
789 }
790
791 g_debug("Tracefile file or directory : %s\n", path);
792
793 // if(strcmp(rel_path, "/eventdefs") == 0) continue;
794
795 if(S_ISDIR(stat_buf.st_mode)) {
796
797 g_debug("Entering subdirectory...\n");
798 ret = open_tracefiles(trace, path, rel_path);
799 if(ret < 0) continue;
800 } else if(S_ISREG(stat_buf.st_mode)) {
801 GQuark name;
802 guint num;
803 gulong tid, pgid;
804 guint64 creation;
805 GArray *group;
806 num = 0;
807 tid = pgid = 0;
808 creation = 0;
809 if(get_tracefile_name_number(rel_path, &name, &num, &tid, &pgid, &creation))
810 continue; /* invalid name */
811
812 g_debug("Opening file.\n");
813 if(ltt_tracefile_open(trace, path, &tmp_tf)) {
814 g_info("Error opening tracefile %s", path);
815
816 continue; /* error opening the tracefile : bad magic number ? */
817 }
818
819 g_debug("Tracefile name is %s and number is %u",
820 g_quark_to_string(name), num);
821
822 tmp_tf.cpu_online = 1;
823 tmp_tf.cpu_num = num;
824 tmp_tf.name = name;
825 tmp_tf.tid = tid;
826 tmp_tf.pgid = pgid;
827 tmp_tf.creation = creation;
828 if(tmp_tf.name == g_quark_from_string("/compact")
829 || tmp_tf.name == g_quark_from_string("/flight-compact"))
830 tmp_tf.compact = 1;
831 else
832 tmp_tf.compact = 0;
833 group = g_datalist_id_get_data(&trace->tracefiles, name);
834 if(group == NULL) {
835 /* Elements are automatically cleared when the array is allocated.
836 * It makes the cpu_online variable set to 0 : cpu offline, by default.
837 */
838 group = g_array_sized_new (FALSE, TRUE, sizeof(LttTracefile), 10);
839 g_datalist_id_set_data_full(&trace->tracefiles, name,
840 group, ltt_tracefile_group_destroy);
841 }
842
843 /* Add the per cpu tracefile to the named group */
844 unsigned int old_len = group->len;
845 if(num+1 > old_len)
846 group = g_array_set_size(group, num+1);
847 g_array_index (group, LttTracefile, num) = tmp_tf;
848 g_array_index (group, LttTracefile, num).event.tracefile =
849 &g_array_index (group, LttTracefile, num);
850 }
851 }
852
853 closedir(dir);
854
855 return 0;
856}
857
858
859/* Presumes the tracefile is already seeked at the beginning. It makes sense,
860 * because it must be done just after the opening */
861int ltt_process_facility_tracefile(LttTracefile *tf)
862{
863 int err;
864 //LttFacility *fac;
865 //GArray *fac_ids;
866 guint i;
867 //LttEventType *et;
868
869 while(1) {
870 err = ltt_tracefile_read_seek(tf);
871 if(err == EPERM) goto seek_error;
872 else if(err == ERANGE) break; /* End of tracefile */
873
874 err = ltt_tracefile_read_update_event(tf);
875 if(err) goto update_error;
876
877 /* We are on a facility load/or facility unload/ or heartbeat event */
878 /* The rules are :
879 * * facility 0 is hardcoded : this is the core facility. It will be shown
880 * in the facility array though, and is shown as "loaded builtin" in the
881 * trace.
882 * It contains event :
883 * 0 : facility load
884 * 1 : facility unload
885 * 2 : state dump facility load
886 * 3 : heartbeat
887 */
888 if(tf->event.event_id >= MARKER_CORE_IDS) {
889 /* Should only contain core facility */
890 g_warning("Error in processing facility file %s, "
891 "should not contain event id %u.", g_quark_to_string(tf->name),
892 tf->event.event_id);
893 err = EPERM;
894 goto event_id_error;
895 } else {
896
897 char *pos;
898 const char *marker_name, *format;
899 uint16_t id;
900 guint8 int_size, long_size, pointer_size, size_t_size, alignment;
901
902 // FIXME align
903 switch((enum marker_id)tf->event.event_id) {
904 case MARKER_ID_SET_MARKER_ID:
905 marker_name = pos = tf->event.data;
906 g_debug("Doing MARKER_ID_SET_MARKER_ID of marker %s", marker_name);
907 pos += strlen(marker_name) + 1;
908 //remove genevent compatibility
909 //pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->alignment);
910 pos += ltt_align((size_t)pos, sizeof(uint16_t), tf->alignment);
911 id = ltt_get_uint16(LTT_GET_BO(tf), pos);
912 g_debug("In MARKER_ID_SET_MARKER_ID of marker %s id %hu",
913 marker_name, id);
914 pos += sizeof(guint16);
915 int_size = *(guint8*)pos;
916 pos += sizeof(guint8);
917 long_size = *(guint8*)pos;
918 pos += sizeof(guint8);
919 pointer_size = *(guint8*)pos;
920 pos += sizeof(guint8);
921 size_t_size = *(guint8*)pos;
922 pos += sizeof(guint8);
923 alignment = *(guint8*)pos;
924 pos += sizeof(guint8);
925 marker_id_event(tf->trace, g_quark_from_string(marker_name),
926 id, int_size, long_size,
927 pointer_size, size_t_size, alignment);
928 break;
929 case MARKER_ID_SET_MARKER_FORMAT:
930 marker_name = pos = tf->event.data;
931 g_debug("Doing MARKER_ID_SET_MARKER_FORMAT of marker %s",
932 marker_name);
933 pos += strlen(marker_name) + 1;
934 //break genevent.
935 //pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->alignment);
936 format = pos;
937 pos += strlen(format) + 1;
938 //break genevent
939 //pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->alignment);
940 marker_format_event(tf->trace, g_quark_from_string(marker_name),
941 format);
942 /* get information from dictionnary TODO */
943 break;
944 case MARKER_ID_HEARTBEAT_32:
945 case MARKER_ID_HEARTBEAT_64:
946 break;
947 default:
948 g_warning("Error in processing facility file %s, "
949 "unknown event id %hhu.",
950 g_quark_to_string(tf->name),
951 tf->event.event_id);
952 err = EPERM;
953 goto event_id_error;
954 }
955 }
956 }
957 return 0;
958
959 /* Error handling */
960event_id_error:
961update_error:
962seek_error:
963 g_warning("An error occured in facility tracefile parsing");
964 return err;
965}
966
967
968LttTrace *ltt_trace_open(const gchar *pathname)
969{
970 gchar abs_path[PATH_MAX];
971 LttTrace * t;
972 LttTracefile *tf;
973 GArray *group;
974 int i, ret;
975 struct ltt_block_start_header *header;
976 DIR *dir;
977 struct dirent *entry;
978 guint control_found = 0;
979 struct stat stat_buf;
980 gchar path[PATH_MAX];
981
982 t = g_new(LttTrace, 1);
983 if(!t) goto alloc_error;
984
985 get_absolute_pathname(pathname, abs_path);
986 t->pathname = g_quark_from_string(abs_path);
987
988 g_datalist_init(&t->tracefiles);
989
990 /* Test to see if it looks like a trace */
991 dir = opendir(abs_path);
992 if(dir == NULL) {
993 perror(abs_path);
994 goto open_error;
995 }
996 while((entry = readdir(dir)) != NULL) {
997 strcpy(path, abs_path);
998 strcat(path, "/");
999 strcat(path, entry->d_name);
1000 ret = stat(path, &stat_buf);
1001 if(ret == -1) {
1002 perror(path);
1003 continue;
1004 }
1005 if(S_ISDIR(stat_buf.st_mode)) {
1006 if(strcmp(entry->d_name, "control") == 0) {
1007 control_found = 1;
1008 }
1009 }
1010 }
1011 closedir(dir);
1012
1013 if(!control_found) goto find_error;
1014
1015 /* Open all the tracefiles */
1016 if(open_tracefiles(t, abs_path, "")) {
1017 g_warning("Error opening tracefile %s", abs_path);
1018 goto find_error;
1019 }
1020
1021 /* Parse each trace control/facilitiesN files : get runtime fac. info */
1022 group = g_datalist_id_get_data(&t->tracefiles, LTT_TRACEFILE_NAME_FACILITIES);
1023 if(group == NULL) {
1024 g_error("Trace %s has no facility tracefile", abs_path);
1025 g_assert(0);
1026 goto facilities_error;
1027 }
1028
1029 /* Get the trace information for the control/facility 0 tracefile */
1030 g_assert(group->len > 0);
1031 tf = &g_array_index (group, LttTracefile, 0);
1032 header = (struct ltt_block_start_header*)tf->buffer.head;
1033 g_assert(parse_trace_header(header->trace,
1034 tf, t) == 0);
1035
1036 t->num_cpu = group->len;
1037
1038 ret = allocate_marker_data(t);
1039 if (ret)
1040 g_error("Error in allocating marker data");
1041
1042 for(i=0; i<group->len; i++) {
1043 tf = &g_array_index (group, LttTracefile, i);
1044 if(ltt_process_facility_tracefile(tf))
1045 goto facilities_error;
1046 }
1047
1048 return t;
1049
1050 /* Error handling */
1051facilities_error:
1052 destroy_marker_data(t);
1053find_error:
1054 g_datalist_clear(&t->tracefiles);
1055open_error:
1056 g_free(t);
1057alloc_error:
1058 return NULL;
1059
1060}
1061
1062GQuark ltt_trace_name(const LttTrace *t)
1063{
1064 return t->pathname;
1065}
1066
1067
1068/******************************************************************************
1069 * When we copy a trace, we want all the opening actions to happen again :
1070 * the trace will be reopened and totally independant from the original.
1071 * That's why we call ltt_trace_open.
1072 *****************************************************************************/
1073LttTrace *ltt_trace_copy(LttTrace *self)
1074{
1075 return ltt_trace_open(g_quark_to_string(self->pathname));
1076}
1077
1078void ltt_trace_close(LttTrace *t)
1079{
1080 g_datalist_clear(&t->tracefiles);
1081 g_free(t);
1082}
1083
1084
1085/*****************************************************************************
1086 * Get the start time and end time of the trace
1087 ****************************************************************************/
1088
1089void ltt_tracefile_time_span_get(LttTracefile *tf,
1090 LttTime *start, LttTime *end)
1091{
1092 int err;
1093
1094 err = map_block(tf, 0);
1095 if(unlikely(err)) {
1096 g_error("Can not map block");
1097 *start = ltt_time_infinite;
1098 } else
1099 *start = tf->buffer.begin.timestamp;
1100
1101 err = map_block(tf, tf->num_blocks - 1); /* Last block */
1102 if(unlikely(err)) {
1103 g_error("Can not map block");
1104 *end = ltt_time_zero;
1105 } else
1106 *end = tf->buffer.end.timestamp;
1107}
1108
1109struct tracefile_time_span_get_args {
1110 LttTrace *t;
1111 LttTime *start;
1112 LttTime *end;
1113};
1114
1115void group_time_span_get(GQuark name, gpointer data, gpointer user_data)
1116{
1117 struct tracefile_time_span_get_args *args =
1118 (struct tracefile_time_span_get_args*)user_data;
1119
1120 GArray *group = (GArray *)data;
1121 int i;
1122 LttTracefile *tf;
1123 LttTime tmp_start;
1124 LttTime tmp_end;
1125
1126 for(i=0; i<group->len; i++) {
1127 tf = &g_array_index (group, LttTracefile, i);
1128 if(tf->cpu_online) {
1129 ltt_tracefile_time_span_get(tf, &tmp_start, &tmp_end);
1130 if(ltt_time_compare(*args->start, tmp_start)>0) *args->start = tmp_start;
1131 if(ltt_time_compare(*args->end, tmp_end)<0) *args->end = tmp_end;
1132 }
1133 }
1134}
1135
1136void ltt_trace_time_span_get(LttTrace *t, LttTime *start, LttTime *end)
1137{
1138 LttTime min_start = ltt_time_infinite;
1139 LttTime max_end = ltt_time_zero;
1140 struct tracefile_time_span_get_args args = { t, &min_start, &max_end };
1141
1142 g_datalist_foreach(&t->tracefiles, &group_time_span_get, &args);
1143
1144 if(start != NULL) *start = min_start;
1145 if(end != NULL) *end = max_end;
1146
1147}
1148
1149
1150/*****************************************************************************
1151 *Get the name of a tracefile
1152 ****************************************************************************/
1153
1154GQuark ltt_tracefile_name(const LttTracefile *tf)
1155{
1156 return tf->name;
1157}
1158
1159GQuark ltt_tracefile_long_name(const LttTracefile *tf)
1160{
1161 return tf->long_name;
1162}
1163
1164
1165
1166guint ltt_tracefile_cpu(LttTracefile *tf)
1167{
1168 return tf->cpu_num;
1169}
1170
1171guint ltt_tracefile_tid(LttTracefile *tf)
1172{
1173 return tf->tid;
1174}
1175
1176guint ltt_tracefile_pgid(LttTracefile *tf)
1177{
1178 return tf->pgid;
1179}
1180
1181guint64 ltt_tracefile_creation(LttTracefile *tf)
1182{
1183 return tf->creation;
1184}
1185/*****************************************************************************
1186 * Get the number of blocks in the tracefile
1187 ****************************************************************************/
1188
1189guint ltt_tracefile_block_number(LttTracefile *tf)
1190{
1191 return tf->num_blocks;
1192}
1193
1194
1195/* Seek to the first event in a tracefile that has a time equal or greater than
1196 * the time passed in parameter.
1197 *
1198 * If the time parameter is outside the tracefile time span, seek to the first
1199 * event or if after, return ERANGE.
1200 *
1201 * If the time parameter is before the first event, we have to seek specially to
1202 * there.
1203 *
1204 * If the time is after the end of the trace, return ERANGE.
1205 *
1206 * Do a binary search to find the right block, then a sequential search in the
1207 * block to find the event.
1208 *
1209 * In the special case where the time requested fits inside a block that has no
1210 * event corresponding to the requested time, the first event of the next block
1211 * will be seeked.
1212 *
1213 * IMPORTANT NOTE : // FIXME everywhere...
1214 *
1215 * You MUST NOT do a ltt_tracefile_read right after a ltt_tracefile_seek_time :
1216 * you will jump over an event if you do.
1217 *
1218 * Return value : 0 : no error, the tf->event can be used
1219 * ERANGE : time if after the last event of the trace
1220 * otherwise : this is an error.
1221 *
1222 * */
1223
1224int ltt_tracefile_seek_time(LttTracefile *tf, LttTime time)
1225{
1226 int ret = 0;
1227 int err;
1228 unsigned int block_num, high, low;
1229
1230 /* seek at the beginning of trace */
1231 err = map_block(tf, 0); /* First block */
1232 if(unlikely(err)) {
1233 g_error("Can not map block");
1234 goto fail;
1235 }
1236
1237 /* If the time is lower or equal the beginning of the trace,
1238 * go to the first event. */
1239 if(ltt_time_compare(time, tf->buffer.begin.timestamp) <= 0) {
1240 ret = ltt_tracefile_read(tf);
1241 if(ret == ERANGE) goto range;
1242 else if (ret) goto fail;
1243 goto found; /* There is either no event in the trace or the event points
1244 to the first event in the trace */
1245 }
1246
1247 err = map_block(tf, tf->num_blocks - 1); /* Last block */
1248 if(unlikely(err)) {
1249 g_error("Can not map block");
1250 goto fail;
1251 }
1252
1253 /* If the time is after the end of the trace, return ERANGE. */
1254 if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) {
1255 goto range;
1256 }
1257
1258 /* Binary search the block */
1259 high = tf->num_blocks - 1;
1260 low = 0;
1261
1262 while(1) {
1263 block_num = ((high-low) / 2) + low;
1264
1265 err = map_block(tf, block_num);
1266 if(unlikely(err)) {
1267 g_error("Can not map block");
1268 goto fail;
1269 }
1270 if(high == low) {
1271 /* We cannot divide anymore : this is what would happen if the time
1272 * requested was exactly between two consecutive buffers'end and start
1273 * timestamps. This is also what would happend if we didn't deal with out
1274 * of span cases prior in this function. */
1275 /* The event is right in the buffer!
1276 * (or in the next buffer first event) */
1277 while(1) {
1278 ret = ltt_tracefile_read(tf);
1279 if(ret == ERANGE) goto range; /* ERANGE or EPERM */
1280 else if(ret) goto fail;
1281
1282 if(ltt_time_compare(time, tf->event.event_time) <= 0)
1283 goto found;
1284 }
1285
1286 } else if(ltt_time_compare(time, tf->buffer.begin.timestamp) < 0) {
1287 /* go to lower part */
1288 high = block_num - 1;
1289 } else if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) {
1290 /* go to higher part */
1291 low = block_num + 1;
1292 } else {/* The event is right in the buffer!
1293 (or in the next buffer first event) */
1294 while(1) {
1295 ret = ltt_tracefile_read(tf);
1296 if(ret == ERANGE) goto range; /* ERANGE or EPERM */
1297 else if(ret) goto fail;
1298
1299 if(ltt_time_compare(time, tf->event.event_time) <= 0)
1300 break;
1301 }
1302 goto found;
1303 }
1304 }
1305
1306found:
1307 return 0;
1308range:
1309 return ERANGE;
1310
1311 /* Error handling */
1312fail:
1313 g_error("ltt_tracefile_seek_time failed on tracefile %s",
1314 g_quark_to_string(tf->name));
1315 return EPERM;
1316}
1317
1318
1319int ltt_tracefile_seek_position(LttTracefile *tf, const LttEventPosition *ep) {
1320
1321 int err;
1322
1323 if(ep->tracefile != tf) {
1324 goto fail;
1325 }
1326
1327 err = map_block(tf, ep->block);
1328 if(unlikely(err)) {
1329 g_error("Can not map block");
1330 goto fail;
1331 }
1332
1333 tf->event.offset = ep->offset;
1334
1335 /* Put back the event real tsc */
1336 tf->event.tsc = ep->tsc;
1337 tf->buffer.tsc = ep->tsc;
1338
1339 err = ltt_tracefile_read_update_event(tf);
1340 if(err) goto fail;
1341 err = ltt_tracefile_read_op(tf);
1342 if(err) goto fail;
1343
1344 return 0;
1345
1346fail:
1347 g_error("ltt_tracefile_seek_time failed on tracefile %s",
1348 g_quark_to_string(tf->name));
1349 return 1;
1350}
1351
1352LttTime ltt_interpolate_time_from_tsc(LttTracefile *tf, guint64 tsc)
1353{
1354 LttTime time;
1355
1356 if(tsc > tf->trace->start_tsc) {
1357 time = ltt_time_from_uint64(
1358 (double)(tsc - tf->trace->start_tsc)
1359 * (1000000000.0 / tf->trace->freq_scale)
1360 / (double)tf->trace->start_freq);
1361 time = ltt_time_add(tf->trace->start_time_from_tsc, time);
1362 } else {
1363 time = ltt_time_from_uint64(
1364 (double)(tf->trace->start_tsc - tsc)
1365 * (1000000000.0 / tf->trace->freq_scale)
1366 / (double)tf->trace->start_freq);
1367 time = ltt_time_sub(tf->trace->start_time_from_tsc, time);
1368 }
1369 return time;
1370}
1371
1372/* Calculate the real event time based on the buffer boundaries */
1373LttTime ltt_interpolate_time(LttTracefile *tf, LttEvent *event)
1374{
1375 return ltt_interpolate_time_from_tsc(tf, tf->buffer.tsc);
1376}
1377
1378
1379/* Get the current event of the tracefile : valid until the next read */
1380LttEvent *ltt_tracefile_get_event(LttTracefile *tf)
1381{
1382 return &tf->event;
1383}
1384
1385
1386
1387/*****************************************************************************
1388 *Function name
1389 * ltt_tracefile_read : Read the next event in the tracefile
1390 *Input params
1391 * t : tracefile
1392 *Return value
1393 *
1394 * Returns 0 if an event can be used in tf->event.
1395 * Returns ERANGE on end of trace. The event in tf->event still can be used
1396 * (if the last block was not empty).
1397 * Returns EPERM on error.
1398 *
1399 * This function does make the tracefile event structure point to the event
1400 * currently pointed to by the tf->event.
1401 *
1402 * Note : you must call a ltt_tracefile_seek to the beginning of the trace to
1403 * reinitialize it after an error if you want results to be coherent.
1404 * It would be the case if a end of trace last buffer has no event : the end
1405 * of trace wouldn't be returned, but an error.
1406 * We make the assumption there is at least one event per buffer.
1407 ****************************************************************************/
1408
1409int ltt_tracefile_read(LttTracefile *tf)
1410{
1411 int err;
1412
1413 err = ltt_tracefile_read_seek(tf);
1414 if(err) return err;
1415 err = ltt_tracefile_read_update_event(tf);
1416 if(err) return err;
1417 err = ltt_tracefile_read_op(tf);
1418 if(err) return err;
1419
1420 return 0;
1421}
1422
1423int ltt_tracefile_read_seek(LttTracefile *tf)
1424{
1425 int err;
1426
1427 /* Get next buffer until we finally have an event, or end of trace */
1428 while(1) {
1429 err = ltt_seek_next_event(tf);
1430 if(unlikely(err == ENOPROTOOPT)) {
1431 return EPERM;
1432 }
1433
1434 /* Are we at the end of the buffer ? */
1435 if(err == ERANGE) {
1436 if(unlikely(tf->buffer.index == tf->num_blocks-1)){ /* end of trace ? */
1437 return ERANGE;
1438 } else {
1439 /* get next block */
1440 err = map_block(tf, tf->buffer.index + 1);
1441 if(unlikely(err)) {
1442 g_error("Can not map block");
1443 return EPERM;
1444 }
1445 }
1446 } else break; /* We found an event ! */
1447 }
1448
1449 return 0;
1450}
1451
1452
1453/* do specific operation on events */
1454int ltt_tracefile_read_op(LttTracefile *tf)
1455{
1456 LttEvent *event;
1457
1458 event = &tf->event;
1459
1460 /* do event specific operation */
1461
1462 /* do something if its an heartbeat event : increment the heartbeat count */
1463 //if(event->facility_id == LTT_FACILITY_CORE)
1464 // if(event->event_id == LTT_EVENT_HEARTBEAT)
1465 // tf->cur_heart_beat_number++;
1466
1467 return 0;
1468}
1469
1470static void print_debug_event_header(LttEvent *ev, void *start_pos, void *end_pos)
1471{
1472 unsigned int offset = 0;
1473 int i, j;
1474
1475 g_printf("Event header (tracefile %s offset %llx):\n",
1476 g_quark_to_string(ev->tracefile->long_name),
1477 ((uint64_t)ev->tracefile->buffer.index * ev->tracefile->buf_size)
1478 + (long)start_pos - (long)ev->tracefile->buffer.head);
1479
1480 while (offset < (long)end_pos - (long)start_pos) {
1481 g_printf("%8lx", (long)start_pos - (long)ev->tracefile->buffer.head + offset);
1482 g_printf(" ");
1483
1484 for (i = 0; i < 4 ; i++) {
1485 for (j = 0; j < 4; j++) {
1486 if (offset + ((i * 4) + j) <
1487 (long)end_pos - (long)start_pos)
1488 g_printf("%02hhX",
1489 ((char*)start_pos)[offset + ((i * 4) + j)]);
1490 else
1491 g_printf(" ");
1492 g_printf(" ");
1493 }
1494 if (i < 4)
1495 g_printf(" ");
1496 }
1497 offset+=16;
1498 g_printf("\n");
1499 }
1500}
1501
1502
1503/* same as ltt_tracefile_read, but does not seek to the next event nor call
1504 * event specific operation. */
1505int ltt_tracefile_read_update_event(LttTracefile *tf)
1506{
1507 void * pos;
1508 LttEvent *event;
1509 void *pos_aligned;
1510
1511 event = &tf->event;
1512 pos = tf->buffer.head + event->offset;
1513
1514 /* Read event header */
1515
1516 /* Align the head */
1517 if(!tf->compact)
1518 pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->alignment);
1519 else {
1520 g_assert(tf->has_heartbeat);
1521 pos += ltt_align((size_t)pos, sizeof(uint32_t), tf->alignment);
1522 }
1523 pos_aligned = pos;
1524
1525 if(tf->has_heartbeat) {
1526 event->timestamp = ltt_get_uint32(LTT_GET_BO(tf),
1527 pos);
1528 if(!tf->compact) {
1529 /* 32 bits -> 64 bits tsc */
1530 /* note : still works for seek and non seek cases. */
1531 if(event->timestamp < (0xFFFFFFFFULL&tf->buffer.tsc)) {
1532 tf->buffer.tsc = ((tf->buffer.tsc&0xFFFFFFFF00000000ULL)
1533 + 0x100000000ULL)
1534 | (guint64)event->timestamp;
1535 event->tsc = tf->buffer.tsc;
1536 } else {
1537 /* no overflow */
1538 tf->buffer.tsc = (tf->buffer.tsc&0xFFFFFFFF00000000ULL)
1539 | (guint64)event->timestamp;
1540 event->tsc = tf->buffer.tsc;
1541 event->compact_data = 0;
1542 }
1543 } else {
1544 /* Compact header */
1545 /* We keep the LSB of the previous timestamp, to make sure
1546 * we never go back */
1547 event->event_id = event->timestamp >> tf->tscbits;
1548 event->event_id = event->event_id & ((1 << tf->compact_event_bits) - 1);
1549 event->compact_data = event->timestamp >>
1550 (tf->compact_event_bits + tf->tscbits);
1551 //printf("tsc bits %u, ev bits %u init data %u\n",
1552 // tf->tscbits, tf->trace->compact_event_bits, event->compact_data);
1553 /* Put the compact data back in original endianness */
1554 event->compact_data = ltt_get_uint32(LTT_GET_BO(tf), &event->compact_data);
1555 event->event_size = 0xFFFF;
1556 //printf("Found compact event %d\n", event->event_id);
1557 //printf("Compact data %d\n", event->compact_data);
1558 event->timestamp = event->timestamp << tf->tsc_lsb_truncate;
1559 event->timestamp = event->timestamp & tf->tsc_mask;
1560 //printf("timestamp 0x%lX\n", event->timestamp);
1561 //printf("mask 0x%llX\n", tf->tsc_mask);
1562 //printf("mask_next 0x%llX\n", tf->tsc_mask_next_bit);
1563 //printf("previous tsc 0x%llX\n", tf->buffer.tsc);
1564 //printf("previous tsc&mask 0x%llX\n", tf->tsc_mask&tf->buffer.tsc);
1565 //printf("previous tsc&(~mask) 0x%llX\n", tf->buffer.tsc&(~tf->tsc_mask));
1566 if(event->timestamp < (tf->tsc_mask&tf->buffer.tsc)) {
1567 //printf("wrap\n");
1568 tf->buffer.tsc = ((tf->buffer.tsc&(~tf->tsc_mask))
1569 + tf->tsc_mask_next_bit)
1570 | (guint64)event->timestamp;
1571 event->tsc = tf->buffer.tsc;
1572 } else {
1573 //printf("no wrap\n");
1574 /* no overflow */
1575 tf->buffer.tsc = (tf->buffer.tsc&(~tf->tsc_mask))
1576 | (guint64)event->timestamp;
1577 event->tsc = tf->buffer.tsc;
1578 }
1579 //printf("current tsc 0x%llX\n", tf->buffer.tsc);
1580 }
1581 pos += sizeof(guint32);
1582 } else {
1583 event->tsc = ltt_get_uint64(LTT_GET_BO(tf), pos);
1584 tf->buffer.tsc = event->tsc;
1585 event->compact_data = 0;
1586 pos += sizeof(guint64);
1587 }
1588 event->event_time = ltt_interpolate_time(tf, event);
1589
1590 if(!tf->compact) {
1591 event->event_id = ltt_get_uint16(LTT_GET_BO(tf), pos);
1592 pos += sizeof(guint16);
1593
1594 event->event_size = ltt_get_uint16(LTT_GET_BO(tf), pos);
1595 pos += sizeof(guint16);
1596 } else {
1597 /* Compact event */
1598 event->event_size = 0xFFFF;
1599 }
1600
1601 if (a_event_debug)
1602 print_debug_event_header(event, pos_aligned, pos);
1603
1604 /* Align the head */
1605 if(!tf->compact)
1606 pos += ltt_align((size_t)pos, tf->trace->arch_size, tf->alignment);
1607
1608 event->data = pos;
1609
1610 /* get the data size and update the event fields with the current
1611 * information. Also update the time if a heartbeat_full event is found. */
1612 ltt_update_event_size(tf);
1613
1614 return 0;
1615}
1616
1617
1618/****************************************************************************
1619 *Function name
1620 * map_block : map a block from the file
1621 *Input Params
1622 * lttdes : ltt trace file
1623 * whichBlock : the block which will be read
1624 *return value
1625 * 0 : success
1626 * EINVAL : lseek fail
1627 * EIO : can not read from the file
1628 ****************************************************************************/
1629
1630gint map_block(LttTracefile * tf, guint block_num)
1631{
1632 int page_size = getpagesize();
1633 struct ltt_block_start_header *header;
1634
1635 g_assert(block_num < tf->num_blocks);
1636
1637 if(tf->buffer.head != NULL) {
1638 if(munmap(tf->buffer.head, PAGE_ALIGN(tf->buf_size))) {
1639 g_warning("unmap size : %u\n",
1640 PAGE_ALIGN(tf->buf_size));
1641 perror("munmap error");
1642 g_assert(0);
1643 }
1644 }
1645
1646
1647 /* Multiple of pages aligned head */
1648 tf->buffer.head = mmap(0,
1649 PAGE_ALIGN(tf->buf_size),
1650 PROT_READ, MAP_PRIVATE, tf->fd,
1651 PAGE_ALIGN((off_t)tf->buf_size * (off_t)block_num));
1652
1653 if(tf->buffer.head == MAP_FAILED) {
1654 perror("Error in allocating memory for buffer of tracefile");
1655 g_assert(0);
1656 goto map_error;
1657 }
1658 g_assert( ( (gulong)tf->buffer.head&(8-1) ) == 0); // make sure it's aligned.
1659
1660
1661 tf->buffer.index = block_num;
1662
1663 header = (struct ltt_block_start_header*)tf->buffer.head;
1664
1665#if 0
1666 tf->buffer.begin.timestamp = ltt_time_add(
1667 ltt_time_from_uint64(
1668 ltt_get_uint64(LTT_GET_BO(tf),
1669 &header->begin.timestamp)
1670 - tf->trace->start_monotonic),
1671 tf->trace->start_time);
1672#endif //0
1673 //g_debug("block %u begin : %lu.%lu", block_num,
1674 // tf->buffer.begin.timestamp.tv_sec, tf->buffer.begin.timestamp.tv_nsec);
1675 tf->buffer.begin.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
1676 &header->begin.cycle_count);
1677 tf->buffer.begin.freq = ltt_get_uint64(LTT_GET_BO(tf),
1678 &header->begin.freq);
1679 if(tf->buffer.begin.freq == 0)
1680 tf->buffer.begin.freq = tf->trace->start_freq;
1681
1682 tf->buffer.begin.timestamp = ltt_interpolate_time_from_tsc(tf,
1683 tf->buffer.begin.cycle_count);
1684#if 0
1685 ltt_time_add(
1686 ltt_time_from_uint64(
1687 (double)(tf->buffer.begin.cycle_count
1688 - tf->trace->start_tsc) * 1000000.0
1689 / (double)tf->trace->start_freq),
1690 tf->trace->start_time_from_tsc);
1691#endif //0
1692#if 0
1693
1694 tf->buffer.end.timestamp = ltt_time_add(
1695 ltt_time_from_uint64(
1696 ltt_get_uint64(LTT_GET_BO(tf),
1697 &header->end.timestamp)
1698 - tf->trace->start_monotonic),
1699 tf->trace->start_time);
1700#endif //0
1701 //g_debug("block %u end : %lu.%lu", block_num,
1702 // tf->buffer.end.timestamp.tv_sec, tf->buffer.end.timestamp.tv_nsec);
1703 tf->buffer.end.cycle_count = ltt_get_uint64(LTT_GET_BO(tf),
1704 &header->end.cycle_count);
1705 tf->buffer.end.freq = ltt_get_uint64(LTT_GET_BO(tf),
1706 &header->end.freq);
1707 if(tf->buffer.end.freq == 0)
1708 tf->buffer.end.freq = tf->trace->start_freq;
1709
1710 tf->buffer.lost_size = ltt_get_uint32(LTT_GET_BO(tf),
1711 &header->lost_size);
1712 tf->buffer.end.timestamp = ltt_interpolate_time_from_tsc(tf,
1713 tf->buffer.end.cycle_count);
1714#if 0
1715 ltt_time_add(
1716 ltt_time_from_uint64(
1717 (double)(tf->buffer.end.cycle_count
1718 - tf->trace->start_tsc) * 1000000.0
1719 / (double)tf->trace->start_freq),
1720 tf->trace->start_time_from_tsc);
1721#endif //0
1722 tf->buffer.tsc = tf->buffer.begin.cycle_count;
1723 tf->event.tsc = tf->buffer.tsc;
1724 tf->buffer.freq = tf->buffer.begin.freq;
1725
1726 /* FIXME
1727 * eventually support variable buffer size : will need a partial pre-read of
1728 * the headers to create an index when we open the trace... eventually. */
1729 g_assert(tf->buf_size == ltt_get_uint32(LTT_GET_BO(tf),
1730 &header->buf_size));
1731
1732 /* Now that the buffer is mapped, calculate the time interpolation for the
1733 * block. */
1734
1735// tf->buffer.nsecs_per_cycle = calc_nsecs_per_cycle(tf);
1736 //tf->buffer.cyc2ns_scale = calc_nsecs_per_cycle(tf);
1737
1738 /* Make the current event point to the beginning of the buffer :
1739 * it means that the event read must get the first event. */
1740 tf->event.tracefile = tf;
1741 tf->event.block = block_num;
1742 tf->event.offset = 0;
1743
1744 return 0;
1745
1746map_error:
1747 return -errno;
1748
1749}
1750
1751static void print_debug_event_data(LttEvent *ev)
1752{
1753 unsigned int offset = 0;
1754 int i, j;
1755
1756 if (!max(ev->event_size, ev->data_size))
1757 return;
1758
1759 g_printf("Event data (tracefile %s offset %llx):\n",
1760 g_quark_to_string(ev->tracefile->long_name),
1761 ((uint64_t)ev->tracefile->buffer.index * ev->tracefile->buf_size)
1762 + (long)ev->data - (long)ev->tracefile->buffer.head);
1763
1764 while (offset < max(ev->event_size, ev->data_size)) {
1765 g_printf("%8lx", (long)ev->data + offset
1766 - (long)ev->tracefile->buffer.head);
1767 g_printf(" ");
1768
1769 for (i = 0; i < 4 ; i++) {
1770 for (j = 0; j < 4; j++) {
1771 if (offset + ((i * 4) + j) < max(ev->event_size, ev->data_size))
1772 g_printf("%02hhX", ((char*)ev->data)[offset + ((i * 4) + j)]);
1773 else
1774 g_printf(" ");
1775 g_printf(" ");
1776 }
1777 if (i < 4)
1778 g_printf(" ");
1779 }
1780
1781 g_printf(" ");
1782
1783 for (i = 0; i < 4; i++) {
1784 for (j = 0; j < 4; j++) {
1785 if (offset + ((i * 4) + j) < max(ev->event_size, ev->data_size)) {
1786 if (isprint(((char*)ev->data)[offset + ((i * 4) + j)]))
1787 g_printf("%c", ((char*)ev->data)[offset + ((i * 4) + j)]);
1788 else
1789 g_printf(".");
1790 } else
1791 g_printf(" ");
1792 }
1793 }
1794 offset+=16;
1795 g_printf("\n");
1796 }
1797}
1798
1799/* It will update the fields offsets too */
1800void ltt_update_event_size(LttTracefile *tf)
1801{
1802 off_t size = 0;
1803 char *tscdata;
1804 struct marker_info *info;
1805
1806 switch((enum marker_id)tf->event.event_id) {
1807 case MARKER_ID_SET_MARKER_ID:
1808 size = strlen((char*)tf->event.data) + 1;
1809 g_debug("marker %s id set", (char*)tf->event.data);
1810 size += ltt_align(size, sizeof(guint16), tf->alignment);
1811 size += sizeof(guint16);
1812 size += sizeof(guint8);
1813 size += sizeof(guint8);
1814 size += sizeof(guint8);
1815 size += sizeof(guint8);
1816 size += sizeof(guint8);
1817 break;
1818 case MARKER_ID_SET_MARKER_FORMAT:
1819 g_debug("marker %s format set", (char*)tf->event.data);
1820 size = strlen((char*)tf->event.data) + 1;
1821 size += strlen((char*)tf->event.data + size) + 1;
1822 break;
1823 case MARKER_ID_HEARTBEAT_32:
1824 g_debug("Update Event heartbeat 32 bits");
1825 break;
1826 case MARKER_ID_HEARTBEAT_64:
1827 g_debug("Update Event heartbeat 64 bits");
1828 tscdata = (char*)(tf->event.data);
1829 tf->event.tsc = ltt_get_uint64(LTT_GET_BO(tf), tscdata);
1830 tf->buffer.tsc = tf->event.tsc;
1831 tf->event.event_time = ltt_interpolate_time(tf, &tf->event);
1832 size = ltt_align(size, sizeof(guint64), tf->alignment);
1833 size += sizeof(guint64);
1834 break;
1835 }
1836
1837 info = marker_get_info_from_id(tf->trace, tf->event.event_id);
1838
1839 if (tf->event.event_id >= MARKER_CORE_IDS)
1840 g_assert(info != NULL);
1841
1842 /* Do not update field offsets of core markers when initially reading the
1843 * facility tracefile when the infos about these markers do not exist yet.
1844 */
1845 if (likely(info && info->fields)) {
1846 if (info->size != -1)
1847 size = info->size;
1848 else
1849 size = marker_update_fields_offsets(marker_get_info_from_id(tf->trace,
1850 tf->event.event_id), tf->event.data);
1851 }
1852
1853 tf->event.data_size = size;
1854
1855 /* Check consistency between kernel and LTTV structure sizes */
1856 if(tf->event.event_size == 0xFFFF) {
1857 /* Event size too big to fit in the event size field */
1858 tf->event.event_size = tf->event.data_size;
1859 }
1860
1861 if (a_event_debug)
1862 print_debug_event_data(&tf->event);
1863
1864 /* Having a marker load or marker format event out of the facilities
1865 * tracefiles is a serious bug. */
1866 switch((enum marker_id)tf->event.event_id) {
1867 case MARKER_ID_SET_MARKER_ID:
1868 case MARKER_ID_SET_MARKER_FORMAT:
1869 if (tf->name != g_quark_from_string("/control/facilities"))
1870 g_error("Trace inconsistency : metadata event found in data "
1871 "tracefile %s", g_quark_to_string(tf->long_name));
1872 }
1873
1874 if (tf->event.data_size != tf->event.event_size) {
1875 struct marker_info *info = marker_get_info_from_id(tf->trace,
1876 tf->event.event_id);
1877 g_error("Kernel/LTTV event size differs for event %s: kernel %u, LTTV %u",
1878 g_quark_to_string(info->name),
1879 tf->event.event_size, tf->event.data_size);
1880 exit(-1);
1881 }
1882}
1883
1884
1885/* Take the tf current event offset and use the event facility id and event id
1886 * to figure out where is the next event offset.
1887 *
1888 * This is an internal function not aiming at being used elsewhere : it will
1889 * not jump over the current block limits. Please consider using
1890 * ltt_tracefile_read to do this.
1891 *
1892 * Returns 0 on success
1893 * ERANGE if we are at the end of the buffer.
1894 * ENOPROTOOPT if an error occured when getting the current event size.
1895 */
1896int ltt_seek_next_event(LttTracefile *tf)
1897{
1898 int ret = 0;
1899 void *pos;
1900
1901 /* seek over the buffer header if we are at the buffer start */
1902 if(tf->event.offset == 0) {
1903 tf->event.offset += tf->buffer_header_size;
1904
1905 if(tf->event.offset == tf->buf_size - tf->buffer.lost_size) {
1906 ret = ERANGE;
1907 }
1908 goto found;
1909 }
1910
1911
1912 pos = tf->event.data;
1913
1914 if(tf->event.data_size < 0) goto error;
1915
1916 pos += (size_t)tf->event.data_size;
1917
1918 tf->event.offset = pos - tf->buffer.head;
1919
1920 if(tf->event.offset == tf->buf_size - tf->buffer.lost_size) {
1921 ret = ERANGE;
1922 goto found;
1923 }
1924 g_assert(tf->event.offset < tf->buf_size - tf->buffer.lost_size);
1925
1926found:
1927 return ret;
1928
1929error:
1930 g_error("Error in ltt_seek_next_event for tracefile %s",
1931 g_quark_to_string(tf->name));
1932 return ENOPROTOOPT;
1933}
1934
1935#if 0
1936/*****************************************************************************
1937 *Function name
1938 * calc_nsecs_per_cycle : calculate nsecs per cycle for current block
1939 *
1940 * 1.0 / (freq(khz) *1000) * 1000000000
1941 *Input Params
1942 * t : tracefile
1943 ****************************************************************************/
1944/* from timer_tsc.c */
1945#define CYC2NS_SCALE_FACTOR 10
1946static guint32 calc_nsecs_per_cycle(LttTracefile * tf)
1947{
1948 //return 1e6 / (double)tf->buffer.freq;
1949 guint32 cpu_mhz = tf->buffer.freq / 1000;
1950 guint32 cyc2ns_scale = (1000 << CYC2NS_SCALE_FACTOR)/cpu_mhz;
1951
1952 return cyc2ns_scale;
1953 // return 1e6 / (double)tf->buffer.freq;
1954}
1955
1956static guint64 cycles_2_ns(LttTracefile *tf, guint64 cycles)
1957{
1958 return (cycles * tf->buffer.cyc2ns_scale) >> CYC2NS_SCALE_FACTOR;
1959}
1960#endif //0
1961
1962#if 0
1963void setFieldsOffset(LttTracefile *tf, LttEventType *evT,void *evD)
1964{
1965 LttField * rootFld = evT->root_field;
1966 // rootFld->base_address = evD;
1967
1968 if(likely(rootFld))
1969 rootFld->field_size = getFieldtypeSize(tf, evT->facility,
1970 evT, 0,0,rootFld, evD);
1971}
1972#endif //0
1973#if 0
1974/*****************************************************************************
1975 *Function name
1976 * set_fields_offsets : set the precomputable offset of the fields
1977 *Input params
1978 * tracefile : opened trace file
1979 * event_type : the event type
1980 ****************************************************************************/
1981
1982void set_fields_offsets(LttTracefile *tf, LttEventType *event_type)
1983{
1984 LttField *field = event_type->root_field;
1985 enum field_status fixed_root = FIELD_FIXED, fixed_parent = FIELD_FIXED;
1986
1987 if(likely(field))
1988 preset_field_type_size(tf, event_type, 0, 0,
1989 &fixed_root, &fixed_parent,
1990 field);
1991
1992}
1993#endif //0
1994
1995
1996/*****************************************************************************
1997 *Function name
1998 * get_alignment : Get the alignment needed for a field.
1999 *Input params
2000 * field : field
2001 *
2002 * returns : The size on which it must be aligned.
2003 *
2004 ****************************************************************************/
2005#if 0
2006off_t get_alignment(LttField *field)
2007{
2008 LttType *type = &field->field_type;
2009
2010 switch(type->type_class) {
2011 case LTT_INT_FIXED:
2012 case LTT_UINT_FIXED:
2013 case LTT_POINTER:
2014 case LTT_CHAR:
2015 case LTT_UCHAR:
2016 case LTT_SHORT:
2017 case LTT_USHORT:
2018 case LTT_INT:
2019 case LTT_UINT:
2020 case LTT_LONG:
2021 case LTT_ULONG:
2022 case LTT_SIZE_T:
2023 case LTT_SSIZE_T:
2024 case LTT_OFF_T:
2025 case LTT_FLOAT:
2026 case LTT_ENUM:
2027 /* Align offset on type size */
2028 g_assert(field->field_size != 0);
2029 return field->field_size;
2030 break;
2031 case LTT_STRING:
2032 return 1;
2033 break;
2034 case LTT_ARRAY:
2035 g_assert(type->fields->len == 1);
2036 {
2037 LttField *child = &g_array_index(type->fields, LttField, 0);
2038 return get_alignment(child);
2039 }
2040 break;
2041 case LTT_SEQUENCE:
2042 g_assert(type->fields->len == 2);
2043 {
2044 off_t localign = 1;
2045 LttField *child = &g_array_index(type->fields, LttField, 0);
2046
2047 localign = max(localign, get_alignment(child));
2048
2049 child = &g_array_index(type->fields, LttField, 1);
2050 localign = max(localign, get_alignment(child));
2051
2052 return localign;
2053 }
2054 break;
2055 case LTT_STRUCT:
2056 case LTT_UNION:
2057 {
2058 guint i;
2059 off_t localign = 1;
2060
2061 for(i=0; i<type->fields->len; i++) {
2062 LttField *child = &g_array_index(type->fields, LttField, i);
2063 localign = max(localign, get_alignment(child));
2064 }
2065 return localign;
2066 }
2067 break;
2068 case LTT_NONE:
2069 default:
2070 g_error("get_alignment : unknown type");
2071 return -1;
2072 }
2073}
2074
2075#endif //0
2076
2077/*****************************************************************************
2078 *Function name
2079 * field_compute_static_size : Determine the size of fields known by their
2080 * sole definition. Unions, arrays and struct sizes might be known, but
2081 * the parser does not give that information.
2082 *Input params
2083 * tf : tracefile
2084 * field : field
2085 *
2086 ****************************************************************************/
2087#if 0
2088void field_compute_static_size(LttFacility *fac, LttField *field)
2089{
2090 LttType *type = &field->field_type;
2091
2092 switch(type->type_class) {
2093 case LTT_INT_FIXED:
2094 case LTT_UINT_FIXED:
2095 case LTT_POINTER:
2096 case LTT_CHAR:
2097 case LTT_UCHAR:
2098 case LTT_SHORT:
2099 case LTT_USHORT:
2100 case LTT_INT:
2101 case LTT_UINT:
2102 case LTT_LONG:
2103 case LTT_ULONG:
2104 case LTT_SIZE_T:
2105 case LTT_SSIZE_T:
2106 case LTT_OFF_T:
2107 case LTT_FLOAT:
2108 case LTT_ENUM:
2109 case LTT_STRING:
2110 /* nothing to do */
2111 break;
2112 case LTT_ARRAY:
2113 /* note this : array type size is the number of elements in the array,
2114 * while array field size of the length of the array in bytes */
2115 g_assert(type->fields->len == 1);
2116 {
2117 LttField *child = &g_array_index(type->fields, LttField, 0);
2118 field_compute_static_size(fac, child);
2119
2120 if(child->field_size != 0) {
2121 field->field_size = type->size * child->field_size;
2122 field->dynamic_offsets = g_array_sized_new(FALSE, TRUE,
2123 sizeof(off_t), type->size);
2124 } else {
2125 field->field_size = 0;
2126 }
2127 }
2128 break;
2129 case LTT_SEQUENCE:
2130 g_assert(type->fields->len == 2);
2131 {
2132 off_t local_offset = 0;
2133 LttField *child = &g_array_index(type->fields, LttField, 1);
2134 field_compute_static_size(fac, child);
2135 field->field_size = 0;
2136 type->size = 0;
2137 if(child->field_size != 0) {
2138 field->dynamic_offsets = g_array_sized_new(FALSE, TRUE,
2139 sizeof(off_t), SEQUENCE_AVG_ELEMENTS);
2140 }
2141 }
2142 break;
2143 case LTT_STRUCT:
2144 case LTT_UNION:
2145 {
2146 guint i;
2147 for(i=0;i<type->fields->len;i++) {
2148 LttField *child = &g_array_index(type->fields, LttField, i);
2149 field_compute_static_size(fac, child);
2150 if(child->field_size != 0) {
2151 type->size += ltt_align(type->size, get_alignment(child),
2152 fac->alignment);
2153 type->size += child->field_size;
2154 } else {
2155 /* As soon as we find a child with variable size, we have
2156 * a variable size */
2157 type->size = 0;
2158 break;
2159 }
2160 }
2161 field->field_size = type->size;
2162 }
2163 break;
2164 default:
2165 g_error("field_static_size : unknown type");
2166 }
2167
2168}
2169#endif //0
2170
2171
2172/*****************************************************************************
2173 *Function name
2174 * precompute_fields_offsets : set the precomputable offset of the fields
2175 *Input params
2176 * fac : facility
2177 * field : the field
2178 * offset : pointer to the current offset, must be incremented
2179 *
2180 * return : 1 : found a variable length field, stop the processing.
2181 * 0 otherwise.
2182 ****************************************************************************/
2183
2184#if 0
2185gint precompute_fields_offsets(LttFacility *fac, LttField *field, off_t *offset, gint is_compact)
2186{
2187 LttType *type = &field->field_type;
2188
2189 if(unlikely(is_compact)) {
2190 g_assert(field->field_size != 0);
2191 /* FIXME THIS IS A HUUUUUGE hack :
2192 * offset is between the compact_data field in struct LttEvent
2193 * and the address of the field root in the memory map.
2194 * ark. Both will stay at the same addresses while the event
2195 * is readable, so it's ok.
2196 */
2197 field->offset_root = 0;
2198 field->fixed_root = FIELD_FIXED;
2199 return 0;
2200 }
2201
2202 switch(type->type_class) {
2203 case LTT_INT_FIXED:
2204 case LTT_UINT_FIXED:
2205 case LTT_POINTER:
2206 case LTT_CHAR:
2207 case LTT_UCHAR:
2208 case LTT_SHORT:
2209 case LTT_USHORT:
2210 case LTT_INT:
2211 case LTT_UINT:
2212 case LTT_LONG:
2213 case LTT_ULONG:
2214 case LTT_SIZE_T:
2215 case LTT_SSIZE_T:
2216 case LTT_OFF_T:
2217 case LTT_FLOAT:
2218 case LTT_ENUM:
2219 g_assert(field->field_size != 0);
2220 /* Align offset on type size */
2221 *offset += ltt_align(*offset, get_alignment(field),
2222 fac->alignment);
2223 /* remember offset */
2224 field->offset_root = *offset;
2225 field->fixed_root = FIELD_FIXED;
2226 /* Increment offset */
2227 *offset += field->field_size;
2228 return 0;
2229 break;
2230 case LTT_STRING:
2231 field->offset_root = *offset;
2232 field->fixed_root = FIELD_FIXED;
2233 return 1;
2234 break;
2235 case LTT_ARRAY:
2236 g_assert(type->fields->len == 1);
2237 {
2238 LttField *child = &g_array_index(type->fields, LttField, 0);
2239
2240 *offset += ltt_align(*offset, get_alignment(field),
2241 fac->alignment);
2242
2243 /* remember offset */
2244 field->offset_root = *offset;
2245 field->array_offset = *offset;
2246 field->fixed_root = FIELD_FIXED;
2247
2248 /* Let the child be variable */
2249 //precompute_fields_offsets(tf, child, offset);
2250
2251 if(field->field_size != 0) {
2252 /* Increment offset */
2253 /* field_size is the array size in bytes */
2254 *offset += field->field_size;
2255 return 0;
2256 } else {
2257 return 1;
2258 }
2259 }
2260 break;
2261 case LTT_SEQUENCE:
2262 g_assert(type->fields->len == 2);
2263 {
2264 LttField *child;
2265 guint ret;
2266
2267 *offset += ltt_align(*offset, get_alignment(field),
2268 fac->alignment);
2269
2270 /* remember offset */
2271 field->offset_root = *offset;
2272 field->fixed_root = FIELD_FIXED;
2273
2274 child = &g_array_index(type->fields, LttField, 0);
2275 ret = precompute_fields_offsets(fac, child, offset, is_compact);
2276 g_assert(ret == 0); /* Seq len cannot have variable len */
2277
2278 child = &g_array_index(type->fields, LttField, 1);
2279 *offset += ltt_align(*offset, get_alignment(child),
2280 fac->alignment);
2281 field->array_offset = *offset;
2282 /* Let the child be variable. */
2283 //ret = precompute_fields_offsets(fac, child, offset);
2284
2285 /* Cannot precompute fields offsets of sequence members, and has
2286 * variable length. */
2287 return 1;
2288 }
2289 break;
2290 case LTT_STRUCT:
2291 {
2292 LttField *child;
2293 guint i;
2294 gint ret=0;
2295
2296 *offset += ltt_align(*offset, get_alignment(field),
2297 fac->alignment);
2298 /* remember offset */
2299 field->offset_root = *offset;
2300 field->fixed_root = FIELD_FIXED;
2301
2302 for(i=0; i< type->fields->len; i++) {
2303 child = &g_array_index(type->fields, LttField, i);
2304 ret = precompute_fields_offsets(fac, child, offset, is_compact);
2305
2306 if(ret) break;
2307 }
2308 return ret;
2309 }
2310 break;
2311 case LTT_UNION:
2312 {
2313 LttField *child;
2314 guint i;
2315 gint ret=0;
2316
2317 *offset += ltt_align(*offset, get_alignment(field),
2318 fac->alignment);
2319 /* remember offset */
2320 field->offset_root = *offset;
2321 field->fixed_root = FIELD_FIXED;
2322
2323 for(i=0; i< type->fields->len; i++) {
2324 *offset = field->offset_root;
2325 child = &g_array_index(type->fields, LttField, i);
2326 ret = precompute_fields_offsets(fac, child, offset, is_compact);
2327
2328 if(ret) break;
2329 }
2330 *offset = field->offset_root + field->field_size;
2331 return ret;
2332 }
2333
2334 break;
2335 case LTT_NONE:
2336 default:
2337 g_error("precompute_fields_offsets : unknown type");
2338 return 1;
2339 }
2340
2341}
2342
2343#endif //0
2344
2345#if 0
2346/*****************************************************************************
2347 *Function name
2348 * precompute_offsets : set the precomputable offset of an event type
2349 *Input params
2350 * tf : tracefile
2351 * event : event type
2352 *
2353 ****************************************************************************/
2354void precompute_offsets(LttFacility *fac, LttEventType *event)
2355{
2356 guint i;
2357 off_t offset = 0;
2358 gint ret;
2359
2360 /* First, compute the size of fixed size fields. Will determine size for
2361 * arrays, struct and unions, which is not done by the parser */
2362 for(i=0; i<event->fields->len; i++) {
2363 LttField *field = &g_array_index(event->fields, LttField, i);
2364 field_compute_static_size(fac, field);
2365 }
2366
2367 /* Precompute all known offsets */
2368 for(i=0; i<event->fields->len; i++) {
2369 LttField *field = &g_array_index(event->fields, LttField, i);
2370 if(event->has_compact_data && i == 0)
2371 ret = precompute_fields_offsets(fac, field, &offset, 1);
2372 else
2373 ret = precompute_fields_offsets(fac, field, &offset, 0);
2374 if(ret) break;
2375 }
2376}
2377#endif //0
2378
2379
2380
2381/*****************************************************************************
2382 *Function name
2383 * preset_field_type_size : set the fixed sizes of the field type
2384 *Input params
2385 * tf : tracefile
2386 * event_type : event type
2387 * offset_root : offset from the root
2388 * offset_parent : offset from the parent
2389 * fixed_root : Do we know a fixed offset to the root ?
2390 * fixed_parent : Do we know a fixed offset to the parent ?
2391 * field : field
2392 ****************************************************************************/
2393
2394
2395
2396// preset the fixed size offsets. Calculate them just like genevent-new : an
2397// increment of a *to value that represents the offset from the start of the
2398// event data.
2399// The preset information is : offsets up to (and including) the first element
2400// of variable size. All subsequent fields must be flagged "VARIABLE OFFSET".
2401#if 0
2402void preset_field_type_size(LttTracefile *tf, LttEventType *event_type,
2403 off_t offset_root, off_t offset_parent,
2404 enum field_status *fixed_root, enum field_status *fixed_parent,
2405 LttField *field)
2406{
2407 enum field_status local_fixed_root, local_fixed_parent;
2408 guint i;
2409 LttType *type;
2410
2411 g_assert(field->fixed_root == FIELD_UNKNOWN);
2412 g_assert(field->fixed_parent == FIELD_UNKNOWN);
2413 g_assert(field->fixed_size == FIELD_UNKNOWN);
2414
2415 type = field->field_type;
2416
2417 field->fixed_root = *fixed_root;
2418 if(field->fixed_root == FIELD_FIXED)
2419 field->offset_root = offset_root;
2420 else
2421 field->offset_root = 0;
2422
2423 field->fixed_parent = *fixed_parent;
2424 if(field->fixed_parent == FIELD_FIXED)
2425 field->offset_parent = offset_parent;
2426 else
2427 field->offset_parent = 0;
2428
2429 size_t current_root_offset;
2430 size_t current_offset;
2431 enum field_status current_child_status, final_child_status;
2432 size_t max_size;
2433
2434 switch(type->type_class) {
2435 case LTT_INT_FIXED:
2436 case LTT_UINT_FIXED:
2437 case LTT_CHAR:
2438 case LTT_UCHAR:
2439 case LTT_SHORT:
2440 case LTT_USHORT:
2441 case LTT_INT:
2442 case LTT_UINT:
2443 case LTT_FLOAT:
2444 case LTT_ENUM:
2445 field->field_size = ltt_type_size(tf->trace, type);
2446 field->fixed_size = FIELD_FIXED;
2447 break;
2448 case LTT_POINTER:
2449 field->field_size = (off_t)event_type->facility->pointer_size;
2450 field->fixed_size = FIELD_FIXED;
2451 break;
2452 case LTT_LONG:
2453 case LTT_ULONG:
2454 field->field_size = (off_t)event_type->facility->long_size;
2455 field->fixed_size = FIELD_FIXED;
2456 break;
2457 case LTT_SIZE_T:
2458 case LTT_SSIZE_T:
2459 case LTT_OFF_T:
2460 field->field_size = (off_t)event_type->facility->size_t_size;
2461 field->fixed_size = FIELD_FIXED;
2462 break;
2463 case LTT_SEQUENCE:
2464 local_fixed_root = FIELD_VARIABLE;
2465 local_fixed_parent = FIELD_VARIABLE;
2466 preset_field_type_size(tf, event_type,
2467 0, 0,
2468 &local_fixed_root, &local_fixed_parent,
2469 field->child[0]);
2470 field->fixed_size = FIELD_VARIABLE;
2471 field->field_size = 0;
2472 *fixed_root = FIELD_VARIABLE;
2473 *fixed_parent = FIELD_VARIABLE;
2474 break;
2475 case LTT_STRING:
2476 field->fixed_size = FIELD_VARIABLE;
2477 field->field_size = 0;
2478 *fixed_root = FIELD_VARIABLE;
2479 *fixed_parent = FIELD_VARIABLE;
2480 break;
2481 case LTT_ARRAY:
2482 local_fixed_root = FIELD_VARIABLE;
2483 local_fixed_parent = FIELD_VARIABLE;
2484 preset_field_type_size(tf, event_type,
2485 0, 0,
2486 &local_fixed_root, &local_fixed_parent,
2487 field->child[0]);
2488 field->fixed_size = field->child[0]->fixed_size;
2489 if(field->fixed_size == FIELD_FIXED) {
2490 field->field_size = type->element_number * field->child[0]->field_size;
2491 } else {
2492 field->field_size = 0;
2493 *fixed_root = FIELD_VARIABLE;
2494 *fixed_parent = FIELD_VARIABLE;
2495 }
2496 break;
2497 case LTT_STRUCT:
2498 current_root_offset = field->offset_root;
2499 current_offset = 0;
2500 current_child_status = FIELD_FIXED;
2501 for(i=0;i<type->element_number;i++) {
2502 preset_field_type_size(tf, event_type,
2503 current_root_offset, current_offset,
2504 fixed_root, &current_child_status,
2505 field->child[i]);
2506 if(current_child_status == FIELD_FIXED) {
2507 current_root_offset += field->child[i]->field_size;
2508 current_offset += field->child[i]->field_size;
2509 } else {
2510 current_root_offset = 0;
2511 current_offset = 0;
2512 }
2513 }
2514 if(current_child_status != FIELD_FIXED) {
2515 *fixed_parent = current_child_status;
2516 field->field_size = 0;
2517 field->fixed_size = current_child_status;
2518 } else {
2519 field->field_size = current_offset;
2520 field->fixed_size = FIELD_FIXED;
2521 }
2522 break;
2523 case LTT_UNION:
2524 current_root_offset = field->offset_root;
2525 current_offset = 0;
2526 max_size = 0;
2527 final_child_status = FIELD_FIXED;
2528 for(i=0;i<type->element_number;i++) {
2529 enum field_status current_root_child_status = FIELD_FIXED;
2530 enum field_status current_child_status = FIELD_FIXED;
2531 preset_field_type_size(tf, event_type,
2532 current_root_offset, current_offset,
2533 &current_root_child_status, &current_child_status,
2534 field->child[i]);
2535 if(current_child_status != FIELD_FIXED)
2536 final_child_status = current_child_status;
2537 else
2538 max_size = max(max_size, field->child[i]->field_size);
2539 }
2540 if(final_child_status != FIELD_FIXED) {
2541 g_error("LTTV does not support variable size fields in unions.");
2542 /* This will stop the application. */
2543 *fixed_root = final_child_status;
2544 *fixed_parent = final_child_status;
2545 field->field_size = 0;
2546 field->fixed_size = current_child_status;
2547 } else {
2548 field->field_size = max_size;
2549 field->fixed_size = FIELD_FIXED;
2550 }
2551 break;
2552 case LTT_NONE:
2553 g_error("unexpected type NONE");
2554 break;
2555 }
2556
2557}
2558#endif //0
2559
2560/*****************************************************************************
2561 *Function name
2562 * check_fields_compatibility : Check for compatibility between two fields :
2563 * do they use the same inner structure ?
2564 *Input params
2565 * event_type1 : event type
2566 * event_type2 : event type
2567 * field1 : field
2568 * field2 : field
2569 *Returns : 0 if identical
2570 * 1 if not.
2571 ****************************************************************************/
2572// this function checks for equality of field types. Therefore, it does not use
2573// per se offsets. For instance, an aligned version of a structure is
2574// compatible with an unaligned version of the same structure.
2575#if 0
2576gint check_fields_compatibility(LttEventType *event_type1,
2577 LttEventType *event_type2,
2578 LttField *field1, LttField *field2)
2579{
2580 guint different = 0;
2581 LttType *type1;
2582 LttType *type2;
2583
2584 if(field1 == NULL) {
2585 if(field2 == NULL) goto end;
2586 else {
2587 different = 1;
2588 goto end;
2589 }
2590 } else if(field2 == NULL) {
2591 different = 1;
2592 goto end;
2593 }
2594
2595 type1 = &field1->field_type;
2596 type2 = &field2->field_type;
2597
2598 if(type1->type_class != type2->type_class) {
2599 different = 1;
2600 goto end;
2601 }
2602 if(type1->network != type2->network) {
2603 different = 1;
2604 goto end;
2605 }
2606
2607 switch(type1->type_class) {
2608 case LTT_INT_FIXED:
2609 case LTT_UINT_FIXED:
2610 case LTT_POINTER:
2611 case LTT_CHAR:
2612 case LTT_UCHAR:
2613 case LTT_SHORT:
2614 case LTT_USHORT:
2615 case LTT_INT:
2616 case LTT_UINT:
2617 case LTT_LONG:
2618 case LTT_ULONG:
2619 case LTT_SIZE_T:
2620 case LTT_SSIZE_T:
2621 case LTT_OFF_T:
2622 case LTT_FLOAT:
2623 case LTT_ENUM:
2624 if(field1->field_size != field2->field_size)
2625 different = 1;
2626 break;
2627 case LTT_STRING:
2628 break;
2629 case LTT_ARRAY:
2630 {
2631 LttField *child1 = &g_array_index(type1->fields, LttField, 0);
2632 LttField *child2 = &g_array_index(type2->fields, LttField, 0);
2633
2634 if(type1->size != type2->size)
2635 different = 1;
2636 if(check_fields_compatibility(event_type1, event_type2, child1, child2))
2637 different = 1;
2638 }
2639 break;
2640 case LTT_SEQUENCE:
2641 {
2642 LttField *child1 = &g_array_index(type1->fields, LttField, 1);
2643 LttField *child2 = &g_array_index(type2->fields, LttField, 1);
2644
2645 if(check_fields_compatibility(event_type1, event_type2, child1, child2))
2646 different = 1;
2647 }
2648 break;
2649 case LTT_STRUCT:
2650 case LTT_UNION:
2651 {
2652 LttField *child;
2653 guint i;
2654
2655 if(type1->fields->len != type2->fields->len) {
2656 different = 1;
2657 goto end;
2658 }
2659
2660 for(i=0; i< type1->fields->len; i++) {
2661 LttField *child1;
2662 LttField *child2;
2663 child1 = &g_array_index(type1->fields, LttField, i);
2664 child2 = &g_array_index(type2->fields, LttField, i);
2665 different = check_fields_compatibility(event_type1,
2666 event_type2, child1, child2);
2667
2668 if(different) break;
2669 }
2670 }
2671 break;
2672 case LTT_NONE:
2673 default:
2674 g_error("check_fields_compatibility : unknown type");
2675 }
2676
2677end:
2678 return different;
2679}
2680#endif //0
2681
2682#if 0
2683gint check_fields_compatibility(LttEventType *event_type1,
2684 LttEventType *event_type2,
2685 LttField *field1, LttField *field2)
2686{
2687 guint different = 0;
2688 guint i;
2689 LttType *type1;
2690 LttType *type2;
2691
2692 if(field1 == NULL) {
2693 if(field2 == NULL) goto end;
2694 else {
2695 different = 1;
2696 goto end;
2697 }
2698 } else if(field2 == NULL) {
2699 different = 1;
2700 goto end;
2701 }
2702
2703 g_assert(field1->fixed_root != FIELD_UNKNOWN);
2704 g_assert(field2->fixed_root != FIELD_UNKNOWN);
2705 g_assert(field1->fixed_parent != FIELD_UNKNOWN);
2706 g_assert(field2->fixed_parent != FIELD_UNKNOWN);
2707 g_assert(field1->fixed_size != FIELD_UNKNOWN);
2708 g_assert(field2->fixed_size != FIELD_UNKNOWN);
2709
2710 type1 = field1->field_type;
2711 type2 = field2->field_type;
2712
2713 if(type1->type_class != type2->type_class) {
2714 different = 1;
2715 goto end;
2716 }
2717 if(type1->element_name != type2->element_name) {
2718 different = 1;
2719 goto end;
2720 }
2721
2722 switch(type1->type_class) {
2723 case LTT_INT_FIXED:
2724 case LTT_UINT_FIXED:
2725 case LTT_POINTER:
2726 case LTT_CHAR:
2727 case LTT_UCHAR:
2728 case LTT_SHORT:
2729 case LTT_USHORT:
2730 case LTT_INT:
2731 case LTT_UINT:
2732 case LTT_FLOAT:
2733 case LTT_POINTER:
2734 case LTT_LONG:
2735 case LTT_ULONG:
2736 case LTT_SIZE_T:
2737 case LTT_SSIZE_T:
2738 case LTT_OFF_T:
2739 if(field1->field_size != field2->field_size) {
2740 different = 1;
2741 goto end;
2742 }
2743 break;
2744 case LTT_ENUM:
2745 if(type1->element_number != type2->element_number) {
2746 different = 1;
2747 goto end;
2748 }
2749 for(i=0;i<type1->element_number;i++) {
2750 if(type1->enum_strings[i] != type2->enum_strings[i]) {
2751 different = 1;
2752 goto end;
2753 }
2754 }
2755 break;
2756 case LTT_SEQUENCE:
2757 /* Two elements : size and child */
2758 g_assert(type1->element_number != type2->element_number);
2759 for(i=0;i<type1->element_number;i++) {
2760 if(check_fields_compatibility(event_type1, event_type2,
2761 field1->child[0], field2->child[0])) {
2762 different = 1;
2763 goto end;
2764 }
2765 }
2766 break;
2767 case LTT_STRING:
2768 break;
2769 case LTT_ARRAY:
2770 if(field1->field_size != field2->field_size) {
2771 different = 1;
2772 goto end;
2773 }
2774 /* Two elements : size and child */
2775 g_assert(type1->element_number != type2->element_number);
2776 for(i=0;i<type1->element_number;i++) {
2777 if(check_fields_compatibility(event_type1, event_type2,
2778 field1->child[0], field2->child[0])) {
2779 different = 1;
2780 goto end;
2781 }
2782 }
2783 break;
2784 case LTT_STRUCT:
2785 case LTT_UNION:
2786 if(type1->element_number != type2->element_number) {
2787 different = 1;
2788 break;
2789 }
2790 for(i=0;i<type1->element_number;i++) {
2791 if(check_fields_compatibility(event_type1, event_type2,
2792 field1->child[0], field2->child[0])) {
2793 different = 1;
2794 goto end;
2795 }
2796 }
2797 break;
2798 }
2799end:
2800 return different;
2801}
2802#endif //0
2803
2804
2805/*****************************************************************************
2806 *Function name
2807 * ltt_get_int : get an integer number
2808 *Input params
2809 * reverse_byte_order: must we reverse the byte order ?
2810 * size : the size of the integer
2811 * ptr : the data pointer
2812 *Return value
2813 * gint64 : a 64 bits integer
2814 ****************************************************************************/
2815
2816gint64 ltt_get_int(gboolean reverse_byte_order, gint size, void *data)
2817{
2818 gint64 val;
2819
2820 switch(size) {
2821 case 1: val = *((gint8*)data); break;
2822 case 2: val = ltt_get_int16(reverse_byte_order, data); break;
2823 case 4: val = ltt_get_int32(reverse_byte_order, data); break;
2824 case 8: val = ltt_get_int64(reverse_byte_order, data); break;
2825 default: val = ltt_get_int64(reverse_byte_order, data);
2826 g_critical("get_int : integer size %d unknown", size);
2827 break;
2828 }
2829
2830 return val;
2831}
2832
2833/*****************************************************************************
2834 *Function name
2835 * ltt_get_uint : get an unsigned integer number
2836 *Input params
2837 * reverse_byte_order: must we reverse the byte order ?
2838 * size : the size of the integer
2839 * ptr : the data pointer
2840 *Return value
2841 * guint64 : a 64 bits unsigned integer
2842 ****************************************************************************/
2843
2844guint64 ltt_get_uint(gboolean reverse_byte_order, gint size, void *data)
2845{
2846 guint64 val;
2847
2848 switch(size) {
2849 case 1: val = *((gint8*)data); break;
2850 case 2: val = ltt_get_uint16(reverse_byte_order, data); break;
2851 case 4: val = ltt_get_uint32(reverse_byte_order, data); break;
2852 case 8: val = ltt_get_uint64(reverse_byte_order, data); break;
2853 default: val = ltt_get_uint64(reverse_byte_order, data);
2854 g_critical("get_uint : unsigned integer size %d unknown",
2855 size);
2856 break;
2857 }
2858
2859 return val;
2860}
2861
2862
2863/* get the node name of the system */
2864
2865char * ltt_trace_system_description_node_name (LttSystemDescription * s)
2866{
2867 return s->node_name;
2868}
2869
2870
2871/* get the domain name of the system */
2872
2873char * ltt_trace_system_description_domain_name (LttSystemDescription * s)
2874{
2875 return s->domain_name;
2876}
2877
2878
2879/* get the description of the system */
2880
2881char * ltt_trace_system_description_description (LttSystemDescription * s)
2882{
2883 return s->description;
2884}
2885
2886
2887/* get the NTP corrected start time of the trace */
2888LttTime ltt_trace_start_time(LttTrace *t)
2889{
2890 return t->start_time;
2891}
2892
2893/* get the monotonic start time of the trace */
2894LttTime ltt_trace_start_time_monotonic(LttTrace *t)
2895{
2896 return t->start_time_from_tsc;
2897}
2898
2899LttTracefile *ltt_tracefile_new()
2900{
2901 LttTracefile *tf;
2902 tf = g_new(LttTracefile, 1);
2903 tf->event.tracefile = tf;
2904 return tf;
2905}
2906
2907void ltt_tracefile_destroy(LttTracefile *tf)
2908{
2909 g_free(tf);
2910}
2911
2912void ltt_tracefile_copy(LttTracefile *dest, const LttTracefile *src)
2913{
2914 *dest = *src;
2915}
2916
2917/* Before library loading... */
2918
2919void init(void)
2920{
2921 LTT_FACILITY_NAME_HEARTBEAT = g_quark_from_string("heartbeat");
2922 LTT_EVENT_NAME_HEARTBEAT = g_quark_from_string("heartbeat");
2923 LTT_EVENT_NAME_HEARTBEAT_FULL = g_quark_from_string("heartbeat_full");
2924
2925 LTT_TRACEFILE_NAME_FACILITIES = g_quark_from_string("/control/facilities");
2926}
This page took 0.030709 seconds and 4 git commands to generate.