diff options
Diffstat (limited to 'profiling/server/include/timelineDecoder')
4 files changed, 276 insertions, 0 deletions
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 <cstdint> +#include <string> + +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 <common/include/CommandHandlerFunctor.hpp> +#include <common/include/Packet.hpp> + +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 <vector> + +namespace arm +{ + +namespace pipe +{ + +class TimelineDecoder : public ITimelineDecoder +{ + +public: + + struct Model + { + std::vector<Entity> m_Entities; + std::vector<EventClass> m_EventClasses; + std::vector<Event> m_Events; + std::vector<Label> m_Labels; + std::vector<Relationship> m_Relationships; + }; + + using OnNewEntityCallback = void (*)(Model &, const Entity); + using OnNewEventClassCallback = void (*)(Model &, const EventClass); + using OnNewEventCallback = void (*)(Model &, const Event); + using OnNewLabelCallback = void (*)(Model &, const Label); + using OnNewRelationshipCallback = void (*)(Model &, const Relationship); + + virtual TimelineStatus CreateEntity(const Entity &) override; + virtual TimelineStatus CreateEventClass(const EventClass &) override; + virtual TimelineStatus CreateEvent(const Event &) override; + virtual TimelineStatus CreateLabel(const Label &) override; + virtual TimelineStatus CreateRelationship(const Relationship &) override; + + const Model& GetModel(); + + TimelineStatus SetEntityCallback(const OnNewEntityCallback); + TimelineStatus SetEventClassCallback(const OnNewEventClassCallback); + TimelineStatus SetEventCallback(const OnNewEventCallback); + TimelineStatus SetLabelCallback(const OnNewLabelCallback); + TimelineStatus SetRelationshipCallback(const OnNewRelationshipCallback); + + void SetDefaultCallbacks(); + + void print(); + +private: + Model m_Model; + + OnNewEntityCallback m_OnNewEntityCallback; + OnNewEventClassCallback m_OnNewEventClassCallback; + OnNewEventCallback m_OnNewEventCallback; + OnNewLabelCallback m_OnNewLabelCallback; + OnNewRelationshipCallback m_OnNewRelationshipCallback; + + void printLabels(); + void printEntities(); + void printEventClasses(); + void printRelationships(); + void printEvents(); +}; + +} // namespace pipe +} // namespace arm
\ No newline at end of file diff --git a/profiling/server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp b/profiling/server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp new file mode 100644 index 0000000000..826ee1f10d --- /dev/null +++ b/profiling/server/include/timelineDecoder/TimelineDirectoryCaptureCommandHandler.hpp @@ -0,0 +1,50 @@ +// +// Copyright © 2019 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include "TimelineCaptureCommandHandler.hpp" + +#include <common/include/SwTrace.hpp> + +namespace arm +{ + +namespace pipe +{ + +class TimelineDirectoryCaptureCommandHandler : public arm::pipe::CommandHandlerFunctor +{ + // Utils + uint32_t uint8_t_size = sizeof(uint8_t); + uint32_t uint32_t_size = sizeof(uint32_t); + +public: + TimelineDirectoryCaptureCommandHandler(uint32_t familyId, + uint32_t packetId, + uint32_t version, + TimelineCaptureCommandHandler& timelineCaptureCommandHandler, + bool quietOperation = false) + : CommandHandlerFunctor(familyId, packetId, version) + , m_TimelineCaptureCommandHandler(timelineCaptureCommandHandler) + , m_QuietOperation(quietOperation) + {} + + void operator()(const arm::pipe::Packet& packet) override; + + arm::pipe::SwTraceHeader m_SwTraceHeader; + std::vector<arm::pipe::SwTraceMessage> m_SwTraceMessages; + +private: + void ParseData(const arm::pipe::Packet& packet); + void Print(); + + TimelineCaptureCommandHandler& m_TimelineCaptureCommandHandler; + bool m_QuietOperation; +}; + +} //namespace pipe + +} //namespace arm |