Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 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 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame^] | 12 | #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 13 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
| 14 | #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame^] | 15 | #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h" |
| 16 | #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h" |
| 17 | |
| 18 | #include "llvm/Support/Format.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 19 | |
| 20 | using namespace llvm; |
Zachary Turner | 98571ed | 2015-02-08 22:53:53 +0000 | [diff] [blame] | 21 | PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession, |
Zachary Turner | bae16b3 | 2015-02-08 20:58:09 +0000 | [diff] [blame] | 22 | std::unique_ptr<IPDBRawSymbol> Symbol) |
| 23 | : PDBSymbol(PDBSession, std::move(Symbol)) {} |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 24 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame^] | 25 | void PDBSymbolFunc::dump(raw_ostream &OS, int Indent, |
| 26 | PDB_DumpLevel Level) const { |
| 27 | bool doFullDump = false; |
| 28 | if (Level == PDB_DumpLevel::Compact) { |
| 29 | uint32_t FuncStart = getRelativeVirtualAddress(); |
| 30 | uint32_t FuncEnd = FuncStart + getLength(); |
| 31 | auto DebugEndSymbol = findChildren(PDB_SymType::FuncDebugEnd); |
| 32 | OS << stream_indent(Indent); |
| 33 | OS << "[" << format_hex(FuncStart, 8); |
| 34 | if (auto DebugStartEnum = findChildren(PDB_SymType::FuncDebugStart)) { |
| 35 | if (auto StartSym = DebugStartEnum->getNext()) { |
| 36 | auto DebugStart = dyn_cast<PDBSymbolFuncDebugStart>(StartSym.get()); |
| 37 | OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart; |
| 38 | } |
| 39 | } |
| 40 | OS << " - " << format_hex(FuncEnd, 8); |
| 41 | if (auto DebugEndEnum = findChildren(PDB_SymType::FuncDebugEnd)) { |
| 42 | if (auto DebugEndSym = DebugEndEnum->getNext()) { |
| 43 | auto DebugEnd = dyn_cast<PDBSymbolFuncDebugEnd>(DebugEndSym.get()); |
| 44 | OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress(); |
| 45 | } |
| 46 | } |
| 47 | OS << "] "; |
| 48 | PDB_RegisterId Reg = getLocalBasePointerRegisterId(); |
| 49 | if (Reg == PDB_RegisterId::VFrame) |
| 50 | OS << "(VFrame)"; |
| 51 | else if (hasFramePointer()) { |
| 52 | if (Reg == PDB_RegisterId::EBP) |
| 53 | OS << "(EBP)"; |
| 54 | else |
| 55 | OS << "(" << (int)Reg << ")"; |
| 56 | } else { |
| 57 | OS << "(FPO)"; |
| 58 | doFullDump = true; |
| 59 | } |
| 60 | OS << " " << getName() << "\n"; |
| 61 | } |
| 62 | OS.flush(); |
| 63 | } |