2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <optional>
|
|
|
|
|
|
2024-10-25 22:22:25 +01:00
|
|
|
#include "CommandPacket.hpp"
|
2022-08-30 02:04:35 +01:00
|
|
|
|
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"
|
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 ReadMemory class implements a structure for "m" packets. Upon receiving these packets, the server is
|
|
|
|
|
* expected to read memory from the target and send it the client.
|
|
|
|
|
*/
|
2024-10-25 22:22:25 +01:00
|
|
|
class ReadMemory: public CommandPackets::CommandPacket
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2024-07-23 21:14:22 +01:00
|
|
|
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2024-07-23 21:14:22 +01:00
|
|
|
Targets::TargetMemoryAddress startAddress;
|
|
|
|
|
Targets::TargetMemorySize bytes;
|
2022-04-03 20:35:53 +01:00
|
|
|
|
2024-10-25 22:22:25 +01:00
|
|
|
ReadMemory(const RawPacket& rawPacket, const AvrGdbTargetDescriptor& gdbTargetDescriptor);
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-04-09 15:57:24 +01:00
|
|
|
void handle(
|
2024-10-25 22:22:25 +01:00
|
|
|
DebugSession& debugSession,
|
|
|
|
|
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
2024-07-23 21:14:22 +01:00
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
GdbMemoryAddress gdbStartAddress;
|
|
|
|
|
std::uint32_t bytes;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static PacketData extractPacketData(const RawPacket& rawPacket);
|
|
|
|
|
ReadMemory(
|
|
|
|
|
const RawPacket& rawPacket,
|
2024-10-25 22:22:25 +01:00
|
|
|
const AvrGdbTargetDescriptor& gdbTargetDescriptor,
|
2024-07-23 21:14:22 +01:00
|
|
|
PacketData&& packetData
|
|
|
|
|
);
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
}
|