blob: 52616c9a276e8f098042cd80f51de85b8bd0547f [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 Flynnbbfe6032020-07-20 16:57:44 +010038 arm::pipe::PollFd m_Socket[1]{};
Teresa Charlin9bab4962019-09-06 12:28:35 +010039};
40
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000041} // namespace pipe
42} // namespace arm