1 //===- PDBSymbolFunc.cpp - --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
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/PDBSymbolFuncDebugEnd.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
18 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
19 #include "llvm/Support/Format.h"
23 PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession,
24 std::unique_ptr<IPDBRawSymbol> Symbol)
25 : PDBSymbol(PDBSession, std::move(Symbol)) {}
27 std::unique_ptr<PDBSymbolTypeFunctionSig> PDBSymbolFunc::getSignature() const {
28 return Session.getConcreteSymbolById<PDBSymbolTypeFunctionSig>(getTypeId());
31 void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
32 PDB_DumpLevel Level, PDB_DumpFlags Flags) const {
33 uint32_t FuncStart = getRelativeVirtualAddress();
34 uint32_t FuncEnd = FuncStart + getLength();
35 OS << stream_indent(Indent);
36 if (FuncStart == 0 && FuncEnd == 0) {
40 OS << "[" << format_hex(FuncStart, 8);
41 if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>())
42 OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
43 OS << " - " << format_hex(FuncEnd, 8);
44 if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>())
45 OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
49 PDB_RegisterId Reg = getLocalBasePointerRegisterId();
50 if (Reg == PDB_RegisterId::VFrame)
52 else if (hasFramePointer())
53 OS << "(" << Reg << ")";
58 if (isVirtual() || isPureVirtual())
61 if (auto FuncSig = getSignature()) {
62 // If we have a signature, dump the name with the signature.
63 if (auto ReturnType = FuncSig->getReturnType()) {
64 ReturnType->dump(OS, 0, PDB_DumpLevel::Compact, PDB_DF_Children);
68 OS << FuncSig->getCallingConvention() << " ";
71 FuncSig->dumpArgList(OS);
75 uint32_t ClassId = getClassParentId();
77 if (auto Class = Session.getSymbolById(ClassId)) {
78 if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get()))
79 OS << UDT->getName() << "::";
81 OS << "{class " << Class->getSymTag() << "}::";