2023-05-24 23:15:47 +01:00
|
|
|
#include "ActivateInsight.hpp"
|
|
|
|
|
|
|
|
|
|
#include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp"
|
|
|
|
|
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
|
|
|
|
|
|
|
|
|
|
#include "src/EventManager/EventManager.hpp"
|
|
|
|
|
#include "src/EventManager/Events/InsightActivationRequested.hpp"
|
|
|
|
|
#include "src/Services/StringService.hpp"
|
|
|
|
|
#include "src/Logger/Logger.hpp"
|
|
|
|
|
|
|
|
|
|
#include "src/Exceptions/Exception.hpp"
|
|
|
|
|
|
2023-08-13 15:47:51 +01:00
|
|
|
namespace DebugServer::Gdb::CommandPackets
|
2023-05-24 23:15:47 +01:00
|
|
|
{
|
|
|
|
|
using Services::TargetControllerService;
|
|
|
|
|
|
|
|
|
|
using ResponsePackets::ResponsePacket;
|
|
|
|
|
using ResponsePackets::ErrorResponsePacket;
|
2023-08-13 15:47:51 +01:00
|
|
|
using ::Exceptions::Exception;
|
2023-05-24 23:15:47 +01:00
|
|
|
|
|
|
|
|
ActivateInsight::ActivateInsight(Monitor&& monitorPacket)
|
|
|
|
|
: Monitor(std::move(monitorPacket))
|
|
|
|
|
{}
|
|
|
|
|
|
2024-07-23 21:14:22 +01:00
|
|
|
void ActivateInsight::handle(
|
|
|
|
|
DebugSession& debugSession,
|
|
|
|
|
const TargetDescriptor&,
|
|
|
|
|
const Targets::TargetDescriptor&,
|
|
|
|
|
TargetControllerService&
|
|
|
|
|
) {
|
2023-05-24 23:15:47 +01:00
|
|
|
Logger::info("Handling ActivateInsight packet");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
EventManager::triggerEvent(std::make_shared<Events::InsightActivationRequested>());
|
|
|
|
|
|
2024-07-23 21:14:22 +01:00
|
|
|
debugSession.connection.writePacket(
|
|
|
|
|
ResponsePacket{Services::StringService::toHex("The Insight GUI will be with you shortly.\n")}
|
|
|
|
|
);
|
2023-05-24 23:15:47 +01:00
|
|
|
|
|
|
|
|
} catch (const Exception& exception) {
|
|
|
|
|
Logger::error("Failed to activate Insight - " + exception.getMessage());
|
2024-07-23 21:14:22 +01:00
|
|
|
debugSession.connection.writePacket(ErrorResponsePacket{});
|
2023-05-24 23:15:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|