[BOLT] Add a user friendly error reporting message

Summary:
In case we fail to disassemble or to build the CFG for a
function, print instructions on bug reporting.

(cherry picked from FBD8549737)
This commit is contained in:
Rafael Auler
2018-06-20 12:03:24 -07:00
committed by Maksim Panchenko
parent 221107c5fb
commit 35c09dc4dd
4 changed files with 37 additions and 11 deletions

View File

@@ -1052,3 +1052,22 @@ const Relocation *BinaryContext::getRelocationAt(uint64_t Address) {
assert(Section && "cannot find section for address");
return Section->getRelocationAt(Address - Section->getAddress());
}
void BinaryContext::exitWithBugReport(StringRef Message,
const BinaryFunction &Function) const {
errs() << "=======================================\n";
errs() << "BOLT is unable to proceed because it couldn't properly understand "
"this function.\n";
errs() << "If you are running the most recent version of BOLT, you may "
"want to "
"report this and paste this dump.\nPlease check that there is no "
"sensitive contents being shared in this dump.\n";
errs() << "\nOffending function: " << Function.getPrintName() << "\n\n";
ScopedPrinter SP(errs());
SP.printBinaryBlock("Function contents", *getFunctionData(Function));
errs() << "\n";
Function.dump();
errs() << "ERROR: " << Message;
errs() << "\n=======================================\n";
exit(1);
}