/
lttng2lxt.c
126 lines (101 loc) · 2.26 KB
/
lttng2lxt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
* LTTng to GTKwave trace conversion
*
* Authors:
* Ivan Djelic <ivan.djelic@parrot.com>
* Matthieu Castet <matthieu.castet@parrot.com>
*
* Copyright (C) 2013 Parrot S.A.
*/
#include "lttng2lxt.h"
int verbose;
int diag;
int gtkwave_parrot = 1;
int show_cpu_switch = 1;
int do_stats = 0;
static void link_gtkw_file(const char *tracefile, const char *savefile)
{
int ret;
char *gtkwfile;
ret = asprintf(>kwfile, "%s.gtkw", tracefile);
assert(ret > 0);
unlink(gtkwfile);
link(savefile, gtkwfile);
free(gtkwfile);
}
static void usage(void)
{
fprintf(stderr, "\nUsage: lttng2lxt [-v] [-d] [-c] [-s] [-a] [-S <stat mask>] [-e <exefile>] "
"<lttng_trace_dir> [<outputfile> <savefile>]\n");
exit(1);
}
int main(int argc, char *argv[])
{
int c, ret;
char *tracefile;
char *outputfile, *savefile;
int rebase_clock = 1;
while ((c = getopt(argc, argv, "hvdcse:S:a")) != -1) {
switch (c) {
case 'e':
atag_init(optarg);
break;
case 'v':
verbose = 1;
break;
case 'd':
diag = 1;
break;
case 'c':
gtkwave_parrot = 1;
break;
case 's':
show_cpu_switch = !show_cpu_switch;
break;
case 'S':
do_stats = atoi(optarg);
break;
case 'a':
rebase_clock = 0;
break;
case 'h':
default:
usage();
break;
}
}
display_modules();
if ((optind != argc-1) && (optind != argc-3))
usage();
tracefile = argv[optind];
if (optind == argc-3) {
outputfile = argv[optind+1];
savefile = argv[optind+2];
} else {
/* make new names with proper extensions */
if (tracefile[strlen(tracefile)-1] == '/') /* strip last / */
tracefile[strlen(tracefile)-1] = 0;
ret = asprintf(&outputfile, "%s.fst", tracefile);
assert(ret > 0);
ret = asprintf(&savefile, "%s.sav", tracefile);
assert(ret > 0);
}
save_dump_init(outputfile);
/* do the actual work */
scan_lttng_trace(tracefile, rebase_clock);
/* create a savefile for GTKwave with comments, trace ordering, etc. */
write_savefile(savefile);
link_gtkw_file(tracefile, savefile);
save_dump_close();
fprintf(stdout, "%s: Generated '%s' file\n", argv[0], outputfile);
if (optind != argc-3) {
free(outputfile);
free(savefile);
}
if (do_stats & STAT_IRQ)
irq_stats();
if (do_stats & STAT_SOFTIRQ)
softirq_stats();
unregister_modules();
return 0;
}