2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <optional>
|
|
|
|
|
|
2022-08-30 02:04:35 +01:00
|
|
|
#include "src/DebugServer/Gdb/CommandPackets/CommandPacket.hpp"
|
|
|
|
|
|
2024-07-23 21:14:22 +01:00
|
|
|
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
2022-08-30 02:04:35 +01:00
|
|
|
#include "src/Targets/TargetMemory.hpp"
|
2024-07-23 21:14:22 +01:00
|
|
|
#include "src/DebugServer/Gdb/AvrGdb/TargetDescriptor.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2023-08-13 15:47:51 +01:00
|
|
|
namespace DebugServer::Gdb::AvrGdb::CommandPackets
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The WriteMemory class implements the structure for "M" packets. Upon receiving this packet, the server is
|
|
|
|
|
* expected to write data to the target's memory, at the specified start address.
|
|
|
|
|
*/
|
2022-08-30 02:04:35 +01:00
|
|
|
class WriteMemory: public Gdb::CommandPackets::CommandPacket
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2024-07-23 21:14:22 +01:00
|
|
|
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
|
|
|
|
Targets::TargetMemoryAddress startAddress;
|
|
|
|
|
Targets::TargetMemorySize bytes;
|
2021-05-24 20:58:49 +01:00
|
|
|
Targets::TargetMemoryBuffer buffer;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2024-07-23 21:14:22 +01:00
|
|
|
explicit WriteMemory(const RawPacket& rawPacket, const TargetDescriptor& gdbTargetDescriptor);
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-04-09 15:57:24 +01:00
|
|
|
void handle(
|
2023-09-10 22:27:10 +01:00
|
|
|
Gdb::DebugSession& debugSession,
|
2024-07-23 21:14:22 +01:00
|
|
|
const Gdb::TargetDescriptor& gdbTargetDescriptor,
|
|
|
|
|
const Targets::TargetDescriptor& targetDescriptor,
|
2022-12-26 21:27:19 +00:00
|
|
|
Services::TargetControllerService& targetControllerService
|
2022-04-09 15:57:24 +01:00
|
|
|
) override;
|
2024-07-23 21:14:22 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct PacketData
|
|
|
|
|
{
|
|
|
|
|
std::uint32_t gdbStartAddress;
|
|
|
|
|
std::uint32_t bytes;
|
|
|
|
|
Targets::TargetMemoryBuffer buffer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static PacketData extractPacketData(const RawPacket& rawPacket);
|
|
|
|
|
WriteMemory(const RawPacket& rawPacket, const Gdb::TargetDescriptor& gdbTargetDescriptor, PacketData&& packetData);
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
}
|