Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 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 | |
Zachary Turner | 52c9f88 | 2015-02-14 03:53:56 +0000 | [diff] [blame^] | 10 | #include "llvm/DebugInfo/PDB/PDBSymbolExe.h" |
| 11 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 12 | #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" |
| 13 | #include "llvm/DebugInfo/PDB/PDBExtras.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 14 | #include "llvm/DebugInfo/PDB/PDBSymbol.h" |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 15 | #include "llvm/Support/ConvertUTF.h" |
| 16 | #include "llvm/Support/FileSystem.h" |
| 17 | #include "llvm/Support/raw_ostream.h" |
Chandler Carruth | 71f308a | 2015-02-13 09:09:03 +0000 | [diff] [blame] | 18 | #include <utility> |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 19 | |
Zachary Turner | 52c9f88 | 2015-02-14 03:53:56 +0000 | [diff] [blame^] | 20 | #include <utility> |
| 21 | |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 22 | using namespace llvm; |
| 23 | |
Zachary Turner | 98571ed | 2015-02-08 22:53:53 +0000 | [diff] [blame] | 24 | PDBSymbolExe::PDBSymbolExe(const IPDBSession &PDBSession, |
Zachary Turner | bae16b3 | 2015-02-08 20:58:09 +0000 | [diff] [blame] | 25 | std::unique_ptr<IPDBRawSymbol> Symbol) |
| 26 | : PDBSymbol(PDBSession, std::move(Symbol)) {} |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 27 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 28 | void PDBSymbolExe::dump(raw_ostream &OS, int Indent, |
| 29 | PDB_DumpLevel Level) const { |
| 30 | std::string FileName(getSymbolsFileName()); |
| 31 | |
Zachary Turner | a952c49 | 2015-02-13 07:40:03 +0000 | [diff] [blame] | 32 | OS << stream_indent(Indent) << "Summary for " << FileName << "\n"; |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 33 | |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 34 | uint64_t FileSize = 0; |
| 35 | if (!llvm::sys::fs::file_size(FileName, FileSize)) |
Zachary Turner | a952c49 | 2015-02-13 07:40:03 +0000 | [diff] [blame] | 36 | OS << stream_indent(Indent + 2) << "Size: " << FileSize << " bytes\n"; |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 37 | else |
Zachary Turner | a952c49 | 2015-02-13 07:40:03 +0000 | [diff] [blame] | 38 | OS << stream_indent(Indent + 2) << "Size: (Unable to obtain file size)\n"; |
Zachary Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 39 | PDB_UniqueId Guid = getGuid(); |
Zachary Turner | a952c49 | 2015-02-13 07:40:03 +0000 | [diff] [blame] | 40 | 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 Turner | a554917 | 2015-02-10 22:43:25 +0000 | [diff] [blame] | 43 | if (hasCTypes()) |
| 44 | OS << "HasCTypes "; |
| 45 | if (hasPrivateSymbols()) |
| 46 | OS << "HasPrivateSymbols "; |
| 47 | OS << "\n"; |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame] | 48 | |
| 49 | TagStats Stats; |
| 50 | auto ChildrenEnum = getChildStats(Stats); |
| 51 | OS << stream_indent(Indent + 2) << "Children: " << Stats << "\n"; |
| 52 | while (auto Child = ChildrenEnum->getNext()) { |
Zachary Turner | 04b966d | 2015-02-13 17:57:09 +0000 | [diff] [blame] | 53 | // Skip uninteresting types. These are useful to print as part of type |
| 54 | // hierarchies, but as general children of the global scope, they are |
| 55 | // not very interesting. |
| 56 | switch (Child->getSymTag()) { |
| 57 | case PDB_SymType::ArrayType: |
| 58 | case PDB_SymType::BaseClass: |
| 59 | case PDB_SymType::BuiltinType: |
| 60 | case PDB_SymType::CompilandEnv: |
| 61 | case PDB_SymType::CustomType: |
| 62 | case PDB_SymType::Dimension: |
| 63 | case PDB_SymType::Friend: |
| 64 | case PDB_SymType::ManagedType: |
| 65 | case PDB_SymType::VTableShape: |
| 66 | case PDB_SymType::PointerType: |
| 67 | case PDB_SymType::FunctionSig: |
| 68 | case PDB_SymType::FunctionArg: |
| 69 | continue; |
| 70 | default: |
| 71 | break; |
| 72 | } |
Zachary Turner | a952c49 | 2015-02-13 07:40:03 +0000 | [diff] [blame] | 73 | Child->dump(OS, Indent + 4, PDB_DumpLevel::Normal); |
| 74 | OS << "\n"; |
Zachary Turner | 2a5c0a2 | 2015-02-13 01:23:51 +0000 | [diff] [blame] | 75 | } |
Zachary Turner | 21473f7 | 2015-02-08 00:29:29 +0000 | [diff] [blame] | 76 | } |