New GDB "monitor reset" command packet class
This commit is contained in:
35
src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp
Normal file
35
src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "ResetTarget.hpp"
|
||||
|
||||
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
|
||||
#include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp"
|
||||
|
||||
#include "src/Logger/Logger.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
{
|
||||
using ResponsePackets::ErrorResponsePacket;
|
||||
using ResponsePackets::ResponsePacket;
|
||||
|
||||
using Exceptions::Exception;
|
||||
|
||||
ResetTarget::ResetTarget(Monitor&& monitorPacket)
|
||||
: Monitor(std::move(monitorPacket))
|
||||
{}
|
||||
|
||||
void ResetTarget::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) {
|
||||
Logger::debug("Handling ResetTarget packet");
|
||||
|
||||
try {
|
||||
targetControllerConsole.resetTarget();
|
||||
|
||||
debugSession.connection.writePacket(ResponsePacket(Packet::toHex(
|
||||
"Target reset complete - use the 'continue' command to begin execution.\n"
|
||||
)));
|
||||
|
||||
} catch (const Exception& exception) {
|
||||
Logger::error("Failed to reset target - " + exception.getMessage());
|
||||
debugSession.connection.writePacket(ErrorResponsePacket());
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/DebugServer/Gdb/CommandPackets/ResetTarget.hpp
Normal file
22
src/DebugServer/Gdb/CommandPackets/ResetTarget.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "Monitor.hpp"
|
||||
|
||||
namespace Bloom::DebugServer::Gdb::CommandPackets
|
||||
{
|
||||
/**
|
||||
* The ResetTarget class implements a structure for the custom reset command (triggered via the "monitor reset"
|
||||
* GDB command
|
||||
*
|
||||
* The "monitor reset" command will trigger a target reset and hold the target in a stopped state.
|
||||
*/
|
||||
class ResetTarget: public Monitor
|
||||
{
|
||||
public:
|
||||
explicit ResetTarget(Monitor&& monitorPacket);
|
||||
|
||||
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user