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 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 10 | #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame] | 11 | #include "llvm/DebugInfo/PDB/IPDBSession.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 12 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
| 13 | #include "llvm/DebugInfo/PDB/PDBSymbolFunc.h" |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 14 | #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h" |
| 15 | #include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugStart.h" |
Zachary Turner | a952c49 | 2015-02-13 07:40:03 +0000 | [diff] [blame] | 16 | #include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h" |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame] | 17 | #include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h" |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 18 | #include "llvm/Support/Format.h" |
Chandler Carruth | 71f308a | 2015-02-13 09:09:03 +0000 | [diff] [blame^] | 19 | #include <utility> |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace llvm; |
Zachary Turner | 98571ed | 2015-02-08 22:53:53 +0000 | [diff] [blame] | 22 | PDBSymbolFunc::PDBSymbolFunc(const IPDBSession &PDBSession, |
Zachary Turner | bae16b3 | 2015-02-08 20:58:09 +0000 | [diff] [blame] | 23 | std::unique_ptr<IPDBRawSymbol> Symbol) |
| 24 | : PDBSymbol(PDBSession, std::move(Symbol)) {} |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 25 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 26 | void PDBSymbolFunc::dump(raw_ostream &OS, int Indent, |
| 27 | PDB_DumpLevel Level) const { |
Zachary Turner | a952c49 | 2015-02-13 07:40:03 +0000 | [diff] [blame] | 28 | OS << stream_indent(Indent); |
| 29 | if (Level >= PDB_DumpLevel::Normal) { |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 30 | uint32_t FuncStart = getRelativeVirtualAddress(); |
| 31 | uint32_t FuncEnd = FuncStart + getLength(); |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame] | 32 | if (FuncStart == 0 && FuncEnd == 0) { |
| 33 | OS << "func [???]"; |
| 34 | } else { |
| 35 | OS << "func "; |
| 36 | OS << "[" << format_hex(FuncStart, 8); |
| 37 | if (auto DebugStart = findOneChild<PDBSymbolFuncDebugStart>()) |
| 38 | OS << "+" << DebugStart->getRelativeVirtualAddress() - FuncStart; |
| 39 | OS << " - " << format_hex(FuncEnd, 8); |
| 40 | if (auto DebugEnd = findOneChild<PDBSymbolFuncDebugEnd>()) |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 41 | OS << "-" << FuncEnd - DebugEnd->getRelativeVirtualAddress(); |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame] | 42 | OS << "] "; |
| 43 | } |
| 44 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 45 | PDB_RegisterId Reg = getLocalBasePointerRegisterId(); |
| 46 | if (Reg == PDB_RegisterId::VFrame) |
| 47 | OS << "(VFrame)"; |
Zachary Turner | c074de0 | 2015-02-12 21:09:24 +0000 | [diff] [blame] | 48 | else if (hasFramePointer()) |
| 49 | OS << "(" << Reg << ")"; |
| 50 | else |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 51 | OS << "(FPO)"; |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame] | 52 | |
| 53 | OS << " "; |
Zachary Turner | a952c49 | 2015-02-13 07:40:03 +0000 | [diff] [blame] | 54 | uint32_t FuncSigId = getTypeId(); |
| 55 | if (auto FuncSig = Session.getConcreteSymbolById<PDBSymbolTypeFunctionSig>( |
| 56 | FuncSigId)) { |
| 57 | OS << "(" << FuncSig->getCallingConvention() << ") "; |
| 58 | } |
| 59 | |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame] | 60 | uint32_t ClassId = getClassParentId(); |
| 61 | if (ClassId != 0) { |
| 62 | if (auto Class = Session.getSymbolById(ClassId)) { |
| 63 | if (auto UDT = dyn_cast<PDBSymbolTypeUDT>(Class.get())) |
| 64 | OS << UDT->getName() << "::"; |
| 65 | else |
| 66 | OS << "{class " << Class->getSymTag() << "}::"; |
| 67 | } |
| 68 | } |
| 69 | OS << getName(); |
Zachary Turner | a952c49 | 2015-02-13 07:40:03 +0000 | [diff] [blame] | 70 | } else { |
| 71 | OS << getName(); |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 72 | } |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 73 | } |