aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Flynn <jim.flynn@arm.com>2020-06-26 13:52:38 +0100
committerFrancis Murtagh <francis.murtagh@arm.com>2020-06-26 14:36:42 +0000
commitaa2eb74ff6b8387f045da8f0be39598b45c850a7 (patch)
tree619eecf8fe67081f30f9712a03b27be063e0d58d /src
parent8cfcbb22855817e6af7bc2c967d66ec638106d01 (diff)
downloadarmnn-aa2eb74ff6b8387f045da8f0be39598b45c850a7.tar.gz
IVGCVSW-5049 Terminate Timeline Packet Processing on Error
Change-Id: I2a339da913f18f91734967de2b4a0baa9e2df19b Signed-off-by: Jim Flynn <jim.flynn@arm.com>
Diffstat (limited to 'src')
-rw-r--r--src/timelineDecoder/TimelineCaptureCommandHandler.cpp54
-rw-r--r--src/timelineDecoder/TimelineCaptureCommandHandler.hpp16
2 files changed, 41 insertions, 29 deletions
diff --git a/src/timelineDecoder/TimelineCaptureCommandHandler.cpp b/src/timelineDecoder/TimelineCaptureCommandHandler.cpp
index 9d1e8eee16..39a806ce87 100644
--- a/src/timelineDecoder/TimelineCaptureCommandHandler.cpp
+++ b/src/timelineDecoder/TimelineCaptureCommandHandler.cpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -23,6 +23,16 @@ const TimelineCaptureCommandHandler::ReadFunction TimelineCaptureCommandHandler:
&TimelineCaptureCommandHandler::ReadEvent // Event decl_id = 4
};
+void TimelineCaptureCommandHandler::SetThreadIdSize(uint32_t size)
+{
+ m_ThreadIdSize = size;
+}
+
+void TimelineCaptureCommandHandler::operator()(const profiling::Packet& packet)
+{
+ ParseData(packet);
+}
+
void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& packet)
{
uint32_t offset = 0;
@@ -50,11 +60,17 @@ void TimelineCaptureCommandHandler::ParseData(const armnn::profiling::Packet& pa
declId = profiling::ReadUint32(data, offset);
offset += uint32_t_size;
- (this->*m_ReadFunctions[declId])(data, offset);
+ ITimelineDecoder::TimelineStatus status = (this->*m_ReadFunctions[declId])(data, offset);
+ if (status == ITimelineDecoder::TimelineStatus::TimelineStatus_Fail)
+ {
+ ARMNN_LOG(error) << "Decode of timeline message type [" << declId <<
+ "] at offset [" << offset << "] failed";
+ break;
+ }
}
}
-void TimelineCaptureCommandHandler::ReadLabel(const unsigned char* data, uint32_t& offset)
+ITimelineDecoder::TimelineStatus TimelineCaptureCommandHandler::ReadLabel(const unsigned char* data, uint32_t& offset)
{
ITimelineDecoder::Label label;
label.m_Guid = profiling::ReadUint64(data, offset);
@@ -73,28 +89,31 @@ void TimelineCaptureCommandHandler::ReadLabel(const unsigned char* data, uint32_
uint32_t uint32WordAmount = (nameLength / uint32_t_size) + (nameLength % uint32_t_size != 0 ? 1 : 0);
offset += uint32WordAmount * uint32_t_size;
- m_TimelineDecoder.CreateLabel(label);
+ return m_TimelineDecoder.CreateLabel(label);
}
-void TimelineCaptureCommandHandler::ReadEntity(const unsigned char* data, uint32_t& offset)
+ITimelineDecoder::TimelineStatus 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);
+ return m_TimelineDecoder.CreateEntity(entity);
}
-void TimelineCaptureCommandHandler::ReadEventClass(const unsigned char* data, uint32_t& offset)
+ITimelineDecoder::TimelineStatus TimelineCaptureCommandHandler::ReadEventClass(
+ const unsigned char* data, uint32_t& offset)
{
ITimelineDecoder::EventClass eventClass;
eventClass.m_Guid = profiling::ReadUint64(data, offset);
offset += uint64_t_size;
eventClass.m_NameGuid = profiling::ReadUint64(data, offset);
offset += uint64_t_size;
- m_TimelineDecoder.CreateEventClass(eventClass);
+ return m_TimelineDecoder.CreateEventClass(eventClass);
}
-void TimelineCaptureCommandHandler::ReadRelationship(const unsigned char* data, uint32_t& offset)
+ITimelineDecoder::TimelineStatus TimelineCaptureCommandHandler::ReadRelationship(
+ const unsigned char* data, uint32_t& offset)
{
ITimelineDecoder::Relationship relationship;
relationship.m_RelationshipType =
@@ -113,10 +132,11 @@ void TimelineCaptureCommandHandler::ReadRelationship(const unsigned char* data,
relationship.m_AttributeGuid = profiling::ReadUint64(data, offset);
offset += uint64_t_size;
- m_TimelineDecoder.CreateRelationship(relationship);
+ return m_TimelineDecoder.CreateRelationship(relationship);
}
-void TimelineCaptureCommandHandler::ReadEvent(const unsigned char* data, uint32_t& offset)
+ITimelineDecoder::TimelineStatus TimelineCaptureCommandHandler::ReadEvent(
+ const unsigned char* data, uint32_t& offset)
{
ITimelineDecoder::Event event;
event.m_TimeStamp = profiling::ReadUint64(data, offset);
@@ -136,17 +156,7 @@ void TimelineCaptureCommandHandler::ReadEvent(const unsigned char* data, uint32_
event.m_Guid = profiling::ReadUint64(data, offset);
offset += uint64_t_size;
- m_TimelineDecoder.CreateEvent(event);
-}
-
-void TimelineCaptureCommandHandler::SetThreadIdSize(uint32_t size)
-{
- m_ThreadIdSize = size;
-}
-
-void TimelineCaptureCommandHandler::operator()(const profiling::Packet& packet)
-{
- ParseData(packet);
+ return m_TimelineDecoder.CreateEvent(event);
}
} //namespace gatordmock
diff --git a/src/timelineDecoder/TimelineCaptureCommandHandler.hpp b/src/timelineDecoder/TimelineCaptureCommandHandler.hpp
index 6c0c57ae69..0431e9ca49 100644
--- a/src/timelineDecoder/TimelineCaptureCommandHandler.hpp
+++ b/src/timelineDecoder/TimelineCaptureCommandHandler.hpp
@@ -1,5 +1,5 @@
//
-// Copyright © 2019 Arm Ltd. All rights reserved.
+// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//
@@ -24,7 +24,8 @@ class TimelineCaptureCommandHandler :
uint32_t uint32_t_size = sizeof(uint32_t);
uint32_t uint64_t_size = sizeof(uint64_t);
- using ReadFunction = void (TimelineCaptureCommandHandler::*)(const unsigned char*, uint32_t&);
+ using ReadFunction = ITimelineDecoder::TimelineStatus (TimelineCaptureCommandHandler::*)(
+ const unsigned char*, uint32_t&);
public:
TimelineCaptureCommandHandler(uint32_t familyId,
@@ -40,17 +41,18 @@ public:
void operator()(const armnn::profiling::Packet& packet) override;
- void ReadLabel(const unsigned char* data, uint32_t& offset);
- void ReadEntity(const unsigned char* data, uint32_t& offset);
- void ReadEventClass(const unsigned char* data, uint32_t& offset);
- void ReadRelationship(const unsigned char* data, uint32_t& offset);
- void ReadEvent(const unsigned char* data, uint32_t& offset);
void SetThreadIdSize(uint32_t size);
private:
void ParseData(const armnn::profiling::Packet& packet);
+ ITimelineDecoder::TimelineStatus ReadLabel(const unsigned char* data, uint32_t& offset);
+ ITimelineDecoder::TimelineStatus ReadEntity(const unsigned char* data, uint32_t& offset);
+ ITimelineDecoder::TimelineStatus ReadEventClass(const unsigned char* data, uint32_t& offset);
+ ITimelineDecoder::TimelineStatus ReadRelationship(const unsigned char* data, uint32_t& offset);
+ ITimelineDecoder::TimelineStatus ReadEvent(const unsigned char* data, uint32_t& offset);
+
ITimelineDecoder& m_TimelineDecoder;
uint32_t m_ThreadIdSize;
unsigned int m_PacketLength;