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"
|
|
|
|
|
|
|
|
|
|
#include "src/Helpers/Paths.hpp"
|
2023-01-21 13:37:56 +00:00
|
|
|
#include "src/Helpers/String.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"
|
|
|
|
|
|
|
|
|
|
namespace Bloom::DebugServer::Gdb::CommandPackets
|
|
|
|
|
{
|
|
|
|
|
using TargetController::TargetControllerConsole;
|
|
|
|
|
|
|
|
|
|
using ResponsePackets::ErrorResponsePacket;
|
|
|
|
|
using ResponsePackets::ResponsePacket;
|
|
|
|
|
|
|
|
|
|
using Exceptions::Exception;
|
|
|
|
|
|
|
|
|
|
HelpMonitorInfo::HelpMonitorInfo(Monitor&& monitorPacket)
|
|
|
|
|
: Monitor(std::move(monitorPacket))
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void HelpMonitorInfo::handle(DebugSession& debugSession, TargetControllerConsole&) {
|
|
|
|
|
Logger::debug("Handling HelpMonitorInfo packet");
|
|
|
|
|
|
|
|
|
|
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(
|
2022-12-09 22:26:26 +00:00
|
|
|
QString::fromStdString(
|
|
|
|
|
Paths::compiledResourcesPath() + "/src/DebugServer/Gdb/Resources/GdbHelpMonitorInfo.txt"
|
|
|
|
|
)
|
2022-05-05 20:14:59 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!helpFile.open(QIODevice::ReadOnly)) {
|
|
|
|
|
throw Exception(
|
|
|
|
|
"Failed to open GDB monitor info help file - please report this issue at " + Paths::homeDomainName()
|
|
|
|
|
+ "/report-issue"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
debugSession.connection.writePacket(
|
2023-01-21 13:37:56 +00:00
|
|
|
ResponsePacket(String::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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|