diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp index 22f630e3..a982bc00 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp @@ -5,6 +5,8 @@ #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" + #include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContRangeStep.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContRangeStep.cpp index 1e7f6fce..d69f258e 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContRangeStep.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/VContRangeStep.cpp @@ -2,7 +2,9 @@ #include +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/Microchip/Avr8/OpcodeDecoder/Decoder.hpp" + #include "src/Services/Avr8InstructionService.hpp" #include "src/Services/StringService.hpp" #include "src/Services/PathService.hpp" diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp index 94ebde1c..3ec3b013 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.cpp @@ -1,5 +1,7 @@ #include "WriteMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" + #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp" diff --git a/src/DebugServer/Gdb/RangeSteppingSession.hpp b/src/DebugServer/Gdb/RangeSteppingSession.hpp index ad457afc..1d0f702f 100644 --- a/src/DebugServer/Gdb/RangeSteppingSession.hpp +++ b/src/DebugServer/Gdb/RangeSteppingSession.hpp @@ -3,6 +3,7 @@ #include #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" diff --git a/src/DebugServer/Gdb/RiscVGdb/CommandPackets/FlashDone.cpp b/src/DebugServer/Gdb/RiscVGdb/CommandPackets/FlashDone.cpp index 59d52504..2c51dcdc 100644 --- a/src/DebugServer/Gdb/RiscVGdb/CommandPackets/FlashDone.cpp +++ b/src/DebugServer/Gdb/RiscVGdb/CommandPackets/FlashDone.cpp @@ -1,5 +1,7 @@ #include "FlashDone.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" + #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp" diff --git a/src/DebugServer/Gdb/RiscVGdb/CommandPackets/ReadMemory.cpp b/src/DebugServer/Gdb/RiscVGdb/CommandPackets/ReadMemory.cpp index 170bf5ed..7dc33ee2 100644 --- a/src/DebugServer/Gdb/RiscVGdb/CommandPackets/ReadMemory.cpp +++ b/src/DebugServer/Gdb/RiscVGdb/CommandPackets/ReadMemory.cpp @@ -2,6 +2,8 @@ #include +#include "src/Targets/TargetMemoryAddressRange.hpp" + #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp" diff --git a/src/DebugServer/Gdb/RiscVGdb/CommandPackets/SetBreakpoint.cpp b/src/DebugServer/Gdb/RiscVGdb/CommandPackets/SetBreakpoint.cpp index f304e0b5..60f72f3c 100644 --- a/src/DebugServer/Gdb/RiscVGdb/CommandPackets/SetBreakpoint.cpp +++ b/src/DebugServer/Gdb/RiscVGdb/CommandPackets/SetBreakpoint.cpp @@ -2,6 +2,8 @@ #include +#include "src/Targets/TargetMemoryAddressRange.hpp" + #include "src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/EmptyResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" @@ -9,8 +11,8 @@ #include "src/Targets/TargetBreakpoint.hpp" #include "src/Services/StringService.hpp" - #include "src/Logger/Logger.hpp" + #include "src/Exceptions/Exception.hpp" namespace DebugServer::Gdb::RiscVGdb::CommandPackets diff --git a/src/DebugServer/Gdb/RiscVGdb/CommandPackets/WriteMemory.cpp b/src/DebugServer/Gdb/RiscVGdb/CommandPackets/WriteMemory.cpp index 2615bb5a..04c72cc7 100644 --- a/src/DebugServer/Gdb/RiscVGdb/CommandPackets/WriteMemory.cpp +++ b/src/DebugServer/Gdb/RiscVGdb/CommandPackets/WriteMemory.cpp @@ -1,5 +1,7 @@ #include "WriteMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" + #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp" diff --git a/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.hpp b/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.hpp index e05a32a9..a736f039 100644 --- a/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.hpp +++ b/src/DebugToolDrivers/Protocols/RiscVDebugSpec/DebugTranslator.hpp @@ -15,6 +15,7 @@ #include "DebugModuleDescriptor.hpp" #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" #include "src/Targets/TargetState.hpp" diff --git a/src/DebugToolDrivers/TargetInterfaces/Microchip/Avr8/Avr8DebugInterface.hpp b/src/DebugToolDrivers/TargetInterfaces/Microchip/Avr8/Avr8DebugInterface.hpp index bd92fa21..c15488bd 100644 --- a/src/DebugToolDrivers/TargetInterfaces/Microchip/Avr8/Avr8DebugInterface.hpp +++ b/src/DebugToolDrivers/TargetInterfaces/Microchip/Avr8/Avr8DebugInterface.hpp @@ -15,6 +15,7 @@ #include "src/Targets/TargetState.hpp" #include "src/Targets/TargetRegisterDescriptor.hpp" #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetBreakpoint.hpp" namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr8 diff --git a/src/DebugToolDrivers/TargetInterfaces/RiscV/RiscVDebugInterface.hpp b/src/DebugToolDrivers/TargetInterfaces/RiscV/RiscVDebugInterface.hpp index e5ce5289..605dd11d 100644 --- a/src/DebugToolDrivers/TargetInterfaces/RiscV/RiscVDebugInterface.hpp +++ b/src/DebugToolDrivers/TargetInterfaces/RiscV/RiscVDebugInterface.hpp @@ -11,6 +11,7 @@ #include "src/Targets/TargetState.hpp" #include "src/Targets/TargetRegisterDescriptor.hpp" #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetBreakpoint.hpp" namespace DebugToolDrivers::TargetInterfaces::RiscV diff --git a/src/Insight/InsightSignals.hpp b/src/Insight/InsightSignals.hpp index f0396e15..394a6aba 100644 --- a/src/Insight/InsightSignals.hpp +++ b/src/Insight/InsightSignals.hpp @@ -8,6 +8,7 @@ #include "src/Targets/TargetRegisterDescriptor.hpp" #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" diff --git a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp index 9ab4a9f5..1fe19b8d 100644 --- a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp +++ b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp @@ -3,6 +3,7 @@ #include "InsightWorkerTask.hpp" #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp index 9cfa8824..a0dffa8a 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerSharedState.hpp @@ -3,6 +3,7 @@ #include #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp index 70e9da85..8c49be74 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp @@ -7,6 +7,7 @@ #include #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" #include "src/Targets/TargetState.hpp" diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.hpp index 28b62b5c..0a017b9f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ItemGraphicsScene.hpp @@ -18,6 +18,7 @@ #include #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" #include "src/Targets/TargetState.hpp" diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp index ad42ec9f..fc7dc693 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp @@ -6,7 +6,7 @@ #include #include -#include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "AddressType.hpp" #include "src/Services/DateTimeService.hpp" diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.hpp index 197ba8cf..553c937e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/MemoryRegionManagerWindow.hpp @@ -10,7 +10,6 @@ #include #include -#include "src/Targets/TargetMemory.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp index 4f7ae186..d7e2369d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegionManager/RegionItem.hpp @@ -13,7 +13,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp" -#include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" namespace Widgets diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/ChangeListPane/ChangeListItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/ChangeListPane/ChangeListItem.hpp index ce0145f1..b2eb2039 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/ChangeListPane/ChangeListItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/ChangeListPane/ChangeListItem.hpp @@ -2,7 +2,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListItem.hpp" -#include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" namespace Widgets { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/ChangeListPane/ChangeListPane.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/ChangeListPane/ChangeListPane.hpp index 18a6b039..babd1c4b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/ChangeListPane/ChangeListPane.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/ChangeListPane/ChangeListPane.hpp @@ -10,7 +10,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialHexViewerWidget.hpp" -#include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "ChangeListItem.hpp" diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.hpp index 0175f73e..00e3b5ab 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/DifferentialHexViewerWidget/DifferentialItemGraphicsScene.hpp @@ -7,6 +7,8 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotDiff/SnapshotDiffSettings.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" + namespace Widgets { class DifferentialItemGraphicsScene final: public ItemGraphicsScene diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp index 435711fe..c768f688 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp @@ -12,6 +12,7 @@ #include "src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.hpp" #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" #include "src/Targets/TargetState.hpp" diff --git a/src/Services/TargetControllerService.hpp b/src/Services/TargetControllerService.hpp index 0b437d38..e7e434a5 100644 --- a/src/Services/TargetControllerService.hpp +++ b/src/Services/TargetControllerService.hpp @@ -19,6 +19,7 @@ #include "src/Targets/TargetPadDescriptor.hpp" #include "src/Targets/TargetGpioPadState.hpp" #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetBreakpoint.hpp" #include "src/Targets/PassthroughCommand.hpp" #include "src/Targets/PassthroughResponse.hpp" diff --git a/src/TargetController/Commands/ReadTargetMemory.hpp b/src/TargetController/Commands/ReadTargetMemory.hpp index c89c18b2..f0874137 100644 --- a/src/TargetController/Commands/ReadTargetMemory.hpp +++ b/src/TargetController/Commands/ReadTargetMemory.hpp @@ -10,6 +10,7 @@ #include "src/Targets/TargetMemorySegmentDescriptor.hpp" #include "src/Targets/TargetMemorySegmentType.hpp" #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" namespace TargetController::Commands { diff --git a/src/TargetController/TargetControllerComponent.hpp b/src/TargetController/TargetControllerComponent.hpp index 30996c74..831dd08a 100644 --- a/src/TargetController/TargetControllerComponent.hpp +++ b/src/TargetController/TargetControllerComponent.hpp @@ -68,6 +68,7 @@ #include "src/Targets/Targets.hpp" #include "src/Targets/TargetRegisterDescriptor.hpp" #include "src/Targets/TargetMemory.hpp" +#include "src/Targets/TargetMemoryAddressRange.hpp" #include "src/Targets/TargetAddressSpaceDescriptor.hpp" #include "src/Targets/TargetMemorySegmentDescriptor.hpp" #include "src/Targets/ProgramBreakpointRegistry.hpp" diff --git a/src/Targets/CMakeLists.txt b/src/Targets/CMakeLists.txt index 83335fd6..f4ebee92 100755 --- a/src/Targets/CMakeLists.txt +++ b/src/Targets/CMakeLists.txt @@ -1,6 +1,7 @@ target_sources( Bloom PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/TargetMemoryAddressRange.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TargetDescriptor.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TargetAddressSpaceDescriptor.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TargetMemorySegmentDescriptor.cpp diff --git a/src/Targets/DynamicRegisterValue.cpp b/src/Targets/DynamicRegisterValue.cpp index 1ccc90ab..c28324eb 100644 --- a/src/Targets/DynamicRegisterValue.cpp +++ b/src/Targets/DynamicRegisterValue.cpp @@ -1,6 +1,7 @@ #include "DynamicRegisterValue.hpp" #include +#include namespace Targets { diff --git a/src/Targets/Target.hpp b/src/Targets/Target.hpp index 620655fa..fe0b8f5e 100644 --- a/src/Targets/Target.hpp +++ b/src/Targets/Target.hpp @@ -16,6 +16,7 @@ #include "TargetState.hpp" #include "TargetRegisterDescriptor.hpp" #include "TargetMemory.hpp" +#include "TargetMemoryAddressRange.hpp" #include "TargetBreakpoint.hpp" #include "TargetPadDescriptor.hpp" #include "TargetGpioPadState.hpp" diff --git a/src/Targets/TargetAddressSpaceDescriptor.hpp b/src/Targets/TargetAddressSpaceDescriptor.hpp index 29e1a189..8b8c665b 100644 --- a/src/Targets/TargetAddressSpaceDescriptor.hpp +++ b/src/Targets/TargetAddressSpaceDescriptor.hpp @@ -7,6 +7,7 @@ #include #include "TargetMemory.hpp" +#include "TargetMemoryAddressRange.hpp" #include "TargetMemorySegmentDescriptor.hpp" namespace Targets diff --git a/src/Targets/TargetMemory.hpp b/src/Targets/TargetMemory.hpp index 94af4910..0fae6ab8 100644 --- a/src/Targets/TargetMemory.hpp +++ b/src/Targets/TargetMemory.hpp @@ -1,12 +1,8 @@ #pragma once #include -#include #include #include -#include -#include -#include namespace Targets { @@ -25,98 +21,6 @@ namespace Targets LITTLE, }; - struct TargetMemoryAddressRange - { - TargetMemoryAddress startAddress = 0; - TargetMemoryAddress endAddress = 0; - - TargetMemoryAddressRange() = default; - TargetMemoryAddressRange(TargetMemoryAddress startAddress, TargetMemoryAddress endAddress) - : startAddress(startAddress) - , endAddress(endAddress) - { - assert(this->startAddress <= this->endAddress); - } - - bool operator == (const TargetMemoryAddressRange& rhs) const { - return this->startAddress == rhs.startAddress && this->endAddress == rhs.endAddress; - } - - bool operator < (const TargetMemoryAddressRange& rhs) const { - return this->startAddress < rhs.startAddress; - } - - /** - * Returns the number of addresses in the range. - * - * Keep in mind that the number of addresses may not be equal to the number of bytes in the range. It depends - * on whether the address space is byte-addressable. See TargetAddressSpaceDescriptor::unitSize for more. - * - * @return - */ - [[nodiscard]] TargetMemorySize size() const { - return this->endAddress - this->startAddress + 1; - } - - /** - * Checks if this range intersects with the given range. - * - * @param other - * @return - */ - [[nodiscard]] bool intersectsWith(const TargetMemoryAddressRange& other) const noexcept { - return this->startAddress <= other.endAddress && other.startAddress <= this->endAddress; - } - - /** - * Returns the number of addresses in this range that intersect with the given range. - * - * @param other - * @return - */ - [[nodiscard]] TargetMemorySize intersectingSize(const TargetMemoryAddressRange& other) const noexcept { - return this->intersectsWith(other) - ? std::min(this->endAddress, other.endAddress) - std::max(this->startAddress, other.startAddress) + 1 - : 0; - } - - /** - * Checks if the given address is contained within this range. - * - * @param address - * @return - */ - [[nodiscard]] bool contains(TargetMemoryAddress address) const noexcept { - return address >= this->startAddress && address <= this->endAddress; - } - - /** - * Checks if the given range is completely contained within this range. - * - * @param addressRange - * @return - */ - [[nodiscard]] bool contains(const TargetMemoryAddressRange& addressRange) const noexcept { - return this->startAddress <= addressRange.startAddress && this->endAddress >= addressRange.endAddress; - } - - /** - * Returns a set of all addresses within this range. - * - * @return - */ - [[nodiscard]] std::set addresses() const noexcept { - auto addresses = std::set{}; - auto addressesIt = addresses.end(); - - for (auto i = this->startAddress; i <= this->endAddress; ++i) { - addressesIt = addresses.insert(addressesIt, i); - } - - return addresses; - } - }; - struct TargetMemoryAccess { bool readable = false; diff --git a/src/Targets/TargetMemoryAddressRange.cpp b/src/Targets/TargetMemoryAddressRange.cpp new file mode 100644 index 00000000..9de94140 --- /dev/null +++ b/src/Targets/TargetMemoryAddressRange.cpp @@ -0,0 +1,79 @@ +#include "TargetMemoryAddressRange.hpp" + +#include +#include + +#include "src/Services/IntegerService.hpp" + +namespace Targets +{ + TargetMemoryAddressRange::TargetMemoryAddressRange( + TargetMemoryAddress startAddress, + TargetMemoryAddress endAddress + ) + : startAddress(startAddress) + , endAddress(endAddress) + { + assert(this->startAddress <= this->endAddress); + } + + bool TargetMemoryAddressRange::operator == (const TargetMemoryAddressRange& rhs) const { + return this->startAddress == rhs.startAddress && this->endAddress == rhs.endAddress; + } + + bool TargetMemoryAddressRange::operator < (const TargetMemoryAddressRange& rhs) const { + return this->startAddress < rhs.startAddress; + } + + TargetMemorySize TargetMemoryAddressRange::size() const { + return this->endAddress - this->startAddress + 1; + } + + bool TargetMemoryAddressRange::intersectsWith(const TargetMemoryAddressRange& other) const noexcept { + return this->startAddress <= other.endAddress && other.startAddress <= this->endAddress; + } + + TargetMemorySize TargetMemoryAddressRange::intersectingSize(const TargetMemoryAddressRange& other) const noexcept { + return this->intersectsWith(other) + ? std::min(this->endAddress, other.endAddress) - std::max(this->startAddress, other.startAddress) + 1 + : 0; + } + + bool TargetMemoryAddressRange::contains(TargetMemoryAddress address) const noexcept { + return address >= this->startAddress && address <= this->endAddress; + } + + bool TargetMemoryAddressRange::contains(const TargetMemoryAddressRange& addressRange) const noexcept { + return this->startAddress <= addressRange.startAddress && this->endAddress >= addressRange.endAddress; + } + + std::set TargetMemoryAddressRange::addresses() const noexcept { + auto addresses = std::set{}; + auto addressesIt = addresses.end(); + + for (auto i = this->startAddress; i <= this->endAddress; ++i) { + addressesIt = addresses.insert(addressesIt, i); + } + + return addresses; + } + + std::vector TargetMemoryAddressRange::blocks(TargetMemorySize blockSize) const noexcept { + const auto startBlock = this->startAddress / blockSize; + const auto endBlock = this->endAddress / blockSize; + + auto output = std::vector{}; + output.reserve(endBlock - startBlock + 1); + + for (auto block = startBlock; block <= endBlock; ++block) { + const auto blockStartAddress = blockSize * block; + const auto blockEndAddress = blockStartAddress + blockSize - 1; + output.emplace_back( + std::max(blockStartAddress, this->startAddress), + std::min(blockEndAddress, this->endAddress) + ); + } + + return output; + } +} diff --git a/src/Targets/TargetMemoryAddressRange.hpp b/src/Targets/TargetMemoryAddressRange.hpp new file mode 100644 index 00000000..ce8fb87b --- /dev/null +++ b/src/Targets/TargetMemoryAddressRange.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include +#include + +#include "TargetMemory.hpp" + +namespace Targets +{ + struct TargetMemoryAddressRange + { + TargetMemoryAddress startAddress = 0; + TargetMemoryAddress endAddress = 0; + + TargetMemoryAddressRange() = default; + TargetMemoryAddressRange(TargetMemoryAddress startAddress, TargetMemoryAddress endAddress); + + bool operator == (const TargetMemoryAddressRange& rhs) const; + bool operator < (const TargetMemoryAddressRange& rhs) const; + + /** + * Returns the number of addresses in the range. + * + * Keep in mind that the number of addresses may not be equal to the number of bytes in the range. It depends + * on whether the address space is byte-addressable. See TargetAddressSpaceDescriptor::unitSize for more. + * + * @return + */ + [[nodiscard]] TargetMemorySize size() const; + + /** + * Checks if this range intersects with the given range. + * + * @param other + * @return + */ + [[nodiscard]] bool intersectsWith(const TargetMemoryAddressRange& other) const noexcept; + + /** + * Returns the number of addresses in this range that intersect with the given range. + * + * @param other + * @return + */ + [[nodiscard]] TargetMemorySize intersectingSize(const TargetMemoryAddressRange& other) const noexcept; + + /** + * Checks if the given address is contained within this range. + * + * @param address + * @return + */ + [[nodiscard]] bool contains(TargetMemoryAddress address) const noexcept; + + /** + * Checks if the given range is completely contained within this range. + * + * @param addressRange + * @return + */ + [[nodiscard]] bool contains(const TargetMemoryAddressRange& addressRange) const noexcept; + + /** + * Returns a set of all addresses within this range. + * + * @return + */ + [[nodiscard]] std::set addresses() const noexcept; + + /** + * Splits the address range into a vector of blocks, with the given block size. + * + * @param blockSize + * @return + */ + [[nodiscard]] std::vector blocks(TargetMemorySize blockSize) const noexcept; + }; +} diff --git a/src/Targets/TargetMemorySegmentDescriptor.hpp b/src/Targets/TargetMemorySegmentDescriptor.hpp index 0ed0f6c6..4e7f2df6 100644 --- a/src/Targets/TargetMemorySegmentDescriptor.hpp +++ b/src/Targets/TargetMemorySegmentDescriptor.hpp @@ -6,6 +6,7 @@ #include #include "TargetMemory.hpp" +#include "TargetMemoryAddressRange.hpp" #include "TargetMemorySegmentType.hpp" namespace Targets