================
@@ -8094,6 +8413,82 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printCGProfile() {
}
}
+template <class ELFT> void LLVMELFDumper<ELFT>::printCallGraphInfo() {
+ if (!this->processCallGraphSection() || this->FuncCGInfos.empty())
+ return;
+
+ std::vector<Relocation<ELFT>> Relocations;
+ const Elf_Shdr *RelocSymTab = nullptr;
+ this->getCallGraphRelocations(Relocations, RelocSymTab);
+
+ auto PrintFunc = [](uint64_t FuncEntryPC, std::string FuncSymName,
+ ScopedPrinter &W) {
+ if (!FuncSymName.empty())
+ W.printString("Name", FuncSymName);
+ W.printHex("Address", FuncEntryPC);
+ };
+
+ auto PrintReloc =
+ [&](uint64_t FuncEntryPC,
+ typename std::vector<Relocation<ELFT>>::iterator &Reloc) {
+ if (Reloc == Relocations.end()) {
+ W.printHex("Offset", FuncEntryPC);
+ return;
+ }
+ Expected<RelSymbol<ELFT>> RelSym =
+ this->getRelocationTarget(*Reloc, RelocSymTab);
+ if (!RelSym) {
+ this->reportUniqueWarning(RelSym.takeError());
+ W.printHex("Offset", FuncEntryPC);
+ return;
+ }
+ DictScope DCs(W, "Entry");
+ SmallString<32> RelocName;
+ this->Obj.getRelocationTypeName(Reloc->Type, RelocName);
+ W.printString("Relocation", RelocName);
+ W.printString("Symbol", RelSym->Name);
+ if (Reloc->Addend)
+ W.printHex("Addend", (uintX_t)*Reloc->Addend);
+ };
+
+ auto PrintFunctionInfo = [&](uint64_t FuncEntryPC) {
+ if (this->Obj.getHeader().e_type != ELF::ET_REL) {
+ std::string FuncSymName = this->getFunctionNames(FuncEntryPC);
----------------
Prabhuk wrote:
Modified the implementation to match the stack size printing behavior. PTAL.
https://github.com/llvm/llvm-project/pull/157499