Increment disassembly instruction counters on disassembly error
MODIFY
src/assembler/objdump.cpp
src/assembler/objdump.cpp
@@ -60,6 +60,13 @@ QString stringifyProgram(std::weak_ptr<const Program> program, Stringifier strin
// Stringified instruction
auto disres = stringifier(buffer, addr);
+ if (disres.err.has_value()) {
+ // Error during disassembled; we'll just have to increment the address counter by the default
+ // instruction size of the ISA. std::min with buffer size in the edge case that we're erroring on a
+ // single instruction which is smaller than the default instruction width.
+ addr += std::min(static_cast<unsigned>(buffer.size()), instrBytes);
+ } else
+ addr += disres.bytesDisassembled;
assert(buffer.size() >= disres.bytesDisassembled);
// Instruction word
@@ -81,7 +88,6 @@ QString stringifyProgram(std::weak_ptr<const Program> program, Stringifier strin
}
out += disres.repr + "\n";
- addr += disres.bytesDisassembled;
}
return out;
}

MODIFY
src/assembler/program.cpp
src/assembler/program.cpp
@@ -82,6 +82,11 @@ const DisassembledProgram& Program::getDisassembled() const {
// todo(mortbopet): shouldn't we do something about the possibility of the disassembling returning an error?
const VInt realAddr = textSectionBaseAddr + addr;
disassembled.set(line, realAddr, disRes.repr);
+ if (disRes.err.has_value()) {
+ // Error during disassembled; we'll just have to increment the address counter by the default
+ // instruction size of the ISA.
+ addr += instrBytes;
+ } else
addr += disRes.bytesDisassembled;
++line;
}

Increment disassembly instruction counters on disassembly error