1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2005 Mathieu Desnoyers
4 * Complete rewrite from the original version made by XangXiu Yang.
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.
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.
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.
30 #include <sys/types.h>
35 #include <glib/gprintf.h>
48 #include "ltt-private.h"
49 #include <ltt/trace.h>
50 #include <ltt/event.h>
51 #include <ltt/ltt-types.h>
52 #include <ltt/marker.h>
55 extern long marker_update_fields_offsets(struct marker_info
*info
, const char *data
);
57 /* Tracefile names used in this file */
59 GQuark LTT_TRACEFILE_NAME_METADATA
;
66 #define __UNUSED__ __attribute__((__unused__))
68 #define g_info(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
71 #define g_debug(format...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
76 /* Those macros must be called from within a function where page_size is a known
78 #define PAGE_MASK (~(page_size-1))
79 #define PAGE_ALIGN(addr) (((addr)+page_size-1)&PAGE_MASK)
81 LttTrace
*father_trace
= NULL
;
83 /* set the offset of the fields belonging to the event,
84 need the information of the archecture */
85 //void set_fields_offsets(LttTracefile *tf, LttEventType *event_type);
86 //size_t get_fields_offsets(LttTracefile *tf, LttEventType *event_type, void *data);
88 /* map a fixed size or a block information from the file (fd) */
89 static gint
map_block(LttTracefile
* tf
, guint block_num
);
91 /* calculate nsec per cycles for current block */
93 static guint32
calc_nsecs_per_cycle(LttTracefile
* t
);
94 static guint64
cycles_2_ns(LttTracefile
*tf
, guint64 cycles
);
97 /* go to the next event */
98 static int ltt_seek_next_event(LttTracefile
*tf
);
100 static int open_tracefiles(LttTrace
*trace
, gchar
*root_path
,
101 gchar
*relative_path
);
102 static int ltt_process_metadata_tracefile(LttTracefile
*tf
);
103 static void ltt_tracefile_time_span_get(LttTracefile
*tf
,
104 LttTime
*start
, LttTime
*end
);
105 static void group_time_span_get(GQuark name
, gpointer data
, gpointer user_data
);
106 static gint
map_block(LttTracefile
* tf
, guint block_num
);
107 static void ltt_update_event_size(LttTracefile
*tf
);
109 /* Enable event debugging */
110 static int a_event_debug
= 0;
112 void ltt_event_debug(int state
)
114 a_event_debug
= state
;
119 * Return value : 0 success, 1 bad tracefile
121 static int parse_trace_header(ltt_subbuffer_header_t
*header
,
122 LttTracefile
*tf
, LttTrace
*t
)
124 if (header
->magic_number
== LTT_MAGIC_NUMBER
)
126 else if(header
->magic_number
== LTT_REV_MAGIC_NUMBER
)
128 else /* invalid magic number, bad tracefile ! */
132 t
->ltt_major_version
= header
->major_version
;
133 t
->ltt_minor_version
= header
->minor_version
;
134 t
->arch_size
= header
->arch_size
;
136 tf
->alignment
= header
->alignment
;
138 /* Get float byte order : might be different from int byte order
139 * (or is set to 0 if the trace has no float (kernel trace)) */
140 tf
->float_word_order
= 0;
142 switch(header
->major_version
) {
145 g_warning("Unsupported trace version : %hhu.%hhu",
146 header
->major_version
, header
->minor_version
);
150 switch(header
->minor_version
) {
153 struct ltt_subbuffer_header_2_3
*vheader
= header
;
154 tf
->buffer_header_size
= ltt_subbuffer_header_size();
157 tf
->tsc_mask
= ((1ULL << tf
->tscbits
) - 1);
158 tf
->tsc_mask_next_bit
= (1ULL << tf
->tscbits
);
161 t
->start_freq
= ltt_get_uint64(LTT_GET_BO(tf
),
162 &vheader
->start_freq
);
163 t
->freq_scale
= ltt_get_uint32(LTT_GET_BO(tf
),
164 &vheader
->freq_scale
);
166 t
->start_freq
= father_trace
->start_freq
;
167 t
->freq_scale
= father_trace
->freq_scale
;
171 t
->start_tsc
= ltt_get_uint64(LTT_GET_BO(tf
),
172 &vheader
->cycle_count_begin
);
173 t
->start_monotonic
= 0;
174 t
->start_time
.tv_sec
= ltt_get_uint64(LTT_GET_BO(tf
),
175 &vheader
->start_time_sec
);
176 t
->start_time
.tv_nsec
= ltt_get_uint64(LTT_GET_BO(tf
),
177 &vheader
->start_time_usec
);
178 t
->start_time
.tv_nsec
*= 1000; /* microsec to nanosec */
180 t
->start_time_from_tsc
= ltt_time_from_uint64(
182 * 1000000000.0 * tf
->trace
->freq_scale
183 / (double)t
->start_freq
);
188 g_warning("Unsupported trace version : %hhu.%hhu",
189 header
->major_version
, header
->minor_version
);
194 g_warning("Unsupported trace version : %hhu.%hhu",
195 header
->major_version
, header
->minor_version
);
203 /*****************************************************************************
205 * ltt_tracefile_open : open a trace file, construct a LttTracefile
207 * t : the trace containing the tracefile
208 * fileName : path name of the trace file
209 * tf : the tracefile structure
211 * : 0 for success, -1 otherwise.
212 ****************************************************************************/
214 static gint
ltt_tracefile_open(LttTrace
*t
, gchar
* fileName
, LttTracefile
*tf
)
216 struct stat lTDFStat
; /* Trace data file status */
217 ltt_subbuffer_header_t
*header
;
218 int page_size
= getpagesize();
221 tf
->long_name
= g_quark_from_string(fileName
);
223 tf
->fd
= open(fileName
, O_RDONLY
);
225 g_warning("Unable to open input data file %s\n", fileName
);
229 // Get the file's status
230 if(fstat(tf
->fd
, &lTDFStat
) < 0){
231 g_warning("Unable to get the status of the input data file %s\n", fileName
);
235 // Is the file large enough to contain a trace
236 if(lTDFStat
.st_size
<
237 (off_t
)(ltt_subbuffer_header_size())){
238 g_print("The input data file %s does not contain a trace\n", fileName
);
242 /* Temporarily map the buffer start header to get trace information */
243 /* Multiple of pages aligned head */
244 tf
->buffer
.head
= mmap(0,
245 PAGE_ALIGN(ltt_subbuffer_header_size()), PROT_READ
,
246 MAP_PRIVATE
, tf
->fd
, 0);
247 if(tf
->buffer
.head
== MAP_FAILED
) {
248 perror("Error in allocating memory for buffer of tracefile");
251 g_assert( ( (gulong
)tf
->buffer
.head
&(8-1) ) == 0); // make sure it's aligned.
253 header
= (ltt_subbuffer_header_t
*)tf
->buffer
.head
;
255 if(parse_trace_header(header
, tf
, NULL
)) {
256 g_warning("parse_trace_header error");
260 //store the size of the file
261 tf
->file_size
= lTDFStat
.st_size
;
262 tf
->buf_size
= ltt_get_uint32(LTT_GET_BO(tf
), &header
->buf_size
);
263 tf
->num_blocks
= tf
->file_size
/ tf
->buf_size
;
265 tf
->subbuf_corrupt
= 0;
267 if(munmap(tf
->buffer
.head
,
268 PAGE_ALIGN(ltt_subbuffer_header_size()))) {
269 g_warning("unmap size : %zu\n",
270 PAGE_ALIGN(ltt_subbuffer_header_size()));
271 perror("munmap error");
274 tf
->buffer
.head
= NULL
;
276 //read the first block
277 if(map_block(tf
,0)) {
278 perror("Cannot map block for tracefile");
286 if(munmap(tf
->buffer
.head
,
287 PAGE_ALIGN(ltt_subbuffer_header_size()))) {
288 g_warning("unmap size : %zu\n",
289 PAGE_ALIGN(ltt_subbuffer_header_size()));
290 perror("munmap error");
300 /*****************************************************************************
302 * ltt_tracefile_close: close a trace file,
304 * t : tracefile which will be closed
305 ****************************************************************************/
307 static void ltt_tracefile_close(LttTracefile
*t
)
309 int page_size
= getpagesize();
311 if(t
->buffer
.head
!= NULL
)
312 if(munmap(t
->buffer
.head
, PAGE_ALIGN(t
->buf_size
))) {
313 g_warning("unmap size : %u\n",
314 PAGE_ALIGN(t
->buf_size
));
315 perror("munmap error");
322 /****************************************************************************
323 * get_absolute_pathname
325 * return the unique pathname in the system
327 * MD : Fixed this function so it uses realpath, dealing well with
328 * forgotten cases (.. were not used correctly before).
330 ****************************************************************************/
331 void get_absolute_pathname(const gchar
*pathname
, gchar
* abs_pathname
)
333 abs_pathname
[0] = '\0';
335 if (realpath(pathname
, abs_pathname
) != NULL
)
339 /* error, return the original path unmodified */
340 strcpy(abs_pathname
, pathname
);
346 /* Search for something like : .*_.*
348 * The left side is the name, the right side is the number.
350 * Exclude flight- prefix.
353 static int get_tracefile_name_number(gchar
*raw_name
,
360 guint raw_name_len
= strlen(raw_name
);
361 gchar char_name
[PATH_MAX
];
369 for(i
= 0; i
< raw_name_len
-1;i
++) {
370 if(raw_name
[i
] != '/')
373 raw_name
= &raw_name
[i
];
374 raw_name_len
= strlen(raw_name
);
376 for(i
=raw_name_len
-1;i
>=0;i
--) {
377 if(raw_name
[i
] == '_') break;
379 if(i
==-1) { /* Either not found or name length is 0 */
380 /* This is a userspace tracefile */
381 strncpy(char_name
, raw_name
, raw_name_len
);
382 char_name
[raw_name_len
] = '\0';
383 *name
= g_quark_from_string(char_name
);
384 *num
= 0; /* unknown cpu */
385 for(i
=0;i
<raw_name_len
;i
++) {
386 if(raw_name
[i
] == '/') {
391 for(;i
<raw_name_len
;i
++) {
392 if(raw_name
[i
] == '/') {
397 for(;i
<raw_name_len
;i
++) {
398 if(raw_name
[i
] == '-') {
402 if(i
== raw_name_len
) return -1;
404 tmpptr
= &raw_name
[i
];
405 for(;i
<raw_name_len
;i
++) {
406 if(raw_name
[i
] == '.') {
411 *tid
= strtoul(tmpptr
, &endptr
, 10);
413 return -1; /* No digit */
414 if(*tid
== ULONG_MAX
)
415 return -1; /* underflow / overflow */
417 tmpptr
= &raw_name
[i
];
418 for(;i
<raw_name_len
;i
++) {
419 if(raw_name
[i
] == '.') {
424 *pgid
= strtoul(tmpptr
, &endptr
, 10);
426 return -1; /* No digit */
427 if(*pgid
== ULONG_MAX
)
428 return -1; /* underflow / overflow */
430 tmpptr
= &raw_name
[i
];
431 *creation
= strtoull(tmpptr
, &endptr
, 10);
433 return -1; /* No digit */
434 if(*creation
== G_MAXUINT64
)
435 return -1; /* underflow / overflow */
439 cpu_num
= strtol(raw_name
+underscore_pos
+1, &endptr
, 10);
441 if(endptr
== raw_name
+underscore_pos
+1)
442 return -1; /* No digit */
443 if(cpu_num
== LONG_MIN
|| cpu_num
== LONG_MAX
)
444 return -1; /* underflow / overflow */
446 if (!strncmp(raw_name
, "flight-", sizeof("flight-") - 1)) {
447 raw_name
+= sizeof("flight-") - 1;
448 underscore_pos
-= sizeof("flight-") - 1;
450 strncpy(char_name
, raw_name
, underscore_pos
);
451 char_name
[underscore_pos
] = '\0';
452 *name
= g_quark_from_string(char_name
);
461 GData
**ltt_trace_get_tracefiles_groups(LttTrace
*trace
)
463 return &trace
->tracefiles
;
467 void compute_tracefile_group(GQuark key_id
,
469 struct compute_tracefile_group_args
*args
)
474 for(i
=0; i
<group
->len
; i
++) {
475 tf
= &g_array_index (group
, LttTracefile
, i
);
477 args
->func(tf
, args
->func_args
);
482 static void ltt_tracefile_group_destroy(gpointer data
)
484 GArray
*group
= (GArray
*)data
;
489 destroy_marker_data(g_array_index (group
, LttTracefile
, 0).mdata
);
490 for(i
=0; i
<group
->len
; i
++) {
491 tf
= &g_array_index (group
, LttTracefile
, i
);
493 ltt_tracefile_close(tf
);
495 g_array_free(group
, TRUE
);
498 static __attribute__ ((__unused__
)) gboolean
ltt_tracefile_group_has_cpu_online(gpointer data
)
500 GArray
*group
= (GArray
*)data
;
504 for(i
=0; i
<group
->len
; i
++) {
505 tf
= &g_array_index (group
, LttTracefile
, i
);
513 /* Open each tracefile under a specific directory. Put them in a
514 * GData : permits to access them using their tracefile group pathname.
515 * i.e. access control/modules tracefile group by index :
518 * relative path is the path relative to the trace root
519 * root path is the full path
521 * A tracefile group is simply an array where all the per cpu tracefiles sit.
524 static int open_tracefiles(LttTrace
*trace
, gchar
*root_path
, gchar
*relative_path
)
526 DIR *dir
= opendir(root_path
);
527 struct dirent
*entry
;
528 struct stat stat_buf
;
530 struct marker_data
*mdata
;
532 gchar path
[PATH_MAX
];
537 gchar rel_path
[PATH_MAX
];
546 strncpy(path
, root_path
, PATH_MAX
-1);
547 path_len
= strlen(path
);
548 path
[path_len
] = '/';
550 path_ptr
= path
+ path_len
;
552 strncpy(rel_path
, relative_path
, PATH_MAX
-1);
553 rel_path_len
= strlen(rel_path
);
554 rel_path
[rel_path_len
] = '/';
556 rel_path_ptr
= rel_path
+ rel_path_len
;
558 while((entry
= readdir(dir
)) != NULL
) {
560 if(entry
->d_name
[0] == '.') continue;
562 strncpy(path_ptr
, entry
->d_name
, PATH_MAX
- path_len
);
563 strncpy(rel_path_ptr
, entry
->d_name
, PATH_MAX
- rel_path_len
);
565 ret
= stat(path
, &stat_buf
);
571 g_debug("Tracefile file or directory : %s\n", path
);
573 // if(strcmp(rel_path, "/eventdefs") == 0) continue;
575 if(S_ISDIR(stat_buf
.st_mode
)) {
577 g_debug("Entering subdirectory...\n");
578 ret
= open_tracefiles(trace
, path
, rel_path
);
579 if(ret
< 0) continue;
580 } else if(S_ISREG(stat_buf
.st_mode
)) {
589 if(get_tracefile_name_number(rel_path
, &name
, &num
, &tid
, &pgid
, &creation
))
590 continue; /* invalid name */
592 g_debug("Opening file.\n");
593 if(ltt_tracefile_open(trace
, path
, &tmp_tf
)) {
594 g_info("Error opening tracefile %s", path
);
596 continue; /* error opening the tracefile : bad magic number ? */
599 g_debug("Tracefile name is %s and number is %u",
600 g_quark_to_string(name
), num
);
603 tmp_tf
.cpu_online
= 1;
604 tmp_tf
.cpu_num
= num
;
608 tmp_tf
.creation
= creation
;
609 group
= g_datalist_id_get_data(&trace
->tracefiles
, name
);
611 /* Elements are automatically cleared when the array is allocated.
612 * It makes the cpu_online variable set to 0 : cpu offline, by default.
614 group
= g_array_sized_new (FALSE
, TRUE
, sizeof(LttTracefile
), 10);
615 g_datalist_id_set_data_full(&trace
->tracefiles
, name
,
616 group
, ltt_tracefile_group_destroy
);
617 mdata
= allocate_marker_data();
619 g_error("Error in allocating marker data");
622 /* Add the per cpu tracefile to the named group */
623 unsigned int old_len
= group
->len
;
625 group
= g_array_set_size(group
, num
+1);
627 g_assert(group
->len
> 0);
629 mdata
= g_array_index (group
, LttTracefile
, 0).mdata
;
631 g_array_index (group
, LttTracefile
, num
) = tmp_tf
;
632 g_array_index (group
, LttTracefile
, num
).event
.tracefile
=
633 &g_array_index (group
, LttTracefile
, num
);
634 for (i
= 0; i
< group
->len
; i
++)
635 g_array_index (group
, LttTracefile
, i
).mdata
= mdata
;
645 /* Presumes the tracefile is already seeked at the beginning. It makes sense,
646 * because it must be done just after the opening */
647 static int ltt_process_metadata_tracefile(LttTracefile
*tf
)
652 err
= ltt_tracefile_read_seek(tf
);
653 if(err
== EPERM
) goto seek_error
;
654 else if(err
== ERANGE
) break; /* End of tracefile */
656 err
= ltt_tracefile_read_update_event(tf
);
657 if(err
) goto update_error
;
660 * It contains only core events :
662 * 1 : set_marker_format
664 if(tf
->event
.event_id
>= MARKER_CORE_IDS
) {
665 /* Should only contain core events */
666 g_warning("Error in processing metadata file %s, "
667 "should not contain event id %u.", g_quark_to_string(tf
->name
),
673 const char *channel_name
, *marker_name
, *format
;
675 guint8 int_size
, long_size
, pointer_size
, size_t_size
, alignment
;
677 switch((enum marker_id
)tf
->event
.event_id
) {
678 case MARKER_ID_SET_MARKER_ID
:
679 channel_name
= pos
= tf
->event
.data
;
680 pos
+= strlen(channel_name
) + 1;
682 g_debug("Doing MARKER_ID_SET_MARKER_ID of marker %s.%s",
683 channel_name
, marker_name
);
684 pos
+= strlen(marker_name
) + 1;
685 pos
+= ltt_align((size_t)pos
, sizeof(guint16
), tf
->alignment
);
686 id
= ltt_get_uint16(LTT_GET_BO(tf
), pos
);
687 g_debug("In MARKER_ID_SET_MARKER_ID of marker %s.%s id %hu",
688 channel_name
, marker_name
, id
);
689 pos
+= sizeof(guint16
);
690 int_size
= *(guint8
*)pos
;
691 pos
+= sizeof(guint8
);
692 long_size
= *(guint8
*)pos
;
693 pos
+= sizeof(guint8
);
694 pointer_size
= *(guint8
*)pos
;
695 pos
+= sizeof(guint8
);
696 size_t_size
= *(guint8
*)pos
;
697 pos
+= sizeof(guint8
);
698 alignment
= *(guint8
*)pos
;
699 pos
+= sizeof(guint8
);
700 marker_id_event(tf
->trace
,
701 g_quark_from_string(channel_name
),
702 g_quark_from_string(marker_name
),
703 id
, int_size
, long_size
,
704 pointer_size
, size_t_size
, alignment
);
706 case MARKER_ID_SET_MARKER_FORMAT
:
707 channel_name
= pos
= tf
->event
.data
;
708 pos
+= strlen(channel_name
) + 1;
710 g_debug("Doing MARKER_ID_SET_MARKER_FORMAT of marker %s.%s",
711 channel_name
, marker_name
);
712 pos
+= strlen(marker_name
) + 1;
714 pos
+= strlen(format
) + 1;
715 marker_format_event(tf
->trace
,
716 g_quark_from_string(channel_name
),
717 g_quark_from_string(marker_name
),
719 /* get information from dictionary TODO */
722 g_warning("Error in processing metadata file %s, "
723 "unknown event id %hhu.",
724 g_quark_to_string(tf
->name
),
737 g_warning("An error occured in metadata tracefile parsing");
742 * Open a trace and return its LttTrace handle.
744 * pathname must be the directory of the trace
747 LttTrace
*ltt_trace_open(const gchar
*pathname
)
749 gchar abs_path
[PATH_MAX
];
755 ltt_subbuffer_header_t
*header
;
757 struct dirent
*entry
;
758 struct stat stat_buf
;
759 gchar path
[PATH_MAX
];
761 t
= g_new(LttTrace
, 1);
762 if(!t
) goto alloc_error
;
764 get_absolute_pathname(pathname
, abs_path
);
765 t
->pathname
= g_quark_from_string(abs_path
);
767 g_datalist_init(&t
->tracefiles
);
769 /* Test to see if it looks like a trace */
770 dir
= opendir(abs_path
);
775 while((entry
= readdir(dir
)) != NULL
) {
776 strcpy(path
, abs_path
);
778 strcat(path
, entry
->d_name
);
779 ret
= stat(path
, &stat_buf
);
787 /* Open all the tracefiles */
788 if(open_tracefiles(t
, abs_path
, "")) {
789 g_warning("Error opening tracefile %s", abs_path
);
793 /* Parse each trace metadata_N files : get runtime fac. info */
794 group
= g_datalist_id_get_data(&t
->tracefiles
, LTT_TRACEFILE_NAME_METADATA
);
796 g_warning("Trace %s has no metadata tracefile", abs_path
);
801 * Get the trace information for the metadata_0 tracefile.
802 * Getting a correct trace start_time and start_tsc is insured by the fact
803 * that no subbuffers are supposed to be lost in the metadata channel.
804 * Therefore, the first subbuffer contains the start_tsc timestamp in its
807 g_assert(group
->len
> 0);
808 tf
= &g_array_index (group
, LttTracefile
, 0);
809 header
= (ltt_subbuffer_header_t
*)tf
->buffer
.head
;
810 ret
= parse_trace_header(header
, tf
, t
);
813 t
->num_cpu
= group
->len
;
815 //ret = allocate_marker_data(t);
817 // g_error("Error in allocating marker data");
819 for(i
=0; i
<group
->len
; i
++) {
820 tf
= &g_array_index (group
, LttTracefile
, i
);
822 if(ltt_process_metadata_tracefile(tf
))
824 // goto metadata_error;
831 // destroy_marker_data(t);
833 g_datalist_clear(&t
->tracefiles
);
841 /* Open another, completely independant, instance of a trace.
843 * A read on this new instance will read the first event of the trace.
845 * When we copy a trace, we want all the opening actions to happen again :
846 * the trace will be reopened and totally independant from the original.
847 * That's why we call ltt_trace_open.
849 LttTrace
*ltt_trace_copy(LttTrace
*self
)
851 return ltt_trace_open(g_quark_to_string(self
->pathname
));
858 void ltt_trace_close(LttTrace
*t
)
860 g_datalist_clear(&t
->tracefiles
);
865 /*****************************************************************************
866 * Get the start time and end time of the trace
867 ****************************************************************************/
869 void ltt_tracefile_time_span_get(LttTracefile
*tf
,
870 LttTime
*start
, LttTime
*end
)
874 err
= map_block(tf
, 0);
876 g_error("Can not map block");
877 *start
= ltt_time_infinite
;
879 *start
= tf
->buffer
.begin
.timestamp
;
881 err
= map_block(tf
, tf
->num_blocks
- 1); /* Last block */
883 g_error("Can not map block");
884 *end
= ltt_time_zero
;
886 *end
= tf
->buffer
.end
.timestamp
;
889 struct tracefile_time_span_get_args
{
895 static void group_time_span_get(GQuark name
, gpointer data
, gpointer user_data
)
897 struct tracefile_time_span_get_args
*args
=
898 (struct tracefile_time_span_get_args
*)user_data
;
900 GArray
*group
= (GArray
*)data
;
906 for(i
=0; i
<group
->len
; i
++) {
907 tf
= &g_array_index (group
, LttTracefile
, i
);
909 ltt_tracefile_time_span_get(tf
, &tmp_start
, &tmp_end
);
910 if(ltt_time_compare(*args
->start
, tmp_start
)>0) *args
->start
= tmp_start
;
911 if(ltt_time_compare(*args
->end
, tmp_end
)<0) *args
->end
= tmp_end
;
916 /* return the start and end time of a trace */
918 void ltt_trace_time_span_get(LttTrace
*t
, LttTime
*start
, LttTime
*end
)
920 LttTime min_start
= ltt_time_infinite
;
921 LttTime max_end
= ltt_time_zero
;
922 struct tracefile_time_span_get_args args
= { t
, &min_start
, &max_end
};
924 g_datalist_foreach(&t
->tracefiles
, &group_time_span_get
, &args
);
926 if(start
!= NULL
) *start
= min_start
;
927 if(end
!= NULL
) *end
= max_end
;
932 /* Seek to the first event in a tracefile that has a time equal or greater than
933 * the time passed in parameter.
935 * If the time parameter is outside the tracefile time span, seek to the first
936 * event or if after, return ERANGE.
938 * If the time parameter is before the first event, we have to seek specially to
941 * If the time is after the end of the trace, return ERANGE.
943 * Do a binary search to find the right block, then a sequential search in the
944 * block to find the event.
946 * In the special case where the time requested fits inside a block that has no
947 * event corresponding to the requested time, the first event of the next block
950 * IMPORTANT NOTE : // FIXME everywhere...
952 * You MUST NOT do a ltt_tracefile_read right after a ltt_tracefile_seek_time :
953 * you will jump over an event if you do.
955 * Return value : 0 : no error, the tf->event can be used
956 * ERANGE : time if after the last event of the trace
957 * otherwise : this is an error.
961 int ltt_tracefile_seek_time(LttTracefile
*tf
, LttTime time
)
965 unsigned int block_num
, high
, low
;
967 /* seek at the beginning of trace */
968 err
= map_block(tf
, 0); /* First block */
970 g_error("Can not map block");
974 /* If the time is lower or equal the beginning of the trace,
975 * go to the first event. */
976 if(ltt_time_compare(time
, tf
->buffer
.begin
.timestamp
) <= 0) {
977 ret
= ltt_tracefile_read(tf
);
978 if(ret
== ERANGE
) goto range
;
979 else if (ret
) goto fail
;
980 goto found
; /* There is either no event in the trace or the event points
981 to the first event in the trace */
984 err
= map_block(tf
, tf
->num_blocks
- 1); /* Last block */
986 g_error("Can not map block");
990 /* If the time is after the end of the trace, return ERANGE. */
991 if(ltt_time_compare(time
, tf
->buffer
.end
.timestamp
) > 0) {
995 /* Binary search the block */
996 high
= tf
->num_blocks
- 1;
1000 block_num
= ((high
-low
) / 2) + low
;
1002 err
= map_block(tf
, block_num
);
1004 g_error("Can not map block");
1008 /* We cannot divide anymore : this is what would happen if the time
1009 * requested was exactly between two consecutive buffers'end and start
1010 * timestamps. This is also what would happend if we didn't deal with out
1011 * of span cases prior in this function. */
1012 /* The event is right in the buffer!
1013 * (or in the next buffer first event) */
1015 ret
= ltt_tracefile_read(tf
);
1016 if(ret
== ERANGE
) goto range
; /* ERANGE or EPERM */
1017 else if(ret
) goto fail
;
1019 if(ltt_time_compare(time
, tf
->event
.event_time
) <= 0)
1023 } else if(ltt_time_compare(time
, tf
->buffer
.begin
.timestamp
) < 0) {
1024 /* go to lower part */
1025 high
= block_num
- 1;
1026 } else if(ltt_time_compare(time
, tf
->buffer
.end
.timestamp
) > 0) {
1027 /* go to higher part */
1028 low
= block_num
+ 1;
1029 } else {/* The event is right in the buffer!
1030 (or in the next buffer first event) */
1032 ret
= ltt_tracefile_read(tf
);
1033 if(ret
== ERANGE
) goto range
; /* ERANGE or EPERM */
1034 else if(ret
) goto fail
;
1036 if(ltt_time_compare(time
, tf
->event
.event_time
) <= 0)
1048 /* Error handling */
1050 g_error("ltt_tracefile_seek_time failed on tracefile %s",
1051 g_quark_to_string(tf
->name
));
1055 /* Seek to a position indicated by an LttEventPosition
1058 int ltt_tracefile_seek_position(LttTracefile
*tf
, const LttEventPosition
*ep
)
1062 if(ep
->tracefile
!= tf
) {
1066 err
= map_block(tf
, ep
->block
);
1068 g_error("Can not map block");
1072 tf
->event
.offset
= ep
->offset
;
1074 /* Put back the event real tsc */
1075 tf
->event
.tsc
= ep
->tsc
;
1076 tf
->buffer
.tsc
= ep
->tsc
;
1078 err
= ltt_tracefile_read_update_event(tf
);
1081 /* deactivate this, as it does nothing for now
1082 err = ltt_tracefile_read_op(tf);
1089 g_error("ltt_tracefile_seek_time failed on tracefile %s",
1090 g_quark_to_string(tf
->name
));
1094 /* Given a TSC value, return the LttTime (seconds,nanoseconds) it
1098 LttTime
ltt_interpolate_time_from_tsc(LttTracefile
*tf
, guint64 tsc
)
1102 if(tsc
> tf
->trace
->start_tsc
) {
1103 time
= ltt_time_from_uint64(
1104 (double)(tsc
- tf
->trace
->start_tsc
)
1105 * 1000000000.0 * tf
->trace
->freq_scale
1106 / (double)tf
->trace
->start_freq
);
1107 time
= ltt_time_add(tf
->trace
->start_time_from_tsc
, time
);
1109 time
= ltt_time_from_uint64(
1110 (double)(tf
->trace
->start_tsc
- tsc
)
1111 * 1000000000.0 * tf
->trace
->freq_scale
1112 / (double)tf
->trace
->start_freq
);
1113 time
= ltt_time_sub(tf
->trace
->start_time_from_tsc
, time
);
1118 /* Calculate the real event time based on the buffer boundaries */
1119 LttTime
ltt_interpolate_time(LttTracefile
*tf
, LttEvent
*event
)
1121 return ltt_interpolate_time_from_tsc(tf
, tf
->buffer
.tsc
);
1125 /* Get the current event of the tracefile : valid until the next read */
1126 LttEvent
*ltt_tracefile_get_event(LttTracefile
*tf
)
1133 /*****************************************************************************
1135 * ltt_tracefile_read : Read the next event in the tracefile
1140 * Returns 0 if an event can be used in tf->event.
1141 * Returns ERANGE on end of trace. The event in tf->event still can be used
1142 * (if the last block was not empty).
1143 * Returns EPERM on error.
1145 * This function does make the tracefile event structure point to the event
1146 * currently pointed to by the tf->event.
1148 * Note : you must call a ltt_tracefile_seek to the beginning of the trace to
1149 * reinitialize it after an error if you want results to be coherent.
1150 * It would be the case if a end of trace last buffer has no event : the end
1151 * of trace wouldn't be returned, but an error.
1152 * We make the assumption there is at least one event per buffer.
1153 ****************************************************************************/
1155 int ltt_tracefile_read(LttTracefile
*tf
)
1159 err
= ltt_tracefile_read_seek(tf
);
1161 err
= ltt_tracefile_read_update_event(tf
);
1164 /* deactivate this, as it does nothing for now
1165 err = ltt_tracefile_read_op(tf);
1172 int ltt_tracefile_read_seek(LttTracefile
*tf
)
1176 /* Get next buffer until we finally have an event, or end of trace */
1178 err
= ltt_seek_next_event(tf
);
1179 if(unlikely(err
== ENOPROTOOPT
)) {
1183 /* Are we at the end of the buffer ? */
1185 if(unlikely(tf
->buffer
.index
== tf
->num_blocks
-1)){ /* end of trace ? */
1188 /* get next block */
1189 err
= map_block(tf
, tf
->buffer
.index
+ 1);
1191 g_error("Can not map block");
1195 } else break; /* We found an event ! */
1201 /* do an operation when reading a new event */
1203 /* This function does nothing for now */
1205 int ltt_tracefile_read_op(LttTracefile
*tf
)
1211 /* do event specific operation */
1219 static void print_debug_event_header(LttEvent
*ev
, void *start_pos
, void *end_pos
)
1221 unsigned int offset
= 0;
1224 g_printf("Event header (tracefile %s offset %" PRIx64
"):\n",
1225 g_quark_to_string(ev
->tracefile
->long_name
),
1226 ((uint64_t)ev
->tracefile
->buffer
.index
* ev
->tracefile
->buf_size
)
1227 + (long)start_pos
- (long)ev
->tracefile
->buffer
.head
);
1229 while (offset
< (long)end_pos
- (long)start_pos
) {
1230 g_printf("%8lx", (long)start_pos
- (long)ev
->tracefile
->buffer
.head
+ offset
);
1233 for (i
= 0; i
< 4 ; i
++) {
1234 for (j
= 0; j
< 4; j
++) {
1235 if (offset
+ ((i
* 4) + j
) <
1236 (long)end_pos
- (long)start_pos
)
1238 ((char*)start_pos
)[offset
+ ((i
* 4) + j
)]);
1252 /* same as ltt_tracefile_read, but does not seek to the next event nor call
1253 * event specific operation. */
1254 int ltt_tracefile_read_update_event(LttTracefile
*tf
)
1259 guint16 packed_evid
; /* event id reader from the 5 bits in header */
1262 pos
= tf
->buffer
.head
+ event
->offset
;
1264 /* Read event header */
1266 /* Align the head */
1267 pos
+= ltt_align((size_t)pos
, sizeof(guint32
), tf
->alignment
);
1270 event
->timestamp
= ltt_get_uint32(LTT_GET_BO(tf
), pos
);
1271 event
->event_id
= packed_evid
= event
->timestamp
>> tf
->tscbits
;
1272 event
->timestamp
= event
->timestamp
& tf
->tsc_mask
;
1273 pos
+= sizeof(guint32
);
1275 switch (packed_evid
) {
1276 case 29: /* LTT_RFLAG_ID_SIZE_TSC */
1277 event
->event_id
= ltt_get_uint16(LTT_GET_BO(tf
), pos
);
1278 pos
+= sizeof(guint16
);
1279 event
->event_size
= ltt_get_uint16(LTT_GET_BO(tf
), pos
);
1280 pos
+= sizeof(guint16
);
1281 if (event
->event_size
== 0xFFFF) {
1282 event
->event_size
= ltt_get_uint32(LTT_GET_BO(tf
), pos
);
1283 pos
+= sizeof(guint32
);
1285 pos
+= ltt_align((size_t)pos
, sizeof(guint64
), tf
->alignment
);
1286 tf
->buffer
.tsc
= ltt_get_uint64(LTT_GET_BO(tf
), pos
);
1287 pos
+= sizeof(guint64
);
1289 case 30: /* LTT_RFLAG_ID_SIZE */
1290 event
->event_id
= ltt_get_uint16(LTT_GET_BO(tf
), pos
);
1291 pos
+= sizeof(guint16
);
1292 event
->event_size
= ltt_get_uint16(LTT_GET_BO(tf
), pos
);
1293 pos
+= sizeof(guint16
);
1294 if (event
->event_size
== 0xFFFF) {
1295 event
->event_size
= ltt_get_uint32(LTT_GET_BO(tf
), pos
);
1296 pos
+= sizeof(guint32
);
1299 case 31: /* LTT_RFLAG_ID */
1300 event
->event_id
= ltt_get_uint16(LTT_GET_BO(tf
), pos
);
1301 pos
+= sizeof(guint16
);
1302 event
->event_size
= G_MAXUINT
;
1305 event
->event_size
= G_MAXUINT
;
1309 if (likely(packed_evid
!= 29)) {
1310 /* No extended timestamp */
1311 if (event
->timestamp
< (tf
->buffer
.tsc
& tf
->tsc_mask
))
1312 tf
->buffer
.tsc
= ((tf
->buffer
.tsc
& ~tf
->tsc_mask
) /* overflow */
1313 + tf
->tsc_mask_next_bit
)
1314 | (guint64
)event
->timestamp
;
1316 tf
->buffer
.tsc
= (tf
->buffer
.tsc
& ~tf
->tsc_mask
) /* no overflow */
1317 | (guint64
)event
->timestamp
;
1319 event
->tsc
= tf
->buffer
.tsc
;
1321 event
->event_time
= ltt_interpolate_time(tf
, event
);
1324 print_debug_event_header(event
, pos_aligned
, pos
);
1329 * Let ltt_update_event_size update event->data according to the largest
1330 * alignment within the payload.
1331 * Get the data size and update the event fields with the current
1333 ltt_update_event_size(tf
);
1339 /****************************************************************************
1341 * map_block : map a block from the file
1343 * lttdes : ltt trace file
1344 * whichBlock : the block which will be read
1347 * EINVAL : lseek fail
1348 * EIO : can not read from the file
1349 ****************************************************************************/
1351 static gint
map_block(LttTracefile
* tf
, guint block_num
)
1353 int page_size
= getpagesize();
1354 ltt_subbuffer_header_t
*header
;
1356 g_assert(block_num
< tf
->num_blocks
);
1358 if(tf
->buffer
.head
!= NULL
) {
1359 if(munmap(tf
->buffer
.head
, PAGE_ALIGN(tf
->buf_size
))) {
1360 g_warning("unmap size : %u\n",
1361 PAGE_ALIGN(tf
->buf_size
));
1362 perror("munmap error");
1367 /* Multiple of pages aligned head */
1368 tf
->buffer
.head
= mmap(0,
1369 PAGE_ALIGN(tf
->buf_size
),
1370 PROT_READ
, MAP_PRIVATE
, tf
->fd
,
1371 PAGE_ALIGN((off_t
)tf
->buf_size
* (off_t
)block_num
));
1373 if(tf
->buffer
.head
== MAP_FAILED
) {
1374 perror("Error in allocating memory for buffer of tracefile");
1378 g_assert( ( (gulong
)tf
->buffer
.head
&(8-1) ) == 0); // make sure it's aligned.
1381 tf
->buffer
.index
= block_num
;
1383 header
= (ltt_subbuffer_header_t
*)tf
->buffer
.head
;
1385 tf
->buffer
.begin
.cycle_count
= ltt_get_uint64(LTT_GET_BO(tf
),
1386 &header
->cycle_count_begin
);
1387 tf
->buffer
.begin
.freq
= tf
->trace
->start_freq
;
1389 tf
->buffer
.begin
.timestamp
= ltt_interpolate_time_from_tsc(tf
,
1390 tf
->buffer
.begin
.cycle_count
);
1391 tf
->buffer
.end
.cycle_count
= ltt_get_uint64(LTT_GET_BO(tf
),
1392 &header
->cycle_count_end
);
1393 tf
->buffer
.end
.freq
= tf
->trace
->start_freq
;
1395 tf
->buffer
.lost_size
= ltt_get_uint32(LTT_GET_BO(tf
),
1396 &header
->lost_size
);
1397 tf
->buffer
.end
.timestamp
= ltt_interpolate_time_from_tsc(tf
,
1398 tf
->buffer
.end
.cycle_count
);
1399 tf
->buffer
.tsc
= tf
->buffer
.begin
.cycle_count
;
1400 tf
->event
.tsc
= tf
->buffer
.tsc
;
1401 tf
->buffer
.freq
= tf
->buffer
.begin
.freq
;
1404 * eventually support variable buffer size : will need a partial pre-read of
1405 * the headers to create an index when we open the trace... eventually. */
1406 g_assert(tf
->buf_size
== ltt_get_uint32(LTT_GET_BO(tf
),
1407 &header
->buf_size
));
1409 /* Make the current event point to the beginning of the buffer :
1410 * it means that the event read must get the first event. */
1411 tf
->event
.tracefile
= tf
;
1412 tf
->event
.block
= block_num
;
1413 tf
->event
.offset
= 0;
1415 if (header
->events_lost
) {
1416 g_warning("%d events lost so far in tracefile %s at block %u",
1417 (guint
)header
->events_lost
,
1418 g_quark_to_string(tf
->long_name
),
1420 tf
->events_lost
= header
->events_lost
;
1422 if (header
->subbuf_corrupt
) {
1423 g_warning("%d subbuffer(s) corrupted so far in tracefile %s at block %u",
1424 (guint
)header
->subbuf_corrupt
,
1425 g_quark_to_string(tf
->long_name
),
1427 tf
->subbuf_corrupt
= header
->subbuf_corrupt
;
1436 static void print_debug_event_data(LttEvent
*ev
)
1438 unsigned int offset
= 0;
1441 if (!max(ev
->event_size
, ev
->data_size
))
1444 g_printf("Event data (tracefile %s offset %" PRIx64
"):\n",
1445 g_quark_to_string(ev
->tracefile
->long_name
),
1446 ((uint64_t)ev
->tracefile
->buffer
.index
* ev
->tracefile
->buf_size
)
1447 + (long)ev
->data
- (long)ev
->tracefile
->buffer
.head
);
1449 while (offset
< max(ev
->event_size
, ev
->data_size
)) {
1450 g_printf("%8lx", (long)ev
->data
+ offset
1451 - (long)ev
->tracefile
->buffer
.head
);
1454 for (i
= 0; i
< 4 ; i
++) {
1455 for (j
= 0; j
< 4; j
++) {
1456 if (offset
+ ((i
* 4) + j
) < max(ev
->event_size
, ev
->data_size
))
1457 g_printf("%02hhX", ((char*)ev
->data
)[offset
+ ((i
* 4) + j
)]);
1468 for (i
= 0; i
< 4; i
++) {
1469 for (j
= 0; j
< 4; j
++) {
1470 if (offset
+ ((i
* 4) + j
) < max(ev
->event_size
, ev
->data_size
)) {
1471 if (isprint(((char*)ev
->data
)[offset
+ ((i
* 4) + j
)]))
1472 g_printf("%c", ((char*)ev
->data
)[offset
+ ((i
* 4) + j
)]);
1484 /* It will update the fields offsets too */
1485 void ltt_update_event_size(LttTracefile
*tf
)
1488 struct marker_info
*info
;
1490 if (tf
->name
== LTT_TRACEFILE_NAME_METADATA
) {
1491 switch((enum marker_id
)tf
->event
.event_id
) {
1492 case MARKER_ID_SET_MARKER_ID
:
1493 size
= strlen((char*)tf
->event
.data
) + 1;
1494 g_debug("marker %s id set", (char*)tf
->event
.data
+ size
);
1495 size
+= strlen((char*)tf
->event
.data
+ size
) + 1;
1496 size
+= ltt_align(size
, sizeof(guint16
), tf
->alignment
);
1497 size
+= sizeof(guint16
);
1498 size
+= sizeof(guint8
);
1499 size
+= sizeof(guint8
);
1500 size
+= sizeof(guint8
);
1501 size
+= sizeof(guint8
);
1502 size
+= sizeof(guint8
);
1504 case MARKER_ID_SET_MARKER_FORMAT
:
1505 size
= strlen((char*)tf
->event
.data
) + 1;
1506 g_debug("marker %s format set", (char*)tf
->event
.data
);
1507 size
+= strlen((char*)tf
->event
.data
+ size
) + 1;
1508 size
+= strlen((char*)tf
->event
.data
+ size
) + 1;
1513 info
= marker_get_info_from_id(tf
->mdata
, tf
->event
.event_id
);
1515 if (tf
->event
.event_id
>= MARKER_CORE_IDS
)
1516 g_assert(info
!= NULL
);
1518 /* Do not update field offsets of core markers when initially reading the
1519 * metadata tracefile when the infos about these markers do not exist yet.
1521 if (likely(info
&& info
->fields
)) {
1523 tf
->event
.data
+= ltt_align((off_t
)(unsigned long)tf
->event
.data
,
1524 info
->largest_align
,
1526 /* size, dynamically computed */
1527 if (info
->size
!= -1)
1530 size
= marker_update_fields_offsets(marker_get_info_from_id(tf
->mdata
,
1531 tf
->event
.event_id
), tf
->event
.data
);
1534 tf
->event
.data_size
= size
;
1536 /* Check consistency between kernel and LTTV structure sizes */
1537 if(tf
->event
.event_size
== G_MAXUINT
) {
1538 /* Event size too big to fit in the event size field */
1539 tf
->event
.event_size
= tf
->event
.data_size
;
1543 print_debug_event_data(&tf
->event
);
1545 if (tf
->event
.data_size
!= tf
->event
.event_size
) {
1546 struct marker_info
*info
= marker_get_info_from_id(tf
->mdata
,
1547 tf
->event
.event_id
);
1549 g_error("Undescribed event %hhu in channel %s", tf
->event
.event_id
,
1550 g_quark_to_string(tf
->name
));
1551 g_error("Kernel/LTTV event size differs for event %s: kernel %u, LTTV %u",
1552 g_quark_to_string(info
->name
),
1553 tf
->event
.event_size
, tf
->event
.data_size
);
1559 /* Take the tf current event offset and use the event id to figure out where is
1560 * the next event offset.
1562 * This is an internal function not aiming at being used elsewhere : it will
1563 * not jump over the current block limits. Please consider using
1564 * ltt_tracefile_read to do this.
1566 * Returns 0 on success
1567 * ERANGE if we are at the end of the buffer.
1568 * ENOPROTOOPT if an error occured when getting the current event size.
1570 static int ltt_seek_next_event(LttTracefile
*tf
)
1575 /* seek over the buffer header if we are at the buffer start */
1576 if(tf
->event
.offset
== 0) {
1577 tf
->event
.offset
+= tf
->buffer_header_size
;
1579 if(tf
->event
.offset
== tf
->buf_size
- tf
->buffer
.lost_size
) {
1585 pos
= tf
->event
.data
;
1587 if(tf
->event
.data_size
< 0) goto error
;
1589 pos
+= (size_t)tf
->event
.data_size
;
1591 tf
->event
.offset
= pos
- tf
->buffer
.head
;
1593 if(tf
->event
.offset
== tf
->buf_size
- tf
->buffer
.lost_size
) {
1597 g_assert(tf
->event
.offset
< tf
->buf_size
- tf
->buffer
.lost_size
);
1603 g_error("Error in ltt_seek_next_event for tracefile %s",
1604 g_quark_to_string(tf
->name
));
1609 /*****************************************************************************
1611 * ltt_get_int : get an integer number
1613 * reverse_byte_order: must we reverse the byte order ?
1614 * size : the size of the integer
1615 * ptr : the data pointer
1617 * gint64 : a 64 bits integer
1618 ****************************************************************************/
1620 gint64
ltt_get_int(gboolean reverse_byte_order
, gint size
, void *data
)
1625 case 1: val
= *((gint8
*)data
); break;
1626 case 2: val
= ltt_get_int16(reverse_byte_order
, data
); break;
1627 case 4: val
= ltt_get_int32(reverse_byte_order
, data
); break;
1628 case 8: val
= ltt_get_int64(reverse_byte_order
, data
); break;
1629 default: val
= ltt_get_int64(reverse_byte_order
, data
);
1630 g_critical("get_int : integer size %d unknown", size
);
1637 /*****************************************************************************
1639 * ltt_get_uint : get an unsigned integer number
1641 * reverse_byte_order: must we reverse the byte order ?
1642 * size : the size of the integer
1643 * ptr : the data pointer
1645 * guint64 : a 64 bits unsigned integer
1646 ****************************************************************************/
1648 guint64
ltt_get_uint(gboolean reverse_byte_order
, gint size
, void *data
)
1653 case 1: val
= *((gint8
*)data
); break;
1654 case 2: val
= ltt_get_uint16(reverse_byte_order
, data
); break;
1655 case 4: val
= ltt_get_uint32(reverse_byte_order
, data
); break;
1656 case 8: val
= ltt_get_uint64(reverse_byte_order
, data
); break;
1657 default: val
= ltt_get_uint64(reverse_byte_order
, data
);
1658 g_critical("get_uint : unsigned integer size %d unknown",
1667 /* get the node name of the system */
1669 char * ltt_trace_system_description_node_name (LttSystemDescription
* s
)
1671 return s
->node_name
;
1675 /* get the domain name of the system */
1677 char * ltt_trace_system_description_domain_name (LttSystemDescription
* s
)
1679 return s
->domain_name
;
1683 /* get the description of the system */
1685 char * ltt_trace_system_description_description (LttSystemDescription
* s
)
1687 return s
->description
;
1691 /* get the NTP corrected start time of the trace */
1692 LttTime
ltt_trace_start_time(LttTrace
*t
)
1694 return t
->start_time
;
1697 /* get the monotonic start time of the trace */
1698 LttTime
ltt_trace_start_time_monotonic(LttTrace
*t
)
1700 return t
->start_time_from_tsc
;
1703 static __attribute__ ((__unused__
)) LttTracefile
*ltt_tracefile_new()
1706 tf
= g_new(LttTracefile
, 1);
1707 tf
->event
.tracefile
= tf
;
1711 static __attribute__ ((__unused__
)) void ltt_tracefile_destroy(LttTracefile
*tf
)
1716 static __attribute__ ((__unused__
)) void ltt_tracefile_copy(LttTracefile
*dest
, const LttTracefile
*src
)
1721 /* Before library loading... */
1723 static __attribute__((constructor
)) void init(void)
1725 LTT_TRACEFILE_NAME_METADATA
= g_quark_from_string("metadata");