diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2017-11-09 12:32:16 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2017-11-10 10:01:36 +0000 |
commit | 720c871f32386a385a2252baf2e431e550b81d04 (patch) | |
tree | fb1bfde1d5d00277a2f7c3548478f80f746d0182 | |
parent | f382993a8b6d1a9ecd75905114db89c736a1c057 (diff) |
Keep PerfEventAttributes in a vector rather than a hash
We never look them up by value, but we want to be able to look them up
by our internal ID.
Change-Id: Id116ef6eed5dc0d66bb5d1c9676e02530e99a344
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | app/perfattributes.cpp | 41 | ||||
-rw-r--r-- | app/perfattributes.h | 2 | ||||
-rw-r--r-- | app/perfunwind.cpp | 14 | ||||
-rw-r--r-- | app/perfunwind.h | 4 |
4 files changed, 4 insertions, 57 deletions
diff --git a/app/perfattributes.cpp b/app/perfattributes.cpp index e9ea7df..7f0a135 100644 --- a/app/perfattributes.cpp +++ b/app/perfattributes.cpp @@ -208,47 +208,6 @@ bool PerfEventAttributes::operator==(const PerfEventAttributes &rhs) const && m_reserved2 == rhs.m_reserved2; } -uint qHash(const PerfEventAttributes &attrs, uint seed) -{ - QtPrivate::QHashCombine hash; - seed = hash(seed, attrs.m_type); - seed = hash(seed, attrs.m_size); - seed = hash(seed, attrs.m_config); - seed = hash(seed, attrs.m_samplePeriod); - seed = hash(seed, attrs.m_sampleType); - seed = hash(seed, attrs.m_readFormat); - seed = hash(seed, attrs.m_disabled); - seed = hash(seed, attrs.m_inherit); - seed = hash(seed, attrs.m_pinned); - seed = hash(seed, attrs.m_exclusive); - seed = hash(seed, attrs.m_excludeUser); - seed = hash(seed, attrs.m_excludeKernel); - seed = hash(seed, attrs.m_excludeHv); - seed = hash(seed, attrs.m_excludeIdle); - seed = hash(seed, attrs.m_mmap); - seed = hash(seed, attrs.m_comm); - seed = hash(seed, attrs.m_freq); - seed = hash(seed, attrs.m_inheritStat); - seed = hash(seed, attrs.m_enableOnExec); - seed = hash(seed, attrs.m_task); - seed = hash(seed, attrs.m_watermark); - seed = hash(seed, attrs.m_preciseIp); - seed = hash(seed, attrs.m_mmapData); - seed = hash(seed, attrs.m_sampleIdAll); - seed = hash(seed, attrs.m_excludeHost); - seed = hash(seed, attrs.m_excludeGuest); - seed = hash(seed, attrs.m_reserved1); - seed = hash(seed, attrs.m_wakeupEvents); - seed = hash(seed, attrs.m_bpType); - seed = hash(seed, attrs.m_bpAddr); - seed = hash(seed, attrs.m_bpLen); - seed = hash(seed, attrs.m_branchSampleType); - seed = hash(seed, attrs.m_sampleRegsUser); - seed = hash(seed, attrs.m_sampleStackUser); - seed = hash(seed, attrs.m_reserved2); - return seed; -} - bool PerfAttributes::read(QIODevice *device, PerfHeader *header) { if (header->attrSize() < PerfEventAttributes::fixedLength() + PerfFileSection::fixedLength()) { diff --git a/app/perfattributes.h b/app/perfattributes.h index db4f4f2..64e90ad 100644 --- a/app/perfattributes.h +++ b/app/perfattributes.h @@ -267,11 +267,9 @@ private: quint32 m_reserved2; friend QDataStream &operator>>(QDataStream &stream, PerfEventAttributes &attrs); - friend uint qHash(const PerfEventAttributes &attrs, uint seed); }; QDataStream &operator>>(QDataStream &stream, PerfEventAttributes &attrs); -uint qHash(const PerfEventAttributes &attrs, uint seed = 0); class PerfAttributes { public: diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp index 7823791..e06a3ac 100644 --- a/app/perfunwind.cpp +++ b/app/perfunwind.cpp @@ -203,7 +203,9 @@ void PerfUnwind::attr(const PerfRecordAttr &attr) void PerfUnwind::addAttributes(const PerfEventAttributes &attributes, const QByteArray &name, const QList<quint64> &ids) { - const qint32 internalId = resolveAttributes(attributes, name); + const qint32 internalId = m_attributes.size(); + m_attributes.append(attributes); + sendAttributes(internalId, attributes, name); if (ids.isEmpty()) { // If we only get one attribute, it doesn't have an ID. @@ -216,16 +218,6 @@ void PerfUnwind::addAttributes(const PerfEventAttributes &attributes, const QByt } } -qint32 PerfUnwind::resolveAttributes(const PerfEventAttributes &attributes, const QByteArray &name) -{ - auto it = m_attributes.find(attributes); - if (it == m_attributes.end()) { - it = m_attributes.insert(attributes, m_attributes.size()); - sendAttributes(it.value(), attributes, name); - } - return it.value(); -} - void PerfUnwind::sendAttributes(qint32 id, const PerfEventAttributes &attributes, const QByteArray &name) { const qint32 attrNameId = resolveString(name); diff --git a/app/perfunwind.h b/app/perfunwind.h index 7f4eae3..23d256e 100644 --- a/app/perfunwind.h +++ b/app/perfunwind.h @@ -185,8 +185,6 @@ public: void addAttributes(const PerfEventAttributes &attributes, const QByteArray &name, const QList<quint64> &ids); - qint32 resolveAttributes(const PerfEventAttributes &attributes, - const QByteArray &name); int lookupLocation(const Location &location) const; int resolveLocation(const Location &location); @@ -262,7 +260,7 @@ private: QHash<Location, qint32> m_locations; QHash<qint32, Symbol> m_symbols; QHash<quint64, qint32> m_attributeIds; - QHash<PerfEventAttributes, qint32> m_attributes; + QVector<PerfEventAttributes> m_attributes; QHash<QByteArray, QByteArray> m_buildIds; uint m_maxEventBufferSize; |