Remove m_validExecutionRange from ProcessorHandler
Refactored to always fetch the valid execution range from the currently
loaded program.
MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -33,13 +33,13 @@ void ProcessorHandler::loadProgram(const Program* p) {
m_currentProcessor->setPCInitialValue(p->entryPoint);
- // Set the valid execution range to be contained within the .text segment.
- m_validExecutionRange = {textSection->address, textSection->address + textSection->data.length()};
+ const auto textStart = textSection->address;
+ const auto textEnd = textSection->address + textSection->data.length();
// Update breakpoints to stay within the loaded program range
std::vector<uint32_t> bpsToRemove;
for (const auto& bp : m_breakpoints) {
- if ((bp < m_validExecutionRange.first) || (bp >= m_validExecutionRange.second)) {
+ if ((bp < textStart) || (bp >= textEnd)) {
bpsToRemove.push_back(bp);
}
}
@@ -229,7 +229,14 @@ void ProcessorHandler::stop() {
}
bool ProcessorHandler::isExecutableAddress(uint32_t address) const {
- return m_validExecutionRange.first <= address && address < m_validExecutionRange.second;
+ if (m_program) {
+ if (auto* textSection = m_program->getSection(TEXT_SECTION_NAME)) {
+ const auto textStart = textSection->address;
+ const auto textEnd = textSection->address + textSection->data.length();
+ return textStart <= address && address < textEnd;
+ }
+ }
+ return false;
}
void ProcessorHandler::checkValidExecutionRange() const {

MODIFY
src/processorhandler.h
src/processorhandler.h
@@ -158,13 +158,6 @@ private:
ProcessorID m_currentID = ProcessorID::RISCV_5S;
std::unique_ptr<vsrtl::core::RipesProcessor> m_currentProcessor;
- /**
- * @brief m_validExecutionRange
- * Address range which the processor is allowed to fetch instructions from. Currently, only a single range is
- * supported which shall encapsulate the .text segment. If, for instance JIT compilation and execution is required
- * in the future, this range should be expanded to also include the .data or other relevant program sections.
- */
- std::pair<uint32_t, uint32_t> m_validExecutionRange;
std::set<uint32_t> m_breakpoints;
const Program* m_program = nullptr;

Remove m_validExecutionRange from ProcessorHandler

Refactored to always fetch the valid execution range from the currently
loaded program.