2022-05-05 20:14:59 +01:00
|
|
|
#include "HelpMonitorInfo.hpp"
|
|
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
|
|
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
|
|
|
|
|
#include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp"
|
|
|
|
|
|
2022-12-26 21:47:09 +00:00
|
|
|
#include "src/Services/PathService.hpp"
|
2023-01-21 14:27:45 +00:00
|
|
|
#include "src/Services/StringService.hpp"
|
2022-05-05 20:14:59 +01:00
|
|
|
#include "src/Logger/Logger.hpp"
|
2023-01-21 13:37:56 +00:00
|
|
|
|
2022-05-05 20:14:59 +01:00
|
|
|
#include "src/Exceptions/Exception.hpp"
|
|
|
|
|
|
2023-08-13 15:47:51 +01:00
|
|
|
namespace DebugServer::Gdb::CommandPackets
|
2022-05-05 20:14:59 +01:00
|
|
|
{
|
2022-12-26 21:27:19 +00:00
|
|
|
using Services::TargetControllerService;
|
2022-05-05 20:14:59 +01:00
|
|
|
|
|
|
|
|
using ResponsePackets::ErrorResponsePacket;
|
|
|
|
|
using ResponsePackets::ResponsePacket;
|
|
|
|
|
|
2023-08-13 15:47:51 +01:00
|
|
|
using ::Exceptions::Exception;
|
2022-05-05 20:14:59 +01:00
|
|
|
|
|
|
|
|
HelpMonitorInfo::HelpMonitorInfo(Monitor&& monitorPacket)
|
|
|
|
|
: Monitor(std::move(monitorPacket))
|
|
|
|
|
{}
|
|
|
|
|
|
2022-12-26 21:27:19 +00:00
|
|
|
void HelpMonitorInfo::handle(DebugSession& debugSession, TargetControllerService&) {
|
2023-05-07 20:17:33 +01:00
|
|
|
Logger::info("Handling HelpMonitorInfo packet");
|
2022-05-05 20:14:59 +01:00
|
|
|
|
|
|
|
|
try {
|
2022-07-23 16:13:08 +01:00
|
|
|
/*
|
2022-12-09 22:26:26 +00:00
|
|
|
* The file GdbHelpMonitorInfo.txt is included in the binary image as a resource.
|
|
|
|
|
* See src/DebugServer/CMakeLists.txt for more.
|
2022-07-23 16:13:08 +01:00
|
|
|
*/
|
2022-05-05 20:14:59 +01:00
|
|
|
auto helpFile = QFile(
|
2023-05-24 23:15:47 +01:00
|
|
|
QString::fromStdString(":/compiled/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt")
|
2022-05-05 20:14:59 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!helpFile.open(QIODevice::ReadOnly)) {
|
|
|
|
|
throw Exception(
|
2023-01-21 14:27:45 +00:00
|
|
|
"Failed to open GDB monitor info help file - please report this issue at "
|
|
|
|
|
+ Services::PathService::homeDomainName() + "/report-issue"
|
2022-05-05 20:14:59 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
debugSession.connection.writePacket(
|
2023-01-21 14:27:45 +00:00
|
|
|
ResponsePacket(Services::StringService::toHex(
|
|
|
|
|
"\n" + QTextStream(&helpFile).readAll().toUtf8().toStdString() + "\n"
|
|
|
|
|
))
|
2022-05-05 20:14:59 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
} catch (const Exception& exception) {
|
|
|
|
|
Logger::error(exception.getMessage());
|
|
|
|
|
debugSession.connection.writePacket(ErrorResponsePacket());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|