summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp
blob: 0ea0b185911f4de66d456ff985f2937d1e83ce4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//===- PDBSymbolCompiland.cpp - compiland details --------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"

#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h"
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompilandEnv.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"

#include <utility>
#include <vector>

using namespace llvm;

PDBSymbolCompiland::PDBSymbolCompiland(const IPDBSession &PDBSession,
                                       std::unique_ptr<IPDBRawSymbol> Symbol)
    : PDBSymbol(PDBSession, std::move(Symbol)) {}

void PDBSymbolCompiland::dump(raw_ostream &OS, int Indent,
                              PDB_DumpLevel Level) const {
  if (Level == PDB_DumpLevel::Detailed) {
    std::string FullName = getName();
    StringRef Name = llvm::sys::path::filename(StringRef(FullName.c_str()));

    OS.indent(Indent);
    OS << "Compiland: " << Name << "\n";

    std::string Source = getSourceFileName();
    std::string Library = getLibraryName();
    if (!Source.empty())
      OS << stream_indent(Indent + 2) << "Source: " << this->getSourceFileName()
         << "\n";
    if (!Library.empty())
      OS << stream_indent(Indent + 2) << "Library: " << this->getLibraryName()
         << "\n";

    TagStats Stats;
    auto ChildrenEnum = getChildStats(Stats);
    OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n";
    if (Level >= PDB_DumpLevel::Detailed) {
      while (auto Child = ChildrenEnum->getNext()) {
        if (llvm::isa<PDBSymbolCompilandDetails>(*Child))
          continue;
        if (llvm::isa<PDBSymbolCompilandEnv>(*Child))
          continue;
        PDB_DumpLevel ChildLevel = (Level == PDB_DumpLevel::Detailed)
                                       ? PDB_DumpLevel::Normal
                                       : PDB_DumpLevel::Compact;
        Child->dump(OS, Indent + 4, ChildLevel);
        OS << "\n";
      }
    }

    auto DetailsEnum(findAllChildren<PDBSymbolCompilandDetails>());
    if (auto CD = DetailsEnum->getNext()) {
      VersionInfo FE;
      VersionInfo BE;
      CD->getFrontEndVersion(FE);
      CD->getBackEndVersion(BE);
      OS << stream_indent(Indent + 2) << "Compiler: " << CD->getCompilerName()
         << "\n";
      OS << stream_indent(Indent + 2) << "Version: " << FE << ", " << BE
         << "\n";

      OS << stream_indent(Indent + 2) << "Lang: " << CD->getLanguage() << "\n";
      OS << stream_indent(Indent + 2) << "Attributes: ";
      if (CD->hasDebugInfo())
        OS << "DebugInfo ";
      if (CD->isDataAligned())
        OS << "DataAligned ";
      if (CD->isLTCG())
        OS << "LTCG ";
      if (CD->hasSecurityChecks())
        OS << "SecurityChecks ";
      if (CD->isHotpatchable())
        OS << "HotPatchable";

      auto Files(Session.getSourceFilesForCompiland(*this));
      OS << "\n";
      OS << stream_indent(Indent + 2) << Files->getChildCount()
         << " source files";
    }
    uint32_t Count = DetailsEnum->getChildCount();
    if (Count > 1) {
      OS << "\n";
      OS << stream_indent(Indent + 2) << "(" << Count - 1 << " more omitted)";
    }
  } else {
    std::string FullName = getName();
    OS << stream_indent(Indent) << "Compiland: " << FullName;
  }
}
OpenPOWER on IntegriCloud