Files
BloomPatched/src/DebugServer/Gdb/TargetDescriptor.hpp

70 lines
2.2 KiB
C++
Raw Normal View History

2022-03-24 19:04:18 +00:00
#pragma once
#include <cstdint>
#include <optional>
#include <vector>
#include <set>
#include <map>
2022-03-24 19:04:18 +00:00
#include "src/Helpers/BiMap.hpp"
2022-03-24 19:04:18 +00:00
#include "src/Targets/TargetDescriptor.hpp"
#include "src/Targets/TargetRegisterDescriptor.hpp"
#include "src/Targets/TargetMemory.hpp"
2022-03-24 19:04:18 +00:00
2022-03-25 00:19:32 +00:00
#include "RegisterDescriptor.hpp"
namespace DebugServer::Gdb
2022-03-24 19:04:18 +00:00
{
using GdbMemoryAddress = std::uint32_t;
2022-04-03 17:00:40 +01:00
/**
* GDB target descriptor.
*/
class TargetDescriptor
2022-03-24 19:04:18 +00:00
{
public:
std::map<GdbRegisterId, RegisterDescriptor> gdbRegisterDescriptorsById;
std::map<GdbRegisterId, const Targets::TargetRegisterDescriptor*> targetRegisterDescriptorsByGdbId;
2022-03-24 19:04:18 +00:00
virtual ~TargetDescriptor() = default;
2022-10-25 19:13:02 +01:00
/**
* For targets with multiple address spaces (e.g. AVR), GDB encodes address space information into memory
* addresses, by applying a mask.
*
* This function should identify the encoded address space within a GDB memory address, and return the
* relevant address space descriptor.
2022-10-25 19:13:02 +01:00
*
* @param address
* @return
*/
virtual const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptorFromGdbAddress(
GdbMemoryAddress address
) const = 0;
2022-03-24 19:04:18 +00:00
/**
* This function should translate a GDB memory address to a target memory address. This should strip any
* GDB-specific masks and return an address that can be used within Bloom.
2022-03-24 19:04:18 +00:00
*
* @param address
2022-03-24 19:04:18 +00:00
* @return
*/
virtual Targets::TargetMemoryAddress translateGdbAddress(GdbMemoryAddress address) const = 0;
2022-03-24 19:04:18 +00:00
/**
* This function should translate a target memory address to a GDB memory address. It should encode any
* additional data expected by GDB.
2022-03-24 19:04:18 +00:00
*
* @param address
* @param addressSpaceDescriptor
* @param memorySegmentDescriptor
2022-03-24 19:04:18 +00:00
* @return
*/
virtual GdbMemoryAddress translateTargetMemoryAddress(
Targets::TargetMemoryAddress address,
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor
) const = 0;
2022-03-24 19:04:18 +00:00
};
}