Currently, there is no convenient way to emit diagnostics in a disassembler. For instance, a disassembler for a specific backend has no way of reporting information in-sync with the instruction it correponds to because an output stream is created, formatted and flushed before every instruction is printed; all of which is handled by the MCDisassembler.
I propose something very similar to clang Diagnostics for the Disassembler.
MCDisassembler.cpp, to package and emit diagnostics.
std::pair<DecodeStatus, MCDiagnostic>. This will require a change in
DecodeStatus MCDisassembler::getInstruction(MCInst &Instr, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address, raw_ostream &CStream) const;
which all disassemblers implement.
printInst(..)to accept an
MCDiagnostic. This will require a change in
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, MCDiagnostic *Diag, raw_ostream &OS)
Any feedback will be appreciated!