Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects.
[oota-llvm.git] / lib / DebugInfo / PDB / PDBSymbolFunc.cpp
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/PDBSymbol.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
16 #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h"
17
18 #include "llvm/Support/Format.h"
19
20 using namespace llvm;
21 PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession,
22                              std::unique_ptr<IPDBRawSymbol> Symbol)
23     : PDBSymbol(PDBSession, std::move(Symbol)) {}
24
25 void PDBSymbolFunc::dump(raw_ostream &OS, int Indent,
26                          PDB_DumpLevel Level) const {
27   if (Level == PDB_DumpLevel::Compact) {
28     uint32_t FuncStart = getRelativeVirtualAddress();
29     uint32_t FuncEnd = FuncStart + getLength();
30     auto DebugEndSymbol = findChildren(PDB_SymType::FuncDebugEnd);
31     OS << stream_indent(Indent);
32     OS << "[" << format_hex(FuncStart, 8);
33     if (auto DebugStartEnum = findChildren(PDB_SymType::FuncDebugStart)) {
34       if (auto StartSym = DebugStartEnum->getNext()) {
35         auto DebugStart = dyn_cast<PDBSymbolFuncDebugStart>(StartSym.get());
36         OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart;
37       }
38     }
39     OS << " - " << format_hex(FuncEnd, 8);
40     if (auto DebugEndEnum = findChildren(PDB_SymType::FuncDebugEnd)) {
41       if (auto DebugEndSym = DebugEndEnum->getNext()) {
42         auto DebugEnd = dyn_cast<PDBSymbolFuncDebugEnd>(DebugEndSym.get());
43         OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress();
44       }
45     }
46     OS << "] ";
47     PDB_RegisterId Reg = getLocalBasePointerRegisterId();
48     if (Reg == PDB_RegisterId::VFrame)
49       OS << "(VFrame)";
50     else if (hasFramePointer()) {
51       if (Reg == PDB_RegisterId::EBP)
52         OS << "(EBP)";
53       else
54         OS << "(" << (int)Reg << ")";
55     } else {
56       OS << "(FPO)";
57     }
58     OS << " " << getName() << "\n";
59   }
60   OS.flush();
61 }