From bbfe603e5ae42317a2b67d713d00882bea341c88 Mon Sep 17 00:00:00 2001 From: Jim Flynn Date: Mon, 20 Jul 2020 16:57:44 +0100 Subject: IVGCVSW-5166 Pull out the common and server side code into standalone libraries Change-Id: I180f84c493a9b2be4b93b25d312ebdd9e71b1735 Signed-off-by: Jim Flynn --- .../include/timelineDecoder/ITimelineDecoder.hpp | 91 ++++++++++++++++++++++ .../TimelineCaptureCommandHandler.hpp | 63 +++++++++++++++ .../include/timelineDecoder/TimelineDecoder.hpp | 72 +++++++++++++++++ .../TimelineDirectoryCaptureCommandHandler.hpp | 50 ++++++++++++ 4 files changed, 276 insertions(+) create mode 100644 profiling/server/include/timelineDecoder/ITimelineDecoder.hpp create mode 100644 profiling/server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp create mode 100644 profiling/server/include/timelineDecoder/TimelineDecoder.hpp create mode 100644 profiling/server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp (limited to 'profiling/server/include/timelineDecoder') diff --git a/profiling/server/include/timelineDecoder/ITimelineDecoder.hpp b/profiling/server/include/timelineDecoder/ITimelineDecoder.hpp new file mode 100644 index 0000000000..18b8cc7006 --- /dev/null +++ b/profiling/server/include/timelineDecoder/ITimelineDecoder.hpp @@ -0,0 +1,91 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include +#include + +namespace arm +{ + +namespace pipe +{ + +class ITimelineDecoder +{ + +public: + + enum class TimelineStatus + { + TimelineStatus_Success, + TimelineStatus_Fail + }; + + enum class RelationshipType + { + RetentionLink, /// Head retains(parents) Tail + ExecutionLink, /// Head execution start depends on Tail execution completion + DataLink, /// Head uses data of Tail + LabelLink /// Head uses label Tail (Tail MUST be a guid of a label). + }; + + static char const* GetRelationshipAsCString(RelationshipType rType) + { + switch (rType) + { + case RelationshipType::RetentionLink: return "RetentionLink"; + case RelationshipType::ExecutionLink: return "ExecutionLink"; + case RelationshipType::DataLink: return "DataLink"; + case RelationshipType::LabelLink: return "LabelLink"; + default: return "Unknown"; + } + } + + struct Entity + { + uint64_t m_Guid; + }; + + struct EventClass + { + uint64_t m_Guid; + uint64_t m_NameGuid; + }; + + struct Event + { + uint64_t m_Guid; + uint64_t m_TimeStamp; + uint64_t m_ThreadId; + }; + + struct Label + { + uint64_t m_Guid; + std::string m_Name; + }; + + struct Relationship + { + RelationshipType m_RelationshipType; + uint64_t m_Guid; + uint64_t m_HeadGuid; + uint64_t m_TailGuid; + uint64_t m_AttributeGuid; + }; + + virtual ~ITimelineDecoder() = default; + + virtual TimelineStatus CreateEntity(const Entity&) = 0; + virtual TimelineStatus CreateEventClass(const EventClass&) = 0; + virtual TimelineStatus CreateEvent(const Event&) = 0; + virtual TimelineStatus CreateLabel(const Label&) = 0; + virtual TimelineStatus CreateRelationship(const Relationship&) = 0; +}; + +} // namespace pipe +} // namespace arm diff --git a/profiling/server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp b/profiling/server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp new file mode 100644 index 0000000000..c51cfd32cd --- /dev/null +++ b/profiling/server/include/timelineDecoder/TimelineCaptureCommandHandler.hpp @@ -0,0 +1,63 @@ +// +// Copyright © 2019 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include "ITimelineDecoder.hpp" + +#include +#include + +namespace arm +{ + +namespace pipe +{ + +class TimelineCaptureCommandHandler : public arm::pipe::CommandHandlerFunctor +{ + // Utils + uint32_t uint32_t_size = sizeof(uint32_t); + uint32_t uint64_t_size = sizeof(uint64_t); + + using ReadFunction = ITimelineDecoder::TimelineStatus (TimelineCaptureCommandHandler::*)( + const unsigned char*, uint32_t&); + +public: + TimelineCaptureCommandHandler(uint32_t familyId, + uint32_t packetId, + uint32_t version, + ITimelineDecoder& timelineDecoder, + uint32_t threadIdSize = 0) + : CommandHandlerFunctor(familyId, packetId, version) + , m_TimelineDecoder(timelineDecoder) + , m_ThreadIdSize(threadIdSize) + , m_PacketLength(0) + {} + + void operator()(const arm::pipe::Packet& packet) override; + + + void SetThreadIdSize(uint32_t size); + +private: + void ParseData(const arm::pipe::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; + static const ReadFunction m_ReadFunctions[]; + +}; + +} //namespace pipe + +} //namespace arm diff --git a/profiling/server/include/timelineDecoder/TimelineDecoder.hpp b/profiling/server/include/timelineDecoder/TimelineDecoder.hpp new file mode 100644 index 0000000000..ea4b144860 --- /dev/null +++ b/profiling/server/include/timelineDecoder/TimelineDecoder.hpp @@ -0,0 +1,72 @@ +// +// Copyright © 2020 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// +#pragma once + +#include "ITimelineDecoder.hpp" + +#include + +namespace arm +{ + +namespace pipe +{ + +class TimelineDecoder : public ITimelineDecoder +{ + +public: + + struct Model + { + std::vector m_Entities; + std::vector m_EventClasses; + std::vector m_Events; + std::vector