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/IPDBEnumChildren.h"
11 #include "llvm/DebugInfo/PDB/IPDBSession.h"
12 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
13 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
17 #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
18 #include "llvm/Support/Format.h"
22 PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession,
23 std::unique_ptr<IPDBRawSymbol> Symbol)
24 : PDBSymbol(PDBSession, std::move(Symbol)) {}
26 void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
27 PDB_DumpLevel Level) const {
28 OS << stream_indent(Indent);
29 if (Level >= PDB_DumpLevel::Normal) {
30 uint32_t FuncStart = getRelativeVirtualAddress();
31 uint32_t FuncEnd = FuncStart + getLength();
32 if (FuncStart == 0 && FuncEnd == 0) {
36 OS << "[" << format_hex(FuncStart, 8);
37 if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>())
38 OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
39 OS << " - " << format_hex(FuncEnd, 8);
40 if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>())
41 OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
45 PDB_RegisterId Reg = getLocalBasePointerRegisterId();
46 if (Reg == PDB_RegisterId::VFrame)
48 else if (hasFramePointer())
49 OS << "(" << Reg << ")";
54 uint32_t FuncSigId = getTypeId();
55 if (auto FuncSig = Session.getConcreteSymbolById<PDBSymbolTypeFunctionSig>(
57 OS << "(" << FuncSig->getCallingConvention() << ") ";
60 uint32_t ClassId = getClassParentId();
62 if (auto Class = Session.getSymbolById(ClassId)) {
63 if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get()))
64 OS << UDT->getName() << "::";
66 OS << "{class " << Class->getSymTag() << "}::";