llvm-pdbdump: Add more comprehensive dumping of symbol types.
[oota-llvm.git] / lib / DebugInfo / PDB / PDBSymbolExe.cpp
1 //===- PDBSymbolExe.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
12 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
13 #include "llvm/DebugInfo/PDB/PDBExtras.h"
14 #include "llvm/DebugInfo/PDB/PDBSymbol.h"
15 #include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
16 #include "llvm/Support/ConvertUTF.h"
17 #include "llvm/Support/FileSystem.h"
18 #include "llvm/Support/raw_ostream.h"
19
20 using namespace llvm;
21
22 PDBSymbolExe::PDBSymbolExe(const IPDBSession &PDBSession,
23                            std::unique_ptr<IPDBRawSymbol> Symbol)
24     : PDBSymbol(PDBSession, std::move(Symbol)) {}
25
26 void PDBSymbolExe::dump(raw_ostream &OS, int Indent,
27                         PDB_DumpLevel Level) const {
28   std::string FileName(getSymbolsFileName());
29
30   OS << stream_indent(Indent) << "Summary for " << FileName << "\n";
31
32   uint64_t FileSize = 0;
33   if (!llvm::sys::fs::file_size(FileName, FileSize))
34     OS << stream_indent(Indent + 2) << "Size: " << FileSize << " bytes\n";
35   else
36     OS << stream_indent(Indent + 2) << "Size: (Unable to obtain file size)\n";
37   PDB_UniqueId Guid = getGuid();
38   OS << stream_indent(Indent + 2) << "Guid: " << Guid << "\n";
39   OS << stream_indent(Indent + 2) << "Age: " << getAge() << "\n";
40   OS << stream_indent(Indent + 2) << "Attributes: ";
41   if (hasCTypes())
42     OS << "HasCTypes ";
43   if (hasPrivateSymbols())
44     OS << "HasPrivateSymbols ";
45   OS << "\n";
46
47   TagStats Stats;
48   auto ChildrenEnum = getChildStats(Stats);
49   OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n";
50   while (auto Child = ChildrenEnum->getNext()) {
51     Child->dump(OS, Indent + 4, PDB_DumpLevel::Normal);
52     OS << "\n";
53   }
54 }