Added "monitor version machine" command, to display the current Bloom version in JSON format
This commit is contained in:
41
src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp
Normal file
41
src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "BloomVersionMachine.hpp"
|
||||
|
||||
#include <QString>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
|
||||
#include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp"
|
||||
|
||||
#include "src/Application.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
{
|
||||
using TargetController::TargetControllerConsole;
|
||||
|
||||
using ResponsePackets::ErrorResponsePacket;
|
||||
using ResponsePackets::ResponsePacket;
|
||||
|
||||
using Exceptions::Exception;
|
||||
|
||||
BloomVersionMachine::BloomVersionMachine(Monitor&& monitorPacket)
|
||||
: Monitor(std::move(monitorPacket))
|
||||
{}
|
||||
|
||||
void BloomVersionMachine::handle(DebugSession& debugSession, TargetControllerConsole&) {
|
||||
Logger::debug("Handling BloomVersionMachine packet");
|
||||
|
||||
debugSession.connection.writePacket(ResponsePacket(Packet::toHex(
|
||||
QJsonDocument(QJsonObject({
|
||||
{"version", QString::fromStdString(Application::VERSION.toString())},
|
||||
{"components", QJsonObject({
|
||||
{"major", Application::VERSION.getMajor()},
|
||||
{"minor", Application::VERSION.getMinor()},
|
||||
{"patch", Application::VERSION.getPatch()},
|
||||
})},
|
||||
})).toJson().toStdString()
|
||||
)));
|
||||
}
|
||||
}
|
||||
24
src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.hpp
Normal file
24
src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "Monitor.hpp"
|
||||
|
||||
namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
{
|
||||
/**
|
||||
* The BloomVersionMachine class implements a structure for the "monitor version machine" GDB command.
|
||||
*
|
||||
* We just output Bloom's current version number in JSON format.
|
||||
*/
|
||||
class BloomVersionMachine: public Monitor
|
||||
{
|
||||
public:
|
||||
explicit BloomVersionMachine(Monitor&& monitorPacket);
|
||||
|
||||
void handle(
|
||||
DebugSession& debugSession,
|
||||
TargetController::TargetControllerConsole& targetControllerConsole
|
||||
) override;
|
||||
};
|
||||
}
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "CommandPackets/Monitor.hpp"
|
||||
#include "CommandPackets/ResetTarget.hpp"
|
||||
#include "CommandPackets/BloomVersion.hpp"
|
||||
#include "CommandPackets/BloomVersionMachine.hpp"
|
||||
|
||||
// Response packets
|
||||
#include "ResponsePackets/TargetStopped.hpp"
|
||||
@@ -298,6 +299,11 @@ namespace Bloom::DebugServer::Gdb
|
||||
if (monitorCommand->command == "version") {
|
||||
return std::make_unique<CommandPackets::BloomVersion>(std::move(*(monitorCommand.get())));
|
||||
}
|
||||
|
||||
if (monitorCommand->command == "version machine") {
|
||||
return std::make_unique<CommandPackets::BloomVersionMachine>(std::move(*(monitorCommand.get())));
|
||||
}
|
||||
|
||||
if (monitorCommand->command == "reset") {
|
||||
return std::make_unique<CommandPackets::ResetTarget>(std::move(*(monitorCommand.get())));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user