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
|
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd
** All rights reserved.
** For any questions to The Qt Company, please use contact form at http://www.qt.io/contact-us
**
** 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 "perffilesection.h"
#include <QDataStream>
#include <QIODevice>
class PerfHeader : public QObject {
Q_OBJECT
public:
PerfHeader(QIODevice *source);
enum Feature {
RESERVED = 0, /* always cleared */
FIRST_FEATURE = 1,
TRACING_DATA = 1,
BUILD_ID,
HOSTNAME,
OSRELEASE,
VERSION,
ARCH,
NRCPUS,
CPUDESC,
CPUID,
TOTAL_MEM,
CMDLINE,
EVENT_DESC,
CPU_TOPOLOGY,
NUMA_TOPOLOGY,
BRANCH_STACK,
PMU_MAPPINGS,
GROUP_DESC,
LAST_FEATURE,
FEAT_BITS = 256,
};
Q_ENUM(Feature)
QDataStream::ByteOrder byteOrder() const;
bool hasFeature(Feature feature) const;
void setFeature(Feature feature);
void clearFeature(Feature feature);
qint64 numAttrs() const { return m_attrs.size > 0 ? m_attrs.size / m_attrSize : 0ll; }
qint64 attrSize() const { return m_attrSize; }
const PerfFileSection &attrs() const { return m_attrs; }
qint64 featureOffset() const { return m_data.offset + m_data.size; }
qint64 dataOffset() const { return m_data.offset; }
qint64 dataSize() const { return m_data.size; }
bool isPipe() const { return m_size == pipeHeaderFixedLength(); }
qint64 size() const { return m_size; }
public slots:
void read();
signals:
void finished();
void error();
private:
static quint16 fileHeaderFixedLength();
static quint16 pipeHeaderFixedLength();
QIODevice *m_source;
qint64 m_magic;
qint64 m_size;
qint64 m_attrSize;
PerfFileSection m_attrs;
PerfFileSection m_data;
PerfFileSection m_eventTypes;
quint64 m_features[FEAT_BITS / 64 + ((FEAT_BITS % 64) > 0 ? 1 : 0)];
static const qint64 s_magicSame = 0x32454c4946524550LL;
static const qint64 s_magicSwitched = 0x50455246494c4532LL;
};
|