diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2017-03-24 14:59:07 +0100 |
---|---|---|
committer | Milian Wolff <milian.wolff@kdab.com> | 2017-03-27 19:36:46 +0000 |
commit | c9e284904ae7d1e0d3358160ded766e0e46e83ca (patch) | |
tree | 71d42ed6b1aea17f131875e4000e6672e4a30953 | |
parent | 84ff48052518af05ccfe749863a155de33cef74c (diff) |
Also map global attribute ids to internal idsv4.3.0-beta1
So far, only the streamed PerfRecordAttr events updated the mapping
of the attribute ids to the internal ids. Now, we also do this
for the global attributes contained within the PerfFeatures.
This fixes the resolution of the attribute ids for samples in a
non-streamed perf.data file.
Change-Id: I1fabb99727d70e3a1c237691ecd4b7421d76a44e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | app/perfunwind.cpp | 19 | ||||
-rw-r--r-- | app/perfunwind.h | 6 |
2 files changed, 17 insertions, 8 deletions
diff --git a/app/perfunwind.cpp b/app/perfunwind.cpp index caf2ece..8dfcc7f 100644 --- a/app/perfunwind.cpp +++ b/app/perfunwind.cpp @@ -116,20 +116,26 @@ void PerfUnwind::comm(const PerfRecordComm &comm) void PerfUnwind::attr(const PerfRecordAttr &attr) { - const qint32 internalId = resolveAttr(attr.attr(), attr.attr().name()); + addAttributes(attr.attr(), attr.attr().name(), attr.ids()); +} + +void PerfUnwind::addAttributes(const PerfEventAttributes &attributes, const QByteArray &name, + const QList<quint64> &ids) +{ + const qint32 internalId = resolveAttributes(attributes, name); - if (attr.ids().isEmpty()) { + if (ids.isEmpty()) { // If we only get one attribute, it doesn't have an ID. // The default ID for samples is 0, so we assign that here, // in order to look it up in analyze(). m_attributeIds[0] = internalId; } else { - foreach (quint64 id, attr.ids()) + foreach (quint64 id, ids) m_attributeIds[id] = internalId; } } -qint32 PerfUnwind::resolveAttr(const PerfEventAttributes &attributes, const QByteArray &name) +qint32 PerfUnwind::resolveAttributes(const PerfEventAttributes &attributes, const QByteArray &name) { auto it = m_attributes.find(attributes); if (it == m_attributes.end()) { @@ -161,9 +167,8 @@ void PerfUnwind::lost(const PerfRecordLost &lost) void PerfUnwind::features(const PerfFeatures &features) { const auto &eventDescs = features.eventDesc().eventDescs; - for (const auto &desc : eventDescs) { - resolveAttr(desc.attrs, desc.name); - } + for (const auto &desc : eventDescs) + addAttributes(desc.attrs, desc.name, desc.ids); QByteArray buffer; QDataStream(&buffer, QIODevice::WriteOnly) << static_cast<quint8>(FeaturesDefinition) diff --git a/app/perfunwind.h b/app/perfunwind.h index 19361f3..931a552 100644 --- a/app/perfunwind.h +++ b/app/perfunwind.h @@ -129,7 +129,11 @@ public: Dwfl *dwfl(quint32 pid, quint64 timestamp); qint32 resolveString(const QByteArray &string); - qint32 resolveAttr(const PerfEventAttributes &attributes, const QByteArray &name); + + 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); |