1 //===- PDBSymbolFunc.cpp - --------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include <utility> 11 12 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" 13 #include "llvm/DebugInfo/PDB/IPDBSession.h" 14 #include "llvm/DebugInfo/PDB/PDBSymbol.h" 15 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" 16 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h" 17 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h" 18 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h" 19 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" 20 21 #include "llvm/Support/Format.h" 22 23 using namespace llvm; 24 PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession, 25 std::unique_ptr<IPDBRawSymbol> Symbol) 26 : PDBSymbol(PDBSession, std::move(Symbol)) {} 27 28 void PDBSymbolFunc::dump(raw_ostream &OS, int Indent, 29 PDB_DumpLevel Level) const { 30 OS << stream_indent(Indent); 31 if (Level >= PDB_DumpLevel::Normal) { 32 uint32_t FuncStart = getRelativeVirtualAddress(); 33 uint32_t FuncEnd = FuncStart + getLength(); 34 if (FuncStart == 0 && FuncEnd == 0) { 35 OS << "func [???]"; 36 } else { 37 OS << "func "; 38 OS << "[" << format_hex(FuncStart, 8); 39 if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>()) 40 OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart; 41 OS << " - " << format_hex(FuncEnd, 8); 42 if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>()) 43 OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress(); 44 OS << "] "; 45 } 46 47 PDB_RegisterId Reg = getLocalBasePointerRegisterId(); 48 if (Reg == PDB_RegisterId::VFrame) 49 OS << "(VFrame)"; 50 else if (hasFramePointer()) 51 OS << "(" << Reg << ")"; 52 else 53 OS << "(FPO)"; 54 55 OS << " "; 56 uint32_t FuncSigId = getTypeId(); 57 if (auto FuncSig = Session.getConcreteSymbolById<PDBSymbolTypeFunctionSig>( 58 FuncSigId)) { 59 OS << "(" << FuncSig->getCallingConvention() << ") "; 60 } 61 62 uint32_t ClassId = getClassParentId(); 63 if (ClassId != 0) { 64 if (auto Class = Session.getSymbolById(ClassId)) { 65 if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get())) 66 OS << UDT->getName() << "::"; 67 else 68 OS << "{class " << Class->getSymTag() << "}::"; 69 } 70 } 71 OS << getName(); 72 } else { 73 OS << getName(); 74 } 75 } 76