Skip to content

Commit b851b8d

Browse files
committed
Make llvm output better.
1 parent 09d3a87 commit b851b8d

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

llvm/tools/llvm-readobj/ELFDumper.cpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5472,13 +5472,13 @@ template <class ELFT> bool ELFDumper<ELFT>::processCallGraphSection() {
54725472
static StringRef GetFuntionKindString(FunctionKind Kind) {
54735473
switch (Kind) {
54745474
case FunctionKind::NOT_INDIRECT_TARGET:
5475-
return "NOT_INDIRECT_TARGET";
5475+
return "NOT_INDIRECT";
54765476
case FunctionKind::INDIRECT_TARGET_UNKNOWN_TID:
5477-
return "INDIRECT_TARGET_UNKNOWN_TID";
5477+
return "UNKNOWN_TID";
54785478
case FunctionKind::INDIRECT_TARGET_KNOWN_TID:
5479-
return "INDIRECT_TARGET_KNOWN_TID";
5479+
return "KNOWN_TID";
54805480
case FunctionKind::NOT_LISTED:
5481-
return "NOT_LISTED";
5481+
return "NO_INFO";
54825482
}
54835483
llvm_unreachable("Unknown FunctionKind.");
54845484
}
@@ -8399,44 +8399,43 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
83998399
return join(FuncSymNames, ", ");
84008400
};
84018401

8402-
DictScope D(this->W, "callgraph_info");
8402+
ListScope CGI(W, "callgraph_info");
84038403

8404-
for (const auto &El : this->FuncCGInfos) {
8404+
for (const auto &El : this->FuncCGInfos) {
8405+
DictScope D(W, "Function");
84058406
typename ELFT::uint FuncEntryPc = El.first;
84068407
FunctionCallgraphInfo CGInfo = El.second;
8407-
std::string FuncPCStr;
8408-
raw_string_ostream OS(FuncPCStr);
8409-
OS << format("0x%lx", FuncEntryPc);
8410-
DictScope FuncScope(this->W, OS.str());
84118408
std::string FuncSymName = GetFunctionName(FuncEntryPc);
84128409
if (!FuncSymName.empty())
8413-
this->W.printString("Name", FuncSymName);
8410+
W.printString("Name", FuncSymName);
84148411

8415-
this->W.printNumber("FormatVersionNumber", CGInfo.FormatVersionNumber);
8416-
this->W.printString("KindStr", GetFuntionKindString(CGInfo.Kind));
8417-
this->W.printNumber("Kind", (uint64_t)CGInfo.Kind);
8412+
W.printHex("Address", FuncEntryPc);
8413+
W.printNumber("Version", CGInfo.FormatVersionNumber);
8414+
W.printString("KindStr", GetFuntionKindString(CGInfo.Kind));
8415+
W.printNumber("Kind", (uint64_t)CGInfo.Kind);
84188416
if (CGInfo.Kind == FunctionKind::INDIRECT_TARGET_KNOWN_TID)
8419-
this->W.printHex("TypeId", CGInfo.FunctionTypeId);
8420-
this->W.printNumber("NumIndirectCallSites",
8417+
W.printHex("TypeId", CGInfo.FunctionTypeId);
8418+
W.printNumber("NumIndirectCallSites",
84218419
CGInfo.IndirectCallsites.size());
84228420
if (CGInfo.IndirectCallsites.size() > 0) {
8423-
ListScope ICT(this->W, "indirect_call_sites");
8424-
for (auto &[IndirCallSitePc, TypeId] : CGInfo.IndirectCallsites) {
8425-
DictScope IDC(this->W);
8426-
this->W.printHex("callsite", IndirCallSitePc);
8427-
this->W.printHex("type_id", TypeId);
8421+
ListScope ICSs(W, "IndirectCallsites");
8422+
for (auto &[IndirCallSitePc, TypeId] : CGInfo.IndirectCallsites) {
8423+
DictScope ICS(W, "IndirectCallsite");
8424+
W.printHex("Address", IndirCallSitePc);
8425+
W.printHex("TypeId", TypeId);
84288426
}
84298427
}
8430-
this->W.printNumber("NumDirectCallSites", CGInfo.DirectCallees.size());
8428+
W.printNumber("NumDirectCallSites", CGInfo.DirectCallees.size());
84318429
if (CGInfo.DirectCallees.size() > 0) {
8432-
ListScope ICT(this->W, "direct_callees");
8433-
for (auto CalleePC : CGInfo.DirectCallees) {
8434-
this->W.printHex("calleePC", CalleePC);
8430+
ListScope DCs(W, "DirectCallees");
8431+
for (auto CalleePC : CGInfo.DirectCallees) {
8432+
DictScope DCs(W, "DirectCallee");
8433+
W.printHex("Address", CalleePC);
84358434
std::string CalleeSymName = GetFunctionName(CalleePC);
84368435
if (!CalleeSymName.empty())
8437-
this->W.printString("Name", CalleeSymName);
8438-
}
8439-
}
8436+
W.printString("Name", CalleeSymName);
8437+
}
8438+
}
84408439
}
84418440
}
84428441

0 commit comments

Comments
 (0)