diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dc65b8a..8adc8a59 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ set(CMAKE_SKIP_BUILD_RPATH false) set(CMAKE_BUILD_RPATH_USE_ORIGIN true) set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib:/usr/local/lib") set(CMAKE_BUILD_RPATH ${CMAKE_INSTALL_RPATH}) +set(COMPILED_RESOURCES_BUILD_DIR ${CMAKE_BINARY_DIR}/compiled_resources/) add_compile_definitions(BLOOM_VERSION="${CMAKE_PROJECT_VERSION}") diff --git a/src/DebugServer/CMakeLists.txt b/src/DebugServer/CMakeLists.txt index ee55b87e..64968076 100755 --- a/src/DebugServer/CMakeLists.txt +++ b/src/DebugServer/CMakeLists.txt @@ -40,6 +40,30 @@ target_sources( ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/FlashDone.cpp ) +if (NOT EXCLUDE_INSIGHT) + target_sources( + Bloom + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/ActivateInsight.cpp + ) + + set( + ACTIVATE_INSIGHT_HELP_TEXT + "\n insight Activates the Insight GUI.\n" + ) +endif () + +configure_file( + "./Gdb/Resources/GdbHelpMonitorInfo.txt.in" + "${COMPILED_RESOURCES_BUILD_DIR}/Gdb/GdbHelpMonitorInfo.txt" + @ONLY +) + +set_source_files_properties( + "${COMPILED_RESOURCES_BUILD_DIR}/Gdb/GdbHelpMonitorInfo.txt" + PROPERTIES QT_RESOURCE_ALIAS "/Gdb/Resources/GdbHelpMonitorInfo.txt" +) + # DebugServer resources qt_add_resources( Bloom @@ -48,5 +72,5 @@ qt_add_resources( "/compiled/src/DebugServer" FILES # GDB RSP Server - "./Gdb/Resources/GdbHelpMonitorInfo.txt" + "${COMPILED_RESOURCES_BUILD_DIR}/Gdb/GdbHelpMonitorInfo.txt" ) diff --git a/src/DebugServer/Gdb/CommandPackets/ActivateInsight.cpp b/src/DebugServer/Gdb/CommandPackets/ActivateInsight.cpp new file mode 100644 index 00000000..a30512c7 --- /dev/null +++ b/src/DebugServer/Gdb/CommandPackets/ActivateInsight.cpp @@ -0,0 +1,40 @@ +#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" + +namespace Bloom::DebugServer::Gdb::CommandPackets +{ + using Services::TargetControllerService; + + using ResponsePackets::ResponsePacket; + using ResponsePackets::ErrorResponsePacket; + using Bloom::Exceptions::Exception; + + ActivateInsight::ActivateInsight(Monitor&& monitorPacket) + : Monitor(std::move(monitorPacket)) + {} + + void ActivateInsight::handle(DebugSession& debugSession, TargetControllerService&) { + Logger::info("Handling ActivateInsight packet"); + + try { + EventManager::triggerEvent(std::make_shared()); + + debugSession.connection.writePacket(ResponsePacket(Services::StringService::toHex( + "Insight requested\n" + ))); + + } catch (const Exception& exception) { + Logger::error("Failed to activate Insight - " + exception.getMessage()); + debugSession.connection.writePacket(ErrorResponsePacket()); + } + } +} diff --git a/src/DebugServer/Gdb/CommandPackets/ActivateInsight.hpp b/src/DebugServer/Gdb/CommandPackets/ActivateInsight.hpp new file mode 100644 index 00000000..45a1c213 --- /dev/null +++ b/src/DebugServer/Gdb/CommandPackets/ActivateInsight.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "Monitor.hpp" + +namespace Bloom::DebugServer::Gdb::CommandPackets +{ + /** + * The ActivateInsight class implements a structure for the "monitor insight" GDB command. + * + * This command will activate the Insight GUI. + */ + class ActivateInsight: public Monitor + { + public: + explicit ActivateInsight(Monitor&& monitorPacket); + + void handle( + DebugSession& debugSession, + Services::TargetControllerService& targetControllerService + ) override; + }; +} diff --git a/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp b/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp index 282b60f1..d1df0429 100644 --- a/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp +++ b/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp @@ -34,9 +34,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets * See src/DebugServer/CMakeLists.txt for more. */ auto helpFile = QFile( - QString::fromStdString( - Services::PathService::compiledResourcesPath() + "/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt" - ) + QString::fromStdString(":/compiled/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt") ); if (!helpFile.open(QIODevice::ReadOnly)) { diff --git a/src/DebugServer/Gdb/GdbRspDebugServer.cpp b/src/DebugServer/Gdb/GdbRspDebugServer.cpp index 4f53ea7a..f249fc90 100644 --- a/src/DebugServer/Gdb/GdbRspDebugServer.cpp +++ b/src/DebugServer/Gdb/GdbRspDebugServer.cpp @@ -32,6 +32,10 @@ #include "CommandPackets/Detach.hpp" #include "CommandPackets/EepromFill.hpp" +#ifndef EXCLUDE_INSIGHT +#include "CommandPackets/ActivateInsight.hpp" +#endif + // Response packets #include "ResponsePackets/TargetStopped.hpp" @@ -321,7 +325,11 @@ namespace Bloom::DebugServer::Gdb if (monitorCommand->command.find("eeprom fill") == 0) { return std::make_unique(std::move(*(monitorCommand.release()))); } - +#ifndef EXCLUDE_INSIGHT + if (monitorCommand->command.find("insight") == 0) { + return std::make_unique(std::move(*(monitorCommand.release()))); + } +#endif return monitorCommand; } } diff --git a/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt b/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt.in similarity index 97% rename from src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt rename to src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt.in index c4262597..fa6c020f 100644 --- a/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt +++ b/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt.in @@ -3,7 +3,7 @@ Supported Bloom commands: help Displays this help text. version Outputs Bloom's version information. version machine Outputs Bloom's version information in JSON format. - +@ACTIVATE_INSIGHT_HELP_TEXT@ svd Generates the System View Description (SVD) XML for the current target and saves it into a file located in the current project directory. svd --out Generates the System View Description (SVD) XML for the current target and sends it to GDB, as