blob: 6555b814a6827e8ea16d5e4cf3bf4485c1dbf62b [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 Turner52c9f882015-02-14 03:53:56 +000010#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
11
Zachary Turnera5549172015-02-10 22:43:25 +000012#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
13#include "llvm/DebugInfo/PDB/PDBExtras.h"
Zachary Turner21473f72015-02-08 00:29:29 +000014#include "llvm/DebugInfo/PDB/PDBSymbol.h"
Zachary Turner21473f72015-02-08 00:29:29 +000015#include "llvm/Support/ConvertUTF.h"
16#include "llvm/Support/FileSystem.h"
17#include "llvm/Support/raw_ostream.h"
Chandler Carruth71f308a2015-02-13 09:09:03 +000018#include <utility>
Zachary Turner21473f72015-02-08 00:29:29 +000019
Zachary Turner52c9f882015-02-14 03:53:56 +000020#include <utility>
21
Zachary Turner21473f72015-02-08 00:29:29 +000022using namespace llvm;
23
Zachary Turner98571ed2015-02-08 22:53:53 +000024PDBSymbolExe::PDBSymbolExe(const IPDBSession &PDBSession,
Zachary Turnerbae16b32015-02-08 20:58:09 +000025 std::unique_ptr<IPDBRawSymbol> Symbol)
26 : PDBSymbol(PDBSession, std::move(Symbol)) {}
Zachary Turner21473f72015-02-08 00:29:29 +000027
Zachary Turnera5549172015-02-10 22:43:25 +000028void PDBSymbolExe::dump(raw_ostream &OS, int Indent,
29 PDB_DumpLevel Level) const {
30 std::string FileName(getSymbolsFileName());
31
Zachary Turnera952c492015-02-13 07:40:03 +000032 OS << stream_indent(Indent) << "Summary for " << FileName << "\n";
Zachary Turnera5549172015-02-10 22:43:25 +000033
Zachary Turnera5549172015-02-10 22:43:25 +000034 uint64_t FileSize = 0;
35 if (!llvm::sys::fs::file_size(FileName, FileSize))
Zachary Turnera952c492015-02-13 07:40:03 +000036 OS << stream_indent(Indent + 2) << "Size: " << FileSize << " bytes\n";
Zachary Turnera5549172015-02-10 22:43:25 +000037 else
Zachary Turnera952c492015-02-13 07:40:03 +000038 OS << stream_indent(Indent + 2) << "Size: (Unable to obtain file size)\n";
Zachary Turnera5549172015-02-10 22:43:25 +000039 PDB_UniqueId Guid = getGuid();
Zachary Turnera952c492015-02-13 07:40:03 +000040 OS << stream_indent(Indent + 2) << "Guid: " << Guid << "\n";
41 OS << stream_indent(Indent + 2) << "Age: " << getAge() << "\n";
42 OS << stream_indent(Indent + 2) << "Attributes: ";
Zachary Turnera5549172015-02-10 22:43:25 +000043 if (hasCTypes())
44 OS << "HasCTypes ";
45 if (hasPrivateSymbols())
46 OS << "HasPrivateSymbols ";
47 OS << "\n";
Zachary Turner2a5c0a22015-02-13 01:23:51 +000048
Zachary Turner26ebe3f2015-02-14 03:54:28 +000049 auto ChildrenEnum = findAllChildren();
50 OS << stream_indent(Indent + 2) << ChildrenEnum->getChildCount()
51 << " children\n";
52#if 0
53 dumpChildren(OS, PDB_SymType::None, Indent+4);
54#else
55 dumpChildren(OS, "Compilands", PDB_SymType::Compiland, Indent + 4);
56 dumpChildren(OS, "Functions", PDB_SymType::Function, Indent + 4);
57 dumpChildren(OS, "Blocks", PDB_SymType::Block, Indent + 4);
58 dumpChildren(OS, "Data", PDB_SymType::Data, Indent + 4);
59 dumpChildren(OS, "Labels", PDB_SymType::Label, Indent + 4);
60 dumpChildren(OS, "Public Symbols", PDB_SymType::PublicSymbol, Indent + 4);
61 dumpChildren(OS, "UDTs", PDB_SymType::UDT, Indent + 4);
62 dumpChildren(OS, "Enums", PDB_SymType::Enum, Indent + 4);
63 dumpChildren(OS, "Function Signatures", PDB_SymType::FunctionSig, Indent + 4);
64 dumpChildren(OS, "Typedefs", PDB_SymType::Typedef, Indent + 4);
65 dumpChildren(OS, "VTables", PDB_SymType::VTable, Indent + 4);
66 dumpChildren(OS, "Thunks", PDB_SymType::Thunk, Indent + 4);
67#endif
68}
69
70void PDBSymbolExe::dumpChildren(raw_ostream &OS, StringRef Label,
71 PDB_SymType ChildType, int Indent) const {
72 auto ChildrenEnum = findAllChildren(ChildType);
73 OS << stream_indent(Indent) << Label << ": (" << ChildrenEnum->getChildCount()
74 << " items)\n";
Zachary Turner2a5c0a22015-02-13 01:23:51 +000075 while (auto Child = ChildrenEnum->getNext()) {
Zachary Turner26ebe3f2015-02-14 03:54:28 +000076 Child->dump(OS, Indent + 2, PDB_DumpLevel::Normal);
Zachary Turnera952c492015-02-13 07:40:03 +000077 OS << "\n";
Zachary Turner2a5c0a22015-02-13 01:23:51 +000078 }
Zachary Turner21473f72015-02-08 00:29:29 +000079}