[llvm] r289569 - [bpf] change llvm-objdump to print dec instead of hex
Alexei Starovoitov via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 13 11:07:08 PST 2016
Author: ast
Date: Tue Dec 13 13:07:08 2016
New Revision: 289569
URL: http://llvm.org/viewvc/llvm-project?rev=289569&view=rev
Log:
[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 at kernel.org>
Modified:
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=289569&r1=289568&r2=289569&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Tue Dec 13 13:07:08 2016
@@ -594,6 +594,26 @@ public:
};
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) {
switch(Triple.getArch()) {
default:
@@ -602,6 +622,9 @@ PrettyPrinter &selectPrettyPrinter(Tripl
return HexagonPrettyPrinterInst;
case Triple::amdgcn:
return AMDGCNPrettyPrinterInst;
+ case Triple::bpfel:
+ case Triple::bpfeb:
+ return BPFPrettyPrinterInst;
}
}
}
More information about the llvm-commits
mailing list