Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
tracegen.cpp
Go to the documentation of this file.
1
// Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Rafael Roquetto <rafael.roquetto@kdab.com>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4
#
include
"provider.h"
5
#
include
"ctf.h"
6
#
include
"lttng.h"
7
#
include
"etw.h"
8
#
include
"panic.h"
9
10
#
include
<
qstring
.
h
>
11
#
include
<
qfile
.
h
>
12
13
enum
class
Target
14
{
15
LTTNG,
16
ETW,
17
CTF,
18
};
19
20
static
inline
void
usage
(
int
status)
21
{
22
printf(
"Usage: tracegen <lttng|etw|ctf> <input file> <output file>\n"
);
23
exit(status);
24
}
25
26
static
void
parseArgs
(
int
argc,
char
*argv[], Target *target, QString *inFile, QString *outFile)
27
{
28
if
(argc == 1)
29
usage
(
EXIT_SUCCESS
)
;
30
if
(argc != 4)
31
usage
(
EXIT_FAILURE
)
;
32
33
const
char
*targetString = argv[1];
34
35
if
(qstrcmp(targetString,
"lttng"
) == 0) {
36
*target = Target::LTTNG;
37
}
else
if
(qstrcmp(targetString,
"etw"
) == 0) {
38
*target = Target::ETW;
39
}
else
if
(qstrcmp(targetString,
"ctf"
) == 0) {
40
*target = Target::CTF;
41
}
else
{
42
fprintf(stderr,
"Invalid target: %s\n"
, targetString);
43
usage
(
EXIT_FAILURE
)
;
44
}
45
46
*inFile = QLatin1StringView(argv[2]);
47
*outFile = QLatin1StringView(argv[3]);
48
}
49
50
int
main
(
int
argc,
char
*argv[])
51
{
52
Target target = Target::LTTNG;
53
QString inFile;
54
QString outFile;
55
56
parseArgs(argc, argv, &target, &inFile, &outFile);
57
58
Provider
p = parseProvider(inFile);
59
60
QFile out(outFile);
61
62
if
(!out.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
63
panic(
"Cannot open '%s' for writing: %s"
,
64
qPrintable
(outFile),
qPrintable
(out.errorString()));
65
}
66
67
switch
(target) {
68
case
Target::CTF:
69
writeCtf(out, p);
70
break
;
71
case
Target::LTTNG:
72
writeLttng(out, p);
73
break
;
74
case
Target::ETW:
75
writeEtw(out, p);
76
break
;
77
}
78
79
return
0;
80
}
qPrintable
#define qPrintable(string)
Definition
qstring.h:1685
main
int main(int argc, char *argv[])
[ctor_close]
Definition
src_corelib_animation_qpropertyanimation.cpp:100
Provider
Definition
provider.h:82
usage
static void usage(int status)
Definition
tracegen.cpp:20
parseArgs
static void parseArgs(int argc, char *argv[], Target *target, QString *inFile, QString *outFile)
Definition
tracegen.cpp:26
qtbase
src
tools
tracegen
tracegen.cpp
Generated on
for Qt by
1.14.0