diff options
Diffstat (limited to 'src/timelineDecoder/TimelineCaptureCommandHandler.cpp')
-rw-r--r-- | src/timelineDecoder/TimelineCaptureCommandHandler.cpp | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/timelineDecoder/TimelineCaptureCommandHandler.cpp b/src/timelineDecoder/TimelineCaptureCommandHandler.cpp index 01f55bd6d9..fb6935e247 100644 --- a/src/timelineDecoder/TimelineCaptureCommandHandler.cpp +++ b/src/timelineDecoder/TimelineCaptureCommandHandler.cpp @@ -26,8 +26,9 @@ const TimelineCaptureCommandHandler::ReadFunction TimelineCaptureCommandHandler: void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet) { uint32_t offset = 0; + m_PacketLength = packet.GetLength(); - if (packet.GetLength() < 8) + if ( m_PacketLength < 8 ) { return; } @@ -36,13 +37,16 @@ void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& pa uint32_t declId = 0; - declId = profiling::ReadUint32(data, offset); - offset += uint32_t_size; + while ( offset < m_PacketLength ) + { + declId = profiling::ReadUint32(data, offset); + offset += uint32_t_size; - (this->*m_ReadFunctions[declId])(data, offset); + (this->*m_ReadFunctions[declId])(data, offset); + } } -void TimelineCaptureCommandHandler::ReadLabel(const unsigned char* data, uint32_t offset) +void TimelineCaptureCommandHandler::ReadLabel(const unsigned char* data, uint32_t& offset) { ITimelineDecoder::Label label; label.m_Guid = profiling::ReadUint64(data, offset); @@ -51,30 +55,36 @@ void TimelineCaptureCommandHandler::ReadLabel(const unsigned char* data, uint32_ uint32_t nameLength = profiling::ReadUint32(data, offset); offset += uint32_t_size; - for (uint32_t i = 0; i < nameLength-1; ++i) + uint32_t i = 0; + // nameLength - 1 to account for null operator \0 + for ( i = 0; i < nameLength - 1; ++i ) { label.m_Name += static_cast<char>(profiling::ReadUint8(data, offset + i)); } + // Shift offset past nameLength + uint32_t uint32WordAmount = (nameLength / uint32_t_size) + (nameLength % uint32_t_size != 0 ? 1 : 0); + offset += uint32WordAmount * uint32_t_size; + m_TimelineDecoder.CreateLabel(label); } -void TimelineCaptureCommandHandler::ReadEntity(const unsigned char* data, uint32_t offset) +void TimelineCaptureCommandHandler::ReadEntity(const unsigned char* data, uint32_t& offset) { ITimelineDecoder::Entity entity; entity.m_Guid = profiling::ReadUint64(data, offset); - + offset += uint64_t_size; m_TimelineDecoder.CreateEntity(entity); } -void TimelineCaptureCommandHandler::ReadEventClass(const unsigned char* data, uint32_t offset) +void TimelineCaptureCommandHandler::ReadEventClass(const unsigned char* data, uint32_t& offset) { ITimelineDecoder::EventClass eventClass; eventClass.m_Guid = profiling::ReadUint64(data, offset); - + offset += uint64_t_size; m_TimelineDecoder.CreateEventClass(eventClass); } -void TimelineCaptureCommandHandler::ReadRelationship(const unsigned char* data, uint32_t offset) +void TimelineCaptureCommandHandler::ReadRelationship(const unsigned char* data, uint32_t& offset) { ITimelineDecoder::Relationship relationship; relationship.m_RelationshipType = @@ -84,25 +94,25 @@ void TimelineCaptureCommandHandler::ReadRelationship(const unsigned char* data, relationship.m_Guid = profiling::ReadUint64(data, offset); offset += uint64_t_size; - relationship.m_HeadGuid = profiling::ReadUint64(data, offset); + relationship.m_HeadGuid = profiling::ReadUint64(data, offset); offset += uint64_t_size; relationship.m_TailGuid = profiling::ReadUint64(data, offset); - + offset += uint64_t_size; m_TimelineDecoder.CreateRelationship(relationship); } -void TimelineCaptureCommandHandler::ReadEvent(const unsigned char* data, uint32_t offset) +void TimelineCaptureCommandHandler::ReadEvent(const unsigned char* data, uint32_t& offset) { ITimelineDecoder::Event event; event.m_TimeStamp = profiling::ReadUint64(data, offset); offset += uint64_t_size; - if (m_ThreadIdSize == 4) + if ( m_ThreadIdSize == 4 ) { event.m_ThreadId = profiling::ReadUint32(data, offset); } - else if (m_ThreadIdSize == 8) + else if ( m_ThreadIdSize == 8 ) { event.m_ThreadId = profiling::ReadUint64(data, offset); } @@ -110,6 +120,7 @@ void TimelineCaptureCommandHandler::ReadEvent(const unsigned char* data, uint32_ offset += m_ThreadIdSize; event.m_Guid = profiling::ReadUint64(data, offset); + offset += uint64_t_size; m_TimelineDecoder.CreateEvent(event); } |