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
127
|
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Enterprise Perf Profiler Add-on.
**
** GNU General Public License Usage
** This file may be used under the terms of the GNU General Public License
** version 3 as published by the Free Software Foundation and appearing in
** the file LICENSE.GPLv3 included in the packaging of this file. Please
** review the following information to ensure the GNU General Public License
** requirements will be met: https://www.gnu.org/licenses/gpl.html.
**
** If you have questions regarding the use of this file, please use
** contact form at http://www.qt.io/contact-us
**
****************************************************************************/
#pragma once
#include <QHash>
#include <QIODevice>
#include <QObject>
#include <QVariant>
#include <QVector>
class PerfParserTestClient : public QObject
{
Q_OBJECT
public:
struct AttributeEvent {
quint32 type = 0;
qint32 name = -1;
quint64 config = 0;
bool usesFrequency = false;
quint64 frequencyOrPeriod = 0;
};
struct ThreadEvent {
qint32 pid = -1;
qint32 tid = -1;
quint64 time = 0;
quint32 cpu = 0;
};
struct ThreadEndEvent : public ThreadEvent
{
};
struct CommandEvent : public ThreadEvent {
qint32 name = -1;
};
struct LocationEvent {
quint64 address = 0;
qint32 file = -1;
quint32 pid = 0;
qint32 line = -1;
qint32 column = -1;
qint32 parentLocationId = -1;
};
struct SymbolEvent {
qint32 name = -1;
qint32 binary = -1;
qint32 path = -1;
bool isKernel = false;
};
struct SampleEvent : public ThreadEvent {
QVector<qint32> frames;
QVector<QPair<qint32, quint64>> values;
QHash<qint32, QVariant> tracePointData;
quint8 numGuessedFrames = 0;
};
struct TracePointFormatEvent {
qint32 system = -1;
qint32 name = -1;
quint32 flags = 0;
};
// Repeated here, as we want to check against accidental changes in enum values.
enum EventType {
ThreadStart,
ThreadEnd,
Command,
LocationDefinition,
SymbolDefinition,
StringDefinition,
LostDefinition,
FeaturesDefinition,
Error,
Progress,
TracePointFormat,
AttributesDefinition,
ContextSwitchDefinition,
Sample,
TracePointSample,
InvalidType
};
Q_ENUM(EventType)
explicit PerfParserTestClient(QObject *parent = nullptr);
void extractTrace(QIODevice *output);
QByteArray string(qint32 id) const { return m_strings.value(id); }
CommandEvent command(qint32 tid) const { return m_commands[tid]; }
AttributeEvent attribute(qint32 id) const { return m_attributes.value(id); }
QVector<SampleEvent> samples() const { return m_samples; }
LocationEvent location(qint32 id) const { return m_locations.value(id); }
SymbolEvent symbol(qint32 id) const { return m_symbols.value(id); }
TracePointFormatEvent tracePointFormat(qint32 id) { return m_tracePointFormats.value(id); }
private:
QVector<QByteArray> m_strings;
QVector<AttributeEvent> m_attributes;
QHash<qint32, CommandEvent> m_commands;
QVector<ThreadEndEvent> m_threadEnds;
QVector<LocationEvent> m_locations;
QHash<qint32, SymbolEvent> m_symbols;
QVector<SampleEvent> m_samples;
QHash<qint32, TracePointFormatEvent> m_tracePointFormats;
};
|