Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 1 | // |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 2 | // Copyright © 2019 Arm Ltd and Contributors. All rights reserved. |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "FileOnlyProfilingConnection.hpp" |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 7 | |
Finn Williams | e09fc82 | 2020-04-29 13:17:30 +0100 | [diff] [blame] | 8 | #include <common/include/Constants.hpp> |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 9 | #include <common/include/ProfilingException.hpp> |
Nikhil Raj | 7dcc697 | 2021-04-30 15:44:24 +0100 | [diff] [blame] | 10 | #include <common/include/PacketVersionResolver.hpp> |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 11 | |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 12 | #include <algorithm> |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 13 | #include <iostream> |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 14 | |
| 15 | #if defined(ARMNN_DISABLE_THREADS) |
| 16 | #include <common/include/IgnoreUnused.hpp> |
| 17 | #endif |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 18 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 19 | namespace arm |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 20 | { |
| 21 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 22 | namespace pipe |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 23 | { |
| 24 | |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 25 | std::vector<uint32_t> StreamMetaDataProcessor::GetHeadersAccepted() |
| 26 | { |
| 27 | std::vector<uint32_t> headers; |
| 28 | headers.push_back(m_MetaDataPacketHeader); |
| 29 | return headers; |
| 30 | } |
| 31 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 32 | void StreamMetaDataProcessor::HandlePacket(const arm::pipe::Packet& packet) |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 33 | { |
| 34 | if (packet.GetHeader() != m_MetaDataPacketHeader) |
| 35 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 36 | throw arm::pipe::ProfilingException("StreamMetaDataProcessor can only handle Stream Meta Data Packets"); |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 37 | } |
| 38 | // determine the endianness of the protocol |
| 39 | TargetEndianness endianness; |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 40 | if (ToUint32(packet.GetData(),TargetEndianness::BeWire) == arm::pipe::PIPE_MAGIC) |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 41 | { |
| 42 | endianness = TargetEndianness::BeWire; |
| 43 | } |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 44 | else if (ToUint32(packet.GetData(), TargetEndianness::LeWire) == arm::pipe::PIPE_MAGIC) |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 45 | { |
| 46 | endianness = TargetEndianness::LeWire; |
| 47 | } |
| 48 | else |
| 49 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 50 | throw arm::pipe::ProfilingException("Protocol read error. Unable to read the PIPE_MAGIC value."); |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 51 | } |
| 52 | m_FileOnlyProfilingConnection->SetEndianess(endianness); |
| 53 | // send back the acknowledgement |
| 54 | std::unique_ptr<unsigned char[]> uniqueNullPtr = nullptr; |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 55 | arm::pipe::Packet returnPacket(0x10000, 0, uniqueNullPtr); |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 56 | m_FileOnlyProfilingConnection->ReturnPacket(returnPacket); |
| 57 | } |
| 58 | |
| 59 | uint32_t StreamMetaDataProcessor::ToUint32(const unsigned char* data, TargetEndianness endianness) |
| 60 | { |
| 61 | // Extract the first 4 bytes starting at data and push them into a 32bit integer based on the |
| 62 | // specified endianness. |
| 63 | if (endianness == TargetEndianness::BeWire) |
| 64 | { |
| 65 | return static_cast<uint32_t>(data[0]) << 24 | static_cast<uint32_t>(data[1]) << 16 | |
| 66 | static_cast<uint32_t>(data[2]) << 8 | static_cast<uint32_t>(data[3]); |
| 67 | } |
| 68 | else |
| 69 | { |
| 70 | return static_cast<uint32_t>(data[3]) << 24 | static_cast<uint32_t>(data[2]) << 16 | |
| 71 | static_cast<uint32_t>(data[1]) << 8 | static_cast<uint32_t>(data[0]); |
| 72 | } |
| 73 | } |
| 74 | |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 75 | FileOnlyProfilingConnection::~FileOnlyProfilingConnection() |
| 76 | { |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 77 | try |
| 78 | { |
| 79 | Close(); |
| 80 | } |
| 81 | catch (...) |
| 82 | { |
| 83 | // do nothing |
| 84 | } |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | bool FileOnlyProfilingConnection::IsOpen() const |
| 88 | { |
| 89 | // This type of connection is always open. |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | void FileOnlyProfilingConnection::Close() |
| 94 | { |
| 95 | // Dump any unread packets out of the queue. |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 96 | size_t initialSize = m_PacketQueue.size(); |
| 97 | for (size_t i = 0; i < initialSize; ++i) |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 98 | { |
| 99 | m_PacketQueue.pop(); |
| 100 | } |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 101 | // dispose of the processing thread |
| 102 | m_KeepRunning.store(false); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 103 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 104 | if (m_LocalHandlersThread.joinable()) |
| 105 | { |
| 106 | // make sure the thread wakes up and sees it has to stop |
| 107 | m_ConditionPacketReadable.notify_one(); |
| 108 | m_LocalHandlersThread.join(); |
| 109 | } |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 110 | #endif |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 111 | } |
| 112 | |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 113 | bool FileOnlyProfilingConnection::WritePacket(const unsigned char* buffer, uint32_t length) |
| 114 | { |
Jim Flynn | 6730fe9 | 2022-03-10 22:57:47 +0000 | [diff] [blame] | 115 | ARM_PIPE_ASSERT(buffer); |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 116 | arm::pipe::Packet packet = ReceivePacket(buffer, length); |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 117 | ForwardPacketToHandlers(packet); |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 118 | return true; |
| 119 | } |
| 120 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 121 | void FileOnlyProfilingConnection::ReturnPacket(arm::pipe::Packet& packet) |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 122 | { |
| 123 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 124 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 125 | std::lock_guard<std::mutex> lck(m_PacketAvailableMutex); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 126 | #endif |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 127 | m_PacketQueue.push(std::move(packet)); |
| 128 | } |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 129 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 130 | m_ConditionPacketAvailable.notify_one(); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 131 | #endif |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 132 | } |
| 133 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 134 | arm::pipe::Packet FileOnlyProfilingConnection::ReadPacket(uint32_t timeout) |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 135 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 136 | #if !defined(ARMNN_DISABLE_THREADS) |
Colm Donelan | 4cace32 | 2019-11-20 14:59:12 +0000 | [diff] [blame] | 137 | std::unique_lock<std::mutex> lck(m_PacketAvailableMutex); |
Finn Williams | 09ad6f9 | 2019-12-19 17:05:18 +0000 | [diff] [blame] | 138 | |
| 139 | // Here we are using m_PacketQueue.empty() as a predicate variable |
| 140 | // The conditional variable will wait until packetQueue is not empty or until a timeout |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 141 | if (!m_ConditionPacketAvailable.wait_for(lck, |
| 142 | std::chrono::milliseconds(timeout), |
| 143 | [&]{return !m_PacketQueue.empty();})) |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 144 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 145 | arm::pipe::Packet empty; |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 146 | return empty; |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 147 | } |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 148 | #else |
| 149 | IgnoreUnused(timeout); |
| 150 | #endif |
Finn Williams | 09ad6f9 | 2019-12-19 17:05:18 +0000 | [diff] [blame] | 151 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 152 | arm::pipe::Packet returnedPacket = std::move(m_PacketQueue.front()); |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 153 | m_PacketQueue.pop(); |
| 154 | return returnedPacket; |
| 155 | } |
| 156 | |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 157 | void FileOnlyProfilingConnection::Fail(const std::string& errorMessage) |
| 158 | { |
| 159 | Close(); |
Jim Flynn | f9db3ef | 2022-03-08 21:23:44 +0000 | [diff] [blame] | 160 | throw arm::pipe::ProfilingException(errorMessage); |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 161 | } |
| 162 | |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 163 | /// Adds a local packet handler to the FileOnlyProfilingConnection. Invoking this will start |
| 164 | /// a processing thread that will ensure that processing of packets will happen on a separate |
| 165 | /// thread from the profiling services send thread and will therefore protect against the |
| 166 | /// profiling message buffer becoming exhausted because packet handling slows the dispatch. |
| 167 | void FileOnlyProfilingConnection::AddLocalPacketHandler(ILocalPacketHandlerSharedPtr localPacketHandler) |
| 168 | { |
| 169 | m_PacketHandlers.push_back(std::move(localPacketHandler)); |
| 170 | ILocalPacketHandlerSharedPtr localCopy = m_PacketHandlers.back(); |
| 171 | localCopy->SetConnection(this); |
| 172 | if (localCopy->GetHeadersAccepted().empty()) |
| 173 | { |
| 174 | //this is a universal handler |
| 175 | m_UniversalHandlers.push_back(localCopy); |
| 176 | } |
| 177 | else |
| 178 | { |
| 179 | for (uint32_t header : localCopy->GetHeadersAccepted()) |
| 180 | { |
| 181 | auto iter = m_IndexedHandlers.find(header); |
| 182 | if (iter == m_IndexedHandlers.end()) |
| 183 | { |
| 184 | std::vector<ILocalPacketHandlerSharedPtr> handlers; |
| 185 | handlers.push_back(localCopy); |
| 186 | m_IndexedHandlers.emplace(std::make_pair(header, handlers)); |
| 187 | } |
| 188 | else |
| 189 | { |
| 190 | iter->second.push_back(localCopy); |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | void FileOnlyProfilingConnection::StartProcessingThread() |
| 197 | { |
| 198 | // check if the thread has already started |
| 199 | if (m_IsRunning.load()) |
| 200 | { |
| 201 | return; |
| 202 | } |
| 203 | // make sure if there was one running before it is joined |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 204 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 205 | if (m_LocalHandlersThread.joinable()) |
| 206 | { |
| 207 | m_LocalHandlersThread.join(); |
| 208 | } |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 209 | #endif |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 210 | m_IsRunning.store(true); |
| 211 | m_KeepRunning.store(true); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 212 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 213 | m_LocalHandlersThread = std::thread(&FileOnlyProfilingConnection::ServiceLocalHandlers, this); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 214 | #endif |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 215 | } |
| 216 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 217 | void FileOnlyProfilingConnection::ForwardPacketToHandlers(arm::pipe::Packet& packet) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 218 | { |
| 219 | if (m_PacketHandlers.empty()) |
| 220 | { |
| 221 | return; |
| 222 | } |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 223 | if (!m_KeepRunning.load()) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 224 | { |
| 225 | return; |
| 226 | } |
| 227 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 228 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 229 | std::unique_lock<std::mutex> readableListLock(m_ReadableMutex); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 230 | #endif |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 231 | if (!m_KeepRunning.load()) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 232 | { |
| 233 | return; |
| 234 | } |
| 235 | m_ReadableList.push(std::move(packet)); |
| 236 | } |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 237 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 238 | m_ConditionPacketReadable.notify_one(); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 239 | #endif |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | void FileOnlyProfilingConnection::ServiceLocalHandlers() |
| 243 | { |
| 244 | do |
| 245 | { |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 246 | arm::pipe::Packet returnedPacket; |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 247 | bool readPacket = false; |
| 248 | { // only lock while we are taking the packet off the incoming list |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 249 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 250 | std::unique_lock<std::mutex> lck(m_ReadableMutex); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 251 | #endif |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 252 | if (m_Timeout < 0) |
| 253 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 254 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 255 | m_ConditionPacketReadable.wait(lck, |
| 256 | [&] { return !m_ReadableList.empty(); }); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 257 | #endif |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 258 | } |
| 259 | else |
| 260 | { |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 261 | #if !defined(ARMNN_DISABLE_THREADS) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 262 | m_ConditionPacketReadable.wait_for(lck, |
| 263 | std::chrono::milliseconds(std::max(m_Timeout, 1000)), |
| 264 | [&] { return !m_ReadableList.empty(); }); |
Jim Flynn | e195a04 | 2022-04-12 17:19:28 +0100 | [diff] [blame^] | 265 | #endif |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 266 | } |
| 267 | if (m_KeepRunning.load()) |
| 268 | { |
| 269 | if (!m_ReadableList.empty()) |
| 270 | { |
| 271 | returnedPacket = std::move(m_ReadableList.front()); |
| 272 | m_ReadableList.pop(); |
| 273 | readPacket = true; |
| 274 | } |
| 275 | } |
| 276 | else |
| 277 | { |
| 278 | ClearReadableList(); |
| 279 | } |
| 280 | } |
| 281 | if (m_KeepRunning.load() && readPacket) |
| 282 | { |
| 283 | DispatchPacketToHandlers(returnedPacket); |
| 284 | } |
| 285 | } while (m_KeepRunning.load()); |
| 286 | // make sure the readable list is cleared |
| 287 | ClearReadableList(); |
| 288 | m_IsRunning.store(false); |
| 289 | } |
| 290 | |
| 291 | void FileOnlyProfilingConnection::ClearReadableList() |
| 292 | { |
| 293 | // make sure the incoming packet queue gets emptied |
| 294 | size_t initialSize = m_ReadableList.size(); |
| 295 | for (size_t i = 0; i < initialSize; ++i) |
| 296 | { |
| 297 | m_ReadableList.pop(); |
| 298 | } |
| 299 | } |
| 300 | |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 301 | void FileOnlyProfilingConnection::DispatchPacketToHandlers(const arm::pipe::Packet& packet) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 302 | { |
| 303 | for (auto& delegate : m_UniversalHandlers) |
| 304 | { |
| 305 | delegate->HandlePacket(packet); |
| 306 | } |
| 307 | auto iter = m_IndexedHandlers.find(packet.GetHeader()); |
| 308 | if (iter != m_IndexedHandlers.end()) |
| 309 | { |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 310 | for (auto& delegate : iter->second) |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 311 | { |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 312 | try |
| 313 | { |
| 314 | delegate->HandlePacket(packet); |
| 315 | } |
Jim Flynn | bbfe603 | 2020-07-20 16:57:44 +0100 | [diff] [blame] | 316 | catch (const arm::pipe::ProfilingException& ex) |
Jim Flynn | 01d0281 | 2020-04-29 21:12:13 +0100 | [diff] [blame] | 317 | { |
| 318 | Fail(ex.what()); |
| 319 | } |
| 320 | catch (const std::exception& ex) |
| 321 | { |
| 322 | Fail(ex.what()); |
| 323 | } |
| 324 | catch (...) |
| 325 | { |
| 326 | Fail("handler failed"); |
| 327 | } |
Jim Flynn | 4e755a5 | 2020-03-29 17:48:26 +0100 | [diff] [blame] | 328 | } |
| 329 | } |
| 330 | } |
| 331 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 332 | } // namespace pipe |
Keith Davis | 3201eea | 2019-10-24 17:30:41 +0100 | [diff] [blame] | 333 | |
Cathal Corbett | 5aa9fd7 | 2022-02-25 15:33:28 +0000 | [diff] [blame] | 334 | } // namespace arm |