blob: 4bd96080c7f7dfcb1c8551f073bae11ae6f7db6f [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 Turner2a5c0a22015-02-13 01:23:51 +000013#include "llvm/DebugInfo/PDB/IPDBSession.h"
Zachary Turner21473f72015-02-08 00:29:29 +000014#include "llvm/DebugInfo/PDB/PDBSymbol.h"
15#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
Zachary Turnera5549172015-02-10 22:43:25 +000016#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
17#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
Zachary Turner2a5c0a22015-02-13 01:23:51 +000018#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
Zachary Turnera5549172015-02-10 22:43:25 +000019
20#include "llvm/Support/Format.h"
Zachary Turner21473f72015-02-08 00:29:29 +000021
22using namespace llvm;
Zachary Turner98571ed2015-02-08 22:53:53 +000023PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession,
Zachary Turnerbae16b32015-02-08 20:58:09 +000024 std::unique_ptr<IPDBRawSymbol> Symbol)
25 : PDBSymbol(PDBSession, std::move(Symbol)) {}
Zachary Turner21473f72015-02-08 00:29:29 +000026
Zachary Turnera5549172015-02-10 22:43:25 +000027void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
28 PDB_DumpLevel Level) const {
Zachary Turnera5549172015-02-10 22:43:25 +000029 if (Level == PDB_DumpLevel::Compact) {
Zachary Turner2a5c0a22015-02-13 01:23:51 +000030 OS << stream_indent(Indent);
31
Zachary Turnera5549172015-02-10 22:43:25 +000032 uint32_t FuncStart = getRelativeVirtualAddress();
33 uint32_t FuncEnd = FuncStart + getLength();
Zachary Turner2a5c0a22015-02-13 01:23:51 +000034 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>())
Zachary Turnera5549172015-02-10 22:43:25 +000043 OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
Zachary Turner2a5c0a22015-02-13 01:23:51 +000044 OS << "] ";
45 }
46
Zachary Turnera5549172015-02-10 22:43:25 +000047 PDB_RegisterId Reg = getLocalBasePointerRegisterId();
48 if (Reg == PDB_RegisterId::VFrame)
49 OS << "(VFrame)";
Zachary Turnerc074de02015-02-12 21:09:24 +000050 else if (hasFramePointer())
51 OS << "(" << Reg << ")";
52 else
Zachary Turnera5549172015-02-10 22:43:25 +000053 OS << "(FPO)";
Zachary Turner2a5c0a22015-02-13 01:23:51 +000054
55 OS << " ";
56 uint32_t ClassId = getClassParentId();
57 if (ClassId != 0) {
58 if (auto Class = Session.getSymbolById(ClassId)) {
59 if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get()))
60 OS << UDT->getName() << "::";
61 else
62 OS << "{class " << Class->getSymTag() << "}::";
63 }
64 }
65 OS << getName();
66 OS << "\n";
Zachary Turnera5549172015-02-10 22:43:25 +000067 }
Zachary Turnera5549172015-02-10 22:43:25 +000068}