Massive refactor to accommodate RISC-V targets
- Refactored entire codebase (excluding the Insight component) to accommodate multiple target architectures (no longer specific to AVR) - Deleted 'generate SVD' GDB monitor command - I will eventually move this functionality to the Bloom website - Added unit size property to address spaces - Many other changes which I couldn't be bothered to describe here
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "src/DebugServer/Gdb/Signal.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/Exceptions/ClientCommunicationError.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
namespace DebugServer::Gdb::CommandPackets
|
||||
@@ -20,36 +21,49 @@ namespace DebugServer::Gdb::CommandPackets
|
||||
using ResponsePackets::EmptyResponsePacket;
|
||||
using ResponsePackets::ErrorResponsePacket;
|
||||
|
||||
void CommandPacket::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
|
||||
const auto packetString = std::string(this->data.begin(), this->data.end());
|
||||
CommandPacket::CommandPacket(const RawPacket& rawPacket) {
|
||||
if (rawPacket.size() < 5) {
|
||||
throw Exceptions::ClientCommunicationError{"Invalid raw packet size"};
|
||||
}
|
||||
|
||||
this->data.insert(this->data.begin(), rawPacket.begin() + 1, rawPacket.end() - 3);
|
||||
}
|
||||
|
||||
void CommandPacket::handle(
|
||||
DebugSession& debugSession,
|
||||
const TargetDescriptor&,
|
||||
const Targets::TargetDescriptor&,
|
||||
TargetControllerService&
|
||||
) {
|
||||
const auto packetString = std::string{this->data.begin(), this->data.end()};
|
||||
|
||||
if (packetString.empty()) {
|
||||
Logger::error("Empty GDB RSP packet received.");
|
||||
debugSession.connection.writePacket(ErrorResponsePacket());
|
||||
debugSession.connection.writePacket(ErrorResponsePacket{});
|
||||
return;
|
||||
}
|
||||
|
||||
if (packetString[0] == '?') {
|
||||
// Status report
|
||||
debugSession.connection.writePacket(TargetStopped(Signal::TRAP));
|
||||
debugSession.connection.writePacket(TargetStopped{Signal::TRAP});
|
||||
return;
|
||||
}
|
||||
|
||||
if (packetString.find("vMustReplyEmpty") == 0) {
|
||||
Logger::info("Handling vMustReplyEmpty");
|
||||
debugSession.connection.writePacket(EmptyResponsePacket());
|
||||
debugSession.connection.writePacket(EmptyResponsePacket{});
|
||||
return;
|
||||
}
|
||||
|
||||
if (packetString.find("qAttached") == 0) {
|
||||
Logger::info("Handling qAttached");
|
||||
debugSession.connection.writePacket(ResponsePacket(std::vector<unsigned char>({1})));
|
||||
debugSession.connection.writePacket(ResponsePacket{std::vector<unsigned char>({1})});
|
||||
return;
|
||||
}
|
||||
|
||||
Logger::debug("Unknown GDB RSP packet: " + packetString + " - returning empty response");
|
||||
|
||||
// Respond with an empty packet
|
||||
debugSession.connection.writePacket(EmptyResponsePacket());
|
||||
// GDB expects an empty response for all unsupported commands
|
||||
debugSession.connection.writePacket(EmptyResponsePacket{});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user