2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2022-03-31 21:52:46 +01:00
|
|
|
#include "src/DebugServer/Gdb/Packet.hpp"
|
|
|
|
|
#include "src/DebugServer/Gdb/DebugSession.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-12-26 21:27:19 +00:00
|
|
|
#include "src/Services/TargetControllerService.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-03-31 16:05:39 +01:00
|
|
|
namespace Bloom::DebugServer::Gdb::CommandPackets
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* GDB RSP command packets are sent to the server, from the GDB client. These packets carry instructions that the
|
|
|
|
|
* server is expected to carry out. Upon completion, the server is expected to respond to the client with
|
|
|
|
|
* a ResponsePacket.
|
|
|
|
|
*
|
|
|
|
|
* For some command packets, we define a specific data structure by extending this CommandPacket class. These
|
|
|
|
|
* classes extend the data structure to include fields for data which may be specific to the command.
|
|
|
|
|
* They also implement additional methods that allow us to easily access the additional data. An example
|
|
|
|
|
* of this would be the SupportedFeaturesQuery class. It extends the CommandPacket class and provides access
|
|
|
|
|
* to additional data fields that are specific to the command (in this case, a set of GDB features reported to be
|
|
|
|
|
* supported by the GDB client).
|
|
|
|
|
*
|
|
|
|
|
* Typically, command packets that require specific data structures are handled in a dedicated handler method
|
|
|
|
|
* in the GdbRspDebugServer. This is done by double dispatching the packet object to the appropriate handler.
|
|
|
|
|
* See CommandPacket::dispatchToHandler(), GdbRspDebugServer::serve() and the overloads
|
|
|
|
|
* for GdbRspDebugServer::handleGdbPacket() for more on this.
|
|
|
|
|
*
|
|
|
|
|
* Some command packets are so simple they do not require a dedicated data structure. An example of this is
|
|
|
|
|
* the halt reason packet, which contains nothing more than an ? character in the packet body. These packets are
|
|
|
|
|
* typically handled in the generic GdbRspDebugServer::handleGdbPacket(CommandPacket&) method.
|
|
|
|
|
*
|
|
|
|
|
* See the Packet class for information on how the raw packets are formatted.
|
|
|
|
|
*/
|
|
|
|
|
class CommandPacket: public Packet
|
|
|
|
|
{
|
|
|
|
|
public:
|
2023-04-01 14:30:33 +01:00
|
|
|
explicit CommandPacket(const RawPacket& rawPacket)
|
|
|
|
|
: Packet(rawPacket)
|
|
|
|
|
{}
|
|
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
/**
|
2022-03-24 19:17:41 +00:00
|
|
|
* Should handle the command for the current active debug session.
|
|
|
|
|
*
|
|
|
|
|
* @param debugSession
|
|
|
|
|
* The current active debug session.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2022-12-26 21:27:19 +00:00
|
|
|
* @param TargetControllerService
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
2022-04-09 15:57:24 +01:00
|
|
|
virtual void handle(
|
|
|
|
|
DebugSession& debugSession,
|
2022-12-26 21:27:19 +00:00
|
|
|
Services::TargetControllerService& targetControllerService
|
2022-04-09 15:57:24 +01:00
|
|
|
);
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
}
|