Removed monitor target-info machine command

This commit is contained in:
Nav
2022-08-30 02:56:33 +01:00
parent cfb0ee6eee
commit 7a39327c95
5 changed files with 0 additions and 132 deletions

View File

@@ -8,6 +8,5 @@ Supported Bloom commands:
file located in the current project directory. 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 svd --out Generates the System View Description (SVD) XML for the current target and sends it to GDB, as
command output. command output.
target-info machine Outputs information on the connected target, in JSON format.
reset Resets the target and holds it in a stopped state. reset Resets the target and holds it in a stopped state.

View File

@@ -22,7 +22,6 @@ target_sources(
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/HelpMonitorInfo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/HelpMonitorInfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/BloomVersion.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/BloomVersion.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/BloomVersionMachine.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/BloomVersionMachine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/TargetInfoMachine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/GenerateSvd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/CommandPackets/GenerateSvd.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/ResponsePackets/SupportedFeaturesResponse.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Gdb/ResponsePackets/SupportedFeaturesResponse.cpp

View File

@@ -1,95 +0,0 @@
#include "TargetInfoMachine.hpp"
#include <QString>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp"
#include "src/Application.hpp"
#include "src/Logger/Logger.hpp"
namespace Bloom::DebugServer::Gdb::CommandPackets
{
using TargetController::TargetControllerConsole;
using ResponsePackets::ResponsePacket;
TargetInfoMachine::TargetInfoMachine(Monitor&& monitorPacket)
: Monitor(std::move(monitorPacket))
{}
void TargetInfoMachine::handle(DebugSession& debugSession, TargetControllerConsole&) {
Logger::debug("Handling TargetInfoMachine packet");
debugSession.connection.writePacket(ResponsePacket(Packet::toHex(
QJsonDocument(
this->generateTargetInfo(debugSession.gdbTargetDescriptor.targetDescriptor)
).toJson().toStdString()
)));
}
QJsonObject TargetInfoMachine::generateTargetInfo(const Targets::TargetDescriptor& targetDescriptor) const {
using Targets::TargetMemoryType;
static const auto memoryTypeNamesByType = std::map<TargetMemoryType, QString>({
{TargetMemoryType::FLASH, QString("Flash")},
{TargetMemoryType::RAM, QString("RAM")},
{TargetMemoryType::EEPROM, QString("EEPROM")},
});
auto memoryDescriptorsJson = QJsonArray();
for (const auto& [memoryType, memoryDescriptor] : targetDescriptor.memoryDescriptorsByType) {
if (!memoryTypeNamesByType.contains(memoryType)) {
continue;
}
memoryDescriptorsJson.push_back(QJsonObject({
{"name", memoryTypeNamesByType.at(memoryType)},
{"size", static_cast<qint64>(memoryDescriptor.size())},
{"addressRange", QJsonObject({
{"startAddress", "0x" + QString::number(memoryDescriptor.addressRange.startAddress, 16)},
{"endAddress", "0x" + QString::number(memoryDescriptor.addressRange.endAddress, 16)},
})}
}));
}
auto registerDescriptorsJson = QJsonArray();
for (const auto& [registerType, registerDescriptors] : targetDescriptor.registerDescriptorsByType) {
for (const auto& registerDescriptor : registerDescriptors) {
if (!registerDescriptor.name.has_value() || !registerDescriptor.startAddress.has_value()) {
continue;
}
registerDescriptorsJson.push_back(QJsonObject({
{"name", QString::fromStdString(registerDescriptor.name.value())},
{"groupName", QString::fromStdString(registerDescriptor.groupName.value_or("Other"))},
{
"description",
registerDescriptor.description.has_value()
? QString::fromStdString(registerDescriptor.description.value())
: QJsonValue()
},
{"size", static_cast<qint64>(registerDescriptor.size)},
{"startAddress", "0x" + QString::number(registerDescriptor.startAddress.value(), 16)},
{
"gdbStartAddress",
"0x" + QString::number(registerDescriptor.startAddress.value() | 0x00800000UL, 16)
},
}));
}
}
return QJsonObject({
{"target", QJsonObject({
{"name", QString::fromStdString(targetDescriptor.name)},
{"id", QString::fromStdString(targetDescriptor.id)},
{"memoryDescriptors", memoryDescriptorsJson},
{"registerDescriptors", registerDescriptorsJson},
})},
});
}
}

View File

@@ -1,30 +0,0 @@
#pragma once
#include <cstdint>
#include <QJsonObject>
#include "Monitor.hpp"
#include "src/Targets/TargetDescriptor.hpp"
namespace Bloom::DebugServer::Gdb::CommandPackets
{
/**
* The TargetInfoMachine class implements a structure for the "monitor target-info machine" GDB command.
*
* We just output information on the connected target, in JSON format.
*/
class TargetInfoMachine: public Monitor
{
public:
explicit TargetInfoMachine(Monitor&& monitorPacket);
void handle(
DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole
) override;
private:
QJsonObject generateTargetInfo(const Targets::TargetDescriptor& targetDescriptor) const;
};
}

View File

@@ -30,7 +30,6 @@
#include "CommandPackets/HelpMonitorInfo.hpp" #include "CommandPackets/HelpMonitorInfo.hpp"
#include "CommandPackets/BloomVersion.hpp" #include "CommandPackets/BloomVersion.hpp"
#include "CommandPackets/BloomVersionMachine.hpp" #include "CommandPackets/BloomVersionMachine.hpp"
#include "CommandPackets/TargetInfoMachine.hpp"
#include "CommandPackets/GenerateSvd.hpp" #include "CommandPackets/GenerateSvd.hpp"
// Response packets // Response packets
@@ -316,10 +315,6 @@ namespace Bloom::DebugServer::Gdb
return std::make_unique<CommandPackets::ResetTarget>(std::move(*(monitorCommand.release()))); return std::make_unique<CommandPackets::ResetTarget>(std::move(*(monitorCommand.release())));
} }
if (monitorCommand->command == "target-info machine") {
return std::make_unique<CommandPackets::TargetInfoMachine>(std::move(*(monitorCommand.release())));
}
if (monitorCommand->command.find("svd") == 0) { if (monitorCommand->command.find("svd") == 0) {
return std::make_unique<CommandPackets::GenerateSvd>(std::move(*(monitorCommand.release()))); return std::make_unique<CommandPackets::GenerateSvd>(std::move(*(monitorCommand.release())));
} }