2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
2023-09-20 23:37:54 +01:00
|
|
|
#include <optional>
|
2023-09-23 21:50:04 +01:00
|
|
|
#include <cassert>
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-09-06 17:16:49 +01:00
|
|
|
#include "TargetMemory.hpp"
|
|
|
|
|
|
2023-08-13 15:47:51 +01:00
|
|
|
namespace Targets
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
2023-09-20 23:37:54 +01:00
|
|
|
enum class TargetBreakCause: std::uint8_t
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
|
|
|
|
BREAKPOINT,
|
|
|
|
|
UNKNOWN,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct TargetBreakpoint
|
|
|
|
|
{
|
2023-09-20 23:37:54 +01:00
|
|
|
enum class Type: std::uint8_t
|
|
|
|
|
{
|
|
|
|
|
HARDWARE,
|
|
|
|
|
SOFTWARE,
|
|
|
|
|
};
|
|
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
/**
|
|
|
|
|
* Byte address of the breakpoint.
|
|
|
|
|
*/
|
2022-09-06 17:16:49 +01:00
|
|
|
TargetMemoryAddress address = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2023-09-20 23:37:54 +01:00
|
|
|
Type type = Type::SOFTWARE;
|
|
|
|
|
|
2022-04-03 16:59:14 +01:00
|
|
|
TargetBreakpoint() = default;
|
2023-09-20 23:37:54 +01:00
|
|
|
|
|
|
|
|
explicit TargetBreakpoint(TargetMemoryAddress address, Type type = Type::SOFTWARE)
|
|
|
|
|
: address(address)
|
|
|
|
|
, type(type)
|
|
|
|
|
{};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct BreakpointResources
|
|
|
|
|
{
|
2024-03-21 15:03:06 +00:00
|
|
|
std::optional<std::uint16_t> maximumHardwareBreakpoints = std::nullopt;
|
|
|
|
|
std::optional<std::uint16_t> maximumSoftwareBreakpoints = std::nullopt;
|
|
|
|
|
std::uint16_t reservedHardwareBreakpoints = 0;
|
|
|
|
|
|
|
|
|
|
BreakpointResources() = default;
|
2023-09-20 23:37:54 +01:00
|
|
|
|
|
|
|
|
BreakpointResources(
|
|
|
|
|
std::optional<std::uint16_t> maximumHardwareBreakpoints,
|
2023-09-23 21:50:04 +01:00
|
|
|
std::optional<std::uint16_t> maximumSoftwareBreakpoints,
|
|
|
|
|
std::uint16_t reservedHardwareBreakpoints
|
2023-09-20 23:37:54 +01:00
|
|
|
)
|
|
|
|
|
: maximumHardwareBreakpoints(maximumHardwareBreakpoints)
|
|
|
|
|
, maximumSoftwareBreakpoints(maximumSoftwareBreakpoints)
|
2023-09-23 21:50:04 +01:00
|
|
|
, reservedHardwareBreakpoints(reservedHardwareBreakpoints)
|
|
|
|
|
{
|
|
|
|
|
assert(
|
|
|
|
|
!this->maximumHardwareBreakpoints.has_value()
|
|
|
|
|
|| this->maximumHardwareBreakpoints >= this->reservedHardwareBreakpoints
|
|
|
|
|
);
|
|
|
|
|
}
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
|
|
|
|
}
|