blob: db6b5123d1ad3cd3324fba03dc48bf4011eee013 [file] [log] [blame]
Teresa Charlin9bab4962019-09-06 12:28:35 +01001//
Jim Flynn6da6a452020-07-14 14:26:27 +01002// Copyright © 2019 Arm Ltd and Contributors. All rights reserved.
Teresa Charlin9bab4962019-09-06 12:28:35 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "IProfilingConnection.hpp"
7
Finn Williams9937f932020-04-29 12:00:24 +01008#include <common/include/NetworkSockets.hpp>
Teresa Charlin9bab4962019-09-06 12:28:35 +01009
10#pragma once
11
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000012namespace arm
Teresa Charlin9bab4962019-09-06 12:28:35 +010013{
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000014namespace pipe
Teresa Charlin9bab4962019-09-06 12:28:35 +010015{
16
17class SocketProfilingConnection : public IProfilingConnection
18{
19public:
20 SocketProfilingConnection();
Matteo Martincigh54fb9572019-10-02 12:50:57 +010021 bool IsOpen() const final;
Teresa Charlin9bab4962019-09-06 12:28:35 +010022 void Close() final;
Matteo Martincigh24e8f922019-09-19 11:57:46 +010023 bool WritePacket(const unsigned char* buffer, uint32_t length) final;
Jim Flynnbbfe6032020-07-20 16:57:44 +010024 arm::pipe::Packet ReadPacket(uint32_t timeout) final;
Matteo Martincigh24e8f922019-09-19 11:57:46 +010025
Teresa Charlin9bab4962019-09-06 12:28:35 +010026private:
Colm Donelana21620d2019-10-11 13:09:49 +010027
28 // Read a full packet from the socket.
Jim Flynnbbfe6032020-07-20 16:57:44 +010029 arm::pipe::Packet ReceivePacket();
Colm Donelana21620d2019-10-11 13:09:49 +010030
Jim Flynn6da6a452020-07-14 14:26:27 +010031#ifndef __APPLE__
Teresa Charlin9bab4962019-09-06 12:28:35 +010032 // To indicate we want to use an abstract UDS ensure the first character of the address is 0.
33 const char* m_GatorNamespace = "\0gatord_namespace";
Jim Flynn6da6a452020-07-14 14:26:27 +010034#else
35 // MACOSX does not support abstract UDS
36 const char* m_GatorNamespace = "/tmp/gatord_namespace";
37#endif
Jim Flynne195a042022-04-12 17:19:28 +010038#if !defined(ARMNN_DISABLE_SOCKETS)
Jim Flynnbbfe6032020-07-20 16:57:44 +010039 arm::pipe::PollFd m_Socket[1]{};
Jim Flynne195a042022-04-12 17:19:28 +010040#endif
Teresa Charlin9bab4962019-09-06 12:28:35 +010041};
42
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000043} // namespace pipe
44} // namespace arm