Handle breakpoints for programs loaded at non-0x0 start addresses
MODIFY
src/codeeditor.cpp
src/codeeditor.cpp
@@ -219,7 +219,8 @@ void CodeEditor::breakpointAreaPaintEvent(QPaintEvent* event) {
if (m_breakpointAreaEnabled) {
QTextBlock block = firstVisibleBlock();
- uint32_t address = block.blockNumber() * ProcessorHandler::get()->currentISA()->bytes();
+ uint32_t address = ProcessorHandler::get()->getTextStart() +
+ block.blockNumber() * ProcessorHandler::get()->currentISA()->bytes();
int top = static_cast<int>(blockBoundingGeometry(block).translated(contentOffset()).top());
int bottom = top + static_cast<int>(blockBoundingRect(block).height());
@@ -277,7 +278,8 @@ long CodeEditor::addressForPos(const QPoint& pos) const {
return -1;
// Toggle breakpoint
- return block.blockNumber() * ProcessorHandler::get()->currentISA()->bytes();
+ return block.blockNumber() * ProcessorHandler::get()->currentISA()->bytes() +
+ ProcessorHandler::get()->getTextStart();
}
bool CodeEditor::hasBreakpoint(const QPoint& pos) const {

MODIFY
src/processorhandler.cpp
src/processorhandler.cpp
@@ -144,6 +144,16 @@ int ProcessorHandler::getCurrentProgramSize() const {
return 0;
}
+unsigned long ProcessorHandler::getTextStart() const {
+ if (m_program) {
+ const auto* textSection = m_program->getSection(TEXT_SECTION_NAME);
+ if (textSection)
+ return textSection->address;
+ }
+
+ return 0;
+}
+
QString ProcessorHandler::parseInstrAt(const uint32_t addr) const {
return Parser::getParser()->disassemble(m_currentProcessor->getMemory().readMem(addr), addr);
}

MODIFY
src/processorhandler.h
src/processorhandler.h
@@ -65,6 +65,12 @@ public:
*/
int getCurrentProgramSize() const;
+ /**
+ * @brief getEntryPoint
+ * @return address of the entry point of the currently loaded program
+ */
+ unsigned long getTextStart() const;
+
/**
* @brief parseInstrAt
* @return string representation of the instruction at @param addr

Handle breakpoints for programs loaded at non-0x0 start addresses