[bpf] change llvm-objdump to print dec instead of hex

since bpf instruction stream is multiple of 8 change llvm-objdump
to print decimal instruction number instead of hex address, so that
users don't have to do this math manually to match kernel verifier output

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
llvm-svn: 289569
This commit is contained in:
Alexei Starovoitov 2016-12-13 19:07:08 +00:00
parent 125b15e6c9
commit 3b9efca8e8
1 changed files with 23 additions and 0 deletions

View File

@ -594,6 +594,26 @@ public:
}; };
AMDGCNPrettyPrinter AMDGCNPrettyPrinterInst; AMDGCNPrettyPrinter AMDGCNPrettyPrinterInst;
class BPFPrettyPrinter : public PrettyPrinter {
public:
void printInst(MCInstPrinter &IP, const MCInst *MI, ArrayRef<uint8_t> Bytes,
uint64_t Address, raw_ostream &OS, StringRef Annot,
MCSubtargetInfo const &STI, SourcePrinter *SP) override {
if (SP && (PrintSource || PrintLines))
SP->printSourceLine(OS, Address);
OS << format("%8" PRId64 ":", Address / 8);
if (!NoShowRawInsn) {
OS << "\t";
dumpBytes(Bytes, OS);
}
if (MI)
IP.printInst(MI, OS, "", STI);
else
OS << " <unknown>";
}
};
BPFPrettyPrinter BPFPrettyPrinterInst;
PrettyPrinter &selectPrettyPrinter(Triple const &Triple) { PrettyPrinter &selectPrettyPrinter(Triple const &Triple) {
switch(Triple.getArch()) { switch(Triple.getArch()) {
default: default:
@ -602,6 +622,9 @@ PrettyPrinter &selectPrettyPrinter(Triple const &Triple) {
return HexagonPrettyPrinterInst; return HexagonPrettyPrinterInst;
case Triple::amdgcn: case Triple::amdgcn:
return AMDGCNPrettyPrinterInst; return AMDGCNPrettyPrinterInst;
case Triple::bpfel:
case Triple::bpfeb:
return BPFPrettyPrinterInst;
} }
} }
} }