blob: 13f6cccd0a2df92f7f3d320aa91fe47b3ccea69a [file] [log] [blame]
Zachary Turner21473f72015-02-08 00:29:29 +00001//===- 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 Turnera5549172015-02-10 22:43:25 +000011#include <vector>
Zachary Turner21473f72015-02-08 00:29:29 +000012
13#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
Zachary Turnera5549172015-02-10 22:43:25 +000014#include "llvm/DebugInfo/PDB/IPDBSession.h"
15#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
16#include "llvm/DebugInfo/PDB/PDBExtras.h"
Zachary Turner21473f72015-02-08 00:29:29 +000017#include "llvm/DebugInfo/PDB/PDBSymbol.h"
18#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
19#include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h"
Zachary Turnera5549172015-02-10 22:43:25 +000020#include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h"
Zachary Turner21473f72015-02-08 00:29:29 +000021#include "llvm/Support/raw_ostream.h"
22
23using namespace llvm;
24
Zachary Turner98571ed2015-02-08 22:53:53 +000025PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
Zachary Turnerbae16b32015-02-08 20:58:09 +000026 std::unique_ptr<IPDBRawSymbol> Symbol)
27 : PDBSymbol(PDBSession, std::move(Symbol)) {}
Zachary Turner21473f72015-02-08 00:29:29 +000028
Zachary Turnera5549172015-02-10 22:43:25 +000029void 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 Turner21473f72015-02-08 00:29:29 +000098}