1 // 2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 6 #include "DeactivateTimelineReportingCommandHandler.hpp" 7 8 #include <common/include/ProfilingException.hpp> 9 10 #include <fmt/format.h> 11 12 13 namespace arm 14 { 15 16 namespace pipe 17 { 18 operator ()(const arm::pipe::Packet & packet)19void DeactivateTimelineReportingCommandHandler::operator()(const arm::pipe::Packet& packet) 20 { 21 ProfilingState currentState = m_StateMachine.GetCurrentState(); 22 23 switch ( currentState ) 24 { 25 case ProfilingState::Uninitialised: 26 case ProfilingState::NotConnected: 27 case ProfilingState::WaitingForAck: 28 throw arm::pipe::ProfilingException(fmt::format( 29 "Deactivate Timeline Reporting Command Handler invoked while in a wrong state: {}", 30 GetProfilingStateName(currentState))); 31 case ProfilingState::Active: 32 if (!(packet.GetPacketFamily() == 0u && packet.GetPacketId() == 7u)) 33 { 34 throw arm::pipe::ProfilingException(std::string( 35 "Expected Packet family = 0, id = 7 but received family =") 36 + std::to_string(packet.GetPacketFamily()) 37 + " id = " + std::to_string(packet.GetPacketId())); 38 } 39 40 m_TimelineReporting.store(false); 41 42 // Notify Backends 43 m_BackendNotifier.NotifyBackendsForTimelineReporting(); 44 45 break; 46 default: 47 throw arm::pipe::ProfilingException(fmt::format("Unknown profiling service state: {}", 48 static_cast<int>(currentState))); 49 } 50 } 51 52 } // namespace pipe 53 54 } // namespace arm 55