blob: 31b17aa8fec8ca247398cf80e65ff6c205e7e715 [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
Teresa Charlin9bab4962019-09-06 12:28:35 +01008#include <Runtime.hpp>
Finn Williams9937f932020-04-29 12:00:24 +01009#include <common/include/NetworkSockets.hpp>
Teresa Charlin9bab4962019-09-06 12:28:35 +010010
11#pragma once
12
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000013namespace arm
Teresa Charlin9bab4962019-09-06 12:28:35 +010014{
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000015namespace pipe
Teresa Charlin9bab4962019-09-06 12:28:35 +010016{
17
18class SocketProfilingConnection : public IProfilingConnection
19{
20public:
21 SocketProfilingConnection();
Matteo Martincigh54fb9572019-10-02 12:50:57 +010022 bool IsOpen() const final;
Teresa Charlin9bab4962019-09-06 12:28:35 +010023 void Close() final;
Matteo Martincigh24e8f922019-09-19 11:57:46 +010024 bool WritePacket(const unsigned char* buffer, uint32_t length) final;
Jim Flynnbbfe6032020-07-20 16:57:44 +010025 arm::pipe::Packet ReadPacket(uint32_t timeout) final;
Matteo Martincigh24e8f922019-09-19 11:57:46 +010026
Teresa Charlin9bab4962019-09-06 12:28:35 +010027private:
Colm Donelana21620d2019-10-11 13:09:49 +010028
29 // Read a full packet from the socket.
Jim Flynnbbfe6032020-07-20 16:57:44 +010030 arm::pipe::Packet ReceivePacket();
Colm Donelana21620d2019-10-11 13:09:49 +010031
Jim Flynn6da6a452020-07-14 14:26:27 +010032#ifndef __APPLE__
Teresa Charlin9bab4962019-09-06 12:28:35 +010033 // To indicate we want to use an abstract UDS ensure the first character of the address is 0.
34 const char* m_GatorNamespace = "\0gatord_namespace";
Jim Flynn6da6a452020-07-14 14:26:27 +010035#else
36 // MACOSX does not support abstract UDS
37 const char* m_GatorNamespace = "/tmp/gatord_namespace";
38#endif
Jim Flynnbbfe6032020-07-20 16:57:44 +010039 arm::pipe::PollFd m_Socket[1]{};
Teresa Charlin9bab4962019-09-06 12:28:35 +010040};
41
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000042} // namespace pipe
43} // namespace arm