IVGCVSW-4541 Modify Timeline Packet construction
* Changed TimelinePacket encoding so that there is only one header for
multiple timeline swtrace messages
* Refactored function names to have more suitable description
* Refactored CodeStyle to coincide with ArmNN coding standards
* Refactored profiling test names to be descriptive
* Refactored ErrorCode name to TimelineStatus
* Updated existing unit tests
Signed-off-by: Keith Davis <keith.davis@arm.com>
Change-Id: I83bd4bb9e7393617bca97eba96a6e1388916e5b0
diff --git a/src/profiling/SendTimelinePacket.hpp b/src/profiling/SendTimelinePacket.hpp
index 737a1aa..b3b4aa1 100644
--- a/src/profiling/SendTimelinePacket.hpp
+++ b/src/profiling/SendTimelinePacket.hpp
@@ -25,8 +25,8 @@
SendTimelinePacket(IBufferManager& bufferManager)
: m_BufferManager(bufferManager)
, m_WriteBuffer(nullptr)
- , m_Offset(0u)
- , m_BufferSize(0u)
+ , m_Offset(8u)
+ , m_RemainingBufferSize(0u)
{}
/// Commits the current buffer and reset the member variables
@@ -59,13 +59,20 @@
template <typename Func, typename ... Params>
void ForwardWriteBinaryFunction(Func& func, Params&& ... params);
- IBufferManager& m_BufferManager;
+ IBufferManager& m_BufferManager;
IPacketBufferPtr m_WriteBuffer;
- unsigned int m_Offset;
- unsigned int m_BufferSize;
+ unsigned int m_Offset;
+ unsigned int m_RemainingBufferSize;
+
+ const unsigned int m_uint32_t_size = sizeof(uint32_t);
+
+ std::pair<uint32_t, uint32_t> m_PacketHeader;
+ uint32_t m_PacketDataLength;
+
+ bool m_DirectoryPackage = false;
};
-template <typename Func, typename ... Params>
+template<typename Func, typename ... Params>
void SendTimelinePacket::ForwardWriteBinaryFunction(Func& func, Params&& ... params)
{
try
@@ -73,30 +80,31 @@
ReserveBuffer();
BOOST_ASSERT(m_WriteBuffer);
unsigned int numberOfBytesWritten = 0;
- while (true)
+ // Header will be prepended to the buffer on Commit()
+ while ( true )
{
TimelinePacketStatus result = func(std::forward<Params>(params)...,
&m_WriteBuffer->GetWritableData()[m_Offset],
- m_BufferSize,
+ m_RemainingBufferSize,
numberOfBytesWritten);
- switch (result)
+ switch ( result )
{
- case TimelinePacketStatus::BufferExhaustion:
- Commit();
- ReserveBuffer();
- continue;
+ case TimelinePacketStatus::BufferExhaustion:
+ Commit();
+ ReserveBuffer();
+ continue;
- case TimelinePacketStatus::Error:
- throw RuntimeException("Error processing while sending TimelineBinaryPacket", CHECK_LOCATION());
+ case TimelinePacketStatus::Error:
+ throw RuntimeException("Error processing while sending TimelineBinaryPacket",
+ CHECK_LOCATION());
- default:
- m_Offset += numberOfBytesWritten;
- m_BufferSize -= numberOfBytesWritten;
- return;
+ default:m_Offset += numberOfBytesWritten;
+ m_RemainingBufferSize -= numberOfBytesWritten;
+ return;
}
}
}
- catch (...)
+ catch ( ... )
{
throw RuntimeException("Error processing while sending TimelineBinaryPacket", CHECK_LOCATION());
}