Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 1 | //===- PDBSymbolCompiland.cpp - compiland details --------*- 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> |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame^] | 11 | #include <vector> |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 12 | |
| 13 | #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame^] | 14 | #include "llvm/DebugInfo/PDB/IPDBSession.h" |
| 15 | #include "llvm/DebugInfo/PDB/IPDBSourceFile.h" |
| 16 | #include "llvm/DebugInfo/PDB/PDBExtras.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 17 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
| 18 | #include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h" |
| 19 | #include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h" |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame^] | 20 | #include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 21 | #include "llvm/Support/raw_ostream.h" |
| 22 | |
| 23 | using namespace llvm; |
| 24 | |
Zachary Turner | 98571ed | 2015-02-08 22:53:53 +0000 | [diff] [blame] | 25 | PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession, |
Zachary Turner | bae16b3 | 2015-02-08 20:58:09 +0000 | [diff] [blame] | 26 | std::unique_ptr<IPDBRawSymbol> Symbol) |
| 27 | : PDBSymbol(PDBSession, std::move(Symbol)) {} |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 28 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame^] | 29 | void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent, |
| 30 | PDB_DumpLevel Level) const { |
| 31 | std::string Name = getName(); |
| 32 | OS << "---- [IDX: " << getSymIndexId() << "] Compiland: " << Name |
| 33 | << " ----\n"; |
| 34 | |
| 35 | std::string Source = getSourceFileName(); |
| 36 | std::string Library = getLibraryName(); |
| 37 | if (!Source.empty()) |
| 38 | OS << stream_indent(Indent + 2) << "Source: " << this->getSourceFileName() |
| 39 | << "\n"; |
| 40 | if (!Library.empty()) |
| 41 | OS << stream_indent(Indent + 2) << "Library: " << this->getLibraryName() |
| 42 | << "\n"; |
| 43 | |
| 44 | TagStats Stats; |
| 45 | auto ChildrenEnum = getChildStats(Stats); |
| 46 | OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n"; |
| 47 | if (Level >= PDB_DumpLevel::Normal) { |
| 48 | while (auto Child = ChildrenEnum->getNext()) { |
| 49 | if (llvm::isa<PDBSymbolCompilandDetails>(*Child)) |
| 50 | continue; |
| 51 | if (llvm::isa<PDBSymbolCompilandEnv>(*Child)) |
| 52 | continue; |
| 53 | Child->dump(OS, Indent + 4, PDB_DumpLevel::Compact); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | std::unique_ptr<IPDBEnumSymbols> DetailsEnum( |
| 58 | findChildren(PDB_SymType::CompilandDetails)); |
| 59 | if (auto DetailsPtr = DetailsEnum->getNext()) { |
| 60 | const auto *CD = dyn_cast<PDBSymbolCompilandDetails>(DetailsPtr.get()); |
| 61 | assert(CD && "We only asked for compilands, but got something else!"); |
| 62 | VersionInfo FE; |
| 63 | VersionInfo BE; |
| 64 | CD->getFrontEndVersion(FE); |
| 65 | CD->getBackEndVersion(BE); |
| 66 | OS << stream_indent(Indent + 2) << "Compiler: " << CD->getCompilerName() |
| 67 | << "\n"; |
| 68 | OS << stream_indent(Indent + 2) << "Version: " << FE << ", " << BE << "\n"; |
| 69 | |
| 70 | OS << stream_indent(Indent + 2) << "Lang: " << CD->getLanguage() << "\n"; |
| 71 | OS << stream_indent(Indent + 2) << "Attributes: "; |
| 72 | if (CD->hasDebugInfo()) |
| 73 | OS << "DebugInfo "; |
| 74 | if (CD->isDataAligned()) |
| 75 | OS << "DataAligned "; |
| 76 | if (CD->isLTCG()) |
| 77 | OS << "LTCG "; |
| 78 | if (CD->hasSecurityChecks()) |
| 79 | OS << "SecurityChecks "; |
| 80 | if (CD->isHotpatchable()) |
| 81 | OS << "HotPatchable"; |
| 82 | |
| 83 | OS << "\n"; |
| 84 | auto Files(Session.getSourceFilesForCompiland(*this)); |
| 85 | if (Level >= PDB_DumpLevel::Detailed) { |
| 86 | OS << stream_indent(Indent + 2) << Files->getChildCount() |
| 87 | << " source files:\n"; |
| 88 | while (auto File = Files->getNext()) |
| 89 | File->dump(OS, Indent + 4, PDB_DumpLevel::Compact); |
| 90 | } else { |
| 91 | OS << stream_indent(Indent + 2) << Files->getChildCount() |
| 92 | << " source files\n"; |
| 93 | } |
| 94 | } |
| 95 | uint32_t Count = DetailsEnum->getChildCount(); |
| 96 | if (Count > 1) |
| 97 | OS << stream_indent(Indent + 2) << "(" << Count - 1 << " more omitted)\n"; |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 98 | } |