• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 
9 #include <common/include/IgnoreUnused.hpp>
10 #include <common/include/TargetEndianess.hpp>
11 
12 #include <cstdint>
13 #include <memory>
14 #include <vector>
15 
16 // forward declare to prevent a circular dependency
17 namespace arm
18 {
19 namespace pipe
20 {
21 
22 class Packet;
23 
24 // the handlers need to be able to do two
25 // things to service the FileOnlyProfilingConnection
26 // and any other implementation of IProfilingConnection
27 // set the endianness and write a packet back i.e.
28 // return a packet and close the connection
29 class IInternalProfilingConnection
30 {
31 public:
~IInternalProfilingConnection()32     virtual ~IInternalProfilingConnection() {};
33 
34     virtual void SetEndianess(const TargetEndianness& endianness) = 0;
35 
36     virtual void ReturnPacket(Packet& packet) = 0;
37 
38     virtual void Close() = 0;
39 };
40 
41 class ILocalPacketHandler
42 {
43 public:
~ILocalPacketHandler()44     virtual ~ILocalPacketHandler() {};
45 
46     /// @return lists the headers of the packets that this handler accepts
47     ///         only these packets will get sent to this handler.
48     ///         If this function returns an empty list then ALL packets
49     ///         will be sent to the PacketHandler i.e. a universal handler.
50     virtual std::vector<uint32_t> GetHeadersAccepted() = 0;
51 
52     /// process the packet
53     virtual void HandlePacket(const Packet& packet) = 0;
54 
55     /// Set a profiling connection on the handler. Only need to implement this
56     /// function if the handler will be writing data back to the profiled application.
SetConnection(IInternalProfilingConnection * profilingConnection)57     virtual void SetConnection(IInternalProfilingConnection* profilingConnection)
58     {
59         arm::pipe::IgnoreUnused(profilingConnection);
60     }
61 };
62 
63 using ILocalPacketHandlerPtr = std::unique_ptr<ILocalPacketHandler>;
64 using ILocalPacketHandlerSharedPtr = std::shared_ptr<ILocalPacketHandler>;
65 
66 } // namespace pipe
67 
68 } // namespace arm
69