blob: 17473c17a45cfb329dd68a8ef630b7b6ebd99f0f [file] [log] [blame]
Zachary Turner21473f72015-02-08 00:29:29 +00001//===- 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
Zachary Turnera5549172015-02-10 22:43:25 +000012#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
Zachary Turner21473f72015-02-08 00:29:29 +000013#include "llvm/DebugInfo/PDB/PDBSymbol.h"
14#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
Zachary Turnera5549172015-02-10 22:43:25 +000015#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
16#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
17
18#include "llvm/Support/Format.h"
Zachary Turner21473f72015-02-08 00:29:29 +000019
20using namespace llvm;
Zachary Turner98571ed2015-02-08 22:53:53 +000021PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession,
Zachary Turnerbae16b32015-02-08 20:58:09 +000022 std::unique_ptr<IPDBRawSymbol> Symbol)
23 : PDBSymbol(PDBSession, std::move(Symbol)) {}
Zachary Turner21473f72015-02-08 00:29:29 +000024
Zachary Turnera5549172015-02-10 22:43:25 +000025void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
26 PDB_DumpLevel Level) const {
Zachary Turnera5549172015-02-10 22:43:25 +000027 if (Level == PDB_DumpLevel::Compact) {
28 uint32_t FuncStart = getRelativeVirtualAddress();
29 uint32_t FuncEnd = FuncStart + getLength();
Zachary Turnera5549172015-02-10 22:43:25 +000030 OS << stream_indent(Indent);
31 OS << "[" << format_hex(FuncStart, 8);
Zachary Turnerc074de02015-02-12 21:09:24 +000032 if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>())
33 OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
Zachary Turnera5549172015-02-10 22:43:25 +000034 OS << " - " << format_hex(FuncEnd, 8);
Zachary Turnerc074de02015-02-12 21:09:24 +000035 if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>())
Zachary Turnera5549172015-02-10 22:43:25 +000036 OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
Zachary Turnera5549172015-02-10 22:43:25 +000037 OS << "] ";
38 PDB_RegisterId Reg = getLocalBasePointerRegisterId();
39 if (Reg == PDB_RegisterId::VFrame)
40 OS << "(VFrame)";
Zachary Turnerc074de02015-02-12 21:09:24 +000041 else if (hasFramePointer())
42 OS << "(" << Reg << ")";
43 else
Zachary Turnera5549172015-02-10 22:43:25 +000044 OS << "(FPO)";
Zachary Turnera5549172015-02-10 22:43:25 +000045 OS << " " << getName() << "\n";
46 }
Zachary Turnera5549172015-02-10 22:43:25 +000047}