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 | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame^] | 13 | #include "llvm/DebugInfo/PDB/IPDBSession.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 14 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
| 15 | #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 16 | #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h" |
| 17 | #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h" |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame^] | 18 | #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 19 | |
| 20 | #include "llvm/Support/Format.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace llvm; |
Zachary Turner | 98571ed | 2015-02-08 22:53:53 +0000 | [diff] [blame] | 23 | PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession, |
Zachary Turner | bae16b3 | 2015-02-08 20:58:09 +0000 | [diff] [blame] | 24 | std::unique_ptr<IPDBRawSymbol> Symbol) |
| 25 | : PDBSymbol(PDBSession, std::move(Symbol)) {} |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 26 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 27 | void PDBSymbolFunc::dump(raw_ostream &OS, int Indent, |
| 28 | PDB_DumpLevel Level) const { |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 29 | if (Level == PDB_DumpLevel::Compact) { |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame^] | 30 | OS << stream_indent(Indent); |
| 31 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 32 | uint32_t FuncStart = getRelativeVirtualAddress(); |
| 33 | uint32_t FuncEnd = FuncStart + getLength(); |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame^] | 34 | 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 Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 43 | OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress(); |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame^] | 44 | OS << "] "; |
| 45 | } |
| 46 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 47 | PDB_RegisterId Reg = getLocalBasePointerRegisterId(); |
| 48 | if (Reg == PDB_RegisterId::VFrame) |
| 49 | OS << "(VFrame)"; |
Zachary Turner | c074de0 | 2015-02-12 21:09:24 +0000 | [diff] [blame] | 50 | else if (hasFramePointer()) |
| 51 | OS << "(" << Reg << ")"; |
| 52 | else |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 53 | OS << "(FPO)"; |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame^] | 54 | |
| 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 Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 67 | } |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 68 | } |