[llvm] 783ba64 - [JITLink] Improve formatting for Edge, Block and Symbol debugging output.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 13 15:44:24 PDT 2020
Author: Lang Hames
Date: 2020-09-13T15:44:07-07:00
New Revision: 783ba64a8950768d412555abd52bbc65156d4fb5
URL: https://github.com/llvm/llvm-project/commit/783ba64a8950768d412555abd52bbc65156d4fb5
DIFF: https://github.com/llvm/llvm-project/commit/783ba64a8950768d412555abd52bbc65156d4fb5.diff
LOG: [JITLink] Improve formatting for Edge, Block and Symbol debugging output.
Added:
Modified:
llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
index 5105ec495148..71ec88639a5b 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLink.cpp
@@ -93,6 +93,7 @@ const char *getScopeName(Scope S) {
raw_ostream &operator<<(raw_ostream &OS, const Block &B) {
return OS << formatv("{0:x16}", B.getAddress()) << " -- "
<< formatv("{0:x16}", B.getAddress() + B.getSize()) << ": "
+ << "size = " << formatv("{0:x}", B.getSize()) << ", "
<< (B.isZeroFill() ? "zero-fill" : "content")
<< ", align = " << B.getAlignment()
<< ", align-ofs = " << B.getAlignmentOffset()
@@ -126,10 +127,10 @@ raw_ostream &operator<<(raw_ostream &OS, const Symbol &Sym) {
break;
}
OS << (Sym.isLive() ? '+' : '-')
- << ", size = " << formatv("{0:x8}", Sym.getSize())
+ << ", size = " << formatv("{0:x}", Sym.getSize())
<< ", addr = " << formatv("{0:x16}", Sym.getAddress()) << " ("
<< formatv("{0:x16}", Sym.getAddressable().getAddress()) << " + "
- << formatv("{0:x8}", Sym.getOffset());
+ << formatv("{0:x}", Sym.getOffset());
if (Sym.isDefined())
OS << " " << Sym.getBlock().getSection().getName();
OS << ")>";
@@ -139,8 +140,33 @@ raw_ostream &operator<<(raw_ostream &OS, const Symbol &Sym) {
void printEdge(raw_ostream &OS, const Block &B, const Edge &E,
StringRef EdgeKindName) {
OS << "edge@" << formatv("{0:x16}", B.getAddress() + E.getOffset()) << ": "
- << formatv("{0:x16}", B.getAddress()) << " + " << E.getOffset() << " -- "
- << EdgeKindName << " -> " << E.getTarget() << " + " << E.getAddend();
+ << formatv("{0:x16}", B.getAddress()) << " + "
+ << formatv("{0:x}", E.getOffset()) << " -- " << EdgeKindName << " -> ";
+
+ auto &TargetSym = E.getTarget();
+ if (TargetSym.hasName())
+ OS << TargetSym.getName();
+ else {
+ auto &TargetBlock = TargetSym.getBlock();
+ auto &TargetSec = TargetBlock.getSection();
+ JITTargetAddress SecAddress = ~JITTargetAddress(0);
+ for (auto *B : TargetSec.blocks())
+ if (B->getAddress() < SecAddress)
+ SecAddress = B->getAddress();
+
+ JITTargetAddress SecDelta = TargetSym.getAddress() - SecAddress;
+ OS << formatv("{0:x16}", TargetSym.getAddress()) << " (section "
+ << TargetSec.getName();
+ if (SecDelta)
+ OS << " + " << formatv("{0:x}", SecDelta);
+ OS << " / block " << formatv("{0:x16}", TargetBlock.getAddress());
+ if (TargetSym.getOffset())
+ OS << " + " << formatv("{0:x}", TargetSym.getOffset());
+ OS << ")";
+ }
+
+ if (E.getAddend() != 0)
+ OS << " + " << E.getAddend();
}
Section::~Section() {
More information about the llvm-commits
mailing list