blob: 366c748ca200b0e98957b86be93ae28a77765654 [file] [log] [blame]
Zachary Turner21473f72015-02-08 00:29:29 +00001//===- 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
Zachary Turnera5549172015-02-10 22:43:25 +000010#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
11#include "llvm/DebugInfo/PDB/PDBExtras.h"
Zachary Turner21473f72015-02-08 00:29:29 +000012#include "llvm/DebugInfo/PDB/PDBSymbol.h"
13#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
14#include "llvm/Support/ConvertUTF.h"
15#include "llvm/Support/FileSystem.h"
16#include "llvm/Support/raw_ostream.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000017#include <utility>
Zachary Turner21473f72015-02-08 00:29:29 +000018
Zachary Turner21473f72015-02-08 00:29:29 +000019using namespace llvm;
20
Zachary Turner98571ed2015-02-08 22:53:53 +000021PDBSymbolExe::PDBSymbolExe(const IPDBSession &PDBSession,
Zachary Turnerbae16b32015-02-08 20:58:09 +000022 std::unique_ptr<IPDBRawSymbol> Symbol)
23 : PDBSymbol(PDBSession, std::move(Symbol)) {}
Zachary Turner21473f72015-02-08 00:29:29 +000024
Zachary Turnera5549172015-02-10 22:43:25 +000025void PDBSymbolExe::dump(raw_ostream &OS, int Indent,
26 PDB_DumpLevel Level) const {
27 std::string FileName(getSymbolsFileName());
28
Zachary Turnera952c492015-02-13 07:40:03 +000029 OS << stream_indent(Indent) << "Summary for " << FileName << "\n";
Zachary Turnera5549172015-02-10 22:43:25 +000030
Zachary Turnera5549172015-02-10 22:43:25 +000031 uint64_t FileSize = 0;
32 if (!llvm::sys::fs::file_size(FileName, FileSize))
Zachary Turnera952c492015-02-13 07:40:03 +000033 OS << stream_indent(Indent + 2) << "Size: " << FileSize << " bytes\n";
Zachary Turnera5549172015-02-10 22:43:25 +000034 else
Zachary Turnera952c492015-02-13 07:40:03 +000035 OS << stream_indent(Indent + 2) << "Size: (Unable to obtain file size)\n";
Zachary Turnera5549172015-02-10 22:43:25 +000036 PDB_UniqueId Guid = getGuid();
Zachary Turnera952c492015-02-13 07:40:03 +000037 OS << stream_indent(Indent + 2) << "Guid: " << Guid << "\n";
38 OS << stream_indent(Indent + 2) << "Age: " << getAge() << "\n";
39 OS << stream_indent(Indent + 2) << "Attributes: ";
Zachary Turnera5549172015-02-10 22:43:25 +000040 if (hasCTypes())
41 OS << "HasCTypes ";
42 if (hasPrivateSymbols())
43 OS << "HasPrivateSymbols ";
44 OS << "\n";
Zachary Turner2a5c0a22015-02-13 01:23:51 +000045
46 TagStats Stats;
47 auto ChildrenEnum = getChildStats(Stats);
48 OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n";
49 while (auto Child = ChildrenEnum->getNext()) {
Zachary Turner04b966d2015-02-13 17:57:09 +000050 // Skip uninteresting types. These are useful to print as part of type
51 // hierarchies, but as general children of the global scope, they are
52 // not very interesting.
53 switch (Child->getSymTag()) {
54 case PDB_SymType::ArrayType:
55 case PDB_SymType::BaseClass:
56 case PDB_SymType::BuiltinType:
57 case PDB_SymType::CompilandEnv:
58 case PDB_SymType::CustomType:
59 case PDB_SymType::Dimension:
60 case PDB_SymType::Friend:
61 case PDB_SymType::ManagedType:
62 case PDB_SymType::VTableShape:
63 case PDB_SymType::PointerType:
64 case PDB_SymType::FunctionSig:
65 case PDB_SymType::FunctionArg:
66 continue;
67 default:
68 break;
69 }
Zachary Turnera952c492015-02-13 07:40:03 +000070 Child->dump(OS, Indent + 4, PDB_DumpLevel::Normal);
71 OS << "\n";
Zachary Turner2a5c0a22015-02-13 01:23:51 +000072 }
Zachary Turner21473f72015-02-08 00:29:29 +000073}